public function can_output()
 {
     $screen = '';
     $can = true;
     if (function_exists('get_current_screen')) {
         $screen = get_current_screen();
         $screen = $screen->id;
     }
     // if in post / page
     if (VP_Metabox::_is_post_or_page()) {
         // then consider the types
         if (!in_array("*", $this->types)) {
             // if wildcard exists, then always shows
             $can &= in_array(VP_Metabox::_get_current_post_type(), $this->types);
         } else {
             $can &= true;
         }
     } else {
         // if not, only consider the screen id
         if (!empty($screen)) {
             $can &= in_array($screen, $this->included_pages);
         } else {
             if (!is_admin()) {
                 $can &= false;
             }
         }
     }
     return $can;
 }
Example #2
0
 function vp_metabox($key, $default = null, $post_id = null)
 {
     global $post;
     $vp_metaboxes = VP_Metabox::get_pool();
     if (!is_null($post_id)) {
         $the_post = get_post($post_id);
         if (empty($the_post)) {
             $post_id = null;
         }
     }
     if (is_null($post) and is_null($post_id)) {
         return $default;
     }
     $keys = explode('.', $key);
     $temp = NULL;
     foreach ($keys as $idx => $key) {
         if ($idx == 0) {
             if (array_key_exists($key, $vp_metaboxes)) {
                 $temp = $vp_metaboxes[$key];
                 if (!is_null($post_id)) {
                     $temp->the_meta($post_id);
                 } else {
                     $temp->the_meta();
                 }
             } else {
                 return $default;
             }
         } else {
             if (is_object($temp) and get_class($temp) === 'VP_Metabox') {
                 $temp = $temp->get_the_value($key);
             } else {
                 if (is_array($temp) and array_key_exists($key, $temp)) {
                     $temp = $temp[$key];
                 } else {
                     return $default;
                 }
             }
         }
     }
     return $temp;
 }
Example #3
0
 public static function init_buttons()
 {
     if (VP_Metabox::_is_post_or_page() && !current_user_can('edit_posts') && !current_user_can('edit_pages') && get_user_option('rich_editing') == 'true') {
         return;
     }
     add_filter('mce_external_plugins', array(__CLASS__, 'add_buttons'));
     add_filter('mce_buttons', array(__CLASS__, 'register_buttons'));
     add_filter('wp_fullscreen_buttons', array(__CLASS__, 'fullscreen_buttons'));
     add_filter('admin_print_styles', array(__CLASS__, 'print_styles'));
 }