Plugin Directory

Changeset 3048971


Ignore:
Timestamp:
03/11/2024 10:22:41 AM (21 months ago)
Author:
totalpressorg
Message:

5.0.2

Location:
custom-post-types
Files:
75 added
5 edited

Legend:

Unmodified
Added
Removed
  • custom-post-types/trunk/custom-post-types.php

    r3036818 r3048971  
    88Text Domain: custom-post-types
    99Domain Path: /languages/
    10 Version: 5.0.1
     10Version: 5.0.2
    1111*/
    1212
  • custom-post-types/trunk/includes/class-cpt-ajax.php

    r2989869 r3048971  
    2020                'wp_ajax_' . $action,
    2121                function () use ( $args ) {
    22                     $nonce = ! empty( $_REQUEST['nonce'] ) && wp_verify_nonce( $_REQUEST['nonce'], CPT_NONCE_KEY );
     22                    if ( empty( $_SERVER['REQUEST_METHOD'] ) ) {
     23                        wp_send_json_error();
     24                    }
     25                    $data  = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET;
     26                    $nonce = ! empty( $data['nonce'] ) && wp_verify_nonce( $data['nonce'], CPT_NONCE_KEY );
    2327                    if ( ! $nonce ) {
    2428                        wp_send_json_error();
    2529                    }
    2630                    foreach ( $args['required'] as $param ) {
    27                         if ( empty( $_REQUEST[ $param ] ) ) {
     31                        if ( empty( $data[ $param ] ) ) {
    2832                            wp_send_json_error();
    2933                        }
     
    3236                        wp_send_json_error();
    3337                    }
    34                     $result = $args['callback']( $_REQUEST );
     38                    $result = $args['callback']( $data );
    3539                    wp_send_json_success( $result );
    3640                }
  • custom-post-types/trunk/includes/class-cpt-fields.php

    r3036818 r3048971  
    1919            return;
    2020        }
     21
    2122        return esc_html( 'meta-fields' . ( $parent_name ? $parent_name : '' ) . '[' . $key . ']' );
    2223    }
     
    3536        $parent_id = str_replace( '[', '-', $parent_id );
    3637        $parent_id = str_replace( ']', '', $parent_id );
     38
    3739        return esc_html( 'meta-fields' . $parent_id . '-' . $key );
     40    }
     41
     42    /**
     43     * @param $value
     44     *
     45     * @return mixed|string
     46     */
     47    private function sanitize_recursive_value( $value ) {
     48        if ( is_string( $value ) ) {
     49            $value = esc_html( $value );
     50        } elseif ( is_array( $value ) ) {
     51            foreach ( $value as $i => $item ) {
     52                $value[ $i ] = self::sanitize_recursive_value( $item );
     53            }
     54        }
     55
     56        return $value;
    3857    }
    3958
     
    5170            return;
    5271        }
    53         if( ! empty( $field_config['extra']['placeholder'] ) ){
    54             $field_config['extra']['placeholder'] = esc_html( $field_config['extra']['placeholder'] );
    55         }
    56         if( ! empty( $field_config['value'] ) && is_string( $field_config['value'] ) ){
    57             $field_config['value'] = esc_html( $field_config['value'] );
    58         }
     72        if ( ! empty( $field_config['extra']['placeholder'] ) ) {
     73            $field_config['extra']['placeholder'] = esc_html( $field_config['extra']['placeholder'] );
     74        }
     75        if ( 'repeater' !== $field_config['type'] && ! empty( $field_config['value'] ) ) {
     76            $field_config['value'] = self::sanitize_recursive_value( $field_config['value'] );
     77        }
    5978        ob_start();
    6079        ?>
    6180        <div
    62             class="cpt-field"<?php echo ! empty( $field_config['wrap']['width'] ) ? ' style="width: ' . $field_config['wrap']['width'] . '%"' : ''; ?>
    63             data-field-type="<?php echo $field_config['type']; ?>">
     81                class="cpt-field"<?php echo ! empty( $field_config['wrap']['width'] ) ? ' style="width: ' . esc_html( $field_config['wrap']['width'] ) . '%"' : ''; ?>
     82                data-field-type="<?php echo esc_html( $field_config['type'] ); ?>">
    6483            <div class="cpt-field-inner">
    6584                <input type="hidden" name="<?php echo esc_html( $input_name ); ?>" value="">
     
    177196                            'get_callback' => function ( $item ) use ( $route, $group_id, $fields, $get_callback ) {
    178197                                $content_id = $item['id'];
    179                                 $values = array();
     198                                $values     = array();
    180199                                foreach ( $fields as $field ) {
    181                                     $meta_key = $field['key'];
    182                                     $output_filter = apply_filters( 'cpt_rest_output', true, $meta_key, $route, $group_id, $content_id );
     200                                    $meta_key            = $field['key'];
     201                                    $output_filter       = apply_filters( 'cpt_rest_output', true, $meta_key, $route, $group_id, $content_id );
    183202                                    $values[ $meta_key ] = $get_callback( $meta_key, $content_id, $output_filter );
    184203                                }
     204
    185205                                return $values;
    186206                            },
     
    531551                    function ( $key ) use ( $item_id ) {
    532552                        $key = str_replace( '-' . $item_id, '', $key );
     553
    533554                        return ! empty( $item_id ) ? get_post_meta( $item_id, $key, true ) : null;
    534555                    }
     
    548569                    function ( $key, $value ) use ( $item_id ) {
    549570                        $key = str_replace( '-' . $item_id, '', $key );
     571
    550572                        return update_post_meta( $item_id, $key, $value );
    551573                    },
     
    569591        $content_type_fields = cpt_utils()->get_fields_by_supports( "$content_type/$content_type_id" );
    570592        $field_object        = ! empty( $content_type_fields[ $meta_key ] ) ? $content_type_fields[ $meta_key ] : null;
     593
    571594        return $field_object;
    572595    }
     
    603626                );
    604627            }
     628
    605629            return '';
    606630        }
     631
    607632        return apply_filters( 'cpt_field_get', $meta_value, $meta_key, $meta_type, $content_type_id, $content_id );
    608633    }
     
    643668
    644669        $field_class = ! empty( $this->types[ $type ] ) ? $this->types[ $type ] : false;
     670
    645671        return $field_class;
    646672    }
  • custom-post-types/trunk/includes/class-cpt-ui.php

    r3036818 r3048971  
    5858     */
    5959    public function feedback_actions() {
    60         $nonce = ! empty( $_REQUEST['nonce'] ) && wp_verify_nonce( $_REQUEST['nonce'], CPT_NONCE_KEY );
     60        $nonce = ! empty( $_GET['nonce'] ) && wp_verify_nonce( $_GET['nonce'], CPT_NONCE_KEY );
    6161        if ( ! $nonce ) {
    6262            return;
    6363        }
    6464
    65         $action = ! empty( $_REQUEST['action'] ) && 'cpt-feedback' == $_REQUEST['action'] ? $_REQUEST['action'] : false; //phpcs:ignore Universal.Operators.StrictComparisons
     65        $action = ! empty( $_GET['action'] ) && 'cpt-feedback' == $_GET['action'] ? $_GET['action'] : false; //phpcs:ignore Universal.Operators.StrictComparisons
    6666        if ( ! $action ) {
    6767            return;
     
    6969
    7070        $feedback = array();
    71         if ( ! empty( $_REQUEST['reason'] ) ) {
    72             $feedback[] = esc_textarea( $_REQUEST['reason'] );
    73         }
    74         if ( ! empty( $_REQUEST['suggestion'] ) ) {
    75             $feedback[] = esc_textarea( $_REQUEST['suggestion'] );
     71        if ( ! empty( $_GET['reason'] ) ) {
     72            $feedback[] = esc_textarea( $_GET['reason'] );
     73        }
     74        if ( ! empty( $_GET['suggestion'] ) ) {
     75            $feedback[] = esc_textarea( $_GET['suggestion'] );
    7676        }
    7777        if ( ! empty( $feedback ) ) {
  • custom-post-types/trunk/readme.txt

    r3036818 r3048971  
    55Requires at least: 4.0
    66Tested up to: 6.4
    7 Stable tag: 5.0.1
     7Stable tag: 5.0.2
    88Requires PHP: 5.6
    99License: GPLv2 or later
     
    188188== Changelog ==
    189189
     190= 5.0.2 - 2024-03-11 =
     191* FIX: improve plugin self-request security;
     192
    190193= 5.0.1 - 2024-02-16 =
    191194* FIX: Authenticated (Administrator+) Stored Cross-Site Scripting (thanks to Taihei Shimamine);
Note: See TracChangeset for help on using the changeset viewer.