From da183a215a7586f1f6af03b7b9d848edefe25970 Mon Sep 17 00:00:00 2001 From: mohamedhamad Date: Fri, 12 Dec 2014 16:50:25 -0500 Subject: [PATCH 1/9] minor update --- meta-box-class/my-meta-box-class.php | 572 +++++++++++++-------------- 1 file changed, 286 insertions(+), 286 deletions(-) diff --git a/meta-box-class/my-meta-box-class.php b/meta-box-class/my-meta-box-class.php index 23f0bd3..94cd909 100644 --- a/meta-box-class/my-meta-box-class.php +++ b/meta-box-class/my-meta-box-class.php @@ -1,22 +1,22 @@ - version 3.2. which later was forked - * by Cory Crowley (email: cory.ivan@gmail.com) The purpose of this class is not to rewrite the script but to - * modify and change small things and adding a few field types that i needed to my personal preference. + * This class is derived from Meta Box script by Rilwis version 3.2. which later was forked + * by Cory Crowley (email: cory.ivan@gmail.com) The purpose of this class is not to rewrite the script but to + * modify and change small things and adding a few field types that i needed to my personal preference. * The original author did a great job in writing this class, so all props goes to him. - * + * * @version 3.1.1 * @copyright 2011 - 2013 * @author Ohad Raz (email: admin@bainternet.info) * @link http://en.bainternet.info - * + * * @license GNU General Public LIcense v3.0 - license.txt * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, @@ -40,7 +40,7 @@ * @todo Nothing. */ class AT_Meta_Box { - + /** * Holds meta box object * @@ -48,7 +48,7 @@ class AT_Meta_Box { * @access protected */ protected $_meta_box; - + /** * Holds meta box fields. * @@ -56,7 +56,7 @@ class AT_Meta_Box { * @access protected */ protected $_prefix; - + /** * Holds Prefix for meta box fields. * @@ -64,7 +64,7 @@ class AT_Meta_Box { * @access protected */ protected $_fields; - + /** * Use local images. * @@ -72,7 +72,7 @@ class AT_Meta_Box { * @access protected */ protected $_Local_images; - + /** * SelfPath to allow themes as well as plugins. * @@ -81,7 +81,7 @@ class AT_Meta_Box { * @since 1.6 */ protected $SelfPath; - + /** * $field_types holds used field types * @var array @@ -104,20 +104,20 @@ class AT_Meta_Box { * @since 1.0 * @access public * - * @param array $meta_box + * @param array $meta_box */ public function __construct ( $meta_box ) { - + // If we are not in admin area exit. if ( ! is_admin() ) return; - + //load translation add_filter('init', array($this,'load_textdomain')); // Assign meta box values to local variables and add it's missed values. $this->_meta_box = $meta_box; - $this->_prefix = (isset($meta_box['prefix'])) ? $meta_box['prefix'] : ''; + $this->_prefix = (isset($meta_box['prefix'])) ? $meta_box['prefix'] : ''; $this->_fields = $this->_meta_box['fields']; $this->_Local_images = (isset($meta_box['local_images'])) ? true : false; $this->add_missed_values(); @@ -132,7 +132,7 @@ public function __construct ( $meta_box ) { else{ $this->SelfPath = plugins_url( 'meta-box-class', plugin_basename( dirname( __FILE__ ) ) ); } - + // Add metaboxes add_action( 'add_meta_boxes', array( $this, 'add' ) ); //add_action( 'wp_insert_post', array( $this, 'save' ) ); @@ -144,7 +144,7 @@ public function __construct ( $meta_box ) { add_filter('wp_handle_upload_prefilter', array($this,'Validate_upload_file_type')); } - + /** * Load all Javascript and CSS * @@ -152,20 +152,20 @@ public function __construct ( $meta_box ) { * @access public */ public function load_scripts_styles() { - + // Get Plugin Path $plugin_path = $this->SelfPath; - - + + //only load styles and js when needed - /* + /* * since 1.8 */ global $typenow; if (in_array($typenow,$this->_meta_box['pages']) && $this->is_edit_page()){ // Enqueue Meta Box Style wp_enqueue_style( 'at-meta-box', $plugin_path . '/css/meta-box.css' ); - + // Enqueue Meta Box Scripts wp_enqueue_script( 'at-meta-box', $plugin_path . '/js/meta-box.js', array( 'jquery' ), null, true ); @@ -177,15 +177,15 @@ public function load_scripts_styles() { wp_enqueue_script( 'jquery-ui-sortable' ); } // Check for special fields and add needed actions for them. - + //this replaces the ugly check fields methods calls foreach (array('upload','color','date','time','code','select') as $type) { call_user_func ( array( $this, 'check_field_' . $type )); } } - + } - + /** * Check the Field select, Add needed Actions * @@ -193,13 +193,13 @@ public function load_scripts_styles() { * @access public */ public function check_field_select() { - + // Check if the field is an image or file. If not, return. if ( ! $this->has_field( 'select' )) return; $plugin_path = $this->SelfPath; // Enqueu JQuery UI, use proper version. - + // Enqueu JQuery select2 library, use proper version. wp_enqueue_style('at-multiselect-select2-css', $plugin_path . '/js/select2/select2.css', array(), null); wp_enqueue_script('at-multiselect-select2-js', $plugin_path . '/js/select2/select2.js', array('jquery'), false, true); @@ -212,16 +212,16 @@ public function check_field_select() { * @access public */ public function check_field_upload() { - + // Check if the field is an image or file. If not, return. if ( ! $this->has_field( 'image' ) && ! $this->has_field( 'file' ) ) return; - - // Add data encoding type for file uploading. + + // Add data encoding type for file uploading. add_action( 'post_edit_form_tag', array( $this, 'add_enctype' ) ); - + } - + /** * Add data encoding type for file uploading * @@ -231,7 +231,7 @@ public function check_field_upload() { public function add_enctype () { printf(' enctype="multipart/form-data" encoding="multipart/form-data" '); } - + /** * Check Field Color * @@ -239,21 +239,21 @@ public function add_enctype () { * @access public */ public function check_field_color() { - + if ( $this->has_field( 'color' ) && $this->is_edit_page() ) { wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_script( 'wp-color-picker' ); } } - + /** * Check Field Date * * @since 1.0 - * @access public + * @access public */ public function check_field_date() { - + if ( $this->has_field( 'date' ) && $this->is_edit_page() ) { // Enqueu JQuery UI, use proper version. $plugin_path = $this->SelfPath; @@ -262,7 +262,7 @@ public function check_field_date() { wp_enqueue_script( 'jquery-ui-datepicker'); } } - + /** * Check Field Time * @@ -270,7 +270,7 @@ public function check_field_date() { * @access public */ public function check_field_time() { - + if ( $this->has_field( 'time' ) && $this->is_edit_page() ) { $plugin_path = $this->SelfPath; // Enqueu JQuery UI, use proper version. @@ -279,7 +279,7 @@ public function check_field_time() { wp_enqueue_script( 'at-timepicker', $plugin_path .'/js/jquery-ui/jquery-ui-timepicker-addon.js', array( 'jquery-ui-slider','jquery-ui-datepicker' ),false,true ); } } - + /** * Check Field code editor * @@ -287,7 +287,7 @@ public function check_field_time() { * @access public */ public function check_field_code() { - + if ( $this->has_field( 'code' ) && $this->is_edit_page() ) { $plugin_path = $this->SelfPath; // Enqueu codemirror js and css @@ -300,10 +300,10 @@ public function check_field_code() { wp_enqueue_script('at-code-js-css',$plugin_path .'/js/codemirror/css.js',array('jquery'),false,true); wp_enqueue_script('at-code-js-clike',$plugin_path .'/js/codemirror/clike.js',array('jquery'),false,true); wp_enqueue_script('at-code-js-php',$plugin_path .'/js/codemirror/php.js',array('jquery'),false,true); - + } } - + /** * Add Meta Box for multiple post types. * @@ -315,12 +315,12 @@ public function add($postType) { add_meta_box( $this->_meta_box['id'], $this->_meta_box['title'], array( $this, 'show' ),$postType, $this->_meta_box['context'], $this->_meta_box['priority'] ); } } - + /** * Callback function to show fields in meta box. * * @since 1.0 - * @access public + * @access public */ public function show() { $this->inGroup = false; @@ -335,7 +335,7 @@ public function show() { if (!in_array($field['type'], array('image', 'repeater','file'))) $meta = is_array( $meta ) ? array_map( 'esc_attr', $meta ) : esc_attr( $meta ); - + if ($this->inGroup !== true) echo ''; @@ -343,7 +343,7 @@ public function show() { $this->inGroup = true; echo ''; } - + // Call Separated methods for displaying each type of field. call_user_func ( array( $this, 'show_field_' . $field['type'] ), $field, $meta ); @@ -358,28 +358,28 @@ public function show() { } echo '
'; } - + /** * Show Repeater Fields. * - * @param string $field - * @param string $meta + * @param string $field + * @param string $meta * @since 1.0 * @access public */ public function show_field_repeater( $field, $meta ) { - global $post; + global $post; // Get Plugin Path $plugin_path = $this->SelfPath; $this->show_field_begin( $field, $meta ); $class = ''; - if ($field['sortable']) + if ($field['sortable']) $class = " repeater-sortable"; echo "
"; - + $c = 0; $meta = get_post_meta($post->ID,$field['id'],true); - + if (count($meta) > 0 && is_array($meta) ){ foreach ($meta as $me){ //for labling toggles @@ -402,13 +402,13 @@ public function show_field_repeater( $field, $meta ) { $f['id'] = $id; if (!$field['inline']){ echo ''; - } + } call_user_func ( array( $this, 'show_field_' . $f['type'] ), $f, $m); if (!$field['inline']){ echo ''; - } + } } - if ($field['inline']){ + if ($field['inline']){ echo ''; } echo ''; @@ -416,7 +416,7 @@ public function show_field_repeater( $field, $meta ) { echo 'sort'; echo' - Edit + Edit '.__('Remove','mmb').'
'; $c = $c + 1; @@ -430,18 +430,18 @@ public function show_field_repeater( $field, $meta ) { echo 'http://i.imgur.com/w5Tuc.png'; } echo '" alt="'.__('Add','mmb').'" title="'.__('Add','mmb').'" id="add-'.$field['id'].'">
'; - + //create all fields once more for js function and catch with object buffer ob_start(); echo '
'; if ($field['inline']){ echo ''; - } + } foreach ($field['fields'] as $f){ //reset var $id for repeater $id = ''; $id = $field['id'].'[CurrentCounter]['.$f['id'].']'; - $f['id'] = $id; + $f['id'] = $id; if (!$field['inline']){ echo ''; } @@ -451,11 +451,11 @@ public function show_field_repeater( $field, $meta ) { call_user_func ( array( $this, 'show_field_' . $f['type'] ), $f, '',true); if (!$field['inline']){ echo ''; - } + } } if ($field['inline']){ echo ''; - } + } echo '
'.__('Remove','mmb').'
'; $counter = 'countadd_'.$field['id']; $js_code = ob_get_clean (); @@ -468,7 +468,7 @@ public function show_field_repeater( $field, $meta ) { var '.$counter.' = '.$c.'; jQuery("#add-'.$field['id'].'").live(\'click\', function() { '.$counter.' = '.$counter.' + 1; - jQuery(this).before(\''.$js_code.'\'); + jQuery(this).before(\''.$js_code.'\'); update_repeater_fields(); }); jQuery("#remove-'.$field['id'].'").live(\'click\', function() { @@ -483,7 +483,7 @@ public function show_field_repeater( $field, $meta ) { .at_re_sort_highlight{min-height: 55px; background-color: #EEEEEE; margin: 2px;} .re-control-clear{clear: both; display: block;} .at_re_sort_handle{cursor: move;} -.re-control{float: right; padding: 5px;} +.re-control{float: right; padding: 5px;} .at-inline{line-height: 1 !important;} .at-inline .at-field{border: 0px !important;} .at-inline .at-label{margin: 0 0 1px !important;} @@ -493,12 +493,12 @@ public function show_field_repeater( $field, $meta ) { '; $this->show_field_end($field, $meta); } - + /** * Begin Field. * - * @param string $field - * @param string $meta + * @param string $field + * @param string $meta * @since 1.0 * @access public */ @@ -510,14 +510,14 @@ public function show_field_begin( $field, $meta) { echo ""; } } - + /** * End Field. * - * @param string $field - * @param string $meta + * @param string $field + * @param string $meta * @since 1.0 - * @access public + * @access public */ public function show_field_end( $field, $meta=NULL ,$group = false) { //print description @@ -525,30 +525,30 @@ public function show_field_end( $field, $meta=NULL ,$group = false) { echo "
{$field['desc']}
"; echo ""; } - + /** * Show Field Text. * - * @param string $field - * @param string $meta + * @param string $field + * @param string $meta * @since 1.0 * @access public */ - public function show_field_text( $field, $meta) { + public function show_field_text( $field, $meta) { $this->show_field_begin( $field, $meta ); echo ""; $this->show_field_end( $field, $meta ); } - + /** * Show Field number. * - * @param string $field - * @param string $meta + * @param string $field + * @param string $meta * @since 1.0 * @access public */ - public function show_field_number( $field, $meta) { + public function show_field_number( $field, $meta) { $this->show_field_begin( $field, $meta ); $step = (isset($field['step']) || $field['step'] != '1')? "step='".$field['step']."' ": ''; $min = isset($field['min'])? "min='".$field['min']."' ": ''; @@ -560,9 +560,9 @@ public function show_field_number( $field, $meta) { /** * Show Field code editor. * - * @param string $field + * @param string $field * @author Ohad Raz - * @param string $meta + * @param string $meta * @since 2.1 * @access public */ @@ -571,40 +571,40 @@ public function show_field_code( $field, $meta) { echo ""; $this->show_field_end( $field, $meta ); } - - + + /** * Show Field hidden. * - * @param string $field - * @param string|mixed $meta + * @param string $field + * @param string|mixed $meta * @since 0.1.3 * @access public */ - public function show_field_hidden( $field, $meta) { + public function show_field_hidden( $field, $meta) { //$this->show_field_begin( $field, $meta ); echo ""; //$this->show_field_end( $field, $meta ); } - + /** * Show Field Paragraph. * - * @param string $field + * @param string $field * @since 0.1.3 * @access public */ - public function show_field_paragraph( $field) { + public function show_field_paragraph( $field) { //$this->show_field_begin( $field, $meta ); echo '

'.$field['value'].'

'; //$this->show_field_end( $field, $meta ); } - + /** * Show Field Textarea. * - * @param string $field - * @param string $meta + * @param string $field + * @param string $meta * @since 1.0 * @access public */ @@ -613,20 +613,20 @@ public function show_field_textarea( $field, $meta ) { echo ""; $this->show_field_end( $field, $meta ); } - + /** * Show Field Select. * - * @param string $field - * @param string $meta + * @param string $field + * @param string $meta * @since 1.0 * @access public */ public function show_field_select( $field, $meta ) { - - if ( ! is_array( $meta ) ) + + if ( ! is_array( $meta ) ) $meta = (array) $meta; - + $this->show_field_begin( $field, $meta ); echo ""; $this->show_field_end( $field, $meta ); - + } - + /** * Show Radio Field. * - * @param string $field - * @param string $meta + * @param string $field + * @param string $meta * @since 1.0 - * @access public + * @access public */ public function show_field_radio( $field, $meta ) { - + if ( ! is_array( $meta ) ) $meta = (array) $meta; - + $this->show_field_begin( $field, $meta ); foreach ( $field['options'] as $key => $value ) { echo " {$value}"; } $this->show_field_end( $field, $meta ); } - + /** * Show Checkbox Field. * - * @param string $field - * @param string $meta + * @param string $field + * @param string $meta * @since 1.0 * @access public */ public function show_field_checkbox( $field, $meta ) { - + $this->show_field_begin($field, $meta); echo ""; $this->show_field_end( $field, $meta ); - + } - + /** * Show Wysiwig Field. * - * @param string $field - * @param string $meta + * @param string $field + * @param string $meta * @since 1.0 * @access public */ public function show_field_wysiwyg( $field, $meta,$in_repeater = false ) { $this->show_field_begin( $field, $meta ); - + if ( $in_repeater ) echo ""; else{ @@ -696,12 +696,12 @@ public function show_field_wysiwyg( $field, $meta,$in_repeater = false ) { } $this->show_field_end( $field, $meta ); } - + /** * Show File Field. * - * @param string $field - * @param string $meta + * @param string $field + * @param string $meta * @since 1.0 * @access public */ @@ -732,23 +732,23 @@ public function show_field_file( $field, $meta ) { $this->show_field_end( $field, $meta ); } - + /** * Show Image Field. * - * @param array $field - * @param array $meta + * @param array $field + * @param array $meta * @since 1.0 * @access public */ public function show_field_image( $field, $meta ) { wp_enqueue_media(); $this->show_field_begin( $field, $meta ); - + $std = isset($field['std'])? $field['std'] : array('id' => '', 'url' => ''); $name = esc_attr( $field['id'] ); $value = isset($meta['id']) ? $meta : $std; - + $value['url'] = isset($meta['src'])? $meta['src'] : $value['url']; //backwords capability $has_image = empty($value['url'])? false : true; $w = isset($field['width'])? $field['width'] : 'auto'; @@ -767,64 +767,64 @@ public function show_field_image( $field, $meta ) { echo ""; $this->show_field_end( $field, $meta ); } - + /** * Show Color Field. * - * @param string $field - * @param string $meta + * @param string $field + * @param string $meta * @since 1.0 * @access public */ public function show_field_color( $field, $meta ) { - - if ( empty( $meta ) ) + + if ( empty( $meta ) ) $meta = '#'; - + $this->show_field_begin( $field, $meta ); if( wp_style_is( 'wp-color-picker', 'registered' ) ) { //iris color picker since 3.5 - echo ""; + echo ""; }else{ echo ""; echo ""; echo ""; } $this->show_field_end($field, $meta); - + } /** * Show Checkbox List Field * - * @param string $field - * @param string $meta + * @param string $field + * @param string $meta * @since 1.0 * @access public */ public function show_field_checkbox_list( $field, $meta ) { - - if ( ! is_array( $meta ) ) + + if ( ! is_array( $meta ) ) $meta = (array) $meta; - + $this->show_field_begin($field, $meta); - + $html = array(); - + foreach ($field['options'] as $key => $value) { $html[] = " {$value}"; } - + echo implode( '
' , $html ); - + $this->show_field_end($field, $meta); - + } - + /** * Show Date Field. * - * @param string $field - * @param string $meta + * @param string $field + * @param string $meta * @since 1.0 * @access public */ @@ -833,14 +833,14 @@ public function show_field_date( $field, $meta ) { echo ""; $this->show_field_end( $field, $meta ); } - + /** * Show time field. * - * @param string $field - * @param string $meta + * @param string $field + * @param string $meta * @since 1.0 - * @access public + * @access public */ public function show_field_time( $field, $meta ) { $this->show_field_begin( $field, $meta ); @@ -848,18 +848,18 @@ public function show_field_time( $field, $meta ) { echo ""; $this->show_field_end( $field, $meta ); } - + /** * Show Posts field. * used creating a posts/pages/custom types checkboxlist or a select dropdown - * @param string $field - * @param string $meta + * @param string $field + * @param string $meta * @since 1.0 - * @access public + * @access public */ public function show_field_posts($field, $meta) { global $post; - + if (!is_array($meta)) $meta = (array) $meta; $this->show_field_begin($field, $meta); $options = $field['options']; @@ -880,28 +880,28 @@ public function show_field_posts($field, $meta) { } echo ""; } - + $this->show_field_end($field, $meta); } - + /** * Show Taxonomy field. * used creating a category/tags/custom taxonomy checkboxlist or a select dropdown - * @param string $field - * @param string $meta + * @param string $field + * @param string $meta * @since 1.0 - * @access public - * + * @access public + * * @uses get_terms() */ public function show_field_taxonomy($field, $meta) { global $post; - + if (!is_array($meta)) $meta = (array) $meta; $this->show_field_begin($field, $meta); $options = $field['options']; $terms = get_terms($options['taxonomy'], $options['args']); - + // checkbox_list if ('checkbox_list' == $options['type']) { foreach ($terms as $term) { @@ -916,20 +916,20 @@ public function show_field_taxonomy($field, $meta) { } echo ""; } - + $this->show_field_end($field, $meta); } /** * Show conditinal Checkbox Field. * - * @param string $field - * @param string $meta + * @param string $field + * @param string $meta * @since 2.9.9 * @access public */ public function show_field_cond( $field, $meta ) { - + $this->show_field_begin($field, $meta); $checked = false; if (is_array($meta) && isset($meta['enabled']) && $meta['enabled'] == 'on'){ @@ -938,7 +938,7 @@ public function show_field_cond( $field, $meta ) { echo ""; //start showing the fields $display = ($checked)? '' : ' style="display: none;"'; - + echo '
'; foreach ((array)$field['fields'] as $f){ //reset var $id for cond @@ -958,18 +958,18 @@ public function show_field_cond( $field, $meta ) { echo '
'; $this->show_field_end( $field, $meta ); } - + /** * Save Data from Metabox * - * @param string $post_id + * @param string $post_id * @since 1.0 - * @access public + * @access public */ public function save( $post_id ) { global $post_type; - + $post_type_object = get_post_type_object( $post_type ); if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) // Check Autosave @@ -980,20 +980,20 @@ public function save( $post_id ) { { return $post_id; } - + foreach ( $this->_fields as $field ) { - + $name = $field['id']; $type = $field['type']; $old = get_post_meta( $post_id, $name, ! $field['multiple'] ); $new = ( isset( $_POST[$name] ) ) ? $_POST[$name] : ( ( $field['multiple'] ) ? array() : '' ); - + // Validate meta value if ( class_exists( 'at_Meta_Box_Validate' ) && method_exists( 'at_Meta_Box_Validate', $field['validate_func'] ) ) { $new = call_user_func( array( 'at_Meta_Box_Validate', $field['validate_func'] ), $new ); } - + //skip on Paragraph field if ($type != "paragraph"){ @@ -1005,24 +1005,24 @@ public function save( $post_id ) { $this->save_field( $post_id, $field, $old, $new ); } } - + } // End foreach } - + /** * Common function for saving fields. * - * @param string $post_id - * @param string $field - * @param string $old - * @param string|mixed $new + * @param string $post_id + * @param string $field + * @param string $old + * @param string|mixed $new * @since 1.0 * @access public */ public function save_field( $post_id, $field, $old, $new ) { $name = $field['id']; delete_post_meta( $post_id, $name ); - if ( $new === '' || $new === array() ) + if ( $new === '' || $new === array() ) return; if ( $field['multiple'] ) { foreach ( $new as $add_new ) { @@ -1031,15 +1031,15 @@ public function save_field( $post_id, $field, $old, $new ) { } else { update_post_meta( $post_id, $name, $new ); } - } - + } + /** * function for saving image field. * - * @param string $post_id - * @param string $field - * @param string $old - * @param string|mixed $new + * @param string $post_id + * @param string $field + * @param string $old + * @param string|mixed $new * @since 1.7 * @access public */ @@ -1048,35 +1048,35 @@ public function save_field_image( $post_id, $field, $old, $new ) { delete_post_meta( $post_id, $name ); if ( $new === '' || $new === array() || $new['id'] == '' || $new['url'] == '') return; - + update_post_meta( $post_id, $name, $new ); } - + /* * Save Wysiwyg Field. * - * @param string $post_id - * @param string $field - * @param string $old - * @param string $new + * @param string $post_id + * @param string $field + * @param string $old + * @param string $new * @since 1.0 - * @access public + * @access public */ public function save_field_wysiwyg( $post_id, $field, $old, $new ) { $id = str_replace( "_","",$this->stripNumeric( strtolower( $field['id']) ) ); $new = ( isset( $_POST[$id] ) ) ? $_POST[$id] : ( ( $field['multiple'] ) ? array() : '' ); $this->save_field( $post_id, $field, $old, $new ); } - + /** * Save repeater Fields. * - * @param string $post_id - * @param string $field - * @param string|mixed $old - * @param string|mixed $new + * @param string $post_id + * @param string $field + * @param string|mixed $old + * @param string|mixed $new * @since 1.0 - * @access public + * @access public */ public function save_field_repeater( $post_id, $field, $old, $new ) { if (is_array($new) && count($new) > 0){ @@ -1085,7 +1085,7 @@ public function save_field_repeater( $post_id, $field, $old, $new ) { $type = $f['type']; switch($type) { case 'wysiwyg': - $n[$f['id']] = wpautop( $n[$f['id']] ); + $n[$f['id']] = wpautop( $n[$f['id']] ); break; default: break; @@ -1105,39 +1105,39 @@ public function save_field_repeater( $post_id, $field, $old, $new ) { delete_post_meta($post_id,$field['id']); } } - + /** * Save File Field. * - * @param string $post_id - * @param string $field - * @param string $old - * @param string $new + * @param string $post_id + * @param string $field + * @param string $old + * @param string $new * @since 1.0 * @access public */ public function save_field_file( $post_id, $field, $old, $new ) { - + $name = $field['id']; delete_post_meta( $post_id, $name ); if ( $new === '' || $new === array() || $new['id'] == '' || $new['url'] == '') return; - + update_post_meta( $post_id, $name, $new ); } - + /** * Save repeater File Field. - * @param string $post_id - * @param string $field - * @param string $old - * @param string $new + * @param string $post_id + * @param string $field + * @param string $old + * @param string $new * @since 1.0 * @access public * @deprecated 3.0.7 */ public function save_field_file_repeater( $post_id, $field, $old, $new ) {} - + /** * Add missed values for meta box. * @@ -1145,27 +1145,27 @@ public function save_field_file_repeater( $post_id, $field, $old, $new ) {} * @access public */ public function add_missed_values() { - + // Default values for meta box $this->_meta_box = array_merge( array( 'context' => 'normal', 'priority' => 'high', 'pages' => array( 'post' ) ), (array)$this->_meta_box ); // Default values for fields foreach ( $this->_fields as &$field ) { - + $multiple = in_array( $field['type'], array( 'checkbox_list', 'file', 'image' ) ); $std = $multiple ? array() : ''; - $format = 'date' == $field['type'] ? 'yy-mm-dd' : ( 'time' == $field['type'] ? 'hh:mm' : '' ); + $format = 'date' == $field['type'] ? 'yy-mm-dd' : ( 'time' == $field['type'] ? 'HH:mm' : '' ); $field = array_merge( array( 'multiple' => $multiple, 'std' => $std, 'desc' => '', 'format' => $format, 'validate_func' => '' ), $field ); - + } // End foreach - + } /** * Check if field with $type exists. * - * @param string $type + * @param string $type * @since 1.0 * @access public */ @@ -1181,7 +1181,7 @@ public function has_field( $type ) { $temp[] = $field['type']; if ('repeater' == $field['type'] || 'cond' == $field['type']){ foreach((array)$field["fields"] as $repeater_field) { - $temp[] = $repeater_field["type"]; + $temp[] = $repeater_field["type"]; } } } @@ -1202,32 +1202,32 @@ public function is_edit_page() { global $pagenow; return in_array( $pagenow, array( 'post.php', 'post-new.php' ) ); } - + /** * Fixes the odd indexing of multiple file uploads. * - * Goes from the format: + * Goes from the format: * $_FILES['field']['key']['index'] * to * The More standard and appropriate: * $_FILES['field']['index']['key'] * - * @param string $files + * @param string $files * @since 1.0 * @access public */ public function fix_file_array( &$files ) { - + $output = array(); - + foreach ( $files as $key => $list ) { foreach ( $list as $index => $value ) { $output[$index][$key] = $value; } } - + return $output; - + } /** @@ -1239,17 +1239,17 @@ public function fix_file_array( &$files ) { * @access public */ public function get_jqueryui_ver() { - + global $wp_version; - + if ( version_compare( $wp_version, '3.1', '>=') ) { return '1.8.10'; } - + return '1.7.3'; - + } - + /** * Add Field to meta box (generic function) * @author Ohad Raz @@ -1263,7 +1263,7 @@ public function addField($id,$args){ $new_field = array_merge($new_field, $args); $this->_fields[] = $new_field; } - + /** * Add Text Field to meta box * @author Ohad Raz @@ -1276,7 +1276,7 @@ public function addField($id,$args){ * 'std' => // default value, string optional * 'style' => // custom style for field, string optional * 'validate_func' => // validate function, string optional - * @param $repeater bool is this a field inside a repeatr? true|false(default) + * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addText($id,$args,$repeater=false){ $new_field = array('type' => 'text','id'=> $id,'std' => '','desc' => '','style' =>'','name' => 'Text Field'); @@ -1287,7 +1287,7 @@ public function addText($id,$args,$repeater=false){ return $new_field; } } - + /** * Add Number Field to meta box * @author Ohad Raz @@ -1300,7 +1300,7 @@ public function addText($id,$args,$repeater=false){ * 'std' => // default value, string optional * 'style' => // custom style for field, string optional * 'validate_func' => // validate function, string optional - * @param $repeater bool is this a field inside a repeatr? true|false(default) + * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addNumber($id,$args,$repeater=false){ $new_field = array('type' => 'number','id'=> $id,'std' => '0','desc' => '','style' =>'','name' => 'Number Field','step' => '1','min' => '0'); @@ -1325,7 +1325,7 @@ public function addNumber($id,$args,$repeater=false){ * 'style' => // custom style for field, string optional * 'syntax' => // syntax language to use in editor (php,javascript,css,html) * 'validate_func' => // validate function, string optional - * @param $repeater bool is this a field inside a repeatr? true|false(default) + * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addCode($id,$args,$repeater=false){ $new_field = array('type' => 'code','id'=> $id,'std' => '','desc' => '','style' =>'','name' => 'Code Editor Field','syntax' => 'php','theme' => 'defualt'); @@ -1336,7 +1336,7 @@ public function addCode($id,$args,$repeater=false){ return $new_field; } } - + /** * Add Hidden Field to meta box * @author Ohad Raz @@ -1349,7 +1349,7 @@ public function addCode($id,$args,$repeater=false){ * 'std' => // default value, string optional * 'style' => // custom style for field, string optional * 'validate_func' => // validate function, string optional - * @param $repeater bool is this a field inside a repeatr? true|false(default) + * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addHidden($id,$args,$repeater=false){ $new_field = array('type' => 'hidden','id'=> $id,'std' => '','desc' => '','style' =>'','name' => 'Text Field'); @@ -1360,7 +1360,7 @@ public function addHidden($id,$args,$repeater=false){ return $new_field; } } - + /** * Add Paragraph to meta box * @author Ohad Raz @@ -1368,7 +1368,7 @@ public function addHidden($id,$args,$repeater=false){ * @access public * @param $id string field id, i.e. the meta key * @param $value paragraph html - * @param $repeater bool is this a field inside a repeatr? true|false(default) + * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addParagraph($id,$args,$repeater=false){ $new_field = array('type' => 'paragraph','id'=> $id,'value' => ''); @@ -1379,7 +1379,7 @@ public function addParagraph($id,$args,$repeater=false){ return $new_field; } } - + /** * Add Checkbox Field to meta box * @author Ohad Raz @@ -1391,7 +1391,7 @@ public function addParagraph($id,$args,$repeater=false){ * 'desc' => // field description, string optional * 'std' => // default value, string optional * 'validate_func' => // validate function, string optional - * @param $repeater bool is this a field inside a repeatr? true|false(default) + * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addCheckbox($id,$args,$repeater=false){ $new_field = array('type' => 'checkbox','id'=> $id,'std' => '','desc' => '','style' =>'','name' => 'Checkbox Field'); @@ -1416,8 +1416,8 @@ public function addCheckbox($id,$args,$repeater=false){ * 'std' => // default value, string optional * 'validate_func' => // validate function, string optional * @param $repeater bool is this a field inside a repeatr? true|false(default) - * - * @return : remember to call: $checkbox_list = get_post_meta(get_the_ID(), 'meta_name', false); + * + * @return : remember to call: $checkbox_list = get_post_meta(get_the_ID(), 'meta_name', false); * which means the last param as false to get the values in an array */ public function addCheckboxList($id,$options,$args,$repeater=false){ @@ -1429,7 +1429,7 @@ public function addCheckboxList($id,$options,$args,$repeater=false){ return $new_field; } } - + /** * Add Textarea Field to meta box * @author Ohad Raz @@ -1442,7 +1442,7 @@ public function addCheckboxList($id,$options,$args,$repeater=false){ * 'std' => // default value, string optional * 'style' => // custom style for field, string optional * 'validate_func' => // validate function, string optional - * @param $repeater bool is this a field inside a repeatr? true|false(default) + * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addTextarea($id,$args,$repeater=false){ $new_field = array('type' => 'textarea','id'=> $id,'std' => '','desc' => '','style' =>'','name' => 'Textarea Field'); @@ -1453,21 +1453,21 @@ public function addTextarea($id,$args,$repeater=false){ return $new_field; } } - + /** * Add Select Field to meta box * @author Ohad Raz * @since 1.0 * @access public * @param $id string field id, i.e. the meta key - * @param $options (array) array of key => value pairs for select options + * @param $options (array) array of key => value pairs for select options * @param $args mixed|array * 'name' => // field name/label string optional * 'desc' => // field description, string optional * 'std' => // default value, (array) optional * 'multiple' => // select multiple values, optional. Default is false. * 'validate_func' => // validate function, string optional - * @param $repeater bool is this a field inside a repeatr? true|false(default) + * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addSelect($id,$options,$args,$repeater=false){ $new_field = array('type' => 'select','id'=> $id,'std' => array(),'desc' => '','style' =>'','name' => 'Select Field','multiple' => false,'options' => $options); @@ -1478,8 +1478,8 @@ public function addSelect($id,$options,$args,$repeater=false){ return $new_field; } } - - + + /** * Add Radio Field to meta box * @author Ohad Raz @@ -1491,7 +1491,7 @@ public function addSelect($id,$options,$args,$repeater=false){ * 'name' => // field name/label string optional * 'desc' => // field description, string optional * 'std' => // default value, string optional - * 'validate_func' => // validate function, string optional + * 'validate_func' => // validate function, string optional * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addRadio($id,$options,$args,$repeater=false){ @@ -1516,7 +1516,7 @@ public function addRadio($id,$options,$args,$repeater=false){ * 'std' => // default value, string optional * 'validate_func' => // validate function, string optional * 'format' => // date format, default yy-mm-dd. Optional. Default "'d MM, yy'" See more formats here: http://goo.gl/Wcwxn - * @param $repeater bool is this a field inside a repeatr? true|false(default) + * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addDate($id,$args,$repeater=false){ $new_field = array('type' => 'date','id'=> $id,'std' => '','desc' => '','format'=>'d MM, yy','name' => 'Date Field'); @@ -1539,11 +1539,11 @@ public function addDate($id,$args,$repeater=false){ * 'desc' => // field description, string optional * 'std' => // default value, string optional * 'validate_func' => // validate function, string optional - * 'format' => // time format, default hh:mm. Optional. See more formats here: http://goo.gl/83woX - * @param $repeater bool is this a field inside a repeatr? true|false(default) + * 'format' => // time format, default HH:mm. Optional. See more formats here: http://goo.gl/83woX + * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addTime($id,$args,$repeater=false){ - $new_field = array('type' => 'time','id'=> $id,'std' => '','desc' => '','format'=>'hh:mm','name' => 'Time Field', 'ampm' => false); + $new_field = array('type' => 'time','id'=> $id,'std' => '','desc' => '','format'=>'HH:mm','name' => 'Time Field', 'ampm' => false); $new_field = array_merge($new_field, $args); if(false === $repeater){ $this->_fields[] = $new_field; @@ -1551,7 +1551,7 @@ public function addTime($id,$args,$repeater=false){ return $new_field; } } - + /** * Add Color Field to meta box * @author Ohad Raz @@ -1563,7 +1563,7 @@ public function addTime($id,$args,$repeater=false){ * 'desc' => // field description, string optional * 'std' => // default value, string optional * 'validate_func' => // validate function, string optional - * @param $repeater bool is this a field inside a repeatr? true|false(default) + * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addColor($id,$args,$repeater=false){ $new_field = array('type' => 'color','id'=> $id,'std' => '','desc' => '','name' => 'ColorPicker Field'); @@ -1574,7 +1574,7 @@ public function addColor($id,$args,$repeater=false){ return $new_field; } } - + /** * Add Image Field to meta box * @author Ohad Raz @@ -1585,7 +1585,7 @@ public function addColor($id,$args,$repeater=false){ * 'name' => // field name/label string optional * 'desc' => // field description, string optional * 'validate_func' => // validate function, string optional - * @param $repeater bool is this a field inside a repeatr? true|false(default) + * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addImage($id,$args,$repeater=false){ $new_field = array('type' => 'image','id'=> $id,'desc' => '','name' => 'Image Field','std' => array('id' => '', 'url' => ''),'multiple' => false); @@ -1596,7 +1596,7 @@ public function addImage($id,$args,$repeater=false){ return $new_field; } } - + /** * Add File Field to meta box * @author Ohad Raz @@ -1606,7 +1606,7 @@ public function addImage($id,$args,$repeater=false){ * @param $args mixed|array * 'name' => // field name/label string optional * 'desc' => // field description, string optional - * 'validate_func' => // validate function, string optional + * 'validate_func' => // validate function, string optional * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addFile($id,$args,$repeater=false){ @@ -1630,7 +1630,7 @@ public function addFile($id,$args,$repeater=false){ * 'desc' => // field description, string optional * 'std' => // default value, string optional * 'style' => // custom style for field, string optional Default 'width: 300px; height: 400px' - * 'validate_func' => // validate function, string optional + * 'validate_func' => // validate function, string optional * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addWysiwyg($id,$args,$repeater=false){ @@ -1642,7 +1642,7 @@ public function addWysiwyg($id,$args,$repeater=false){ return $new_field; } } - + /** * Add Taxonomy Field to meta box * @author Ohad Raz @@ -1652,12 +1652,12 @@ public function addWysiwyg($id,$args,$repeater=false){ * @param $options mixed|array options of taxonomy field * 'taxonomy' => // taxonomy name can be category,post_tag or any custom taxonomy default is category * 'type' => // how to show taxonomy? 'select' (default) or 'checkbox_list' - * 'args' => // arguments to query taxonomy, see http://goo.gl/uAANN default ('hide_empty' => false) + * 'args' => // arguments to query taxonomy, see http://goo.gl/uAANN default ('hide_empty' => false) * @param $args mixed|array * 'name' => // field name/label string optional * 'desc' => // field description, string optional * 'std' => // default value, string optional - * 'validate_func' => // validate function, string optional + * 'validate_func' => // validate function, string optional * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addTaxonomy($id,$options,$args,$repeater=false){ @@ -1684,12 +1684,12 @@ public function addTaxonomy($id,$options,$args,$repeater=false){ * @param $options mixed|array options of taxonomy field * 'post_type' => // post type name, 'post' (default) 'page' or any custom post type * 'type' => // how to show posts? 'select' (default) or 'checkbox_list' - * 'args' => // arguments to query posts, see http://goo.gl/is0yK default ('posts_per_page' => -1) + * 'args' => // arguments to query posts, see http://goo.gl/is0yK default ('posts_per_page' => -1) * @param $args mixed|array * 'name' => // field name/label string optional * 'desc' => // field description, string optional * 'std' => // default value, string optional - * 'validate_func' => // validate function, string optional + * 'validate_func' => // validate function, string optional * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addPosts($id,$options,$args,$repeater=false){ @@ -1707,7 +1707,7 @@ public function addPosts($id,$options,$args,$repeater=false){ return $new_field; } } - + /** * Add repeater Field Block to meta box * @author Ohad Raz @@ -1720,7 +1720,7 @@ public function addPosts($id,$options,$args,$repeater=false){ * 'std' => // default value, string optional * 'style' => // custom style for field, string optional * 'validate_func' => // validate function, string optional - * 'fields' => //fields to repeater + * 'fields' => //fields to repeater */ public function addRepeaterBlock($id,$args){ $new_field = array( @@ -1747,7 +1747,7 @@ public function addRepeaterBlock($id,$args){ * 'std' => // default value, string optional * 'validate_func' => // validate function, string optional * 'fields' => list of fields to show conditionally. - * @param $repeater bool is this a field inside a repeatr? true|false(default) + * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addCondition($id,$args,$repeater=false){ $new_field = array( @@ -1766,8 +1766,8 @@ public function addCondition($id,$args,$repeater=false){ return $new_field; } } - - + + /** * Finish Declaration of Meta Box * @author Ohad Raz @@ -1777,7 +1777,7 @@ public function addCondition($id,$args,$repeater=false){ public function Finish() { $this->add_missed_values(); } - + /** * Helper function to check for empty arrays * @author Ohad Raz @@ -1788,7 +1788,7 @@ public function Finish() { public function is_array_empty($array){ if (!is_array($array)) return true; - + foreach ($array as $a){ if (is_array($a)){ foreach ($a as $sub_a){ @@ -1804,10 +1804,10 @@ public function is_array_empty($array){ } /** - * Validate_upload_file_type + * Validate_upload_file_type * * Checks if the uploaded file is of the expected format - * + * * @author Ohad Raz * @since 3.0.7 * @access public @@ -1836,7 +1836,7 @@ function Validate_upload_file_type($file) { /** * function to sanitize field id - * + * * @author Ohad Raz * @since 3.0.7 * @access public @@ -1845,7 +1845,7 @@ function Validate_upload_file_type($file) { */ public function idfy($str){ return str_replace(" ", "_", $str); - + } /** @@ -1863,7 +1863,7 @@ public function stripNumeric($str){ /** - * load_textdomain + * load_textdomain * @author Ohad Raz * @since 2.9.4 * @return void From b16f70a383bd6b6c1301ff128b2f87870a9a6db8 Mon Sep 17 00:00:00 2001 From: mohamedhamad Date: Fri, 12 Dec 2014 16:58:51 -0500 Subject: [PATCH 2/9] Reverting changes --- meta-box-class/my-meta-box-class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/meta-box-class/my-meta-box-class.php b/meta-box-class/my-meta-box-class.php index 94cd909..c3d2454 100644 --- a/meta-box-class/my-meta-box-class.php +++ b/meta-box-class/my-meta-box-class.php @@ -1154,7 +1154,7 @@ public function add_missed_values() { $multiple = in_array( $field['type'], array( 'checkbox_list', 'file', 'image' ) ); $std = $multiple ? array() : ''; - $format = 'date' == $field['type'] ? 'yy-mm-dd' : ( 'time' == $field['type'] ? 'HH:mm' : '' ); + $format = 'date' == $field['type'] ? 'yy-mm-dd' : ( 'time' == $field['type'] ? 'hh:mm' : '' ); $field = array_merge( array( 'multiple' => $multiple, 'std' => $std, 'desc' => '', 'format' => $format, 'validate_func' => '' ), $field ); @@ -1539,11 +1539,11 @@ public function addDate($id,$args,$repeater=false){ * 'desc' => // field description, string optional * 'std' => // default value, string optional * 'validate_func' => // validate function, string optional - * 'format' => // time format, default HH:mm. Optional. See more formats here: http://goo.gl/83woX + * 'format' => // time format, default hh:mm. Optional. See more formats here: http://goo.gl/83woX * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addTime($id,$args,$repeater=false){ - $new_field = array('type' => 'time','id'=> $id,'std' => '','desc' => '','format'=>'HH:mm','name' => 'Time Field', 'ampm' => false); + $new_field = array('type' => 'time','id'=> $id,'std' => '','desc' => '','format'=>'hh:mm','name' => 'Time Field', 'ampm' => false); $new_field = array_merge($new_field, $args); if(false === $repeater){ $this->_fields[] = $new_field; From 8df73b8ee0cfd94a30c1434a1c548f0b420a8eab Mon Sep 17 00:00:00 2001 From: mohamedhamad Date: Fri, 12 Dec 2014 17:00:04 -0500 Subject: [PATCH 3/9] Time picker 12hour to 24hours Change the time picker default time setting from hh:mm (12hours) to HH:mm (24hours). Makes it easier to understand the time set in the time picker --- meta-box-class/my-meta-box-class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/meta-box-class/my-meta-box-class.php b/meta-box-class/my-meta-box-class.php index c3d2454..94cd909 100644 --- a/meta-box-class/my-meta-box-class.php +++ b/meta-box-class/my-meta-box-class.php @@ -1154,7 +1154,7 @@ public function add_missed_values() { $multiple = in_array( $field['type'], array( 'checkbox_list', 'file', 'image' ) ); $std = $multiple ? array() : ''; - $format = 'date' == $field['type'] ? 'yy-mm-dd' : ( 'time' == $field['type'] ? 'hh:mm' : '' ); + $format = 'date' == $field['type'] ? 'yy-mm-dd' : ( 'time' == $field['type'] ? 'HH:mm' : '' ); $field = array_merge( array( 'multiple' => $multiple, 'std' => $std, 'desc' => '', 'format' => $format, 'validate_func' => '' ), $field ); @@ -1539,11 +1539,11 @@ public function addDate($id,$args,$repeater=false){ * 'desc' => // field description, string optional * 'std' => // default value, string optional * 'validate_func' => // validate function, string optional - * 'format' => // time format, default hh:mm. Optional. See more formats here: http://goo.gl/83woX + * 'format' => // time format, default HH:mm. Optional. See more formats here: http://goo.gl/83woX * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addTime($id,$args,$repeater=false){ - $new_field = array('type' => 'time','id'=> $id,'std' => '','desc' => '','format'=>'hh:mm','name' => 'Time Field', 'ampm' => false); + $new_field = array('type' => 'time','id'=> $id,'std' => '','desc' => '','format'=>'HH:mm','name' => 'Time Field', 'ampm' => false); $new_field = array_merge($new_field, $args); if(false === $repeater){ $this->_fields[] = $new_field; From 0777005c16ca71716aca82aa1a155e32e2e77e46 Mon Sep 17 00:00:00 2001 From: mohamedhamad Date: Fri, 12 Dec 2014 17:35:39 -0500 Subject: [PATCH 4/9] Metabox display updates Datepicker: date saved changed to yy-mm-dd Dispaly of fields is now in 2 columns Label:Field (not stacked) Grouped items are each in a row of their own CSS: Label td set to 100px width Image upload set to max-width:100% so that it doesnt display full sized image which takes over the screen --- meta-box-class/css/meta-box.css | 23 ++++++++++++++--------- meta-box-class/my-meta-box-class.php | 13 ++++++++----- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/meta-box-class/css/meta-box.css b/meta-box-class/css/meta-box.css index bd95bf6..b8384f2 100644 --- a/meta-box-class/css/meta-box.css +++ b/meta-box-class/css/meta-box.css @@ -8,26 +8,26 @@ /* =Common Rules for all fields. ----------------------------------------------- */ -.form-table td.at-field{ border: 1px solid #DDD; padding: 10px 10px 20px; margin: 0px; font-family: "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue", Helvetica, Arial, sans-serif; } -.at-label { margin: 0 0 5px 0; padding: 5px 0 0 0; - font: 20px/31px "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue", Helvetica, Arial, sans-serif; +.form-table td.at-field{ border: 1px solid #DDD; padding: 10px 10px 20px; margin: 0px; font-family: "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue", Helvetica, Arial, sans-serif; width:100px; } +.at-label { margin: 0 0 5px 0; padding: 5px 0 0 0; + font: 20px/31px "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue", Helvetica, Arial, sans-serif; text-shadow: rgba(255, 255, 255, 1) 0 1px 0; width: auto; } -.at-radio-label{ padding-right: 10px; } -.at-file-upload-label{ clear: both; margin: 5px 0px 5px 1px; } +.at-radio-label{ padding-right: 10px; } +.at-file-upload-label{ clear: both; margin: 5px 0px 5px 1px; } /* =Form Fields ----------------------------------------------- */ .postbox .at-field input, -.postbox .at-field textarea { padding: 5px; line-height: 18px; } +.postbox .at-field textarea { padding: 5px; line-height: 18px; } .postbox .at-field input.at-radio{} .postbox .at-field input.at-color{ border: 0px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; margin-right: 10px; min-width: 100px; } -.at-field input:focus, +.at-field input:focus, .at-field textarea:focus { background: #fffff8; } #wpcontent select.at-select { height: 30px !important; padding: 5px; display: block; min-width: 200px; } .at-field .desc-field { color: #AAA; font-style: italic; margin: 5px 0 0 3px !important; font-size: 13px; } .at-field .wp_themeSkin table.mceLayout{ border: 1px solid #DFDFDF; } -#post-body .at-field .wp_themeSkin .mceStatusbar a.mceResize{ top: -25px; } +#post-body .at-field .wp_themeSkin .mceStatusbar a.mceResize{ top: -25px; } /* =Uploaded Images ----------------------------------------------- */ @@ -40,7 +40,7 @@ ----------------------------------------------- */ .at-upload-button { float: left; clear: both; margin-top: 10px; } .at-add-file { float: left; clear: both; margin-top: 10px; } - + /* =Time Picker ----------------------------------------------- */ .ui-timepicker-div { font-size: 0.9em; } @@ -59,4 +59,9 @@ /* code Editor */ .CodeMirror{ background-color: #fff; +} + +td.at-field .simplePanelImagePreview img{ + max-width: 100% !important; + height: auto; } \ No newline at end of file diff --git a/meta-box-class/my-meta-box-class.php b/meta-box-class/my-meta-box-class.php index 94cd909..63e9878 100644 --- a/meta-box-class/my-meta-box-class.php +++ b/meta-box-class/my-meta-box-class.php @@ -341,15 +341,17 @@ public function show() { if (isset($field['group']) && $field['group'] == 'start'){ $this->inGroup = true; - echo ''; + echo ''; + echo '
'; } + echo ''; // Call Separated methods for displaying each type of field. call_user_func ( array( $this, 'show_field_' . $field['type'] ), $field, $meta ); + echo ''; if ($this->inGroup === true){ if(isset($field['group']) && $field['group'] == 'end'){ - echo '
'; $this->inGroup = false; } }else{ @@ -507,7 +509,8 @@ public function show_field_begin( $field, $meta) { if ( $field['name'] != '' || $field['name'] != FALSE ) { echo "
"; echo ""; - echo "
"; + echo ""; + echo "inGroup === true)? " valign='top'": "").">"; } } @@ -1515,11 +1518,11 @@ public function addRadio($id,$options,$args,$repeater=false){ * 'desc' => // field description, string optional * 'std' => // default value, string optional * 'validate_func' => // validate function, string optional - * 'format' => // date format, default yy-mm-dd. Optional. Default "'d MM, yy'" See more formats here: http://goo.gl/Wcwxn + * 'format' => // date format, default yy-mm-dd. Optional. Default "'yy-mm-dd'" See more formats here: http://goo.gl/Wcwxn * @param $repeater bool is this a field inside a repeatr? true|false(default) */ public function addDate($id,$args,$repeater=false){ - $new_field = array('type' => 'date','id'=> $id,'std' => '','desc' => '','format'=>'d MM, yy','name' => 'Date Field'); + $new_field = array('type' => 'date','id'=> $id,'std' => '','desc' => '','format'=>'yy-mm-dd','name' => 'Date Field'); $new_field = array_merge($new_field, $args); if(false === $repeater){ $this->_fields[] = $new_field; From d06fb639e3eb6f91def4a8ac46e4f475374013c8 Mon Sep 17 00:00:00 2001 From: mohamedhamad Date: Sat, 27 Dec 2014 19:57:53 -0500 Subject: [PATCH 5/9] minor text domain change --- meta-box-class/my-meta-box-class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meta-box-class/my-meta-box-class.php b/meta-box-class/my-meta-box-class.php index 63e9878..4089d1c 100644 --- a/meta-box-class/my-meta-box-class.php +++ b/meta-box-class/my-meta-box-class.php @@ -1824,7 +1824,7 @@ function Validate_upload_file_type($file) { $ext = substr(strrchr($file['name'],'.'),1); if (!in_array($ext, (array)$allowed)){ - $file['error'] = __("Sorry, you cannot upload this file type for this field."); + $file['error'] = __("Sorry, you cannot upload this file type for this field.",'mmb'); return $file; } @@ -1832,7 +1832,7 @@ function Validate_upload_file_type($file) { if (strpos($key, $ext) || $key == $ext) return $file; } - $file['error'] = __("Sorry, you cannot upload this file type for this field."); + $file['error'] = __("Sorry, you cannot upload this file type for this field.",'mmb'); } return $file; } From 7cb6f1f60880558ff445407af22b79ce282e8175 Mon Sep 17 00:00:00 2001 From: mohamedhamad Date: Thu, 8 Jan 2015 18:12:48 -0500 Subject: [PATCH 6/9] Conditional Image bug fix Fixed bug that wouldnt display image in conditional --- meta-box-class/css/meta-box.css | 6 ++++-- meta-box-class/my-meta-box-class.php | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/meta-box-class/css/meta-box.css b/meta-box-class/css/meta-box.css index b8384f2..ada9171 100644 --- a/meta-box-class/css/meta-box.css +++ b/meta-box-class/css/meta-box.css @@ -8,7 +8,7 @@ /* =Common Rules for all fields. ----------------------------------------------- */ -.form-table td.at-field{ border: 1px solid #DDD; padding: 10px 10px 20px; margin: 0px; font-family: "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue", Helvetica, Arial, sans-serif; width:100px; } +.form-table td.at-field{ border: 1px solid #DDD; padding: 10px 10px 20px; margin: 0px; font-family: "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue", Helvetica, Arial, sans-serif; width:100px; vertical-align: top;} .at-label { margin: 0 0 5px 0; padding: 5px 0 0 0; font: 20px/31px "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue", Helvetica, Arial, sans-serif; text-shadow: rgba(255, 255, 255, 1) 0 1px 0; width: auto; } @@ -64,4 +64,6 @@ td.at-field .simplePanelImagePreview img{ max-width: 100% !important; height: auto; -} \ No newline at end of file +} + +.conditinal_container table{ width: 100% !important; max-width: 100% !important; } \ No newline at end of file diff --git a/meta-box-class/my-meta-box-class.php b/meta-box-class/my-meta-box-class.php index 4089d1c..6bd8ea9 100644 --- a/meta-box-class/my-meta-box-class.php +++ b/meta-box-class/my-meta-box-class.php @@ -753,6 +753,7 @@ public function show_field_image( $field, $meta ) { $value = isset($meta['id']) ? $meta : $std; $value['url'] = isset($meta['src'])? $meta['src'] : $value['url']; //backwords capability + $has_image = empty($value['url'])? false : true; $w = isset($field['width'])? $field['width'] : 'auto'; $h = isset($field['height'])? $field['height'] : 'auto'; @@ -932,7 +933,7 @@ public function show_field_taxonomy($field, $meta) { * @access public */ public function show_field_cond( $field, $meta ) { - + global $post; $this->show_field_begin($field, $meta); $checked = false; if (is_array($meta) && isset($meta['enabled']) && $meta['enabled'] == 'on'){ @@ -950,13 +951,22 @@ public function show_field_cond( $field, $meta ) { $m = ''; $m = (isset($meta[$f['id']])) ? $meta[$f['id']]: ''; $m = ( $m !== '' ) ? $m : (isset($f['std'])? $f['std'] : ''); - if ('image' != $f['type'] && $f['type'] != 'repeater') + + + if ('image' != $f['type'] && $f['type'] != 'repeater'){ $m = is_array( $m) ? array_map( 'esc_attr', $m ) : esc_attr( $m); + }elseif('image' == $f['type']){ + $saved_data = get_post_meta($post->ID, $field['id']); + if(is_array($saved_data[0][$f['id']])){ + $m = $saved_data[0][$f['id']]; + } + } //set new id for field in array format $f['id'] = $id; echo ''; call_user_func ( array( $this, 'show_field_' . $f['type'] ), $f, $m); echo ''; + } echo ''; $this->show_field_end( $field, $meta ); From 17d7518f6232324138a212057288f926e49f57b0 Mon Sep 17 00:00:00 2001 From: mohamedhamad Date: Mon, 20 Apr 2015 18:03:21 -0400 Subject: [PATCH 7/9] css updates --- meta-box-class/js/select2/select2.css | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/meta-box-class/js/select2/select2.css b/meta-box-class/js/select2/select2.css index 3eae731..5fdfa89 100644 --- a/meta-box-class/js/select2/select2.css +++ b/meta-box-class/js/select2/select2.css @@ -34,6 +34,9 @@ Version: @@ver@@ Timestamp: @@timestamp@@ overflow: hidden; position: relative; + min-width: 200px !important; + max-width: 100% !important; + border: 1px solid #aaa; white-space: nowrap; line-height: 26px; @@ -75,7 +78,7 @@ Version: @@ver@@ Timestamp: @@timestamp@@ } .select2-container .select2-choice span { - margin-right: 26px; + margin-right: 0/* 26px */; display: block; overflow: hidden; @@ -91,7 +94,7 @@ Version: @@ver@@ Timestamp: @@timestamp@@ width: 12px; height: 12px; position: absolute; - right: 26px; + right: 6px/* 26px */; top: 8px; font-size: 1px; @@ -442,6 +445,8 @@ disabled look for already selected choices in the results dropdown height: 15px; padding: 5px; margin: 1px 0; + max-width: 100% !important; + min-width: 200px !important; font-family: sans-serif; font-size: 100%; From 25d4eae93a7de8c452a6c675d5026942a44bb089 Mon Sep 17 00:00:00 2001 From: mohamedhamad Date: Wed, 10 Jun 2015 17:22:01 -0400 Subject: [PATCH 8/9] minor css update --- class-usage-demo.php | 60 ++++++++++++++++----------------- meta-box-class/css/meta-box.css | 2 +- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/class-usage-demo.php b/class-usage-demo.php index c6abe6d..9bed43b 100644 --- a/class-usage-demo.php +++ b/class-usage-demo.php @@ -11,14 +11,14 @@ //include the main class file require_once("meta-box-class/my-meta-box-class.php"); if (is_admin()){ - /* + /* * prefix of meta keys, optional * use underscore (_) at the beginning to make keys hidden, for example $prefix = '_ba_'; * you also can make prefix empty to disable it - * + * */ $prefix = 'ba_'; - /* + /* * configure your meta box */ $config = array( @@ -31,17 +31,17 @@ 'local_images' => false, // Use local or hosted images (meta box images for add/remove) 'use_with_theme' => false //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false). ); - - + + /* * Initiate your meta box */ $my_meta = new AT_Meta_Box($config); - + /* * Add fields to your meta box */ - + //text field $my_meta->addText($prefix.'text_field_id',array('name'=> 'My Text ')); //textarea field @@ -59,15 +59,15 @@ //file upload field with type limitation $my_meta->addFile($prefix.'file_pdf_field_id',array('name'=> 'My File limited to PDF Only','ext' =>'pdf','mime_type' => 'application/pdf')); /* - * Don't Forget to Close up the meta box Declaration + * Don't Forget to Close up the meta box Declaration */ - //Finish Meta Box Declaration + //Finish Meta Box Declaration $my_meta->Finish(); /** * Create a second metabox */ - /* + /* * configure your meta box */ $config2 = array( @@ -80,17 +80,17 @@ 'local_images' => false, // Use local or hosted images (meta box images for add/remove) 'use_with_theme' => false //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false). ); - - + + /* * Initiate your 2nd meta box */ $my_meta2 = new AT_Meta_Box($config2); - + /* * Add fields to your 2nd meta box */ - //add checkboxes list + //add checkboxes list $my_meta2->addCheckboxList($prefix.'CheckboxList_field_id',array('checkboxkey1'=>'checkbox Value1','checkboxkey2'=>'checkbox Value2'),array('name'=> 'My checkbox list ', 'std'=> array('checkboxkey2'))); //date field $my_meta2->addDate($prefix.'date_field_id',array('name'=> 'My Date ')); @@ -106,11 +106,11 @@ $my_meta2->addPosts($prefix.'posts_field_id',array('post_type' => 'post'),array('name'=> 'My Posts ')); //add Code editor field $my_meta2->addCode($prefix.'code_field_id',array( - 'name' => 'Code editor Field', + 'name' => 'Code editor Field', 'syntax' => 'php', 'theme' => 'light' )); - + /* * To Create a reapeater Block first create an array of fields * use the same functions as above but add true as a last param @@ -124,12 +124,12 @@ */ //repeater block $my_meta2->addRepeaterBlock($prefix.'re_',array( - 'inline' => true, + 'inline' => true, 'name' => 'This is a Repeater Block', - 'fields' => $repeater_fields, + 'fields' => $repeater_fields, 'sortable' => true )); - + /* * To Create a conditinal Block first create an array of fields * use the same functions as above but add true as a last param (like the repater block) @@ -138,7 +138,7 @@ $Conditinal_fields[] = $my_meta2->addTextarea($prefix.'con_textarea_field_id',array('name'=> 'My Textarea '),true); $Conditinal_fields[] = $my_meta2->addCheckbox($prefix.'con_checkbox_field_id',array('name'=> 'My Checkbox '),true); $Conditinal_fields[] = $my_meta2->addColor($prefix.'con_color_field_id',array('name'=> 'My color '),true); - + /* * Then just add the fields to the repeater block */ @@ -150,14 +150,14 @@ 'fields' => $Conditinal_fields, 'std' => false )); - + /* - * Don't Forget to Close up the meta box Declaration + * Don't Forget to Close up the meta box Declaration */ - //Finish Meta Box Declaration + //Finish Meta Box Declaration $my_meta2->Finish(); - - + + $prefix = "_groupped_"; $config3 = array( 'id' => 'demo_meta_box3', // meta box id, unique per meta box @@ -169,14 +169,14 @@ 'local_images' => false, // Use local or hosted images (meta box images for add/remove) 'use_with_theme' => false //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false). ); - - + + /* * Initiate your 3rd meta box */ $my_meta3 = new AT_Meta_Box($config3); //first field of the group has 'group' => 'start' and last field has 'group' => 'end' - + //text field $my_meta3->addText($prefix.'text_field_id',array('name'=> 'My Text ','group' => 'start')); //textarea field @@ -189,8 +189,8 @@ $my_meta3->addRadio($prefix.'radio_field_id',array('radiokey1'=>'Radio Value1','radiokey2'=>'Radio Value2'),array('name'=> 'My Radio Filed', 'std'=> array('radionkey2'),'group' => 'end')); /* - * Don't Forget to Close up the meta box Declaration + * Don't Forget to Close up the meta box Declaration */ - //Finish Meta Box Declaration + //Finish Meta Box Declaration $my_meta3->Finish(); } diff --git a/meta-box-class/css/meta-box.css b/meta-box-class/css/meta-box.css index ada9171..20f9e70 100644 --- a/meta-box-class/css/meta-box.css +++ b/meta-box-class/css/meta-box.css @@ -8,7 +8,7 @@ /* =Common Rules for all fields. ----------------------------------------------- */ -.form-table td.at-field{ border: 1px solid #DDD; padding: 10px 10px 20px; margin: 0px; font-family: "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue", Helvetica, Arial, sans-serif; width:100px; vertical-align: top;} +.form-table td.at-field{ border: 1px solid #DDD; padding: 10px 10px 20px; margin: 0px; font-family: "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue", Helvetica, Arial, sans-serif; width:0; vertical-align: top;} .at-label { margin: 0 0 5px 0; padding: 5px 0 0 0; font: 20px/31px "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue", Helvetica, Arial, sans-serif; text-shadow: rgba(255, 255, 255, 1) 0 1px 0; width: auto; } From 5efd3508e5020e57f41f8ebe119207275f61a7fd Mon Sep 17 00:00:00 2001 From: mohamedhamad Date: Tue, 14 Jul 2015 23:23:28 -0400 Subject: [PATCH 9/9] minor css --- meta-box-class/css/meta-box.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/meta-box-class/css/meta-box.css b/meta-box-class/css/meta-box.css index 20f9e70..4910244 100644 --- a/meta-box-class/css/meta-box.css +++ b/meta-box-class/css/meta-box.css @@ -15,6 +15,9 @@ .at-radio-label{ padding-right: 10px; } .at-file-upload-label{ clear: both; margin: 5px 0px 5px 1px; } +table.repeater-table{ width:100%; } + + /* =Form Fields ----------------------------------------------- */