Plugin Directory

Changeset 3153871


Ignore:
Timestamp:
09/18/2024 10:34:29 AM (16 months ago)
Author:
gandhihitesh9
Message:
  • Date paid support provided to wc orders.
  • HPOS delete and edit
Location:
post-meta-data-manager
Files:
29 added
5 edited

Legend:

Unmodified
Added
Removed
  • post-meta-data-manager/trunk/.gitignore

    r2994271 r3153871  
    1818node_modules/
    1919
     20# Packages
     21vendor
     22
    2023# ignore log files and databases
    2124*.log
     
    2326*.sqlite
    2427*.bak
     28
  • post-meta-data-manager/trunk/includes/admin/class-pmdm-wp-admin.php

    r3123921 r3153871  
    11<?php
    22// Exit if accessed directly
    3 if ( ! defined( 'ABSPATH' ) ) {
     3if (! defined('ABSPATH')) {
    44    exit;
    55}
     
    1616 */
    1717
    18 class Pmdm_Wp_Admin {
     18class Pmdm_Wp_Admin
     19{
    1920
    2021
     
    2223
    2324    // class constructor
    24     function __construct() {
     25    function __construct()
     26    {
    2527
    2628        global $pmdm_wp_scripts;
     
    3638     * @since 1.0
    3739     */
    38     public function pmdm_wp_add_meta_boxes( $post_type, $post ) {
     40    public function pmdm_wp_add_meta_boxes($post_type, $post)
     41    {
    3942
    4043        $current_screen = get_current_screen();
    4144
    4245        $metabox_id               = 'pmdm-wp';
    43         $metabox_title            = esc_html__( 'Post Metadata Manager', 'pmdm_wp' );
     46        $metabox_title            = esc_html__('Post Metadata Manager', 'pmdm_wp');
    4447        $metabox_screen           = $post_type;
    4548        $metabox_context          = 'normal';
    4649        $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()) {
    5455                    return;
    5556                }
    5657
    57                 if ( ! current_user_can( 'edit_post', $post->get_id() ) ) {
     58                if (! current_user_can('edit_post', $post->get_id())) {
    5859                    return;
    5960                }
    60                 if ( $post_type == 'woocommerce_page_wc-orders' && $_GET['action'] != 'edit' ) {  // HPOS
     61                if ($post_type == 'woocommerce_page_wc-orders' && $_GET['action'] != 'edit') {  // HPOS
    6162                    return;
    6263                }
    6364                $pmdm_selected_post_types[] = 'woocommerce_page_wc-orders';
    6465
    65                 if ( in_array( $post_type, $pmdm_selected_post_types ) ) {
    66 
     66                if (in_array($post_type, $pmdm_selected_post_types)) {
    6767                    $metabox_screen = wc_get_container()->get(
    6868                        CustomOrdersTableController::class
    6969                    )->custom_orders_table_usage_is_enabled()
    70                         ? wc_get_page_screen_id( 'shop-order' )
     70                        ? wc_get_page_screen_id('shop-order')
    7171                        : 'shop_order';
    7272
    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());
    7474                }
    7575            } else {
    76                 if ( isset( $current_screen->action ) && $current_screen->action == 'add' ) { // check new post
     76                if (isset($current_screen->action) && $current_screen->action == 'add') { // check new post
    7777                    return;
    7878                }
    79                 if ( ! $post->ID ) {
     79                if (! $post->ID) {
    8080                    return;
    8181                }
    8282
    83                 if ( ! current_user_can( 'edit_post', $post->ID ) ) {
     83                if (! current_user_can('edit_post', $post->ID)) {
    8484                    return;
    8585                }
    86                 if ( empty( $pmdm_selected_post_types ) ) {
     86                if (empty($pmdm_selected_post_types)) {
    8787                    $pmdm_selected_post_types = array(
    8888                        'post',
     
    9494                }
    9595
    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());
    9898                }
    9999            }
    100100        } 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
    103102                return;
    104103            }
    105             if ( ! $post->ID ) {
     104            if (! $post->ID) {
    106105                return;
    107106            }
    108107
    109             if ( ! current_user_can( 'edit_post', $post->ID ) ) {
     108            if (! current_user_can('edit_post', $post->ID)) {
    110109                return;
    111110            }
    112             if ( empty( $pmdm_selected_post_types ) ) {
     111            if (empty($pmdm_selected_post_types)) {
    113112                $pmdm_selected_post_types = array(
    114113                    'post',
     
    119118                );
    120119            }
    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());
    123122            }
    124123        }
     
    132131     * @since 1.0
    133132     */
    134     public function pmdm_wp_display_post_metadata( $post ) {
     133    public function pmdm_wp_display_post_metadata($post)
     134    {
    135135
    136136        $post_meta = array();
    137137
    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()) {
    142141                    return;
    143142                }
    144                 $order = wc_get_order( $post->get_id() );
    145 
    146                 if ( $order ) { // HPOS
     143                $order = wc_get_order($post->get_id());
     144
     145                if ($order) { // HPOS
    147146                    $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) {
    150149                            $post_meta[ $meta_data->key ] = $meta_data->value;
    151150                        }
    152151                    }
     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                    }
    153157                }
    154158            } else {
    155                 if ( ! $post->ID ) {
     159                if (! $post->ID) {
    156160                    return;
    157161                }
    158                 $post_meta = get_post_meta( $post->ID );
    159    
     162                $post_meta = get_post_meta($post->ID);
    160163            }
    161164        } else {
    162             if ( ! $post->ID ) {
     165            if (! $post->ID) {
    163166                return;
    164167            }
    165             $post_meta = get_post_meta( $post->ID );
    166 
     168            $post_meta = get_post_meta($post->ID);
    167169        }
    168170
     
    179181     * @since 1.0
    180182     */
    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')) {
    184186            $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) {
    193201                    // 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') {
    199207                        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') )
    201209                        );
    202210                    }
    203211
    204                     if ( $order ) { // HPOS
    205                         $order->delete_meta_data( $meta_id );
     212                    if ($order) { // HPOS
     213                        $order->delete_meta_data($meta_id);
    206214                        $order->save_meta_data();
     215                        wp_send_json_success(
     216                            array( 'msg' => esc_html__('Meta successfully deleted', 'pmdm_wp') )
     217                        );
    207218                    }
    208219                }
    209220            } 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') {
    213224                    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') )
    215226                    );
    216227                }
    217228
    218                 delete_post_meta( $post_id, $meta_id );
     229                delete_post_meta($post_id, $meta_id);
    219230
    220231                wp_send_json_success(
    221                     array( 'msg' => esc_html__( 'Meta successfully deleted', 'pmdm_wp' ) )
     232                    array( 'msg' => esc_html__('Meta successfully deleted', 'pmdm_wp') )
    222233                );
    223234            }
    224235        } else {
    225236            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') )
    227238            );
    228239        }
     
    237248     * @since 1.0.2
    238249     */
    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') {
    248259                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') )
    250261                );
    251262            }
    252263
    253             delete_user_meta( $user_ID, $meta_id );
     264            delete_user_meta($user_ID, $meta_id);
    254265
    255266            wp_send_json_success(
    256                 array( 'msg' => esc_html__( 'Meta successfully deleted', 'pmdm_wp' ) )
     267                array( 'msg' => esc_html__('Meta successfully deleted', 'pmdm_wp') )
    257268            );
    258269        } else {
    259270            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') )
    261272            );
    262273        }
     
    271282     * @since 1.0
    272283     */
    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)) {
    276288            $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)) {
    283294                        $input_name = $meta_main_key;
    284295
    285296                        $display_label = $meta_main_key;
    286297
    287                     if ( ! empty( $level_key ) ) {
    288                         foreach ( $level_key as $skk ) {
     298                    if (! empty($level_key)) {
     299                        foreach ($level_key as $skk) {
    289300                            $input_name    .= '[' . $skk . ']';
    290301                            $display_label .= '=>' . $skk;
     
    295306                    ?>
    296307                        <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); ?>" />
    299310                        </div>
    300311                        <?php
     
    303314                }
    304315            }
    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');
    307318            }
    308319        } else {
    309320            ?>
    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 />
    311322            <?php
    312323        }
     
    320331     * @since 1.0
    321332     */
    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') {
    330347                        continue;
    331348                    }
    332349
    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);
    352377                                }
    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);
    360382                                } 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);
    371384                                }
    372385                            }
     
    384397     * @since 1.0.2
    385398     */
    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') {
    394406                        continue;
    395407                    }
    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);
    399411                        } else {
    400                             $pv = wp_kses_post( $pv );
     412                            $pv = wp_kses_post($pv);
    401413                        }
    402414
    403                         update_user_meta( intval( $_POST['current_user_id'] ), $pk, $pv );
     415                        update_user_meta(intval($_POST['current_user_id']), $pk, $pv);
    404416                    }
    405417                }
     
    414426     * @since 1.0
    415427     */
    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);
    426437        return $data;
    427438    }
     
    435446     * @since 1.0
    436447     */
    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);
    445455        }
    446456
     
    454464     * @since 1.0.2
    455465     */
    456     public function pmdm_wp_user_metadata_box( $user ) {
     466    public function pmdm_wp_user_metadata_box($user)
     467    {
    457468        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);
    460471
    461472            require_once PMDM_WP_ADMIN_DIR . '/html/pmdm_wp_display_user_metadata_html.php';
     
    469480     * @since 1.0.3
    470481     */
    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);
    474486        // update_term_meta
    475487        // delete_term_meta
     
    483495     * @since 1.0.3
    484496     */
    485     public function pmdm_add_html_for_all_taxonomy() {
     497    public function pmdm_add_html_for_all_taxonomy()
     498    {
    486499        $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)) {
    489502            $pmdm_selected_taxonomies = array(
    490503                'category',
     
    494507            );
    495508        }
    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);
    500513                }
    501514            }
     
    510523     * @since 1.0.3
    511524     */
    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)) {
    517530                $disallow_term_key_array = apply_filters(
    518531                    PMDM_WP_PREFIX . '_disallow_term_keys',
     
    535548                    )
    536549                );
    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)) {
    539552                        continue;
    540553                    }
    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);
    544557                        } else {
    545                             $pv = wp_kses_post( $pv );
     558                            $pv = wp_kses_post($pv);
    546559                        }
    547560
    548                         update_term_meta( intval( $_POST['current_term_id'] ), $pk, $pv );
     561                        update_term_meta(intval($_POST['current_term_id']), $pk, $pv);
    549562                    }
    550563                }
     
    565578     * @since 1.0.3
    566579     */
    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')) {
    570583            $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') {
    577590                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') )
    579592                );
    580593            }
    581594
    582             delete_term_meta( $term_id, $meta_id );
     595            delete_term_meta($term_id, $meta_id);
    583596
    584597            wp_send_json_success(
    585                 array( 'msg' => esc_html__( 'Meta successfully deleted', 'pmdm_wp' ) )
     598                array( 'msg' => esc_html__('Meta successfully deleted', 'pmdm_wp') )
    586599            );
    587600        } else {
    588601            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') )
    590603            );
    591604        }
     
    594607    }
    595608
    596     public function pmdm_admin_menus() {
     609    public function pmdm_admin_menus()
     610    {
    597611        $parent_page_slug = 'pmdm-general-settings';
    598612        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'),
    601615            'manage_options',
    602616            $parent_page_slug,
     
    605619        add_submenu_page(
    606620            $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'),
    609623            'manage_options',
    610624            'pmdm-help',
     
    613627    }
    614628
    615     public function pmdm_general_settings_cb() {
     629    public function pmdm_general_settings_cb()
     630    {
    616631        require_once PMDM_WP_ADMIN_DIR . '/html/pmdm_general_settings_html.php';
    617632    }
    618     public function pmdm_help_cb() {
     633    public function pmdm_help_cb()
     634    {
    619635        require_once PMDM_WP_ADMIN_DIR . '/html/pmdm_help_html.php';
    620636    }
    621637
    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);
    630648        }
    631649    }
     
    637655     * @since 1.0
    638656     */
    639     public function add_hooks() {
     657    public function add_hooks()
     658    {
    640659
    641660        // 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' ));
    646665
    647666        // 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' ));
    652671
    653672        // 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' ));
    662681    }
    663682}
  • post-meta-data-manager/trunk/includes/admin/html/pmdm_wp_display_post_metadata_html.php

    r3115396 r3153871  
    11<?php
    22// Exit if accessed directly
    3 if ( ! defined( 'ABSPATH' ) ) {
     3if (! defined('ABSPATH')) {
    44    exit;
    55}
     
    1414<thead>
    1515    <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>
    1919    </tr>
    2020</thead>
     
    2222    <?php
    2323
    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);
    2828            }
    2929        } else {
     
    3131        }
    3232
    33             $is_added = isset( $post_meta[ $meta_key ] ) ? false : true;
     33            $is_added = isset($post_meta[ $meta_key ]) ? false : true;
    3434
    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            }
    3845        } 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);
    4047        }
    4148
     
    4350        ?>
    4451            <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>
    4754                <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>
    4956
    5057                    <div id="javascript:;" class="modal-window">
    5158                        <div>
    5259                            <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>
    5461                            <div class="model-body">
    5562                                <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'); ?>
    5764
    5865                                <?php
    5966
    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);
    6469                                } else {
    65 
    66                                     $get_meta_field_values_len = strlen( $get_meta_field_values );
     70                                    $get_meta_field_values_len = strlen($get_meta_field_values);
    6771                                    ?>
    6872                                            <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>
    7074
    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 } ?>
    7680
    7781                                            </div>
     
    8084                                ?>
    8185                                <?php
    82                                 if ( isset( $_GET['page'] ) && $_GET['page'] == 'wc-orders' ) { // HPOS
     86                                if (isset($_GET['page']) && $_GET['page'] == 'wc-orders') { // HPOS
    8387                                    ?>
    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" />
    8589                                    <?php
    8690                                } else {
    8791                                    ?>
    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" />
    8993                                    <?php
    9094                                }
    9195                                ?>
    9296                                   
    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"/>
    9599
    96100                                </form>
     
    100104
    101105                    |
    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>
    103107                </td>
    104108            </tr>
     
    106110
    107111        <?php
    108 
    109112    }
    110113
  • post-meta-data-manager/trunk/post-meta-data-manager.php

    r3123921 r3153871  
    11<?php
    2 /*
     2
     3/**
    34 * Plugin Name: Post Meta Data Manager
    45 * Plugin URI: http://www.wpexpertplugins.com/
    56 * Description: Post Meta management Posts, Pages, Custom Post Types, Users, Taxonomoies.
    6  * Version: 1.4.2
     7 * Version: 1.4.3
    78 * Author: WpExpertPlugins
    89 * Text Domain: pmdm_wp
     
    1112 * WC tested up to: 6.1
    1213 * Domain Path: /languages
    13 */
     14 */
    1415
    1516/**
     
    1718 *
    1819 * @package Post Meta Data Manager
    19  * @since 1.0
     20 * @since   1.0
    2021 */
    21 if ( ! defined( 'PMDM_WP_DIR' ) ) {
    22     define( 'PMDM_WP_DIR', __DIR__ );      // Plugin dir
     22
     23if (! defined('PMDM_WP_DIR')) {
     24    define('PMDM_WP_DIR', __DIR__);      // Plugin dir
    2325}
    24 if ( ! defined( 'PMDM_WP_VERSION' ) ) {
    25     define( 'PMDM_WP_VERSION', '1.4.2' );
     26if (! defined('PMDM_WP_VERSION')) {
     27    define('PMDM_WP_VERSION', '1.4.3');
    2628}
    27 if ( ! defined( 'PMDM_WP_PLUGIN_MAIN_FILE_PATH' ) ) {
    28     define( 'PMDM_WP_PLUGIN_MAIN_FILE_PATH', __FILE__ );   // mail file path
     29if (! defined('PMDM_WP_PLUGIN_MAIN_FILE_PATH')) {
     30    define('PMDM_WP_PLUGIN_MAIN_FILE_PATH', __FILE__);   // mail file path
    2931}
    30 if ( ! defined( 'PMDM_WP_URL' ) ) {
    31     define( 'PMDM_WP_URL', plugin_dir_url( __FILE__ ) );   // Plugin url
     32if (! defined('PMDM_WP_URL')) {
     33    define('PMDM_WP_URL', plugin_dir_url(__FILE__));   // Plugin url
    3234}
    33 if ( ! defined( 'PMDM_WP_INC_DIR' ) ) {
    34     define( 'PMDM_WP_INC_DIR', PMDM_WP_DIR . '/includes' );   // Plugin include dir
     35if (! defined('PMDM_WP_INC_DIR')) {
     36    define('PMDM_WP_INC_DIR', PMDM_WP_DIR . '/includes');   // Plugin include dir
    3537}
    36 if ( ! defined( 'PMDM_WP_INC_URL' ) ) {
    37     define( 'PMDM_WP_INC_URL', PMDM_WP_URL . 'includes' );    // Plugin include url
     38if (! defined('PMDM_WP_INC_URL')) {
     39    define('PMDM_WP_INC_URL', PMDM_WP_URL . 'includes');    // Plugin include url
    3840}
    39 if ( ! defined( 'PMDM_WP_ADMIN_DIR' ) ) {
    40     define( 'PMDM_WP_ADMIN_DIR', PMDM_WP_INC_DIR . '/admin' );  // Plugin admin dir
     41if (! defined('PMDM_WP_ADMIN_DIR')) {
     42    define('PMDM_WP_ADMIN_DIR', PMDM_WP_INC_DIR . '/admin');  // Plugin admin dir
    4143}
    42 if ( ! defined( 'PMDM_WP_BASE_NAME' ) ) {
    43     define( 'PMDM_WP_BASE_NAME', 'pmdm_wp' ); // Plugin folder name
     44if (! defined('PMDM_WP_BASE_NAME')) {
     45    define('PMDM_WP_BASE_NAME', 'pmdm_wp'); // Plugin folder name
    4446}
    45 if ( ! defined( 'PMDM_WP_PREFIX' ) ) {
    46     define( 'PMDM_WP_PREFIX', 'pmdm_wp' ); // Plugin Prefix
     47if (! defined('PMDM_WP_PREFIX')) {
     48    define('PMDM_WP_PREFIX', 'pmdm_wp'); // Plugin Prefix
    4749}
    48 if ( ! defined( 'PMDM_WP_VAR_PREFIX' ) ) {
    49     define( 'PMDM_WP_VAR_PREFIX', '_pmdm_wp_' ); // Variable Prefix
     50if (! defined('PMDM_WP_VAR_PREFIX')) {
     51    define('PMDM_WP_VAR_PREFIX', '_pmdm_wp_'); // Variable Prefix
    5052}
    51 if ( ! defined( 'PMDM_HELP_LINK' ) ) {
    52     define( 'PMDM_HELP_LINK', 'http://www.wpexpertplugins.com/contact-us/' ); // Variable Prefix
     53if (! defined('PMDM_HELP_LINK')) {
     54    define('PMDM_HELP_LINK', 'http://www.wpexpertplugins.com/contact-us/'); // Variable Prefix
    5355}
    5456
     
    5961 *
    6062 * @package Post Meta Data Manager
    61  * @since 1.0
     63 * @since   1.0
    6264 */
    63 add_action( 'plugins_loaded', 'pmdm_wp_init_textdomain' );
     65add_action('plugins_loaded', 'pmdm_wp_init_textdomain');
    6466
    65 function pmdm_wp_init_textdomain() {
     67function pmdm_wp_init_textdomain()
     68{
    6669
    67     // Filter for Language directory
    68     $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);
    7073
    71     // WordPress Locale file
    72     $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);
    7477
    75     // Setup path to current locale
    76     $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;
    7881
    79     if ( file_exists( $mofile_global ) ) { // look in global Languages folder
    80         load_textdomain( 'pmdm_wp', $mofile_global );
    81     } elseif ( file_exists( $mofile_locale ) ) { // look in local plugin Languages folder
    82         load_textdomain( 'pmdm_wp', $mofile_locale );
    83     } else { // Load the default Languages file
    84         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    }
    8689}
    8790
     
    9295 *
    9396 * @package Post Meta Data Manager
    94  * @since 1.0
     97 * @since   1.0
    9598 */
    96 register_activation_hook( __FILE__, 'pmdm_wp_install' );
     99register_activation_hook(__FILE__, 'pmdm_wp_install');
    97100
    98 function pmdm_wp_install() {
     101function pmdm_wp_install()
     102{
    99103}
    100104
     
    105109 *
    106110 * @package Post Meta Data Manager
    107  * @since 1.0
     111 * @since   1.0
    108112 */
    109 register_deactivation_hook( __FILE__, 'pmdm_wp_uninstall' );
     113register_deactivation_hook(__FILE__, 'pmdm_wp_uninstall');
    110114
    111 function pmdm_wp_uninstall() {
     115function pmdm_wp_uninstall()
     116{
    112117}
    113118
  • post-meta-data-manager/trunk/readme.txt

    r3123924 r3153871  
    77Requires at least: 3.0
    88Tested up to: 6.5.4
    9 Stable tag: 1.4.2
     9Stable tag: 1.4.3
    1010License: GPLv2 or later
    1111License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6262
    6363== 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
    6468
    6569= 1.4.2 - 2024-07-23 =
Note: See TracChangeset for help on using the changeset viewer.