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;
 }
 /**
  * Constructs the meta box
  *
  * @param 	string 			$title
  * @param 	array|string	$fields
  * @param 	string 			$post_type_name
  * @param 	string 			$context
  * @param 	string 			$priority
  *
  * @author 	Gijs Jorissen
  * @since 	0.2
  *
  */
 function __construct($title, $post_type, $data = array(), $context = 'normal', $priority = 'default')
 {
     if (!empty($title)) {
         $this->post_types = (array) $post_type;
         // Meta variables
         $this->id = Cuztom::uglify($title);
         $this->title = Cuztom::beautify($title);
         $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->_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'));
     }
 }
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'));
             }
         }
     }
 }
 /**
  * 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'));
 }
 /**
  * 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 #7
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;
 }
 /**
  * Construct a new Custom Post Type
  *
  * @param string $name
  * @param array $args
  * @param array $labels
  *
  * @author Gijs Jorissen
  * @since 0.1
  *
  */
 function __construct($name, $args = array(), $labels = array())
 {
     if (!empty($name)) {
         // Set some important variables
         $this->post_type_name = Cuztom::uglify($name);
         $this->post_type_args = $args;
         $this->post_type_labels = $labels;
         // Add action to register the post type, if the post type doesnt exist
         if (!post_type_exists($this->post_type_name)) {
             add_action('init', array(&$this, 'register_post_type'));
         }
     }
 }
 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;
 }
Exemple #10
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;
 }
Exemple #11
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;
 }
 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 #13
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 #14
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'));
 }
 /**
  * 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;
         // Taxonomy properties
         $this->taxonomy_name = Cuztom::uglify($name);
         $this->taxonomy_labels = $labels;
         $this->taxonomy_args = $args;
         if (!taxonomy_exists($this->taxonomy_name)) {
             add_action('init', array(&$this, 'register_taxonomy'));
         } else {
             add_action('init', array(&$this, 'register_taxonomy_for_object_type'));
         }
     }
 }
Exemple #16
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 				$title
  * @param 	string|array 		$locations
  * @param 	array  				$data
  *
  * @author  Gijs Jorissen
  * @since   1.5
  * 
  */
 function __construct($title, $locations, $data = array())
 {
     // Meta variables
     $this->id = Cuztom::uglify($title);
     $this->title = Cuztom::beautify($title);
     $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->_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 #19
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 #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 to register the post type, if the post type doesnt exist
         if (!post_type_exists($this->name)) {
             $this->register_post_type();
         }
     }
 }
 /**
  * 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;
 }
Exemple #22
0
 /**
  * Main callback for meta
  *
  * @param 	object 			$post
  * @param 	object 			$data
  * @return 	mixed
  *
  * @author 	Gijs Jorissen
  * @since 	0.2
  *
  */
 function callback($post, $data = array())
 {
     // Nonce field for validation
     wp_nonce_field(plugin_basename(dirname(__FILE__)), 'cuztom_nonce');
     // Get all inputs from $data
     $data = $this->data;
     if (!empty($data)) {
         // Hidden field, so cuztom is always set
         echo '<input type="hidden" name="cuztom[__activate]" />';
         echo '<div class="cuztom_helper">';
         if ($data instanceof Cuztom_Tabs || $data instanceof Cuztom_Accordion) {
             $tabs = $data->tabs;
             // If it's about tabs or accordion
             echo '<div class="' . ($data instanceof Cuztom_Tabs ? 'cuztom_tabs' : 'cuztom_accordion') . '">';
             // Show tabs
             if ($data instanceof Cuztom_Tabs) {
                 echo '<ul>';
                 foreach ($tabs as $title => $tab) {
                     $tab_id = Cuztom::uglify($title);
                     echo '<li><a href="#' . $tab_id . '">' . Cuztom::beautify($title) . '</a></li>';
                 }
                 echo '</ul>';
             }
             /* Loop through $data, tabs in this case */
             foreach ($tabs as $title => $tab) {
                 $tab_id = Cuztom::uglify($title);
                 $fields = $tab->fields;
                 // Show header if accordion
                 if ($data instanceof Cuztom_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) {
                     $value = $this->get_meta_type() == 'user' ? get_user_meta($post->ID, $field_id_name, true) : get_post_meta($post->ID, $field_id_name, true);
                     if (!$field instanceof Cuztom_Field_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 && $field->_supports_repeatable()) {
                             echo '<div class="cuztom_padding_wrap">';
                             echo '<a class="button-secondary cuztom_add cuztom_add_field cuztom_button" href="#">';
                             echo sprintf('+ %s', __('Add', CUZTOM_TEXTDOMAIN));
                             echo '</a>';
                             echo '<ul class="cuztom_repeatable_wrap">';
                         }
                         echo $field->output($value);
                         if ($field->repeatable && $field->_supports_repeatable()) {
                             echo '</ul></div>';
                         }
                         echo '</td>';
                         echo '</tr>';
                     } else {
                         echo $field->output($value);
                     }
                 }
                 echo '</table>';
                 echo '</div>';
             }
             echo '</div>';
         } elseif ($data instanceof Cuztom_Bundle) {
             $meta = $this->get_meta_type() == 'user' ? get_user_meta($post->ID, $field_id_name, true) : get_post_meta($post->ID, $field_id_name, true);
             $meta = $meta[0];
             echo '<div class="cuztom_padding_wrap">';
             echo '<a class="button-secondary cuztom_add cuztom_add_bundle cuztom_button" href="#">';
             echo sprintf('+ %s', __('Add', CUZTOM_TEXTDOMAIN));
             echo '</a>';
             echo '<ul class="cuztom_bundle_wrap">';
             if (!empty($meta) && isset($meta[0])) {
                 $i = 0;
                 foreach ($meta as $bundle) {
                     echo '<li class="cuztom_bundle">';
                     echo '<div class="handle_bundle"></div>';
                     echo '<fieldset>';
                     echo '<table border="0" cellading="0" cellspacing="0" class="cuztom_table cuztom_helper_table">';
                     $bundle = $data;
                     foreach ($bundle->fields as $field_id_name => $field) {
                         $field->pre = '[' . $this->id . '][' . $i . ']';
                         $value = isset($meta[$i][$field_id_name]) ? $meta[$i][$field_id_name] : '';
                         if (!$field instanceof Cuztom_Field_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->_supports_bundle()) {
                                 echo $field->output($value);
                             } else {
                                 _e('<em>This input type doesn\'t support the bundle functionality (yet).</em>');
                             }
                             echo '</td>';
                             echo '</tr>';
                         } else {
                             echo $field->output($value);
                         }
                     }
                     echo '</table>';
                     echo '</fieldset>';
                     echo count($meta) > 1 ? '<div class="remove_bundle"></div>' : '';
                     echo '</li>';
                     $i++;
                 }
             } else {
                 echo '<li class="cuztom_bundle">';
                 echo '<div class="handle_bundle"></div>';
                 echo '<fieldset>';
                 echo '<table border="0" cellading="0" cellspacing="0" class="cuztom_table cuztom_helper_table">';
                 $fields = $data->fields;
                 foreach ($fields as $field_id_name => $field) {
                     $field->pre = '[' . $this->id . '][0]';
                     $value = '';
                     if (!$field instanceof Cuztom_Field_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->_supports_bundle()) {
                             echo $field->output($value);
                         } else {
                             _e('<em>This input type doesn\'t support the bundle functionality (yet).</em>');
                         }
                         echo '</td>';
                         echo '</tr>';
                     } else {
                         echo $field->output($value);
                     }
                 }
                 echo '</table>';
                 echo '</fieldset>';
                 echo '</li>';
             }
             echo '</ul>';
             echo '</div>';
         } else {
             echo '<table border="0" cellading="0" cellspacing="0" class="form-table cuztom_table cuztom_helper_table">';
             /* Loop through $data */
             foreach ($data as $field_id_name => $field) {
                 $meta = $this->get_meta_type() == 'user' ? get_user_meta($post->ID, $field_id_name, true) : get_post_meta($post->ID, $field_id_name, true);
                 if (!$field instanceof Cuztom_Field_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 && $field->_supports_repeatable()) {
                         echo '<div class="cuztom_padding_wrap">';
                         echo '<a class="button-secondary cuztom_add cuztom_add_field cuztom_button" href="#">';
                         echo sprintf('+ %s', __('Add', CUZTOM_TEXTDOMAIN));
                         echo '</a>';
                         echo '<ul class="cuztom_repeatable_wrap">';
                     }
                     echo $field->output($meta);
                     if ($field->repeatable && $field->_supports_repeatable()) {
                         echo '</ul></div>';
                     }
                     echo '</td>';
                     echo '</tr>';
                 } else {
                     echo $field->output($meta);
                 }
             }
             echo '</table>';
         }
         echo '</div>';
     }
 }
 /**
  * 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']));
 }
 /**
  * Cleans post meta on removal of dynamic fields
  *
  */
 function sanitize_data($input)
 {
     if (!empty($_POST)) {
         // If we are updating the options.php page with dynamic fields
         if ($_POST['option_page'] == $this->id && !empty($this->post_type)) {
             $post_meta_keys = array();
             $option_keys = array();
             $dynamic_fields = $_POST[$this->id];
             $args = array('post_type' => $this->post_type);
             $posts = Cuztom::get_cuztom_posts($args);
             $prefix = 'nm_dyn_';
             // Add the posted option key names
             foreach ($dynamic_fields as $value) {
                 foreach ($value as $post_value) {
                     $key_name = $post_value['_field_name'];
                     $option_keys[] = Cuztom::uglify($prefix . $key_name);
                 }
             }
             if (!empty($posts)) {
                 // Loop through all the posts deleting dynamic_fields that arn't used anymore
                 foreach ($posts as $post) {
                     // Get the post meta for all the posts + add it to an array
                     $post_metas = get_post_custom($post->ID);
                     foreach ($post_metas as $key => $value) {
                         if (strpos($key, 'nm_dyn_') !== false) {
                             $post_meta_keys[$key] = false;
                         }
                     }
                     // Check against the posted option values and set to true
                     foreach ($post_meta_keys as $post_meta_key => $value) {
                         foreach ($option_keys as $option_key) {
                             if (strpos($post_meta_key, $option_key) !== false) {
                                 $post_meta_keys[$post_meta_key] = true;
                             }
                         }
                     }
                     // If the post_meta failed the check and isn't being used delete it
                     foreach ($post_meta_keys as $post_meta_key => $is_used) {
                         if ($is_used == false) {
                             delete_post_meta($post->ID, $post_meta_key);
                         }
                     }
                 }
             }
         }
     }
     return $input;
 }
Exemple #26
0
 function __construct($title)
 {
     $this->id = Cuztom::uglify($title);
     $this->title = Cuztom::beautify($title);
 }
Exemple #27
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));
 }
Exemple #28
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']);
 }
 /**
  * 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>';
         }
     }
 }