/**
  * Initiate the dashboard metaboxes.
  *
  * @access private
  * @since  0.8
  *
  * @return void
  */
 public static function init()
 {
     // Bail if doing an AJAX request.
     if (defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     // Build the array that defines the dashboard metaboxes.
     self::register();
     // Register the dashboard metaboxes the Metabox API.
     foreach (self::$metaboxes as $atts) {
         cnMetaboxAPI::add($atts);
     }
 }
 /**
  * Initiate the core metaboxes and fields.
  *
  * @access private
  * @since  0.8
  *
  * @return void
  */
 public static function init()
 {
     // Grab an instance of the Connections object.
     $instance = Connections_Directory();
     // Build the array that defines the core metaboxes.
     self::register();
     // Register the core metaboxes the Metabox API.
     foreach (self::$metaboxes as $atts) {
         cnMetaboxAPI::add($atts);
     }
     // Set the "Visibility" options that can be set by the current user.
     if (is_user_logged_in()) {
         self::$visibility = $instance->options->getVisibilityOptions();
     }
 }
Ejemplo n.º 3
0
 /**
  * Register the metaboxes with WordPress.
  *
  * NOTE: This method can be used to "late" register a metabox.
  * Meaning if you need to register a metabox right before render.
  * See the `manage.php` admin page file for a working example.
  *
  * @access public
  * @since 0.8
  * @uses add_meta_box()
  * @param string $pageHook The page hood / post type in which to add the metabox.
  * @param array  $metabox  The array of metaboxes to add. NOTE: Valid field options, @see cnMetaboxAPI::add().
  *
  * @return void
  */
 public static function add($pageHook, array $metabox)
 {
     // Bail if params are empty.
     if (empty($pageHook) || empty($metabox)) {
         return;
     }
     // Use the core metabox API to render the metabox unless the metabox was registered with a custom callback to be used to render the metabox.
     // $callback = isset( $metabox['callback'] ) && ! empty( $metabox['callback'] ) ? $metabox['callback'] : array( new cnMetabox_Render(), 'render' );
     if (is_admin()) {
         add_meta_box($metabox['id'], $metabox['title'], $metabox['callback'], $pageHook, $metabox['context'], $metabox['priority'], $metabox);
     } else {
         // self::$metaboxes[ $metabox['id'] ] = array(
         // 	'id'        => $metabox['id'],
         // 	'title'     => $metabox['title'],
         // 	'callback'  => $metabox['callback'],
         // 	'page_hook' => $pageHook,
         // 	'context'   => $metabox['context'],
         // 	'priority'  => $metabox['priority'],
         // 	'args'      => $metabox
         // 	);
         $metabox['field'] = isset($metabox['field']) && !empty($metabox['field']) ? $metabox['field'] : array('public');
         cnMetaboxAPI::add($metabox);
     }
 }
Ejemplo n.º 4
0
 /**
  * Registers the entry edit form metaboxes.
  *
  * This is deprecated method, left in place for backward compatibility only.
  *
  * NOTE: This should only be called by the "load-$page_hook" action.
  *
  * @access private
  * @deprecated
  * @since 0.8
  * @param string  $pageHook The page hook to add the entry edit metaboxes to.
  * @return void
  */
 public function registerEditMetaboxes($pageHook)
 {
     // Retrieve all metabox registered with cnMetaboxAPI.
     $metaboxes = cnMetaboxAPI::get();
     foreach ($metaboxes as $metabox) {
         $metabox['pages'] = array($pageHook);
         cnMetaboxAPI::add($metabox);
     }
     cnMetaboxAPI::register();
 }
Ejemplo n.º 5
0
function cn_register_custom_bio_and_text_field()
{
    $atts = array('title' => 'biog-highlights', 'id' => 'highlights_one', 'context' => 'normal', 'priority' => 'core', 'fields' => array(array('name' => 'Biography', 'show_label' => TRUE, 'id' => 'highlights_id', 'type' => 'text', 'size' => 'regular')));
    cnMetaboxAPI::add($atts);
}
 /**
  * Registered the custom metabox.
  *
  * @access private
  * @since  1.0
  * @static
  * @uses   levels()
  * @uses   cnMetaboxAPI::add()
  * @return void
  */
 public static function registerMetabox()
 {
     $atts = array('name' => __('Hobbies', 'connections_hobbies'), 'id' => 'hobbies', 'title' => __('Hobbies', 'connections_hobbies'), 'context' => 'side', 'priority' => 'core', 'fields' => array(array('id' => 'hobbies', 'type' => 'checkbox-group', 'options' => self::hobbies(), 'default' => '')));
     cnMetaboxAPI::add($atts);
 }