예제 #1
0
/**
 * Registers default options (lockers, popups, forms).
 * 
 * @since 1.0.0
 */
function opanda_add_meta_boxes()
{
    global $bizpanda;
    $type = OPanda_Items::getCurrentItem();
    if (empty($type)) {
        return;
    }
    $typeName = $type['name'];
    $data = array();
    if (OPanda_Items::isCurrentPremium()) {
        $data[] = array('class' => 'OPanda_BasicOptionsMetaBox', 'path' => OPANDA_BIZPANDA_DIR . '/includes/metaboxes/basic-options.php');
        $data[] = array('class' => 'OPanda_PreviewMetaBox', 'path' => OPANDA_BIZPANDA_DIR . '/includes/metaboxes/preview.php');
        $data[] = array('class' => 'OPanda_ManualLockingMetaBox', 'path' => OPANDA_BIZPANDA_DIR . '/includes/metaboxes/manual-locking.php');
        $data[] = array('class' => 'OPanda_BulkLockingMetaBox', 'path' => OPANDA_BIZPANDA_DIR . '/includes/metaboxes/bulk-locking.php');
        $data[] = array('class' => 'OPanda_VisabilityOptionsMetaBox', 'path' => OPANDA_BIZPANDA_DIR . '/includes/metaboxes/visability-options.php');
        $data[] = array('class' => 'OPanda_AdvancedOptionsMetaBox', 'path' => OPANDA_BIZPANDA_DIR . '/includes/metaboxes/advanced-options.php');
    } else {
        $data[] = array('class' => 'OPanda_BasicOptionsMetaBox', 'path' => OPANDA_BIZPANDA_DIR . '/includes/metaboxes/basic-options.php');
        $data[] = array('class' => 'OPanda_PreviewMetaBox', 'path' => OPANDA_BIZPANDA_DIR . '/includes/metaboxes/preview.php');
        $data[] = array('class' => 'OPanda_ManualLockingMetaBox', 'path' => OPANDA_BIZPANDA_DIR . '/includes/metaboxes/manual-locking.php');
        $data[] = array('class' => 'OPanda_BulkLockingMetaBox', 'path' => OPANDA_BIZPANDA_DIR . '/includes/metaboxes/bulk-locking.php');
    }
    $data = apply_filters("opanda_item_type_metaboxes", $data, $typeName);
    $data = apply_filters("opanda_{$typeName}_type_metaboxes", $data);
    foreach ($data as $metabox) {
        require_once $metabox['path'];
        FactoryMetaboxes321::registerFor(new $metabox['class']($bizpanda), OPANDA_POST_TYPE, $bizpanda);
    }
}
예제 #2
0
 /**
  * Registers the custom post type for the admin area.
  * 
  * @since 1.0.0
  * @return void
  */
 public function registerForAdmin()
 {
     $this->buildLables();
     $this->buildMessages();
     $metaboxes = array();
     $this->configure();
     // adds metaboxes that needed to load
     foreach ($this->metaboxes as $metabox) {
         FactoryMetaboxes321::registerFor($metabox, $this->name, $this->plugin);
     }
     if (!$this->scripts->isEmpty('bootstrap') || !$this->styles->isEmpty('bootstrap')) {
         add_action('factory_bootstrap_enqueue_scripts_' . $this->plugin->pluginName, array($this, 'actionAdminBootstrapScripts'));
     }
     // includes styles and scripts
     if (!$this->scripts->isEmpty() || !$this->styles->isEmpty()) {
         add_action('admin_enqueue_scripts', array($this, 'actionAdminScripts'));
     }
     // updates messages thats displays during changes
     add_filter('post_updated_messages', array($this, 'actionUpdatedMessages'));
     // redefines the Publish metabox for non-public types
     if ($this->template !== 'public') {
         //FactoryMetaboxes321::registerFor('FactoryMetaboxes321_PublishMetabox', $this->name);
         add_action('add_meta_boxes', array($this, 'actionAddMetaboxs'));
     }
     if (!empty($this->capabilities)) {
         $this->options['capability_type'] = $this->name;
         $this->options['capabilities'] = array('edit_post' => 'edit_' . $this->name, 'read_post' => 'read_' . $this->name, 'delete_post' => 'delete_' . $this->name, 'delete_posts' => 'delete_' . $this->name . 's', 'edit_posts' => 'edit_' . $this->name . 's', 'edit_others_posts' => 'edit_others_' . $this->name . 's', 'publish_posts' => 'publish_' . $this->name . 's', 'read_private_posts' => 'read_private_' . $this->name . 's', 'create_posts' => 'edit_' . $this->name . 's');
     } elseif ($this->options['capability_type'] == null) {
         $this->options['capability_type'] = 'post';
     }
     // register view table
     if (!empty($this->viewTable) && class_exists($this->viewTable)) {
         $this->viewTable = new $this->viewTable($this->plugin);
         $this->viewTable->connect($this);
     }
     // sets menu icon
     if (!empty($this->menu)) {
         add_action('admin_head', array($this, 'actionAdminHead'));
         if (!empty($this->menu->title)) {
             add_action('admin_menu', array($this, 'actionAdminMenu'));
         }
     }
     register_post_type($this->name, $this->options);
 }