Changeset 3153871
- Timestamp:
- 09/18/2024 10:34:29 AM (16 months ago)
- Location:
- post-meta-data-manager
- Files:
-
- 29 added
- 5 edited
-
tags/1.4.3 (added)
-
tags/1.4.3/.gitignore (added)
-
tags/1.4.3/CHANGELOG.md (added)
-
tags/1.4.3/includes (added)
-
tags/1.4.3/includes/admin (added)
-
tags/1.4.3/includes/admin/class-pmdm-wp-admin.php (added)
-
tags/1.4.3/includes/admin/html (added)
-
tags/1.4.3/includes/admin/html/pmdm_general_settings_html.php (added)
-
tags/1.4.3/includes/admin/html/pmdm_help_html.php (added)
-
tags/1.4.3/includes/admin/html/pmdm_wp_display_post_metadata_html.php (added)
-
tags/1.4.3/includes/admin/html/pmdm_wp_display_term_metadata_html.php (added)
-
tags/1.4.3/includes/admin/html/pmdm_wp_display_user_metadata_html.php (added)
-
tags/1.4.3/includes/class-pmdm-wp-scripts.php (added)
-
tags/1.4.3/includes/css (added)
-
tags/1.4.3/includes/css/datatables.min.css (added)
-
tags/1.4.3/includes/css/images (added)
-
tags/1.4.3/includes/css/images/sort_asc.png (added)
-
tags/1.4.3/includes/css/images/sort_asc_disabled.png (added)
-
tags/1.4.3/includes/css/images/sort_both.png (added)
-
tags/1.4.3/includes/css/images/sort_desc.png (added)
-
tags/1.4.3/includes/css/images/sort_desc_disabled.png (added)
-
tags/1.4.3/includes/css/pmdm-wp.css (added)
-
tags/1.4.3/includes/js (added)
-
tags/1.4.3/includes/js/datatables.min.js (added)
-
tags/1.4.3/includes/js/pmdm-wp.js (added)
-
tags/1.4.3/index.php (added)
-
tags/1.4.3/languages (added)
-
tags/1.4.3/post-meta-data-manager.php (added)
-
tags/1.4.3/readme.txt (added)
-
trunk/.gitignore (modified) (2 diffs)
-
trunk/includes/admin/class-pmdm-wp-admin.php (modified) (27 diffs)
-
trunk/includes/admin/html/pmdm_wp_display_post_metadata_html.php (modified) (8 diffs)
-
trunk/post-meta-data-manager.php (modified) (6 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
post-meta-data-manager/trunk/.gitignore
r2994271 r3153871 18 18 node_modules/ 19 19 20 # Packages 21 vendor 22 20 23 # ignore log files and databases 21 24 *.log … … 23 26 *.sqlite 24 27 *.bak 28 -
post-meta-data-manager/trunk/includes/admin/class-pmdm-wp-admin.php
r3123921 r3153871 1 1 <?php 2 2 // Exit if accessed directly 3 if ( ! defined( 'ABSPATH' )) {3 if (! defined('ABSPATH')) { 4 4 exit; 5 5 } … … 16 16 */ 17 17 18 class Pmdm_Wp_Admin { 18 class Pmdm_Wp_Admin 19 { 19 20 20 21 … … 22 23 23 24 // class constructor 24 function __construct() { 25 function __construct() 26 { 25 27 26 28 global $pmdm_wp_scripts; … … 36 38 * @since 1.0 37 39 */ 38 public function pmdm_wp_add_meta_boxes( $post_type, $post ) { 40 public function pmdm_wp_add_meta_boxes($post_type, $post) 41 { 39 42 40 43 $current_screen = get_current_screen(); 41 44 42 45 $metabox_id = 'pmdm-wp'; 43 $metabox_title = esc_html__( 'Post Metadata Manager', 'pmdm_wp');46 $metabox_title = esc_html__('Post Metadata Manager', 'pmdm_wp'); 44 47 $metabox_screen = $post_type; 45 48 $metabox_context = 'normal'; 46 49 $metabox_priority = 'low'; 47 $pmdm_selected_post_types = get_option( 'pmdm_selected_post_types' ); 48 49 if ( class_exists( OrderUtil::class ) && class_exists( CustomOrdersTableController::class ) ) { 50 51 if ( OrderUtil::custom_orders_table_usage_is_enabled() && isset( $_GET['page'] ) && $_GET['page'] == 'wc-orders' ) { 52 53 if ( ! $post->get_id() ) { 50 $pmdm_selected_post_types = get_option('pmdm_selected_post_types'); 51 52 if (class_exists(OrderUtil::class) && class_exists(CustomOrdersTableController::class)) { 53 if (OrderUtil::custom_orders_table_usage_is_enabled() && isset($_GET['page']) && $_GET['page'] == 'wc-orders') { 54 if (! $post->get_id()) { 54 55 return; 55 56 } 56 57 57 if ( ! current_user_can( 'edit_post', $post->get_id() )) {58 if (! current_user_can('edit_post', $post->get_id())) { 58 59 return; 59 60 } 60 if ( $post_type == 'woocommerce_page_wc-orders' && $_GET['action'] != 'edit') { // HPOS61 if ($post_type == 'woocommerce_page_wc-orders' && $_GET['action'] != 'edit') { // HPOS 61 62 return; 62 63 } 63 64 $pmdm_selected_post_types[] = 'woocommerce_page_wc-orders'; 64 65 65 if ( in_array( $post_type, $pmdm_selected_post_types ) ) { 66 66 if (in_array($post_type, $pmdm_selected_post_types)) { 67 67 $metabox_screen = wc_get_container()->get( 68 68 CustomOrdersTableController::class 69 69 )->custom_orders_table_usage_is_enabled() 70 ? wc_get_page_screen_id( 'shop-order')70 ? wc_get_page_screen_id('shop-order') 71 71 : 'shop_order'; 72 72 73 add_meta_box( $metabox_id, $metabox_title, array( $this, 'pmdm_wp_display_post_metadata' ), $metabox_screen, $metabox_context, $metabox_priority, array());73 add_meta_box($metabox_id, $metabox_title, array( $this, 'pmdm_wp_display_post_metadata' ), $metabox_screen, $metabox_context, $metabox_priority, array()); 74 74 } 75 75 } else { 76 if ( isset( $current_screen->action ) && $current_screen->action == 'add') { // check new post76 if (isset($current_screen->action) && $current_screen->action == 'add') { // check new post 77 77 return; 78 78 } 79 if ( ! $post->ID) {79 if (! $post->ID) { 80 80 return; 81 81 } 82 82 83 if ( ! current_user_can( 'edit_post', $post->ID )) {83 if (! current_user_can('edit_post', $post->ID)) { 84 84 return; 85 85 } 86 if ( empty( $pmdm_selected_post_types )) {86 if (empty($pmdm_selected_post_types)) { 87 87 $pmdm_selected_post_types = array( 88 88 'post', … … 94 94 } 95 95 96 if ( in_array( $post_type, $pmdm_selected_post_types )) {97 add_meta_box( $metabox_id, $metabox_title, array( $this, 'pmdm_wp_display_post_metadata' ), $metabox_screen, $metabox_context, $metabox_priority, array());96 if (in_array($post_type, $pmdm_selected_post_types)) { 97 add_meta_box($metabox_id, $metabox_title, array( $this, 'pmdm_wp_display_post_metadata' ), $metabox_screen, $metabox_context, $metabox_priority, array()); 98 98 } 99 99 } 100 100 } else { 101 102 if ( isset( $current_screen->action ) && $current_screen->action == 'add' ) { // check new post 101 if (isset($current_screen->action) && $current_screen->action == 'add') { // check new post 103 102 return; 104 103 } 105 if ( ! $post->ID) {104 if (! $post->ID) { 106 105 return; 107 106 } 108 107 109 if ( ! current_user_can( 'edit_post', $post->ID )) {108 if (! current_user_can('edit_post', $post->ID)) { 110 109 return; 111 110 } 112 if ( empty( $pmdm_selected_post_types )) {111 if (empty($pmdm_selected_post_types)) { 113 112 $pmdm_selected_post_types = array( 114 113 'post', … … 119 118 ); 120 119 } 121 if ( in_array( $post_type, $pmdm_selected_post_types )) {122 add_meta_box( $metabox_id, $metabox_title, array( $this, 'pmdm_wp_display_post_metadata' ), $metabox_screen, $metabox_context, $metabox_priority, array());120 if (in_array($post_type, $pmdm_selected_post_types)) { 121 add_meta_box($metabox_id, $metabox_title, array( $this, 'pmdm_wp_display_post_metadata' ), $metabox_screen, $metabox_context, $metabox_priority, array()); 123 122 } 124 123 } … … 132 131 * @since 1.0 133 132 */ 134 public function pmdm_wp_display_post_metadata( $post ) { 133 public function pmdm_wp_display_post_metadata($post) 134 { 135 135 136 136 $post_meta = array(); 137 137 138 if ( class_exists( OrderUtil::class ) ) { 139 140 if ( OrderUtil::custom_orders_table_usage_is_enabled() && isset( $_GET['page'] ) && $_GET['page'] == 'wc-orders' ) { 141 if ( ! $post->get_id() ) { 138 if (class_exists(OrderUtil::class)) { 139 if (OrderUtil::custom_orders_table_usage_is_enabled() && isset($_GET['page']) && $_GET['page'] == 'wc-orders') { 140 if (! $post->get_id()) { 142 141 return; 143 142 } 144 $order = wc_get_order( $post->get_id());145 146 if ( $order) { // HPOS143 $order = wc_get_order($post->get_id()); 144 145 if ($order) { // HPOS 147 146 $order_meta = $order->get_meta_data(); 148 if ( ! empty( $order_meta )) {149 foreach ( $order_meta as $meta_data) {147 if (! empty($order_meta)) { 148 foreach ($order_meta as $meta_data) { 150 149 $post_meta[ $meta_data->key ] = $meta_data->value; 151 150 } 152 151 } 152 153 $date_paid = $order->get_date_paid('edit'); 154 if ($date_paid) { 155 $post_meta[ "date_paid" ] = $date_paid->date("Y-m-d H:i:s"); 156 } 153 157 } 154 158 } else { 155 if ( ! $post->ID) {159 if (! $post->ID) { 156 160 return; 157 161 } 158 $post_meta = get_post_meta( $post->ID ); 159 162 $post_meta = get_post_meta($post->ID); 160 163 } 161 164 } else { 162 if ( ! $post->ID) {165 if (! $post->ID) { 163 166 return; 164 167 } 165 $post_meta = get_post_meta( $post->ID ); 166 168 $post_meta = get_post_meta($post->ID); 167 169 } 168 170 … … 179 181 * @since 1.0 180 182 */ 181 public function pmdm_wp_ajax_delete_meta() {182 if ( isset( $_POST ) && ! empty( $_POST['post_id'] ) && $_POST['meta_id'] && current_user_can( 'administrator' ) && wp_verify_nonce( $_POST['security'], 'ajax-security' ) ){183 183 public function pmdm_wp_ajax_delete_meta() 184 { 185 if (isset($_POST) && ! empty($_POST['post_id']) && $_POST['meta_id'] && current_user_can('administrator') && wp_verify_nonce($_POST['security'], 'ajax-security')) { 184 186 $meta_value = ''; 185 $post_id = intval( $_POST['post_id'] ); 186 $meta_id = esc_html( $_POST['meta_id'] ); 187 188 if ( class_exists( OrderUtil::class ) ) { 189 190 $order = wc_get_order( $post_id ); 191 if ( OrderUtil::custom_orders_table_usage_is_enabled() && $order ) { 192 187 $post_id = intval($_POST['post_id']); 188 $meta_id = esc_html($_POST['meta_id']); 189 $post_type = get_post_type($post_id); 190 191 $is_hpos = false; 192 if (class_exists(OrderUtil::class) && $post_type == "shop_order") { 193 if (OrderUtil::custom_orders_table_usage_is_enabled()) { 194 $is_hpos = true; 195 } 196 } 197 198 if ($is_hpos) { 199 $order = wc_get_order($post_id); 200 if ($order) { 193 201 // HPOS 194 if ( $order) {195 $meta_value = $order->get_meta( $meta_id, true);196 } 197 198 if ( empty( $meta_value ) && $meta_value != '0') {202 if ($order) { 203 $meta_value = $order->get_meta($meta_id, true); 204 } 205 206 if (empty($meta_value) && $meta_value != '0') { 199 207 wp_send_json_error( 200 array( 'msg' => esc_html__( 'You have enter incorrect meta_id ! Please try again', 'pmdm_wp') )208 array( 'msg' => esc_html__('You have enter incorrect meta_id ! Please try again', 'pmdm_wp') ) 201 209 ); 202 210 } 203 211 204 if ( $order) { // HPOS205 $order->delete_meta_data( $meta_id);212 if ($order) { // HPOS 213 $order->delete_meta_data($meta_id); 206 214 $order->save_meta_data(); 215 wp_send_json_success( 216 array( 'msg' => esc_html__('Meta successfully deleted', 'pmdm_wp') ) 217 ); 207 218 } 208 219 } 209 220 } else { 210 $meta_value = get_post_meta( $post_id, $meta_id, true);211 212 if ( empty( $meta_value ) && $meta_value != '0') {221 $meta_value = get_post_meta($post_id, $meta_id, true); 222 223 if (empty($meta_value) && $meta_value != '0') { 213 224 wp_send_json_error( 214 array( 'msg' => esc_html__( 'You have enter incorrect meta_id ! Please try again', 'pmdm_wp') )225 array( 'msg' => esc_html__('You have enter incorrect meta_id ! Please try again', 'pmdm_wp') ) 215 226 ); 216 227 } 217 228 218 delete_post_meta( $post_id, $meta_id);229 delete_post_meta($post_id, $meta_id); 219 230 220 231 wp_send_json_success( 221 array( 'msg' => esc_html__( 'Meta successfully deleted', 'pmdm_wp') )232 array( 'msg' => esc_html__('Meta successfully deleted', 'pmdm_wp') ) 222 233 ); 223 234 } 224 235 } else { 225 236 wp_send_json_error( 226 array( 'msg' => esc_html__( 'There is something worong! Please try again', 'pmdm_wp') )237 array( 'msg' => esc_html__('There is something worong! Please try again', 'pmdm_wp') ) 227 238 ); 228 239 } … … 237 248 * @since 1.0.2 238 249 */ 239 public function pmdm_wp_delete_user_meta() {240 if ( isset( $_POST ) && ! empty( $_POST['user_ID'] ) && $_POST['meta_id'] && current_user_can( 'administrator' ) && wp_verify_nonce( $_POST['security'], 'ajax-security' ) ){241 242 $user_ID = intval( $_POST['user_ID']);243 $meta_id = esc_html( $_POST['meta_id']);244 245 $user_meta_value = get_user_meta( $user_ID, $meta_id, true);246 247 if ( empty( $user_meta_value ) && $user_meta_value != '0') {250 public function pmdm_wp_delete_user_meta() 251 { 252 if (isset($_POST) && ! empty($_POST['user_ID']) && $_POST['meta_id'] && current_user_can('administrator') && wp_verify_nonce($_POST['security'], 'ajax-security')) { 253 $user_ID = intval($_POST['user_ID']); 254 $meta_id = esc_html($_POST['meta_id']); 255 256 $user_meta_value = get_user_meta($user_ID, $meta_id, true); 257 258 if (empty($user_meta_value) && $user_meta_value != '0') { 248 259 wp_send_json_error( 249 array( 'msg' => esc_html__( 'You have enter incorrect meta_id ! Please try again', 'pmdm_wp') )260 array( 'msg' => esc_html__('You have enter incorrect meta_id ! Please try again', 'pmdm_wp') ) 250 261 ); 251 262 } 252 263 253 delete_user_meta( $user_ID, $meta_id);264 delete_user_meta($user_ID, $meta_id); 254 265 255 266 wp_send_json_success( 256 array( 'msg' => esc_html__( 'Meta successfully deleted', 'pmdm_wp') )267 array( 'msg' => esc_html__('Meta successfully deleted', 'pmdm_wp') ) 257 268 ); 258 269 } else { 259 270 wp_send_json_error( 260 array( 'msg' => esc_html__( 'There is something worong! Please try again', 'pmdm_wp') )271 array( 'msg' => esc_html__('There is something worong! Please try again', 'pmdm_wp') ) 261 272 ); 262 273 } … … 271 282 * @since 1.0 272 283 */ 273 public function pmdm_wp_get_recursively_inputs( $meta_main_key, $get_meta_field_values, $level_key = array() ) { 274 275 if ( is_array( $get_meta_field_values ) ) { 284 public function pmdm_wp_get_recursively_inputs($meta_main_key, $get_meta_field_values, $level_key = array()) 285 { 286 287 if (is_array($get_meta_field_values)) { 276 288 $is_editable = true; 277 foreach ( $get_meta_field_values as $gmfvk => $gmfvv ) { 278 279 if ( is_array( $gmfvv ) ) { 280 $store_keys = array_merge( $level_key, array( $gmfvk ) ); 281 $this->pmdm_wp_get_recursively_inputs( $meta_main_key, $gmfvv, $store_keys ); 282 } elseif ( is_string( $gmfvv ) ) { 289 foreach ($get_meta_field_values as $gmfvk => $gmfvv) { 290 if (is_array($gmfvv)) { 291 $store_keys = array_merge($level_key, array( $gmfvk )); 292 $this->pmdm_wp_get_recursively_inputs($meta_main_key, $gmfvv, $store_keys); 293 } elseif (is_string($gmfvv)) { 283 294 $input_name = $meta_main_key; 284 295 285 296 $display_label = $meta_main_key; 286 297 287 if ( ! empty( $level_key )) {288 foreach ( $level_key as $skk) {298 if (! empty($level_key)) { 299 foreach ($level_key as $skk) { 289 300 $input_name .= '[' . $skk . ']'; 290 301 $display_label .= '=>' . $skk; … … 295 306 ?> 296 307 <div class="input_wrapper input_wrapper_arr"> 297 <p class="display_label_key">Key: <strong><?php echo esc_html( $display_label); ?></strong></p>298 <input type="text" name="<?php echo $input_name; ?>" class="input_box" value="<?php echo htmlentities( $gmfvv, ENT_QUOTES); ?>" />308 <p class="display_label_key">Key: <strong><?php echo esc_html($display_label); ?></strong></p> 309 <input type="text" name="<?php echo $input_name; ?>" class="input_box" value="<?php echo htmlentities($gmfvv, ENT_QUOTES); ?>" /> 299 310 </div> 300 311 <?php … … 303 314 } 304 315 } 305 if ( ! $is_editable) {306 esc_html_e( 'This key contains some object information. So it\'s not editable.', 'pmdm_wp');316 if (! $is_editable) { 317 esc_html_e('This key contains some object information. So it\'s not editable.', 'pmdm_wp'); 307 318 } 308 319 } else { 309 320 ?> 310 <input type="text" name="<?php echo $meta_main_key; ?>" value="<?php echo htmlentities( $get_meta_field_values, ENT_QUOTES); ?>" /> <br />321 <input type="text" name="<?php echo $meta_main_key; ?>" value="<?php echo htmlentities($get_meta_field_values, ENT_QUOTES); ?>" /> <br /> 311 322 <?php 312 323 } … … 320 331 * @since 1.0 321 332 */ 322 public function pmdm_wp_change_post_meta() { 323 324 if ( isset( $_POST['change_post_meta_field'] ) && wp_verify_nonce( $_POST['change_post_meta_field'], 'change_post_meta_action' ) && current_user_can( 'administrator' ) ) { 325 326 if ( ! empty( $_POST ) ) { 327 foreach ( $_POST as $pk => $pv ) { 328 329 if ( $pk == 'change_post_meta_field' || $pk == '_wp_http_referer' || $pk == 'current_post_id' ) { 333 public function pmdm_wp_change_post_meta() 334 { 335 336 if (isset($_POST['change_post_meta_field']) && wp_verify_nonce($_POST['change_post_meta_field'], 'change_post_meta_action') && current_user_can('administrator')) { 337 if (! empty($_POST)) { 338 $is_hpos = false; 339 if (class_exists(OrderUtil::class) && isset($_GET['page']) && $_GET['page'] == 'wc-orders') { 340 if (OrderUtil::custom_orders_table_usage_is_enabled()) { 341 $is_hpos = true; 342 } 343 } 344 345 foreach ($_POST as $pk => $pv) { 346 if ($pk == 'change_post_meta_field' || $pk == '_wp_http_referer' || $pk == 'current_post_id') { 330 347 continue; 331 348 } 332 349 333 if ( isset( $_POST['changed_keys'] ) && $pk == $_POST['changed_keys'] ) { 334 335 if ( class_exists( OrderUtil::class ) ) { 336 337 if ( OrderUtil::custom_orders_table_usage_is_enabled() && isset( $_GET['page'] ) && $_GET['page'] == 'wc-orders' ) { 338 339 $order = wc_get_order( $_POST['current_post_id'] ); 340 341 $is_meta_exists = $order->get_meta( $pk, true ); 342 343 if ( ! empty( $is_meta_exists ) ) { 344 if ( is_array( $pv ) ) { 345 $pv = $this->pmdm_wp_escape_slashes_deep( $pv ); 346 } else { 347 $pv = wp_kses_post( $pv ); 348 } 349 $order->update_meta_data( $pk, $pv ); 350 $order->save(); 351 350 if (isset($_POST['changed_keys']) && $pk == $_POST['changed_keys']) { 351 if ($is_hpos) { 352 $order = wc_get_order($_POST['current_post_id']); 353 354 $is_meta_exists = $order->get_meta($pk, true); 355 if ($pk == "date_paid") { 356 $pv = wp_kses_post($pv); 357 $order->set_date_paid(strtotime($pv)); 358 $order->save(); 359 } 360 if (! empty($is_meta_exists)) { 361 if (is_array($pv)) { 362 $pv = $this->pmdm_wp_escape_slashes_deep($pv); 363 } else { 364 $pv = wp_kses_post($pv); 365 } 366 $order->update_meta_data($pk, $pv); 367 368 $order->save(); 369 } 370 } else { 371 $is_meta_exists = get_post_meta(intval($_POST['current_post_id']), $pk, true); 372 if (! empty($is_meta_exists)) { 373 if (is_array($pv)) { 374 $pv = $this->pmdm_wp_escape_slashes_deep($pv); 375 } else { 376 $pv = wp_kses_post($pv); 352 377 } 353 } 354 } else { 355 356 $is_meta_exists = get_post_meta( intval( $_POST['current_post_id'] ), $pk, true ); 357 if ( ! empty( $is_meta_exists ) ) { 358 if ( is_array( $pv ) ) { 359 $pv = $this->pmdm_wp_escape_slashes_deep( $pv ); 378 379 if (( $pk == 'product_ids' || $pk == 'exclude_product_ids' ) && isset($_POST['post_type']) && $_POST['post_type'] == 'shop_coupon') { 380 $product_ids = implode(',', $pv); 381 update_post_meta(intval($_POST['current_post_id']), $pk, $product_ids); 360 382 } else { 361 $pv = wp_kses_post( $pv ); 362 } 363 364 if ( ( $pk == 'product_ids' || $pk == 'exclude_product_ids' ) && isset( $_POST['post_type'] ) && $_POST['post_type'] == 'shop_coupon' ) { 365 366 $product_ids = implode( ',', $pv ); 367 update_post_meta( intval( $_POST['current_post_id'] ), $pk, $product_ids ); 368 369 } else { 370 update_post_meta( intval( $_POST['current_post_id'] ), $pk, $pv ); 383 update_post_meta(intval($_POST['current_post_id']), $pk, $pv); 371 384 } 372 385 } … … 384 397 * @since 1.0.2 385 398 */ 386 public function pmdm_wp_change_user_meta() { 387 388 if ( isset( $_POST['change_user_meta_field'] ) && wp_verify_nonce( $_POST['change_user_meta_field'], 'change_user_meta_action' ) && current_user_can( 'administrator' ) ) { 389 390 if ( ! empty( $_POST ) ) { 391 392 foreach ( $_POST as $pk => $pv ) { 393 if ( $pk == 'change_user_meta_field' || $pk == '_wp_http_referer' || $pk == 'current_user_id' ) { 399 public function pmdm_wp_change_user_meta() 400 { 401 402 if (isset($_POST['change_user_meta_field']) && wp_verify_nonce($_POST['change_user_meta_field'], 'change_user_meta_action') && current_user_can('administrator')) { 403 if (! empty($_POST)) { 404 foreach ($_POST as $pk => $pv) { 405 if ($pk == 'change_user_meta_field' || $pk == '_wp_http_referer' || $pk == 'current_user_id') { 394 406 continue; 395 407 } 396 if ( isset( $_POST['changed_keys'] ) && $pk == $_POST['changed_keys']) {397 if ( is_array( $pv )) {398 $pv = $this->pmdm_wp_escape_slashes_deep( $pv);408 if (isset($_POST['changed_keys']) && $pk == $_POST['changed_keys']) { 409 if (is_array($pv)) { 410 $pv = $this->pmdm_wp_escape_slashes_deep($pv); 399 411 } else { 400 $pv = wp_kses_post( $pv);412 $pv = wp_kses_post($pv); 401 413 } 402 414 403 update_user_meta( intval( $_POST['current_user_id'] ), $pk, $pv);415 update_user_meta(intval($_POST['current_user_id']), $pk, $pv); 404 416 } 405 417 } … … 414 426 * @since 1.0 415 427 */ 416 public function pmdm_wp_escape_slashes_deep( $data = array(), $flag = false, $limited = false ) { 417 418 if ( $flag != true ) { 419 420 $data = $this->pmdm_wp_nohtml_kses( $data ); 421 } elseif ( $limited == true ) { 422 423 $data = wp_kses_post( $data ); 424 } 425 $data = stripslashes_deep( $data ); 428 public function pmdm_wp_escape_slashes_deep($data = array(), $flag = false, $limited = false) 429 { 430 431 if ($flag != true) { 432 $data = $this->pmdm_wp_nohtml_kses($data); 433 } elseif ($limited == true) { 434 $data = wp_kses_post($data); 435 } 436 $data = stripslashes_deep($data); 426 437 return $data; 427 438 } … … 435 446 * @since 1.0 436 447 */ 437 public function pmdm_wp_nohtml_kses( $data = array() ) { 438 439 if ( is_array( $data ) ) { 440 441 $data = array_map( array( $this, 'pmdm_wp_nohtml_kses' ), $data ); 442 } elseif ( is_string( $data ) ) { 443 444 $data = wp_kses_post( $data ); 448 public function pmdm_wp_nohtml_kses($data = array()) 449 { 450 451 if (is_array($data)) { 452 $data = array_map(array( $this, 'pmdm_wp_nohtml_kses' ), $data); 453 } elseif (is_string($data)) { 454 $data = wp_kses_post($data); 445 455 } 446 456 … … 454 464 * @since 1.0.2 455 465 */ 456 public function pmdm_wp_user_metadata_box( $user ) { 466 public function pmdm_wp_user_metadata_box($user) 467 { 457 468 global $current_screen; 458 if ( ( $current_screen->id == 'user-edit' ) || ( $current_screen->id == 'profile' )) {459 $user_meta = get_user_meta( $user->ID);469 if (( $current_screen->id == 'user-edit' ) || ( $current_screen->id == 'profile' )) { 470 $user_meta = get_user_meta($user->ID); 460 471 461 472 require_once PMDM_WP_ADMIN_DIR . '/html/pmdm_wp_display_user_metadata_html.php'; … … 469 480 * @since 1.0.3 470 481 */ 471 public function pmdm_wp_taxonomy_metadata_box( $term ) { 472 473 $term_meta = get_term_meta( $term->term_id ); 482 public function pmdm_wp_taxonomy_metadata_box($term) 483 { 484 485 $term_meta = get_term_meta($term->term_id); 474 486 // update_term_meta 475 487 // delete_term_meta … … 483 495 * @since 1.0.3 484 496 */ 485 public function pmdm_add_html_for_all_taxonomy() { 497 public function pmdm_add_html_for_all_taxonomy() 498 { 486 499 $all_taxonomies = get_taxonomies(); 487 $pmdm_selected_taxonomies = get_option( 'pmdm_selected_taxonomies');488 if ( empty( $pmdm_selected_taxonomies )) {500 $pmdm_selected_taxonomies = get_option('pmdm_selected_taxonomies'); 501 if (empty($pmdm_selected_taxonomies)) { 489 502 $pmdm_selected_taxonomies = array( 490 503 'category', … … 494 507 ); 495 508 } 496 if ( ! empty( $all_taxonomies )) {497 foreach ( $all_taxonomies as $taxk => $taxv) {498 if ( in_array( $taxk, $pmdm_selected_taxonomies )) {499 add_action( $taxk . '_edit_form', array( $this, 'pmdm_wp_taxonomy_metadata_box' ), 99);509 if (! empty($all_taxonomies)) { 510 foreach ($all_taxonomies as $taxk => $taxv) { 511 if (in_array($taxk, $pmdm_selected_taxonomies)) { 512 add_action($taxk . '_edit_form', array( $this, 'pmdm_wp_taxonomy_metadata_box' ), 99); 500 513 } 501 514 } … … 510 523 * @since 1.0.3 511 524 */ 512 public function pmdm_wp_change_taxonomy_meta() {513 514 if ( isset( $_POST['change_term_meta_field'] ) && wp_verify_nonce( $_POST['change_term_meta_field'], 'change_term_meta_action' ) && current_user_can( 'administrator' ) ) { 515 if ( ! empty( $_POST )) {516 525 public function pmdm_wp_change_taxonomy_meta() 526 { 527 528 if (isset($_POST['change_term_meta_field']) && wp_verify_nonce($_POST['change_term_meta_field'], 'change_term_meta_action') && current_user_can('administrator')) { 529 if (! empty($_POST)) { 517 530 $disallow_term_key_array = apply_filters( 518 531 PMDM_WP_PREFIX . '_disallow_term_keys', … … 535 548 ) 536 549 ); 537 foreach ( $_POST as $pk => $pv) {538 if ( in_array( $pk, $disallow_term_key_array )) {550 foreach ($_POST as $pk => $pv) { 551 if (in_array($pk, $disallow_term_key_array)) { 539 552 continue; 540 553 } 541 if ( isset( $_POST['changed_keys'] ) && $pk == $_POST['changed_keys']) {542 if ( is_array( $pv )) {543 $pv = $this->pmdm_wp_escape_slashes_deep( $pv);554 if (isset($_POST['changed_keys']) && $pk == $_POST['changed_keys']) { 555 if (is_array($pv)) { 556 $pv = $this->pmdm_wp_escape_slashes_deep($pv); 544 557 } else { 545 $pv = wp_kses_post( $pv);558 $pv = wp_kses_post($pv); 546 559 } 547 560 548 update_term_meta( intval( $_POST['current_term_id'] ), $pk, $pv);561 update_term_meta(intval($_POST['current_term_id']), $pk, $pv); 549 562 } 550 563 } … … 565 578 * @since 1.0.3 566 579 */ 567 public function pmdm_wp_delete_term_meta() {568 if ( isset( $_POST ) && ! empty( $_POST['term_id'] ) && $_POST['meta_id'] && current_user_can( 'administrator' ) && wp_verify_nonce( $_POST['security'], 'ajax-security' ) ){569 580 public function pmdm_wp_delete_term_meta() 581 { 582 if (isset($_POST) && ! empty($_POST['term_id']) && $_POST['meta_id'] && current_user_can('administrator') && wp_verify_nonce($_POST['security'], 'ajax-security')) { 570 583 $term_value = ''; 571 $term_id = intval( $_POST['term_id']);572 $meta_id = esc_html( $_POST['meta_id']);573 574 $term_value = get_term_meta( $term_id, $meta_id, true);575 576 if ( empty( $term_value ) && $term_value != '0') {584 $term_id = intval($_POST['term_id']); 585 $meta_id = esc_html($_POST['meta_id']); 586 587 $term_value = get_term_meta($term_id, $meta_id, true); 588 589 if (empty($term_value) && $term_value != '0') { 577 590 wp_send_json_error( 578 array( 'msg' => esc_html__( 'You have enter incorrect meta_id ! Please try again', 'pmdm_wp') )591 array( 'msg' => esc_html__('You have enter incorrect meta_id ! Please try again', 'pmdm_wp') ) 579 592 ); 580 593 } 581 594 582 delete_term_meta( $term_id, $meta_id);595 delete_term_meta($term_id, $meta_id); 583 596 584 597 wp_send_json_success( 585 array( 'msg' => esc_html__( 'Meta successfully deleted', 'pmdm_wp') )598 array( 'msg' => esc_html__('Meta successfully deleted', 'pmdm_wp') ) 586 599 ); 587 600 } else { 588 601 wp_send_json_error( 589 array( 'msg' => esc_html__( 'There is something worong! Please try again', 'pmdm_wp') )602 array( 'msg' => esc_html__('There is something worong! Please try again', 'pmdm_wp') ) 590 603 ); 591 604 } … … 594 607 } 595 608 596 public function pmdm_admin_menus() { 609 public function pmdm_admin_menus() 610 { 597 611 $parent_page_slug = 'pmdm-general-settings'; 598 612 add_menu_page( 599 esc_html__( 'PMDM Settings', 'pmdm_wp'),600 esc_html__( 'PMDM Settings', 'pmdm_wp'),613 esc_html__('PMDM Settings', 'pmdm_wp'), 614 esc_html__('PMDM Settings', 'pmdm_wp'), 601 615 'manage_options', 602 616 $parent_page_slug, … … 605 619 add_submenu_page( 606 620 $parent_page_slug, 607 esc_html__( 'Help', 'pmdm_wp'),608 esc_html__( 'Help', 'pmdm_wp'),621 esc_html__('Help', 'pmdm_wp'), 622 esc_html__('Help', 'pmdm_wp'), 609 623 'manage_options', 610 624 'pmdm-help', … … 613 627 } 614 628 615 public function pmdm_general_settings_cb() { 629 public function pmdm_general_settings_cb() 630 { 616 631 require_once PMDM_WP_ADMIN_DIR . '/html/pmdm_general_settings_html.php'; 617 632 } 618 public function pmdm_help_cb() { 633 public function pmdm_help_cb() 634 { 619 635 require_once PMDM_WP_ADMIN_DIR . '/html/pmdm_help_html.php'; 620 636 } 621 637 622 public function pmdm_register_general_settings_cb() { 623 register_setting( 'pmdm_general_settings_group', 'pmdm_selected_post_types' ); 624 register_setting( 'pmdm_general_settings_group', 'pmdm_selected_taxonomies' ); 625 } 626 627 public function pmdm_hpos_declare_compatibility() { 628 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { 629 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', PMDM_WP_PLUGIN_MAIN_FILE_PATH, true ); 638 public function pmdm_register_general_settings_cb() 639 { 640 register_setting('pmdm_general_settings_group', 'pmdm_selected_post_types'); 641 register_setting('pmdm_general_settings_group', 'pmdm_selected_taxonomies'); 642 } 643 644 public function pmdm_hpos_declare_compatibility() 645 { 646 if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) { 647 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', PMDM_WP_PLUGIN_MAIN_FILE_PATH, true); 630 648 } 631 649 } … … 637 655 * @since 1.0 638 656 */ 639 public function add_hooks() { 657 public function add_hooks() 658 { 640 659 641 660 // post details page hooks 642 add_action( 'add_meta_boxes', array( $this, 'pmdm_wp_add_meta_boxes' ), 1000, 2);643 add_action( 'admin_init', array( $this, 'pmdm_wp_change_post_meta' ), 10);644 645 add_action( 'wp_ajax_pmdm_wp_delete_meta', array( $this, 'pmdm_wp_ajax_delete_meta' ));661 add_action('add_meta_boxes', array( $this, 'pmdm_wp_add_meta_boxes' ), 1000, 2); 662 add_action('admin_init', array( $this, 'pmdm_wp_change_post_meta' ), 10); 663 664 add_action('wp_ajax_pmdm_wp_delete_meta', array( $this, 'pmdm_wp_ajax_delete_meta' )); 646 665 647 666 // user details page hooks 648 add_action( 'edit_user_profile', array( $this, 'pmdm_wp_user_metadata_box' ), 99);649 add_action( 'show_user_profile', array( $this, 'pmdm_wp_user_metadata_box' ), 99);650 add_action( 'admin_init', array( $this, 'pmdm_wp_change_user_meta' ), 11);651 add_action( 'wp_ajax_pmdm_wp_delete_user_meta', array( $this, 'pmdm_wp_delete_user_meta' ));667 add_action('edit_user_profile', array( $this, 'pmdm_wp_user_metadata_box' ), 99); 668 add_action('show_user_profile', array( $this, 'pmdm_wp_user_metadata_box' ), 99); 669 add_action('admin_init', array( $this, 'pmdm_wp_change_user_meta' ), 11); 670 add_action('wp_ajax_pmdm_wp_delete_user_meta', array( $this, 'pmdm_wp_delete_user_meta' )); 652 671 653 672 // taxonomy details page hooks 654 add_action( 'admin_init', array( $this, 'pmdm_add_html_for_all_taxonomy' ), 99);655 add_action( 'admin_init', array( $this, 'pmdm_wp_change_taxonomy_meta' ), 12);656 add_action( 'wp_ajax_pmdm_wp_delete_term_meta', array( $this, 'pmdm_wp_delete_term_meta' ));657 658 add_action( 'admin_menu', array( $this, 'pmdm_admin_menus' ), 10);659 add_action( 'admin_init', array( $this, 'pmdm_register_general_settings_cb' ));660 661 add_action( 'before_woocommerce_init', array( $this, 'pmdm_hpos_declare_compatibility' ));673 add_action('admin_init', array( $this, 'pmdm_add_html_for_all_taxonomy' ), 99); 674 add_action('admin_init', array( $this, 'pmdm_wp_change_taxonomy_meta' ), 12); 675 add_action('wp_ajax_pmdm_wp_delete_term_meta', array( $this, 'pmdm_wp_delete_term_meta' )); 676 677 add_action('admin_menu', array( $this, 'pmdm_admin_menus' ), 10); 678 add_action('admin_init', array( $this, 'pmdm_register_general_settings_cb' )); 679 680 add_action('before_woocommerce_init', array( $this, 'pmdm_hpos_declare_compatibility' )); 662 681 } 663 682 } -
post-meta-data-manager/trunk/includes/admin/html/pmdm_wp_display_post_metadata_html.php
r3115396 r3153871 1 1 <?php 2 2 // Exit if accessed directly 3 if ( ! defined( 'ABSPATH' )) {3 if (! defined('ABSPATH')) { 4 4 exit; 5 5 } … … 14 14 <thead> 15 15 <tr> 16 <th><?php echo esc_html__( 'Key', 'pmdm_wp'); ?></th>17 <th><?php echo esc_html__( 'Value', 'pmdm_wp'); ?></th>18 <th><?php echo esc_html__( 'Action', 'pmdm_wp'); ?></th>16 <th><?php echo esc_html__('Key', 'pmdm_wp'); ?></th> 17 <th><?php echo esc_html__('Value', 'pmdm_wp'); ?></th> 18 <th><?php echo esc_html__('Action', 'pmdm_wp'); ?></th> 19 19 </tr> 20 20 </thead> … … 22 22 <?php 23 23 24 foreach ( $post_meta as $meta_key => $value) {25 if ( is_array( $value )) {26 foreach ( $value as $num => $el) {27 $value[ $num ] = maybe_unserialize( $el);24 foreach ($post_meta as $meta_key => $value) { 25 if (is_array($value)) { 26 foreach ($value as $num => $el) { 27 $value[ $num ] = maybe_unserialize($el); 28 28 } 29 29 } else { … … 31 31 } 32 32 33 $is_added = isset( $post_meta[ $meta_key ]) ? false : true;33 $is_added = isset($post_meta[ $meta_key ]) ? false : true; 34 34 35 if ( isset( $_GET['page'] ) && $_GET['page'] == 'wc-orders' ) { // HPOS 36 $order = wc_get_order( $post->get_id() ); 37 $get_meta_field_values = $order->get_meta( $meta_key, true ); 35 if (isset($_GET['page']) && $_GET['page'] == 'wc-orders') { // HPOS 36 $order = wc_get_order($post->get_id()); 37 $get_meta_field_values = $order->get_meta($meta_key, true); 38 if ($meta_key == "date_paid") { 39 $date_paid = $order->get_date_paid('edit'); 40 41 if ($date_paid) { 42 $get_meta_field_values = $date_paid->date("Y-m-d H:i:s"); 43 } 44 } 38 45 } else { 39 $get_meta_field_values = get_post_meta( $post->ID, $meta_key, true);46 $get_meta_field_values = get_post_meta($post->ID, $meta_key, true); 40 47 } 41 48 … … 43 50 ?> 44 51 <tr> 45 <td><?php echo esc_html( $meta_key); ?></td>46 <td><?php echo esc_html( var_export( $value, true )); ?></td>52 <td><?php echo esc_html($meta_key); ?></td> 53 <td><?php echo esc_html(var_export($value, true)); ?></td> 47 54 <td> 48 <a href="javascript:;" data-id="<?php echo esc_html( $meta_key ); ?>" id="edit-<?php echo esc_html( $meta_key ); ?>" class="edit-meta"><?php echo esc_html__( 'Edit', 'pmdm_wp'); ?></a>55 <a href="javascript:;" data-id="<?php echo esc_html($meta_key); ?>" id="edit-<?php echo esc_html($meta_key); ?>" class="edit-meta"><?php echo esc_html__('Edit', 'pmdm_wp'); ?></a> 49 56 50 57 <div id="javascript:;" class="modal-window"> 51 58 <div> 52 59 <a href="javascript:;" title="Close" class="modal-close">x</a> 53 <h1><strong><?php echo esc_html__( 'Currently you are editing', 'pmdm_wp' ); ?></strong>: <?php echo esc_html( $meta_key); ?></h1>60 <h1><strong><?php echo esc_html__('Currently you are editing', 'pmdm_wp'); ?></strong>: <?php echo esc_html($meta_key); ?></h1> 54 61 <div class="model-body"> 55 62 <form method="post" action=""> 56 <?php wp_nonce_field( 'change_post_meta_action', 'change_post_meta_field'); ?>63 <?php wp_nonce_field('change_post_meta_action', 'change_post_meta_field'); ?> 57 64 58 65 <?php 59 66 60 if ( is_array( $get_meta_field_values ) ) { 61 62 $this->pmdm_wp_get_recursively_inputs( $meta_key, $get_meta_field_values ); 63 67 if (is_array($get_meta_field_values)) { 68 $this->pmdm_wp_get_recursively_inputs($meta_key, $get_meta_field_values); 64 69 } else { 65 66 $get_meta_field_values_len = strlen( $get_meta_field_values ); 70 $get_meta_field_values_len = strlen($get_meta_field_values); 67 71 ?> 68 72 <div class="input_wrapper"> 69 <p class="display_label_key">Key: <strong><?php echo esc_html( $meta_key); ?></strong></p>73 <p class="display_label_key">Key: <strong><?php echo esc_html($meta_key); ?></strong></p> 70 74 71 <?php if ( $get_meta_field_values_len > 20) { ?>72 <textarea name="<?php echo esc_html( $meta_key ); ?>" rows="10"><?php echo htmlspecialchars( $get_meta_field_values, ENT_QUOTES); ?></textarea>73 <?php } else { ?>74 <input type="text" name="<?php echo esc_html( $meta_key ); ?>" class="input_box" value="<?php echo htmlspecialchars( $get_meta_field_values, ENT_QUOTES); ?>" />75 <?php } ?>75 <?php if ($get_meta_field_values_len > 20) { ?> 76 <textarea name="<?php echo esc_html($meta_key); ?>" rows="10"><?php echo htmlspecialchars($get_meta_field_values, ENT_QUOTES); ?></textarea> 77 <?php } else { ?> 78 <input type="text" name="<?php echo esc_html($meta_key); ?>" class="input_box" value="<?php echo htmlspecialchars($get_meta_field_values, ENT_QUOTES); ?>" /> 79 <?php } ?> 76 80 77 81 </div> … … 80 84 ?> 81 85 <?php 82 if ( isset( $_GET['page'] ) && $_GET['page'] == 'wc-orders') { // HPOS86 if (isset($_GET['page']) && $_GET['page'] == 'wc-orders') { // HPOS 83 87 ?> 84 <input type="hidden" value="<?php echo esc_html( $post->get_id()); ?>" name="current_post_id" />88 <input type="hidden" value="<?php echo esc_html($post->get_id()); ?>" name="current_post_id" /> 85 89 <?php 86 90 } else { 87 91 ?> 88 <input type="hidden" value="<?php echo esc_html( $post->ID); ?>" name="current_post_id" />92 <input type="hidden" value="<?php echo esc_html($post->ID); ?>" name="current_post_id" /> 89 93 <?php 90 94 } 91 95 ?> 92 96 93 <input type="hidden" value="<?php echo esc_html( $meta_key); ?>" name="changed_keys" id="changed_keys" />94 <input type="submit" value="<?php echo esc_html__( 'Change', 'pmdm_wp'); ?>" class="change_btn" id="change_btn"/>97 <input type="hidden" value="<?php echo esc_html($meta_key); ?>" name="changed_keys" id="changed_keys" /> 98 <input type="submit" value="<?php echo esc_html__('Change', 'pmdm_wp'); ?>" class="change_btn" id="change_btn"/> 95 99 96 100 </form> … … 100 104 101 105 | 102 <a href="javascript:;" data-id="<?php echo esc_html( $meta_key ); ?>" id="delete-<?php echo esc_html( $meta_key ); ?>" class="delete-meta"><?php echo esc_html__( 'Delete', 'pmdm_wp'); ?></a>106 <a href="javascript:;" data-id="<?php echo esc_html($meta_key); ?>" id="delete-<?php echo esc_html($meta_key); ?>" class="delete-meta"><?php echo esc_html__('Delete', 'pmdm_wp'); ?></a> 103 107 </td> 104 108 </tr> … … 106 110 107 111 <?php 108 109 112 } 110 113 -
post-meta-data-manager/trunk/post-meta-data-manager.php
r3123921 r3153871 1 1 <?php 2 /* 2 3 /** 3 4 * Plugin Name: Post Meta Data Manager 4 5 * Plugin URI: http://www.wpexpertplugins.com/ 5 6 * Description: Post Meta management Posts, Pages, Custom Post Types, Users, Taxonomoies. 6 * Version: 1.4. 27 * Version: 1.4.3 7 8 * Author: WpExpertPlugins 8 9 * Text Domain: pmdm_wp … … 11 12 * WC tested up to: 6.1 12 13 * Domain Path: /languages 13 */14 */ 14 15 15 16 /** … … 17 18 * 18 19 * @package Post Meta Data Manager 19 * @since 1.020 * @since 1.0 20 21 */ 21 if ( ! defined( 'PMDM_WP_DIR' ) ) { 22 define( 'PMDM_WP_DIR', __DIR__ ); // Plugin dir 22 23 if (! defined('PMDM_WP_DIR')) { 24 define('PMDM_WP_DIR', __DIR__); // Plugin dir 23 25 } 24 if ( ! defined( 'PMDM_WP_VERSION' )) {25 define( 'PMDM_WP_VERSION', '1.4.2');26 if (! defined('PMDM_WP_VERSION')) { 27 define('PMDM_WP_VERSION', '1.4.3'); 26 28 } 27 if ( ! defined( 'PMDM_WP_PLUGIN_MAIN_FILE_PATH' )) {28 define( 'PMDM_WP_PLUGIN_MAIN_FILE_PATH', __FILE__); // mail file path29 if (! defined('PMDM_WP_PLUGIN_MAIN_FILE_PATH')) { 30 define('PMDM_WP_PLUGIN_MAIN_FILE_PATH', __FILE__); // mail file path 29 31 } 30 if ( ! defined( 'PMDM_WP_URL' )) {31 define( 'PMDM_WP_URL', plugin_dir_url( __FILE__ )); // Plugin url32 if (! defined('PMDM_WP_URL')) { 33 define('PMDM_WP_URL', plugin_dir_url(__FILE__)); // Plugin url 32 34 } 33 if ( ! defined( 'PMDM_WP_INC_DIR' )) {34 define( 'PMDM_WP_INC_DIR', PMDM_WP_DIR . '/includes'); // Plugin include dir35 if (! defined('PMDM_WP_INC_DIR')) { 36 define('PMDM_WP_INC_DIR', PMDM_WP_DIR . '/includes'); // Plugin include dir 35 37 } 36 if ( ! defined( 'PMDM_WP_INC_URL' )) {37 define( 'PMDM_WP_INC_URL', PMDM_WP_URL . 'includes'); // Plugin include url38 if (! defined('PMDM_WP_INC_URL')) { 39 define('PMDM_WP_INC_URL', PMDM_WP_URL . 'includes'); // Plugin include url 38 40 } 39 if ( ! defined( 'PMDM_WP_ADMIN_DIR' )) {40 define( 'PMDM_WP_ADMIN_DIR', PMDM_WP_INC_DIR . '/admin'); // Plugin admin dir41 if (! defined('PMDM_WP_ADMIN_DIR')) { 42 define('PMDM_WP_ADMIN_DIR', PMDM_WP_INC_DIR . '/admin'); // Plugin admin dir 41 43 } 42 if ( ! defined( 'PMDM_WP_BASE_NAME' )) {43 define( 'PMDM_WP_BASE_NAME', 'pmdm_wp'); // Plugin folder name44 if (! defined('PMDM_WP_BASE_NAME')) { 45 define('PMDM_WP_BASE_NAME', 'pmdm_wp'); // Plugin folder name 44 46 } 45 if ( ! defined( 'PMDM_WP_PREFIX' )) {46 define( 'PMDM_WP_PREFIX', 'pmdm_wp'); // Plugin Prefix47 if (! defined('PMDM_WP_PREFIX')) { 48 define('PMDM_WP_PREFIX', 'pmdm_wp'); // Plugin Prefix 47 49 } 48 if ( ! defined( 'PMDM_WP_VAR_PREFIX' )) {49 define( 'PMDM_WP_VAR_PREFIX', '_pmdm_wp_'); // Variable Prefix50 if (! defined('PMDM_WP_VAR_PREFIX')) { 51 define('PMDM_WP_VAR_PREFIX', '_pmdm_wp_'); // Variable Prefix 50 52 } 51 if ( ! defined( 'PMDM_HELP_LINK' )) {52 define( 'PMDM_HELP_LINK', 'http://www.wpexpertplugins.com/contact-us/'); // Variable Prefix53 if (! defined('PMDM_HELP_LINK')) { 54 define('PMDM_HELP_LINK', 'http://www.wpexpertplugins.com/contact-us/'); // Variable Prefix 53 55 } 54 56 … … 59 61 * 60 62 * @package Post Meta Data Manager 61 * @since 1.063 * @since 1.0 62 64 */ 63 add_action( 'plugins_loaded', 'pmdm_wp_init_textdomain');65 add_action('plugins_loaded', 'pmdm_wp_init_textdomain'); 64 66 65 function pmdm_wp_init_textdomain() { 67 function pmdm_wp_init_textdomain() 68 { 66 69 67 // Filter for Language directory68 $pmdm_wp_lang_dir = dirname( plugin_basename( __FILE__ )) . '/languages/';69 $pmdm_wp_lang_dir = apply_filters( 'pmdm_wp_languages_directory', $pmdm_wp_lang_dir);70 // Filter for Language directory 71 $pmdm_wp_lang_dir = dirname(plugin_basename(__FILE__)) . '/languages/'; 72 $pmdm_wp_lang_dir = apply_filters('pmdm_wp_languages_directory', $pmdm_wp_lang_dir); 70 73 71 // WordPress Locale file72 $locale = apply_filters( 'plugin_locale', get_locale(), 'pmdm_wp');73 $mofile = sprintf( '%1$s-%2$s.mo', 'pmdm_wp', $locale);74 // WordPress Locale file 75 $locale = apply_filters('plugin_locale', get_locale(), 'pmdm_wp'); 76 $mofile = sprintf('%1$s-%2$s.mo', 'pmdm_wp', $locale); 74 77 75 // Setup path to current locale76 $mofile_locale = $pmdm_wp_lang_dir . $mofile;77 $mofile_global = WP_LANG_DIR . '/' . PMDM_WP_BASE_NAME . '/' . $mofile;78 // Setup path to current locale 79 $mofile_locale = $pmdm_wp_lang_dir . $mofile; 80 $mofile_global = WP_LANG_DIR . '/' . PMDM_WP_BASE_NAME . '/' . $mofile; 78 81 79 if ( file_exists( $mofile_global )) { // look in global Languages folder80 load_textdomain( 'pmdm_wp', $mofile_global);81 } elseif ( file_exists( $mofile_locale )) { // look in local plugin Languages folder82 load_textdomain( 'pmdm_wp', $mofile_locale);83 } else { // Load the default Languages file84 load_plugin_textdomain( 'pmdm_wp', false, $pmdm_wp_lang_dir);85 }82 if (file_exists($mofile_global)) { // look in global Languages folder 83 load_textdomain('pmdm_wp', $mofile_global); 84 } elseif (file_exists($mofile_locale)) { // look in local plugin Languages folder 85 load_textdomain('pmdm_wp', $mofile_locale); 86 } else { // Load the default Languages file 87 load_plugin_textdomain('pmdm_wp', false, $pmdm_wp_lang_dir); 88 } 86 89 } 87 90 … … 92 95 * 93 96 * @package Post Meta Data Manager 94 * @since 1.097 * @since 1.0 95 98 */ 96 register_activation_hook( __FILE__, 'pmdm_wp_install');99 register_activation_hook(__FILE__, 'pmdm_wp_install'); 97 100 98 function pmdm_wp_install() { 101 function pmdm_wp_install() 102 { 99 103 } 100 104 … … 105 109 * 106 110 * @package Post Meta Data Manager 107 * @since 1.0111 * @since 1.0 108 112 */ 109 register_deactivation_hook( __FILE__, 'pmdm_wp_uninstall');113 register_deactivation_hook(__FILE__, 'pmdm_wp_uninstall'); 110 114 111 function pmdm_wp_uninstall() { 115 function pmdm_wp_uninstall() 116 { 112 117 } 113 118 -
post-meta-data-manager/trunk/readme.txt
r3123924 r3153871 7 7 Requires at least: 3.0 8 8 Tested up to: 6.5.4 9 Stable tag: 1.4. 29 Stable tag: 1.4.3 10 10 License: GPLv2 or later 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 62 62 63 63 == Changelog == 64 = 1.4.3 - 2024-09-18 = 65 * Resolved a support ticket. 66 * Fixed edit & delete not working issue when wc installed and hpos not enabled. 67 64 68 65 69 = 1.4.2 - 2024-07-23 =
Note: See TracChangeset
for help on using the changeset viewer.