Changeset 3350006
- Timestamp:
- 08/26/2025 01:39:08 AM (6 months ago)
- Location:
- bulk-content-toolkit
- Files:
-
- 6 edited
- 1 copied
-
tags/1.2.4 (copied) (copied from bulk-content-toolkit/trunk)
-
tags/1.2.4/bulk-content-toolkit.php (modified) (3 diffs)
-
tags/1.2.4/js/user.js (modified) (1 diff)
-
tags/1.2.4/readme.txt (modified) (2 diffs)
-
trunk/bulk-content-toolkit.php (modified) (3 diffs)
-
trunk/js/user.js (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bulk-content-toolkit/tags/1.2.4/bulk-content-toolkit.php
r3349789 r3350006 3 3 Plugin Name: Bulk Content Toolkit 4 4 Description: A comprehensive toolkit for efficiently managing bulk actions on various types of content in WordPress, including posts, pages, and custom post types. 5 Version: 1.2. 35 Version: 1.2.4 6 6 Requires at least: 5.0 7 7 Tested up to: 6.8 … … 116 116 } 117 117 } 118 function bulkedittoolkit_save_custom_bulk_edit($post_id) { // modification de masse via quick edit118 function bulkedittoolkit_save_custom_bulk_edit($post_id) { 119 119 global $bulkedittoolkit_bulk_edit_settings; 120 bulkedittoolkit_debug_log("Hook save_post_product called for post ID: $post_id", $GLOBALS["bulkedittoolkit_is_debug_active"]);121 if (isset($_REQUEST['post'])) {120 bulkedittoolkit_debug_log("Hook save_post_product called for post ID: $post_id", $GLOBALS["bulkedittoolkit_is_debug_active"]); 121 if (isset($_REQUEST['post'])) { 122 122 bulkedittoolkit_debug_log("Posts in REQUEST: " . print_r($_REQUEST['post'], true), $GLOBALS["bulkedittoolkit_is_debug_active"]); 123 123 } 124 //error_log("EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"); 124 125 125 // Vérifiez si c'est une autosave ou si le type de post ne correspond pas 126 126 if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) { … … 132 132 } 133 133 $fields_names = bulkedittoolkit_get_bulk_edit_field_name(get_post_type($post_id)); 134 134 135 // Traitement de la modification en masse 135 136 bulkedittoolkit_debug_log("before"); 136 137 if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'edit' && isset($_REQUEST['bulk_edit'])) { 137 bulkedittoolkit_debug_log("after"); 138 // Sanitize and validate the array of post IDs 139 $posts_to_update = isset($_REQUEST['post']) ? (array)$_REQUEST['post'] : array(); 140 $posts_to_update = array_map('intval', $posts_to_update); // Convert all elements to integers 141 $posts_to_update = array_filter($posts_to_update); // Remove any potential falsy values (like 0 or empty strings) 142 foreach ($fields_names as $field_name => $field_details) { 143 bulkedittoolkit_debug_log("loop"); 144 bulkedittoolkit_debug_log($field_name); 145 // Vérifie si ce champ spécifique est soumis dans la requête 146 $custom_field_key = 'custom_' . $field_name; 147 bulkedittoolkit_debug_log($custom_field_key); 148 // Get the input type for the field 149 $input_type = $bulkedittoolkit_bulk_edit_settings->bulkedittoolkit_get_input_type(get_post_type($post_id), $field_name); 150 if (isset($_REQUEST[$custom_field_key])) { 151 $value = sanitize_text_field($_REQUEST[$custom_field_key]); // 'yes' si coché, sinon la valeur soumise 152 // Skip empty values for non-checkbox fields to respect "— Aucun changement —" 153 if ($value === '' && $input_type !== 'checkbox') { 154 bulkedittoolkit_debug_log("Skipping empty value for non-checkbox field $field_name", $GLOBALS["bulkedittoolkit_is_debug_active"]); 138 bulkedittoolkit_debug_log("after"); 139 // Sanitize and validate the array of post IDs 140 $posts_to_update = isset($_REQUEST['post']) ? (array)$_REQUEST['post'] : array(); 141 $posts_to_update = array_map('intval', $posts_to_update); // Convert all elements to integers 142 $posts_to_update = array_filter($posts_to_update); // Remove any potential falsy values (like 0 or empty strings) 143 foreach ($fields_names as $field_name => $custom_field_key) { 144 bulkedittoolkit_debug_log("loop"); 145 bulkedittoolkit_debug_log($field_name); 146 // Vérifie si ce champ spécifique est soumis dans la requête 147 $change_field_key = 'change_custom_' . $field_name; 148 $custom_field_key = 'custom_' . $field_name; 149 bulkedittoolkit_debug_log($custom_field_key); 150 151 // Get the input type for the field 152 $input_type = $bulkedittoolkit_bulk_edit_settings->bulkedittoolkit_get_input_type(get_post_type($post_id), $field_name); 153 154 // Check if the change selector is set to "No Change" for non-checkbox fields 155 if ($input_type !== 'checkbox' && isset($_REQUEST[$change_field_key]) && $_REQUEST[$change_field_key] === '') { 156 bulkedittoolkit_debug_log("Skipping field $field_name due to 'No Change' selection", $GLOBALS["bulkedittoolkit_is_debug_active"]); 155 157 continue; 156 158 } 157 // For checkboxes, treat empty value as false 158 if ($value === '' && $input_type === 'checkbox') { 159 $value = false; 160 bulkedittoolkit_debug_log("Checkbox $field_name received empty value, setting to false", $GLOBALS["bulkedittoolkit_is_debug_active"]); 161 } 162 } else { 163 // Si la clé n'est pas définie, cela signifie que la checkbox est décochée 159 160 // Handle checkboxes specifically 164 161 if ($input_type === 'checkbox') { 165 $value = false; // ou false, selon ce que votre logique attend 166 bulkedittoolkit_debug_log("Checkbox $field_name not set, applying false", $GLOBALS["bulkedittoolkit_is_debug_active"]); 162 if (isset($_REQUEST[$custom_field_key])) { 163 $value = sanitize_text_field($_REQUEST[$custom_field_key]); 164 if ($value === 'indeterminate') { 165 bulkedittoolkit_debug_log("Checkbox $field_name is indeterminate, skipping", $GLOBALS["bulkedittoolkit_is_debug_active"]); 166 continue; 167 } 168 $value = $value === 'yes' ? 'yes' : 'no'; 169 bulkedittoolkit_debug_log("Checkbox $field_name set to $value", $GLOBALS["bulkedittoolkit_is_debug_active"]); 170 } else { 171 bulkedittoolkit_debug_log("Checkbox $field_name not set in request, skipping", $GLOBALS["bulkedittoolkit_is_debug_active"]); 172 continue; // Skip if checkbox is not included (unlikely with name attribute kept) 173 } 167 174 } else { 168 bulkedittoolkit_debug_log("Skipping non-checkbox field $field_name as it was not submitted", $GLOBALS["bulkedittoolkit_is_debug_active"]); 169 continue; 170 } 171 } 175 if (isset($_REQUEST[$custom_field_key])) { 176 $value = sanitize_text_field($_REQUEST[$custom_field_key]); 177 // Skip empty values for non-checkbox fields when "Change to" is selected 178 if ($value === '' && isset($_REQUEST[$change_field_key]) && $_REQUEST[$change_field_key] === '1') { 179 bulkedittoolkit_debug_log("Skipping empty value for non-checkbox field $field_name", $GLOBALS["bulkedittoolkit_is_debug_active"]); 180 continue; 181 } 182 } else { 183 bulkedittoolkit_debug_log("Skipping non-checkbox field $field_name as it was not submitted", $GLOBALS["bulkedittoolkit_is_debug_active"]); 184 continue; 185 } 186 } 172 187 bulkedittoolkit_debug_log("Value for $field_name: $value", $GLOBALS["bulkedittoolkit_is_debug_active"]); 173 188 foreach ($posts_to_update as $post_id) { 174 // Supposant que set_coming_soon peut gérer différents champs ou que vous avez une fonction plus générique175 189 bulkedittoolkit_set_coming_soon($post_id, $field_name, $value); 176 190 bulkedittoolkit_debug_log("Bulk edit set $field_name to $value for post $post_id", $GLOBALS["bulkedittoolkit_is_debug_active"]); 177 191 } 178 } 179 //} 192 } 180 193 return; // Sortir après avoir traité la modification en masse 181 194 } 182 if (isset($_REQUEST["action"]) && $_REQUEST["action"] === "inline-save" && isset($_REQUEST["post_ID"])) { 183 $post_id = intval($_REQUEST["post_ID"]); // Sanitize post ID 184 if (get_post($post_id)) { // Check if the post exists 185 bulkedittoolkit_save_custom_quick_edit($post_id); 186 } else { 187 bulkedittoolkit_debug_log("Post with ID $post_id does not exist."); 188 // Optionally, you can redirect or send an error message here 189 // wp_redirect(admin_url('edit.php?message=error')); 190 // exit; 191 } 192 } 195 if (isset($_REQUEST["action"]) && $_REQUEST["action"] === "inline-save" && isset($_REQUEST["post_ID"])) { 196 $post_id = intval($_REQUEST["post_ID"]); 197 if (get_post($post_id)) { 198 bulkedittoolkit_save_custom_quick_edit($post_id); 199 } else { 200 bulkedittoolkit_debug_log("Post with ID $post_id does not exist."); 201 } 202 } 193 203 } 194 204 function bulkedittoolkit_add_custom_columns($columns) { -
bulk-content-toolkit/tags/1.2.4/js/user.js
r3349789 r3350006 89 89 bulkEditSwitch.indeterminate = true; 90 90 bulkEditSwitch.checked = false; 91 bulkEditSwitch.removeAttribute('name'); 91 bulkEditSwitch.setAttribute('name', 'custom_' + fieldName); 92 bulkEditSwitch.setAttribute('value', 'indeterminate'); 92 93 bulkEditSwitch.setAttribute('data-indeterminate', 'true'); 93 94 bulkEditSwitch.parentNode.classList.add('indeterminate'); -
bulk-content-toolkit/tags/1.2.4/readme.txt
r3349789 r3350006 6 6 Tested up to: 6.8 7 7 Requires PHP: 7.4 8 Stable Tag: 1.2. 38 Stable Tag: 1.2.4 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 46 46 47 47 == Changelog == 48 49 = 1.2.4 = 50 - Fixed: Ensured "Aucun changement" (No Change) option for select fields in bulk edit correctly prevents unintended updates to fields. 51 - Attempt: Correct Select and Switches behavior in bulk edit mode by passing undetermined states into $_REQUEST instead of deleting names. 48 52 49 53 = 1.2.3 = -
bulk-content-toolkit/trunk/bulk-content-toolkit.php
r3349789 r3350006 3 3 Plugin Name: Bulk Content Toolkit 4 4 Description: A comprehensive toolkit for efficiently managing bulk actions on various types of content in WordPress, including posts, pages, and custom post types. 5 Version: 1.2. 35 Version: 1.2.4 6 6 Requires at least: 5.0 7 7 Tested up to: 6.8 … … 116 116 } 117 117 } 118 function bulkedittoolkit_save_custom_bulk_edit($post_id) { // modification de masse via quick edit118 function bulkedittoolkit_save_custom_bulk_edit($post_id) { 119 119 global $bulkedittoolkit_bulk_edit_settings; 120 bulkedittoolkit_debug_log("Hook save_post_product called for post ID: $post_id", $GLOBALS["bulkedittoolkit_is_debug_active"]);121 if (isset($_REQUEST['post'])) {120 bulkedittoolkit_debug_log("Hook save_post_product called for post ID: $post_id", $GLOBALS["bulkedittoolkit_is_debug_active"]); 121 if (isset($_REQUEST['post'])) { 122 122 bulkedittoolkit_debug_log("Posts in REQUEST: " . print_r($_REQUEST['post'], true), $GLOBALS["bulkedittoolkit_is_debug_active"]); 123 123 } 124 //error_log("EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"); 124 125 125 // Vérifiez si c'est une autosave ou si le type de post ne correspond pas 126 126 if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) { … … 132 132 } 133 133 $fields_names = bulkedittoolkit_get_bulk_edit_field_name(get_post_type($post_id)); 134 134 135 // Traitement de la modification en masse 135 136 bulkedittoolkit_debug_log("before"); 136 137 if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'edit' && isset($_REQUEST['bulk_edit'])) { 137 bulkedittoolkit_debug_log("after"); 138 // Sanitize and validate the array of post IDs 139 $posts_to_update = isset($_REQUEST['post']) ? (array)$_REQUEST['post'] : array(); 140 $posts_to_update = array_map('intval', $posts_to_update); // Convert all elements to integers 141 $posts_to_update = array_filter($posts_to_update); // Remove any potential falsy values (like 0 or empty strings) 142 foreach ($fields_names as $field_name => $field_details) { 143 bulkedittoolkit_debug_log("loop"); 144 bulkedittoolkit_debug_log($field_name); 145 // Vérifie si ce champ spécifique est soumis dans la requête 146 $custom_field_key = 'custom_' . $field_name; 147 bulkedittoolkit_debug_log($custom_field_key); 148 // Get the input type for the field 149 $input_type = $bulkedittoolkit_bulk_edit_settings->bulkedittoolkit_get_input_type(get_post_type($post_id), $field_name); 150 if (isset($_REQUEST[$custom_field_key])) { 151 $value = sanitize_text_field($_REQUEST[$custom_field_key]); // 'yes' si coché, sinon la valeur soumise 152 // Skip empty values for non-checkbox fields to respect "— Aucun changement —" 153 if ($value === '' && $input_type !== 'checkbox') { 154 bulkedittoolkit_debug_log("Skipping empty value for non-checkbox field $field_name", $GLOBALS["bulkedittoolkit_is_debug_active"]); 138 bulkedittoolkit_debug_log("after"); 139 // Sanitize and validate the array of post IDs 140 $posts_to_update = isset($_REQUEST['post']) ? (array)$_REQUEST['post'] : array(); 141 $posts_to_update = array_map('intval', $posts_to_update); // Convert all elements to integers 142 $posts_to_update = array_filter($posts_to_update); // Remove any potential falsy values (like 0 or empty strings) 143 foreach ($fields_names as $field_name => $custom_field_key) { 144 bulkedittoolkit_debug_log("loop"); 145 bulkedittoolkit_debug_log($field_name); 146 // Vérifie si ce champ spécifique est soumis dans la requête 147 $change_field_key = 'change_custom_' . $field_name; 148 $custom_field_key = 'custom_' . $field_name; 149 bulkedittoolkit_debug_log($custom_field_key); 150 151 // Get the input type for the field 152 $input_type = $bulkedittoolkit_bulk_edit_settings->bulkedittoolkit_get_input_type(get_post_type($post_id), $field_name); 153 154 // Check if the change selector is set to "No Change" for non-checkbox fields 155 if ($input_type !== 'checkbox' && isset($_REQUEST[$change_field_key]) && $_REQUEST[$change_field_key] === '') { 156 bulkedittoolkit_debug_log("Skipping field $field_name due to 'No Change' selection", $GLOBALS["bulkedittoolkit_is_debug_active"]); 155 157 continue; 156 158 } 157 // For checkboxes, treat empty value as false 158 if ($value === '' && $input_type === 'checkbox') { 159 $value = false; 160 bulkedittoolkit_debug_log("Checkbox $field_name received empty value, setting to false", $GLOBALS["bulkedittoolkit_is_debug_active"]); 161 } 162 } else { 163 // Si la clé n'est pas définie, cela signifie que la checkbox est décochée 159 160 // Handle checkboxes specifically 164 161 if ($input_type === 'checkbox') { 165 $value = false; // ou false, selon ce que votre logique attend 166 bulkedittoolkit_debug_log("Checkbox $field_name not set, applying false", $GLOBALS["bulkedittoolkit_is_debug_active"]); 162 if (isset($_REQUEST[$custom_field_key])) { 163 $value = sanitize_text_field($_REQUEST[$custom_field_key]); 164 if ($value === 'indeterminate') { 165 bulkedittoolkit_debug_log("Checkbox $field_name is indeterminate, skipping", $GLOBALS["bulkedittoolkit_is_debug_active"]); 166 continue; 167 } 168 $value = $value === 'yes' ? 'yes' : 'no'; 169 bulkedittoolkit_debug_log("Checkbox $field_name set to $value", $GLOBALS["bulkedittoolkit_is_debug_active"]); 170 } else { 171 bulkedittoolkit_debug_log("Checkbox $field_name not set in request, skipping", $GLOBALS["bulkedittoolkit_is_debug_active"]); 172 continue; // Skip if checkbox is not included (unlikely with name attribute kept) 173 } 167 174 } else { 168 bulkedittoolkit_debug_log("Skipping non-checkbox field $field_name as it was not submitted", $GLOBALS["bulkedittoolkit_is_debug_active"]); 169 continue; 170 } 171 } 175 if (isset($_REQUEST[$custom_field_key])) { 176 $value = sanitize_text_field($_REQUEST[$custom_field_key]); 177 // Skip empty values for non-checkbox fields when "Change to" is selected 178 if ($value === '' && isset($_REQUEST[$change_field_key]) && $_REQUEST[$change_field_key] === '1') { 179 bulkedittoolkit_debug_log("Skipping empty value for non-checkbox field $field_name", $GLOBALS["bulkedittoolkit_is_debug_active"]); 180 continue; 181 } 182 } else { 183 bulkedittoolkit_debug_log("Skipping non-checkbox field $field_name as it was not submitted", $GLOBALS["bulkedittoolkit_is_debug_active"]); 184 continue; 185 } 186 } 172 187 bulkedittoolkit_debug_log("Value for $field_name: $value", $GLOBALS["bulkedittoolkit_is_debug_active"]); 173 188 foreach ($posts_to_update as $post_id) { 174 // Supposant que set_coming_soon peut gérer différents champs ou que vous avez une fonction plus générique175 189 bulkedittoolkit_set_coming_soon($post_id, $field_name, $value); 176 190 bulkedittoolkit_debug_log("Bulk edit set $field_name to $value for post $post_id", $GLOBALS["bulkedittoolkit_is_debug_active"]); 177 191 } 178 } 179 //} 192 } 180 193 return; // Sortir après avoir traité la modification en masse 181 194 } 182 if (isset($_REQUEST["action"]) && $_REQUEST["action"] === "inline-save" && isset($_REQUEST["post_ID"])) { 183 $post_id = intval($_REQUEST["post_ID"]); // Sanitize post ID 184 if (get_post($post_id)) { // Check if the post exists 185 bulkedittoolkit_save_custom_quick_edit($post_id); 186 } else { 187 bulkedittoolkit_debug_log("Post with ID $post_id does not exist."); 188 // Optionally, you can redirect or send an error message here 189 // wp_redirect(admin_url('edit.php?message=error')); 190 // exit; 191 } 192 } 195 if (isset($_REQUEST["action"]) && $_REQUEST["action"] === "inline-save" && isset($_REQUEST["post_ID"])) { 196 $post_id = intval($_REQUEST["post_ID"]); 197 if (get_post($post_id)) { 198 bulkedittoolkit_save_custom_quick_edit($post_id); 199 } else { 200 bulkedittoolkit_debug_log("Post with ID $post_id does not exist."); 201 } 202 } 193 203 } 194 204 function bulkedittoolkit_add_custom_columns($columns) { -
bulk-content-toolkit/trunk/js/user.js
r3349789 r3350006 89 89 bulkEditSwitch.indeterminate = true; 90 90 bulkEditSwitch.checked = false; 91 bulkEditSwitch.removeAttribute('name'); 91 bulkEditSwitch.setAttribute('name', 'custom_' + fieldName); 92 bulkEditSwitch.setAttribute('value', 'indeterminate'); 92 93 bulkEditSwitch.setAttribute('data-indeterminate', 'true'); 93 94 bulkEditSwitch.parentNode.classList.add('indeterminate'); -
bulk-content-toolkit/trunk/readme.txt
r3349789 r3350006 6 6 Tested up to: 6.8 7 7 Requires PHP: 7.4 8 Stable Tag: 1.2. 38 Stable Tag: 1.2.4 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 46 46 47 47 == Changelog == 48 49 = 1.2.4 = 50 - Fixed: Ensured "Aucun changement" (No Change) option for select fields in bulk edit correctly prevents unintended updates to fields. 51 - Attempt: Correct Select and Switches behavior in bulk edit mode by passing undetermined states into $_REQUEST instead of deleting names. 48 52 49 53 = 1.2.3 =
Note: See TracChangeset
for help on using the changeset viewer.