@@ -28,260 +28,260 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | if (!class_exists('Tax_Meta_Class')) : |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * All Types Meta Box class. |
|
| 33 | - * |
|
| 34 | - * @package All Types Meta Box |
|
| 35 | - * @since 1.0 |
|
| 36 | - * |
|
| 37 | - * @todo Nothing. |
|
| 38 | - */ |
|
| 39 | - |
|
| 40 | - |
|
| 41 | - class Tax_Meta_Class |
|
| 42 | - { |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Holds meta box object |
|
| 46 | - * |
|
| 47 | - * @var object |
|
| 48 | - * @access protected |
|
| 49 | - */ |
|
| 50 | - protected $_meta_box; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Holds meta box fields. |
|
| 54 | - * |
|
| 55 | - * @var array |
|
| 56 | - * @access protected |
|
| 57 | - */ |
|
| 58 | - protected $_prefix; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Holds Prefix for meta box fields. |
|
| 62 | - * |
|
| 63 | - * @var array |
|
| 64 | - * @access protected |
|
| 65 | - */ |
|
| 66 | - protected $_fields; |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * Use local images. |
|
| 70 | - * |
|
| 71 | - * @var bool |
|
| 72 | - * @access protected |
|
| 73 | - */ |
|
| 74 | - protected $_Local_images; |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * What form is this? edit or new term. |
|
| 78 | - * |
|
| 79 | - * @var string |
|
| 80 | - * @access protected |
|
| 81 | - * $since 1.0 |
|
| 82 | - */ |
|
| 83 | - protected $_form_type; |
|
| 84 | - /** |
|
| 85 | - * SelfPath to allow themes as well as plugins. |
|
| 86 | - * |
|
| 87 | - * @var string |
|
| 88 | - * @access protected |
|
| 89 | - * $since 1.0 |
|
| 90 | - */ |
|
| 91 | - protected $SelfPath; |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Constructor |
|
| 95 | - * |
|
| 96 | - * @since 1.0 |
|
| 97 | - * @access public |
|
| 98 | - * |
|
| 99 | - * @param array $meta_box |
|
| 100 | - */ |
|
| 101 | - public function __construct($meta_box) |
|
| 102 | - { |
|
| 103 | - |
|
| 104 | - // If we are not in admin area exit. |
|
| 105 | - if (!is_admin()) |
|
| 106 | - return; |
|
| 107 | - |
|
| 108 | - // Assign meta box values to local variables and add it's missed values. |
|
| 109 | - $this->_meta_box = $meta_box; |
|
| 110 | - $this->_prefix = (isset($meta_box['prefix'])) ? $meta_box['prefix'] : ''; |
|
| 111 | - $this->_fields = &$this->_meta_box['fields']; |
|
| 112 | - $this->_Local_images = (isset($meta_box['local_images'])) ? true : false; |
|
| 113 | - $this->add_missed_values(); |
|
| 114 | - if (isset($meta_box['use_with_theme'])) |
|
| 115 | - if ($meta_box['use_with_theme'] === true) { |
|
| 116 | - $this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta'; |
|
| 117 | - } elseif ($meta_box['use_with_theme'] === false) { |
|
| 118 | - $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); |
|
| 119 | - } else { |
|
| 120 | - $this->SelfPath = $meta_box['use_with_theme']; |
|
| 121 | - } |
|
| 122 | - else { |
|
| 123 | - $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - |
|
| 127 | - // Add Actions |
|
| 128 | - add_action('admin_init', array(&$this, 'add')); |
|
| 129 | - |
|
| 130 | - // Check for special fields and add needed actions for them. |
|
| 131 | - $this->check_field_upload(); |
|
| 132 | - $this->check_field_color(); |
|
| 133 | - $this->check_field_date(); |
|
| 134 | - $this->check_field_time(); |
|
| 135 | - |
|
| 136 | - // Load common js, css files |
|
| 137 | - // Must enqueue for all pages as we need js for the media upload, too. |
|
| 138 | - add_action('admin_print_styles', array(&$this, 'load_scripts_styles')); |
|
| 139 | - |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * Load all Javascript and CSS |
|
| 144 | - * |
|
| 145 | - * @since 1.0 |
|
| 146 | - * @access public |
|
| 147 | - */ |
|
| 148 | - public function load_scripts_styles() |
|
| 149 | - { |
|
| 150 | - |
|
| 151 | - // Get Plugin Path |
|
| 152 | - $plugin_path = $this->SelfPath; |
|
| 153 | - //only load styles and js when needed |
|
| 154 | - /* |
|
| 31 | + /** |
|
| 32 | + * All Types Meta Box class. |
|
| 33 | + * |
|
| 34 | + * @package All Types Meta Box |
|
| 35 | + * @since 1.0 |
|
| 36 | + * |
|
| 37 | + * @todo Nothing. |
|
| 38 | + */ |
|
| 39 | + |
|
| 40 | + |
|
| 41 | + class Tax_Meta_Class |
|
| 42 | + { |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Holds meta box object |
|
| 46 | + * |
|
| 47 | + * @var object |
|
| 48 | + * @access protected |
|
| 49 | + */ |
|
| 50 | + protected $_meta_box; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Holds meta box fields. |
|
| 54 | + * |
|
| 55 | + * @var array |
|
| 56 | + * @access protected |
|
| 57 | + */ |
|
| 58 | + protected $_prefix; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Holds Prefix for meta box fields. |
|
| 62 | + * |
|
| 63 | + * @var array |
|
| 64 | + * @access protected |
|
| 65 | + */ |
|
| 66 | + protected $_fields; |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * Use local images. |
|
| 70 | + * |
|
| 71 | + * @var bool |
|
| 72 | + * @access protected |
|
| 73 | + */ |
|
| 74 | + protected $_Local_images; |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * What form is this? edit or new term. |
|
| 78 | + * |
|
| 79 | + * @var string |
|
| 80 | + * @access protected |
|
| 81 | + * $since 1.0 |
|
| 82 | + */ |
|
| 83 | + protected $_form_type; |
|
| 84 | + /** |
|
| 85 | + * SelfPath to allow themes as well as plugins. |
|
| 86 | + * |
|
| 87 | + * @var string |
|
| 88 | + * @access protected |
|
| 89 | + * $since 1.0 |
|
| 90 | + */ |
|
| 91 | + protected $SelfPath; |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Constructor |
|
| 95 | + * |
|
| 96 | + * @since 1.0 |
|
| 97 | + * @access public |
|
| 98 | + * |
|
| 99 | + * @param array $meta_box |
|
| 100 | + */ |
|
| 101 | + public function __construct($meta_box) |
|
| 102 | + { |
|
| 103 | + |
|
| 104 | + // If we are not in admin area exit. |
|
| 105 | + if (!is_admin()) |
|
| 106 | + return; |
|
| 107 | + |
|
| 108 | + // Assign meta box values to local variables and add it's missed values. |
|
| 109 | + $this->_meta_box = $meta_box; |
|
| 110 | + $this->_prefix = (isset($meta_box['prefix'])) ? $meta_box['prefix'] : ''; |
|
| 111 | + $this->_fields = &$this->_meta_box['fields']; |
|
| 112 | + $this->_Local_images = (isset($meta_box['local_images'])) ? true : false; |
|
| 113 | + $this->add_missed_values(); |
|
| 114 | + if (isset($meta_box['use_with_theme'])) |
|
| 115 | + if ($meta_box['use_with_theme'] === true) { |
|
| 116 | + $this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta'; |
|
| 117 | + } elseif ($meta_box['use_with_theme'] === false) { |
|
| 118 | + $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); |
|
| 119 | + } else { |
|
| 120 | + $this->SelfPath = $meta_box['use_with_theme']; |
|
| 121 | + } |
|
| 122 | + else { |
|
| 123 | + $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + |
|
| 127 | + // Add Actions |
|
| 128 | + add_action('admin_init', array(&$this, 'add')); |
|
| 129 | + |
|
| 130 | + // Check for special fields and add needed actions for them. |
|
| 131 | + $this->check_field_upload(); |
|
| 132 | + $this->check_field_color(); |
|
| 133 | + $this->check_field_date(); |
|
| 134 | + $this->check_field_time(); |
|
| 135 | + |
|
| 136 | + // Load common js, css files |
|
| 137 | + // Must enqueue for all pages as we need js for the media upload, too. |
|
| 138 | + add_action('admin_print_styles', array(&$this, 'load_scripts_styles')); |
|
| 139 | + |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * Load all Javascript and CSS |
|
| 144 | + * |
|
| 145 | + * @since 1.0 |
|
| 146 | + * @access public |
|
| 147 | + */ |
|
| 148 | + public function load_scripts_styles() |
|
| 149 | + { |
|
| 150 | + |
|
| 151 | + // Get Plugin Path |
|
| 152 | + $plugin_path = $this->SelfPath; |
|
| 153 | + //only load styles and js when needed |
|
| 154 | + /* |
|
| 155 | 155 | * since 1.0 |
| 156 | 156 | */ |
| 157 | - $taxnow = isset($_REQUEST['taxonomy']) ? $_REQUEST['taxonomy'] : ''; |
|
| 158 | - |
|
| 159 | - if (!empty($this->_meta_box['pages'])) { |
|
| 160 | - if (in_array($taxnow, $this->_meta_box['pages'])) { |
|
| 161 | - // Enqueue Meta Box Style |
|
| 162 | - //wp_enqueue_style( 'tax-meta-clss', $plugin_path . '/css/Tax-meta-class.css' ); |
|
| 163 | - // Enqueue Meta Box Scripts |
|
| 164 | - //wp_enqueue_script( 'tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array( 'jquery' ), null, true ); |
|
| 165 | - |
|
| 166 | - } |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * Check the Field Upload, Add needed Actions |
|
| 173 | - * |
|
| 174 | - * @since 1.0 |
|
| 175 | - * @access public |
|
| 176 | - */ |
|
| 177 | - public function enqueue_tax_meta_scripts() |
|
| 178 | - { |
|
| 179 | - // Make upload feature work event when custom post type doesn't support 'editor' |
|
| 180 | - wp_enqueue_script('media-upload'); |
|
| 181 | - wp_enqueue_script('thickbox'); |
|
| 182 | - add_thickbox(); |
|
| 183 | - wp_enqueue_script('jquery-ui-core'); |
|
| 184 | - wp_enqueue_script('jquery-ui-sortable'); |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - public function check_field_upload() |
|
| 190 | - { |
|
| 191 | - |
|
| 192 | - // Check if the field is an image or file. If not, return. |
|
| 193 | - if (!$this->has_field('image') && !$this->has_field('file')) |
|
| 194 | - return; |
|
| 195 | - |
|
| 196 | - |
|
| 197 | - add_action('wp_enqueue_scripts', array(&$this, 'enqueue_tax_meta_scripts'), 100); |
|
| 198 | - |
|
| 199 | - // Add data encoding type for file uploading. |
|
| 200 | - add_action('post_edit_form_tag', array(&$this, 'add_enctype')); |
|
| 201 | - |
|
| 202 | - |
|
| 203 | - // Add filters for media upload. |
|
| 204 | - add_filter('media_upload_gallery', array(&$this, 'insert_images')); |
|
| 205 | - add_filter('media_upload_library', array(&$this, 'insert_images')); |
|
| 206 | - add_filter('media_upload_image', array(&$this, 'insert_images')); |
|
| 207 | - |
|
| 208 | - // Delete all attachments when delete custom post type. |
|
| 209 | - add_action('wp_ajax_at_delete_file', array(&$this, 'delete_file')); |
|
| 210 | - add_action('wp_ajax_at_reorder_images', array(&$this, 'reorder_images')); |
|
| 211 | - // Delete file via Ajax |
|
| 212 | - add_action('wp_ajax_at_delete_mupload', array($this, 'wp_ajax_delete_image')); |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * Add data encoding type for file uploading |
|
| 217 | - * |
|
| 218 | - * @since 1.0 |
|
| 219 | - * @access public |
|
| 220 | - */ |
|
| 221 | - public function add_enctype() |
|
| 222 | - { |
|
| 223 | - echo ' enctype="multipart/form-data"'; |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * Process images added to meta field. |
|
| 228 | - * |
|
| 229 | - * Modified from Faster Image Insert plugin. |
|
| 230 | - * |
|
| 231 | - * @return void |
|
| 232 | - * @author Cory Crowley |
|
| 233 | - */ |
|
| 234 | - public function insert_images() |
|
| 235 | - { |
|
| 236 | - |
|
| 237 | - // If post variables are empty, return. |
|
| 238 | - if (!isset($_POST['at-insert']) || empty($_POST['attachments'])) |
|
| 239 | - return; |
|
| 240 | - |
|
| 241 | - // Security Check |
|
| 242 | - check_admin_referer('media-form'); |
|
| 243 | - |
|
| 244 | - // Create Security Nonce |
|
| 245 | - $nonce = wp_create_nonce('at_ajax_delete'); |
|
| 246 | - |
|
| 247 | - // Get Post Id and Field Id |
|
| 248 | - $term_id = $_POST['post_id']; |
|
| 249 | - $id = $_POST['field_id']; |
|
| 250 | - |
|
| 251 | - // Modify the insertion string |
|
| 252 | - $html = ''; |
|
| 253 | - foreach ($_POST['attachments'] as $attachment_id => $attachment) { |
|
| 254 | - |
|
| 255 | - // Strip Slashes |
|
| 256 | - $attachment = stripslashes_deep($attachment); |
|
| 257 | - |
|
| 258 | - // If not selected or url is empty, continue in loop. |
|
| 259 | - if (empty($attachment['selected']) || empty($attachment['url'])) |
|
| 260 | - continue; |
|
| 261 | - |
|
| 262 | - $li = "<li id='item_{$attachment_id}'>"; |
|
| 263 | - $li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />"; |
|
| 264 | - //$li .= "<a title='" . __( 'Delete this image' ) . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'>" . __( 'Delete' ) . "</a>"; |
|
| 265 | - $li .= "<a title='" . __('Remove this image', 'geodirectory') . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='" . $this->SelfPath . "/images/delete-16.png' alt='" . __('Remove', 'geodirectory') . "' /></a>"; |
|
| 266 | - $li .= "<input type='hidden' name='{$id}[]' value='{$attachment_id}' />"; |
|
| 267 | - $li .= "</li>"; |
|
| 268 | - $html .= $li; |
|
| 269 | - |
|
| 270 | - } // End For Each |
|
| 271 | - |
|
| 272 | - return media_send_to_editor($html); |
|
| 273 | - |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - /** |
|
| 277 | - * Delete attachments associated with the post. |
|
| 278 | - * |
|
| 279 | - * @since 1.0 |
|
| 280 | - * @access public |
|
| 281 | - * |
|
| 282 | - * @param int|string $term_id The term ID. |
|
| 283 | - */ |
|
| 284 | - /*public function delete_attachments( $term_id ) { |
|
| 157 | + $taxnow = isset($_REQUEST['taxonomy']) ? $_REQUEST['taxonomy'] : ''; |
|
| 158 | + |
|
| 159 | + if (!empty($this->_meta_box['pages'])) { |
|
| 160 | + if (in_array($taxnow, $this->_meta_box['pages'])) { |
|
| 161 | + // Enqueue Meta Box Style |
|
| 162 | + //wp_enqueue_style( 'tax-meta-clss', $plugin_path . '/css/Tax-meta-class.css' ); |
|
| 163 | + // Enqueue Meta Box Scripts |
|
| 164 | + //wp_enqueue_script( 'tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array( 'jquery' ), null, true ); |
|
| 165 | + |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * Check the Field Upload, Add needed Actions |
|
| 173 | + * |
|
| 174 | + * @since 1.0 |
|
| 175 | + * @access public |
|
| 176 | + */ |
|
| 177 | + public function enqueue_tax_meta_scripts() |
|
| 178 | + { |
|
| 179 | + // Make upload feature work event when custom post type doesn't support 'editor' |
|
| 180 | + wp_enqueue_script('media-upload'); |
|
| 181 | + wp_enqueue_script('thickbox'); |
|
| 182 | + add_thickbox(); |
|
| 183 | + wp_enqueue_script('jquery-ui-core'); |
|
| 184 | + wp_enqueue_script('jquery-ui-sortable'); |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + public function check_field_upload() |
|
| 190 | + { |
|
| 191 | + |
|
| 192 | + // Check if the field is an image or file. If not, return. |
|
| 193 | + if (!$this->has_field('image') && !$this->has_field('file')) |
|
| 194 | + return; |
|
| 195 | + |
|
| 196 | + |
|
| 197 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_tax_meta_scripts'), 100); |
|
| 198 | + |
|
| 199 | + // Add data encoding type for file uploading. |
|
| 200 | + add_action('post_edit_form_tag', array(&$this, 'add_enctype')); |
|
| 201 | + |
|
| 202 | + |
|
| 203 | + // Add filters for media upload. |
|
| 204 | + add_filter('media_upload_gallery', array(&$this, 'insert_images')); |
|
| 205 | + add_filter('media_upload_library', array(&$this, 'insert_images')); |
|
| 206 | + add_filter('media_upload_image', array(&$this, 'insert_images')); |
|
| 207 | + |
|
| 208 | + // Delete all attachments when delete custom post type. |
|
| 209 | + add_action('wp_ajax_at_delete_file', array(&$this, 'delete_file')); |
|
| 210 | + add_action('wp_ajax_at_reorder_images', array(&$this, 'reorder_images')); |
|
| 211 | + // Delete file via Ajax |
|
| 212 | + add_action('wp_ajax_at_delete_mupload', array($this, 'wp_ajax_delete_image')); |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * Add data encoding type for file uploading |
|
| 217 | + * |
|
| 218 | + * @since 1.0 |
|
| 219 | + * @access public |
|
| 220 | + */ |
|
| 221 | + public function add_enctype() |
|
| 222 | + { |
|
| 223 | + echo ' enctype="multipart/form-data"'; |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * Process images added to meta field. |
|
| 228 | + * |
|
| 229 | + * Modified from Faster Image Insert plugin. |
|
| 230 | + * |
|
| 231 | + * @return void |
|
| 232 | + * @author Cory Crowley |
|
| 233 | + */ |
|
| 234 | + public function insert_images() |
|
| 235 | + { |
|
| 236 | + |
|
| 237 | + // If post variables are empty, return. |
|
| 238 | + if (!isset($_POST['at-insert']) || empty($_POST['attachments'])) |
|
| 239 | + return; |
|
| 240 | + |
|
| 241 | + // Security Check |
|
| 242 | + check_admin_referer('media-form'); |
|
| 243 | + |
|
| 244 | + // Create Security Nonce |
|
| 245 | + $nonce = wp_create_nonce('at_ajax_delete'); |
|
| 246 | + |
|
| 247 | + // Get Post Id and Field Id |
|
| 248 | + $term_id = $_POST['post_id']; |
|
| 249 | + $id = $_POST['field_id']; |
|
| 250 | + |
|
| 251 | + // Modify the insertion string |
|
| 252 | + $html = ''; |
|
| 253 | + foreach ($_POST['attachments'] as $attachment_id => $attachment) { |
|
| 254 | + |
|
| 255 | + // Strip Slashes |
|
| 256 | + $attachment = stripslashes_deep($attachment); |
|
| 257 | + |
|
| 258 | + // If not selected or url is empty, continue in loop. |
|
| 259 | + if (empty($attachment['selected']) || empty($attachment['url'])) |
|
| 260 | + continue; |
|
| 261 | + |
|
| 262 | + $li = "<li id='item_{$attachment_id}'>"; |
|
| 263 | + $li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />"; |
|
| 264 | + //$li .= "<a title='" . __( 'Delete this image' ) . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'>" . __( 'Delete' ) . "</a>"; |
|
| 265 | + $li .= "<a title='" . __('Remove this image', 'geodirectory') . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='" . $this->SelfPath . "/images/delete-16.png' alt='" . __('Remove', 'geodirectory') . "' /></a>"; |
|
| 266 | + $li .= "<input type='hidden' name='{$id}[]' value='{$attachment_id}' />"; |
|
| 267 | + $li .= "</li>"; |
|
| 268 | + $html .= $li; |
|
| 269 | + |
|
| 270 | + } // End For Each |
|
| 271 | + |
|
| 272 | + return media_send_to_editor($html); |
|
| 273 | + |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * Delete attachments associated with the post. |
|
| 278 | + * |
|
| 279 | + * @since 1.0 |
|
| 280 | + * @access public |
|
| 281 | + * |
|
| 282 | + * @param int|string $term_id The term ID. |
|
| 283 | + */ |
|
| 284 | + /*public function delete_attachments( $term_id ) { |
|
| 285 | 285 | |
| 286 | 286 | // Get Attachments |
| 287 | 287 | $attachments = get_posts( array( 'numberposts' => -1, 'post_type' => 'attachment', 'post_parent' => $term_id ) ); |
@@ -295,349 +295,349 @@ discard block |
||
| 295 | 295 | |
| 296 | 296 | }*/ |
| 297 | 297 | |
| 298 | - /** |
|
| 299 | - * Ajax callback for deleting files. |
|
| 300 | - * |
|
| 301 | - * Modified from a function used by "Verve Meta Boxes" plugin ( http://goo.gl/aw64H ) |
|
| 302 | - * |
|
| 303 | - * @since 1.0 |
|
| 304 | - * @access public |
|
| 305 | - */ |
|
| 306 | - public function delete_file() |
|
| 307 | - { |
|
| 308 | - |
|
| 309 | - |
|
| 310 | - // If data is not set, die. |
|
| 311 | - if (!isset($_POST['data'])) |
|
| 312 | - die(); |
|
| 313 | - |
|
| 314 | - list($nonce, $term_id, $key, $attach_id) = explode('|', $_POST['data']); |
|
| 315 | - |
|
| 316 | - if (!wp_verify_nonce($nonce, 'at_ajax_delete')) |
|
| 317 | - die('1'); |
|
| 318 | - |
|
| 319 | - $this->delete_tax_meta($term_id, $key, $attach_id); |
|
| 320 | - |
|
| 321 | - die('0'); |
|
| 322 | - |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - /** |
|
| 326 | - * Ajax callback for deleting files. |
|
| 327 | - * Modified from a function used by "Verve Meta Boxes" plugin (http://goo.gl/LzYSq) |
|
| 328 | - * @since 1.0 |
|
| 329 | - * @access public |
|
| 330 | - */ |
|
| 331 | - public function wp_ajax_delete_image() |
|
| 332 | - { |
|
| 333 | - $term_id = isset($_GET['post_id']) ? intval($_GET['post_id']) : 0; |
|
| 334 | - $field_id = isset($_GET['field_id']) ? $_GET['field_id'] : 0; |
|
| 335 | - $attachment_id = isset($_GET['attachment_id']) ? intval($_GET['attachment_id']) : 0; |
|
| 336 | - $ok = false; |
|
| 337 | - if (strpos($field_id, '[') === false) { |
|
| 338 | - check_admin_referer("at-delete-mupload_" . urldecode($field_id)); |
|
| 339 | - if ($term_id > 0) |
|
| 340 | - $this->delete_tax_meta($term_id, $field_id); |
|
| 341 | - //$ok = wp_delete_attachment( $attachment_id ); |
|
| 342 | - $ok = 1; |
|
| 343 | - } else { |
|
| 344 | - $f = explode('[', urldecode($field_id)); |
|
| 345 | - $f_fiexed = array(); |
|
| 346 | - foreach ($f as $k => $v) { |
|
| 347 | - $f[$k] = str_replace(']', '', $v); |
|
| 348 | - } |
|
| 349 | - $saved = $this->get_tax_meta($term_id, $f[0], true); |
|
| 350 | - if (isset($saved[$f[1]][$f[2]])) { |
|
| 351 | - unset($saved[$f[1]][$f[2]]); |
|
| 352 | - if ($term_id > 0) |
|
| 353 | - update_post_meta($term_id, $f[0], $saved); |
|
| 354 | - //$ok = wp_delete_attachment( $attachment_id ); |
|
| 355 | - $ok = 1; |
|
| 356 | - } |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - |
|
| 360 | - if ($ok) { |
|
| 361 | - echo json_encode(array('status' => 'success')); |
|
| 362 | - die(); |
|
| 363 | - } else { |
|
| 364 | - echo json_encode(array('message' => __('Cannot delete file. Something\'s wrong.', 'geodirectory'))); |
|
| 365 | - die(); |
|
| 366 | - } |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * Ajax callback for reordering Images. |
|
| 371 | - * |
|
| 372 | - * @since 1.0 |
|
| 373 | - * @access public |
|
| 374 | - */ |
|
| 375 | - public function reorder_images() |
|
| 376 | - { |
|
| 377 | - |
|
| 378 | - if (!isset($_POST['data'])) |
|
| 379 | - die(); |
|
| 380 | - |
|
| 381 | - list($order, $term_id, $key, $nonce) = explode('|', $_POST['data']); |
|
| 382 | - |
|
| 383 | - if (!wp_verify_nonce($nonce, 'at_ajax_reorder')) |
|
| 384 | - die('1'); |
|
| 385 | - |
|
| 386 | - parse_str($order, $items); |
|
| 387 | - $items = $items['item']; |
|
| 388 | - $order = 1; |
|
| 389 | - foreach ($items as $item) { |
|
| 390 | - wp_update_post(array('ID' => $item, 'post_parent' => $term_id, 'menu_order' => $order)); |
|
| 391 | - $order++; |
|
| 392 | - } |
|
| 393 | - |
|
| 394 | - die('0'); |
|
| 395 | - |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - /** |
|
| 399 | - * Check Field Color |
|
| 400 | - * |
|
| 401 | - * @since 1.0 |
|
| 402 | - * @access public |
|
| 403 | - */ |
|
| 404 | - public function check_field_color() |
|
| 405 | - { |
|
| 406 | - |
|
| 407 | - if ($this->has_field('color') && $this->is_edit_page()) { |
|
| 408 | - // Enqueu built-in script and style for color picker. |
|
| 409 | - wp_enqueue_style('farbtastic'); |
|
| 410 | - wp_enqueue_script('farbtastic'); |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - /** |
|
| 416 | - * Check Field Date |
|
| 417 | - * |
|
| 418 | - * @since 1.0 |
|
| 419 | - * @access public |
|
| 420 | - */ |
|
| 421 | - public function check_field_date() |
|
| 422 | - { |
|
| 423 | - |
|
| 424 | - if ($this->has_field('date') && $this->is_edit_page()) { |
|
| 425 | - // Enqueu JQuery UI, use proper version. |
|
| 426 | - wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css'); |
|
| 427 | - wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery')); |
|
| 428 | - } |
|
| 429 | - |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - /** |
|
| 433 | - * Check Field Time |
|
| 434 | - * |
|
| 435 | - * @since 1.0 |
|
| 436 | - * @access public |
|
| 437 | - */ |
|
| 438 | - public function check_field_time() |
|
| 439 | - { |
|
| 440 | - |
|
| 441 | - if ($this->has_field('time') && $this->is_edit_page()) { |
|
| 442 | - |
|
| 443 | - // Enqueu JQuery UI, use proper version. |
|
| 444 | - wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css', array(), false, true); |
|
| 445 | - wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'), false, true); |
|
| 446 | - wp_enqueue_script('at-timepicker', 'https://github.com/trentrichardson/jQuery-Timepicker-Addon/raw/master/jquery-ui-timepicker-addon.js', array('tmc-jquery-ui'), false, true); |
|
| 447 | - |
|
| 448 | - } |
|
| 449 | - |
|
| 450 | - } |
|
| 451 | - |
|
| 452 | - /** |
|
| 453 | - * Add Meta Box for multiple post types. |
|
| 454 | - * |
|
| 455 | - * @since 1.0 |
|
| 456 | - * @access public |
|
| 457 | - */ |
|
| 458 | - public function add() |
|
| 459 | - { |
|
| 460 | - |
|
| 461 | - // Loop through array |
|
| 462 | - if (!empty($this->_meta_box['pages'])) { |
|
| 463 | - foreach ($this->_meta_box['pages'] as $page) { |
|
| 464 | - //add fields to edit form |
|
| 465 | - add_action($page . '_edit_form_fields', array(&$this, 'show_edit_form')); |
|
| 466 | - //add fields to add new form |
|
| 467 | - add_action($page . '_add_form_fields', array(&$this, 'show_new_form')); |
|
| 468 | - // this saves the edit fields |
|
| 469 | - add_action('edited_' . $page, array(&$this, 'save'), 10, 2); |
|
| 470 | - // this saves the add fields |
|
| 471 | - add_action('created_' . $page, array(&$this, 'save'), 10, 2); |
|
| 472 | - } |
|
| 473 | - } |
|
| 474 | - |
|
| 475 | - } |
|
| 476 | - |
|
| 477 | - /** |
|
| 478 | - * Callback function to show fields on add new taxonomy term form. |
|
| 479 | - * |
|
| 480 | - * @since 1.0 |
|
| 481 | - * @access public |
|
| 482 | - */ |
|
| 483 | - public function show_new_form($term_id) |
|
| 484 | - { |
|
| 485 | - $this->_form_type = 'new'; |
|
| 486 | - $this->show($term_id); |
|
| 487 | - } |
|
| 488 | - |
|
| 489 | - /** |
|
| 490 | - * Callback function to show fields on term edit form. |
|
| 491 | - * |
|
| 492 | - * @since 1.0 |
|
| 493 | - * @access public |
|
| 494 | - */ |
|
| 495 | - public function show_edit_form($term_id) |
|
| 496 | - { |
|
| 497 | - $this->_form_type = 'edit'; |
|
| 498 | - $this->show($term_id); |
|
| 499 | - } |
|
| 500 | - |
|
| 501 | - |
|
| 502 | - /** |
|
| 503 | - * Callback function to show fields in meta box. |
|
| 504 | - * |
|
| 505 | - * @since 1.0 |
|
| 506 | - * @access public |
|
| 507 | - */ |
|
| 508 | - public function show($term_id) |
|
| 509 | - { |
|
| 510 | - |
|
| 511 | - wp_nonce_field(basename(__FILE__), 'tax_meta_class_nonce'); |
|
| 512 | - |
|
| 513 | - foreach ($this->_fields as $field) { |
|
| 514 | - $meta = $this->get_tax_meta($term_id, $field['id'], !$field['multiple']); |
|
| 515 | - $meta = ($meta !== '') ? $meta : $field['std']; |
|
| 516 | - if ('image' != $field['type'] && $field['type'] != 'repeater') |
|
| 517 | - $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta); |
|
| 518 | - |
|
| 519 | - if ($field['validate_func']) { |
|
| 520 | - echo '<tr class="form-field form-required ' . $field['style'] . '">'; |
|
| 521 | - } else { |
|
| 522 | - echo '<tr class="form-field ' . $field['style'] . '">'; |
|
| 523 | - } |
|
| 524 | - |
|
| 525 | - // Call Separated methods for displaying each type of field. |
|
| 526 | - call_user_func(array(&$this, 'show_field_' . $field['type']), $field, $meta); |
|
| 527 | - echo '</tr>'; |
|
| 528 | - } |
|
| 529 | - echo '</table>'; |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - /** |
|
| 533 | - * Show Repeater Fields. |
|
| 534 | - * |
|
| 535 | - * @param string $field |
|
| 536 | - * @param string $meta |
|
| 537 | - * @since 1.0 |
|
| 538 | - * @access public |
|
| 539 | - */ |
|
| 540 | - public function show_field_repeater($field, $meta) |
|
| 541 | - { |
|
| 542 | - // Get Plugin Path |
|
| 543 | - $plugin_path = $this->SelfPath; |
|
| 544 | - $this->show_field_begin($field, $meta); |
|
| 545 | - echo "<div class='at-repeat' id='{$field['id']}'>"; |
|
| 546 | - |
|
| 547 | - $c = 0; |
|
| 548 | - |
|
| 549 | - if (count($meta) > 0 && is_array($meta)) { |
|
| 550 | - foreach ($meta as $me) { |
|
| 551 | - //for labling toggles |
|
| 552 | - $mmm = $me[$field['fields'][0]['id']]; |
|
| 553 | - echo '<div class="at-repater-block">' . $mmm . '<br/><table class="repeater-table" style="display: none;">'; |
|
| 554 | - if ($field['inline']) { |
|
| 555 | - echo '<tr class="at-inline" VALIGN="top">'; |
|
| 556 | - } |
|
| 557 | - foreach ($field['fields'] as $f) { |
|
| 558 | - //reset var $id for repeater |
|
| 559 | - $id = ''; |
|
| 560 | - $id = $field['id'] . '[' . $c . '][' . $f['id'] . ']'; |
|
| 561 | - $m = $me[$f['id']]; |
|
| 562 | - $m = ($m !== '') ? $m : $f['std']; |
|
| 563 | - if ('image' != $f['type'] && $f['type'] != 'repeater') |
|
| 564 | - $m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m); |
|
| 565 | - //set new id for field in array format |
|
| 566 | - $f['id'] = $id; |
|
| 567 | - if (!$field['inline']) { |
|
| 568 | - echo '<tr>'; |
|
| 569 | - } |
|
| 570 | - call_user_func(array(&$this, 'show_field_' . $f['type']), $f, $m); |
|
| 571 | - if (!$field['inline']) { |
|
| 572 | - echo '</tr>'; |
|
| 573 | - } |
|
| 574 | - } |
|
| 575 | - if ($field['inline']) { |
|
| 576 | - echo '</tr>'; |
|
| 577 | - } |
|
| 578 | - echo '</table> |
|
| 298 | + /** |
|
| 299 | + * Ajax callback for deleting files. |
|
| 300 | + * |
|
| 301 | + * Modified from a function used by "Verve Meta Boxes" plugin ( http://goo.gl/aw64H ) |
|
| 302 | + * |
|
| 303 | + * @since 1.0 |
|
| 304 | + * @access public |
|
| 305 | + */ |
|
| 306 | + public function delete_file() |
|
| 307 | + { |
|
| 308 | + |
|
| 309 | + |
|
| 310 | + // If data is not set, die. |
|
| 311 | + if (!isset($_POST['data'])) |
|
| 312 | + die(); |
|
| 313 | + |
|
| 314 | + list($nonce, $term_id, $key, $attach_id) = explode('|', $_POST['data']); |
|
| 315 | + |
|
| 316 | + if (!wp_verify_nonce($nonce, 'at_ajax_delete')) |
|
| 317 | + die('1'); |
|
| 318 | + |
|
| 319 | + $this->delete_tax_meta($term_id, $key, $attach_id); |
|
| 320 | + |
|
| 321 | + die('0'); |
|
| 322 | + |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + /** |
|
| 326 | + * Ajax callback for deleting files. |
|
| 327 | + * Modified from a function used by "Verve Meta Boxes" plugin (http://goo.gl/LzYSq) |
|
| 328 | + * @since 1.0 |
|
| 329 | + * @access public |
|
| 330 | + */ |
|
| 331 | + public function wp_ajax_delete_image() |
|
| 332 | + { |
|
| 333 | + $term_id = isset($_GET['post_id']) ? intval($_GET['post_id']) : 0; |
|
| 334 | + $field_id = isset($_GET['field_id']) ? $_GET['field_id'] : 0; |
|
| 335 | + $attachment_id = isset($_GET['attachment_id']) ? intval($_GET['attachment_id']) : 0; |
|
| 336 | + $ok = false; |
|
| 337 | + if (strpos($field_id, '[') === false) { |
|
| 338 | + check_admin_referer("at-delete-mupload_" . urldecode($field_id)); |
|
| 339 | + if ($term_id > 0) |
|
| 340 | + $this->delete_tax_meta($term_id, $field_id); |
|
| 341 | + //$ok = wp_delete_attachment( $attachment_id ); |
|
| 342 | + $ok = 1; |
|
| 343 | + } else { |
|
| 344 | + $f = explode('[', urldecode($field_id)); |
|
| 345 | + $f_fiexed = array(); |
|
| 346 | + foreach ($f as $k => $v) { |
|
| 347 | + $f[$k] = str_replace(']', '', $v); |
|
| 348 | + } |
|
| 349 | + $saved = $this->get_tax_meta($term_id, $f[0], true); |
|
| 350 | + if (isset($saved[$f[1]][$f[2]])) { |
|
| 351 | + unset($saved[$f[1]][$f[2]]); |
|
| 352 | + if ($term_id > 0) |
|
| 353 | + update_post_meta($term_id, $f[0], $saved); |
|
| 354 | + //$ok = wp_delete_attachment( $attachment_id ); |
|
| 355 | + $ok = 1; |
|
| 356 | + } |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + |
|
| 360 | + if ($ok) { |
|
| 361 | + echo json_encode(array('status' => 'success')); |
|
| 362 | + die(); |
|
| 363 | + } else { |
|
| 364 | + echo json_encode(array('message' => __('Cannot delete file. Something\'s wrong.', 'geodirectory'))); |
|
| 365 | + die(); |
|
| 366 | + } |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * Ajax callback for reordering Images. |
|
| 371 | + * |
|
| 372 | + * @since 1.0 |
|
| 373 | + * @access public |
|
| 374 | + */ |
|
| 375 | + public function reorder_images() |
|
| 376 | + { |
|
| 377 | + |
|
| 378 | + if (!isset($_POST['data'])) |
|
| 379 | + die(); |
|
| 380 | + |
|
| 381 | + list($order, $term_id, $key, $nonce) = explode('|', $_POST['data']); |
|
| 382 | + |
|
| 383 | + if (!wp_verify_nonce($nonce, 'at_ajax_reorder')) |
|
| 384 | + die('1'); |
|
| 385 | + |
|
| 386 | + parse_str($order, $items); |
|
| 387 | + $items = $items['item']; |
|
| 388 | + $order = 1; |
|
| 389 | + foreach ($items as $item) { |
|
| 390 | + wp_update_post(array('ID' => $item, 'post_parent' => $term_id, 'menu_order' => $order)); |
|
| 391 | + $order++; |
|
| 392 | + } |
|
| 393 | + |
|
| 394 | + die('0'); |
|
| 395 | + |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + /** |
|
| 399 | + * Check Field Color |
|
| 400 | + * |
|
| 401 | + * @since 1.0 |
|
| 402 | + * @access public |
|
| 403 | + */ |
|
| 404 | + public function check_field_color() |
|
| 405 | + { |
|
| 406 | + |
|
| 407 | + if ($this->has_field('color') && $this->is_edit_page()) { |
|
| 408 | + // Enqueu built-in script and style for color picker. |
|
| 409 | + wp_enqueue_style('farbtastic'); |
|
| 410 | + wp_enqueue_script('farbtastic'); |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + /** |
|
| 416 | + * Check Field Date |
|
| 417 | + * |
|
| 418 | + * @since 1.0 |
|
| 419 | + * @access public |
|
| 420 | + */ |
|
| 421 | + public function check_field_date() |
|
| 422 | + { |
|
| 423 | + |
|
| 424 | + if ($this->has_field('date') && $this->is_edit_page()) { |
|
| 425 | + // Enqueu JQuery UI, use proper version. |
|
| 426 | + wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css'); |
|
| 427 | + wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery')); |
|
| 428 | + } |
|
| 429 | + |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + /** |
|
| 433 | + * Check Field Time |
|
| 434 | + * |
|
| 435 | + * @since 1.0 |
|
| 436 | + * @access public |
|
| 437 | + */ |
|
| 438 | + public function check_field_time() |
|
| 439 | + { |
|
| 440 | + |
|
| 441 | + if ($this->has_field('time') && $this->is_edit_page()) { |
|
| 442 | + |
|
| 443 | + // Enqueu JQuery UI, use proper version. |
|
| 444 | + wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css', array(), false, true); |
|
| 445 | + wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'), false, true); |
|
| 446 | + wp_enqueue_script('at-timepicker', 'https://github.com/trentrichardson/jQuery-Timepicker-Addon/raw/master/jquery-ui-timepicker-addon.js', array('tmc-jquery-ui'), false, true); |
|
| 447 | + |
|
| 448 | + } |
|
| 449 | + |
|
| 450 | + } |
|
| 451 | + |
|
| 452 | + /** |
|
| 453 | + * Add Meta Box for multiple post types. |
|
| 454 | + * |
|
| 455 | + * @since 1.0 |
|
| 456 | + * @access public |
|
| 457 | + */ |
|
| 458 | + public function add() |
|
| 459 | + { |
|
| 460 | + |
|
| 461 | + // Loop through array |
|
| 462 | + if (!empty($this->_meta_box['pages'])) { |
|
| 463 | + foreach ($this->_meta_box['pages'] as $page) { |
|
| 464 | + //add fields to edit form |
|
| 465 | + add_action($page . '_edit_form_fields', array(&$this, 'show_edit_form')); |
|
| 466 | + //add fields to add new form |
|
| 467 | + add_action($page . '_add_form_fields', array(&$this, 'show_new_form')); |
|
| 468 | + // this saves the edit fields |
|
| 469 | + add_action('edited_' . $page, array(&$this, 'save'), 10, 2); |
|
| 470 | + // this saves the add fields |
|
| 471 | + add_action('created_' . $page, array(&$this, 'save'), 10, 2); |
|
| 472 | + } |
|
| 473 | + } |
|
| 474 | + |
|
| 475 | + } |
|
| 476 | + |
|
| 477 | + /** |
|
| 478 | + * Callback function to show fields on add new taxonomy term form. |
|
| 479 | + * |
|
| 480 | + * @since 1.0 |
|
| 481 | + * @access public |
|
| 482 | + */ |
|
| 483 | + public function show_new_form($term_id) |
|
| 484 | + { |
|
| 485 | + $this->_form_type = 'new'; |
|
| 486 | + $this->show($term_id); |
|
| 487 | + } |
|
| 488 | + |
|
| 489 | + /** |
|
| 490 | + * Callback function to show fields on term edit form. |
|
| 491 | + * |
|
| 492 | + * @since 1.0 |
|
| 493 | + * @access public |
|
| 494 | + */ |
|
| 495 | + public function show_edit_form($term_id) |
|
| 496 | + { |
|
| 497 | + $this->_form_type = 'edit'; |
|
| 498 | + $this->show($term_id); |
|
| 499 | + } |
|
| 500 | + |
|
| 501 | + |
|
| 502 | + /** |
|
| 503 | + * Callback function to show fields in meta box. |
|
| 504 | + * |
|
| 505 | + * @since 1.0 |
|
| 506 | + * @access public |
|
| 507 | + */ |
|
| 508 | + public function show($term_id) |
|
| 509 | + { |
|
| 510 | + |
|
| 511 | + wp_nonce_field(basename(__FILE__), 'tax_meta_class_nonce'); |
|
| 512 | + |
|
| 513 | + foreach ($this->_fields as $field) { |
|
| 514 | + $meta = $this->get_tax_meta($term_id, $field['id'], !$field['multiple']); |
|
| 515 | + $meta = ($meta !== '') ? $meta : $field['std']; |
|
| 516 | + if ('image' != $field['type'] && $field['type'] != 'repeater') |
|
| 517 | + $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta); |
|
| 518 | + |
|
| 519 | + if ($field['validate_func']) { |
|
| 520 | + echo '<tr class="form-field form-required ' . $field['style'] . '">'; |
|
| 521 | + } else { |
|
| 522 | + echo '<tr class="form-field ' . $field['style'] . '">'; |
|
| 523 | + } |
|
| 524 | + |
|
| 525 | + // Call Separated methods for displaying each type of field. |
|
| 526 | + call_user_func(array(&$this, 'show_field_' . $field['type']), $field, $meta); |
|
| 527 | + echo '</tr>'; |
|
| 528 | + } |
|
| 529 | + echo '</table>'; |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + /** |
|
| 533 | + * Show Repeater Fields. |
|
| 534 | + * |
|
| 535 | + * @param string $field |
|
| 536 | + * @param string $meta |
|
| 537 | + * @since 1.0 |
|
| 538 | + * @access public |
|
| 539 | + */ |
|
| 540 | + public function show_field_repeater($field, $meta) |
|
| 541 | + { |
|
| 542 | + // Get Plugin Path |
|
| 543 | + $plugin_path = $this->SelfPath; |
|
| 544 | + $this->show_field_begin($field, $meta); |
|
| 545 | + echo "<div class='at-repeat' id='{$field['id']}'>"; |
|
| 546 | + |
|
| 547 | + $c = 0; |
|
| 548 | + |
|
| 549 | + if (count($meta) > 0 && is_array($meta)) { |
|
| 550 | + foreach ($meta as $me) { |
|
| 551 | + //for labling toggles |
|
| 552 | + $mmm = $me[$field['fields'][0]['id']]; |
|
| 553 | + echo '<div class="at-repater-block">' . $mmm . '<br/><table class="repeater-table" style="display: none;">'; |
|
| 554 | + if ($field['inline']) { |
|
| 555 | + echo '<tr class="at-inline" VALIGN="top">'; |
|
| 556 | + } |
|
| 557 | + foreach ($field['fields'] as $f) { |
|
| 558 | + //reset var $id for repeater |
|
| 559 | + $id = ''; |
|
| 560 | + $id = $field['id'] . '[' . $c . '][' . $f['id'] . ']'; |
|
| 561 | + $m = $me[$f['id']]; |
|
| 562 | + $m = ($m !== '') ? $m : $f['std']; |
|
| 563 | + if ('image' != $f['type'] && $f['type'] != 'repeater') |
|
| 564 | + $m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m); |
|
| 565 | + //set new id for field in array format |
|
| 566 | + $f['id'] = $id; |
|
| 567 | + if (!$field['inline']) { |
|
| 568 | + echo '<tr>'; |
|
| 569 | + } |
|
| 570 | + call_user_func(array(&$this, 'show_field_' . $f['type']), $f, $m); |
|
| 571 | + if (!$field['inline']) { |
|
| 572 | + echo '</tr>'; |
|
| 573 | + } |
|
| 574 | + } |
|
| 575 | + if ($field['inline']) { |
|
| 576 | + echo '</tr>'; |
|
| 577 | + } |
|
| 578 | + echo '</table> |
|
| 579 | 579 | <span class="at-re-toggle"><img src="'; |
| 580 | - if ($this->_Local_images) { |
|
| 581 | - echo $plugin_path . '/images/edit.png'; |
|
| 582 | - } else { |
|
| 583 | - echo 'http://i.imgur.com/ka0E2.png'; |
|
| 584 | - } |
|
| 585 | - echo '" alt="Edit" title="Edit"/></span> |
|
| 580 | + if ($this->_Local_images) { |
|
| 581 | + echo $plugin_path . '/images/edit.png'; |
|
| 582 | + } else { |
|
| 583 | + echo 'http://i.imgur.com/ka0E2.png'; |
|
| 584 | + } |
|
| 585 | + echo '" alt="Edit" title="Edit"/></span> |
|
| 586 | 586 | <img src="'; |
| 587 | - if ($this->_Local_images) { |
|
| 588 | - echo $plugin_path . '/images/remove.png'; |
|
| 589 | - } else { |
|
| 590 | - echo 'http://i.imgur.com/g8Duj.png'; |
|
| 591 | - } |
|
| 592 | - echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>'; |
|
| 593 | - $c = $c + 1; |
|
| 594 | - |
|
| 595 | - } |
|
| 596 | - $this->show_field_end($field, $meta); |
|
| 597 | - } |
|
| 598 | - |
|
| 599 | - echo '<img src="'; |
|
| 600 | - if ($this->_Local_images) { |
|
| 601 | - echo $plugin_path . '/images/add.png'; |
|
| 602 | - } else { |
|
| 603 | - echo 'http://i.imgur.com/w5Tuc.png'; |
|
| 604 | - } |
|
| 605 | - echo '" alt="' . __('Add', 'geodirectory') . '" title="' . __('Add', 'geodirectory') . '" id="add-' . $field['id'] . '"><br/></div>'; |
|
| 606 | - |
|
| 607 | - //create all fields once more for js function and catch with object buffer |
|
| 608 | - ob_start(); |
|
| 609 | - echo '<div class="at-repater-block"><table class="repeater-table">'; |
|
| 610 | - if ($field['inline']) { |
|
| 611 | - echo '<tr class="at-inline" VALIGN="top">'; |
|
| 612 | - } |
|
| 613 | - foreach ($field['fields'] as $f) { |
|
| 614 | - //reset var $id for repeater |
|
| 615 | - $id = ''; |
|
| 616 | - $id = $field['id'] . '[CurrentCounter][' . $f['id'] . ']'; |
|
| 617 | - $f['id'] = $id; |
|
| 618 | - if (!$field['inline']) { |
|
| 619 | - echo '<tr>'; |
|
| 620 | - } |
|
| 621 | - call_user_func(array(&$this, 'show_field_' . $f['type']), $f, ''); |
|
| 622 | - if (!$field['inline']) { |
|
| 623 | - echo '</tr>'; |
|
| 624 | - } |
|
| 625 | - } |
|
| 626 | - if ($field['inline']) { |
|
| 627 | - echo '</tr>'; |
|
| 628 | - } |
|
| 629 | - echo '</table><img src="'; |
|
| 630 | - if ($this->_Local_images) { |
|
| 631 | - echo $plugin_path . '/images/remove.png'; |
|
| 632 | - } else { |
|
| 633 | - echo 'http://i.imgur.com/g8Duj.png'; |
|
| 634 | - } |
|
| 635 | - echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>'; |
|
| 636 | - $counter = 'countadd_' . $field['id']; |
|
| 637 | - $js_code = ob_get_clean(); |
|
| 638 | - $js_code = str_replace("'", "\"", $js_code); |
|
| 639 | - $js_code = str_replace("CurrentCounter", "' + " . $counter . " + '", $js_code); |
|
| 640 | - echo '<script> |
|
| 587 | + if ($this->_Local_images) { |
|
| 588 | + echo $plugin_path . '/images/remove.png'; |
|
| 589 | + } else { |
|
| 590 | + echo 'http://i.imgur.com/g8Duj.png'; |
|
| 591 | + } |
|
| 592 | + echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>'; |
|
| 593 | + $c = $c + 1; |
|
| 594 | + |
|
| 595 | + } |
|
| 596 | + $this->show_field_end($field, $meta); |
|
| 597 | + } |
|
| 598 | + |
|
| 599 | + echo '<img src="'; |
|
| 600 | + if ($this->_Local_images) { |
|
| 601 | + echo $plugin_path . '/images/add.png'; |
|
| 602 | + } else { |
|
| 603 | + echo 'http://i.imgur.com/w5Tuc.png'; |
|
| 604 | + } |
|
| 605 | + echo '" alt="' . __('Add', 'geodirectory') . '" title="' . __('Add', 'geodirectory') . '" id="add-' . $field['id'] . '"><br/></div>'; |
|
| 606 | + |
|
| 607 | + //create all fields once more for js function and catch with object buffer |
|
| 608 | + ob_start(); |
|
| 609 | + echo '<div class="at-repater-block"><table class="repeater-table">'; |
|
| 610 | + if ($field['inline']) { |
|
| 611 | + echo '<tr class="at-inline" VALIGN="top">'; |
|
| 612 | + } |
|
| 613 | + foreach ($field['fields'] as $f) { |
|
| 614 | + //reset var $id for repeater |
|
| 615 | + $id = ''; |
|
| 616 | + $id = $field['id'] . '[CurrentCounter][' . $f['id'] . ']'; |
|
| 617 | + $f['id'] = $id; |
|
| 618 | + if (!$field['inline']) { |
|
| 619 | + echo '<tr>'; |
|
| 620 | + } |
|
| 621 | + call_user_func(array(&$this, 'show_field_' . $f['type']), $f, ''); |
|
| 622 | + if (!$field['inline']) { |
|
| 623 | + echo '</tr>'; |
|
| 624 | + } |
|
| 625 | + } |
|
| 626 | + if ($field['inline']) { |
|
| 627 | + echo '</tr>'; |
|
| 628 | + } |
|
| 629 | + echo '</table><img src="'; |
|
| 630 | + if ($this->_Local_images) { |
|
| 631 | + echo $plugin_path . '/images/remove.png'; |
|
| 632 | + } else { |
|
| 633 | + echo 'http://i.imgur.com/g8Duj.png'; |
|
| 634 | + } |
|
| 635 | + echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>'; |
|
| 636 | + $counter = 'countadd_' . $field['id']; |
|
| 637 | + $js_code = ob_get_clean(); |
|
| 638 | + $js_code = str_replace("'", "\"", $js_code); |
|
| 639 | + $js_code = str_replace("CurrentCounter", "' + " . $counter . " + '", $js_code); |
|
| 640 | + echo '<script> |
|
| 641 | 641 | jQuery(document).ready(function() { |
| 642 | 642 | var ' . $counter . ' = ' . $c . '; |
| 643 | 643 | jQuery("#add-' . $field['id'] . '").live(\'click\', function() { |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | }); |
| 651 | 651 | }); |
| 652 | 652 | </script>'; |
| 653 | - echo '<br/><style> |
|
| 653 | + echo '<br/><style> |
|
| 654 | 654 | .at-inline{line-height: 1 !important;} |
| 655 | 655 | .at-inline .at-field{border: 0px !important;} |
| 656 | 656 | .at-inline .at-label{margin: 0 0 1px !important;} |
@@ -658,531 +658,531 @@ discard block |
||
| 658 | 658 | .at-inline .at-textarea{width: 100px; height: 75px;} |
| 659 | 659 | .at-repater-block{background-color: #FFFFFF;border: 1px solid;margin: 2px;} |
| 660 | 660 | </style>'; |
| 661 | - $this->show_field_end($field, $meta); |
|
| 662 | - } |
|
| 663 | - |
|
| 664 | - /** |
|
| 665 | - * Begin Field. |
|
| 666 | - * |
|
| 667 | - * @param string $field |
|
| 668 | - * @param string $meta |
|
| 669 | - * @since 1.0 |
|
| 670 | - * @access public |
|
| 671 | - */ |
|
| 672 | - public function show_field_begin($field, $meta) |
|
| 673 | - { |
|
| 674 | - if (isset($field['group'])) { |
|
| 675 | - if ($field['group'] == "start") { |
|
| 676 | - echo "<td class='at-field'>"; |
|
| 677 | - } |
|
| 678 | - } else { |
|
| 679 | - if ($this->_form_type == 'edit') { |
|
| 680 | - echo '<th valign="top" scope="row">'; |
|
| 681 | - } else { |
|
| 682 | - if ($field['validate_func']) { |
|
| 683 | - echo '<td><div class="form-field form-required">'; |
|
| 684 | - } else { |
|
| 685 | - echo '<td><div class="form-field">'; |
|
| 686 | - } |
|
| 687 | - } |
|
| 688 | - } |
|
| 689 | - if ($field['name'] != '' || $field['name'] != FALSE) { |
|
| 690 | - //echo "<div class='at-label'>"; |
|
| 691 | - echo "<label for='{$field['id']}'>{$field['name']}</label>"; |
|
| 692 | - //echo "</div>"; |
|
| 693 | - } |
|
| 694 | - if ($this->_form_type == 'edit') { |
|
| 695 | - echo '</th><td>'; |
|
| 696 | - } |
|
| 697 | - } |
|
| 698 | - |
|
| 699 | - /** |
|
| 700 | - * End Field. |
|
| 701 | - * |
|
| 702 | - * @param string $field |
|
| 703 | - * @param string $meta |
|
| 704 | - * @since 1.0 |
|
| 705 | - * @access public |
|
| 706 | - */ |
|
| 707 | - public function show_field_end($field, $meta = NULL, $group = false) |
|
| 708 | - { |
|
| 709 | - if (isset($field['group'])) { |
|
| 710 | - if ($group == 'end') { |
|
| 711 | - if ($field['desc'] != '') { |
|
| 712 | - echo "<p class='desc-field'>{$field['desc']}</p></td>"; |
|
| 713 | - } else { |
|
| 714 | - echo "</td>"; |
|
| 715 | - } |
|
| 716 | - } else { |
|
| 717 | - if ($field['desc'] != '') { |
|
| 718 | - echo "<p class='desc-field'>{$field['desc']}</p><br/>"; |
|
| 719 | - } else { |
|
| 720 | - echo '<br/>'; |
|
| 721 | - } |
|
| 722 | - } |
|
| 723 | - } else { |
|
| 724 | - if ($field['desc'] != '') { |
|
| 725 | - echo "<p class='desc-field'>{$field['desc']}</p>"; |
|
| 726 | - } |
|
| 727 | - if ($this->_form_type == 'edit') { |
|
| 728 | - echo '</td>'; |
|
| 729 | - } else { |
|
| 730 | - echo '</td></div>'; |
|
| 731 | - } |
|
| 732 | - } |
|
| 733 | - } |
|
| 734 | - |
|
| 735 | - /** |
|
| 736 | - * Show Field Text. |
|
| 737 | - * |
|
| 738 | - * @param string $field |
|
| 739 | - * @param string $meta |
|
| 740 | - * @since 1.0 |
|
| 741 | - * @access public |
|
| 742 | - */ |
|
| 743 | - public function show_field_text($field, $meta) |
|
| 744 | - { |
|
| 745 | - $this->show_field_begin($field, $meta); |
|
| 746 | - echo "<input type='text' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='30' />"; |
|
| 747 | - $this->show_field_end($field, $meta); |
|
| 748 | - } |
|
| 749 | - |
|
| 750 | - /** |
|
| 751 | - * Show Field hidden. |
|
| 752 | - * |
|
| 753 | - * @param string $field |
|
| 754 | - * @param string|mixed $meta |
|
| 755 | - * @since 0.1.3 |
|
| 756 | - * @access public |
|
| 757 | - */ |
|
| 758 | - public function show_field_hidden($field, $meta) |
|
| 759 | - { |
|
| 760 | - //$this->show_field_begin( $field, $meta ); |
|
| 761 | - echo "<input type='hidden' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}'/>"; |
|
| 762 | - //$this->show_field_end( $field, $meta ); |
|
| 763 | - } |
|
| 764 | - |
|
| 765 | - /** |
|
| 766 | - * Show Field Paragraph. |
|
| 767 | - * |
|
| 768 | - * @param string $field |
|
| 769 | - * @since 0.1.3 |
|
| 770 | - * @access public |
|
| 771 | - */ |
|
| 772 | - public function show_field_paragraph($field) |
|
| 773 | - { |
|
| 774 | - //$this->show_field_begin( $field, $meta ); |
|
| 775 | - echo '<p>' . $field['value'] . '</p>'; |
|
| 776 | - //$this->show_field_end( $field, $meta ); |
|
| 777 | - } |
|
| 778 | - |
|
| 779 | - /** |
|
| 780 | - * Show Field Textarea. |
|
| 781 | - * |
|
| 782 | - * @param string $field |
|
| 783 | - * @param string $meta |
|
| 784 | - * @since 1.0 |
|
| 785 | - * @access public |
|
| 786 | - */ |
|
| 787 | - public function show_field_textarea($field, $meta) |
|
| 788 | - { |
|
| 789 | - $this->show_field_begin($field, $meta); |
|
| 790 | - echo "<textarea class='at-textarea large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>"; |
|
| 791 | - $this->show_field_end($field, $meta); |
|
| 792 | - } |
|
| 793 | - |
|
| 794 | - /** |
|
| 795 | - * Show Field Select. |
|
| 796 | - * |
|
| 797 | - * @param string $field |
|
| 798 | - * @param string $meta |
|
| 799 | - * @since 1.0 |
|
| 800 | - * @access public |
|
| 801 | - */ |
|
| 802 | - public function show_field_select($field, $meta) |
|
| 803 | - { |
|
| 804 | - |
|
| 805 | - if (!is_array($meta)) |
|
| 806 | - $meta = (array)$meta; |
|
| 807 | - |
|
| 808 | - $this->show_field_begin($field, $meta); |
|
| 809 | - echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">"; |
|
| 810 | - foreach ($field['options'] as $key => $value) { |
|
| 811 | - echo "<option value='{$key}'" . selected(in_array($key, $meta), true, false) . ">{$value}</option>"; |
|
| 812 | - } |
|
| 813 | - echo "</select>"; |
|
| 814 | - $this->show_field_end($field, $meta); |
|
| 815 | - |
|
| 816 | - } |
|
| 817 | - |
|
| 818 | - /** |
|
| 819 | - * Show Radio Field. |
|
| 820 | - * |
|
| 821 | - * @param string $field |
|
| 822 | - * @param string $meta |
|
| 823 | - * @since 1.0 |
|
| 824 | - * @access public |
|
| 825 | - */ |
|
| 826 | - public function show_field_radio($field, $meta) |
|
| 827 | - { |
|
| 828 | - |
|
| 829 | - if (!is_array($meta)) |
|
| 830 | - $meta = (array)$meta; |
|
| 831 | - |
|
| 832 | - $this->show_field_begin($field, $meta); |
|
| 833 | - foreach ($field['options'] as $key => $value) { |
|
| 834 | - echo "<input type='radio' class='at-radio' name='{$field['id']}' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> <span class='at-radio-label'>{$value}</span>"; |
|
| 835 | - } |
|
| 836 | - $this->show_field_end($field, $meta); |
|
| 837 | - } |
|
| 838 | - |
|
| 839 | - /** |
|
| 840 | - * Show Checkbox Field. |
|
| 841 | - * |
|
| 842 | - * @param string $field |
|
| 843 | - * @param string $meta |
|
| 844 | - * @since 1.0 |
|
| 845 | - * @access public |
|
| 846 | - */ |
|
| 847 | - public function show_field_checkbox($field, $meta) |
|
| 848 | - { |
|
| 849 | - |
|
| 850 | - $this->show_field_begin($field, $meta); |
|
| 851 | - echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'" . checked(!empty($meta), true, false) . " /> {$field['desc']}"; |
|
| 852 | - $this->show_field_end($field, $meta); |
|
| 853 | - } |
|
| 854 | - |
|
| 855 | - /** |
|
| 856 | - * Show Wysiwig Field. |
|
| 857 | - * |
|
| 858 | - * @param string $field |
|
| 859 | - * @param string $meta |
|
| 860 | - * @since 1.0 |
|
| 861 | - * @access public |
|
| 862 | - */ |
|
| 863 | - public function show_field_wysiwyg($field, $meta) |
|
| 864 | - { |
|
| 865 | - $this->show_field_begin($field, $meta); |
|
| 866 | - // Add TinyMCE script for WP version < 3.3 |
|
| 867 | - global $wp_version; |
|
| 868 | - |
|
| 869 | - if (version_compare($wp_version, '3.2.1') < 1) { |
|
| 870 | - echo "<textarea class='at-wysiwyg theEditor large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>"; |
|
| 871 | - } else { |
|
| 872 | - // Use new wp_editor() since WP 3.3 |
|
| 873 | - wp_editor(stripslashes(html_entity_decode($meta)), $field['id'], array('editor_class' => 'at-wysiwyg')); |
|
| 874 | - } |
|
| 875 | - $this->show_field_end($field, $meta); |
|
| 876 | - } |
|
| 877 | - |
|
| 878 | - /** |
|
| 879 | - * Show File Field. |
|
| 880 | - * |
|
| 881 | - * @global object $post The current post object. |
|
| 882 | - * @param string $field |
|
| 883 | - * @param string $meta |
|
| 884 | - * @since 1.0 |
|
| 885 | - * @access public |
|
| 886 | - */ |
|
| 887 | - public function show_field_file($field, $meta) |
|
| 888 | - { |
|
| 889 | - |
|
| 890 | - global $post; |
|
| 891 | - |
|
| 892 | - if (!is_array($meta)) |
|
| 893 | - $meta = (array)$meta; |
|
| 894 | - |
|
| 895 | - $this->show_field_begin($field, $meta); |
|
| 896 | - echo "{$field['desc']}<br />"; |
|
| 897 | - |
|
| 898 | - if (!empty($meta)) { |
|
| 899 | - $nonce = wp_create_nonce('at_ajax_delete'); |
|
| 900 | - echo '<div style="margin-bottom: 10px"><strong>' . __('Uploaded files', 'geodirectory') . '</strong></div>'; |
|
| 901 | - echo '<ol class="at-upload">'; |
|
| 902 | - foreach ($meta as $att) { |
|
| 903 | - // if (wp_attachment_is_image($att)) continue; // what's image uploader for? |
|
| 904 | - echo "<li>" . wp_get_attachment_link($att, '', false, false, ' ') . " (<a class='at-delete-file' href='#' rel='{$nonce}|{$post->ID}|{$field['id']}|{$att}'>" . __('Remove', 'geodirectory') . "</a>)</li>"; |
|
| 905 | - } |
|
| 906 | - echo '</ol>'; |
|
| 907 | - } |
|
| 908 | - |
|
| 909 | - // show form upload |
|
| 910 | - |
|
| 911 | - echo "<div class='at-file-upload-label'>"; |
|
| 912 | - echo "<strong>" . __('Upload new files', 'geodirectory') . "</strong>"; |
|
| 913 | - echo "</div>"; |
|
| 914 | - echo "<div class='new-files'>"; |
|
| 915 | - echo "<div class='file-input'>"; |
|
| 916 | - echo "<input type='file' name='{$field['id']}[]' />"; |
|
| 917 | - echo "</div><!-- End .file-input -->"; |
|
| 918 | - echo "<a class='at-add-file button' href='#'>" . __('Add more files', 'geodirectory') . "</a>"; |
|
| 919 | - echo "</div><!-- End .new-files -->"; |
|
| 920 | - echo "</td>"; |
|
| 921 | - $this->show_field_end($field, $meta); |
|
| 922 | - } |
|
| 923 | - |
|
| 924 | - /** |
|
| 925 | - * Show Image Field. |
|
| 926 | - * |
|
| 927 | - * @param array $field |
|
| 928 | - * @param array $meta |
|
| 929 | - * @since 1.0 |
|
| 930 | - * @access public |
|
| 931 | - */ |
|
| 932 | - public function show_field_image($field, $meta) |
|
| 933 | - { |
|
| 934 | - $this->show_field_begin($field, $meta); |
|
| 935 | - $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false); |
|
| 936 | - if (is_array($meta)) { |
|
| 937 | - if (isset($meta[0]) && is_array($meta[0])) |
|
| 938 | - $meta = $meta[0]; |
|
| 939 | - } |
|
| 940 | - |
|
| 941 | - $uploads = wp_upload_dir(); |
|
| 942 | - if (is_array($meta) && isset($meta['src']) && $meta['src'] != '') { |
|
| 943 | - $file_info = pathinfo($meta['src']); |
|
| 944 | - |
|
| 945 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
| 946 | - $sub_dir = $file_info['dirname']; |
|
| 947 | - |
|
| 948 | - $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
| 949 | - $uploads_baseurl = $uploads['baseurl']; |
|
| 950 | - $uploads_path = $uploads['path']; |
|
| 951 | - |
|
| 952 | - $file_name = $file_info['basename']; |
|
| 953 | - |
|
| 954 | - if (strpos($sub_dir, 'https://') !== false) { |
|
| 955 | - $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
| 956 | - } else { |
|
| 957 | - $uploads['baseurl'] = str_replace('https://', 'http://', $uploads['baseurl']); |
|
| 958 | - } |
|
| 959 | - $sub_dir = str_replace($uploads['baseurl'], '', $sub_dir); |
|
| 960 | - |
|
| 961 | - $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 962 | - |
|
| 963 | - $meta['src'] = $uploads_url . '/' . $file_name; |
|
| 964 | - |
|
| 965 | - $html .= "<span class='mupload_img_holder'><img src='" . $meta['src'] . "' style='max-height: 150px;max-width: 150px;' /></span>"; |
|
| 966 | - $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='" . $meta['id'] . "' />"; |
|
| 967 | - $html .= "<input type='hidden' class='" . $field['id'] . "[src]' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='" . $meta['src'] . "' />"; |
|
| 968 | - $html .= "<input class='at-delete_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Remove Image', 'geodirectory') . "' />"; |
|
| 969 | - } else { |
|
| 970 | - $html .= "<span class='mupload_img_holder'></span>"; |
|
| 971 | - $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='' />"; |
|
| 972 | - $html .= "<input class='" . $field['id'] . "[src]' style='position:absolute;left:-500px;width:50px;' type='text' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='' />"; |
|
| 973 | - $html .= "<input class='at-upload_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Upload Image', 'geodirectory') . "' />"; |
|
| 974 | - } |
|
| 975 | - echo $html; |
|
| 976 | - $this->show_field_end($field, $meta); |
|
| 977 | - } |
|
| 978 | - |
|
| 979 | - /** |
|
| 980 | - * Show Color Field. |
|
| 981 | - * |
|
| 982 | - * @param string $field |
|
| 983 | - * @param string $meta |
|
| 984 | - * @since 1.0 |
|
| 985 | - * @access public |
|
| 986 | - */ |
|
| 987 | - public function show_field_color($field, $meta) |
|
| 988 | - { |
|
| 989 | - |
|
| 990 | - if (empty($meta)) |
|
| 991 | - $meta = '#'; |
|
| 992 | - |
|
| 993 | - $this->show_field_begin($field, $meta); |
|
| 994 | - |
|
| 995 | - echo "<input class='at-color' type='text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='8' />"; |
|
| 996 | - // echo "<a href='#' class='at-color-select button' rel='{$field['id']}'>" . __( 'Select a color' ) . "</a>"; |
|
| 997 | - echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='" . __('Select a color', 'geodirectory') . "'/>"; |
|
| 998 | - echo "<div style='display:none' class='at-color-picker' rel='{$field['id']}'></div>"; |
|
| 999 | - $this->show_field_end($field, $meta); |
|
| 1000 | - |
|
| 1001 | - } |
|
| 1002 | - |
|
| 1003 | - /** |
|
| 1004 | - * Show Checkbox List Field |
|
| 1005 | - * |
|
| 1006 | - * @param string $field |
|
| 1007 | - * @param string $meta |
|
| 1008 | - * @since 1.0 |
|
| 1009 | - * @access public |
|
| 1010 | - */ |
|
| 1011 | - public function show_field_checkbox_list($field, $meta) |
|
| 1012 | - { |
|
| 1013 | - |
|
| 1014 | - if (!is_array($meta)) |
|
| 1015 | - $meta = (array)$meta; |
|
| 1016 | - |
|
| 1017 | - $this->show_field_begin($field, $meta); |
|
| 1018 | - |
|
| 1019 | - $html = array(); |
|
| 1020 | - |
|
| 1021 | - foreach ($field['options'] as $key => $value) { |
|
| 1022 | - $html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> {$value}"; |
|
| 1023 | - } |
|
| 1024 | - |
|
| 1025 | - echo implode('<br />', $html); |
|
| 1026 | - |
|
| 1027 | - $this->show_field_end($field, $meta); |
|
| 1028 | - |
|
| 1029 | - } |
|
| 1030 | - |
|
| 1031 | - /** |
|
| 1032 | - * Show Date Field. |
|
| 1033 | - * |
|
| 1034 | - * @param string $field |
|
| 1035 | - * @param string $meta |
|
| 1036 | - * @since 1.0 |
|
| 1037 | - * @access public |
|
| 1038 | - */ |
|
| 1039 | - public function show_field_date($field, $meta) |
|
| 1040 | - { |
|
| 1041 | - $this->show_field_begin($field, $meta); |
|
| 1042 | - echo "<input type='text' class='at-date' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />"; |
|
| 1043 | - $this->show_field_end($field, $meta); |
|
| 1044 | - } |
|
| 1045 | - |
|
| 1046 | - /** |
|
| 1047 | - * Show time field. |
|
| 1048 | - * |
|
| 1049 | - * @param string $field |
|
| 1050 | - * @param string $meta |
|
| 1051 | - * @since 1.0 |
|
| 1052 | - * @access public |
|
| 1053 | - */ |
|
| 1054 | - public function show_field_time($field, $meta) |
|
| 1055 | - { |
|
| 1056 | - $this->show_field_begin($field, $meta); |
|
| 1057 | - echo "<input type='text' class='at-time' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />"; |
|
| 1058 | - $this->show_field_end($field, $meta); |
|
| 1059 | - } |
|
| 1060 | - |
|
| 1061 | - /** |
|
| 1062 | - * Show Posts field. |
|
| 1063 | - * used creating a posts/pages/custom types checkboxlist or a select dropdown |
|
| 1064 | - * |
|
| 1065 | - * @global object $post The current post object. |
|
| 1066 | - * @param string $field |
|
| 1067 | - * @param string $meta |
|
| 1068 | - * @since 1.0 |
|
| 1069 | - * @access public |
|
| 1070 | - */ |
|
| 1071 | - public function show_field_posts($field, $meta) |
|
| 1072 | - { |
|
| 1073 | - global $post; |
|
| 1074 | - |
|
| 1075 | - if (!is_array($meta)) $meta = (array)$meta; |
|
| 1076 | - $this->show_field_begin($field, $meta); |
|
| 1077 | - $options = $field['options']; |
|
| 1078 | - $posts = get_posts($options['args']); |
|
| 1079 | - |
|
| 1080 | - // checkbox_list |
|
| 1081 | - if ('checkbox_list' == $options['type']) { |
|
| 1082 | - foreach ($posts as $p) { |
|
| 1083 | - echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'" . checked(in_array($p->ID, $meta), true, false) . " /> $p->post_title<br/>"; |
|
| 1084 | - } |
|
| 1085 | - } // select |
|
| 1086 | - else { |
|
| 1087 | - echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">"; |
|
| 1088 | - foreach ($posts as $p) { |
|
| 1089 | - echo "<option value='$p->ID'" . selected(in_array($p->ID, $meta), true, false) . ">$p->post_title</option>"; |
|
| 1090 | - } |
|
| 1091 | - echo "</select>"; |
|
| 1092 | - } |
|
| 1093 | - |
|
| 1094 | - $this->show_field_end($field, $meta); |
|
| 1095 | - } |
|
| 1096 | - |
|
| 1097 | - /** |
|
| 1098 | - * Show Taxonomy field. |
|
| 1099 | - * used creating a category/tags/custom taxonomy checkboxlist or a select dropdown |
|
| 1100 | - * |
|
| 1101 | - * @global object $post The current post object. |
|
| 1102 | - * @param string $field |
|
| 1103 | - * @param string $meta |
|
| 1104 | - * @since 1.0 |
|
| 1105 | - * @access public |
|
| 1106 | - * |
|
| 1107 | - * @uses get_terms() |
|
| 1108 | - */ |
|
| 1109 | - public function show_field_taxonomy($field, $meta) |
|
| 1110 | - { |
|
| 1111 | - global $post; |
|
| 1112 | - |
|
| 1113 | - if (!is_array($meta)) $meta = (array)$meta; |
|
| 1114 | - $this->show_field_begin($field, $meta); |
|
| 1115 | - $options = $field['options']; |
|
| 1116 | - $terms = get_terms($options['taxonomy'], $options['args']); |
|
| 1117 | - |
|
| 1118 | - // checkbox_list |
|
| 1119 | - if ('checkbox_list' == $options['type']) { |
|
| 1120 | - foreach ($terms as $term) { |
|
| 1121 | - echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'" . checked(in_array($term->slug, $meta), true, false) . " /> $term->name<br/>"; |
|
| 1122 | - } |
|
| 1123 | - } // select |
|
| 1124 | - else { |
|
| 1125 | - echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">"; |
|
| 1126 | - foreach ($terms as $term) { |
|
| 1127 | - echo "<option value='$term->slug'" . selected(in_array($term->slug, $meta), true, false) . ">$term->name</option>"; |
|
| 1128 | - } |
|
| 1129 | - echo "</select>"; |
|
| 1130 | - } |
|
| 1131 | - |
|
| 1132 | - $this->show_field_end($field, $meta); |
|
| 1133 | - } |
|
| 1134 | - |
|
| 1135 | - /** |
|
| 1136 | - * Save Data from Metabox |
|
| 1137 | - * |
|
| 1138 | - * @param string $term_id The term ID. |
|
| 1139 | - * @since 1.0 |
|
| 1140 | - * @access public |
|
| 1141 | - * @return string |
|
| 1142 | - */ |
|
| 1143 | - public function save($term_id) |
|
| 1144 | - { |
|
| 1145 | - |
|
| 1146 | - $taxnow = ''; |
|
| 1147 | - if (isset($_POST['taxonomy'])) |
|
| 1148 | - $taxnow = $_POST['taxonomy']; |
|
| 1149 | - |
|
| 1150 | - if (!isset($term_id) // Check Revision |
|
| 1151 | - || (!in_array($taxnow, $this->_meta_box['pages'])) // Check if current taxonomy type is supported. |
|
| 1152 | - || (!check_admin_referer(basename(__FILE__), 'tax_meta_class_nonce')) // Check nonce - Security |
|
| 1153 | - || (!current_user_can('manage_categories')) |
|
| 1154 | - ) // Check permission |
|
| 1155 | - { |
|
| 1156 | - return $term_id; |
|
| 1157 | - } |
|
| 1158 | - |
|
| 1159 | - |
|
| 1160 | - foreach ($this->_fields as $field) { |
|
| 1161 | - |
|
| 1162 | - $name = $field['id']; |
|
| 1163 | - $type = $field['type']; |
|
| 1164 | - $old = $this->get_tax_meta($term_id, $name, !$field['multiple']); |
|
| 1165 | - $new = (isset($_POST[$name])) ? $_POST[$name] : (($field['multiple']) ? array() : ''); |
|
| 1166 | - |
|
| 1167 | - // Validate meta value |
|
| 1168 | - if (class_exists('Tax_Meta_Validate') && method_exists('Tax_Meta_Validate', $field['validate_func'])) { |
|
| 1169 | - $new = call_user_func(array('Tax_Meta_Validate', $field['validate_func']), $new); |
|
| 1170 | - } |
|
| 1171 | - |
|
| 1172 | - |
|
| 1173 | - if ($name == 'ct_cat_icon') { |
|
| 1174 | - |
|
| 1175 | - $upload_dir = wp_upload_dir(); |
|
| 1176 | - |
|
| 1177 | - $image_name_arr = explode('/', $new['src']); |
|
| 1178 | - //$old_filename = end($image_name_arr); |
|
| 1179 | - //$img_name_arr = explode('.',$old_filename); |
|
| 1180 | - |
|
| 1181 | - //$old_filename = $upload_dir['path'].'/'.$old_filename; |
|
| 1182 | - |
|
| 1183 | - $new_filename = $upload_dir['path'] . '/' . 'cat_icon_' . $term_id . '.png'; |
|
| 1184 | - |
|
| 1185 | - /*rename($old_filename, $new_filename); |
|
| 661 | + $this->show_field_end($field, $meta); |
|
| 662 | + } |
|
| 663 | + |
|
| 664 | + /** |
|
| 665 | + * Begin Field. |
|
| 666 | + * |
|
| 667 | + * @param string $field |
|
| 668 | + * @param string $meta |
|
| 669 | + * @since 1.0 |
|
| 670 | + * @access public |
|
| 671 | + */ |
|
| 672 | + public function show_field_begin($field, $meta) |
|
| 673 | + { |
|
| 674 | + if (isset($field['group'])) { |
|
| 675 | + if ($field['group'] == "start") { |
|
| 676 | + echo "<td class='at-field'>"; |
|
| 677 | + } |
|
| 678 | + } else { |
|
| 679 | + if ($this->_form_type == 'edit') { |
|
| 680 | + echo '<th valign="top" scope="row">'; |
|
| 681 | + } else { |
|
| 682 | + if ($field['validate_func']) { |
|
| 683 | + echo '<td><div class="form-field form-required">'; |
|
| 684 | + } else { |
|
| 685 | + echo '<td><div class="form-field">'; |
|
| 686 | + } |
|
| 687 | + } |
|
| 688 | + } |
|
| 689 | + if ($field['name'] != '' || $field['name'] != FALSE) { |
|
| 690 | + //echo "<div class='at-label'>"; |
|
| 691 | + echo "<label for='{$field['id']}'>{$field['name']}</label>"; |
|
| 692 | + //echo "</div>"; |
|
| 693 | + } |
|
| 694 | + if ($this->_form_type == 'edit') { |
|
| 695 | + echo '</th><td>'; |
|
| 696 | + } |
|
| 697 | + } |
|
| 698 | + |
|
| 699 | + /** |
|
| 700 | + * End Field. |
|
| 701 | + * |
|
| 702 | + * @param string $field |
|
| 703 | + * @param string $meta |
|
| 704 | + * @since 1.0 |
|
| 705 | + * @access public |
|
| 706 | + */ |
|
| 707 | + public function show_field_end($field, $meta = NULL, $group = false) |
|
| 708 | + { |
|
| 709 | + if (isset($field['group'])) { |
|
| 710 | + if ($group == 'end') { |
|
| 711 | + if ($field['desc'] != '') { |
|
| 712 | + echo "<p class='desc-field'>{$field['desc']}</p></td>"; |
|
| 713 | + } else { |
|
| 714 | + echo "</td>"; |
|
| 715 | + } |
|
| 716 | + } else { |
|
| 717 | + if ($field['desc'] != '') { |
|
| 718 | + echo "<p class='desc-field'>{$field['desc']}</p><br/>"; |
|
| 719 | + } else { |
|
| 720 | + echo '<br/>'; |
|
| 721 | + } |
|
| 722 | + } |
|
| 723 | + } else { |
|
| 724 | + if ($field['desc'] != '') { |
|
| 725 | + echo "<p class='desc-field'>{$field['desc']}</p>"; |
|
| 726 | + } |
|
| 727 | + if ($this->_form_type == 'edit') { |
|
| 728 | + echo '</td>'; |
|
| 729 | + } else { |
|
| 730 | + echo '</td></div>'; |
|
| 731 | + } |
|
| 732 | + } |
|
| 733 | + } |
|
| 734 | + |
|
| 735 | + /** |
|
| 736 | + * Show Field Text. |
|
| 737 | + * |
|
| 738 | + * @param string $field |
|
| 739 | + * @param string $meta |
|
| 740 | + * @since 1.0 |
|
| 741 | + * @access public |
|
| 742 | + */ |
|
| 743 | + public function show_field_text($field, $meta) |
|
| 744 | + { |
|
| 745 | + $this->show_field_begin($field, $meta); |
|
| 746 | + echo "<input type='text' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='30' />"; |
|
| 747 | + $this->show_field_end($field, $meta); |
|
| 748 | + } |
|
| 749 | + |
|
| 750 | + /** |
|
| 751 | + * Show Field hidden. |
|
| 752 | + * |
|
| 753 | + * @param string $field |
|
| 754 | + * @param string|mixed $meta |
|
| 755 | + * @since 0.1.3 |
|
| 756 | + * @access public |
|
| 757 | + */ |
|
| 758 | + public function show_field_hidden($field, $meta) |
|
| 759 | + { |
|
| 760 | + //$this->show_field_begin( $field, $meta ); |
|
| 761 | + echo "<input type='hidden' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}'/>"; |
|
| 762 | + //$this->show_field_end( $field, $meta ); |
|
| 763 | + } |
|
| 764 | + |
|
| 765 | + /** |
|
| 766 | + * Show Field Paragraph. |
|
| 767 | + * |
|
| 768 | + * @param string $field |
|
| 769 | + * @since 0.1.3 |
|
| 770 | + * @access public |
|
| 771 | + */ |
|
| 772 | + public function show_field_paragraph($field) |
|
| 773 | + { |
|
| 774 | + //$this->show_field_begin( $field, $meta ); |
|
| 775 | + echo '<p>' . $field['value'] . '</p>'; |
|
| 776 | + //$this->show_field_end( $field, $meta ); |
|
| 777 | + } |
|
| 778 | + |
|
| 779 | + /** |
|
| 780 | + * Show Field Textarea. |
|
| 781 | + * |
|
| 782 | + * @param string $field |
|
| 783 | + * @param string $meta |
|
| 784 | + * @since 1.0 |
|
| 785 | + * @access public |
|
| 786 | + */ |
|
| 787 | + public function show_field_textarea($field, $meta) |
|
| 788 | + { |
|
| 789 | + $this->show_field_begin($field, $meta); |
|
| 790 | + echo "<textarea class='at-textarea large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>"; |
|
| 791 | + $this->show_field_end($field, $meta); |
|
| 792 | + } |
|
| 793 | + |
|
| 794 | + /** |
|
| 795 | + * Show Field Select. |
|
| 796 | + * |
|
| 797 | + * @param string $field |
|
| 798 | + * @param string $meta |
|
| 799 | + * @since 1.0 |
|
| 800 | + * @access public |
|
| 801 | + */ |
|
| 802 | + public function show_field_select($field, $meta) |
|
| 803 | + { |
|
| 804 | + |
|
| 805 | + if (!is_array($meta)) |
|
| 806 | + $meta = (array)$meta; |
|
| 807 | + |
|
| 808 | + $this->show_field_begin($field, $meta); |
|
| 809 | + echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">"; |
|
| 810 | + foreach ($field['options'] as $key => $value) { |
|
| 811 | + echo "<option value='{$key}'" . selected(in_array($key, $meta), true, false) . ">{$value}</option>"; |
|
| 812 | + } |
|
| 813 | + echo "</select>"; |
|
| 814 | + $this->show_field_end($field, $meta); |
|
| 815 | + |
|
| 816 | + } |
|
| 817 | + |
|
| 818 | + /** |
|
| 819 | + * Show Radio Field. |
|
| 820 | + * |
|
| 821 | + * @param string $field |
|
| 822 | + * @param string $meta |
|
| 823 | + * @since 1.0 |
|
| 824 | + * @access public |
|
| 825 | + */ |
|
| 826 | + public function show_field_radio($field, $meta) |
|
| 827 | + { |
|
| 828 | + |
|
| 829 | + if (!is_array($meta)) |
|
| 830 | + $meta = (array)$meta; |
|
| 831 | + |
|
| 832 | + $this->show_field_begin($field, $meta); |
|
| 833 | + foreach ($field['options'] as $key => $value) { |
|
| 834 | + echo "<input type='radio' class='at-radio' name='{$field['id']}' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> <span class='at-radio-label'>{$value}</span>"; |
|
| 835 | + } |
|
| 836 | + $this->show_field_end($field, $meta); |
|
| 837 | + } |
|
| 838 | + |
|
| 839 | + /** |
|
| 840 | + * Show Checkbox Field. |
|
| 841 | + * |
|
| 842 | + * @param string $field |
|
| 843 | + * @param string $meta |
|
| 844 | + * @since 1.0 |
|
| 845 | + * @access public |
|
| 846 | + */ |
|
| 847 | + public function show_field_checkbox($field, $meta) |
|
| 848 | + { |
|
| 849 | + |
|
| 850 | + $this->show_field_begin($field, $meta); |
|
| 851 | + echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'" . checked(!empty($meta), true, false) . " /> {$field['desc']}"; |
|
| 852 | + $this->show_field_end($field, $meta); |
|
| 853 | + } |
|
| 854 | + |
|
| 855 | + /** |
|
| 856 | + * Show Wysiwig Field. |
|
| 857 | + * |
|
| 858 | + * @param string $field |
|
| 859 | + * @param string $meta |
|
| 860 | + * @since 1.0 |
|
| 861 | + * @access public |
|
| 862 | + */ |
|
| 863 | + public function show_field_wysiwyg($field, $meta) |
|
| 864 | + { |
|
| 865 | + $this->show_field_begin($field, $meta); |
|
| 866 | + // Add TinyMCE script for WP version < 3.3 |
|
| 867 | + global $wp_version; |
|
| 868 | + |
|
| 869 | + if (version_compare($wp_version, '3.2.1') < 1) { |
|
| 870 | + echo "<textarea class='at-wysiwyg theEditor large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>"; |
|
| 871 | + } else { |
|
| 872 | + // Use new wp_editor() since WP 3.3 |
|
| 873 | + wp_editor(stripslashes(html_entity_decode($meta)), $field['id'], array('editor_class' => 'at-wysiwyg')); |
|
| 874 | + } |
|
| 875 | + $this->show_field_end($field, $meta); |
|
| 876 | + } |
|
| 877 | + |
|
| 878 | + /** |
|
| 879 | + * Show File Field. |
|
| 880 | + * |
|
| 881 | + * @global object $post The current post object. |
|
| 882 | + * @param string $field |
|
| 883 | + * @param string $meta |
|
| 884 | + * @since 1.0 |
|
| 885 | + * @access public |
|
| 886 | + */ |
|
| 887 | + public function show_field_file($field, $meta) |
|
| 888 | + { |
|
| 889 | + |
|
| 890 | + global $post; |
|
| 891 | + |
|
| 892 | + if (!is_array($meta)) |
|
| 893 | + $meta = (array)$meta; |
|
| 894 | + |
|
| 895 | + $this->show_field_begin($field, $meta); |
|
| 896 | + echo "{$field['desc']}<br />"; |
|
| 897 | + |
|
| 898 | + if (!empty($meta)) { |
|
| 899 | + $nonce = wp_create_nonce('at_ajax_delete'); |
|
| 900 | + echo '<div style="margin-bottom: 10px"><strong>' . __('Uploaded files', 'geodirectory') . '</strong></div>'; |
|
| 901 | + echo '<ol class="at-upload">'; |
|
| 902 | + foreach ($meta as $att) { |
|
| 903 | + // if (wp_attachment_is_image($att)) continue; // what's image uploader for? |
|
| 904 | + echo "<li>" . wp_get_attachment_link($att, '', false, false, ' ') . " (<a class='at-delete-file' href='#' rel='{$nonce}|{$post->ID}|{$field['id']}|{$att}'>" . __('Remove', 'geodirectory') . "</a>)</li>"; |
|
| 905 | + } |
|
| 906 | + echo '</ol>'; |
|
| 907 | + } |
|
| 908 | + |
|
| 909 | + // show form upload |
|
| 910 | + |
|
| 911 | + echo "<div class='at-file-upload-label'>"; |
|
| 912 | + echo "<strong>" . __('Upload new files', 'geodirectory') . "</strong>"; |
|
| 913 | + echo "</div>"; |
|
| 914 | + echo "<div class='new-files'>"; |
|
| 915 | + echo "<div class='file-input'>"; |
|
| 916 | + echo "<input type='file' name='{$field['id']}[]' />"; |
|
| 917 | + echo "</div><!-- End .file-input -->"; |
|
| 918 | + echo "<a class='at-add-file button' href='#'>" . __('Add more files', 'geodirectory') . "</a>"; |
|
| 919 | + echo "</div><!-- End .new-files -->"; |
|
| 920 | + echo "</td>"; |
|
| 921 | + $this->show_field_end($field, $meta); |
|
| 922 | + } |
|
| 923 | + |
|
| 924 | + /** |
|
| 925 | + * Show Image Field. |
|
| 926 | + * |
|
| 927 | + * @param array $field |
|
| 928 | + * @param array $meta |
|
| 929 | + * @since 1.0 |
|
| 930 | + * @access public |
|
| 931 | + */ |
|
| 932 | + public function show_field_image($field, $meta) |
|
| 933 | + { |
|
| 934 | + $this->show_field_begin($field, $meta); |
|
| 935 | + $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false); |
|
| 936 | + if (is_array($meta)) { |
|
| 937 | + if (isset($meta[0]) && is_array($meta[0])) |
|
| 938 | + $meta = $meta[0]; |
|
| 939 | + } |
|
| 940 | + |
|
| 941 | + $uploads = wp_upload_dir(); |
|
| 942 | + if (is_array($meta) && isset($meta['src']) && $meta['src'] != '') { |
|
| 943 | + $file_info = pathinfo($meta['src']); |
|
| 944 | + |
|
| 945 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
| 946 | + $sub_dir = $file_info['dirname']; |
|
| 947 | + |
|
| 948 | + $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
| 949 | + $uploads_baseurl = $uploads['baseurl']; |
|
| 950 | + $uploads_path = $uploads['path']; |
|
| 951 | + |
|
| 952 | + $file_name = $file_info['basename']; |
|
| 953 | + |
|
| 954 | + if (strpos($sub_dir, 'https://') !== false) { |
|
| 955 | + $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
| 956 | + } else { |
|
| 957 | + $uploads['baseurl'] = str_replace('https://', 'http://', $uploads['baseurl']); |
|
| 958 | + } |
|
| 959 | + $sub_dir = str_replace($uploads['baseurl'], '', $sub_dir); |
|
| 960 | + |
|
| 961 | + $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 962 | + |
|
| 963 | + $meta['src'] = $uploads_url . '/' . $file_name; |
|
| 964 | + |
|
| 965 | + $html .= "<span class='mupload_img_holder'><img src='" . $meta['src'] . "' style='max-height: 150px;max-width: 150px;' /></span>"; |
|
| 966 | + $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='" . $meta['id'] . "' />"; |
|
| 967 | + $html .= "<input type='hidden' class='" . $field['id'] . "[src]' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='" . $meta['src'] . "' />"; |
|
| 968 | + $html .= "<input class='at-delete_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Remove Image', 'geodirectory') . "' />"; |
|
| 969 | + } else { |
|
| 970 | + $html .= "<span class='mupload_img_holder'></span>"; |
|
| 971 | + $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='' />"; |
|
| 972 | + $html .= "<input class='" . $field['id'] . "[src]' style='position:absolute;left:-500px;width:50px;' type='text' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='' />"; |
|
| 973 | + $html .= "<input class='at-upload_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Upload Image', 'geodirectory') . "' />"; |
|
| 974 | + } |
|
| 975 | + echo $html; |
|
| 976 | + $this->show_field_end($field, $meta); |
|
| 977 | + } |
|
| 978 | + |
|
| 979 | + /** |
|
| 980 | + * Show Color Field. |
|
| 981 | + * |
|
| 982 | + * @param string $field |
|
| 983 | + * @param string $meta |
|
| 984 | + * @since 1.0 |
|
| 985 | + * @access public |
|
| 986 | + */ |
|
| 987 | + public function show_field_color($field, $meta) |
|
| 988 | + { |
|
| 989 | + |
|
| 990 | + if (empty($meta)) |
|
| 991 | + $meta = '#'; |
|
| 992 | + |
|
| 993 | + $this->show_field_begin($field, $meta); |
|
| 994 | + |
|
| 995 | + echo "<input class='at-color' type='text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='8' />"; |
|
| 996 | + // echo "<a href='#' class='at-color-select button' rel='{$field['id']}'>" . __( 'Select a color' ) . "</a>"; |
|
| 997 | + echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='" . __('Select a color', 'geodirectory') . "'/>"; |
|
| 998 | + echo "<div style='display:none' class='at-color-picker' rel='{$field['id']}'></div>"; |
|
| 999 | + $this->show_field_end($field, $meta); |
|
| 1000 | + |
|
| 1001 | + } |
|
| 1002 | + |
|
| 1003 | + /** |
|
| 1004 | + * Show Checkbox List Field |
|
| 1005 | + * |
|
| 1006 | + * @param string $field |
|
| 1007 | + * @param string $meta |
|
| 1008 | + * @since 1.0 |
|
| 1009 | + * @access public |
|
| 1010 | + */ |
|
| 1011 | + public function show_field_checkbox_list($field, $meta) |
|
| 1012 | + { |
|
| 1013 | + |
|
| 1014 | + if (!is_array($meta)) |
|
| 1015 | + $meta = (array)$meta; |
|
| 1016 | + |
|
| 1017 | + $this->show_field_begin($field, $meta); |
|
| 1018 | + |
|
| 1019 | + $html = array(); |
|
| 1020 | + |
|
| 1021 | + foreach ($field['options'] as $key => $value) { |
|
| 1022 | + $html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> {$value}"; |
|
| 1023 | + } |
|
| 1024 | + |
|
| 1025 | + echo implode('<br />', $html); |
|
| 1026 | + |
|
| 1027 | + $this->show_field_end($field, $meta); |
|
| 1028 | + |
|
| 1029 | + } |
|
| 1030 | + |
|
| 1031 | + /** |
|
| 1032 | + * Show Date Field. |
|
| 1033 | + * |
|
| 1034 | + * @param string $field |
|
| 1035 | + * @param string $meta |
|
| 1036 | + * @since 1.0 |
|
| 1037 | + * @access public |
|
| 1038 | + */ |
|
| 1039 | + public function show_field_date($field, $meta) |
|
| 1040 | + { |
|
| 1041 | + $this->show_field_begin($field, $meta); |
|
| 1042 | + echo "<input type='text' class='at-date' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />"; |
|
| 1043 | + $this->show_field_end($field, $meta); |
|
| 1044 | + } |
|
| 1045 | + |
|
| 1046 | + /** |
|
| 1047 | + * Show time field. |
|
| 1048 | + * |
|
| 1049 | + * @param string $field |
|
| 1050 | + * @param string $meta |
|
| 1051 | + * @since 1.0 |
|
| 1052 | + * @access public |
|
| 1053 | + */ |
|
| 1054 | + public function show_field_time($field, $meta) |
|
| 1055 | + { |
|
| 1056 | + $this->show_field_begin($field, $meta); |
|
| 1057 | + echo "<input type='text' class='at-time' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />"; |
|
| 1058 | + $this->show_field_end($field, $meta); |
|
| 1059 | + } |
|
| 1060 | + |
|
| 1061 | + /** |
|
| 1062 | + * Show Posts field. |
|
| 1063 | + * used creating a posts/pages/custom types checkboxlist or a select dropdown |
|
| 1064 | + * |
|
| 1065 | + * @global object $post The current post object. |
|
| 1066 | + * @param string $field |
|
| 1067 | + * @param string $meta |
|
| 1068 | + * @since 1.0 |
|
| 1069 | + * @access public |
|
| 1070 | + */ |
|
| 1071 | + public function show_field_posts($field, $meta) |
|
| 1072 | + { |
|
| 1073 | + global $post; |
|
| 1074 | + |
|
| 1075 | + if (!is_array($meta)) $meta = (array)$meta; |
|
| 1076 | + $this->show_field_begin($field, $meta); |
|
| 1077 | + $options = $field['options']; |
|
| 1078 | + $posts = get_posts($options['args']); |
|
| 1079 | + |
|
| 1080 | + // checkbox_list |
|
| 1081 | + if ('checkbox_list' == $options['type']) { |
|
| 1082 | + foreach ($posts as $p) { |
|
| 1083 | + echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'" . checked(in_array($p->ID, $meta), true, false) . " /> $p->post_title<br/>"; |
|
| 1084 | + } |
|
| 1085 | + } // select |
|
| 1086 | + else { |
|
| 1087 | + echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">"; |
|
| 1088 | + foreach ($posts as $p) { |
|
| 1089 | + echo "<option value='$p->ID'" . selected(in_array($p->ID, $meta), true, false) . ">$p->post_title</option>"; |
|
| 1090 | + } |
|
| 1091 | + echo "</select>"; |
|
| 1092 | + } |
|
| 1093 | + |
|
| 1094 | + $this->show_field_end($field, $meta); |
|
| 1095 | + } |
|
| 1096 | + |
|
| 1097 | + /** |
|
| 1098 | + * Show Taxonomy field. |
|
| 1099 | + * used creating a category/tags/custom taxonomy checkboxlist or a select dropdown |
|
| 1100 | + * |
|
| 1101 | + * @global object $post The current post object. |
|
| 1102 | + * @param string $field |
|
| 1103 | + * @param string $meta |
|
| 1104 | + * @since 1.0 |
|
| 1105 | + * @access public |
|
| 1106 | + * |
|
| 1107 | + * @uses get_terms() |
|
| 1108 | + */ |
|
| 1109 | + public function show_field_taxonomy($field, $meta) |
|
| 1110 | + { |
|
| 1111 | + global $post; |
|
| 1112 | + |
|
| 1113 | + if (!is_array($meta)) $meta = (array)$meta; |
|
| 1114 | + $this->show_field_begin($field, $meta); |
|
| 1115 | + $options = $field['options']; |
|
| 1116 | + $terms = get_terms($options['taxonomy'], $options['args']); |
|
| 1117 | + |
|
| 1118 | + // checkbox_list |
|
| 1119 | + if ('checkbox_list' == $options['type']) { |
|
| 1120 | + foreach ($terms as $term) { |
|
| 1121 | + echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'" . checked(in_array($term->slug, $meta), true, false) . " /> $term->name<br/>"; |
|
| 1122 | + } |
|
| 1123 | + } // select |
|
| 1124 | + else { |
|
| 1125 | + echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">"; |
|
| 1126 | + foreach ($terms as $term) { |
|
| 1127 | + echo "<option value='$term->slug'" . selected(in_array($term->slug, $meta), true, false) . ">$term->name</option>"; |
|
| 1128 | + } |
|
| 1129 | + echo "</select>"; |
|
| 1130 | + } |
|
| 1131 | + |
|
| 1132 | + $this->show_field_end($field, $meta); |
|
| 1133 | + } |
|
| 1134 | + |
|
| 1135 | + /** |
|
| 1136 | + * Save Data from Metabox |
|
| 1137 | + * |
|
| 1138 | + * @param string $term_id The term ID. |
|
| 1139 | + * @since 1.0 |
|
| 1140 | + * @access public |
|
| 1141 | + * @return string |
|
| 1142 | + */ |
|
| 1143 | + public function save($term_id) |
|
| 1144 | + { |
|
| 1145 | + |
|
| 1146 | + $taxnow = ''; |
|
| 1147 | + if (isset($_POST['taxonomy'])) |
|
| 1148 | + $taxnow = $_POST['taxonomy']; |
|
| 1149 | + |
|
| 1150 | + if (!isset($term_id) // Check Revision |
|
| 1151 | + || (!in_array($taxnow, $this->_meta_box['pages'])) // Check if current taxonomy type is supported. |
|
| 1152 | + || (!check_admin_referer(basename(__FILE__), 'tax_meta_class_nonce')) // Check nonce - Security |
|
| 1153 | + || (!current_user_can('manage_categories')) |
|
| 1154 | + ) // Check permission |
|
| 1155 | + { |
|
| 1156 | + return $term_id; |
|
| 1157 | + } |
|
| 1158 | + |
|
| 1159 | + |
|
| 1160 | + foreach ($this->_fields as $field) { |
|
| 1161 | + |
|
| 1162 | + $name = $field['id']; |
|
| 1163 | + $type = $field['type']; |
|
| 1164 | + $old = $this->get_tax_meta($term_id, $name, !$field['multiple']); |
|
| 1165 | + $new = (isset($_POST[$name])) ? $_POST[$name] : (($field['multiple']) ? array() : ''); |
|
| 1166 | + |
|
| 1167 | + // Validate meta value |
|
| 1168 | + if (class_exists('Tax_Meta_Validate') && method_exists('Tax_Meta_Validate', $field['validate_func'])) { |
|
| 1169 | + $new = call_user_func(array('Tax_Meta_Validate', $field['validate_func']), $new); |
|
| 1170 | + } |
|
| 1171 | + |
|
| 1172 | + |
|
| 1173 | + if ($name == 'ct_cat_icon') { |
|
| 1174 | + |
|
| 1175 | + $upload_dir = wp_upload_dir(); |
|
| 1176 | + |
|
| 1177 | + $image_name_arr = explode('/', $new['src']); |
|
| 1178 | + //$old_filename = end($image_name_arr); |
|
| 1179 | + //$img_name_arr = explode('.',$old_filename); |
|
| 1180 | + |
|
| 1181 | + //$old_filename = $upload_dir['path'].'/'.$old_filename; |
|
| 1182 | + |
|
| 1183 | + $new_filename = $upload_dir['path'] . '/' . 'cat_icon_' . $term_id . '.png'; |
|
| 1184 | + |
|
| 1185 | + /*rename($old_filename, $new_filename); |
|
| 1186 | 1186 | |
| 1187 | 1187 | //subdir |
| 1188 | 1188 | $new['src'] = $upload_dir['url'].'/'.'cat_icon_'.$term_id.'.png'; |
@@ -1190,7 +1190,7 @@ discard block |
||
| 1190 | 1190 | update_attached_file( $new['id'], $new['src'] );*/ |
| 1191 | 1191 | |
| 1192 | 1192 | |
| 1193 | - /* |
|
| 1193 | + /* |
|
| 1194 | 1194 | |
| 1195 | 1195 | $new['src'] = $upload_dir['url'].'/'.'cat_icon_'.$term_id.'.png'; |
| 1196 | 1196 | |
@@ -1215,67 +1215,67 @@ discard block |
||
| 1215 | 1215 | $attach_id = wp_insert_attachment( $attachment, $filename);*/ |
| 1216 | 1216 | |
| 1217 | 1217 | |
| 1218 | - } |
|
| 1219 | - |
|
| 1220 | - |
|
| 1221 | - //skip on Paragraph field |
|
| 1222 | - if ($type != "paragraph") { |
|
| 1223 | - |
|
| 1224 | - // Call defined method to save meta value, if there's no methods, call common one. |
|
| 1225 | - $save_func = 'save_field_' . $type; |
|
| 1226 | - if (method_exists($this, $save_func)) { |
|
| 1227 | - call_user_func(array(&$this, 'save_field_' . $type), $term_id, $field, $old, $new); |
|
| 1228 | - } else { |
|
| 1229 | - $this->save_field($term_id, $field, $old, $new); |
|
| 1230 | - } |
|
| 1231 | - } |
|
| 1232 | - |
|
| 1233 | - } // End foreach |
|
| 1234 | - |
|
| 1235 | - } |
|
| 1236 | - |
|
| 1237 | - /** |
|
| 1238 | - * Common function for saving fields. |
|
| 1239 | - * |
|
| 1240 | - * @param string $term_id The term ID. |
|
| 1241 | - * @param string $field |
|
| 1242 | - * @param string $old |
|
| 1243 | - * @param string|mixed $new |
|
| 1244 | - * @since 1.0 |
|
| 1245 | - * @access public |
|
| 1246 | - */ |
|
| 1247 | - public function save_field($term_id, $field, $old, $new) |
|
| 1248 | - { |
|
| 1249 | - $name = $field['id']; |
|
| 1250 | - $this->delete_tax_meta($term_id, $name); |
|
| 1251 | - if ($new === '' || $new === array()) |
|
| 1252 | - return; |
|
| 1253 | - |
|
| 1254 | - $this->update_tax_meta($term_id, $name, $new); |
|
| 1255 | - } |
|
| 1256 | - |
|
| 1257 | - /** |
|
| 1258 | - * function for saving image field. |
|
| 1259 | - * |
|
| 1260 | - * @param string $term_id The term ID. |
|
| 1261 | - * @param string $field |
|
| 1262 | - * @param string $old |
|
| 1263 | - * @param string|mixed $new |
|
| 1264 | - * @since 1.0 |
|
| 1265 | - * @access public |
|
| 1266 | - */ |
|
| 1267 | - public function save_field_image($term_id, $field, $old, $new) |
|
| 1268 | - { |
|
| 1269 | - $name = $field['id']; |
|
| 1270 | - |
|
| 1271 | - $this->delete_tax_meta($term_id, $name); |
|
| 1272 | - if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '') |
|
| 1273 | - return; |
|
| 1274 | - |
|
| 1275 | - $this->update_tax_meta($term_id, $name, $new); |
|
| 1276 | - } |
|
| 1277 | - |
|
| 1278 | - /* |
|
| 1218 | + } |
|
| 1219 | + |
|
| 1220 | + |
|
| 1221 | + //skip on Paragraph field |
|
| 1222 | + if ($type != "paragraph") { |
|
| 1223 | + |
|
| 1224 | + // Call defined method to save meta value, if there's no methods, call common one. |
|
| 1225 | + $save_func = 'save_field_' . $type; |
|
| 1226 | + if (method_exists($this, $save_func)) { |
|
| 1227 | + call_user_func(array(&$this, 'save_field_' . $type), $term_id, $field, $old, $new); |
|
| 1228 | + } else { |
|
| 1229 | + $this->save_field($term_id, $field, $old, $new); |
|
| 1230 | + } |
|
| 1231 | + } |
|
| 1232 | + |
|
| 1233 | + } // End foreach |
|
| 1234 | + |
|
| 1235 | + } |
|
| 1236 | + |
|
| 1237 | + /** |
|
| 1238 | + * Common function for saving fields. |
|
| 1239 | + * |
|
| 1240 | + * @param string $term_id The term ID. |
|
| 1241 | + * @param string $field |
|
| 1242 | + * @param string $old |
|
| 1243 | + * @param string|mixed $new |
|
| 1244 | + * @since 1.0 |
|
| 1245 | + * @access public |
|
| 1246 | + */ |
|
| 1247 | + public function save_field($term_id, $field, $old, $new) |
|
| 1248 | + { |
|
| 1249 | + $name = $field['id']; |
|
| 1250 | + $this->delete_tax_meta($term_id, $name); |
|
| 1251 | + if ($new === '' || $new === array()) |
|
| 1252 | + return; |
|
| 1253 | + |
|
| 1254 | + $this->update_tax_meta($term_id, $name, $new); |
|
| 1255 | + } |
|
| 1256 | + |
|
| 1257 | + /** |
|
| 1258 | + * function for saving image field. |
|
| 1259 | + * |
|
| 1260 | + * @param string $term_id The term ID. |
|
| 1261 | + * @param string $field |
|
| 1262 | + * @param string $old |
|
| 1263 | + * @param string|mixed $new |
|
| 1264 | + * @since 1.0 |
|
| 1265 | + * @access public |
|
| 1266 | + */ |
|
| 1267 | + public function save_field_image($term_id, $field, $old, $new) |
|
| 1268 | + { |
|
| 1269 | + $name = $field['id']; |
|
| 1270 | + |
|
| 1271 | + $this->delete_tax_meta($term_id, $name); |
|
| 1272 | + if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '') |
|
| 1273 | + return; |
|
| 1274 | + |
|
| 1275 | + $this->update_tax_meta($term_id, $name, $new); |
|
| 1276 | + } |
|
| 1277 | + |
|
| 1278 | + /* |
|
| 1279 | 1279 | * Save Wysiwyg Field. |
| 1280 | 1280 | * |
| 1281 | 1281 | * @param string $term_id The term ID. |
@@ -1285,806 +1285,806 @@ discard block |
||
| 1285 | 1285 | * @since 1.0 |
| 1286 | 1286 | * @access public |
| 1287 | 1287 | */ |
| 1288 | - public function save_field_wysiwyg($term_id, $field, $old, $new) |
|
| 1289 | - { |
|
| 1290 | - $this->save_field($term_id, $field, $old, $new); |
|
| 1291 | - } |
|
| 1292 | - |
|
| 1293 | - /** |
|
| 1294 | - * Save repeater Fields. |
|
| 1295 | - * |
|
| 1296 | - * @param string $term_id The term ID. |
|
| 1297 | - * @param string $field |
|
| 1298 | - * @param string|mixed $old |
|
| 1299 | - * @param string|mixed $new |
|
| 1300 | - * @since 1.0 |
|
| 1301 | - * @access public |
|
| 1302 | - */ |
|
| 1303 | - public function save_field_repeater($term_id, $field, $old, $new) |
|
| 1304 | - { |
|
| 1305 | - if (is_array($new) && count($new) > 0) { |
|
| 1306 | - foreach ($new as $n) { |
|
| 1307 | - foreach ($field['fields'] as $f) { |
|
| 1308 | - $type = $f['type']; |
|
| 1309 | - switch ($type) { |
|
| 1310 | - case 'wysiwyg': |
|
| 1311 | - $n[$f['id']] = wpautop($n[$f['id']]); |
|
| 1312 | - break; |
|
| 1313 | - case 'file': |
|
| 1314 | - $n[$f['id']] = $this->save_field_file_repeater($term_id, $f, '', $n[$f['id']]); |
|
| 1315 | - break; |
|
| 1316 | - default: |
|
| 1317 | - break; |
|
| 1318 | - } |
|
| 1319 | - } |
|
| 1320 | - if (!$this->is_array_empty($n)) |
|
| 1321 | - $temp[] = $n; |
|
| 1322 | - } |
|
| 1323 | - if (isset($temp) && count($temp) > 0 && !$this->is_array_empty($temp)) { |
|
| 1324 | - $this->update_tax_meta($term_id, $field['id'], $temp); |
|
| 1325 | - } else { |
|
| 1326 | - // remove old meta if exists |
|
| 1327 | - delete_post_meta($term_id, $field['id']); |
|
| 1328 | - } |
|
| 1329 | - } else { |
|
| 1330 | - // remove old meta if exists |
|
| 1331 | - delete_post_meta($term_id, $field['id']); |
|
| 1332 | - } |
|
| 1333 | - } |
|
| 1334 | - |
|
| 1335 | - /** |
|
| 1336 | - * Save File Field. |
|
| 1337 | - * |
|
| 1338 | - * @param string $term_id The term ID. |
|
| 1339 | - * @param string $field |
|
| 1340 | - * @param string $old |
|
| 1341 | - * @param string $new |
|
| 1342 | - * @since 1.0 |
|
| 1343 | - * @access public |
|
| 1344 | - */ |
|
| 1345 | - public function save_field_file($term_id, $field, $old, $new) |
|
| 1346 | - { |
|
| 1347 | - |
|
| 1348 | - $name = $field['id']; |
|
| 1349 | - if (empty($_FILES[$name])) |
|
| 1350 | - return; |
|
| 1351 | - $this->fix_file_array($_FILES[$name]); |
|
| 1352 | - foreach ($_FILES[$name] as $position => $fileitem) { |
|
| 1353 | - |
|
| 1354 | - $file = wp_handle_upload($fileitem, array('test_form' => false)); |
|
| 1355 | - if (empty($file['file'])) |
|
| 1356 | - continue; |
|
| 1357 | - $filename = $file['file']; |
|
| 1358 | - |
|
| 1359 | - $attachment = array( |
|
| 1360 | - 'post_mime_type' => $file['type'], |
|
| 1361 | - 'guid' => $file['url'], |
|
| 1362 | - 'post_parent' => $term_id, |
|
| 1363 | - 'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)), |
|
| 1364 | - 'post_content' => '' |
|
| 1365 | - ); |
|
| 1366 | - |
|
| 1367 | - $id = wp_insert_attachment($attachment, $filename, $term_id); |
|
| 1368 | - |
|
| 1369 | - if (!is_wp_error($id)) { |
|
| 1370 | - |
|
| 1371 | - wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); |
|
| 1372 | - add_post_meta($term_id, $name, $id, false); // save file's url in meta fields |
|
| 1373 | - |
|
| 1374 | - } // End if |
|
| 1375 | - |
|
| 1376 | - } // End foreach |
|
| 1377 | - |
|
| 1378 | - } |
|
| 1379 | - |
|
| 1380 | - /** |
|
| 1381 | - * Save repeater File Field. |
|
| 1382 | - * @param string $term_id The term ID. |
|
| 1383 | - * @param string $field |
|
| 1384 | - * @param string $old |
|
| 1385 | - * @param string $new |
|
| 1386 | - * @since 1.0 |
|
| 1387 | - * @access public |
|
| 1388 | - * @return int|void |
|
| 1389 | - */ |
|
| 1390 | - public function save_field_file_repeater($term_id, $field, $old, $new) |
|
| 1391 | - { |
|
| 1392 | - |
|
| 1393 | - $name = $field['id']; |
|
| 1394 | - if (empty($_FILES[$name])) |
|
| 1395 | - return; |
|
| 1396 | - $this->fix_file_array($_FILES[$name]); |
|
| 1397 | - foreach ($_FILES[$name] as $position => $fileitem) { |
|
| 1398 | - |
|
| 1399 | - $file = wp_handle_upload($fileitem, array('test_form' => false)); |
|
| 1400 | - if (empty($file['file'])) |
|
| 1401 | - continue; |
|
| 1402 | - $filename = $file['file']; |
|
| 1403 | - |
|
| 1404 | - $attachment = array( |
|
| 1405 | - 'post_mime_type' => $file['type'], |
|
| 1406 | - 'guid' => $file['url'], |
|
| 1407 | - 'post_parent' => $term_id, |
|
| 1408 | - 'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)), |
|
| 1409 | - 'post_content' => '' |
|
| 1410 | - ); |
|
| 1411 | - |
|
| 1412 | - $id = wp_insert_attachment($attachment, $filename); |
|
| 1413 | - |
|
| 1414 | - if (!is_wp_error($id)) { |
|
| 1415 | - |
|
| 1416 | - wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); |
|
| 1417 | - return $id; // return file's url in meta fields |
|
| 1418 | - } // End if |
|
| 1419 | - } // End foreach |
|
| 1420 | - } |
|
| 1421 | - |
|
| 1422 | - /** |
|
| 1423 | - * Add missed values for meta box. |
|
| 1424 | - * |
|
| 1425 | - * @since 1.0 |
|
| 1426 | - * @access public |
|
| 1427 | - */ |
|
| 1428 | - public function add_missed_values() |
|
| 1429 | - { |
|
| 1430 | - |
|
| 1431 | - // Default values for meta box |
|
| 1432 | - $this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array)$this->_meta_box); |
|
| 1433 | - |
|
| 1434 | - if(is_array($this->_fields)) { |
|
| 1435 | - // Default values for fields |
|
| 1436 | - foreach ($this->_fields as &$field) { |
|
| 1437 | - $multiple = in_array($field['type'], array('checkbox_list', 'file', 'image')); |
|
| 1438 | - $std = $multiple ? array() : ''; |
|
| 1439 | - $format = 'date' == $field['type'] ? 'yy-mm-dd' : ('time' == $field['type'] ? 'hh:mm' : ''); |
|
| 1440 | - $field = array_merge(array('multiple' => $multiple, 'std' => $std, 'desc' => '', 'format' => $format, 'validate_func' => ''), $field); |
|
| 1441 | - } // End foreach |
|
| 1442 | - } |
|
| 1443 | - } |
|
| 1444 | - |
|
| 1445 | - /** |
|
| 1446 | - * Check if field with $type exists. |
|
| 1447 | - * |
|
| 1448 | - * @param string $type |
|
| 1449 | - * @since 1.0 |
|
| 1450 | - * @access public |
|
| 1451 | - */ |
|
| 1452 | - public function has_field($type) |
|
| 1453 | - { |
|
| 1454 | - if(is_array($this->_fields)) { |
|
| 1455 | - foreach ($this->_fields as $field) { |
|
| 1456 | - if ($type == $field['type']) |
|
| 1457 | - return true; |
|
| 1458 | - } |
|
| 1459 | - } |
|
| 1460 | - return false; |
|
| 1461 | - } |
|
| 1462 | - |
|
| 1463 | - /** |
|
| 1464 | - * Check if current page is edit page. |
|
| 1465 | - * |
|
| 1466 | - * @since 1.0 |
|
| 1467 | - * @access public |
|
| 1468 | - */ |
|
| 1469 | - public function is_edit_page() |
|
| 1470 | - { |
|
| 1471 | - global $pagenow; |
|
| 1472 | - return ($pagenow == 'edit-tags.php' || $pagenow == 'term.php'); |
|
| 1473 | - } |
|
| 1474 | - |
|
| 1475 | - /** |
|
| 1476 | - * Fixes the odd indexing of multiple file uploads. |
|
| 1477 | - * |
|
| 1478 | - * Goes from the format: |
|
| 1479 | - * $_FILES['field']['key']['index'] |
|
| 1480 | - * to |
|
| 1481 | - * The More standard and appropriate: |
|
| 1482 | - * $_FILES['field']['index']['key'] |
|
| 1483 | - * |
|
| 1484 | - * @param string $files |
|
| 1485 | - * @since 1.0 |
|
| 1486 | - * @access public |
|
| 1487 | - */ |
|
| 1488 | - public function fix_file_array(&$files) |
|
| 1489 | - { |
|
| 1490 | - |
|
| 1491 | - $output = array(); |
|
| 1492 | - |
|
| 1493 | - foreach ($files as $key => $list) { |
|
| 1494 | - foreach ($list as $index => $value) { |
|
| 1495 | - $output[$index][$key] = $value; |
|
| 1496 | - } |
|
| 1497 | - } |
|
| 1498 | - |
|
| 1499 | - return $files = $output; |
|
| 1500 | - |
|
| 1501 | - } |
|
| 1502 | - |
|
| 1503 | - /** |
|
| 1504 | - * Get proper JQuery UI version. |
|
| 1505 | - * |
|
| 1506 | - * Used in order to not conflict with WP Admin Scripts. |
|
| 1507 | - * |
|
| 1508 | - * @since 1.0 |
|
| 1509 | - * @access public |
|
| 1510 | - */ |
|
| 1511 | - public function get_jqueryui_ver() |
|
| 1512 | - { |
|
| 1513 | - |
|
| 1514 | - global $wp_version; |
|
| 1515 | - |
|
| 1516 | - if (version_compare($wp_version, '3.1', '>=')) { |
|
| 1517 | - return '1.8.10'; |
|
| 1518 | - } |
|
| 1519 | - |
|
| 1520 | - return '1.7.3'; |
|
| 1521 | - |
|
| 1522 | - } |
|
| 1523 | - |
|
| 1524 | - /** |
|
| 1525 | - * Add Field to meta box (generic function) |
|
| 1526 | - * @author Ohad Raz |
|
| 1527 | - * @since 1.0 |
|
| 1528 | - * @access public |
|
| 1529 | - * @param $id string field id, i.e. the meta key |
|
| 1530 | - * @param $args mixed|array |
|
| 1531 | - */ |
|
| 1532 | - public function addField($id, $args) |
|
| 1533 | - { |
|
| 1534 | - $new_field = array('id' => $id, 'std' => '', 'desc' => '', 'style' => ''); |
|
| 1535 | - $new_field = array_merge($new_field, $args); |
|
| 1536 | - $this->_fields[] = $new_field; |
|
| 1537 | - } |
|
| 1538 | - |
|
| 1539 | - |
|
| 1540 | - /** |
|
| 1541 | - * Add Text Field to meta box |
|
| 1542 | - * @author Ohad Raz |
|
| 1543 | - * @since 1.0 |
|
| 1544 | - * @access public |
|
| 1545 | - * @param $id string field id, i.e. the meta key |
|
| 1546 | - * @param $args mixed|array |
|
| 1547 | - * 'name' => // field name/label string optional |
|
| 1548 | - * 'desc' => // field description, string optional |
|
| 1549 | - * 'std' => // default value, string optional |
|
| 1550 | - * 'style' => // custom style for field, string optional |
|
| 1551 | - * 'validate_func' => // validate function, string optional |
|
| 1552 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1553 | - */ |
|
| 1554 | - public function addText($id, $args, $repeater = false) |
|
| 1555 | - { |
|
| 1556 | - $new_field = array('type' => 'text', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory')); |
|
| 1557 | - $new_field = array_merge($new_field, $args); |
|
| 1558 | - if (false === $repeater) { |
|
| 1559 | - $this->_fields[] = $new_field; |
|
| 1560 | - } else { |
|
| 1561 | - return $new_field; |
|
| 1562 | - } |
|
| 1563 | - } |
|
| 1564 | - |
|
| 1565 | - /** |
|
| 1566 | - * Add Hidden Field to meta box |
|
| 1567 | - * @author Ohad Raz |
|
| 1568 | - * @since 0.1.3 |
|
| 1569 | - * @access public |
|
| 1570 | - * @param $id string field id, i.e. the meta key |
|
| 1571 | - * @param $args mixed|array |
|
| 1572 | - * 'name' => // field name/label string optional |
|
| 1573 | - * 'desc' => // field description, string optional |
|
| 1574 | - * 'std' => // default value, string optional |
|
| 1575 | - * 'style' => // custom style for field, string optional |
|
| 1576 | - * 'validate_func' => // validate function, string optional |
|
| 1577 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1578 | - */ |
|
| 1579 | - public function addHidden($id, $args, $repeater = false) |
|
| 1580 | - { |
|
| 1581 | - $new_field = array('type' => 'hidden', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory')); |
|
| 1582 | - $new_field = array_merge($new_field, $args); |
|
| 1583 | - if (false === $repeater) { |
|
| 1584 | - $this->_fields[] = $new_field; |
|
| 1585 | - } else { |
|
| 1586 | - return $new_field; |
|
| 1587 | - } |
|
| 1588 | - } |
|
| 1589 | - |
|
| 1590 | - /** |
|
| 1591 | - * Add Paragraph to meta box |
|
| 1592 | - * @author Ohad Raz |
|
| 1593 | - * @since 0.1.3 |
|
| 1594 | - * @access public |
|
| 1595 | - * @param $id string field id, i.e. the meta key |
|
| 1596 | - * @param $value paragraph html |
|
| 1597 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1598 | - */ |
|
| 1599 | - public function addParagraph($id, $args, $repeater = false) |
|
| 1600 | - { |
|
| 1601 | - $new_field = array('type' => 'paragraph', 'id' => $id, 'value' => '', 'style' => ''); |
|
| 1602 | - $new_field = array_merge($new_field, $args); |
|
| 1603 | - if (false === $repeater) { |
|
| 1604 | - $this->_fields[] = $new_field; |
|
| 1605 | - } else { |
|
| 1606 | - return $new_field; |
|
| 1607 | - } |
|
| 1608 | - } |
|
| 1609 | - |
|
| 1610 | - /** |
|
| 1611 | - * Add Checkbox Field to meta box |
|
| 1612 | - * @author Ohad Raz |
|
| 1613 | - * @since 1.0 |
|
| 1614 | - * @access public |
|
| 1615 | - * @param $id string field id, i.e. the meta key |
|
| 1616 | - * @param $args mixed|array |
|
| 1617 | - * 'name' => // field name/label string optional |
|
| 1618 | - * 'desc' => // field description, string optional |
|
| 1619 | - * 'std' => // default value, string optional |
|
| 1620 | - * 'validate_func' => // validate function, string optional |
|
| 1621 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1622 | - */ |
|
| 1623 | - public function addCheckbox($id, $args, $repeater = false) |
|
| 1624 | - { |
|
| 1625 | - $new_field = array('type' => 'checkbox', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox Field', 'geodirectory')); |
|
| 1626 | - $new_field = array_merge($new_field, $args); |
|
| 1627 | - if (false === $repeater) { |
|
| 1628 | - $this->_fields[] = $new_field; |
|
| 1629 | - } else { |
|
| 1630 | - return $new_field; |
|
| 1631 | - } |
|
| 1632 | - } |
|
| 1633 | - |
|
| 1634 | - /** |
|
| 1635 | - * Add CheckboxList Field to meta box |
|
| 1636 | - * @author Ohad Raz |
|
| 1637 | - * @since 1.0 |
|
| 1638 | - * @access public |
|
| 1639 | - * @param $id string field id, i.e. the meta key |
|
| 1640 | - * @param $options (array) array of key => value pairs for select options |
|
| 1641 | - * @param $args mixed|array |
|
| 1642 | - * 'name' => // field name/label string optional |
|
| 1643 | - * 'desc' => // field description, string optional |
|
| 1644 | - * 'std' => // default value, string optional |
|
| 1645 | - * 'validate_func' => // validate function, string optional |
|
| 1646 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1647 | - * |
|
| 1648 | - * @return : remember to call: $checkbox_list = $this->get_tax_meta(get_the_ID(), 'meta_name', false); |
|
| 1649 | - * which means the last param as false to get the values in an array |
|
| 1650 | - */ |
|
| 1651 | - public function addCheckboxList($id, $options, $args, $repeater = false) |
|
| 1652 | - { |
|
| 1653 | - $new_field = array('type' => 'checkbox_list', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox List Field', 'geodirectory')); |
|
| 1654 | - $new_field = array_merge($new_field, $args); |
|
| 1655 | - if (false === $repeater) { |
|
| 1656 | - $this->_fields[] = $new_field; |
|
| 1657 | - } else { |
|
| 1658 | - return $new_field; |
|
| 1659 | - } |
|
| 1660 | - } |
|
| 1661 | - |
|
| 1662 | - /** |
|
| 1663 | - * Add Textarea Field to meta box |
|
| 1664 | - * @author Ohad Raz |
|
| 1665 | - * @since 1.0 |
|
| 1666 | - * @access public |
|
| 1667 | - * @param $id string field id, i.e. the meta key |
|
| 1668 | - * @param $args mixed|array |
|
| 1669 | - * 'name' => // field name/label string optional |
|
| 1670 | - * 'desc' => // field description, string optional |
|
| 1671 | - * 'std' => // default value, string optional |
|
| 1672 | - * 'style' => // custom style for field, string optional |
|
| 1673 | - * 'validate_func' => // validate function, string optional |
|
| 1674 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1675 | - */ |
|
| 1676 | - public function addTextarea($id, $args, $repeater = false) |
|
| 1677 | - { |
|
| 1678 | - $new_field = array('type' => 'textarea', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Textarea Field', 'geodirectory')); |
|
| 1679 | - $new_field = array_merge($new_field, $args); |
|
| 1680 | - if (false === $repeater) { |
|
| 1681 | - $this->_fields[] = $new_field; |
|
| 1682 | - } else { |
|
| 1683 | - return $new_field; |
|
| 1684 | - } |
|
| 1685 | - } |
|
| 1686 | - |
|
| 1687 | - /** |
|
| 1688 | - * Add Select Field to meta box |
|
| 1689 | - * @author Ohad Raz |
|
| 1690 | - * @since 1.0 |
|
| 1691 | - * @access public |
|
| 1692 | - * @param $id string field id, i.e. the meta key |
|
| 1693 | - * @param $options (array) array of key => value pairs for select options |
|
| 1694 | - * @param $args mixed|array |
|
| 1695 | - * 'name' => // field name/label string optional |
|
| 1696 | - * 'desc' => // field description, string optional |
|
| 1697 | - * 'std' => // default value, (array) optional |
|
| 1698 | - * 'multiple' => // select multiple values, optional. Default is false. |
|
| 1699 | - * 'validate_func' => // validate function, string optional |
|
| 1700 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1701 | - */ |
|
| 1702 | - public function addSelect($id, $options, $args, $repeater = false) |
|
| 1703 | - { |
|
| 1704 | - $new_field = array('type' => 'select', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Select Field', 'geodirectory'), 'multiple' => false, 'options' => $options); |
|
| 1705 | - $new_field = array_merge($new_field, $args); |
|
| 1706 | - if (false === $repeater) { |
|
| 1707 | - $this->_fields[] = $new_field; |
|
| 1708 | - } else { |
|
| 1709 | - return $new_field; |
|
| 1710 | - } |
|
| 1711 | - } |
|
| 1712 | - |
|
| 1713 | - |
|
| 1714 | - /** |
|
| 1715 | - * Add Radio Field to meta box |
|
| 1716 | - * @author Ohad Raz |
|
| 1717 | - * @since 1.0 |
|
| 1718 | - * @access public |
|
| 1719 | - * @param $id string field id, i.e. the meta key |
|
| 1720 | - * @param $options (array) array of key => value pairs for radio options |
|
| 1721 | - * @param $args mixed|array |
|
| 1722 | - * 'name' => // field name/label string optional |
|
| 1723 | - * 'desc' => // field description, string optional |
|
| 1724 | - * 'std' => // default value, string optional |
|
| 1725 | - * 'validate_func' => // validate function, string optional |
|
| 1726 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1727 | - */ |
|
| 1728 | - public function addRadio($id, $options, $args, $repeater = false) |
|
| 1729 | - { |
|
| 1730 | - $new_field = array('type' => 'radio', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Radio Field', 'geodirectory'), 'options' => $options); |
|
| 1731 | - $new_field = array_merge($new_field, $args); |
|
| 1732 | - if (false === $repeater) { |
|
| 1733 | - $this->_fields[] = $new_field; |
|
| 1734 | - } else { |
|
| 1735 | - return $new_field; |
|
| 1736 | - } |
|
| 1737 | - } |
|
| 1738 | - |
|
| 1739 | - /** |
|
| 1740 | - * Add Date Field to meta box |
|
| 1741 | - * @author Ohad Raz |
|
| 1742 | - * @since 1.0 |
|
| 1743 | - * @access public |
|
| 1744 | - * @param $id string field id, i.e. the meta key |
|
| 1745 | - * @param $args mixed|array |
|
| 1746 | - * 'name' => // field name/label string optional |
|
| 1747 | - * 'desc' => // field description, string optional |
|
| 1748 | - * 'std' => // default value, string optional |
|
| 1749 | - * 'validate_func' => // validate function, string optional |
|
| 1750 | - * 'format' => // date format, default yy-mm-dd. Optional. Default "'d MM, yy'" See more formats here: http://goo.gl/Wcwxn |
|
| 1751 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1752 | - */ |
|
| 1753 | - public function addDate($id, $args, $repeater = false) |
|
| 1754 | - { |
|
| 1755 | - $new_field = array('type' => 'date', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'yy-mm-dd', 'name' => __('Date Field', 'geodirectory')); |
|
| 1756 | - $new_field = array_merge($new_field, $args); |
|
| 1757 | - if (false === $repeater) { |
|
| 1758 | - $this->_fields[] = $new_field; |
|
| 1759 | - } else { |
|
| 1760 | - return $new_field; |
|
| 1761 | - } |
|
| 1762 | - } |
|
| 1763 | - |
|
| 1764 | - /** |
|
| 1765 | - * Add Time Field to meta box |
|
| 1766 | - * @author Ohad Raz |
|
| 1767 | - * @since 1.0 |
|
| 1768 | - * @access public |
|
| 1769 | - * @param $id string- field id, i.e. the meta key |
|
| 1770 | - * @param $args mixed|array |
|
| 1771 | - * 'name' => // field name/label string optional |
|
| 1772 | - * 'desc' => // field description, string optional |
|
| 1773 | - * 'std' => // default value, string optional |
|
| 1774 | - * 'validate_func' => // validate function, string optional |
|
| 1775 | - * 'format' => // time format, default hh:mm. Optional. See more formats here: http://goo.gl/83woX |
|
| 1776 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1777 | - */ |
|
| 1778 | - public function addTime($id, $args, $repeater = false) |
|
| 1779 | - { |
|
| 1780 | - $new_field = array('type' => 'time', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'hh:mm', 'name' => __('Time Field', 'geodirectory')); |
|
| 1781 | - $new_field = array_merge($new_field, $args); |
|
| 1782 | - if (false === $repeater) { |
|
| 1783 | - $this->_fields[] = $new_field; |
|
| 1784 | - } else { |
|
| 1785 | - return $new_field; |
|
| 1786 | - } |
|
| 1787 | - } |
|
| 1788 | - |
|
| 1789 | - /** |
|
| 1790 | - * Add Color Field to meta box |
|
| 1791 | - * @author Ohad Raz |
|
| 1792 | - * @since 1.0 |
|
| 1793 | - * @access public |
|
| 1794 | - * @param $id string field id, i.e. the meta key |
|
| 1795 | - * @param $args mixed|array |
|
| 1796 | - * 'name' => // field name/label string optional |
|
| 1797 | - * 'desc' => // field description, string optional |
|
| 1798 | - * 'std' => // default value, string optional |
|
| 1799 | - * 'validate_func' => // validate function, string optional |
|
| 1800 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1801 | - */ |
|
| 1802 | - public function addColor($id, $args, $repeater = false) |
|
| 1803 | - { |
|
| 1804 | - $new_field = array('type' => 'color', 'id' => $id, 'std' => '', 'desc' => '', 'name' => __('ColorPicker Field', 'geodirectory')); |
|
| 1805 | - $new_field = array_merge($new_field, $args); |
|
| 1806 | - if (false === $repeater) { |
|
| 1807 | - $this->_fields[] = $new_field; |
|
| 1808 | - } else { |
|
| 1809 | - return $new_field; |
|
| 1810 | - } |
|
| 1811 | - } |
|
| 1812 | - |
|
| 1813 | - /** |
|
| 1814 | - * Add Image Field to meta box |
|
| 1815 | - * @author Ohad Raz |
|
| 1816 | - * @since 1.0 |
|
| 1817 | - * @access public |
|
| 1818 | - * @param $id string field id, i.e. the meta key |
|
| 1819 | - * @param $args mixed|array |
|
| 1820 | - * 'name' => // field name/label string optional |
|
| 1821 | - * 'desc' => // field description, string optional |
|
| 1822 | - * 'validate_func' => // validate function, string optional |
|
| 1823 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1824 | - */ |
|
| 1825 | - public function addImage($id, $args, $repeater = false) |
|
| 1826 | - { |
|
| 1827 | - $new_field = array('type' => 'image', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('Image Field', 'geodirectory')); |
|
| 1828 | - $new_field = array_merge($new_field, $args); |
|
| 1829 | - |
|
| 1830 | - if (false === $repeater) { |
|
| 1831 | - $this->_fields[] = $new_field; |
|
| 1832 | - } else { |
|
| 1833 | - return $new_field; |
|
| 1834 | - } |
|
| 1835 | - } |
|
| 1836 | - |
|
| 1837 | - /** |
|
| 1838 | - * Add File Field to meta box |
|
| 1839 | - * @author Ohad Raz |
|
| 1840 | - * @since 1.0 |
|
| 1841 | - * @access public |
|
| 1842 | - * @param $id string field id, i.e. the meta key |
|
| 1843 | - * @param $args mixed|array |
|
| 1844 | - * 'name' => // field name/label string optional |
|
| 1845 | - * 'desc' => // field description, string optional |
|
| 1846 | - * 'validate_func' => // validate function, string optional |
|
| 1847 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1848 | - */ |
|
| 1849 | - public function addFile($id, $args, $repeater = false) |
|
| 1850 | - { |
|
| 1851 | - $new_field = array('type' => 'file', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('File Field', 'geodirectory')); |
|
| 1852 | - $new_field = array_merge($new_field, $args); |
|
| 1853 | - if (false === $repeater) { |
|
| 1854 | - $this->_fields[] = $new_field; |
|
| 1855 | - } else { |
|
| 1856 | - return $new_field; |
|
| 1857 | - } |
|
| 1858 | - } |
|
| 1859 | - |
|
| 1860 | - /** |
|
| 1861 | - * Add WYSIWYG Field to meta box |
|
| 1862 | - * @author Ohad Raz |
|
| 1863 | - * @since 1.0 |
|
| 1864 | - * @access public |
|
| 1865 | - * @param $id string field id, i.e. the meta key |
|
| 1866 | - * @param $args mixed|array |
|
| 1867 | - * 'name' => // field name/label string optional |
|
| 1868 | - * 'desc' => // field description, string optional |
|
| 1869 | - * 'std' => // default value, string optional |
|
| 1870 | - * 'style' => // custom style for field, string optional Default 'width: 300px; height: 400px' |
|
| 1871 | - * 'validate_func' => // validate function, string optional |
|
| 1872 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1873 | - */ |
|
| 1874 | - public function addWysiwyg($id, $args, $repeater = false) |
|
| 1875 | - { |
|
| 1876 | - $new_field = array('type' => 'wysiwyg', 'id' => $id, 'std' => '', 'desc' => '', 'style' => 'width: 300px; height: 400px', 'name' => __('WYSIWYG Editor Field', 'geodirectory')); |
|
| 1877 | - $new_field = array_merge($new_field, $args); |
|
| 1878 | - if (false === $repeater) { |
|
| 1879 | - $this->_fields[] = $new_field; |
|
| 1880 | - } else { |
|
| 1881 | - return $new_field; |
|
| 1882 | - } |
|
| 1883 | - } |
|
| 1884 | - |
|
| 1885 | - /** |
|
| 1886 | - * Add Taxonomy Field to meta box |
|
| 1887 | - * @author Ohad Raz |
|
| 1888 | - * @since 1.0 |
|
| 1889 | - * @access public |
|
| 1890 | - * @param $id string field id, i.e. the meta key |
|
| 1891 | - * @param $options mixed|array options of taxonomy field |
|
| 1892 | - * 'taxonomy' => // taxonomy name can be category,post_tag or any custom taxonomy default is category |
|
| 1893 | - * 'type' => // how to show taxonomy? 'select' (default) or 'checkbox_list' |
|
| 1894 | - * 'args' => // arguments to query taxonomy, see http://goo.gl/uAANN default ('hide_empty' => false) |
|
| 1895 | - * @param $args mixed|array |
|
| 1896 | - * 'name' => // field name/label string optional |
|
| 1897 | - * 'desc' => // field description, string optional |
|
| 1898 | - * 'std' => // default value, string optional |
|
| 1899 | - * 'validate_func' => // validate function, string optional |
|
| 1900 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1901 | - */ |
|
| 1902 | - public function addTaxonomy($id, $options, $args, $repeater = false) |
|
| 1903 | - { |
|
| 1904 | - $q = array('hide_empty' => 0); |
|
| 1905 | - $tax = 'category'; |
|
| 1906 | - $type = 'select'; |
|
| 1907 | - $temp = array($tax, $type, $q); |
|
| 1908 | - $options = array_merge($temp, $options); |
|
| 1909 | - $new_field = array('type' => 'taxonomy', 'id' => $id, 'desc' => '', 'name' => __('Taxonomy Field', 'geodirectory'), 'options' => $options); |
|
| 1910 | - $new_field = array_merge($new_field, $args); |
|
| 1911 | - if (false === $repeater) { |
|
| 1912 | - $this->_fields[] = $new_field; |
|
| 1913 | - } else { |
|
| 1914 | - return $new_field; |
|
| 1915 | - } |
|
| 1916 | - } |
|
| 1917 | - |
|
| 1918 | - /** |
|
| 1919 | - * Add posts Field to meta box |
|
| 1920 | - * @author Ohad Raz |
|
| 1921 | - * @since 1.0 |
|
| 1922 | - * @access public |
|
| 1923 | - * @param $id string field id, i.e. the meta key |
|
| 1924 | - * @param $options mixed|array options of taxonomy field |
|
| 1925 | - * 'post_type' => // post type name, 'post' (default) 'page' or any custom post type |
|
| 1926 | - * 'type' => // how to show posts? 'select' (default) or 'checkbox_list' |
|
| 1927 | - * 'args' => // arguments to query posts, see http://goo.gl/is0yK default ('posts_per_page' => -1) |
|
| 1928 | - * @param $args mixed|array |
|
| 1929 | - * 'name' => // field name/label string optional |
|
| 1930 | - * 'desc' => // field description, string optional |
|
| 1931 | - * 'std' => // default value, string optional |
|
| 1932 | - * 'validate_func' => // validate function, string optional |
|
| 1933 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1934 | - */ |
|
| 1935 | - public function addPosts($id, $options, $args, $repeater = false) |
|
| 1936 | - { |
|
| 1937 | - $q = array('posts_per_page' => -1); |
|
| 1938 | - $temp = array('post_type' => 'post', 'type' => 'select', 'args' => $q); |
|
| 1939 | - $options = array_merge($temp, $options); |
|
| 1940 | - $new_field = array('type' => 'posts', 'id' => $id, 'desc' => '', 'name' => __('Posts Field', 'geodirectory'), 'options' => $options); |
|
| 1941 | - $new_field = array_merge($new_field, $args); |
|
| 1942 | - if (false === $repeater) { |
|
| 1943 | - $this->_fields[] = $new_field; |
|
| 1944 | - } else { |
|
| 1945 | - return $new_field; |
|
| 1946 | - } |
|
| 1947 | - } |
|
| 1948 | - |
|
| 1949 | - /** |
|
| 1950 | - * Add repeater Field Block to meta box |
|
| 1951 | - * @author Ohad Raz |
|
| 1952 | - * @since 1.0 |
|
| 1953 | - * @access public |
|
| 1954 | - * @param $id string field id, i.e. the meta key |
|
| 1955 | - * @param $args mixed|array |
|
| 1956 | - * 'name' => // field name/label string optional |
|
| 1957 | - * 'desc' => // field description, string optional |
|
| 1958 | - * 'std' => // default value, string optional |
|
| 1959 | - * 'style' => // custom style for field, string optional |
|
| 1960 | - * 'validate_func' => // validate function, string optional |
|
| 1961 | - * 'fields' => //fields to repeater |
|
| 1962 | - */ |
|
| 1963 | - public function addRepeaterBlock($id, $args) |
|
| 1964 | - { |
|
| 1965 | - $new_field = array('type' => 'repeater', 'id' => $id, 'name' => __('Reapeater Field', 'geodirectory'), 'fields' => array(), 'inline' => false); |
|
| 1966 | - $new_field = array_merge($new_field, $args); |
|
| 1967 | - $this->_fields[] = $new_field; |
|
| 1968 | - } |
|
| 1969 | - |
|
| 1970 | - |
|
| 1971 | - /** |
|
| 1972 | - * Finish Declaration of Meta Box |
|
| 1973 | - * @author Ohad Raz |
|
| 1974 | - * @since 1.0 |
|
| 1975 | - * @access public |
|
| 1976 | - */ |
|
| 1977 | - public function Finish() |
|
| 1978 | - { |
|
| 1979 | - $this->add_missed_values(); |
|
| 1980 | - $this->check_field_upload(); |
|
| 1981 | - $this->check_field_color(); |
|
| 1982 | - $this->check_field_date(); |
|
| 1983 | - $this->check_field_time(); |
|
| 1984 | - } |
|
| 1985 | - |
|
| 1986 | - /** |
|
| 1987 | - * Helper function to check for empty arrays |
|
| 1988 | - * @author Ohad Raz |
|
| 1989 | - * @since 1.0 |
|
| 1990 | - * @access public |
|
| 1991 | - * @param $args mixed|array |
|
| 1992 | - */ |
|
| 1993 | - public function is_array_empty($array) |
|
| 1994 | - { |
|
| 1995 | - if (!is_array($array)) |
|
| 1996 | - return true; |
|
| 1997 | - |
|
| 1998 | - foreach ($array as $a) { |
|
| 1999 | - if (is_array($a)) { |
|
| 2000 | - foreach ($a as $sub_a) { |
|
| 2001 | - if (!empty($sub_a) && $sub_a != '') |
|
| 2002 | - return false; |
|
| 2003 | - } |
|
| 2004 | - } else { |
|
| 2005 | - if (!empty($a) && $a != '') |
|
| 2006 | - return false; |
|
| 2007 | - } |
|
| 2008 | - } |
|
| 2009 | - return true; |
|
| 2010 | - } |
|
| 2011 | - |
|
| 2012 | - |
|
| 2013 | - //get term meta field |
|
| 2014 | - public function get_tax_meta($term_id, $key, $multi = false, $post_type = '') |
|
| 2015 | - { |
|
| 2016 | - |
|
| 2017 | - if (empty($post_type) && isset($_REQUEST['taxonomy'])) { |
|
| 2018 | - $taxObject = get_taxonomy($_REQUEST['taxonomy']); |
|
| 2019 | - $post_type = $taxObject->object_type[0]; |
|
| 2020 | - } |
|
| 2021 | - |
|
| 2022 | - if($post_type=='post'){$post_type='';} |
|
| 2023 | - if($post_type){$post_type = $post_type.'_';} |
|
| 2024 | - |
|
| 2025 | - $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; |
|
| 2026 | - |
|
| 2027 | - $m = get_option('tax_meta_' . $post_type . $t_id); |
|
| 2028 | - if (isset($m[$key])) { |
|
| 2029 | - return $m[$key]; |
|
| 2030 | - } else { |
|
| 2031 | - return ''; |
|
| 2032 | - } |
|
| 2033 | - } |
|
| 2034 | - |
|
| 2035 | - //delete meta |
|
| 2036 | - public function delete_tax_meta($term_id, $key, $post_type = '') |
|
| 2037 | - { |
|
| 2038 | - |
|
| 2039 | - if (empty($post_type) && isset($_REQUEST['taxonomy'])) { |
|
| 2040 | - $taxObject = get_taxonomy($_REQUEST['taxonomy']); |
|
| 2041 | - $post_type = $taxObject->object_type[0]; |
|
| 2042 | - } |
|
| 2043 | - |
|
| 2044 | - if($post_type=='post'){$post_type='';} |
|
| 2045 | - if($post_type){$post_type = $post_type.'_';} |
|
| 2046 | - |
|
| 2047 | - $m = get_option('tax_meta_' . $post_type . $term_id); |
|
| 2048 | - |
|
| 2049 | - if (isset($m[$key])) { |
|
| 2050 | - unset($m[$key]); |
|
| 2051 | - } |
|
| 2052 | - update_option('tax_meta_' . $post_type . $term_id, $m); |
|
| 2053 | - } |
|
| 2054 | - |
|
| 2055 | - //update meta |
|
| 2056 | - public function update_tax_meta($term_id, $key, $value, $post_type = '') |
|
| 2057 | - { |
|
| 2058 | - |
|
| 2059 | - if (empty($post_type) && isset($_REQUEST['taxonomy'])) { |
|
| 2060 | - $taxObject = get_taxonomy($_REQUEST['taxonomy']); |
|
| 2061 | - $post_type = $taxObject->object_type[0]; |
|
| 2062 | - } |
|
| 2063 | - |
|
| 2064 | - if($post_type=='post'){$post_type='';} |
|
| 2065 | - if($post_type){$post_type = $post_type.'_';} |
|
| 2066 | - |
|
| 2067 | - $m = get_option('tax_meta_' . $post_type . $term_id); |
|
| 2068 | - |
|
| 2069 | - $m[$key] = $value; |
|
| 2070 | - update_option('tax_meta_' . $post_type . $term_id, $m); |
|
| 2071 | - |
|
| 2072 | - /** |
|
| 2073 | - * Called after the tax meta is updated. |
|
| 2074 | - * |
|
| 2075 | - * Used to update things after a GD category is saved. |
|
| 2076 | - * |
|
| 2077 | - * @since 1.0.0 |
|
| 2078 | - * @param bool $false False. |
|
| 2079 | - * @param bool $true True. |
|
| 2080 | - * @param int $term_id The term id being updated. |
|
| 2081 | - * @param string $post_type The post type of the cat being updated. |
|
| 2082 | - */ |
|
| 2083 | - do_action('gd_tax_meta_updated', false, true, $term_id, $post_type); |
|
| 2084 | - } |
|
| 2085 | - |
|
| 2086 | - |
|
| 2087 | - } // End Class |
|
| 1288 | + public function save_field_wysiwyg($term_id, $field, $old, $new) |
|
| 1289 | + { |
|
| 1290 | + $this->save_field($term_id, $field, $old, $new); |
|
| 1291 | + } |
|
| 1292 | + |
|
| 1293 | + /** |
|
| 1294 | + * Save repeater Fields. |
|
| 1295 | + * |
|
| 1296 | + * @param string $term_id The term ID. |
|
| 1297 | + * @param string $field |
|
| 1298 | + * @param string|mixed $old |
|
| 1299 | + * @param string|mixed $new |
|
| 1300 | + * @since 1.0 |
|
| 1301 | + * @access public |
|
| 1302 | + */ |
|
| 1303 | + public function save_field_repeater($term_id, $field, $old, $new) |
|
| 1304 | + { |
|
| 1305 | + if (is_array($new) && count($new) > 0) { |
|
| 1306 | + foreach ($new as $n) { |
|
| 1307 | + foreach ($field['fields'] as $f) { |
|
| 1308 | + $type = $f['type']; |
|
| 1309 | + switch ($type) { |
|
| 1310 | + case 'wysiwyg': |
|
| 1311 | + $n[$f['id']] = wpautop($n[$f['id']]); |
|
| 1312 | + break; |
|
| 1313 | + case 'file': |
|
| 1314 | + $n[$f['id']] = $this->save_field_file_repeater($term_id, $f, '', $n[$f['id']]); |
|
| 1315 | + break; |
|
| 1316 | + default: |
|
| 1317 | + break; |
|
| 1318 | + } |
|
| 1319 | + } |
|
| 1320 | + if (!$this->is_array_empty($n)) |
|
| 1321 | + $temp[] = $n; |
|
| 1322 | + } |
|
| 1323 | + if (isset($temp) && count($temp) > 0 && !$this->is_array_empty($temp)) { |
|
| 1324 | + $this->update_tax_meta($term_id, $field['id'], $temp); |
|
| 1325 | + } else { |
|
| 1326 | + // remove old meta if exists |
|
| 1327 | + delete_post_meta($term_id, $field['id']); |
|
| 1328 | + } |
|
| 1329 | + } else { |
|
| 1330 | + // remove old meta if exists |
|
| 1331 | + delete_post_meta($term_id, $field['id']); |
|
| 1332 | + } |
|
| 1333 | + } |
|
| 1334 | + |
|
| 1335 | + /** |
|
| 1336 | + * Save File Field. |
|
| 1337 | + * |
|
| 1338 | + * @param string $term_id The term ID. |
|
| 1339 | + * @param string $field |
|
| 1340 | + * @param string $old |
|
| 1341 | + * @param string $new |
|
| 1342 | + * @since 1.0 |
|
| 1343 | + * @access public |
|
| 1344 | + */ |
|
| 1345 | + public function save_field_file($term_id, $field, $old, $new) |
|
| 1346 | + { |
|
| 1347 | + |
|
| 1348 | + $name = $field['id']; |
|
| 1349 | + if (empty($_FILES[$name])) |
|
| 1350 | + return; |
|
| 1351 | + $this->fix_file_array($_FILES[$name]); |
|
| 1352 | + foreach ($_FILES[$name] as $position => $fileitem) { |
|
| 1353 | + |
|
| 1354 | + $file = wp_handle_upload($fileitem, array('test_form' => false)); |
|
| 1355 | + if (empty($file['file'])) |
|
| 1356 | + continue; |
|
| 1357 | + $filename = $file['file']; |
|
| 1358 | + |
|
| 1359 | + $attachment = array( |
|
| 1360 | + 'post_mime_type' => $file['type'], |
|
| 1361 | + 'guid' => $file['url'], |
|
| 1362 | + 'post_parent' => $term_id, |
|
| 1363 | + 'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)), |
|
| 1364 | + 'post_content' => '' |
|
| 1365 | + ); |
|
| 1366 | + |
|
| 1367 | + $id = wp_insert_attachment($attachment, $filename, $term_id); |
|
| 1368 | + |
|
| 1369 | + if (!is_wp_error($id)) { |
|
| 1370 | + |
|
| 1371 | + wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); |
|
| 1372 | + add_post_meta($term_id, $name, $id, false); // save file's url in meta fields |
|
| 1373 | + |
|
| 1374 | + } // End if |
|
| 1375 | + |
|
| 1376 | + } // End foreach |
|
| 1377 | + |
|
| 1378 | + } |
|
| 1379 | + |
|
| 1380 | + /** |
|
| 1381 | + * Save repeater File Field. |
|
| 1382 | + * @param string $term_id The term ID. |
|
| 1383 | + * @param string $field |
|
| 1384 | + * @param string $old |
|
| 1385 | + * @param string $new |
|
| 1386 | + * @since 1.0 |
|
| 1387 | + * @access public |
|
| 1388 | + * @return int|void |
|
| 1389 | + */ |
|
| 1390 | + public function save_field_file_repeater($term_id, $field, $old, $new) |
|
| 1391 | + { |
|
| 1392 | + |
|
| 1393 | + $name = $field['id']; |
|
| 1394 | + if (empty($_FILES[$name])) |
|
| 1395 | + return; |
|
| 1396 | + $this->fix_file_array($_FILES[$name]); |
|
| 1397 | + foreach ($_FILES[$name] as $position => $fileitem) { |
|
| 1398 | + |
|
| 1399 | + $file = wp_handle_upload($fileitem, array('test_form' => false)); |
|
| 1400 | + if (empty($file['file'])) |
|
| 1401 | + continue; |
|
| 1402 | + $filename = $file['file']; |
|
| 1403 | + |
|
| 1404 | + $attachment = array( |
|
| 1405 | + 'post_mime_type' => $file['type'], |
|
| 1406 | + 'guid' => $file['url'], |
|
| 1407 | + 'post_parent' => $term_id, |
|
| 1408 | + 'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)), |
|
| 1409 | + 'post_content' => '' |
|
| 1410 | + ); |
|
| 1411 | + |
|
| 1412 | + $id = wp_insert_attachment($attachment, $filename); |
|
| 1413 | + |
|
| 1414 | + if (!is_wp_error($id)) { |
|
| 1415 | + |
|
| 1416 | + wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); |
|
| 1417 | + return $id; // return file's url in meta fields |
|
| 1418 | + } // End if |
|
| 1419 | + } // End foreach |
|
| 1420 | + } |
|
| 1421 | + |
|
| 1422 | + /** |
|
| 1423 | + * Add missed values for meta box. |
|
| 1424 | + * |
|
| 1425 | + * @since 1.0 |
|
| 1426 | + * @access public |
|
| 1427 | + */ |
|
| 1428 | + public function add_missed_values() |
|
| 1429 | + { |
|
| 1430 | + |
|
| 1431 | + // Default values for meta box |
|
| 1432 | + $this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array)$this->_meta_box); |
|
| 1433 | + |
|
| 1434 | + if(is_array($this->_fields)) { |
|
| 1435 | + // Default values for fields |
|
| 1436 | + foreach ($this->_fields as &$field) { |
|
| 1437 | + $multiple = in_array($field['type'], array('checkbox_list', 'file', 'image')); |
|
| 1438 | + $std = $multiple ? array() : ''; |
|
| 1439 | + $format = 'date' == $field['type'] ? 'yy-mm-dd' : ('time' == $field['type'] ? 'hh:mm' : ''); |
|
| 1440 | + $field = array_merge(array('multiple' => $multiple, 'std' => $std, 'desc' => '', 'format' => $format, 'validate_func' => ''), $field); |
|
| 1441 | + } // End foreach |
|
| 1442 | + } |
|
| 1443 | + } |
|
| 1444 | + |
|
| 1445 | + /** |
|
| 1446 | + * Check if field with $type exists. |
|
| 1447 | + * |
|
| 1448 | + * @param string $type |
|
| 1449 | + * @since 1.0 |
|
| 1450 | + * @access public |
|
| 1451 | + */ |
|
| 1452 | + public function has_field($type) |
|
| 1453 | + { |
|
| 1454 | + if(is_array($this->_fields)) { |
|
| 1455 | + foreach ($this->_fields as $field) { |
|
| 1456 | + if ($type == $field['type']) |
|
| 1457 | + return true; |
|
| 1458 | + } |
|
| 1459 | + } |
|
| 1460 | + return false; |
|
| 1461 | + } |
|
| 1462 | + |
|
| 1463 | + /** |
|
| 1464 | + * Check if current page is edit page. |
|
| 1465 | + * |
|
| 1466 | + * @since 1.0 |
|
| 1467 | + * @access public |
|
| 1468 | + */ |
|
| 1469 | + public function is_edit_page() |
|
| 1470 | + { |
|
| 1471 | + global $pagenow; |
|
| 1472 | + return ($pagenow == 'edit-tags.php' || $pagenow == 'term.php'); |
|
| 1473 | + } |
|
| 1474 | + |
|
| 1475 | + /** |
|
| 1476 | + * Fixes the odd indexing of multiple file uploads. |
|
| 1477 | + * |
|
| 1478 | + * Goes from the format: |
|
| 1479 | + * $_FILES['field']['key']['index'] |
|
| 1480 | + * to |
|
| 1481 | + * The More standard and appropriate: |
|
| 1482 | + * $_FILES['field']['index']['key'] |
|
| 1483 | + * |
|
| 1484 | + * @param string $files |
|
| 1485 | + * @since 1.0 |
|
| 1486 | + * @access public |
|
| 1487 | + */ |
|
| 1488 | + public function fix_file_array(&$files) |
|
| 1489 | + { |
|
| 1490 | + |
|
| 1491 | + $output = array(); |
|
| 1492 | + |
|
| 1493 | + foreach ($files as $key => $list) { |
|
| 1494 | + foreach ($list as $index => $value) { |
|
| 1495 | + $output[$index][$key] = $value; |
|
| 1496 | + } |
|
| 1497 | + } |
|
| 1498 | + |
|
| 1499 | + return $files = $output; |
|
| 1500 | + |
|
| 1501 | + } |
|
| 1502 | + |
|
| 1503 | + /** |
|
| 1504 | + * Get proper JQuery UI version. |
|
| 1505 | + * |
|
| 1506 | + * Used in order to not conflict with WP Admin Scripts. |
|
| 1507 | + * |
|
| 1508 | + * @since 1.0 |
|
| 1509 | + * @access public |
|
| 1510 | + */ |
|
| 1511 | + public function get_jqueryui_ver() |
|
| 1512 | + { |
|
| 1513 | + |
|
| 1514 | + global $wp_version; |
|
| 1515 | + |
|
| 1516 | + if (version_compare($wp_version, '3.1', '>=')) { |
|
| 1517 | + return '1.8.10'; |
|
| 1518 | + } |
|
| 1519 | + |
|
| 1520 | + return '1.7.3'; |
|
| 1521 | + |
|
| 1522 | + } |
|
| 1523 | + |
|
| 1524 | + /** |
|
| 1525 | + * Add Field to meta box (generic function) |
|
| 1526 | + * @author Ohad Raz |
|
| 1527 | + * @since 1.0 |
|
| 1528 | + * @access public |
|
| 1529 | + * @param $id string field id, i.e. the meta key |
|
| 1530 | + * @param $args mixed|array |
|
| 1531 | + */ |
|
| 1532 | + public function addField($id, $args) |
|
| 1533 | + { |
|
| 1534 | + $new_field = array('id' => $id, 'std' => '', 'desc' => '', 'style' => ''); |
|
| 1535 | + $new_field = array_merge($new_field, $args); |
|
| 1536 | + $this->_fields[] = $new_field; |
|
| 1537 | + } |
|
| 1538 | + |
|
| 1539 | + |
|
| 1540 | + /** |
|
| 1541 | + * Add Text Field to meta box |
|
| 1542 | + * @author Ohad Raz |
|
| 1543 | + * @since 1.0 |
|
| 1544 | + * @access public |
|
| 1545 | + * @param $id string field id, i.e. the meta key |
|
| 1546 | + * @param $args mixed|array |
|
| 1547 | + * 'name' => // field name/label string optional |
|
| 1548 | + * 'desc' => // field description, string optional |
|
| 1549 | + * 'std' => // default value, string optional |
|
| 1550 | + * 'style' => // custom style for field, string optional |
|
| 1551 | + * 'validate_func' => // validate function, string optional |
|
| 1552 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1553 | + */ |
|
| 1554 | + public function addText($id, $args, $repeater = false) |
|
| 1555 | + { |
|
| 1556 | + $new_field = array('type' => 'text', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory')); |
|
| 1557 | + $new_field = array_merge($new_field, $args); |
|
| 1558 | + if (false === $repeater) { |
|
| 1559 | + $this->_fields[] = $new_field; |
|
| 1560 | + } else { |
|
| 1561 | + return $new_field; |
|
| 1562 | + } |
|
| 1563 | + } |
|
| 1564 | + |
|
| 1565 | + /** |
|
| 1566 | + * Add Hidden Field to meta box |
|
| 1567 | + * @author Ohad Raz |
|
| 1568 | + * @since 0.1.3 |
|
| 1569 | + * @access public |
|
| 1570 | + * @param $id string field id, i.e. the meta key |
|
| 1571 | + * @param $args mixed|array |
|
| 1572 | + * 'name' => // field name/label string optional |
|
| 1573 | + * 'desc' => // field description, string optional |
|
| 1574 | + * 'std' => // default value, string optional |
|
| 1575 | + * 'style' => // custom style for field, string optional |
|
| 1576 | + * 'validate_func' => // validate function, string optional |
|
| 1577 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1578 | + */ |
|
| 1579 | + public function addHidden($id, $args, $repeater = false) |
|
| 1580 | + { |
|
| 1581 | + $new_field = array('type' => 'hidden', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory')); |
|
| 1582 | + $new_field = array_merge($new_field, $args); |
|
| 1583 | + if (false === $repeater) { |
|
| 1584 | + $this->_fields[] = $new_field; |
|
| 1585 | + } else { |
|
| 1586 | + return $new_field; |
|
| 1587 | + } |
|
| 1588 | + } |
|
| 1589 | + |
|
| 1590 | + /** |
|
| 1591 | + * Add Paragraph to meta box |
|
| 1592 | + * @author Ohad Raz |
|
| 1593 | + * @since 0.1.3 |
|
| 1594 | + * @access public |
|
| 1595 | + * @param $id string field id, i.e. the meta key |
|
| 1596 | + * @param $value paragraph html |
|
| 1597 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1598 | + */ |
|
| 1599 | + public function addParagraph($id, $args, $repeater = false) |
|
| 1600 | + { |
|
| 1601 | + $new_field = array('type' => 'paragraph', 'id' => $id, 'value' => '', 'style' => ''); |
|
| 1602 | + $new_field = array_merge($new_field, $args); |
|
| 1603 | + if (false === $repeater) { |
|
| 1604 | + $this->_fields[] = $new_field; |
|
| 1605 | + } else { |
|
| 1606 | + return $new_field; |
|
| 1607 | + } |
|
| 1608 | + } |
|
| 1609 | + |
|
| 1610 | + /** |
|
| 1611 | + * Add Checkbox Field to meta box |
|
| 1612 | + * @author Ohad Raz |
|
| 1613 | + * @since 1.0 |
|
| 1614 | + * @access public |
|
| 1615 | + * @param $id string field id, i.e. the meta key |
|
| 1616 | + * @param $args mixed|array |
|
| 1617 | + * 'name' => // field name/label string optional |
|
| 1618 | + * 'desc' => // field description, string optional |
|
| 1619 | + * 'std' => // default value, string optional |
|
| 1620 | + * 'validate_func' => // validate function, string optional |
|
| 1621 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1622 | + */ |
|
| 1623 | + public function addCheckbox($id, $args, $repeater = false) |
|
| 1624 | + { |
|
| 1625 | + $new_field = array('type' => 'checkbox', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox Field', 'geodirectory')); |
|
| 1626 | + $new_field = array_merge($new_field, $args); |
|
| 1627 | + if (false === $repeater) { |
|
| 1628 | + $this->_fields[] = $new_field; |
|
| 1629 | + } else { |
|
| 1630 | + return $new_field; |
|
| 1631 | + } |
|
| 1632 | + } |
|
| 1633 | + |
|
| 1634 | + /** |
|
| 1635 | + * Add CheckboxList Field to meta box |
|
| 1636 | + * @author Ohad Raz |
|
| 1637 | + * @since 1.0 |
|
| 1638 | + * @access public |
|
| 1639 | + * @param $id string field id, i.e. the meta key |
|
| 1640 | + * @param $options (array) array of key => value pairs for select options |
|
| 1641 | + * @param $args mixed|array |
|
| 1642 | + * 'name' => // field name/label string optional |
|
| 1643 | + * 'desc' => // field description, string optional |
|
| 1644 | + * 'std' => // default value, string optional |
|
| 1645 | + * 'validate_func' => // validate function, string optional |
|
| 1646 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1647 | + * |
|
| 1648 | + * @return : remember to call: $checkbox_list = $this->get_tax_meta(get_the_ID(), 'meta_name', false); |
|
| 1649 | + * which means the last param as false to get the values in an array |
|
| 1650 | + */ |
|
| 1651 | + public function addCheckboxList($id, $options, $args, $repeater = false) |
|
| 1652 | + { |
|
| 1653 | + $new_field = array('type' => 'checkbox_list', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox List Field', 'geodirectory')); |
|
| 1654 | + $new_field = array_merge($new_field, $args); |
|
| 1655 | + if (false === $repeater) { |
|
| 1656 | + $this->_fields[] = $new_field; |
|
| 1657 | + } else { |
|
| 1658 | + return $new_field; |
|
| 1659 | + } |
|
| 1660 | + } |
|
| 1661 | + |
|
| 1662 | + /** |
|
| 1663 | + * Add Textarea Field to meta box |
|
| 1664 | + * @author Ohad Raz |
|
| 1665 | + * @since 1.0 |
|
| 1666 | + * @access public |
|
| 1667 | + * @param $id string field id, i.e. the meta key |
|
| 1668 | + * @param $args mixed|array |
|
| 1669 | + * 'name' => // field name/label string optional |
|
| 1670 | + * 'desc' => // field description, string optional |
|
| 1671 | + * 'std' => // default value, string optional |
|
| 1672 | + * 'style' => // custom style for field, string optional |
|
| 1673 | + * 'validate_func' => // validate function, string optional |
|
| 1674 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1675 | + */ |
|
| 1676 | + public function addTextarea($id, $args, $repeater = false) |
|
| 1677 | + { |
|
| 1678 | + $new_field = array('type' => 'textarea', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Textarea Field', 'geodirectory')); |
|
| 1679 | + $new_field = array_merge($new_field, $args); |
|
| 1680 | + if (false === $repeater) { |
|
| 1681 | + $this->_fields[] = $new_field; |
|
| 1682 | + } else { |
|
| 1683 | + return $new_field; |
|
| 1684 | + } |
|
| 1685 | + } |
|
| 1686 | + |
|
| 1687 | + /** |
|
| 1688 | + * Add Select Field to meta box |
|
| 1689 | + * @author Ohad Raz |
|
| 1690 | + * @since 1.0 |
|
| 1691 | + * @access public |
|
| 1692 | + * @param $id string field id, i.e. the meta key |
|
| 1693 | + * @param $options (array) array of key => value pairs for select options |
|
| 1694 | + * @param $args mixed|array |
|
| 1695 | + * 'name' => // field name/label string optional |
|
| 1696 | + * 'desc' => // field description, string optional |
|
| 1697 | + * 'std' => // default value, (array) optional |
|
| 1698 | + * 'multiple' => // select multiple values, optional. Default is false. |
|
| 1699 | + * 'validate_func' => // validate function, string optional |
|
| 1700 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1701 | + */ |
|
| 1702 | + public function addSelect($id, $options, $args, $repeater = false) |
|
| 1703 | + { |
|
| 1704 | + $new_field = array('type' => 'select', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Select Field', 'geodirectory'), 'multiple' => false, 'options' => $options); |
|
| 1705 | + $new_field = array_merge($new_field, $args); |
|
| 1706 | + if (false === $repeater) { |
|
| 1707 | + $this->_fields[] = $new_field; |
|
| 1708 | + } else { |
|
| 1709 | + return $new_field; |
|
| 1710 | + } |
|
| 1711 | + } |
|
| 1712 | + |
|
| 1713 | + |
|
| 1714 | + /** |
|
| 1715 | + * Add Radio Field to meta box |
|
| 1716 | + * @author Ohad Raz |
|
| 1717 | + * @since 1.0 |
|
| 1718 | + * @access public |
|
| 1719 | + * @param $id string field id, i.e. the meta key |
|
| 1720 | + * @param $options (array) array of key => value pairs for radio options |
|
| 1721 | + * @param $args mixed|array |
|
| 1722 | + * 'name' => // field name/label string optional |
|
| 1723 | + * 'desc' => // field description, string optional |
|
| 1724 | + * 'std' => // default value, string optional |
|
| 1725 | + * 'validate_func' => // validate function, string optional |
|
| 1726 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1727 | + */ |
|
| 1728 | + public function addRadio($id, $options, $args, $repeater = false) |
|
| 1729 | + { |
|
| 1730 | + $new_field = array('type' => 'radio', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Radio Field', 'geodirectory'), 'options' => $options); |
|
| 1731 | + $new_field = array_merge($new_field, $args); |
|
| 1732 | + if (false === $repeater) { |
|
| 1733 | + $this->_fields[] = $new_field; |
|
| 1734 | + } else { |
|
| 1735 | + return $new_field; |
|
| 1736 | + } |
|
| 1737 | + } |
|
| 1738 | + |
|
| 1739 | + /** |
|
| 1740 | + * Add Date Field to meta box |
|
| 1741 | + * @author Ohad Raz |
|
| 1742 | + * @since 1.0 |
|
| 1743 | + * @access public |
|
| 1744 | + * @param $id string field id, i.e. the meta key |
|
| 1745 | + * @param $args mixed|array |
|
| 1746 | + * 'name' => // field name/label string optional |
|
| 1747 | + * 'desc' => // field description, string optional |
|
| 1748 | + * 'std' => // default value, string optional |
|
| 1749 | + * 'validate_func' => // validate function, string optional |
|
| 1750 | + * 'format' => // date format, default yy-mm-dd. Optional. Default "'d MM, yy'" See more formats here: http://goo.gl/Wcwxn |
|
| 1751 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1752 | + */ |
|
| 1753 | + public function addDate($id, $args, $repeater = false) |
|
| 1754 | + { |
|
| 1755 | + $new_field = array('type' => 'date', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'yy-mm-dd', 'name' => __('Date Field', 'geodirectory')); |
|
| 1756 | + $new_field = array_merge($new_field, $args); |
|
| 1757 | + if (false === $repeater) { |
|
| 1758 | + $this->_fields[] = $new_field; |
|
| 1759 | + } else { |
|
| 1760 | + return $new_field; |
|
| 1761 | + } |
|
| 1762 | + } |
|
| 1763 | + |
|
| 1764 | + /** |
|
| 1765 | + * Add Time Field to meta box |
|
| 1766 | + * @author Ohad Raz |
|
| 1767 | + * @since 1.0 |
|
| 1768 | + * @access public |
|
| 1769 | + * @param $id string- field id, i.e. the meta key |
|
| 1770 | + * @param $args mixed|array |
|
| 1771 | + * 'name' => // field name/label string optional |
|
| 1772 | + * 'desc' => // field description, string optional |
|
| 1773 | + * 'std' => // default value, string optional |
|
| 1774 | + * 'validate_func' => // validate function, string optional |
|
| 1775 | + * 'format' => // time format, default hh:mm. Optional. See more formats here: http://goo.gl/83woX |
|
| 1776 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1777 | + */ |
|
| 1778 | + public function addTime($id, $args, $repeater = false) |
|
| 1779 | + { |
|
| 1780 | + $new_field = array('type' => 'time', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'hh:mm', 'name' => __('Time Field', 'geodirectory')); |
|
| 1781 | + $new_field = array_merge($new_field, $args); |
|
| 1782 | + if (false === $repeater) { |
|
| 1783 | + $this->_fields[] = $new_field; |
|
| 1784 | + } else { |
|
| 1785 | + return $new_field; |
|
| 1786 | + } |
|
| 1787 | + } |
|
| 1788 | + |
|
| 1789 | + /** |
|
| 1790 | + * Add Color Field to meta box |
|
| 1791 | + * @author Ohad Raz |
|
| 1792 | + * @since 1.0 |
|
| 1793 | + * @access public |
|
| 1794 | + * @param $id string field id, i.e. the meta key |
|
| 1795 | + * @param $args mixed|array |
|
| 1796 | + * 'name' => // field name/label string optional |
|
| 1797 | + * 'desc' => // field description, string optional |
|
| 1798 | + * 'std' => // default value, string optional |
|
| 1799 | + * 'validate_func' => // validate function, string optional |
|
| 1800 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1801 | + */ |
|
| 1802 | + public function addColor($id, $args, $repeater = false) |
|
| 1803 | + { |
|
| 1804 | + $new_field = array('type' => 'color', 'id' => $id, 'std' => '', 'desc' => '', 'name' => __('ColorPicker Field', 'geodirectory')); |
|
| 1805 | + $new_field = array_merge($new_field, $args); |
|
| 1806 | + if (false === $repeater) { |
|
| 1807 | + $this->_fields[] = $new_field; |
|
| 1808 | + } else { |
|
| 1809 | + return $new_field; |
|
| 1810 | + } |
|
| 1811 | + } |
|
| 1812 | + |
|
| 1813 | + /** |
|
| 1814 | + * Add Image Field to meta box |
|
| 1815 | + * @author Ohad Raz |
|
| 1816 | + * @since 1.0 |
|
| 1817 | + * @access public |
|
| 1818 | + * @param $id string field id, i.e. the meta key |
|
| 1819 | + * @param $args mixed|array |
|
| 1820 | + * 'name' => // field name/label string optional |
|
| 1821 | + * 'desc' => // field description, string optional |
|
| 1822 | + * 'validate_func' => // validate function, string optional |
|
| 1823 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1824 | + */ |
|
| 1825 | + public function addImage($id, $args, $repeater = false) |
|
| 1826 | + { |
|
| 1827 | + $new_field = array('type' => 'image', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('Image Field', 'geodirectory')); |
|
| 1828 | + $new_field = array_merge($new_field, $args); |
|
| 1829 | + |
|
| 1830 | + if (false === $repeater) { |
|
| 1831 | + $this->_fields[] = $new_field; |
|
| 1832 | + } else { |
|
| 1833 | + return $new_field; |
|
| 1834 | + } |
|
| 1835 | + } |
|
| 1836 | + |
|
| 1837 | + /** |
|
| 1838 | + * Add File Field to meta box |
|
| 1839 | + * @author Ohad Raz |
|
| 1840 | + * @since 1.0 |
|
| 1841 | + * @access public |
|
| 1842 | + * @param $id string field id, i.e. the meta key |
|
| 1843 | + * @param $args mixed|array |
|
| 1844 | + * 'name' => // field name/label string optional |
|
| 1845 | + * 'desc' => // field description, string optional |
|
| 1846 | + * 'validate_func' => // validate function, string optional |
|
| 1847 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1848 | + */ |
|
| 1849 | + public function addFile($id, $args, $repeater = false) |
|
| 1850 | + { |
|
| 1851 | + $new_field = array('type' => 'file', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('File Field', 'geodirectory')); |
|
| 1852 | + $new_field = array_merge($new_field, $args); |
|
| 1853 | + if (false === $repeater) { |
|
| 1854 | + $this->_fields[] = $new_field; |
|
| 1855 | + } else { |
|
| 1856 | + return $new_field; |
|
| 1857 | + } |
|
| 1858 | + } |
|
| 1859 | + |
|
| 1860 | + /** |
|
| 1861 | + * Add WYSIWYG Field to meta box |
|
| 1862 | + * @author Ohad Raz |
|
| 1863 | + * @since 1.0 |
|
| 1864 | + * @access public |
|
| 1865 | + * @param $id string field id, i.e. the meta key |
|
| 1866 | + * @param $args mixed|array |
|
| 1867 | + * 'name' => // field name/label string optional |
|
| 1868 | + * 'desc' => // field description, string optional |
|
| 1869 | + * 'std' => // default value, string optional |
|
| 1870 | + * 'style' => // custom style for field, string optional Default 'width: 300px; height: 400px' |
|
| 1871 | + * 'validate_func' => // validate function, string optional |
|
| 1872 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1873 | + */ |
|
| 1874 | + public function addWysiwyg($id, $args, $repeater = false) |
|
| 1875 | + { |
|
| 1876 | + $new_field = array('type' => 'wysiwyg', 'id' => $id, 'std' => '', 'desc' => '', 'style' => 'width: 300px; height: 400px', 'name' => __('WYSIWYG Editor Field', 'geodirectory')); |
|
| 1877 | + $new_field = array_merge($new_field, $args); |
|
| 1878 | + if (false === $repeater) { |
|
| 1879 | + $this->_fields[] = $new_field; |
|
| 1880 | + } else { |
|
| 1881 | + return $new_field; |
|
| 1882 | + } |
|
| 1883 | + } |
|
| 1884 | + |
|
| 1885 | + /** |
|
| 1886 | + * Add Taxonomy Field to meta box |
|
| 1887 | + * @author Ohad Raz |
|
| 1888 | + * @since 1.0 |
|
| 1889 | + * @access public |
|
| 1890 | + * @param $id string field id, i.e. the meta key |
|
| 1891 | + * @param $options mixed|array options of taxonomy field |
|
| 1892 | + * 'taxonomy' => // taxonomy name can be category,post_tag or any custom taxonomy default is category |
|
| 1893 | + * 'type' => // how to show taxonomy? 'select' (default) or 'checkbox_list' |
|
| 1894 | + * 'args' => // arguments to query taxonomy, see http://goo.gl/uAANN default ('hide_empty' => false) |
|
| 1895 | + * @param $args mixed|array |
|
| 1896 | + * 'name' => // field name/label string optional |
|
| 1897 | + * 'desc' => // field description, string optional |
|
| 1898 | + * 'std' => // default value, string optional |
|
| 1899 | + * 'validate_func' => // validate function, string optional |
|
| 1900 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1901 | + */ |
|
| 1902 | + public function addTaxonomy($id, $options, $args, $repeater = false) |
|
| 1903 | + { |
|
| 1904 | + $q = array('hide_empty' => 0); |
|
| 1905 | + $tax = 'category'; |
|
| 1906 | + $type = 'select'; |
|
| 1907 | + $temp = array($tax, $type, $q); |
|
| 1908 | + $options = array_merge($temp, $options); |
|
| 1909 | + $new_field = array('type' => 'taxonomy', 'id' => $id, 'desc' => '', 'name' => __('Taxonomy Field', 'geodirectory'), 'options' => $options); |
|
| 1910 | + $new_field = array_merge($new_field, $args); |
|
| 1911 | + if (false === $repeater) { |
|
| 1912 | + $this->_fields[] = $new_field; |
|
| 1913 | + } else { |
|
| 1914 | + return $new_field; |
|
| 1915 | + } |
|
| 1916 | + } |
|
| 1917 | + |
|
| 1918 | + /** |
|
| 1919 | + * Add posts Field to meta box |
|
| 1920 | + * @author Ohad Raz |
|
| 1921 | + * @since 1.0 |
|
| 1922 | + * @access public |
|
| 1923 | + * @param $id string field id, i.e. the meta key |
|
| 1924 | + * @param $options mixed|array options of taxonomy field |
|
| 1925 | + * 'post_type' => // post type name, 'post' (default) 'page' or any custom post type |
|
| 1926 | + * 'type' => // how to show posts? 'select' (default) or 'checkbox_list' |
|
| 1927 | + * 'args' => // arguments to query posts, see http://goo.gl/is0yK default ('posts_per_page' => -1) |
|
| 1928 | + * @param $args mixed|array |
|
| 1929 | + * 'name' => // field name/label string optional |
|
| 1930 | + * 'desc' => // field description, string optional |
|
| 1931 | + * 'std' => // default value, string optional |
|
| 1932 | + * 'validate_func' => // validate function, string optional |
|
| 1933 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) |
|
| 1934 | + */ |
|
| 1935 | + public function addPosts($id, $options, $args, $repeater = false) |
|
| 1936 | + { |
|
| 1937 | + $q = array('posts_per_page' => -1); |
|
| 1938 | + $temp = array('post_type' => 'post', 'type' => 'select', 'args' => $q); |
|
| 1939 | + $options = array_merge($temp, $options); |
|
| 1940 | + $new_field = array('type' => 'posts', 'id' => $id, 'desc' => '', 'name' => __('Posts Field', 'geodirectory'), 'options' => $options); |
|
| 1941 | + $new_field = array_merge($new_field, $args); |
|
| 1942 | + if (false === $repeater) { |
|
| 1943 | + $this->_fields[] = $new_field; |
|
| 1944 | + } else { |
|
| 1945 | + return $new_field; |
|
| 1946 | + } |
|
| 1947 | + } |
|
| 1948 | + |
|
| 1949 | + /** |
|
| 1950 | + * Add repeater Field Block to meta box |
|
| 1951 | + * @author Ohad Raz |
|
| 1952 | + * @since 1.0 |
|
| 1953 | + * @access public |
|
| 1954 | + * @param $id string field id, i.e. the meta key |
|
| 1955 | + * @param $args mixed|array |
|
| 1956 | + * 'name' => // field name/label string optional |
|
| 1957 | + * 'desc' => // field description, string optional |
|
| 1958 | + * 'std' => // default value, string optional |
|
| 1959 | + * 'style' => // custom style for field, string optional |
|
| 1960 | + * 'validate_func' => // validate function, string optional |
|
| 1961 | + * 'fields' => //fields to repeater |
|
| 1962 | + */ |
|
| 1963 | + public function addRepeaterBlock($id, $args) |
|
| 1964 | + { |
|
| 1965 | + $new_field = array('type' => 'repeater', 'id' => $id, 'name' => __('Reapeater Field', 'geodirectory'), 'fields' => array(), 'inline' => false); |
|
| 1966 | + $new_field = array_merge($new_field, $args); |
|
| 1967 | + $this->_fields[] = $new_field; |
|
| 1968 | + } |
|
| 1969 | + |
|
| 1970 | + |
|
| 1971 | + /** |
|
| 1972 | + * Finish Declaration of Meta Box |
|
| 1973 | + * @author Ohad Raz |
|
| 1974 | + * @since 1.0 |
|
| 1975 | + * @access public |
|
| 1976 | + */ |
|
| 1977 | + public function Finish() |
|
| 1978 | + { |
|
| 1979 | + $this->add_missed_values(); |
|
| 1980 | + $this->check_field_upload(); |
|
| 1981 | + $this->check_field_color(); |
|
| 1982 | + $this->check_field_date(); |
|
| 1983 | + $this->check_field_time(); |
|
| 1984 | + } |
|
| 1985 | + |
|
| 1986 | + /** |
|
| 1987 | + * Helper function to check for empty arrays |
|
| 1988 | + * @author Ohad Raz |
|
| 1989 | + * @since 1.0 |
|
| 1990 | + * @access public |
|
| 1991 | + * @param $args mixed|array |
|
| 1992 | + */ |
|
| 1993 | + public function is_array_empty($array) |
|
| 1994 | + { |
|
| 1995 | + if (!is_array($array)) |
|
| 1996 | + return true; |
|
| 1997 | + |
|
| 1998 | + foreach ($array as $a) { |
|
| 1999 | + if (is_array($a)) { |
|
| 2000 | + foreach ($a as $sub_a) { |
|
| 2001 | + if (!empty($sub_a) && $sub_a != '') |
|
| 2002 | + return false; |
|
| 2003 | + } |
|
| 2004 | + } else { |
|
| 2005 | + if (!empty($a) && $a != '') |
|
| 2006 | + return false; |
|
| 2007 | + } |
|
| 2008 | + } |
|
| 2009 | + return true; |
|
| 2010 | + } |
|
| 2011 | + |
|
| 2012 | + |
|
| 2013 | + //get term meta field |
|
| 2014 | + public function get_tax_meta($term_id, $key, $multi = false, $post_type = '') |
|
| 2015 | + { |
|
| 2016 | + |
|
| 2017 | + if (empty($post_type) && isset($_REQUEST['taxonomy'])) { |
|
| 2018 | + $taxObject = get_taxonomy($_REQUEST['taxonomy']); |
|
| 2019 | + $post_type = $taxObject->object_type[0]; |
|
| 2020 | + } |
|
| 2021 | + |
|
| 2022 | + if($post_type=='post'){$post_type='';} |
|
| 2023 | + if($post_type){$post_type = $post_type.'_';} |
|
| 2024 | + |
|
| 2025 | + $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; |
|
| 2026 | + |
|
| 2027 | + $m = get_option('tax_meta_' . $post_type . $t_id); |
|
| 2028 | + if (isset($m[$key])) { |
|
| 2029 | + return $m[$key]; |
|
| 2030 | + } else { |
|
| 2031 | + return ''; |
|
| 2032 | + } |
|
| 2033 | + } |
|
| 2034 | + |
|
| 2035 | + //delete meta |
|
| 2036 | + public function delete_tax_meta($term_id, $key, $post_type = '') |
|
| 2037 | + { |
|
| 2038 | + |
|
| 2039 | + if (empty($post_type) && isset($_REQUEST['taxonomy'])) { |
|
| 2040 | + $taxObject = get_taxonomy($_REQUEST['taxonomy']); |
|
| 2041 | + $post_type = $taxObject->object_type[0]; |
|
| 2042 | + } |
|
| 2043 | + |
|
| 2044 | + if($post_type=='post'){$post_type='';} |
|
| 2045 | + if($post_type){$post_type = $post_type.'_';} |
|
| 2046 | + |
|
| 2047 | + $m = get_option('tax_meta_' . $post_type . $term_id); |
|
| 2048 | + |
|
| 2049 | + if (isset($m[$key])) { |
|
| 2050 | + unset($m[$key]); |
|
| 2051 | + } |
|
| 2052 | + update_option('tax_meta_' . $post_type . $term_id, $m); |
|
| 2053 | + } |
|
| 2054 | + |
|
| 2055 | + //update meta |
|
| 2056 | + public function update_tax_meta($term_id, $key, $value, $post_type = '') |
|
| 2057 | + { |
|
| 2058 | + |
|
| 2059 | + if (empty($post_type) && isset($_REQUEST['taxonomy'])) { |
|
| 2060 | + $taxObject = get_taxonomy($_REQUEST['taxonomy']); |
|
| 2061 | + $post_type = $taxObject->object_type[0]; |
|
| 2062 | + } |
|
| 2063 | + |
|
| 2064 | + if($post_type=='post'){$post_type='';} |
|
| 2065 | + if($post_type){$post_type = $post_type.'_';} |
|
| 2066 | + |
|
| 2067 | + $m = get_option('tax_meta_' . $post_type . $term_id); |
|
| 2068 | + |
|
| 2069 | + $m[$key] = $value; |
|
| 2070 | + update_option('tax_meta_' . $post_type . $term_id, $m); |
|
| 2071 | + |
|
| 2072 | + /** |
|
| 2073 | + * Called after the tax meta is updated. |
|
| 2074 | + * |
|
| 2075 | + * Used to update things after a GD category is saved. |
|
| 2076 | + * |
|
| 2077 | + * @since 1.0.0 |
|
| 2078 | + * @param bool $false False. |
|
| 2079 | + * @param bool $true True. |
|
| 2080 | + * @param int $term_id The term id being updated. |
|
| 2081 | + * @param string $post_type The post type of the cat being updated. |
|
| 2082 | + */ |
|
| 2083 | + do_action('gd_tax_meta_updated', false, true, $term_id, $post_type); |
|
| 2084 | + } |
|
| 2085 | + |
|
| 2086 | + |
|
| 2087 | + } // End Class |
|
| 2088 | 2088 | |
| 2089 | 2089 | endif; // End Check Class Exists |
| 2090 | 2090 | |
@@ -2094,67 +2094,67 @@ discard block |
||
| 2094 | 2094 | |
| 2095 | 2095 | //get term meta field |
| 2096 | 2096 | if (!function_exists('get_tax_meta')) { |
| 2097 | - function get_tax_meta($term_id, $key, $multi = false, $post_type = '') |
|
| 2098 | - { |
|
| 2099 | - |
|
| 2100 | - if (empty($post_type) && isset($_REQUEST['taxonomy'])) { |
|
| 2101 | - $taxObject = get_taxonomy($_REQUEST['taxonomy']); |
|
| 2102 | - $post_type = $taxObject->object_type[0]; |
|
| 2103 | - } |
|
| 2104 | - |
|
| 2105 | - if($post_type=='post'){$post_type='';} |
|
| 2106 | - if($post_type){$post_type = $post_type.'_';} |
|
| 2107 | - |
|
| 2108 | - $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; |
|
| 2109 | - |
|
| 2110 | - $m = get_option('tax_meta_' . $post_type . $t_id); |
|
| 2111 | - if (isset($m[$key])) { |
|
| 2112 | - return $m[$key]; |
|
| 2113 | - } else { |
|
| 2114 | - return ''; |
|
| 2115 | - } |
|
| 2116 | - } |
|
| 2097 | + function get_tax_meta($term_id, $key, $multi = false, $post_type = '') |
|
| 2098 | + { |
|
| 2099 | + |
|
| 2100 | + if (empty($post_type) && isset($_REQUEST['taxonomy'])) { |
|
| 2101 | + $taxObject = get_taxonomy($_REQUEST['taxonomy']); |
|
| 2102 | + $post_type = $taxObject->object_type[0]; |
|
| 2103 | + } |
|
| 2104 | + |
|
| 2105 | + if($post_type=='post'){$post_type='';} |
|
| 2106 | + if($post_type){$post_type = $post_type.'_';} |
|
| 2107 | + |
|
| 2108 | + $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; |
|
| 2109 | + |
|
| 2110 | + $m = get_option('tax_meta_' . $post_type . $t_id); |
|
| 2111 | + if (isset($m[$key])) { |
|
| 2112 | + return $m[$key]; |
|
| 2113 | + } else { |
|
| 2114 | + return ''; |
|
| 2115 | + } |
|
| 2116 | + } |
|
| 2117 | 2117 | } |
| 2118 | 2118 | |
| 2119 | 2119 | //delete meta |
| 2120 | 2120 | if (!function_exists('delete_tax_meta')) { |
| 2121 | - function delete_tax_meta($term_id, $key) |
|
| 2122 | - { |
|
| 2121 | + function delete_tax_meta($term_id, $key) |
|
| 2122 | + { |
|
| 2123 | 2123 | |
| 2124 | - $taxObject = get_taxonomy($_REQUEST['taxonomy']); |
|
| 2125 | - $post_type = $taxObject->object_type[0]; |
|
| 2124 | + $taxObject = get_taxonomy($_REQUEST['taxonomy']); |
|
| 2125 | + $post_type = $taxObject->object_type[0]; |
|
| 2126 | 2126 | |
| 2127 | - if($post_type=='post'){$post_type='';} |
|
| 2128 | - if($post_type){$post_type = $post_type.'_';} |
|
| 2127 | + if($post_type=='post'){$post_type='';} |
|
| 2128 | + if($post_type){$post_type = $post_type.'_';} |
|
| 2129 | 2129 | |
| 2130 | - $m = get_option('tax_meta_' . $post_type . $term_id); |
|
| 2130 | + $m = get_option('tax_meta_' . $post_type . $term_id); |
|
| 2131 | 2131 | |
| 2132 | - if (isset($m[$key])) { |
|
| 2133 | - unset($m[$key]); |
|
| 2134 | - } |
|
| 2135 | - update_option('tax_meta_' . $post_type . $term_id, $m); |
|
| 2136 | - } |
|
| 2132 | + if (isset($m[$key])) { |
|
| 2133 | + unset($m[$key]); |
|
| 2134 | + } |
|
| 2135 | + update_option('tax_meta_' . $post_type . $term_id, $m); |
|
| 2136 | + } |
|
| 2137 | 2137 | } |
| 2138 | 2138 | |
| 2139 | 2139 | //update meta |
| 2140 | 2140 | if (!function_exists('update_tax_meta')) { |
| 2141 | - function update_tax_meta($term_id, $key, $value, $post_type = '') |
|
| 2142 | - { |
|
| 2141 | + function update_tax_meta($term_id, $key, $value, $post_type = '') |
|
| 2142 | + { |
|
| 2143 | 2143 | |
| 2144 | - if (empty($post_type) && isset($_REQUEST['taxonomy'])) { |
|
| 2145 | - $taxObject = get_taxonomy($_REQUEST['taxonomy']); |
|
| 2146 | - $post_type = $taxObject->object_type[0]; |
|
| 2147 | - } |
|
| 2144 | + if (empty($post_type) && isset($_REQUEST['taxonomy'])) { |
|
| 2145 | + $taxObject = get_taxonomy($_REQUEST['taxonomy']); |
|
| 2146 | + $post_type = $taxObject->object_type[0]; |
|
| 2147 | + } |
|
| 2148 | 2148 | |
| 2149 | - if($post_type=='post'){$post_type='';} |
|
| 2150 | - if($post_type){$post_type = $post_type.'_';} |
|
| 2149 | + if($post_type=='post'){$post_type='';} |
|
| 2150 | + if($post_type){$post_type = $post_type.'_';} |
|
| 2151 | 2151 | |
| 2152 | - $m = get_option('tax_meta_' . $post_type . $term_id); |
|
| 2152 | + $m = get_option('tax_meta_' . $post_type . $term_id); |
|
| 2153 | 2153 | |
| 2154 | - $m[$key] = $value; |
|
| 2155 | - update_option('tax_meta_' . $post_type . $term_id, $m); |
|
| 2154 | + $m[$key] = $value; |
|
| 2155 | + update_option('tax_meta_' . $post_type . $term_id, $m); |
|
| 2156 | 2156 | |
| 2157 | - /** This action is documented in geodirectory-functions/cat-meta-functions/Tax-meta-class.php */ |
|
| 2158 | - do_action('gd_tax_meta_updated', false, true, $term_id, $post_type); |
|
| 2159 | - } |
|
| 2157 | + /** This action is documented in geodirectory-functions/cat-meta-functions/Tax-meta-class.php */ |
|
| 2158 | + do_action('gd_tax_meta_updated', false, true, $term_id, $post_type); |
|
| 2159 | + } |
|
| 2160 | 2160 | } |
| 2161 | 2161 | \ No newline at end of file |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | $this->add_missed_values(); |
| 114 | 114 | if (isset($meta_box['use_with_theme'])) |
| 115 | 115 | if ($meta_box['use_with_theme'] === true) { |
| 116 | - $this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta'; |
|
| 116 | + $this->SelfPath = get_stylesheet_directory_uri().'/library/cat-meta'; |
|
| 117 | 117 | } elseif ($meta_box['use_with_theme'] === false) { |
| 118 | 118 | $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); |
| 119 | 119 | } else { |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | $li = "<li id='item_{$attachment_id}'>"; |
| 263 | 263 | $li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />"; |
| 264 | 264 | //$li .= "<a title='" . __( 'Delete this image' ) . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'>" . __( 'Delete' ) . "</a>"; |
| 265 | - $li .= "<a title='" . __('Remove this image', 'geodirectory') . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='" . $this->SelfPath . "/images/delete-16.png' alt='" . __('Remove', 'geodirectory') . "' /></a>"; |
|
| 265 | + $li .= "<a title='".__('Remove this image', 'geodirectory')."' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='".$this->SelfPath."/images/delete-16.png' alt='".__('Remove', 'geodirectory')."' /></a>"; |
|
| 266 | 266 | $li .= "<input type='hidden' name='{$id}[]' value='{$attachment_id}' />"; |
| 267 | 267 | $li .= "</li>"; |
| 268 | 268 | $html .= $li; |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | $attachment_id = isset($_GET['attachment_id']) ? intval($_GET['attachment_id']) : 0; |
| 336 | 336 | $ok = false; |
| 337 | 337 | if (strpos($field_id, '[') === false) { |
| 338 | - check_admin_referer("at-delete-mupload_" . urldecode($field_id)); |
|
| 338 | + check_admin_referer("at-delete-mupload_".urldecode($field_id)); |
|
| 339 | 339 | if ($term_id > 0) |
| 340 | 340 | $this->delete_tax_meta($term_id, $field_id); |
| 341 | 341 | //$ok = wp_delete_attachment( $attachment_id ); |
@@ -423,8 +423,8 @@ discard block |
||
| 423 | 423 | |
| 424 | 424 | if ($this->has_field('date') && $this->is_edit_page()) { |
| 425 | 425 | // Enqueu JQuery UI, use proper version. |
| 426 | - wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css'); |
|
| 427 | - wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery')); |
|
| 426 | + wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/'.$this->get_jqueryui_ver().'/themes/base/jquery-ui.css'); |
|
| 427 | + wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/'.$this->get_jqueryui_ver().'/jquery-ui.min.js', array('jquery')); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | } |
@@ -441,8 +441,8 @@ discard block |
||
| 441 | 441 | if ($this->has_field('time') && $this->is_edit_page()) { |
| 442 | 442 | |
| 443 | 443 | // Enqueu JQuery UI, use proper version. |
| 444 | - wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css', array(), false, true); |
|
| 445 | - wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'), false, true); |
|
| 444 | + wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/'.$this->get_jqueryui_ver().'/themes/base/jquery-ui.css', array(), false, true); |
|
| 445 | + wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/'.$this->get_jqueryui_ver().'/jquery-ui.min.js', array('jquery'), false, true); |
|
| 446 | 446 | wp_enqueue_script('at-timepicker', 'https://github.com/trentrichardson/jQuery-Timepicker-Addon/raw/master/jquery-ui-timepicker-addon.js', array('tmc-jquery-ui'), false, true); |
| 447 | 447 | |
| 448 | 448 | } |
@@ -462,13 +462,13 @@ discard block |
||
| 462 | 462 | if (!empty($this->_meta_box['pages'])) { |
| 463 | 463 | foreach ($this->_meta_box['pages'] as $page) { |
| 464 | 464 | //add fields to edit form |
| 465 | - add_action($page . '_edit_form_fields', array(&$this, 'show_edit_form')); |
|
| 465 | + add_action($page.'_edit_form_fields', array(&$this, 'show_edit_form')); |
|
| 466 | 466 | //add fields to add new form |
| 467 | - add_action($page . '_add_form_fields', array(&$this, 'show_new_form')); |
|
| 467 | + add_action($page.'_add_form_fields', array(&$this, 'show_new_form')); |
|
| 468 | 468 | // this saves the edit fields |
| 469 | - add_action('edited_' . $page, array(&$this, 'save'), 10, 2); |
|
| 469 | + add_action('edited_'.$page, array(&$this, 'save'), 10, 2); |
|
| 470 | 470 | // this saves the add fields |
| 471 | - add_action('created_' . $page, array(&$this, 'save'), 10, 2); |
|
| 471 | + add_action('created_'.$page, array(&$this, 'save'), 10, 2); |
|
| 472 | 472 | } |
| 473 | 473 | } |
| 474 | 474 | |
@@ -517,13 +517,13 @@ discard block |
||
| 517 | 517 | $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta); |
| 518 | 518 | |
| 519 | 519 | if ($field['validate_func']) { |
| 520 | - echo '<tr class="form-field form-required ' . $field['style'] . '">'; |
|
| 520 | + echo '<tr class="form-field form-required '.$field['style'].'">'; |
|
| 521 | 521 | } else { |
| 522 | - echo '<tr class="form-field ' . $field['style'] . '">'; |
|
| 522 | + echo '<tr class="form-field '.$field['style'].'">'; |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | // Call Separated methods for displaying each type of field. |
| 526 | - call_user_func(array(&$this, 'show_field_' . $field['type']), $field, $meta); |
|
| 526 | + call_user_func(array(&$this, 'show_field_'.$field['type']), $field, $meta); |
|
| 527 | 527 | echo '</tr>'; |
| 528 | 528 | } |
| 529 | 529 | echo '</table>'; |
@@ -550,14 +550,14 @@ discard block |
||
| 550 | 550 | foreach ($meta as $me) { |
| 551 | 551 | //for labling toggles |
| 552 | 552 | $mmm = $me[$field['fields'][0]['id']]; |
| 553 | - echo '<div class="at-repater-block">' . $mmm . '<br/><table class="repeater-table" style="display: none;">'; |
|
| 553 | + echo '<div class="at-repater-block">'.$mmm.'<br/><table class="repeater-table" style="display: none;">'; |
|
| 554 | 554 | if ($field['inline']) { |
| 555 | 555 | echo '<tr class="at-inline" VALIGN="top">'; |
| 556 | 556 | } |
| 557 | 557 | foreach ($field['fields'] as $f) { |
| 558 | 558 | //reset var $id for repeater |
| 559 | 559 | $id = ''; |
| 560 | - $id = $field['id'] . '[' . $c . '][' . $f['id'] . ']'; |
|
| 560 | + $id = $field['id'].'['.$c.']['.$f['id'].']'; |
|
| 561 | 561 | $m = $me[$f['id']]; |
| 562 | 562 | $m = ($m !== '') ? $m : $f['std']; |
| 563 | 563 | if ('image' != $f['type'] && $f['type'] != 'repeater') |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | if (!$field['inline']) { |
| 568 | 568 | echo '<tr>'; |
| 569 | 569 | } |
| 570 | - call_user_func(array(&$this, 'show_field_' . $f['type']), $f, $m); |
|
| 570 | + call_user_func(array(&$this, 'show_field_'.$f['type']), $f, $m); |
|
| 571 | 571 | if (!$field['inline']) { |
| 572 | 572 | echo '</tr>'; |
| 573 | 573 | } |
@@ -578,18 +578,18 @@ discard block |
||
| 578 | 578 | echo '</table> |
| 579 | 579 | <span class="at-re-toggle"><img src="'; |
| 580 | 580 | if ($this->_Local_images) { |
| 581 | - echo $plugin_path . '/images/edit.png'; |
|
| 581 | + echo $plugin_path.'/images/edit.png'; |
|
| 582 | 582 | } else { |
| 583 | 583 | echo 'http://i.imgur.com/ka0E2.png'; |
| 584 | 584 | } |
| 585 | 585 | echo '" alt="Edit" title="Edit"/></span> |
| 586 | 586 | <img src="'; |
| 587 | 587 | if ($this->_Local_images) { |
| 588 | - echo $plugin_path . '/images/remove.png'; |
|
| 588 | + echo $plugin_path.'/images/remove.png'; |
|
| 589 | 589 | } else { |
| 590 | 590 | echo 'http://i.imgur.com/g8Duj.png'; |
| 591 | 591 | } |
| 592 | - echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>'; |
|
| 592 | + echo '" alt="'.__('Remove', 'geodirectory').'" title="'.__('Remove', 'geodirectory').'" id="remove-'.$field['id'].'"></div>'; |
|
| 593 | 593 | $c = $c + 1; |
| 594 | 594 | |
| 595 | 595 | } |
@@ -598,11 +598,11 @@ discard block |
||
| 598 | 598 | |
| 599 | 599 | echo '<img src="'; |
| 600 | 600 | if ($this->_Local_images) { |
| 601 | - echo $plugin_path . '/images/add.png'; |
|
| 601 | + echo $plugin_path.'/images/add.png'; |
|
| 602 | 602 | } else { |
| 603 | 603 | echo 'http://i.imgur.com/w5Tuc.png'; |
| 604 | 604 | } |
| 605 | - echo '" alt="' . __('Add', 'geodirectory') . '" title="' . __('Add', 'geodirectory') . '" id="add-' . $field['id'] . '"><br/></div>'; |
|
| 605 | + echo '" alt="'.__('Add', 'geodirectory').'" title="'.__('Add', 'geodirectory').'" id="add-'.$field['id'].'"><br/></div>'; |
|
| 606 | 606 | |
| 607 | 607 | //create all fields once more for js function and catch with object buffer |
| 608 | 608 | ob_start(); |
@@ -613,12 +613,12 @@ discard block |
||
| 613 | 613 | foreach ($field['fields'] as $f) { |
| 614 | 614 | //reset var $id for repeater |
| 615 | 615 | $id = ''; |
| 616 | - $id = $field['id'] . '[CurrentCounter][' . $f['id'] . ']'; |
|
| 616 | + $id = $field['id'].'[CurrentCounter]['.$f['id'].']'; |
|
| 617 | 617 | $f['id'] = $id; |
| 618 | 618 | if (!$field['inline']) { |
| 619 | 619 | echo '<tr>'; |
| 620 | 620 | } |
| 621 | - call_user_func(array(&$this, 'show_field_' . $f['type']), $f, ''); |
|
| 621 | + call_user_func(array(&$this, 'show_field_'.$f['type']), $f, ''); |
|
| 622 | 622 | if (!$field['inline']) { |
| 623 | 623 | echo '</tr>'; |
| 624 | 624 | } |
@@ -628,24 +628,24 @@ discard block |
||
| 628 | 628 | } |
| 629 | 629 | echo '</table><img src="'; |
| 630 | 630 | if ($this->_Local_images) { |
| 631 | - echo $plugin_path . '/images/remove.png'; |
|
| 631 | + echo $plugin_path.'/images/remove.png'; |
|
| 632 | 632 | } else { |
| 633 | 633 | echo 'http://i.imgur.com/g8Duj.png'; |
| 634 | 634 | } |
| 635 | - echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>'; |
|
| 636 | - $counter = 'countadd_' . $field['id']; |
|
| 635 | + echo '" alt="'.__('Remove', 'geodirectory').'" title="'.__('Remove', 'geodirectory').'" id="remove-'.$field['id'].'"></div>'; |
|
| 636 | + $counter = 'countadd_'.$field['id']; |
|
| 637 | 637 | $js_code = ob_get_clean(); |
| 638 | 638 | $js_code = str_replace("'", "\"", $js_code); |
| 639 | - $js_code = str_replace("CurrentCounter", "' + " . $counter . " + '", $js_code); |
|
| 639 | + $js_code = str_replace("CurrentCounter", "' + ".$counter." + '", $js_code); |
|
| 640 | 640 | echo '<script> |
| 641 | 641 | jQuery(document).ready(function() { |
| 642 | - var ' . $counter . ' = ' . $c . '; |
|
| 643 | - jQuery("#add-' . $field['id'] . '").live(\'click\', function() { |
|
| 644 | - ' . $counter . ' = ' . $counter . ' + 1; |
|
| 645 | - jQuery(this).before(\'' . $js_code . '\'); |
|
| 642 | + var ' . $counter.' = '.$c.'; |
|
| 643 | + jQuery("#add-' . $field['id'].'").live(\'click\', function() { |
|
| 644 | + ' . $counter.' = '.$counter.' + 1; |
|
| 645 | + jQuery(this).before(\'' . $js_code.'\'); |
|
| 646 | 646 | update_repeater_fields(); |
| 647 | 647 | }); |
| 648 | - jQuery("#remove-' . $field['id'] . '").live(\'click\', function() { |
|
| 648 | + jQuery("#remove-' . $field['id'].'").live(\'click\', function() { |
|
| 649 | 649 | jQuery(this).parent().remove(); |
| 650 | 650 | }); |
| 651 | 651 | }); |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | public function show_field_paragraph($field) |
| 773 | 773 | { |
| 774 | 774 | //$this->show_field_begin( $field, $meta ); |
| 775 | - echo '<p>' . $field['value'] . '</p>'; |
|
| 775 | + echo '<p>'.$field['value'].'</p>'; |
|
| 776 | 776 | //$this->show_field_end( $field, $meta ); |
| 777 | 777 | } |
| 778 | 778 | |
@@ -803,12 +803,12 @@ discard block |
||
| 803 | 803 | { |
| 804 | 804 | |
| 805 | 805 | if (!is_array($meta)) |
| 806 | - $meta = (array)$meta; |
|
| 806 | + $meta = (array) $meta; |
|
| 807 | 807 | |
| 808 | 808 | $this->show_field_begin($field, $meta); |
| 809 | - echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">"; |
|
| 809 | + echo "<select class='at-select' name='{$field['id']}".($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'").">"; |
|
| 810 | 810 | foreach ($field['options'] as $key => $value) { |
| 811 | - echo "<option value='{$key}'" . selected(in_array($key, $meta), true, false) . ">{$value}</option>"; |
|
| 811 | + echo "<option value='{$key}'".selected(in_array($key, $meta), true, false).">{$value}</option>"; |
|
| 812 | 812 | } |
| 813 | 813 | echo "</select>"; |
| 814 | 814 | $this->show_field_end($field, $meta); |
@@ -827,11 +827,11 @@ discard block |
||
| 827 | 827 | { |
| 828 | 828 | |
| 829 | 829 | if (!is_array($meta)) |
| 830 | - $meta = (array)$meta; |
|
| 830 | + $meta = (array) $meta; |
|
| 831 | 831 | |
| 832 | 832 | $this->show_field_begin($field, $meta); |
| 833 | 833 | foreach ($field['options'] as $key => $value) { |
| 834 | - echo "<input type='radio' class='at-radio' name='{$field['id']}' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> <span class='at-radio-label'>{$value}</span>"; |
|
| 834 | + echo "<input type='radio' class='at-radio' name='{$field['id']}' value='{$key}'".checked(in_array($key, $meta), true, false)." /> <span class='at-radio-label'>{$value}</span>"; |
|
| 835 | 835 | } |
| 836 | 836 | $this->show_field_end($field, $meta); |
| 837 | 837 | } |
@@ -848,7 +848,7 @@ discard block |
||
| 848 | 848 | { |
| 849 | 849 | |
| 850 | 850 | $this->show_field_begin($field, $meta); |
| 851 | - echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'" . checked(!empty($meta), true, false) . " /> {$field['desc']}"; |
|
| 851 | + echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'".checked(!empty($meta), true, false)." /> {$field['desc']}"; |
|
| 852 | 852 | $this->show_field_end($field, $meta); |
| 853 | 853 | } |
| 854 | 854 | |
@@ -890,18 +890,18 @@ discard block |
||
| 890 | 890 | global $post; |
| 891 | 891 | |
| 892 | 892 | if (!is_array($meta)) |
| 893 | - $meta = (array)$meta; |
|
| 893 | + $meta = (array) $meta; |
|
| 894 | 894 | |
| 895 | 895 | $this->show_field_begin($field, $meta); |
| 896 | 896 | echo "{$field['desc']}<br />"; |
| 897 | 897 | |
| 898 | 898 | if (!empty($meta)) { |
| 899 | 899 | $nonce = wp_create_nonce('at_ajax_delete'); |
| 900 | - echo '<div style="margin-bottom: 10px"><strong>' . __('Uploaded files', 'geodirectory') . '</strong></div>'; |
|
| 900 | + echo '<div style="margin-bottom: 10px"><strong>'.__('Uploaded files', 'geodirectory').'</strong></div>'; |
|
| 901 | 901 | echo '<ol class="at-upload">'; |
| 902 | 902 | foreach ($meta as $att) { |
| 903 | 903 | // if (wp_attachment_is_image($att)) continue; // what's image uploader for? |
| 904 | - echo "<li>" . wp_get_attachment_link($att, '', false, false, ' ') . " (<a class='at-delete-file' href='#' rel='{$nonce}|{$post->ID}|{$field['id']}|{$att}'>" . __('Remove', 'geodirectory') . "</a>)</li>"; |
|
| 904 | + echo "<li>".wp_get_attachment_link($att, '', false, false, ' ')." (<a class='at-delete-file' href='#' rel='{$nonce}|{$post->ID}|{$field['id']}|{$att}'>".__('Remove', 'geodirectory')."</a>)</li>"; |
|
| 905 | 905 | } |
| 906 | 906 | echo '</ol>'; |
| 907 | 907 | } |
@@ -909,13 +909,13 @@ discard block |
||
| 909 | 909 | // show form upload |
| 910 | 910 | |
| 911 | 911 | echo "<div class='at-file-upload-label'>"; |
| 912 | - echo "<strong>" . __('Upload new files', 'geodirectory') . "</strong>"; |
|
| 912 | + echo "<strong>".__('Upload new files', 'geodirectory')."</strong>"; |
|
| 913 | 913 | echo "</div>"; |
| 914 | 914 | echo "<div class='new-files'>"; |
| 915 | 915 | echo "<div class='file-input'>"; |
| 916 | 916 | echo "<input type='file' name='{$field['id']}[]' />"; |
| 917 | 917 | echo "</div><!-- End .file-input -->"; |
| 918 | - echo "<a class='at-add-file button' href='#'>" . __('Add more files', 'geodirectory') . "</a>"; |
|
| 918 | + echo "<a class='at-add-file button' href='#'>".__('Add more files', 'geodirectory')."</a>"; |
|
| 919 | 919 | echo "</div><!-- End .new-files -->"; |
| 920 | 920 | echo "</td>"; |
| 921 | 921 | $this->show_field_end($field, $meta); |
@@ -932,7 +932,7 @@ discard block |
||
| 932 | 932 | public function show_field_image($field, $meta) |
| 933 | 933 | { |
| 934 | 934 | $this->show_field_begin($field, $meta); |
| 935 | - $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false); |
|
| 935 | + $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_".$field['id'], false, false); |
|
| 936 | 936 | if (is_array($meta)) { |
| 937 | 937 | if (isset($meta[0]) && is_array($meta[0])) |
| 938 | 938 | $meta = $meta[0]; |
@@ -958,19 +958,19 @@ discard block |
||
| 958 | 958 | } |
| 959 | 959 | $sub_dir = str_replace($uploads['baseurl'], '', $sub_dir); |
| 960 | 960 | |
| 961 | - $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 961 | + $uploads_url = $uploads_baseurl.$sub_dir; |
|
| 962 | 962 | |
| 963 | - $meta['src'] = $uploads_url . '/' . $file_name; |
|
| 963 | + $meta['src'] = $uploads_url.'/'.$file_name; |
|
| 964 | 964 | |
| 965 | - $html .= "<span class='mupload_img_holder'><img src='" . $meta['src'] . "' style='max-height: 150px;max-width: 150px;' /></span>"; |
|
| 966 | - $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='" . $meta['id'] . "' />"; |
|
| 967 | - $html .= "<input type='hidden' class='" . $field['id'] . "[src]' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='" . $meta['src'] . "' />"; |
|
| 968 | - $html .= "<input class='at-delete_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Remove Image', 'geodirectory') . "' />"; |
|
| 965 | + $html .= "<span class='mupload_img_holder'><img src='".$meta['src']."' style='max-height: 150px;max-width: 150px;' /></span>"; |
|
| 966 | + $html .= "<input type='hidden' name='".$field['id']."[id]' id='".$field['id']."[id]' value='".$meta['id']."' />"; |
|
| 967 | + $html .= "<input type='hidden' class='".$field['id']."[src]' name='".$field['id']."[src]' id='".$field['id']."[src]' value='".$meta['src']."' />"; |
|
| 968 | + $html .= "<input class='at-delete_image_button' type='button' rel='".$field['id']."' value='".__('Remove Image', 'geodirectory')."' />"; |
|
| 969 | 969 | } else { |
| 970 | 970 | $html .= "<span class='mupload_img_holder'></span>"; |
| 971 | - $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='' />"; |
|
| 972 | - $html .= "<input class='" . $field['id'] . "[src]' style='position:absolute;left:-500px;width:50px;' type='text' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='' />"; |
|
| 973 | - $html .= "<input class='at-upload_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Upload Image', 'geodirectory') . "' />"; |
|
| 971 | + $html .= "<input type='hidden' name='".$field['id']."[id]' id='".$field['id']."[id]' value='' />"; |
|
| 972 | + $html .= "<input class='".$field['id']."[src]' style='position:absolute;left:-500px;width:50px;' type='text' name='".$field['id']."[src]' id='".$field['id']."[src]' value='' />"; |
|
| 973 | + $html .= "<input class='at-upload_image_button' type='button' rel='".$field['id']."' value='".__('Upload Image', 'geodirectory')."' />"; |
|
| 974 | 974 | } |
| 975 | 975 | echo $html; |
| 976 | 976 | $this->show_field_end($field, $meta); |
@@ -994,7 +994,7 @@ discard block |
||
| 994 | 994 | |
| 995 | 995 | echo "<input class='at-color' type='text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='8' />"; |
| 996 | 996 | // echo "<a href='#' class='at-color-select button' rel='{$field['id']}'>" . __( 'Select a color' ) . "</a>"; |
| 997 | - echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='" . __('Select a color', 'geodirectory') . "'/>"; |
|
| 997 | + echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='".__('Select a color', 'geodirectory')."'/>"; |
|
| 998 | 998 | echo "<div style='display:none' class='at-color-picker' rel='{$field['id']}'></div>"; |
| 999 | 999 | $this->show_field_end($field, $meta); |
| 1000 | 1000 | |
@@ -1012,14 +1012,14 @@ discard block |
||
| 1012 | 1012 | { |
| 1013 | 1013 | |
| 1014 | 1014 | if (!is_array($meta)) |
| 1015 | - $meta = (array)$meta; |
|
| 1015 | + $meta = (array) $meta; |
|
| 1016 | 1016 | |
| 1017 | 1017 | $this->show_field_begin($field, $meta); |
| 1018 | 1018 | |
| 1019 | 1019 | $html = array(); |
| 1020 | 1020 | |
| 1021 | 1021 | foreach ($field['options'] as $key => $value) { |
| 1022 | - $html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> {$value}"; |
|
| 1022 | + $html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'".checked(in_array($key, $meta), true, false)." /> {$value}"; |
|
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | echo implode('<br />', $html); |
@@ -1072,7 +1072,7 @@ discard block |
||
| 1072 | 1072 | { |
| 1073 | 1073 | global $post; |
| 1074 | 1074 | |
| 1075 | - if (!is_array($meta)) $meta = (array)$meta; |
|
| 1075 | + if (!is_array($meta)) $meta = (array) $meta; |
|
| 1076 | 1076 | $this->show_field_begin($field, $meta); |
| 1077 | 1077 | $options = $field['options']; |
| 1078 | 1078 | $posts = get_posts($options['args']); |
@@ -1080,13 +1080,13 @@ discard block |
||
| 1080 | 1080 | // checkbox_list |
| 1081 | 1081 | if ('checkbox_list' == $options['type']) { |
| 1082 | 1082 | foreach ($posts as $p) { |
| 1083 | - echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'" . checked(in_array($p->ID, $meta), true, false) . " /> $p->post_title<br/>"; |
|
| 1083 | + echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'".checked(in_array($p->ID, $meta), true, false)." /> $p->post_title<br/>"; |
|
| 1084 | 1084 | } |
| 1085 | 1085 | } // select |
| 1086 | 1086 | else { |
| 1087 | - echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">"; |
|
| 1087 | + echo "<select name='{$field['id']}".($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'").">"; |
|
| 1088 | 1088 | foreach ($posts as $p) { |
| 1089 | - echo "<option value='$p->ID'" . selected(in_array($p->ID, $meta), true, false) . ">$p->post_title</option>"; |
|
| 1089 | + echo "<option value='$p->ID'".selected(in_array($p->ID, $meta), true, false).">$p->post_title</option>"; |
|
| 1090 | 1090 | } |
| 1091 | 1091 | echo "</select>"; |
| 1092 | 1092 | } |
@@ -1110,7 +1110,7 @@ discard block |
||
| 1110 | 1110 | { |
| 1111 | 1111 | global $post; |
| 1112 | 1112 | |
| 1113 | - if (!is_array($meta)) $meta = (array)$meta; |
|
| 1113 | + if (!is_array($meta)) $meta = (array) $meta; |
|
| 1114 | 1114 | $this->show_field_begin($field, $meta); |
| 1115 | 1115 | $options = $field['options']; |
| 1116 | 1116 | $terms = get_terms($options['taxonomy'], $options['args']); |
@@ -1118,13 +1118,13 @@ discard block |
||
| 1118 | 1118 | // checkbox_list |
| 1119 | 1119 | if ('checkbox_list' == $options['type']) { |
| 1120 | 1120 | foreach ($terms as $term) { |
| 1121 | - echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'" . checked(in_array($term->slug, $meta), true, false) . " /> $term->name<br/>"; |
|
| 1121 | + echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'".checked(in_array($term->slug, $meta), true, false)." /> $term->name<br/>"; |
|
| 1122 | 1122 | } |
| 1123 | 1123 | } // select |
| 1124 | 1124 | else { |
| 1125 | - echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">"; |
|
| 1125 | + echo "<select name='{$field['id']}".($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'").">"; |
|
| 1126 | 1126 | foreach ($terms as $term) { |
| 1127 | - echo "<option value='$term->slug'" . selected(in_array($term->slug, $meta), true, false) . ">$term->name</option>"; |
|
| 1127 | + echo "<option value='$term->slug'".selected(in_array($term->slug, $meta), true, false).">$term->name</option>"; |
|
| 1128 | 1128 | } |
| 1129 | 1129 | echo "</select>"; |
| 1130 | 1130 | } |
@@ -1180,7 +1180,7 @@ discard block |
||
| 1180 | 1180 | |
| 1181 | 1181 | //$old_filename = $upload_dir['path'].'/'.$old_filename; |
| 1182 | 1182 | |
| 1183 | - $new_filename = $upload_dir['path'] . '/' . 'cat_icon_' . $term_id . '.png'; |
|
| 1183 | + $new_filename = $upload_dir['path'].'/'.'cat_icon_'.$term_id.'.png'; |
|
| 1184 | 1184 | |
| 1185 | 1185 | /*rename($old_filename, $new_filename); |
| 1186 | 1186 | |
@@ -1222,9 +1222,9 @@ discard block |
||
| 1222 | 1222 | if ($type != "paragraph") { |
| 1223 | 1223 | |
| 1224 | 1224 | // Call defined method to save meta value, if there's no methods, call common one. |
| 1225 | - $save_func = 'save_field_' . $type; |
|
| 1225 | + $save_func = 'save_field_'.$type; |
|
| 1226 | 1226 | if (method_exists($this, $save_func)) { |
| 1227 | - call_user_func(array(&$this, 'save_field_' . $type), $term_id, $field, $old, $new); |
|
| 1227 | + call_user_func(array(&$this, 'save_field_'.$type), $term_id, $field, $old, $new); |
|
| 1228 | 1228 | } else { |
| 1229 | 1229 | $this->save_field($term_id, $field, $old, $new); |
| 1230 | 1230 | } |
@@ -1369,7 +1369,7 @@ discard block |
||
| 1369 | 1369 | if (!is_wp_error($id)) { |
| 1370 | 1370 | |
| 1371 | 1371 | wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); |
| 1372 | - add_post_meta($term_id, $name, $id, false); // save file's url in meta fields |
|
| 1372 | + add_post_meta($term_id, $name, $id, false); // save file's url in meta fields |
|
| 1373 | 1373 | |
| 1374 | 1374 | } // End if |
| 1375 | 1375 | |
@@ -1414,7 +1414,7 @@ discard block |
||
| 1414 | 1414 | if (!is_wp_error($id)) { |
| 1415 | 1415 | |
| 1416 | 1416 | wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); |
| 1417 | - return $id; // return file's url in meta fields |
|
| 1417 | + return $id; // return file's url in meta fields |
|
| 1418 | 1418 | } // End if |
| 1419 | 1419 | } // End foreach |
| 1420 | 1420 | } |
@@ -1429,9 +1429,9 @@ discard block |
||
| 1429 | 1429 | { |
| 1430 | 1430 | |
| 1431 | 1431 | // Default values for meta box |
| 1432 | - $this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array)$this->_meta_box); |
|
| 1432 | + $this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array) $this->_meta_box); |
|
| 1433 | 1433 | |
| 1434 | - if(is_array($this->_fields)) { |
|
| 1434 | + if (is_array($this->_fields)) { |
|
| 1435 | 1435 | // Default values for fields |
| 1436 | 1436 | foreach ($this->_fields as &$field) { |
| 1437 | 1437 | $multiple = in_array($field['type'], array('checkbox_list', 'file', 'image')); |
@@ -1451,7 +1451,7 @@ discard block |
||
| 1451 | 1451 | */ |
| 1452 | 1452 | public function has_field($type) |
| 1453 | 1453 | { |
| 1454 | - if(is_array($this->_fields)) { |
|
| 1454 | + if (is_array($this->_fields)) { |
|
| 1455 | 1455 | foreach ($this->_fields as $field) { |
| 1456 | 1456 | if ($type == $field['type']) |
| 1457 | 1457 | return true; |
@@ -2019,12 +2019,12 @@ discard block |
||
| 2019 | 2019 | $post_type = $taxObject->object_type[0]; |
| 2020 | 2020 | } |
| 2021 | 2021 | |
| 2022 | - if($post_type=='post'){$post_type='';} |
|
| 2023 | - if($post_type){$post_type = $post_type.'_';} |
|
| 2022 | + if ($post_type == 'post') {$post_type = ''; } |
|
| 2023 | + if ($post_type) {$post_type = $post_type.'_'; } |
|
| 2024 | 2024 | |
| 2025 | 2025 | $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; |
| 2026 | 2026 | |
| 2027 | - $m = get_option('tax_meta_' . $post_type . $t_id); |
|
| 2027 | + $m = get_option('tax_meta_'.$post_type.$t_id); |
|
| 2028 | 2028 | if (isset($m[$key])) { |
| 2029 | 2029 | return $m[$key]; |
| 2030 | 2030 | } else { |
@@ -2041,15 +2041,15 @@ discard block |
||
| 2041 | 2041 | $post_type = $taxObject->object_type[0]; |
| 2042 | 2042 | } |
| 2043 | 2043 | |
| 2044 | - if($post_type=='post'){$post_type='';} |
|
| 2045 | - if($post_type){$post_type = $post_type.'_';} |
|
| 2044 | + if ($post_type == 'post') {$post_type = ''; } |
|
| 2045 | + if ($post_type) {$post_type = $post_type.'_'; } |
|
| 2046 | 2046 | |
| 2047 | - $m = get_option('tax_meta_' . $post_type . $term_id); |
|
| 2047 | + $m = get_option('tax_meta_'.$post_type.$term_id); |
|
| 2048 | 2048 | |
| 2049 | 2049 | if (isset($m[$key])) { |
| 2050 | 2050 | unset($m[$key]); |
| 2051 | 2051 | } |
| 2052 | - update_option('tax_meta_' . $post_type . $term_id, $m); |
|
| 2052 | + update_option('tax_meta_'.$post_type.$term_id, $m); |
|
| 2053 | 2053 | } |
| 2054 | 2054 | |
| 2055 | 2055 | //update meta |
@@ -2061,13 +2061,13 @@ discard block |
||
| 2061 | 2061 | $post_type = $taxObject->object_type[0]; |
| 2062 | 2062 | } |
| 2063 | 2063 | |
| 2064 | - if($post_type=='post'){$post_type='';} |
|
| 2065 | - if($post_type){$post_type = $post_type.'_';} |
|
| 2064 | + if ($post_type == 'post') {$post_type = ''; } |
|
| 2065 | + if ($post_type) {$post_type = $post_type.'_'; } |
|
| 2066 | 2066 | |
| 2067 | - $m = get_option('tax_meta_' . $post_type . $term_id); |
|
| 2067 | + $m = get_option('tax_meta_'.$post_type.$term_id); |
|
| 2068 | 2068 | |
| 2069 | 2069 | $m[$key] = $value; |
| 2070 | - update_option('tax_meta_' . $post_type . $term_id, $m); |
|
| 2070 | + update_option('tax_meta_'.$post_type.$term_id, $m); |
|
| 2071 | 2071 | |
| 2072 | 2072 | /** |
| 2073 | 2073 | * Called after the tax meta is updated. |
@@ -2102,12 +2102,12 @@ discard block |
||
| 2102 | 2102 | $post_type = $taxObject->object_type[0]; |
| 2103 | 2103 | } |
| 2104 | 2104 | |
| 2105 | - if($post_type=='post'){$post_type='';} |
|
| 2106 | - if($post_type){$post_type = $post_type.'_';} |
|
| 2105 | + if ($post_type == 'post') {$post_type = ''; } |
|
| 2106 | + if ($post_type) {$post_type = $post_type.'_'; } |
|
| 2107 | 2107 | |
| 2108 | 2108 | $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; |
| 2109 | 2109 | |
| 2110 | - $m = get_option('tax_meta_' . $post_type . $t_id); |
|
| 2110 | + $m = get_option('tax_meta_'.$post_type.$t_id); |
|
| 2111 | 2111 | if (isset($m[$key])) { |
| 2112 | 2112 | return $m[$key]; |
| 2113 | 2113 | } else { |
@@ -2124,15 +2124,15 @@ discard block |
||
| 2124 | 2124 | $taxObject = get_taxonomy($_REQUEST['taxonomy']); |
| 2125 | 2125 | $post_type = $taxObject->object_type[0]; |
| 2126 | 2126 | |
| 2127 | - if($post_type=='post'){$post_type='';} |
|
| 2128 | - if($post_type){$post_type = $post_type.'_';} |
|
| 2127 | + if ($post_type == 'post') {$post_type = ''; } |
|
| 2128 | + if ($post_type) {$post_type = $post_type.'_'; } |
|
| 2129 | 2129 | |
| 2130 | - $m = get_option('tax_meta_' . $post_type . $term_id); |
|
| 2130 | + $m = get_option('tax_meta_'.$post_type.$term_id); |
|
| 2131 | 2131 | |
| 2132 | 2132 | if (isset($m[$key])) { |
| 2133 | 2133 | unset($m[$key]); |
| 2134 | 2134 | } |
| 2135 | - update_option('tax_meta_' . $post_type . $term_id, $m); |
|
| 2135 | + update_option('tax_meta_'.$post_type.$term_id, $m); |
|
| 2136 | 2136 | } |
| 2137 | 2137 | } |
| 2138 | 2138 | |
@@ -2146,13 +2146,13 @@ discard block |
||
| 2146 | 2146 | $post_type = $taxObject->object_type[0]; |
| 2147 | 2147 | } |
| 2148 | 2148 | |
| 2149 | - if($post_type=='post'){$post_type='';} |
|
| 2150 | - if($post_type){$post_type = $post_type.'_';} |
|
| 2149 | + if ($post_type == 'post') {$post_type = ''; } |
|
| 2150 | + if ($post_type) {$post_type = $post_type.'_'; } |
|
| 2151 | 2151 | |
| 2152 | - $m = get_option('tax_meta_' . $post_type . $term_id); |
|
| 2152 | + $m = get_option('tax_meta_'.$post_type.$term_id); |
|
| 2153 | 2153 | |
| 2154 | 2154 | $m[$key] = $value; |
| 2155 | - update_option('tax_meta_' . $post_type . $term_id, $m); |
|
| 2155 | + update_option('tax_meta_'.$post_type.$term_id, $m); |
|
| 2156 | 2156 | |
| 2157 | 2157 | /** This action is documented in geodirectory-functions/cat-meta-functions/Tax-meta-class.php */ |
| 2158 | 2158 | do_action('gd_tax_meta_updated', false, true, $term_id, $post_type); |
@@ -102,8 +102,9 @@ discard block |
||
| 102 | 102 | { |
| 103 | 103 | |
| 104 | 104 | // If we are not in admin area exit. |
| 105 | - if (!is_admin()) |
|
| 106 | - return; |
|
| 105 | + if (!is_admin()) { |
|
| 106 | + return; |
|
| 107 | + } |
|
| 107 | 108 | |
| 108 | 109 | // Assign meta box values to local variables and add it's missed values. |
| 109 | 110 | $this->_meta_box = $meta_box; |
@@ -111,15 +112,15 @@ discard block |
||
| 111 | 112 | $this->_fields = &$this->_meta_box['fields']; |
| 112 | 113 | $this->_Local_images = (isset($meta_box['local_images'])) ? true : false; |
| 113 | 114 | $this->add_missed_values(); |
| 114 | - if (isset($meta_box['use_with_theme'])) |
|
| 115 | - if ($meta_box['use_with_theme'] === true) { |
|
| 115 | + if (isset($meta_box['use_with_theme'])) { |
|
| 116 | + if ($meta_box['use_with_theme'] === true) { |
|
| 116 | 117 | $this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta'; |
| 118 | + } |
|
| 117 | 119 | } elseif ($meta_box['use_with_theme'] === false) { |
| 118 | 120 | $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); |
| 119 | 121 | } else { |
| 120 | 122 | $this->SelfPath = $meta_box['use_with_theme']; |
| 121 | - } |
|
| 122 | - else { |
|
| 123 | + } else { |
|
| 123 | 124 | $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); |
| 124 | 125 | } |
| 125 | 126 | |
@@ -190,8 +191,9 @@ discard block |
||
| 190 | 191 | { |
| 191 | 192 | |
| 192 | 193 | // Check if the field is an image or file. If not, return. |
| 193 | - if (!$this->has_field('image') && !$this->has_field('file')) |
|
| 194 | - return; |
|
| 194 | + if (!$this->has_field('image') && !$this->has_field('file')) { |
|
| 195 | + return; |
|
| 196 | + } |
|
| 195 | 197 | |
| 196 | 198 | |
| 197 | 199 | add_action('wp_enqueue_scripts', array(&$this, 'enqueue_tax_meta_scripts'), 100); |
@@ -235,8 +237,9 @@ discard block |
||
| 235 | 237 | { |
| 236 | 238 | |
| 237 | 239 | // If post variables are empty, return. |
| 238 | - if (!isset($_POST['at-insert']) || empty($_POST['attachments'])) |
|
| 239 | - return; |
|
| 240 | + if (!isset($_POST['at-insert']) || empty($_POST['attachments'])) { |
|
| 241 | + return; |
|
| 242 | + } |
|
| 240 | 243 | |
| 241 | 244 | // Security Check |
| 242 | 245 | check_admin_referer('media-form'); |
@@ -256,8 +259,9 @@ discard block |
||
| 256 | 259 | $attachment = stripslashes_deep($attachment); |
| 257 | 260 | |
| 258 | 261 | // If not selected or url is empty, continue in loop. |
| 259 | - if (empty($attachment['selected']) || empty($attachment['url'])) |
|
| 260 | - continue; |
|
| 262 | + if (empty($attachment['selected']) || empty($attachment['url'])) { |
|
| 263 | + continue; |
|
| 264 | + } |
|
| 261 | 265 | |
| 262 | 266 | $li = "<li id='item_{$attachment_id}'>"; |
| 263 | 267 | $li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />"; |
@@ -308,13 +312,15 @@ discard block |
||
| 308 | 312 | |
| 309 | 313 | |
| 310 | 314 | // If data is not set, die. |
| 311 | - if (!isset($_POST['data'])) |
|
| 312 | - die(); |
|
| 315 | + if (!isset($_POST['data'])) { |
|
| 316 | + die(); |
|
| 317 | + } |
|
| 313 | 318 | |
| 314 | 319 | list($nonce, $term_id, $key, $attach_id) = explode('|', $_POST['data']); |
| 315 | 320 | |
| 316 | - if (!wp_verify_nonce($nonce, 'at_ajax_delete')) |
|
| 317 | - die('1'); |
|
| 321 | + if (!wp_verify_nonce($nonce, 'at_ajax_delete')) { |
|
| 322 | + die('1'); |
|
| 323 | + } |
|
| 318 | 324 | |
| 319 | 325 | $this->delete_tax_meta($term_id, $key, $attach_id); |
| 320 | 326 | |
@@ -336,8 +342,9 @@ discard block |
||
| 336 | 342 | $ok = false; |
| 337 | 343 | if (strpos($field_id, '[') === false) { |
| 338 | 344 | check_admin_referer("at-delete-mupload_" . urldecode($field_id)); |
| 339 | - if ($term_id > 0) |
|
| 340 | - $this->delete_tax_meta($term_id, $field_id); |
|
| 345 | + if ($term_id > 0) { |
|
| 346 | + $this->delete_tax_meta($term_id, $field_id); |
|
| 347 | + } |
|
| 341 | 348 | //$ok = wp_delete_attachment( $attachment_id ); |
| 342 | 349 | $ok = 1; |
| 343 | 350 | } else { |
@@ -349,8 +356,9 @@ discard block |
||
| 349 | 356 | $saved = $this->get_tax_meta($term_id, $f[0], true); |
| 350 | 357 | if (isset($saved[$f[1]][$f[2]])) { |
| 351 | 358 | unset($saved[$f[1]][$f[2]]); |
| 352 | - if ($term_id > 0) |
|
| 353 | - update_post_meta($term_id, $f[0], $saved); |
|
| 359 | + if ($term_id > 0) { |
|
| 360 | + update_post_meta($term_id, $f[0], $saved); |
|
| 361 | + } |
|
| 354 | 362 | //$ok = wp_delete_attachment( $attachment_id ); |
| 355 | 363 | $ok = 1; |
| 356 | 364 | } |
@@ -375,13 +383,15 @@ discard block |
||
| 375 | 383 | public function reorder_images() |
| 376 | 384 | { |
| 377 | 385 | |
| 378 | - if (!isset($_POST['data'])) |
|
| 379 | - die(); |
|
| 386 | + if (!isset($_POST['data'])) { |
|
| 387 | + die(); |
|
| 388 | + } |
|
| 380 | 389 | |
| 381 | 390 | list($order, $term_id, $key, $nonce) = explode('|', $_POST['data']); |
| 382 | 391 | |
| 383 | - if (!wp_verify_nonce($nonce, 'at_ajax_reorder')) |
|
| 384 | - die('1'); |
|
| 392 | + if (!wp_verify_nonce($nonce, 'at_ajax_reorder')) { |
|
| 393 | + die('1'); |
|
| 394 | + } |
|
| 385 | 395 | |
| 386 | 396 | parse_str($order, $items); |
| 387 | 397 | $items = $items['item']; |
@@ -513,8 +523,9 @@ discard block |
||
| 513 | 523 | foreach ($this->_fields as $field) { |
| 514 | 524 | $meta = $this->get_tax_meta($term_id, $field['id'], !$field['multiple']); |
| 515 | 525 | $meta = ($meta !== '') ? $meta : $field['std']; |
| 516 | - if ('image' != $field['type'] && $field['type'] != 'repeater') |
|
| 517 | - $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta); |
|
| 526 | + if ('image' != $field['type'] && $field['type'] != 'repeater') { |
|
| 527 | + $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta); |
|
| 528 | + } |
|
| 518 | 529 | |
| 519 | 530 | if ($field['validate_func']) { |
| 520 | 531 | echo '<tr class="form-field form-required ' . $field['style'] . '">'; |
@@ -560,8 +571,9 @@ discard block |
||
| 560 | 571 | $id = $field['id'] . '[' . $c . '][' . $f['id'] . ']'; |
| 561 | 572 | $m = $me[$f['id']]; |
| 562 | 573 | $m = ($m !== '') ? $m : $f['std']; |
| 563 | - if ('image' != $f['type'] && $f['type'] != 'repeater') |
|
| 564 | - $m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m); |
|
| 574 | + if ('image' != $f['type'] && $f['type'] != 'repeater') { |
|
| 575 | + $m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m); |
|
| 576 | + } |
|
| 565 | 577 | //set new id for field in array format |
| 566 | 578 | $f['id'] = $id; |
| 567 | 579 | if (!$field['inline']) { |
@@ -802,8 +814,9 @@ discard block |
||
| 802 | 814 | public function show_field_select($field, $meta) |
| 803 | 815 | { |
| 804 | 816 | |
| 805 | - if (!is_array($meta)) |
|
| 806 | - $meta = (array)$meta; |
|
| 817 | + if (!is_array($meta)) { |
|
| 818 | + $meta = (array)$meta; |
|
| 819 | + } |
|
| 807 | 820 | |
| 808 | 821 | $this->show_field_begin($field, $meta); |
| 809 | 822 | echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">"; |
@@ -826,8 +839,9 @@ discard block |
||
| 826 | 839 | public function show_field_radio($field, $meta) |
| 827 | 840 | { |
| 828 | 841 | |
| 829 | - if (!is_array($meta)) |
|
| 830 | - $meta = (array)$meta; |
|
| 842 | + if (!is_array($meta)) { |
|
| 843 | + $meta = (array)$meta; |
|
| 844 | + } |
|
| 831 | 845 | |
| 832 | 846 | $this->show_field_begin($field, $meta); |
| 833 | 847 | foreach ($field['options'] as $key => $value) { |
@@ -889,8 +903,9 @@ discard block |
||
| 889 | 903 | |
| 890 | 904 | global $post; |
| 891 | 905 | |
| 892 | - if (!is_array($meta)) |
|
| 893 | - $meta = (array)$meta; |
|
| 906 | + if (!is_array($meta)) { |
|
| 907 | + $meta = (array)$meta; |
|
| 908 | + } |
|
| 894 | 909 | |
| 895 | 910 | $this->show_field_begin($field, $meta); |
| 896 | 911 | echo "{$field['desc']}<br />"; |
@@ -934,16 +949,18 @@ discard block |
||
| 934 | 949 | $this->show_field_begin($field, $meta); |
| 935 | 950 | $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false); |
| 936 | 951 | if (is_array($meta)) { |
| 937 | - if (isset($meta[0]) && is_array($meta[0])) |
|
| 938 | - $meta = $meta[0]; |
|
| 952 | + if (isset($meta[0]) && is_array($meta[0])) { |
|
| 953 | + $meta = $meta[0]; |
|
| 954 | + } |
|
| 939 | 955 | } |
| 940 | 956 | |
| 941 | 957 | $uploads = wp_upload_dir(); |
| 942 | 958 | if (is_array($meta) && isset($meta['src']) && $meta['src'] != '') { |
| 943 | 959 | $file_info = pathinfo($meta['src']); |
| 944 | 960 | |
| 945 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
| 946 | - $sub_dir = $file_info['dirname']; |
|
| 961 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') { |
|
| 962 | + $sub_dir = $file_info['dirname']; |
|
| 963 | + } |
|
| 947 | 964 | |
| 948 | 965 | $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
| 949 | 966 | $uploads_baseurl = $uploads['baseurl']; |
@@ -987,8 +1004,9 @@ discard block |
||
| 987 | 1004 | public function show_field_color($field, $meta) |
| 988 | 1005 | { |
| 989 | 1006 | |
| 990 | - if (empty($meta)) |
|
| 991 | - $meta = '#'; |
|
| 1007 | + if (empty($meta)) { |
|
| 1008 | + $meta = '#'; |
|
| 1009 | + } |
|
| 992 | 1010 | |
| 993 | 1011 | $this->show_field_begin($field, $meta); |
| 994 | 1012 | |
@@ -1011,8 +1029,9 @@ discard block |
||
| 1011 | 1029 | public function show_field_checkbox_list($field, $meta) |
| 1012 | 1030 | { |
| 1013 | 1031 | |
| 1014 | - if (!is_array($meta)) |
|
| 1015 | - $meta = (array)$meta; |
|
| 1032 | + if (!is_array($meta)) { |
|
| 1033 | + $meta = (array)$meta; |
|
| 1034 | + } |
|
| 1016 | 1035 | |
| 1017 | 1036 | $this->show_field_begin($field, $meta); |
| 1018 | 1037 | |
@@ -1072,7 +1091,9 @@ discard block |
||
| 1072 | 1091 | { |
| 1073 | 1092 | global $post; |
| 1074 | 1093 | |
| 1075 | - if (!is_array($meta)) $meta = (array)$meta; |
|
| 1094 | + if (!is_array($meta)) { |
|
| 1095 | + $meta = (array)$meta; |
|
| 1096 | + } |
|
| 1076 | 1097 | $this->show_field_begin($field, $meta); |
| 1077 | 1098 | $options = $field['options']; |
| 1078 | 1099 | $posts = get_posts($options['args']); |
@@ -1110,7 +1131,9 @@ discard block |
||
| 1110 | 1131 | { |
| 1111 | 1132 | global $post; |
| 1112 | 1133 | |
| 1113 | - if (!is_array($meta)) $meta = (array)$meta; |
|
| 1134 | + if (!is_array($meta)) { |
|
| 1135 | + $meta = (array)$meta; |
|
| 1136 | + } |
|
| 1114 | 1137 | $this->show_field_begin($field, $meta); |
| 1115 | 1138 | $options = $field['options']; |
| 1116 | 1139 | $terms = get_terms($options['taxonomy'], $options['args']); |
@@ -1144,17 +1167,20 @@ discard block |
||
| 1144 | 1167 | { |
| 1145 | 1168 | |
| 1146 | 1169 | $taxnow = ''; |
| 1147 | - if (isset($_POST['taxonomy'])) |
|
| 1148 | - $taxnow = $_POST['taxonomy']; |
|
| 1170 | + if (isset($_POST['taxonomy'])) { |
|
| 1171 | + $taxnow = $_POST['taxonomy']; |
|
| 1172 | + } |
|
| 1149 | 1173 | |
| 1150 | 1174 | if (!isset($term_id) // Check Revision |
| 1151 | 1175 | || (!in_array($taxnow, $this->_meta_box['pages'])) // Check if current taxonomy type is supported. |
| 1152 | 1176 | || (!check_admin_referer(basename(__FILE__), 'tax_meta_class_nonce')) // Check nonce - Security |
| 1153 | 1177 | || (!current_user_can('manage_categories')) |
| 1154 | - ) // Check permission |
|
| 1178 | + ) { |
|
| 1179 | + // Check permission |
|
| 1155 | 1180 | { |
| 1156 | 1181 | return $term_id; |
| 1157 | 1182 | } |
| 1183 | + } |
|
| 1158 | 1184 | |
| 1159 | 1185 | |
| 1160 | 1186 | foreach ($this->_fields as $field) { |
@@ -1248,8 +1274,9 @@ discard block |
||
| 1248 | 1274 | { |
| 1249 | 1275 | $name = $field['id']; |
| 1250 | 1276 | $this->delete_tax_meta($term_id, $name); |
| 1251 | - if ($new === '' || $new === array()) |
|
| 1252 | - return; |
|
| 1277 | + if ($new === '' || $new === array()) { |
|
| 1278 | + return; |
|
| 1279 | + } |
|
| 1253 | 1280 | |
| 1254 | 1281 | $this->update_tax_meta($term_id, $name, $new); |
| 1255 | 1282 | } |
@@ -1269,8 +1296,9 @@ discard block |
||
| 1269 | 1296 | $name = $field['id']; |
| 1270 | 1297 | |
| 1271 | 1298 | $this->delete_tax_meta($term_id, $name); |
| 1272 | - if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '') |
|
| 1273 | - return; |
|
| 1299 | + if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '') { |
|
| 1300 | + return; |
|
| 1301 | + } |
|
| 1274 | 1302 | |
| 1275 | 1303 | $this->update_tax_meta($term_id, $name, $new); |
| 1276 | 1304 | } |
@@ -1317,8 +1345,9 @@ discard block |
||
| 1317 | 1345 | break; |
| 1318 | 1346 | } |
| 1319 | 1347 | } |
| 1320 | - if (!$this->is_array_empty($n)) |
|
| 1321 | - $temp[] = $n; |
|
| 1348 | + if (!$this->is_array_empty($n)) { |
|
| 1349 | + $temp[] = $n; |
|
| 1350 | + } |
|
| 1322 | 1351 | } |
| 1323 | 1352 | if (isset($temp) && count($temp) > 0 && !$this->is_array_empty($temp)) { |
| 1324 | 1353 | $this->update_tax_meta($term_id, $field['id'], $temp); |
@@ -1346,14 +1375,16 @@ discard block |
||
| 1346 | 1375 | { |
| 1347 | 1376 | |
| 1348 | 1377 | $name = $field['id']; |
| 1349 | - if (empty($_FILES[$name])) |
|
| 1350 | - return; |
|
| 1378 | + if (empty($_FILES[$name])) { |
|
| 1379 | + return; |
|
| 1380 | + } |
|
| 1351 | 1381 | $this->fix_file_array($_FILES[$name]); |
| 1352 | 1382 | foreach ($_FILES[$name] as $position => $fileitem) { |
| 1353 | 1383 | |
| 1354 | 1384 | $file = wp_handle_upload($fileitem, array('test_form' => false)); |
| 1355 | - if (empty($file['file'])) |
|
| 1356 | - continue; |
|
| 1385 | + if (empty($file['file'])) { |
|
| 1386 | + continue; |
|
| 1387 | + } |
|
| 1357 | 1388 | $filename = $file['file']; |
| 1358 | 1389 | |
| 1359 | 1390 | $attachment = array( |
@@ -1391,14 +1422,16 @@ discard block |
||
| 1391 | 1422 | { |
| 1392 | 1423 | |
| 1393 | 1424 | $name = $field['id']; |
| 1394 | - if (empty($_FILES[$name])) |
|
| 1395 | - return; |
|
| 1425 | + if (empty($_FILES[$name])) { |
|
| 1426 | + return; |
|
| 1427 | + } |
|
| 1396 | 1428 | $this->fix_file_array($_FILES[$name]); |
| 1397 | 1429 | foreach ($_FILES[$name] as $position => $fileitem) { |
| 1398 | 1430 | |
| 1399 | 1431 | $file = wp_handle_upload($fileitem, array('test_form' => false)); |
| 1400 | - if (empty($file['file'])) |
|
| 1401 | - continue; |
|
| 1432 | + if (empty($file['file'])) { |
|
| 1433 | + continue; |
|
| 1434 | + } |
|
| 1402 | 1435 | $filename = $file['file']; |
| 1403 | 1436 | |
| 1404 | 1437 | $attachment = array( |
@@ -1453,8 +1486,9 @@ discard block |
||
| 1453 | 1486 | { |
| 1454 | 1487 | if(is_array($this->_fields)) { |
| 1455 | 1488 | foreach ($this->_fields as $field) { |
| 1456 | - if ($type == $field['type']) |
|
| 1457 | - return true; |
|
| 1489 | + if ($type == $field['type']) { |
|
| 1490 | + return true; |
|
| 1491 | + } |
|
| 1458 | 1492 | } |
| 1459 | 1493 | } |
| 1460 | 1494 | return false; |
@@ -1992,18 +2026,21 @@ discard block |
||
| 1992 | 2026 | */ |
| 1993 | 2027 | public function is_array_empty($array) |
| 1994 | 2028 | { |
| 1995 | - if (!is_array($array)) |
|
| 1996 | - return true; |
|
| 2029 | + if (!is_array($array)) { |
|
| 2030 | + return true; |
|
| 2031 | + } |
|
| 1997 | 2032 | |
| 1998 | 2033 | foreach ($array as $a) { |
| 1999 | 2034 | if (is_array($a)) { |
| 2000 | 2035 | foreach ($a as $sub_a) { |
| 2001 | - if (!empty($sub_a) && $sub_a != '') |
|
| 2002 | - return false; |
|
| 2036 | + if (!empty($sub_a) && $sub_a != '') { |
|
| 2037 | + return false; |
|
| 2038 | + } |
|
| 2003 | 2039 | } |
| 2004 | 2040 | } else { |
| 2005 | - if (!empty($a) && $a != '') |
|
| 2006 | - return false; |
|
| 2041 | + if (!empty($a) && $a != '') { |
|
| 2042 | + return false; |
|
| 2043 | + } |
|
| 2007 | 2044 | } |
| 2008 | 2045 | } |
| 2009 | 2046 | return true; |
@@ -11,142 +11,142 @@ discard block |
||
| 11 | 11 | //include the main class file |
| 12 | 12 | require_once("Tax-meta-class.php"); |
| 13 | 13 | if (is_admin()) { |
| 14 | - /* |
|
| 14 | + /* |
|
| 15 | 15 | * prefix of meta keys, optional |
| 16 | 16 | * use underscore (_) at the beginning to make keys hidden, for example $prefix = '_ba_'; |
| 17 | 17 | * you also can make prefix empty to disable it |
| 18 | 18 | * |
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | - $prefix = 'ct_'; |
|
| 22 | - /* |
|
| 21 | + $prefix = 'ct_'; |
|
| 22 | + /* |
|
| 23 | 23 | * configure your meta box |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | - $config = array( |
|
| 27 | - 'id' => 'demo_meta_box', // meta box id, unique per meta box |
|
| 28 | - 'title' => __('Demo Meta Box', 'geodirectory'), // meta box title |
|
| 29 | - 'pages' => geodir_get_taxonomies(), // taxonomy name, accept categories, post_tag and custom taxonomies |
|
| 30 | - 'context' => 'normal', // where the meta box appear: normal (default), advanced, side; optional |
|
| 31 | - 'fields' => array(), // list of meta fields (can be added by field arrays) |
|
| 32 | - 'local_images' => false, // Use local or hosted images (meta box images for add/remove) |
|
| 33 | - 'use_with_theme' => true //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false). |
|
| 34 | - ); |
|
| 26 | + $config = array( |
|
| 27 | + 'id' => 'demo_meta_box', // meta box id, unique per meta box |
|
| 28 | + 'title' => __('Demo Meta Box', 'geodirectory'), // meta box title |
|
| 29 | + 'pages' => geodir_get_taxonomies(), // taxonomy name, accept categories, post_tag and custom taxonomies |
|
| 30 | + 'context' => 'normal', // where the meta box appear: normal (default), advanced, side; optional |
|
| 31 | + 'fields' => array(), // list of meta fields (can be added by field arrays) |
|
| 32 | + 'local_images' => false, // Use local or hosted images (meta box images for add/remove) |
|
| 33 | + 'use_with_theme' => true //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false). |
|
| 34 | + ); |
|
| 35 | 35 | |
| 36 | 36 | |
| 37 | - /* |
|
| 37 | + /* |
|
| 38 | 38 | * Initiate your meta box |
| 39 | 39 | */ |
| 40 | - $my_meta = new Tax_Meta_Class($config); |
|
| 41 | - $my_meta->addWysiwyg($prefix . 'cat_top_desc', array('name' => __('Category Top Description', 'geodirectory'), 'desc' => __('This will appear at the top of the category listing.', 'geodirectory'))); |
|
| 42 | - $my_meta->addImage($prefix . 'cat_default_img', array('name' => __('Default Listing Image', 'geodirectory'), 'desc' => __('Choose a default "no image"', 'geodirectory'))); |
|
| 43 | - $my_meta->addImage($prefix . 'cat_icon', array('name' => __('Category Icon', 'geodirectory'), 'desc' => __('Choose a category icon', 'geodirectory'), 'validate_func' => '!empty')); |
|
| 44 | - /*$my_meta->addCheckbox($prefix.'pointless',array('name'=> __('<b>Exclude</b> Rating sort option','geodirectory'),'style'=>'hidden'));*/// hidden setting to trick WPML |
|
| 45 | - |
|
| 46 | - $my_meta->addSelect($prefix . 'cat_schema', |
|
| 47 | - /* |
|
| 40 | + $my_meta = new Tax_Meta_Class($config); |
|
| 41 | + $my_meta->addWysiwyg($prefix . 'cat_top_desc', array('name' => __('Category Top Description', 'geodirectory'), 'desc' => __('This will appear at the top of the category listing.', 'geodirectory'))); |
|
| 42 | + $my_meta->addImage($prefix . 'cat_default_img', array('name' => __('Default Listing Image', 'geodirectory'), 'desc' => __('Choose a default "no image"', 'geodirectory'))); |
|
| 43 | + $my_meta->addImage($prefix . 'cat_icon', array('name' => __('Category Icon', 'geodirectory'), 'desc' => __('Choose a category icon', 'geodirectory'), 'validate_func' => '!empty')); |
|
| 44 | + /*$my_meta->addCheckbox($prefix.'pointless',array('name'=> __('<b>Exclude</b> Rating sort option','geodirectory'),'style'=>'hidden'));*/// hidden setting to trick WPML |
|
| 45 | + |
|
| 46 | + $my_meta->addSelect($prefix . 'cat_schema', |
|
| 47 | + /* |
|
| 48 | 48 | * Allows you to add/filter the cat schema types. |
| 49 | 49 | * |
| 50 | 50 | * @since 1.5.7 |
| 51 | 51 | */ |
| 52 | - apply_filters('geodir_cat_schemas',array( |
|
| 53 | - '' => __('Default (LocalBusiness)', 'geodirectory'), |
|
| 54 | - 'AccountingService' => 'AccountingService', |
|
| 55 | - 'Attorney' => 'Attorney', |
|
| 56 | - 'AutoBodyShop' => 'AutoBodyShop', |
|
| 57 | - 'AutoDealer' => 'AutoDealer', |
|
| 58 | - 'AutoPartsStore' => 'AutoPartsStore', |
|
| 59 | - 'AutoRental' => 'AutoRental', |
|
| 60 | - 'AutoRepair' => 'AutoRepair', |
|
| 61 | - 'AutoWash' => 'AutoWash', |
|
| 62 | - 'Bakery' => 'Bakery', |
|
| 63 | - 'BarOrPub' => 'BarOrPub', |
|
| 64 | - 'BeautySalon' => 'BeautySalon', |
|
| 65 | - 'BedAndBreakfast' => 'BedAndBreakfast', |
|
| 66 | - 'BikeStore' => 'BikeStore', |
|
| 67 | - 'BookStore' => 'BookStore', |
|
| 68 | - 'CafeOrCoffeeShop' => 'CafeOrCoffeeShop', |
|
| 69 | - 'Campground' => 'Campground', |
|
| 70 | - 'ChildCare' => 'ChildCare', |
|
| 71 | - 'ClothingStore' => 'ClothingStore', |
|
| 72 | - 'ComputerStore' => 'ComputerStore', |
|
| 73 | - 'DaySpa' => 'DaySpa', |
|
| 74 | - 'Dentist' => 'Dentist', |
|
| 75 | - 'DryCleaningOrLaundry' => 'DryCleaningOrLaundry', |
|
| 76 | - 'Electrician' => 'Electrician', |
|
| 77 | - 'ElectronicsStore' => 'ElectronicsStore', |
|
| 78 | - 'EmergencyService' => 'EmergencyService', |
|
| 79 | - 'EntertainmentBusiness' => 'EntertainmentBusiness', |
|
| 80 | - 'Event' => 'Event', |
|
| 81 | - 'EventVenue' => 'EventVenue', |
|
| 82 | - 'ExerciseGym' => 'ExerciseGym', |
|
| 83 | - 'FinancialService' => 'FinancialService', |
|
| 84 | - 'Florist' => 'Florist', |
|
| 85 | - 'FoodEstablishment' => 'FoodEstablishment', |
|
| 86 | - 'FurnitureStore' => 'FurnitureStore', |
|
| 87 | - 'GardenStore' => 'GardenStore', |
|
| 88 | - 'GeneralContractor' => 'GeneralContractor', |
|
| 89 | - 'GolfCourse' => 'GolfCourse', |
|
| 90 | - 'HairSalon' => 'HairSalon', |
|
| 91 | - 'HardwareStore' => 'HardwareStore', |
|
| 92 | - 'HealthAndBeautyBusiness' => 'HealthAndBeautyBusiness', |
|
| 93 | - 'HobbyShop' => 'HobbyShop', |
|
| 94 | - 'HomeAndConstructionBusiness' => 'HomeAndConstructionBusiness', |
|
| 95 | - 'HomeGoodsStore' => 'HomeGoodsStore', |
|
| 96 | - 'Hospital' => 'Hospital', |
|
| 97 | - 'Hostel' => 'Hostel', |
|
| 98 | - 'Hotel' => 'Hotel', |
|
| 99 | - 'HousePainter' => 'HousePainter', |
|
| 100 | - 'HVACBusiness' => 'HVACBusiness', |
|
| 101 | - 'InsuranceAgency' => 'InsuranceAgency', |
|
| 102 | - 'JewelryStore' => 'JewelryStore', |
|
| 103 | - 'LiquorStore' => 'LiquorStore', |
|
| 104 | - 'Locksmith' => 'Locksmith', |
|
| 105 | - 'LodgingBusiness' => 'LodgingBusiness', |
|
| 106 | - 'MedicalClinic' => 'MedicalClinic', |
|
| 107 | - 'MensClothingStore' => 'MensClothingStore', |
|
| 108 | - 'MobilePhoneStore' => 'MobilePhoneStore', |
|
| 109 | - 'Motel' => 'Motel', |
|
| 110 | - 'MotorcycleDealer' => 'MotorcycleDealer', |
|
| 111 | - 'MotorcycleRepair' => 'MotorcycleRepair', |
|
| 112 | - 'MovingCompany' => 'MovingCompany', |
|
| 113 | - 'MusicStore' => 'MusicStore', |
|
| 114 | - 'NailSalon' => 'NailSalon', |
|
| 115 | - 'NightClub' => 'NightClub', |
|
| 116 | - 'Notary' => 'Notary', |
|
| 117 | - 'OfficeEquipmentStore' => 'OfficeEquipmentStore', |
|
| 118 | - 'Optician' => 'Optician', |
|
| 119 | - 'PetStore' => 'PetStore', |
|
| 120 | - 'Physician' => 'Physician', |
|
| 121 | - 'Plumber' => 'Plumber', |
|
| 122 | - 'ProfessionalService' => 'ProfessionalService', |
|
| 123 | - 'RealEstateAgent' => 'RealEstateAgent', |
|
| 124 | - 'Residence' => 'Residence', |
|
| 125 | - 'Restaurant' => 'Restaurant', |
|
| 126 | - 'RoofingContractor' => 'RoofingContractor', |
|
| 127 | - 'RVPark' => 'RVPark', |
|
| 128 | - 'School' => 'School', |
|
| 129 | - 'SelfStorage' => 'SelfStorage', |
|
| 130 | - 'ShoeStore' => 'ShoeStore', |
|
| 131 | - 'SkiResort' => 'SkiResort', |
|
| 132 | - 'SportingGoodsStore' => 'SportingGoodsStore', |
|
| 133 | - 'SportsClub' => 'SportsClub', |
|
| 134 | - 'Store' => 'Store', |
|
| 135 | - 'TattooParlor' => 'TattooParlor', |
|
| 136 | - 'Taxi' => 'Taxi', |
|
| 137 | - 'TennisComplex' => 'TennisComplex', |
|
| 138 | - 'TireShop' => 'TireShop', |
|
| 139 | - 'TouristAttraction' => 'TouristAttraction', |
|
| 140 | - 'ToyStore' => 'ToyStore', |
|
| 141 | - 'TravelAgency' => 'TravelAgency', |
|
| 142 | - //'VacationRentals' => 'VacationRentals', // Not recognised by google yet |
|
| 143 | - 'VeterinaryCare' => 'VeterinaryCare', |
|
| 144 | - 'WholesaleStore' => 'WholesaleStore', |
|
| 145 | - 'Winery' => 'Winery' |
|
| 146 | - )), |
|
| 147 | - array('name' => __('Schema Type', 'geodirectory'), 'desc' => __('Select the Schema to use for this category', 'geodirectory') . "", 'std' => array('selectkey2'))); |
|
| 148 | - |
|
| 149 | - /*$my_meta->addSelect($prefix.'cat_sort',array(''=>__('Default' , 'geodirectory'), |
|
| 52 | + apply_filters('geodir_cat_schemas',array( |
|
| 53 | + '' => __('Default (LocalBusiness)', 'geodirectory'), |
|
| 54 | + 'AccountingService' => 'AccountingService', |
|
| 55 | + 'Attorney' => 'Attorney', |
|
| 56 | + 'AutoBodyShop' => 'AutoBodyShop', |
|
| 57 | + 'AutoDealer' => 'AutoDealer', |
|
| 58 | + 'AutoPartsStore' => 'AutoPartsStore', |
|
| 59 | + 'AutoRental' => 'AutoRental', |
|
| 60 | + 'AutoRepair' => 'AutoRepair', |
|
| 61 | + 'AutoWash' => 'AutoWash', |
|
| 62 | + 'Bakery' => 'Bakery', |
|
| 63 | + 'BarOrPub' => 'BarOrPub', |
|
| 64 | + 'BeautySalon' => 'BeautySalon', |
|
| 65 | + 'BedAndBreakfast' => 'BedAndBreakfast', |
|
| 66 | + 'BikeStore' => 'BikeStore', |
|
| 67 | + 'BookStore' => 'BookStore', |
|
| 68 | + 'CafeOrCoffeeShop' => 'CafeOrCoffeeShop', |
|
| 69 | + 'Campground' => 'Campground', |
|
| 70 | + 'ChildCare' => 'ChildCare', |
|
| 71 | + 'ClothingStore' => 'ClothingStore', |
|
| 72 | + 'ComputerStore' => 'ComputerStore', |
|
| 73 | + 'DaySpa' => 'DaySpa', |
|
| 74 | + 'Dentist' => 'Dentist', |
|
| 75 | + 'DryCleaningOrLaundry' => 'DryCleaningOrLaundry', |
|
| 76 | + 'Electrician' => 'Electrician', |
|
| 77 | + 'ElectronicsStore' => 'ElectronicsStore', |
|
| 78 | + 'EmergencyService' => 'EmergencyService', |
|
| 79 | + 'EntertainmentBusiness' => 'EntertainmentBusiness', |
|
| 80 | + 'Event' => 'Event', |
|
| 81 | + 'EventVenue' => 'EventVenue', |
|
| 82 | + 'ExerciseGym' => 'ExerciseGym', |
|
| 83 | + 'FinancialService' => 'FinancialService', |
|
| 84 | + 'Florist' => 'Florist', |
|
| 85 | + 'FoodEstablishment' => 'FoodEstablishment', |
|
| 86 | + 'FurnitureStore' => 'FurnitureStore', |
|
| 87 | + 'GardenStore' => 'GardenStore', |
|
| 88 | + 'GeneralContractor' => 'GeneralContractor', |
|
| 89 | + 'GolfCourse' => 'GolfCourse', |
|
| 90 | + 'HairSalon' => 'HairSalon', |
|
| 91 | + 'HardwareStore' => 'HardwareStore', |
|
| 92 | + 'HealthAndBeautyBusiness' => 'HealthAndBeautyBusiness', |
|
| 93 | + 'HobbyShop' => 'HobbyShop', |
|
| 94 | + 'HomeAndConstructionBusiness' => 'HomeAndConstructionBusiness', |
|
| 95 | + 'HomeGoodsStore' => 'HomeGoodsStore', |
|
| 96 | + 'Hospital' => 'Hospital', |
|
| 97 | + 'Hostel' => 'Hostel', |
|
| 98 | + 'Hotel' => 'Hotel', |
|
| 99 | + 'HousePainter' => 'HousePainter', |
|
| 100 | + 'HVACBusiness' => 'HVACBusiness', |
|
| 101 | + 'InsuranceAgency' => 'InsuranceAgency', |
|
| 102 | + 'JewelryStore' => 'JewelryStore', |
|
| 103 | + 'LiquorStore' => 'LiquorStore', |
|
| 104 | + 'Locksmith' => 'Locksmith', |
|
| 105 | + 'LodgingBusiness' => 'LodgingBusiness', |
|
| 106 | + 'MedicalClinic' => 'MedicalClinic', |
|
| 107 | + 'MensClothingStore' => 'MensClothingStore', |
|
| 108 | + 'MobilePhoneStore' => 'MobilePhoneStore', |
|
| 109 | + 'Motel' => 'Motel', |
|
| 110 | + 'MotorcycleDealer' => 'MotorcycleDealer', |
|
| 111 | + 'MotorcycleRepair' => 'MotorcycleRepair', |
|
| 112 | + 'MovingCompany' => 'MovingCompany', |
|
| 113 | + 'MusicStore' => 'MusicStore', |
|
| 114 | + 'NailSalon' => 'NailSalon', |
|
| 115 | + 'NightClub' => 'NightClub', |
|
| 116 | + 'Notary' => 'Notary', |
|
| 117 | + 'OfficeEquipmentStore' => 'OfficeEquipmentStore', |
|
| 118 | + 'Optician' => 'Optician', |
|
| 119 | + 'PetStore' => 'PetStore', |
|
| 120 | + 'Physician' => 'Physician', |
|
| 121 | + 'Plumber' => 'Plumber', |
|
| 122 | + 'ProfessionalService' => 'ProfessionalService', |
|
| 123 | + 'RealEstateAgent' => 'RealEstateAgent', |
|
| 124 | + 'Residence' => 'Residence', |
|
| 125 | + 'Restaurant' => 'Restaurant', |
|
| 126 | + 'RoofingContractor' => 'RoofingContractor', |
|
| 127 | + 'RVPark' => 'RVPark', |
|
| 128 | + 'School' => 'School', |
|
| 129 | + 'SelfStorage' => 'SelfStorage', |
|
| 130 | + 'ShoeStore' => 'ShoeStore', |
|
| 131 | + 'SkiResort' => 'SkiResort', |
|
| 132 | + 'SportingGoodsStore' => 'SportingGoodsStore', |
|
| 133 | + 'SportsClub' => 'SportsClub', |
|
| 134 | + 'Store' => 'Store', |
|
| 135 | + 'TattooParlor' => 'TattooParlor', |
|
| 136 | + 'Taxi' => 'Taxi', |
|
| 137 | + 'TennisComplex' => 'TennisComplex', |
|
| 138 | + 'TireShop' => 'TireShop', |
|
| 139 | + 'TouristAttraction' => 'TouristAttraction', |
|
| 140 | + 'ToyStore' => 'ToyStore', |
|
| 141 | + 'TravelAgency' => 'TravelAgency', |
|
| 142 | + //'VacationRentals' => 'VacationRentals', // Not recognised by google yet |
|
| 143 | + 'VeterinaryCare' => 'VeterinaryCare', |
|
| 144 | + 'WholesaleStore' => 'WholesaleStore', |
|
| 145 | + 'Winery' => 'Winery' |
|
| 146 | + )), |
|
| 147 | + array('name' => __('Schema Type', 'geodirectory'), 'desc' => __('Select the Schema to use for this category', 'geodirectory') . "", 'std' => array('selectkey2'))); |
|
| 148 | + |
|
| 149 | + /*$my_meta->addSelect($prefix.'cat_sort',array(''=>__('Default' , 'geodirectory'), |
|
| 150 | 150 | 'random'=>__('Random','geodirectory'), |
| 151 | 151 | 'az'=>__('Alphabetical' , 'geodirectory'), |
| 152 | 152 | 'newest'=>__('Newest','geodirectory'), |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | 'low_review'=>__('Lowest Reviews','geodirectory')), |
| 158 | 158 | array('name'=> __('Sort By','geodirectory'),'desc' => __('Select the default sort option.' ,'geodirectory'), 'std'=> array('selectkey2')));*/ |
| 159 | 159 | |
| 160 | - // Show options for placecategories only |
|
| 161 | - /* if(isset($_REQUEST['taxonomy']) && in_array($_REQUEST['taxonomy'],$config['pages']) ){ |
|
| 160 | + // Show options for placecategories only |
|
| 161 | + /* if(isset($_REQUEST['taxonomy']) && in_array($_REQUEST['taxonomy'],$config['pages']) ){ |
|
| 162 | 162 | // Exclude sort options |
| 163 | 163 | $my_meta->addCheckbox($prefix.'cat_exclude_rating',array('name'=> __('<b>Exclude</b> Rating sort option','geodirectory'))); |
| 164 | 164 | $my_meta->addCheckbox($prefix.'cat_exclude_reviews',array('name'=> __('<b>Exclude</b> Reviews sort option','geodirectory'))); |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | }*/ |
| 172 | 172 | |
| 173 | - //Finish Meta Box Declaration |
|
| 174 | - $my_meta->Finish(); |
|
| 173 | + //Finish Meta Box Declaration |
|
| 174 | + $my_meta->Finish(); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
@@ -180,87 +180,87 @@ discard block |
||
| 180 | 180 | ############################################################## |
| 181 | 181 | $gd_taxonomies = geodir_get_taxonomies(); |
| 182 | 182 | if (!empty($gd_taxonomies)) { |
| 183 | - foreach ($gd_taxonomies as $gd_taxonomy) { |
|
| 183 | + foreach ($gd_taxonomies as $gd_taxonomy) { |
|
| 184 | 184 | |
| 185 | - add_filter('manage_edit-' . $gd_taxonomy . '_columns', 'addCat_column', 10, 2); |
|
| 186 | - add_action('manage_' . $gd_taxonomy . '_custom_column', 'manage_category_custom_fields', 10, 3); |
|
| 185 | + add_filter('manage_edit-' . $gd_taxonomy . '_columns', 'addCat_column', 10, 2); |
|
| 186 | + add_action('manage_' . $gd_taxonomy . '_custom_column', 'manage_category_custom_fields', 10, 3); |
|
| 187 | 187 | |
| 188 | - } |
|
| 188 | + } |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | function addCat_column($columns) |
| 192 | 192 | { |
| 193 | - if (isset($columns['description']) && $posts = $columns['description']) { |
|
| 194 | - unset($columns['description']); |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - $columns['cat_icon'] = 'Icon'; |
|
| 198 | - $columns['cat_default_img'] = __('Default Image', 'geodirectory'); |
|
| 199 | - $columns['cat_ID_num'] = __('Cat ID', 'geodirectory'); |
|
| 200 | - return $columns; |
|
| 193 | + if (isset($columns['description']) && $posts = $columns['description']) { |
|
| 194 | + unset($columns['description']); |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + $columns['cat_icon'] = 'Icon'; |
|
| 198 | + $columns['cat_default_img'] = __('Default Image', 'geodirectory'); |
|
| 199 | + $columns['cat_ID_num'] = __('Cat ID', 'geodirectory'); |
|
| 200 | + return $columns; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | ############################################################# |
| 204 | 204 | function manage_category_custom_fields($deprecated, $column_name, $term_id) |
| 205 | 205 | { |
| 206 | - if ($column_name == 'cat_ID_num') |
|
| 207 | - echo $term_id; |
|
| 206 | + if ($column_name == 'cat_ID_num') |
|
| 207 | + echo $term_id; |
|
| 208 | 208 | |
| 209 | - if ($column_name == 'cat_icon') { |
|
| 210 | - $term_icon_url = get_tax_meta($term_id, 'ct_cat_icon'); |
|
| 209 | + if ($column_name == 'cat_icon') { |
|
| 210 | + $term_icon_url = get_tax_meta($term_id, 'ct_cat_icon'); |
|
| 211 | 211 | |
| 212 | - if ($term_icon_url != '') { |
|
| 213 | - $file_info = pathinfo($term_icon_url['src']); |
|
| 212 | + if ($term_icon_url != '') { |
|
| 213 | + $file_info = pathinfo($term_icon_url['src']); |
|
| 214 | 214 | |
| 215 | - if (isset($file_info['dirname'] ) && $file_info['dirname'] != '.' && $file_info['dirname'] != '..') { |
|
| 216 | - $sub_dir = $file_info['dirname']; |
|
| 217 | - } else { |
|
| 218 | - $sub_dir = ''; |
|
| 219 | - } |
|
| 215 | + if (isset($file_info['dirname'] ) && $file_info['dirname'] != '.' && $file_info['dirname'] != '..') { |
|
| 216 | + $sub_dir = $file_info['dirname']; |
|
| 217 | + } else { |
|
| 218 | + $sub_dir = ''; |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
| 222 | - $uploads_baseurl = $uploads['baseurl']; |
|
| 223 | - $uploads_path = $uploads['path']; |
|
| 221 | + $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
| 222 | + $uploads_baseurl = $uploads['baseurl']; |
|
| 223 | + $uploads_path = $uploads['path']; |
|
| 224 | 224 | |
| 225 | - $file_name = $file_info['basename']; |
|
| 225 | + $file_name = $file_info['basename']; |
|
| 226 | 226 | |
| 227 | - if (strpos($sub_dir, 'https://') !== false) { |
|
| 228 | - $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
| 229 | - } else { |
|
| 230 | - $uploads['baseurl'] = str_replace('https://', 'http://', $uploads['baseurl']); |
|
| 231 | - } |
|
| 232 | - $sub_dir = str_replace($uploads['baseurl'], '', $sub_dir); |
|
| 227 | + if (strpos($sub_dir, 'https://') !== false) { |
|
| 228 | + $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
| 229 | + } else { |
|
| 230 | + $uploads['baseurl'] = str_replace('https://', 'http://', $uploads['baseurl']); |
|
| 231 | + } |
|
| 232 | + $sub_dir = str_replace($uploads['baseurl'], '', $sub_dir); |
|
| 233 | 233 | |
| 234 | - $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 234 | + $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 235 | 235 | |
| 236 | - $term_icon_url['src'] = $uploads_url . '/' . $file_name; |
|
| 237 | - echo '<img src="' . $term_icon_url['src'] . '" />'; |
|
| 238 | - } |
|
| 239 | - } |
|
| 236 | + $term_icon_url['src'] = $uploads_url . '/' . $file_name; |
|
| 237 | + echo '<img src="' . $term_icon_url['src'] . '" />'; |
|
| 238 | + } |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - if ($column_name == 'cat_default_img') { |
|
| 242 | - $cat_default_img = get_tax_meta($term_id, 'ct_cat_default_img'); |
|
| 243 | - if ($cat_default_img != '') |
|
| 244 | - echo '<img src="' . $cat_default_img['src'] . '" style="max-height:60px;max-width:60px;"/>'; |
|
| 241 | + if ($column_name == 'cat_default_img') { |
|
| 242 | + $cat_default_img = get_tax_meta($term_id, 'ct_cat_default_img'); |
|
| 243 | + if ($cat_default_img != '') |
|
| 244 | + echo '<img src="' . $cat_default_img['src'] . '" style="max-height:60px;max-width:60px;"/>'; |
|
| 245 | 245 | |
| 246 | - } |
|
| 246 | + } |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | function geodir_get_default_catimage($term_id, $post_type = 'gd_place') |
| 250 | 250 | { |
| 251 | 251 | |
| 252 | - if ($cat_default_img = get_tax_meta($term_id, 'ct_cat_default_img', '', $post_type)) |
|
| 253 | - return $cat_default_img; |
|
| 254 | - else |
|
| 255 | - return false; |
|
| 252 | + if ($cat_default_img = get_tax_meta($term_id, 'ct_cat_default_img', '', $post_type)) |
|
| 253 | + return $cat_default_img; |
|
| 254 | + else |
|
| 255 | + return false; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | //Clear custom fields |
| 259 | 259 | add_action('in_admin_footer', 'geodir_tax_meta_clear_custom_field'); |
| 260 | 260 | function geodir_tax_meta_clear_custom_field() |
| 261 | 261 | { |
| 262 | - if (isset($_REQUEST['taxonomy']) && !empty($_REQUEST['taxonomy'])): |
|
| 263 | - ?> |
|
| 262 | + if (isset($_REQUEST['taxonomy']) && !empty($_REQUEST['taxonomy'])): |
|
| 263 | + ?> |
|
| 264 | 264 | <script type="text/javascript"> |
| 265 | 265 | jQuery(document).ready(function () { |
| 266 | 266 | jQuery('#addtag #submit').click(function () { |
@@ -281,5 +281,5 @@ discard block |
||
| 281 | 281 | }); |
| 282 | 282 | </script> |
| 283 | 283 | <?php |
| 284 | - endif; |
|
| 284 | + endif; |
|
| 285 | 285 | } |
@@ -24,12 +24,12 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | 26 | $config = array( |
| 27 | - 'id' => 'demo_meta_box', // meta box id, unique per meta box |
|
| 28 | - 'title' => __('Demo Meta Box', 'geodirectory'), // meta box title |
|
| 29 | - 'pages' => geodir_get_taxonomies(), // taxonomy name, accept categories, post_tag and custom taxonomies |
|
| 30 | - 'context' => 'normal', // where the meta box appear: normal (default), advanced, side; optional |
|
| 31 | - 'fields' => array(), // list of meta fields (can be added by field arrays) |
|
| 32 | - 'local_images' => false, // Use local or hosted images (meta box images for add/remove) |
|
| 27 | + 'id' => 'demo_meta_box', // meta box id, unique per meta box |
|
| 28 | + 'title' => __('Demo Meta Box', 'geodirectory'), // meta box title |
|
| 29 | + 'pages' => geodir_get_taxonomies(), // taxonomy name, accept categories, post_tag and custom taxonomies |
|
| 30 | + 'context' => 'normal', // where the meta box appear: normal (default), advanced, side; optional |
|
| 31 | + 'fields' => array(), // list of meta fields (can be added by field arrays) |
|
| 32 | + 'local_images' => false, // Use local or hosted images (meta box images for add/remove) |
|
| 33 | 33 | 'use_with_theme' => true //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false). |
| 34 | 34 | ); |
| 35 | 35 | |
@@ -38,18 +38,18 @@ discard block |
||
| 38 | 38 | * Initiate your meta box |
| 39 | 39 | */ |
| 40 | 40 | $my_meta = new Tax_Meta_Class($config); |
| 41 | - $my_meta->addWysiwyg($prefix . 'cat_top_desc', array('name' => __('Category Top Description', 'geodirectory'), 'desc' => __('This will appear at the top of the category listing.', 'geodirectory'))); |
|
| 42 | - $my_meta->addImage($prefix . 'cat_default_img', array('name' => __('Default Listing Image', 'geodirectory'), 'desc' => __('Choose a default "no image"', 'geodirectory'))); |
|
| 43 | - $my_meta->addImage($prefix . 'cat_icon', array('name' => __('Category Icon', 'geodirectory'), 'desc' => __('Choose a category icon', 'geodirectory'), 'validate_func' => '!empty')); |
|
| 41 | + $my_meta->addWysiwyg($prefix.'cat_top_desc', array('name' => __('Category Top Description', 'geodirectory'), 'desc' => __('This will appear at the top of the category listing.', 'geodirectory'))); |
|
| 42 | + $my_meta->addImage($prefix.'cat_default_img', array('name' => __('Default Listing Image', 'geodirectory'), 'desc' => __('Choose a default "no image"', 'geodirectory'))); |
|
| 43 | + $my_meta->addImage($prefix.'cat_icon', array('name' => __('Category Icon', 'geodirectory'), 'desc' => __('Choose a category icon', 'geodirectory'), 'validate_func' => '!empty')); |
|
| 44 | 44 | /*$my_meta->addCheckbox($prefix.'pointless',array('name'=> __('<b>Exclude</b> Rating sort option','geodirectory'),'style'=>'hidden'));*/// hidden setting to trick WPML |
| 45 | 45 | |
| 46 | - $my_meta->addSelect($prefix . 'cat_schema', |
|
| 46 | + $my_meta->addSelect($prefix.'cat_schema', |
|
| 47 | 47 | /* |
| 48 | 48 | * Allows you to add/filter the cat schema types. |
| 49 | 49 | * |
| 50 | 50 | * @since 1.5.7 |
| 51 | 51 | */ |
| 52 | - apply_filters('geodir_cat_schemas',array( |
|
| 52 | + apply_filters('geodir_cat_schemas', array( |
|
| 53 | 53 | '' => __('Default (LocalBusiness)', 'geodirectory'), |
| 54 | 54 | 'AccountingService' => 'AccountingService', |
| 55 | 55 | 'Attorney' => 'Attorney', |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | 'WholesaleStore' => 'WholesaleStore', |
| 145 | 145 | 'Winery' => 'Winery' |
| 146 | 146 | )), |
| 147 | - array('name' => __('Schema Type', 'geodirectory'), 'desc' => __('Select the Schema to use for this category', 'geodirectory') . "", 'std' => array('selectkey2'))); |
|
| 147 | + array('name' => __('Schema Type', 'geodirectory'), 'desc' => __('Select the Schema to use for this category', 'geodirectory')."", 'std' => array('selectkey2'))); |
|
| 148 | 148 | |
| 149 | 149 | /*$my_meta->addSelect($prefix.'cat_sort',array(''=>__('Default' , 'geodirectory'), |
| 150 | 150 | 'random'=>__('Random','geodirectory'), |
@@ -182,8 +182,8 @@ discard block |
||
| 182 | 182 | if (!empty($gd_taxonomies)) { |
| 183 | 183 | foreach ($gd_taxonomies as $gd_taxonomy) { |
| 184 | 184 | |
| 185 | - add_filter('manage_edit-' . $gd_taxonomy . '_columns', 'addCat_column', 10, 2); |
|
| 186 | - add_action('manage_' . $gd_taxonomy . '_custom_column', 'manage_category_custom_fields', 10, 3); |
|
| 185 | + add_filter('manage_edit-'.$gd_taxonomy.'_columns', 'addCat_column', 10, 2); |
|
| 186 | + add_action('manage_'.$gd_taxonomy.'_custom_column', 'manage_category_custom_fields', 10, 3); |
|
| 187 | 187 | |
| 188 | 188 | } |
| 189 | 189 | } |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | if ($term_icon_url != '') { |
| 213 | 213 | $file_info = pathinfo($term_icon_url['src']); |
| 214 | 214 | |
| 215 | - if (isset($file_info['dirname'] ) && $file_info['dirname'] != '.' && $file_info['dirname'] != '..') { |
|
| 215 | + if (isset($file_info['dirname']) && $file_info['dirname'] != '.' && $file_info['dirname'] != '..') { |
|
| 216 | 216 | $sub_dir = $file_info['dirname']; |
| 217 | 217 | } else { |
| 218 | 218 | $sub_dir = ''; |
@@ -231,17 +231,17 @@ discard block |
||
| 231 | 231 | } |
| 232 | 232 | $sub_dir = str_replace($uploads['baseurl'], '', $sub_dir); |
| 233 | 233 | |
| 234 | - $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 234 | + $uploads_url = $uploads_baseurl.$sub_dir; |
|
| 235 | 235 | |
| 236 | - $term_icon_url['src'] = $uploads_url . '/' . $file_name; |
|
| 237 | - echo '<img src="' . $term_icon_url['src'] . '" />'; |
|
| 236 | + $term_icon_url['src'] = $uploads_url.'/'.$file_name; |
|
| 237 | + echo '<img src="'.$term_icon_url['src'].'" />'; |
|
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | if ($column_name == 'cat_default_img') { |
| 242 | 242 | $cat_default_img = get_tax_meta($term_id, 'ct_cat_default_img'); |
| 243 | 243 | if ($cat_default_img != '') |
| 244 | - echo '<img src="' . $cat_default_img['src'] . '" style="max-height:60px;max-width:60px;"/>'; |
|
| 244 | + echo '<img src="'.$cat_default_img['src'].'" style="max-height:60px;max-width:60px;"/>'; |
|
| 245 | 245 | |
| 246 | 246 | } |
| 247 | 247 | } |
@@ -272,8 +272,8 @@ discard block |
||
| 272 | 272 | jQuery("#addtag iframe").contents().find("body").html(''); |
| 273 | 273 | jQuery('#addtag [rel="ct_cat_default_img"]').removeClass('at-delete_image_button').addClass('at-upload_image_button'); |
| 274 | 274 | jQuery('#addtag [rel="ct_cat_icon"]').removeClass('at-delete_image_button').addClass('at-upload_image_button'); |
| 275 | - jQuery('#addtag [rel="ct_cat_default_img"]').val('<?php _e('Upload Image','geodirectory');?>'); |
|
| 276 | - jQuery('#addtag [rel="ct_cat_icon"]').val('<?php _e('Upload Image','geodirectory');?>'); |
|
| 275 | + jQuery('#addtag [rel="ct_cat_default_img"]').val('<?php _e('Upload Image', 'geodirectory'); ?>'); |
|
| 276 | + jQuery('#addtag [rel="ct_cat_icon"]').val('<?php _e('Upload Image', 'geodirectory'); ?>'); |
|
| 277 | 277 | } |
| 278 | 278 | }, 1000); |
| 279 | 279 | |
@@ -203,8 +203,9 @@ discard block |
||
| 203 | 203 | ############################################################# |
| 204 | 204 | function manage_category_custom_fields($deprecated, $column_name, $term_id) |
| 205 | 205 | { |
| 206 | - if ($column_name == 'cat_ID_num') |
|
| 207 | - echo $term_id; |
|
| 206 | + if ($column_name == 'cat_ID_num') { |
|
| 207 | + echo $term_id; |
|
| 208 | + } |
|
| 208 | 209 | |
| 209 | 210 | if ($column_name == 'cat_icon') { |
| 210 | 211 | $term_icon_url = get_tax_meta($term_id, 'ct_cat_icon'); |
@@ -240,8 +241,9 @@ discard block |
||
| 240 | 241 | |
| 241 | 242 | if ($column_name == 'cat_default_img') { |
| 242 | 243 | $cat_default_img = get_tax_meta($term_id, 'ct_cat_default_img'); |
| 243 | - if ($cat_default_img != '') |
|
| 244 | - echo '<img src="' . $cat_default_img['src'] . '" style="max-height:60px;max-width:60px;"/>'; |
|
| 244 | + if ($cat_default_img != '') { |
|
| 245 | + echo '<img src="' . $cat_default_img['src'] . '" style="max-height:60px;max-width:60px;"/>'; |
|
| 246 | + } |
|
| 245 | 247 | |
| 246 | 248 | } |
| 247 | 249 | } |
@@ -249,11 +251,12 @@ discard block |
||
| 249 | 251 | function geodir_get_default_catimage($term_id, $post_type = 'gd_place') |
| 250 | 252 | { |
| 251 | 253 | |
| 252 | - if ($cat_default_img = get_tax_meta($term_id, 'ct_cat_default_img', '', $post_type)) |
|
| 253 | - return $cat_default_img; |
|
| 254 | - else |
|
| 255 | - return false; |
|
| 256 | -} |
|
| 254 | + if ($cat_default_img = get_tax_meta($term_id, 'ct_cat_default_img', '', $post_type)) { |
|
| 255 | + return $cat_default_img; |
|
| 256 | + } else { |
|
| 257 | + return false; |
|
| 258 | + } |
|
| 259 | + } |
|
| 257 | 260 | |
| 258 | 261 | //Clear custom fields |
| 259 | 262 | add_action('in_admin_footer', 'geodir_tax_meta_clear_custom_field'); |