callback) && !empty($this->id) && $this->title !== '' ) { if ($this->base->cache->doing_ajax) { add_filter(ACF_Stylizer_Constants::HOOK_VALIDATE_DATA, array($this, 'validate_data')); } else { $this->id = ACF_Stylizer_Constants::TOKEN . '_meta_box_' . $this->id; add_action('add_meta_boxes', array($this, 'add_meta_box')); add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'), 0); } } } /** * Get a default value based on the provided name. * * @since 2.0.0 * * @access protected * @param string $name Name of the value to return. * @return mixed Default value if it exists, otherwise an empty string. */ protected function _default($name) { switch ($name) { /** * Function used to populate the meta box. * * @since 2.0.0 * * @var function */ case 'callback': return array($this, 'callback'); /** * Data that should be set as the $args property of the box array. * * @since 2.0.0 * * @var array */ case 'callback_args': return null; /** * CSS classes added to the meta box. * * @since 2.0.0 * * @var array */ case 'classes': /** * Fields displayed in the meta box. * * @since 2.0.0 * * @var array */ case 'fields': /** * Value collection for the fields displayed in the meta box. * * @since 2.0.0 * * @var mixed */ case 'value_collection': return array(); /** * Context within the screen where the boxes should display. * * @since 2.0.0 * * @var string */ case 'context': return 'advanced'; /** * Base ID for the meta box. * * @since 2.0.0 * * @var string */ case 'id': /** * Title displayed in the meta box. * * @since 2.0.0 * * @var string */ case 'title': return ''; /** * Option name for the fields in the meta box. * * @since 2.0.0 * * @var string */ case 'option_name': return ACF_Stylizer_Constants::TOKEN; /** * Priority within the context where the boxes should show. * * @since 2.0.0 * * @var string */ case 'priority': return 'default'; } return parent::_default($name); } /** * Validate data associated with this meta box. * * @since 2.1.0 * * @access public * @param array $valid_data Existing validated data. * @return array Modified validated data. */ public function validate_data($valid_data) { if ( !empty($this->option_name) && isset($_POST[$this->option_name]) && is_array($_POST[$this->option_name]) ) { foreach ($this->fields as $field) { $valid_data = array_merge_recursive($valid_data, $field->validate_data($_POST[$this->option_name])); } } return $valid_data; } /** * Add the meta box to the page. * * @since 2.0.0 * * @access public * @return void */ public function add_meta_box() { $title = esc_html($this->title); add_meta_box($this->id, $title, $this->callback, $this->base->cache->screen, $this->context, $this->priority, $this->callback_args); add_filter('postbox_classes_' . esc_attr($this->base->cache->screen->id) . '_' . esc_attr($this->id), array($this, 'postbox_classes')); } /** * The default callback that is fired for the meta box when one isn't provided. * * @since 2.0.0 * * @access public * @return void */ public function callback() { echo '
'
)),
new ACF_Stylizer_Field_HTML(array
(
'content' => '' . __('Knowledge base available on', 'acf-stylizer') . '
'
)),
new ACF_Stylizer_Field_HTML(array
(
'content' => __('Running into issues with the plugin?', 'acf-stylizer') . '
'
. '
'
. ''
))
)
));
}
/**
* Finalize the meta boxes.
*
* @since 2.1.2 Removed PHP_INT_MAX reference.
* @since 2.0.0
*
* @access public static
* @return void
*/
public static function finalize_meta_boxes()
{
add_action('add_meta_boxes', array(__CLASS__, 'remove_meta_boxes'), 9999999);
do_action('add_meta_boxes', ACF_Stylizer()->cache->screen->id, null);
}
/**
* Remove unnecessary meta boxes.
*
* @since 2.0.0
*
* @access public static
* @return void
*/
public static function remove_meta_boxes()
{
$acfs = ACF_Stylizer();
remove_meta_box('eg-meta-box', $acfs->cache->screen->id, 'normal');
remove_meta_box('mymetabox_revslider_0', $acfs->cache->screen->id, 'normal');
}
}