Changeset 3263526
- Timestamp:
- 03/28/2025 01:23:06 PM (12 months ago)
- Location:
- wc-product-table-lite/trunk
- Files:
-
- 4 edited
-
main.php (modified) (4 diffs)
-
presets/presets.php (modified) (2 diffs)
-
query_editor_v2/query_editor_v2.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wc-product-table-lite/trunk/main.php
r3231930 r3263526 7 7 * Author: WC Product Table 8 8 * Author URI: https://profiles.wordpress.org/wcproducttable/ 9 * Version: 3.9. 59 * Version: 3.9.6 10 10 * 11 11 * WC requires at least: 3.4.4 12 * WC tested up to: 9. 6.012 * WC tested up to: 9.7.1 13 13 * 14 14 * Text Domain: wc-product-table-pro … … 23 23 // define('WCPT_DEV', TRUE); 24 24 25 define('WCPT_VERSION', '3.9. 5');25 define('WCPT_VERSION', '3.9.6'); 26 26 define('WCPT_PLUGIN_PATH', plugin_dir_path(__FILE__)); 27 27 define('WCPT_PLUGIN_URL', plugin_dir_url(__FILE__)); … … 5436 5436 } 5437 5437 5438 // refresh custom field list 5438 // refresh custom field list 5439 5439 add_action('admin_init', 'wcpt_refresh_custom_fields'); 5440 5440 function wcpt_refresh_custom_fields() … … 5442 5442 if ( 5443 5443 is_admin() && 5444 !empty($_GET['wcpt_refresh_custom_fields']) 5444 !empty($_GET['wcpt_refresh_custom_fields']) && 5445 current_user_can('manage_options') // Only allow administrators 5445 5446 ) { 5446 5447 delete_transient('wcpt_custom_fields'); -
wc-product-table-lite/trunk/presets/presets.php
r3204509 r3263526 101 101 function wcpt_presets__set_preset_required_meta_flag() 102 102 { 103 // Check if we're on the table editor page 103 104 if (!wcpt_preset__is_table_editor_page()) { 104 105 return; 105 106 } 106 107 107 // if table is new (no data) then set preset requrired meta flag 108 $post_id = $_GET['post_id']; 108 // Check if user has proper capabilities 109 if (!current_user_can('create_wc_product_tables')) { 110 return; 111 } 112 113 // Validate and sanitize post_id 114 if (empty($_GET['post_id']) || !is_numeric($_GET['post_id'])) { 115 return; 116 } 117 118 $post_id = intval($_GET['post_id']); 119 120 // Verify post exists and is the correct type 121 $post = get_post($post_id); 122 if (!$post || $post->post_type !== 'wc_product_table') { 123 return; 124 } 125 126 // If table is new (no data) then set preset required meta flag 109 127 $table_data = get_post_meta($post_id, 'wcpt_data', true); 110 111 128 if (!$table_data) { 112 129 update_post_meta($post_id, 'wcpt_preset_required', true); 113 130 } 114 131 } 115 116 132 117 133 // duplicate a preset to table … … 119 135 function wcpt_presets__duplicate_preset_to_table() 120 136 { 137 // Check if we're on the table editor page 121 138 if (!wcpt_preset__is_table_editor_page()) { 122 139 return; 123 140 } 124 141 142 // Check for proper authorization 125 143 if (!current_user_can('create_wc_product_tables')) { 126 exit('Unauthorized action.');127 } 128 129 // no preset selected yet144 wp_die('Unauthorized action.'); 145 } 146 147 // No preset selected yet 130 148 if (empty($_GET['wcpt_preset'])) { 131 149 return; 132 150 } 133 151 152 // Validate and sanitize post_id 153 if (empty($_GET['post_id']) || !is_numeric($_GET['post_id'])) { 154 return; 155 } 156 134 157 $post_id = intval($_GET['post_id']); 158 159 // Verify post exists and is the correct type 160 $post = get_post($post_id); 161 if (!$post || $post->post_type !== 'wc_product_table') { 162 return; 163 } 164 165 // Sanitize preset slug and validate against an allowlist (better approach) 135 166 $slug = sanitize_file_name($_GET['wcpt_preset']); 136 167 137 // preset already applied on this table 168 // You might want to create an allowlist of valid presets 169 $allowed_presets = array('blank', 'regular-table', 'list-layout'); // Add all valid presets 170 if (!in_array($slug, $allowed_presets)) { 171 wp_die('Invalid preset selected.'); 172 } 173 174 // Preset already applied on this table 138 175 if (!wcpt_preset__required($post_id)) { 139 176 return; 140 177 } 141 178 142 // apply the preset 143 update_post_meta($post_id, 'wcpt_preset_required', false); // turn off 'preset required' flag 144 145 wp_update_post( 146 array( 147 'ID' => $post_id, 148 'post_title' => $slug == 'blank' ? 'New table' : ucwords(str_replace('-', ' ', $slug)), 149 'post_status' => 'publish', 150 ) 151 ); 179 // Apply the preset 180 update_post_meta($post_id, 'wcpt_preset_required', false); // Turn off 'preset required' flag 181 182 wp_update_post(array( 183 'ID' => $post_id, 184 'post_title' => $slug == 'blank' ? 'New table' : ucwords(str_replace('-', ' ', $slug)), 185 'post_status' => 'publish', 186 )); 152 187 153 188 if ($slug !== 'blank') { 154 // get data from json preset file189 // Get data from json preset file 155 190 $preset_path = WCPT_PLUGIN_PATH . 'presets/table/' . $slug . '.json'; 156 if (realpath($preset_path) && strpos(realpath($preset_path), realpath(WCPT_PLUGIN_PATH . 'presets/table/')) === 0) { 157 $preset_json = file_get_contents($preset_path); 158 191 192 // More robust path validation to prevent directory traversal 193 $real_preset_path = realpath($preset_path); 194 $real_presets_dir = realpath(WCPT_PLUGIN_PATH . 'presets/table/'); 195 196 if ($real_preset_path && strpos($real_preset_path, $real_presets_dir) === 0 && file_exists($real_preset_path)) { 197 $preset_json = file_get_contents($real_preset_path); 159 198 $table_data = json_decode($preset_json, true); 160 wcpt_new_ids($table_data); 161 $table_data['id'] = $post_id; 162 update_post_meta($post_id, 'wcpt_data', addslashes(json_encode($table_data))); 163 164 update_post_meta($post_id, 'wcpt_preset_applied__message_required', true); 165 update_post_meta($post_id, 'wcpt_preset_applied__slug', $slug); 199 200 if ($table_data) { 201 wcpt_new_ids($table_data); 202 $table_data['id'] = $post_id; 203 update_post_meta($post_id, 'wcpt_data', addslashes(json_encode($table_data))); 204 update_post_meta($post_id, 'wcpt_preset_applied__message_required', true); 205 update_post_meta($post_id, 'wcpt_preset_applied__slug', $slug); 206 } 166 207 } 167 208 } -
wc-product-table-lite/trunk/query_editor_v2/query_editor_v2.php
r3204509 r3263526 28 28 function wcpt_qv2_reset() 29 29 { 30 // Check if all required parameters are present 30 31 if ( 31 isset($_GET['post_type']) && $_GET['post_type'] === 'wc_product_table' && 32 isset($_GET['page']) && $_GET['page'] === 'wcpt-edit' && 33 isset($_GET['post_id']) 34 && isset($_GET['qv2']) && $_GET['qv2'] === "false" 32 isset($_GET['post_type']) && 33 $_GET['post_type'] === 'wc_product_table' && 34 isset($_GET['page']) && 35 $_GET['page'] === 'wcpt-edit' && 36 isset($_GET['post_id']) && 37 isset($_GET['qv2']) && 38 $_GET['qv2'] === "false" 35 39 ) { 36 // provide new ids to avoid conflicts 37 if ($table_data = get_post_meta($_GET['post_id'], 'wcpt_data', true)) { 40 // Check user capability 41 if (!current_user_can('create_wc_product_tables')) { 42 wp_die('Unauthorized action.'); 43 } 44 45 // Sanitize and validate post_id 46 $post_id = intval($_GET['post_id']); 47 48 // Verify post exists and is the correct type 49 $post = get_post($post_id); 50 if (!$post || $post->post_type !== 'wc_product_table') { 51 return; 52 } 53 54 // Provide new ids to avoid conflicts 55 $table_data = get_post_meta($post_id, 'wcpt_data', true); 56 if ($table_data) { 38 57 $table_data = json_decode($table_data, true); 39 $table_data['query_v2'] = false; 40 update_post_meta($_GET['post_id'], 'wcpt_data', addslashes(json_encode($table_data))); 58 if (is_array($table_data)) { 59 $table_data['query_v2'] = false; 60 update_post_meta($post_id, 'wcpt_data', addslashes(json_encode($table_data))); 61 } 41 62 } 42 63 } … … 640 661 'wcpt_qv2/v1', 641 662 '/terms/(?P<taxonomy_slug>[a-zA-Z0-9_-]+)', 642 array (663 array( 643 664 'methods' => WP_REST_Server::READABLE, 644 665 'callback' => 'wcpt_qv2_ajax_return_taxonomy_terms_with_children', 645 'args' => array (646 'taxonomy_slug' => array (666 'args' => array( 667 'taxonomy_slug' => array( 647 668 'validate_callback' => function ($param, $request, $key) { 648 return !empty ($param);669 return !empty($param); 649 670 } 650 671 ), … … 652 673 'permission_callback' => function (WP_REST_Request $request) { 653 674 654 if (isset ($_SERVER['HTTP_X_WP_NONCE']) && wp_verify_nonce($_SERVER['HTTP_X_WP_NONCE'], 'wp_rest')) {675 if (isset($_SERVER['HTTP_X_WP_NONCE']) && wp_verify_nonce($_SERVER['HTTP_X_WP_NONCE'], 'wp_rest')) { 655 676 return true; 656 677 } 657 678 658 return new WP_Error('forbidden', 'You do not have permission to access this resource.', array ('status' => 403));679 return new WP_Error('forbidden', 'You do not have permission to access this resource.', array('status' => 403)); 659 680 660 681 } -
wc-product-table-lite/trunk/readme.txt
r3231930 r3263526 178 178 179 179 == Changelog == 180 181 = 3.9.6 (28th March '25) = 182 183 Fixed 184 * Patched security vulnerabilities 185 * WooCommerce 9.7 compatibility tag 180 186 181 187 = 3.9.5 (30th January '25) =
Note: See TracChangeset
for help on using the changeset viewer.