ddevito
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: add_meta_box Callback Argument being distorted…oh ok, I understand. See under parameters and callback_args it states:
“Arguments to pass into your callback function. The callback will receive the $post object and whatever parameters are passed through this variable.”
So when I read whatever parameters are passed through I thought it was a direct pass of the parameter…
Anyway, thanks so much for your help my man!
Is there somewhere I can give you a gold star or something? haha
(you can mark as resolved!)
Forum: Fixing WordPress
In reply to: add_meta_box Callback Argument being distorted…class MetaBoxController{ /******************* * Variables ********************/ protected $arrConfig = array(); protected $arrMetabox = array(); protected $arrInput = array(); protected $numberOfMetaboxes = 0; protected $is_meta_array = false; protected $meta_array = array(); protected $is_meta_single = false; protected $meta_single = array(); /******************* * Variables END ********************/ /******************* * Initiates ********************/ //Passing through the array file through the CORE plugin using the method load_config() public function __construct(Config\I_Config $config) { $this->arrConfig = $config->load_config(); $this->initHooks(); foreach ($this->arrConfig as $value) { $this->numberOfMetaboxes = $this->numberOfMetaboxes + 1; } } public function init_single_array($metabox) { $this->is_meta_array = $metabox['isarray']; } //Starts everything public function initHooks() { add_action('add_meta_boxes', array($this, 'walkMetaBox')); add_action('save_post', array($this, 'walkForMetaKey')); } /******************* * Initiate end ********************/ /******************* * Working Functions Start ********************/ public function walkMetaBox() { array_walk($this->arrConfig, array($this, 'addMetabox')); } //While the array is walked, it applies this method to each key. //Creating all the metaboxes required according to the array file. public function addMetabox($settings) { add_meta_box( $settings['id'], $settings['title'], array($this, 'loadMetabox'), $settings['screen'], $settings['context'], $settings['priority'], $settings ); var_dump($settings); } //Eventually going to render the view file, and call on get_post_meta for data. public function loadMetabox($post, $settings) { var_dump($settings); }The first var dump, dumps out everything it’s suppose to. What it is suppose to dump out is the array from my previous post.
The second var dump (in my head) is suppose to dump out the exact same thing as I am just passing it the parameter. Yet it dumps out some of the Array it is suppose to, but nested within the array are the variables i have at the top of my class. These ones to be exact…
protected $arrConfig = array();
protected $arrMetabox = array();
protected $arrInput = array();protected $numberOfMetaboxes = 0;
Anyway, i thought it was quite strange.
Forum: Fixing WordPress
In reply to: add_meta_box Callback Argument being distorted…This is the array that is being walked….
return array( 'metabox1' => array( 'metabox_name' => 'metabox1', 'meta_single' => array(), 'meta_array' => array( 'meta_key' => '', 'meta_defaults' => array(), ), 'limit_to_page_id' => '', 'id' => '33', 'title' => 'Title Here', 'priority' => 'default',//Screen location (high, core, default or low) 'view' => 'view-test.php',//should be .php and an existing view file 'screen' => 'page', 'context' => 'normal', 'input' => array( //INDEXED: Must be the same as what is on the View File! 'txtName', ), ), 'metabox2' => array( 'metabox_name' => 'metabox2', 'meta_single' => array(), 'meta_array' => array( 'meta_key' => '', 'meta_defaults' => array(), ), 'limit_to_page_id' => '', 'id' => '44', 'title' => 'Title 2 Here', 'priority' => 'default', 'view' => 'view-test.php', 'screen' => 'post', 'context' => 'normal', 'input' => array( //INDEXED: Must be the same as what is on the View File! 'txtName' ), ), ); // end config arrayForum: Fixing WordPress
In reply to: add_meta_box Callback Argument being distorted…Essentially i am designing a plugin that generates metaboxes based off of what is in the array file.
Forum: Fixing WordPress
In reply to: add_meta_box Callback Argument being distorted…Thanks for the timely response!
Unfortunately i dont believe that is the case. This is because the arrConfig is actually its own file that returns an array, and has none of the things that are being “distorted”.
What i mean by this is that, the arrConfig when passed through somehow gets injected with empty array variables declared at the top of my class. That is using the arrConfig. the array file is being passed through on class instantiation in the constructor.
Maybe thats got something to do with it?
Thanks in advance!
@danielliser – I can’t use php to open a pop-up conditionally?
Bump!
I am trying to activate it with php, and do_shortcode does not seem to be working.