Ejemplo n.º 1
0
 /**
  * Constructor for the modal class.
  *
  * @param string $handle A slug-like definition of the modal.
  * @param array $fields An array containing a default set of fields that belong to the modal.
  * @param array $data An array containing the data for the fields that belong to the modal.
  * @param array $config Optional configuration array.
  * @since 0.1.0
  */
 function __construct($handle, $fields = array(), $data = array(), $config = array())
 {
     $this->_data = stripslashes_deep($data);
     $this->_config = wp_parse_args($config, array('title' => __('Edit', 'ev_framework'), 'title_controls' => '', 'button' => __('OK', 'ev_framework'), 'button_nonce' => wp_create_nonce("ev_modal_{$handle}"), 'footer_content' => ''));
     $title = isset($this->_config['title']) ? $this->_config['title'] : '';
     parent::__construct($handle, $title, $fields);
 }
 /**
  * Constructor for the meta box class. Per WordPress Developer documentation
  * the method also binds the "register" method of the class to the
  * "add_meta_boxes" action on admin.
  *
  * @param string $handle A slug-like definition of the meta box.
  * @param string $title A human-readable definition of the meta box.
  * @param array $post_types An array of post types that should display the meta box.
  * @param array $fields An array containing a default set of fields that belong to the meta box.
  * @since 0.1.0
  */
 function __construct($handle, $title, $post_types = 'post', $fields = array())
 {
     $post_types = apply_filters("ev_metabox_post_types[metabox:{$handle}]", (array) $post_types);
     $this->_post_types = (array) $post_types;
     parent::__construct($handle, $title, $fields);
     /* Register the meta box in WordPress. */
     add_action('add_meta_boxes', array($this, 'register'));
     /* Register the saving action. */
     add_action('save_post', array($this, 'save'));
 }
 /**
  * Constructor for the user meta box class.
  *
  * @param string $handle A slug-like definition of the user meta box.
  * @param string $title A human-readable definition of the user meta box.
  * @param array $roles An array of roles that should display the user meta box.
  * @param array $fields An array containing a default set of fields that belong to the user meta box.
  * @since 0.2.0
  */
 function __construct($handle, $title, $roles = array(), $fields = array())
 {
     $roles = apply_filters("ev_user_metabox_roles[metabox:{$handle}]", $roles);
     $this->_roles = $roles;
     parent::__construct($handle, $title, $fields);
     /* Register the user meta box in WordPress. */
     add_action('show_user_profile', array($this, 'render'));
     add_action('edit_user_profile', array($this, 'render'));
     /* Register the saving action. */
     add_action('personal_options_update', array($this, 'save'));
     add_action('edit_user_profile_update', array($this, 'save'));
 }
Ejemplo n.º 4
0
 /**
  * Constructor for the admin page class. Per WordPress Developer documentation
  * the method also binds the "register" method of the class to the
  * "admin_menu" action on admin.
  *
  * @param string $handle A slug-like definition of the page.
  * @param string $title A human-readable definition of the page.
  * @param array $fields An array containing a default set of fields that belong to the admin page.
  * @param array $args An array containing a set of arguments that define the admin page.
  * @since 0.1.0
  */
 function __construct($handle, $title, $fields = array(), $args = array())
 {
     $this->_args = $args;
     parent::__construct($handle, $title, $fields);
     /* Register the admin page in WordPress. */
     add_action('admin_menu', array($this, 'register'));
     if (isset($this->_args['group']) && !empty($this->_args['group'])) {
         /* If a group is set for the page, store the information in the system. */
         add_filter('ev_admin_pages_groups', array($this, 'group'));
     }
     /* Register the saving action for the page tabs. */
     add_action("ev_save_options_tab[page:{$this->handle()}]", array($this, 'save'));
 }
 /**
  * Constructor for the taxonomy meta box class.
  *
  * @param string $handle A slug-like definition of the taxonomy meta box.
  * @param string $title A human-readable definition of the taxonomy meta box.
  * @param array $taxonomies An array of roles that should display the taxonomy meta box.
  * @param array $fields An array containing a default set of fields that belong to the taxonomy meta box.
  * @since 0.4.0
  */
 function __construct($handle, $title, $taxonomies = array(), $fields = array())
 {
     $taxonomies = apply_filters("ev_taxonomy_metabox_taxonomies[metabox:{$handle}]", $taxonomies);
     $this->_taxonomies = (array) $taxonomies;
     parent::__construct($handle, $title, $fields);
     /* Register the taxonomy meta box in WordPress. */
     foreach ($this->_taxonomies as $taxonomy) {
         // add_action( "{$taxonomy}_add_form_fields", array( $this, 'render' ), 10, 2 );
         add_action("{$taxonomy}_edit_form", array($this, 'render'), 10, 2);
     }
     /* Register the saving action. */
     foreach ($this->_taxonomies as $taxonomy) {
         add_action("edited_{$taxonomy}", array($this, 'save'), 10, 2);
         add_action("create_{$taxonomy}", array($this, 'save'), 10, 2);
     }
 }