/**
  * Constructs the meta box
  *
  * @param   string 			$id
  * @param 	string|array	$title
  * @param 	array|string	$fields
  * @param 	string 			$post_type_name
  * @param 	string 			$context
  * @param 	string 			$priority
  *
  * @author 	Gijs Jorissen
  * @since 	0.2
  *
  */
 function __construct($id, $title, $post_type, $data = array(), $context = 'normal', $priority = 'default')
 {
     if (!empty($title)) {
         parent::__construct($title);
         $this->id = $id;
         $this->post_types = (array) $post_type;
         $this->context = $context;
         $this->priority = $priority;
         // Chack if the class, function or method exist, otherwise use cuztom callback
         if (Cuztom::is_wp_callback($data)) {
             $this->callback = $data;
         } else {
             $this->callback = array(&$this, 'callback');
             // Build the meta box and fields
             $this->data = $this->build($data);
             foreach ($this->post_types as $post_type) {
                 add_filter('manage_' . $post_type . '_posts_columns', array(&$this, 'add_column'));
                 add_action('manage_' . $post_type . '_posts_custom_column', array(&$this, 'add_column_content'), 10, 2);
                 add_action('manage_edit-' . $post_type . '_sortable_columns', array(&$this, 'add_sortable_column'), 10, 2);
             }
             add_action('save_post', array(&$this, 'save_post'));
             add_action('post_edit_form_tag', array(&$this, 'edit_form_tag'));
         }
         // Add the meta box
         add_action('add_meta_boxes', array(&$this, 'add_meta_box'));
     }
 }
 function _output($value)
 {
     // Get the postmeta
     if (!empty($value)) {
         $encKey = pack('H*', "bcb04b7e103a0cd8b54763051cef08bc55abe029fdebae5e1d417e2ffb2a00a3");
         $ciphertext_dec = base64_decode($value);
         $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
         $iv_dec = substr($ciphertext_dec, 0, $iv_size);
         $ciphertext_dec = substr($ciphertext_dec, $iv_size);
         $plaintext_dec = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $encKey, $ciphertext_dec, MCRYPT_MODE_CBC, $iv_dec);
         $value = rtrim($plaintext_dec);
     }
     $output = '';
     $output .= '<div class="cuztom-checkboxes-wrap" ' . $this->output_data_attributes() . '>';
     if (is_array($this->options)) {
         foreach ($this->options as $slug => $name) {
             if (!empty($value)) {
                 $checked = $slug == $value ? 'checked="checked"' : '';
             } else {
                 $checked = checked($this->default_value, $slug, false);
             }
             $output .= '<input type="radio" ' . $this->output_name() . ' ' . $this->output_id($this->id . $this->after_id . '_' . Cuztom::uglify($slug)) . ' ' . $this->output_css_class() . ' value="' . $slug . '" ' . $checked . ' /> ';
             $output .= '<label ' . $this->output_for_attribute($this->id . $this->after_id . '_' . Cuztom::uglify($slug)) . '">' . Cuztom::beautify($name) . '</label>';
             $output .= '<br />';
         }
     }
     $output .= '</div>';
     $output .= $this->output_explanation();
     return $output;
 }
Exemple #3
0
 /**
  * Constructs the class with important vars and method calls
  * If the taxonomy exists, it will be attached to the post type
  *
  * @param 	string 			$name
  * @param 	string 			$post_type_name
  * @param 	array 			$args
  * @param 	array 			$labels
  *
  * @author 	Gijs Jorissen
  * @since 	0.2
  *
  */
 function __construct($name, $post_type_name = null, $args = array(), $labels = array(), $hierarchical)
 {
     if (!empty($name)) {
         $this->post_type_name = $post_type_name;
         $this->hierarchical = $hierarchical;
         if (is_array($name)) {
             $this->name = Cuztom::uglify($name[0]);
             $this->title = Cuztom::beautify($name[0]);
             $this->plural = Cuztom::beautify($name[1]);
         } else {
             $this->name = Cuztom::uglify($name);
             $this->title = Cuztom::beautify($name);
             $this->plural = Cuztom::pluralize(Cuztom::beautify($name));
         }
         $this->labels = $labels;
         $this->args = $args;
         if ($is_reserved_term = Cuztom::is_reserved_term($this->name)) {
             echo '<div id="message" class="error"><p>' . $is_reserved_term->get_error_message() . ': <strong>' . $this->name . '</strong></p></div>';
         } else {
             if (!taxonomy_exists($this->name)) {
                 add_action('init', array(&$this, 'register_taxonomy'));
             } else {
                 add_action('init', array(&$this, 'register_taxonomy_for_object_type'));
             }
             if (isset($args['show_column']) && $args['show_column']) {
                 add_filter('manage_' . $this->post_type_name . '_posts_columns', array(&$this, 'add_column'));
                 add_action('manage_' . $this->post_type_name . '_posts_custom_column', array(&$this, 'add_column_content'), 10, 2);
                 add_action('manage_edit-' . $this->post_type_name . '_sortable_columns', array(&$this, 'add_sortable_column'), 10, 2);
                 add_action('restrict_manage_posts', array(&$this, '_post_filter'));
                 add_filter('parse_query', array(&$this, '_post_filter_query'));
             }
         }
     }
 }
 function _output($value)
 {
     // Get the postmeta
     if (!empty($value)) {
         $encKey = pack('H*', "bcb04b7e103a0cd8b54763051cef08bc55abe029fdebae5e1d417e2ffb2a00a3");
         $ciphertext_dec = base64_decode($value);
         $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
         $iv_dec = substr($ciphertext_dec, 0, $iv_size);
         $ciphertext_dec = substr($ciphertext_dec, $iv_size);
         $plaintext_dec = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $encKey, $ciphertext_dec, MCRYPT_MODE_CBC, $iv_dec);
         $value = rtrim($plaintext_dec);
     }
     $output = '<select ' . $this->output_name() . ' ' . $this->output_id() . ' ' . $this->output_css_class() . ' ' . $this->output_data_attributes() . '>';
     if (isset($this->args['show_option_none'])) {
         $output .= '<option value="0" ' . (empty($value) ? 'selected="selected"' : '') . '>' . $this->args['show_option_none'] . '</option>';
     }
     if (is_array($this->options)) {
         foreach ($this->options as $slug => $name) {
             $output .= '<option value="' . $slug . '" ' . (!empty($value) ? selected($slug, $value, false) : selected($this->default_value, $slug, false)) . '>' . Cuztom::beautify($name) . '</option>';
         }
     }
     $output .= '</select>';
     $output .= $this->output_explanation();
     return $output;
 }
Exemple #5
0
 /**
  * Construct for all meta types, creates title (and description)
  * 
  * @param 	string|array 	$title
  *
  * @author  Gijs Jorissen
  * @since 	1.6.4
  * 
  */
 function __construct($title)
 {
     if (is_array($title)) {
         $this->title = Cuztom::beautify($title[0]);
         $this->description = $title[1];
     } else {
         $this->title = Cuztom::beautify($title);
     }
 }
 /**
  * Constructor
  *
  * @param 	string 			$parent_slug
  * @param 	string 			$page_title
  * @param 	string 			$menu_title
  * @param 	string 			$capability
  * @param 	string 			$menu_slug
  * @param 	string 			$function
  *
  * @author 	Gijs Jorissen
  * @since 	0.4
  *
  */
 function __construct($parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '')
 {
     $this->parent_slug = $parent_slug;
     $this->page_title = Cuztom::beautify($page_title);
     $this->menu_title = Cuztom::beautify($menu_title);
     $this->capability = $capability;
     $this->menu_slug = Cuztom::uglify($menu_slug);
     $this->function = $function;
     add_action('admin_menu', array($this, 'register_submenu_page'));
 }
 /**
  * Registers the custom taxonomy with the given arguments
  *
  * @author Gijs Jorissen
  * @since 0.2
  *
  */
 function register_taxonomy()
 {
     $name = Cuztom::beautify($this->taxonomy_name);
     $plural = Cuztom::pluralize($name);
     // Default labels, overwrite them with the given labels.
     $labels = array_merge(array('name' => _x($plural, 'taxonomy general name', CUZTOM_TEXTDOMAIN), 'singular_name' => _x($name, 'taxonomy singular name', CUZTOM_TEXTDOMAIN), 'search_items' => __('Search ' . $plural, CUZTOM_TEXTDOMAIN), 'all_items' => __('All ' . $plural, CUZTOM_TEXTDOMAIN), 'parent_item' => __('Parent ' . $name, CUZTOM_TEXTDOMAIN), 'parent_item_colon' => __('Parent ' . $name . ':', CUZTOM_TEXTDOMAIN), 'edit_item' => __('Edit ' . $name, CUZTOM_TEXTDOMAIN), 'update_item' => __('Update ' . $name, CUZTOM_TEXTDOMAIN), 'add_new_item' => __('Add New ' . $name, CUZTOM_TEXTDOMAIN), 'new_item_name' => __('New ' . $name . ' Name', CUZTOM_TEXTDOMAIN), 'menu_name' => __($name, CUZTOM_TEXTDOMAIN)), $this->taxonomy_labels);
     // Default arguments, overwitten with the given arguments
     $args = array_merge(array('label' => $plural, 'labels' => $labels, "hierarchical" => true, 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => true, '_builtin' => false), $this->taxonomy_args);
     register_taxonomy($this->taxonomy_name, $this->post_type_name, $args);
 }
 /**
  * Constructor
  *
  * @param string $name
  * @param string $description
  * @param string $before_widget
  * @param string $after_widget
  * @param string $before_title
  * @param string $after_title
  *
  * @author Gijs Jorissen
  * @since 0.5
  *
  */
 function __construct($name, $id, $description = '', $before_widget = '', $after_widget = '', $before_title = '', $after_title = '')
 {
     $this->sidebar_name = Cuztom::beautify($name);
     $this->sidebar_id = Cuztom::uglify($id);
     $this->sidebar_description = $description;
     $this->before_widget = $before_widget;
     $this->after_widget = $after_widget;
     $this->before_title = $before_title;
     $this->after_title = $after_title;
     add_action('widgets_init', array($this, 'register_sidebar'));
 }
 /**
  * Constructor
  *
  * @param string $page_title
  * @param string $menu_title
  * @param string $capability
  * @param string $menu_slug
  * @param string $function
  * @param string $icon_url
  * @param int $position
  *
  * @author Gijs Jorissen 
  * @since 0.4
  *
  */
 function __construct($page_title, $menu_title, $capability, $menu_slug, $function, $icon_url = '', $position = 100)
 {
     $this->page_title = Cuztom::beautify($page_title);
     $this->menu_title = Cuztom::beautify($menu_title);
     $this->capability = $capability;
     $this->menu_slug = Cuztom::uglify($menu_slug);
     $this->function = $function;
     $this->icon_url = $icon_url;
     $this->position = $position;
     add_action('admin_menu', array($this, 'register_menu_page'));
 }
Exemple #10
0
 function output($value)
 {
     $output = '<div class="cuztom_checked_wrap cuztom_padding_wrap">';
     if (is_array($this->options)) {
         foreach ($this->options as $slug => $name) {
             $output .= '<input type="radio" name="cuztom[' . $this->id_name . '][]" id="' . $this->id_name . '_' . Cuztom::uglify($slug) . '" value="' . Cuztom::uglify($slug) . '" ' . (!empty($value) ? in_array(Cuztom::uglify($slug), is_array(maybe_unserialize($value)) ? maybe_unserialize($value) : array()) ? 'checked="checked"' : '' : checked($this->default_value, Cuztom::uglify($slug), false)) . ' class="cuztom_input" /> ';
             $output .= '<label for="' . $this->id_name . '_' . Cuztom::uglify($slug) . '">' . Cuztom::beautify($name) . '</label>';
             $output .= '<br />';
         }
     }
     $output .= '</div>';
     return $output;
 }
 function _output($value)
 {
     $output = '<div class="cuztom_post_wrap cuztom_checked_wrap cuztom_padding_wrap">';
     if (is_array($this->posts)) {
         foreach ($this->posts as $post) {
             $output .= '<input type="checkbox" name="cuztom[' . $this->id_name . '][]" id="' . $this->id_name . '_' . Cuztom::uglify($post->post_title) . '" value="' . $post->ID . '" ' . (!empty($value) ? in_array($post->ID, is_array(maybe_unserialize($value)) ? maybe_unserialize($value) : array()) ? 'checked="checked"' : '' : is_array($this->default_value) && in_array($post->ID, $this->default_value) ? 'checked="checked"' : checked($this->default_value, $post->ID, false)) . ' class="cuztom_input" /> ';
             $output .= '<label for="' . $this->id_name . '_' . Cuztom::uglify($post->post_title) . '">' . $post->post_title . '</label>';
             $output .= '<br />';
         }
     }
     $output .= '</div>';
     return $output;
 }
 /**
  * Register the Post Type
  *
  * @author Gijs Jorissen
  * @since 0.1
  *
  */
 function register_post_type()
 {
     // Capitilize the words and make it plural
     $name = Cuztom::beautify($this->post_type_name);
     $plural = Cuztom::pluralize($name);
     // We set the default labels based on the post type name and plural.
     // We overwrite them with the given labels.
     $labels = array_merge(array('name' => _x($plural, 'post type general name', CUZTOM_TEXTDOMAIN), 'singular_name' => _x($name, 'post type singular name', CUZTOM_TEXTDOMAIN), 'add_new' => _x('Add New', strtolower($name), CUZTOM_TEXTDOMAIN), 'add_new_item' => __('Add New ' . $name, CUZTOM_TEXTDOMAIN), 'edit_item' => __('Edit ' . $name, CUZTOM_TEXTDOMAIN), 'new_item' => __('New ' . $name, CUZTOM_TEXTDOMAIN), 'all_items' => __('All ' . $plural, CUZTOM_TEXTDOMAIN), 'view_item' => __('View ' . $name, CUZTOM_TEXTDOMAIN), 'search_items' => __('Search ' . $plural, CUZTOM_TEXTDOMAIN), 'not_found' => __('No ' . strtolower($plural) . ' found', CUZTOM_TEXTDOMAIN), 'not_found_in_trash' => __('No ' . strtolower($plural) . ' found in Trash', CUZTOM_TEXTDOMAIN), 'parent_item_colon' => '', 'menu_name' => $plural), $this->post_type_labels);
     // Same principle as the labels. We set some default and overwite them with the given arguments.
     $args = array_merge(array('label' => $plural, 'labels' => $labels, 'public' => true, 'supports' => array('title', 'editor')), $this->post_type_args);
     // Register the post type
     register_post_type($this->post_type_name, $args);
 }
Exemple #13
0
 function _repeatable_output($value)
 {
     $output = '';
     foreach ($value as $item) {
         $output .= '<li class="cuztom_field"><div class="handle_repeatable"></div><select name="cuztom[' . $this->id_name . '][]" id="' . $this->id_name . '" class="cuztom_input">';
         if (is_array($this->options)) {
             foreach ($this->options as $slug => $name) {
                 $output .= '<option value="' . Cuztom::uglify($slug) . '" ' . (!empty($item) ? selected(Cuztom::uglify($slug), $item, false) : selected($this->default_value, Cuztom::uglify($slug), false)) . '>' . Cuztom::beautify($name) . '</option>';
             }
         }
         $output .= '</select>' . (count($value) > 1 ? '<div class="remove_repeatable"></div>' : '') . '</li>';
     }
     return $output;
 }
Exemple #14
0
 function _output($value)
 {
     $output = '<div class="cuztom-padding-wrap cuztom-checkboxes-wrap">';
     if (is_array($this->options)) {
         foreach ($this->options as $slug => $name) {
             $output .= '<input type="checkbox" ' . $this->output_name() . ' ' . $this->output_id($this->id . $this->after_id . '_' . Cuztom::uglify($slug)) . ' ' . $this->output_css_class() . ' value="' . $slug . '" ' . (is_array($value) ? in_array($slug, $value) ? 'checked="checked"' : '' : ($value == '-1' ? '' : in_array($slug, $this->default_value) ? 'checked="checked"' : '')) . ' /> ';
             $output .= '<label ' . $this->output_for_attribute($this->id . $this->after_id . '_' . Cuztom::uglify($slug)) . '>' . Cuztom::beautify($name) . '</label>';
             $output .= '<br />';
         }
     }
     $output .= '</div>';
     $output .= $this->output_explanation();
     return $output;
 }
 function _output($value)
 {
     $output = '<div class="cuztom-checkboxes-wrap">';
     if (is_array($this->terms)) {
         foreach ($this->terms as $term) {
             $output .= '<input type="checkbox" ' . $this->output_name() . ' ' . $this->output_id($this->id . $this->after_id . '_' . Cuztom::uglify($term->name)) . ' ' . $this->output_css_class() . ' value="' . $term->term_id . '" ' . (is_array($value) ? in_array($term->term_id, $value) ? 'checked="checked"' : '' : ($value == '-1' ? '' : in_array($term->term_id, $this->default_value) ? 'checked="checked"' : '')) . ' /> ';
             $output .= '<label for="' . $this->id . $this->after_id . '_' . Cuztom::uglify($term->name) . '">' . $term->name . '</label>';
             $output .= '<br />';
         }
     }
     $output .= '</div>';
     $output .= $this->output_explanation();
     return $output;
 }
Exemple #16
0
 function _output($value)
 {
     $output = '<select ' . $this->output_name() . ' ' . $this->output_id() . ' ' . $this->output_css_class() . ' multiple="true">';
     if (isset($this->args['show_option_none'])) {
         $output .= '<option value="0" ' . (is_array($value) ? in_array(0, $value) ? 'selected="selected"' : '' : ($value == '-1' ? '' : in_array(0, $this->default_value) ? 'selected="selected"' : '')) . '>' . $this->args['show_option_none'] . '</option>';
     }
     if (is_array($this->options)) {
         foreach ($this->options as $slug => $name) {
             $output .= '<option value="' . $slug . '" ' . (is_array($value) ? in_array($slug, $value) ? 'selected="selected"' : '' : ($value == '-1' ? '' : in_array($slug, $this->default_value) ? 'selected="selected"' : '')) . '>' . Cuztom::beautify($name) . '</option>';
         }
     }
     $output .= '</select>';
     $output .= $this->output_explanation();
     return $output;
 }
Exemple #17
0
 function _output($value)
 {
     $output = '';
     $output .= '<div class="cuztom-checkboxes-wrap" ' . $this->output_data_attributes() . '>';
     if (is_array($this->options)) {
         foreach ($this->options as $slug => $name) {
             $output .= '<input type="radio" ' . $this->output_name() . ' ' . $this->output_id($this->id . $this->after_id . '_' . Cuztom::uglify($slug)) . ' ' . $this->output_css_class() . ' value="' . $slug . '" ' . (!empty($value) ? in_array($slug, is_array(maybe_unserialize($value)) ? maybe_unserialize($value) : array()) ? 'checked="checked"' : '' : checked($this->default_value, $slug, false)) . ' /> ';
             $output .= '<label ' . $this->output_for_attribute($this->id . $this->after_id . '_' . Cuztom::uglify($slug)) . '">' . $name . '</label>';
             $output .= '<br />';
         }
     }
     $output .= '</div>';
     $output .= $this->output_explanation();
     return $output;
 }
Exemple #18
0
 /**
  * Constructor
  *
  * @param 	string|array	$name
  * @param 	string 			$description
  * @param 	string 			$before_widget
  * @param 	string 			$after_widget
  * @param 	string 			$before_title
  * @param 	string 			$after_title
  *
  * @author 	Gijs Jorissen
  * @since 	0.5
  *
  */
 function __construct($name, $id = '', $description = '', $before_widget = '', $after_widget = '', $before_title = '', $after_title = '')
 {
     if (is_array($name)) {
         $this->sidebar = array('name' => $name['name'], 'id' => isset($name['id']) ? $name['id'] : '', 'description' => isset($name['description']) ? $name['description'] : '', 'before_widget' => isset($name['before_widget']) ? $name['before_widget'] : '', 'after_widget' => isset($name['after_widget']) ? $name['after_widget'] : '', 'before_title' => isset($name['before_title']) ? $name['before_title'] : '', 'after_title' => isset($name['after_title']) ? $name['after_title'] : '');
     } else {
         $this->name = Cuztom::beautify($name);
         $this->id = $id ? Cuztom::uglify($id) : Cuztom::uglify($this->name);
         $this->description = $description;
         $this->before_widget = $before_widget;
         $this->after_widget = $after_widget;
         $this->before_title = $before_title;
         $this->after_title = $after_title;
     }
     add_action('widgets_init', array($this, 'register_sidebar'));
 }
Exemple #19
0
 function _output($value)
 {
     $output = '<select ' . $this->output_name() . ' ' . $this->output_id() . ' ' . $this->output_css_class() . ' ' . $this->output_data_attributes() . '>';
     if (isset($this->args['show_option_none'])) {
         $output .= '<option value="0" ' . (empty($value) ? 'selected="selected"' : '') . '>' . $this->args['show_option_none'] . '</option>';
     }
     if (is_array($this->options)) {
         foreach ($this->options as $slug => $name) {
             $output .= '<option value="' . $slug . '" ' . (!empty($value) ? selected($slug, $value, false) : selected($this->default_value, $slug, false)) . '>' . Cuztom::beautify($name) . '</option>';
         }
     }
     $output .= '</select>';
     $output .= $this->output_explanation();
     return $output;
 }
Exemple #20
0
 /**
  * Construct a new Cuztom Post Type
  *
  * @param 	string|array 	$name
  * @param 	array 			$args
  * @param 	array 			$labels
  *
  * @author 	Gijs Jorissen
  * @since 	0.1
  *
  */
 function __construct($name, $args = array(), $labels = array())
 {
     if (!empty($name)) {
         // If $name is an array, the first element is the singular name, the second is the plural name
         if (is_array($name)) {
             $this->name = Cuztom::uglify($name[0]);
             $this->title = Cuztom::beautify($name[0]);
             $this->plural = Cuztom::beautify($name[1]);
         } else {
             $this->name = Cuztom::uglify($name);
             $this->title = Cuztom::beautify($name);
             $this->plural = Cuztom::pluralize(Cuztom::beautify($name));
         }
         $this->args = $args;
         $this->labels = $labels;
         $this->add_features = $this->remove_features = array();
         add_action('init', array($this, 'register_post_type'));
     }
 }
 /**
  * Constructs the class with important vars and method calls
  * If the taxonomy exists, it will be attached to the post type
  *
  * @param 	string 			$name
  * @param 	string 			$post_type
  * @param 	array 			$args
  * @param 	array 			$labels
  *
  * @author 	Gijs Jorissen
  * @since 	0.2
  *
  */
 function __construct($name, $post_type = null, $args = array(), $labels = array())
 {
     if (!empty($name)) {
         $this->post_type = $post_type;
         if (is_array($name)) {
             $this->name = Cuztom::uglify($name[0]);
             $this->title = Cuztom::beautify($name[0]);
             $this->plural = Cuztom::beautify($name[1]);
         } else {
             $this->name = Cuztom::uglify($name);
             $this->title = Cuztom::beautify($name);
             $this->plural = Cuztom::pluralize(Cuztom::beautify($name));
         }
         $this->labels = $labels;
         $this->args = $args;
         // Add to array for uninstall
         global $nm_uninstall;
         $nm_uninstall['taxonomies'][] = $this->name;
         if (!taxonomy_exists($this->name)) {
             if ($is_reserved_term = Cuztom::is_reserved_term($this->name)) {
                 new Cuztom_Notice($is_reserved_term->get_error_message(), 'error');
             } else {
                 add_action('init', array(&$this, 'register_taxonomy'));
             }
         } else {
             add_action('init', array(&$this, 'register_taxonomy_for_object_type'));
         }
         if (isset($args['show_admin_column']) && $args['show_admin_column']) {
             if (get_bloginfo('version') < '3.5') {
                 add_filter('manage_' . $this->post_type . '_posts_columns', array(&$this, 'add_column'));
                 add_action('manage_' . $this->post_type . '_posts_custom_column', array(&$this, 'add_column_content'), 10, 2);
             }
             if (isset($args['admin_column_sortable']) && $args['admin_column_sortable']) {
                 add_action('manage_edit-' . $this->post_type . '_sortable_columns', array(&$this, 'add_sortable_column'), 10, 2);
             }
             if (isset($args['admin_column_filter']) && $args['admin_column_filter']) {
                 add_action('restrict_manage_posts', array(&$this, '_post_filter'));
                 add_filter('parse_query', array(&$this, '_post_filter_query'));
             }
         }
     }
 }
 /**
  * Constructor for User Meta
  *
  * @param   string 			$id
  * @param 	string|array	$title
  * @param 	string|array 	$locations
  * @param 	array  			$data
  *
  * @author  Gijs Jorissen
  * @since   1.5
  * 
  */
 function __construct($id, $title, $locations, $data = array())
 {
     parent::__construct($title);
     $this->id = $id;
     $this->locations = array('show_user_profile', 'edit_user_profile');
     // Chack if the class, function or method exist, otherwise use cuztom callback
     if (Cuztom::is_wp_callback($data)) {
         $this->callback = $data;
     } else {
         $this->callback = array(&$this, 'callback');
         // Build the meta box and fields
         $this->data = $this->build($data);
         add_action('personal_options_update', array(&$this, 'save_user'));
         add_action('edit_user_profile_update', array(&$this, 'save_user'));
         add_action('user_edit_form_tag', array(&$this, 'edit_form_tag'));
     }
     foreach ($this->locations as $location) {
         add_action($location, $this->callback);
     }
 }
Exemple #23
0
 /**
  * Construct a new Cuztom Post Type
  *
  * @param 	string|array 	$name
  * @param 	array 			$args
  * @param 	array 			$labels
  *
  * @author 	Gijs Jorissen
  * @since 	0.1
  *
  */
 function __construct($name, $args = array(), $labels = array())
 {
     if (!empty($name)) {
         // If $name is an array, the first element is the singular name, the second is the plural name
         if (is_array($name)) {
             $this->name = Cuztom::uglify($name[0]);
             $this->title = Cuztom::beautify($name[0]);
             $this->plural = Cuztom::beautify($name[1]);
         } else {
             $this->name = Cuztom::uglify($name);
             $this->title = Cuztom::beautify($name);
             $this->plural = Cuztom::pluralize(Cuztom::beautify($name));
         }
         $this->args = $args;
         $this->labels = $labels;
         $this->add_features = $this->remove_features = array();
         // Add action to register the post type, if the post type doesnt exist
         if (!post_type_exists($this->name)) {
             $this->register_post_type();
         }
     }
 }
Exemple #24
0
 /**
  * Constructs the class with important vars and method calls
  * If the taxonomy exists, it will be attached to the post type
  *
  * @param 	string 			$name
  * @param 	string 			$post_type_name
  * @param 	array 			$args
  * @param 	array 			$labels
  *
  * @author 	Gijs Jorissen
  * @since 	0.2
  *
  */
 function __construct($name, $post_type_name = null, $args = array(), $labels = array())
 {
     if (!empty($name)) {
         $this->post_type_name = $post_type_name;
         if (is_array($name)) {
             $this->name = Cuztom::uglify($name[0]);
             $this->title = Cuztom::beautify($name[0]);
             $this->plural = Cuztom::beautify($name[1]);
         } else {
             $this->name = Cuztom::uglify($name);
             $this->title = Cuztom::beautify($name);
             $this->plural = Cuztom::pluralize(Cuztom::beautify($name));
         }
         $this->labels = $labels;
         $this->args = $args;
         if (!taxonomy_exists($this->name)) {
             add_action('init', array(&$this, 'register_taxonomy'));
         } else {
             add_action('init', array(&$this, 'register_taxonomy_for_object_type'));
         }
     }
 }
Exemple #25
0
 /**
  * Builds an string used as field id and name
  *
  * @param array $field
  * @return string
  *
  * @author Gijs Jorissen
  * @since 0.9
  *
  */
 static function _build_id_name($field, $box_title)
 {
     return (self::_is_hidden($field) ? '_' : '') . Cuztom::uglify($box_title) . "_" . Cuztom::uglify($field['name']);
 }
 /**
  * Builds an string used as field id and name
  *
  * @param 	string 			$name
  * @param  	string 			$parent
  * @return 	string
  *
  * @author 	Gijs Jorissen
  * @since 	0.9
  *
  */
 function build_id($name, $parent)
 {
     return apply_filters('cuztom_build_id', ($this->underscore ? '_' : '') . (!empty($parent) ? Cuztom::uglify($parent) . '_' : '') . Cuztom::uglify($name));
 }
 /**
  * Builds an string used as field id and name
  *
  * @param array $field
  * @return string
  *
  * @author Gijs Jorissen
  * @since 0.9
  *
  */
 static function _build_id_name($field, $box_title)
 {
     return apply_filters('cuztom_buidl_id_name', (self::_is_hidden($field) ? '_' : '') . Cuztom::uglify($box_title) . "_" . Cuztom::uglify($field['name']));
 }
Exemple #28
0
 /**
  * Builds an string used as field id and name
  *
  * @param 	string 			$name
  * @param  	string 			$meta_box
  * @return 	string
  *
  * @author 	Gijs Jorissen
  * @since 	0.9
  *
  */
 function _build_id_name($name, $meta_box)
 {
     return apply_filters('cuztom_build_id_name', ($this->hide ? '_' : '') . Cuztom::uglify($meta_box) . "_" . Cuztom::uglify($name));
 }
 /**
  * Main callback function of add_meta_box
  *
  * @param object $post
  * @param object $data
  * @return mixed
  *
  * @author Gijs Jorissen
  * @since 0.2
  *
  */
 function callback($post, $data)
 {
     // Nonce field for validation
     wp_nonce_field(plugin_basename(__FILE__), 'cuztom_nonce');
     // Get all inputs from $data
     $meta_data = $this->meta_data;
     // Check the array and loop through it
     if (!empty($meta_data)) {
         // Hidden field, so cuztom is always set
         echo '<input type="hidden" name="cuztom[__activate]" />';
         if (isset($meta_data[0]) && !is_array($meta_data[0]) && ($meta_data[0] == 'tabs' || $meta_data[0] == 'accordion')) {
             $tabs = array_slice($meta_data, 1);
             // If it's about tabs or accordion
             echo '<div class="cuztom_helper">';
             echo '<div class="' . ($meta_data[0] == 'tabs' ? 'cuztom_tabs' : 'cuztom_accordion') . '">';
             // Show tabs
             if ($meta_data[0] == 'tabs') {
                 echo '<ul>';
                 foreach ($tabs as $tab => $fields) {
                     $tab_id = Cuztom::uglify($tab);
                     echo '<li><a href="#' . $tab_id . '">' . Cuztom::beautify($tab) . '</a></li>';
                 }
                 echo '</ul>';
             }
             /* Loop through $meta_data, tabs in this case */
             foreach ($tabs as $tab => $fields) {
                 $tab_id = Cuztom::uglify($tab);
                 // Show header if accordion
                 if ($meta_data[0] == 'accordion') {
                     echo '<h3>' . Cuztom::beautify($title) . '</h3>';
                 }
                 echo '<div id="' . $tab_id . '">';
                 echo '<table border="0" cellading="0" cellspacing="0" class="cuztom_table cuztom_helper_table">';
                 foreach ($fields as $field_id_name => $field) {
                     $meta = get_post_meta($post->ID, $field_id_name, true);
                     if ($field['type'] != 'hidden') {
                         echo '<tr>';
                         echo '<th class="cuztom_th th">';
                         echo '<label for="' . $field_id_name . '" class="cuztom_label">' . $field['label'] . '</label>';
                         echo '<div class="cuztom_description description">' . $field['description'] . '</div>';
                         echo '</th>';
                         echo '<td class="cuztom_td td">';
                         if ($field['repeatable'] && Cuztom_Field::_supports_repeatable($field)) {
                             echo '<div class="cuztom_padding_wrap">';
                             echo '<a class="button-secondary cuztom_add cuztom_button" href="#">';
                             echo '+ ' . __('Add', CUZTOM_TEXTDOMAIN) . '</a>';
                             echo '<ul class="cuztom_repeatable_wrap">';
                         }
                         cuztom_field($field_id_name, $field, $meta);
                         if ($field['repeatable'] && Cuztom_Field::_supports_repeatable($field)) {
                             echo '</ul></div>';
                         }
                         echo '</td>';
                         echo '</tr>';
                     } else {
                         cuztom_field($field_id_name, $field, $meta);
                     }
                 }
                 echo '</table>';
                 echo '</div>';
             }
             echo '</div>';
             echo '</div>';
         } else {
             echo '<div class="cuztom_helper">';
             echo '<table border="0" cellading="0" cellspacing="0" class="cuztom_table cuztom_helper_table">';
             /* Loop through $meta_data */
             foreach ($meta_data as $field_id_name => $field) {
                 $meta = get_post_meta($post->ID, $field_id_name, true) ? get_post_meta($post->ID, $field_id_name, true) : false;
                 if ($field['type'] != 'hidden') {
                     echo '<tr>';
                     echo '<th class="cuztom_th th">';
                     echo '<label for="' . $field_id_name . '" class="cuztom_label">' . $field['label'] . '</label>';
                     echo '<div class="cuztom_description description">' . $field['description'] . '</div>';
                     echo '</th>';
                     echo '<td class="cuztom_td td">';
                     if ($field['repeatable'] && Cuztom_Field::_supports_repeatable($field)) {
                         echo '<div class="cuztom_padding_wrap">';
                         echo '<a class="button-secondary cuztom_add cuztom_button" href="#">';
                         echo '+ ' . __('Add', CUZTOM_TEXTDOMAIN) . '</a>';
                         echo '<ul class="cuztom_repeatable_wrap">';
                     }
                     cuztom_field($field_id_name, $field, $meta);
                     if ($field['repeatable'] && Cuztom_Field::_supports_repeatable($field)) {
                         echo '</ul></div>';
                     }
                     echo '</td>';
                     echo '</tr>';
                 } else {
                     cuztom_field($field_id_name, $field, $meta);
                 }
             }
             echo '</table>';
             echo '</div>';
         }
     }
 }
 /**
  * Grabs dynamic fields by key and add it to a metabox field array
  *
  * @param string $option_name 	Option name of the dynamic text field in the wp_options table
  *
  * @return array
  */
 function build_dynamic_fields($option_name)
 {
     // Get the fields from the wp_options table
     $dynamic_fields = array();
     $dynamic_option = get_option($option_name);
     $fields = $dynamic_option['_' . $option_name];
     $prefix = 'nm_dyn_';
     if (!empty($fields) && is_array($fields)) {
         foreach ($fields as $key => $field) {
             if (!empty($field)) {
                 // Sets the type, name label + description
                 $type = Cuztom::uglify($field['_field_type']);
                 $name = Cuztom::uglify($prefix . $field['_field_name']);
                 $label = Cuztom::beautify($field['_field_name']);
                 $desc = $field['_field_desc'];
                 if (!empty($name)) {
                     // Adds builds array with the set values from above
                     $dynamic_fields[] = array('name' => $name, 'label' => $label, 'description' => $desc, 'type' => $type);
                 }
             }
         }
     }
     return $dynamic_fields;
 }