Changeset 3048971
- Timestamp:
- 03/11/2024 10:22:41 AM (21 months ago)
- Location:
- custom-post-types
- Files:
-
- 75 added
- 5 edited
-
tags/5.0.2 (added)
-
tags/5.0.2/assets (added)
-
tags/5.0.2/assets/css (added)
-
tags/5.0.2/assets/css/backend.css (added)
-
tags/5.0.2/assets/dashboard-icon.svg (added)
-
tags/5.0.2/assets/icon-256x256.png (added)
-
tags/5.0.2/assets/icon.svg (added)
-
tags/5.0.2/assets/js (added)
-
tags/5.0.2/assets/js/backend.js (added)
-
tags/5.0.2/custom-post-types.php (added)
-
tags/5.0.2/includes (added)
-
tags/5.0.2/includes/abstracts (added)
-
tags/5.0.2/includes/abstracts/class-cpt-component.php (added)
-
tags/5.0.2/includes/abstracts/class-cpt-field.php (added)
-
tags/5.0.2/includes/args (added)
-
tags/5.0.2/includes/args/core-admin-pages-pro.php (added)
-
tags/5.0.2/includes/args/core-admin-pages.php (added)
-
tags/5.0.2/includes/args/core-post-types.php (added)
-
tags/5.0.2/includes/args/fields-field-group.php (added)
-
tags/5.0.2/includes/args/fields-post-type.php (added)
-
tags/5.0.2/includes/args/fields-repeater.php (added)
-
tags/5.0.2/includes/args/fields-taxonomy.php (added)
-
tags/5.0.2/includes/args/post-types-default-args.php (added)
-
tags/5.0.2/includes/args/post-types-default-labels.php (added)
-
tags/5.0.2/includes/args/taxonomies-default-args.php (added)
-
tags/5.0.2/includes/args/taxonomies-default-labels.php (added)
-
tags/5.0.2/includes/class-cpt-admin-notices.php (added)
-
tags/5.0.2/includes/class-cpt-admin-pages.php (added)
-
tags/5.0.2/includes/class-cpt-ajax.php (added)
-
tags/5.0.2/includes/class-cpt-core.php (added)
-
tags/5.0.2/includes/class-cpt-field-groups.php (added)
-
tags/5.0.2/includes/class-cpt-fields.php (added)
-
tags/5.0.2/includes/class-cpt-plugin.php (added)
-
tags/5.0.2/includes/class-cpt-post-types.php (added)
-
tags/5.0.2/includes/class-cpt-shortcodes.php (added)
-
tags/5.0.2/includes/class-cpt-taxonomies.php (added)
-
tags/5.0.2/includes/class-cpt-ui.php (added)
-
tags/5.0.2/includes/class-cpt-utils.php (added)
-
tags/5.0.2/includes/compatibilities (added)
-
tags/5.0.2/includes/compatibilities/saswp.php (added)
-
tags/5.0.2/includes/compatibilities/v4.php (added)
-
tags/5.0.2/includes/fields (added)
-
tags/5.0.2/includes/fields/class-cpt-field-checkbox.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-color.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-date.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-email.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-embed.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-file.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-html.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-link.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-map.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-number.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-password.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-post-rel.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-radio.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-range.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-repeater.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-select.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-separator.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-switch.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-tax-rel.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-tel.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-text.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-textarea.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-time.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-tinymce.php (added)
-
tags/5.0.2/includes/fields/class-cpt-field-user-rel.php (added)
-
tags/5.0.2/includes/functions.php (added)
-
tags/5.0.2/includes/templates (added)
-
tags/5.0.2/includes/templates/modal-feedback.php (added)
-
tags/5.0.2/includes/templates/page-tools.php (added)
-
tags/5.0.2/index.php (added)
-
tags/5.0.2/languages (added)
-
tags/5.0.2/languages/custom-post-types.pot (added)
-
tags/5.0.2/readme.txt (added)
-
trunk/custom-post-types.php (modified) (1 diff)
-
trunk/includes/class-cpt-ajax.php (modified) (2 diffs)
-
trunk/includes/class-cpt-fields.php (modified) (9 diffs)
-
trunk/includes/class-cpt-ui.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
custom-post-types/trunk/custom-post-types.php
r3036818 r3048971 8 8 Text Domain: custom-post-types 9 9 Domain Path: /languages/ 10 Version: 5.0. 110 Version: 5.0.2 11 11 */ 12 12 -
custom-post-types/trunk/includes/class-cpt-ajax.php
r2989869 r3048971 20 20 'wp_ajax_' . $action, 21 21 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 ); 23 27 if ( ! $nonce ) { 24 28 wp_send_json_error(); 25 29 } 26 30 foreach ( $args['required'] as $param ) { 27 if ( empty( $ _REQUEST[ $param ] ) ) {31 if ( empty( $data[ $param ] ) ) { 28 32 wp_send_json_error(); 29 33 } … … 32 36 wp_send_json_error(); 33 37 } 34 $result = $args['callback']( $ _REQUEST);38 $result = $args['callback']( $data ); 35 39 wp_send_json_success( $result ); 36 40 } -
custom-post-types/trunk/includes/class-cpt-fields.php
r3036818 r3048971 19 19 return; 20 20 } 21 21 22 return esc_html( 'meta-fields' . ( $parent_name ? $parent_name : '' ) . '[' . $key . ']' ); 22 23 } … … 35 36 $parent_id = str_replace( '[', '-', $parent_id ); 36 37 $parent_id = str_replace( ']', '', $parent_id ); 38 37 39 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; 38 57 } 39 58 … … 51 70 return; 52 71 } 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 } 59 78 ob_start(); 60 79 ?> 61 80 <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'] ); ?>"> 64 83 <div class="cpt-field-inner"> 65 84 <input type="hidden" name="<?php echo esc_html( $input_name ); ?>" value=""> … … 177 196 'get_callback' => function ( $item ) use ( $route, $group_id, $fields, $get_callback ) { 178 197 $content_id = $item['id']; 179 $values = array();198 $values = array(); 180 199 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 ); 183 202 $values[ $meta_key ] = $get_callback( $meta_key, $content_id, $output_filter ); 184 203 } 204 185 205 return $values; 186 206 }, … … 531 551 function ( $key ) use ( $item_id ) { 532 552 $key = str_replace( '-' . $item_id, '', $key ); 553 533 554 return ! empty( $item_id ) ? get_post_meta( $item_id, $key, true ) : null; 534 555 } … … 548 569 function ( $key, $value ) use ( $item_id ) { 549 570 $key = str_replace( '-' . $item_id, '', $key ); 571 550 572 return update_post_meta( $item_id, $key, $value ); 551 573 }, … … 569 591 $content_type_fields = cpt_utils()->get_fields_by_supports( "$content_type/$content_type_id" ); 570 592 $field_object = ! empty( $content_type_fields[ $meta_key ] ) ? $content_type_fields[ $meta_key ] : null; 593 571 594 return $field_object; 572 595 } … … 603 626 ); 604 627 } 628 605 629 return ''; 606 630 } 631 607 632 return apply_filters( 'cpt_field_get', $meta_value, $meta_key, $meta_type, $content_type_id, $content_id ); 608 633 } … … 643 668 644 669 $field_class = ! empty( $this->types[ $type ] ) ? $this->types[ $type ] : false; 670 645 671 return $field_class; 646 672 } -
custom-post-types/trunk/includes/class-cpt-ui.php
r3036818 r3048971 58 58 */ 59 59 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 ); 61 61 if ( ! $nonce ) { 62 62 return; 63 63 } 64 64 65 $action = ! empty( $_ REQUEST['action'] ) && 'cpt-feedback' == $_REQUEST['action'] ? $_REQUEST['action'] : false; //phpcs:ignore Universal.Operators.StrictComparisons65 $action = ! empty( $_GET['action'] ) && 'cpt-feedback' == $_GET['action'] ? $_GET['action'] : false; //phpcs:ignore Universal.Operators.StrictComparisons 66 66 if ( ! $action ) { 67 67 return; … … 69 69 70 70 $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'] ); 76 76 } 77 77 if ( ! empty( $feedback ) ) { -
custom-post-types/trunk/readme.txt
r3036818 r3048971 5 5 Requires at least: 4.0 6 6 Tested up to: 6.4 7 Stable tag: 5.0. 17 Stable tag: 5.0.2 8 8 Requires PHP: 5.6 9 9 License: GPLv2 or later … … 188 188 == Changelog == 189 189 190 = 5.0.2 - 2024-03-11 = 191 * FIX: improve plugin self-request security; 192 190 193 = 5.0.1 - 2024-02-16 = 191 194 * FIX: Authenticated (Administrator+) Stored Cross-Site Scripting (thanks to Taihei Shimamine);
Note: See TracChangeset
for help on using the changeset viewer.