/**
  * Create the metaboxes for the available widgets
  *
  * @param $post_type
  * @param $post
  */
 public static function action_add_meta_boxes($post_type, $post)
 {
     global $_wp_post_type_features;
     $add_metas = false;
     if ($custom_meta_groups = array_keys(array_intersect_key($_wp_post_type_features[$post_type], Voce_Meta_API::GetInstance()->groups))) {
         foreach ($custom_meta_groups as $group_id) {
             if (count(Voce_Meta_API::GetInstance()->groups[$group_id]->fields)) {
                 foreach (Voce_Meta_API::GetInstance()->groups[$group_id]->fields as $field) {
                     if (!empty($field->field_type) && 'widget' == $field->field_type) {
                         $add_metas = true;
                         break 2;
                     }
                 }
             }
         }
     }
     if (!$add_metas) {
         return;
     }
     $location = apply_filters('voce_post_meta_widgets_widget_choices_location', 'side', $post_type, $post);
     $priority = apply_filters('voce_post_meta_widgets_widget_choices_priority', 'low', $post_type, $post);
     $callback = array(__CLASS__, 'sidebar_admin_metabox');
     add_meta_box('sidebar_admin', 'Sidebar Admin', $callback, $post_type, $location, $priority);
     $callback = array(__CLASS__, 'hidden_widgets_metabox');
     add_meta_box('voce_widgets_hidden', 'Widgets Hidden', $callback, $post_type, $location, $priority, $post);
 }
    /**
     * Public callback function to display HTML meta form field
     * @param object $field
     * @param string $value
     * @param int $post_id
     */
    function voce_date_field_display($field, $value, $post_id)
    {
        $defaults = array('max_date' => '', 'min_date' => '', 'max_date_field' => '', 'min_date_field' => '', 'default_text' => 'Select Date', 'default_date' => '', 'year_range' => '');
        $args = wp_parse_args($field->args, $defaults);
        $input_pattern = '<input type="text" class="datepicker" id="%s-formatted" data-default_text="%s" data-default_date="%s" data-max_date="%s" data-min_date="%s" data-max_date_field="%s" data-min_date_field="%s" data-year_range="%s" readonly />';
        ?>
	<p>
		<?php 
        voce_field_label_display($field);
        ?>
		<?php 
        printf($input_pattern, $field->get_input_id(), esc_attr($args['default_text']), esc_attr($args['default_date']), esc_attr($args['max_date']), esc_attr($args['min_date']), esc_attr($args['max_date_field']), esc_attr($args['min_date_field']), esc_attr($args['year_range']));
        ?>
		<input class="hidden" type="hidden" id="<?php 
        echo $field->get_input_id();
        ?>
" name="<?php 
        echo $field->get_name();
        ?>
" value="<?php 
        echo esc_attr($value);
        ?>
"  />
		<a href="#" class="submitdelete deletion voce-date-clear">Clear</a>
		<?php 
        echo !empty($field->description) ? '<br><span class="description">' . wp_kses($field->description, Voce_Meta_API::GetInstance()->description_allowed_html) . '</span>' : '';
        ?>
	</p>
	<?php 
    }
예제 #3
0
 /**
  * @method __call
  * @param string $name
  * @param array $func_args
  * @return null
  */
 public function __call($name, $func_args)
 {
     if (strpos($name, 'add_field_') === 0) {
         $type = substr($name, 10);
         $api = Voce_Meta_API::GetInstance();
         if (isset($api->type_mapping[$type])) {
             $mapping = $api->type_mapping[$type];
             $field_args = isset($func_args[2]) ? $func_args[2] : array();
             $field_args = wp_parse_args($field_args, $mapping['args']);
             return $this->add_field($mapping['class'], $func_args[0], $func_args[1], $field_args);
         }
         return null;
     }
 }