예제 #1
0
 /**
  * The wrapper display method.
  *
  * @param string $postType The postType name.
  * @return void
  */
 public function display($postType)
 {
     if ($this->check && !$this->user->can($this->capability)) {
         return;
     }
     // Look if a template is defined.
     // Display the metabox on pages/posts that have a template registered.
     if ($this->hasTemplate() && $postType == $this->datas['postType']) {
         // Fetch current ID (for cpts only).
         $postID = themosis_get_post_id();
         $template = get_post_meta($postID, '_themosisPageTemplate', true);
         // Check if a template is attached to the post/page.
         if ($template == $this->datas['options']['template']) {
             // Add a metabox for post/pages with a registered template.
             $this->addMetabox();
         }
     } else {
         // Add a metabox for no templates cases.
         $this->addMetabox();
     }
 }
예제 #2
0
 /**
  * A function that checks you're on a specified
  * admin page, post, or custom post type (edit) in order to display
  * a certain content.
  *
  * Example : Place a specific metabox for a page, a post or a one of your
  * custom post type.
  *
  * Give the post ID. Visible in the admin uri in your browser.
  *
  * @param int $id A WP_Post ID
  * @return bool True. False if not a WordPress post type.
  */
 function themosis_is_post($id)
 {
     $postId = themosis_get_post_id();
     if (!is_null($postId) && is_numeric($id) && $id === (int) $postId) {
         return true;
     }
     return false;
 }