There is a plugin I have installed that loads a metabox of an array ($requirements
) list of items in edit post.
When I print_r
the plugin's array it shows:
Array
(
[item1] => Array
(
[status] => 1
[label] => Excerpt has text
[value] => 1
[rule] => only_display
[type] => simple
)
[item2] => Array
(
[status] =>
[label] => Between 100 and 600 words
[value] => Array
(
[0] => 100
[1] => 600
)
[rule] => block
[type] => counter
)
)
I want to change the array and replace with my own array from within the functions.php on editing the post.
The Plugin's Class looks something like:
class MY_Checklist extends MY_Module
{
/**
* List of requirements, filled with instances of requirement classes.
* The list is indexed by post types.
*
* @var array
*/
protected $requirements = [];
/**
* List of post types which supports checklist
*
* @var array
*/
protected $post_types = [];
/**
* Instace for the module
*
* @var stdClass
*/
public $module;
/**
* Construct the MY_Checklist class
*/
public function __construct()
{
//.....
}
public function display_meta_box($post)
{
$requirements = []; //Array I want to change with my own
$requirements = apply_filters('my_checklist_requirement_list', $requirements, $post) // . <--- Array I want to change with my own
}
}
This is as far as I've gotten in my function.php and I am not sure what I am doing.
add_action( 'load-edit.php', 'change_checklist_array' );
function change_checklist_array() {
class MY_NEW_Checklist extends MY_Checklist {
function display_meta_box( $post ) {
$my_new_array = "...";
}
}
}
my_checklist_requirement_list
. You can read how filters work here: developer.wordpress.org/plugins/hooks/filtersadd_filter(my_checklist_requirement_list, change_checklist_array)
within my action or something?