allow_custom_field_edits

Allows editing of the meta fields through weblog editors like Marsedit.

Description

(array) allow_custom_field_edits( (array) $allcaps, (array) $cap, (array) $args ); 

Returns (array)

$allcaps

Parameters (3)

0. $allcaps (array)
Capabilities that must all be true to allow action.
1. $cap (array)
Array of capabilities to be checked, unused here.
2. $args (array)
List of arguments for the specific cap to be checked.

Usage

  1. if ( !function_exists( 'allow_custom_field_edits' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'yoast-seo/inc/wpseo-non-ajax-functions.php'; 
  3.  
  4. // Capabilities that must all be true to allow action. 
  5. $allcaps = array(); 
  6.  
  7. // Array of capabilities to be checked, unused here. 
  8. $cap = array(); 
  9.  
  10. // List of arguments for the specific cap to be checked. 
  11. $args = array(); 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = allow_custom_field_edits($allcaps, $cap, $args); 
  15.  

Defined (1)

The function is defined in the following location(s).

/inc/wpseo-non-ajax-functions.php  
  1. function allow_custom_field_edits( $allcaps, $cap, $args ) { 
  2. // $args[0] holds the capability. 
  3. // $args[2] holds the post ID. 
  4. // $args[3] holds the custom field. 
  5. // Make sure the request is to edit or add a post meta (this is usually also the second value in $cap,  
  6. // but this is safer to check). 
  7. if ( in_array( $args[0], array( 'edit_post_meta', 'add_post_meta' ) ) ) { 
  8. // Only allow editing rights for users who have the rights to edit this post and make sure 
  9. // the meta value starts with _yoast_wpseo (WPSEO_Meta::$meta_prefix). 
  10. if ( ( isset( $args[2] ) && current_user_can( 'edit_post', $args[2] ) ) && ( ( isset( $args[3] ) && $args[3] !== '' ) && strpos( $args[3], WPSEO_Meta::$meta_prefix ) === 0 ) ) { 
  11. $allcaps[ $args[0] ] = true; 
  12.  
  13. return $allcaps;