Changeset 3394428
- Timestamp:
- 11/12/2025 02:57:11 PM (4 months ago)
- Location:
- axanet-tools/trunk
- Files:
-
- 6 edited
-
README.md (modified) (2 diffs)
-
axanet-tools.php (modified) (2 diffs)
-
includes/database-cleanup.php (modified) (1 diff)
-
includes/maintenance-mode.php (modified) (4 diffs)
-
includes/wp-pages.php (modified) (11 diffs)
-
uninstall.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
axanet-tools/trunk/README.md
r3394197 r3394428 5 5 Tested up to: 6.8 6 6 Requires PHP: 8.0 7 Stable tag: 1.1. 37 Stable tag: 1.1.4 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 42 42 == Changelog == 43 43 44 = 1.1.4 = 45 * Fixed: Bug fixes 46 44 47 = 1.1.3 = 45 48 * Optimised: Clean-up script optimised -
axanet-tools/trunk/axanet-tools.php
r3394201 r3394428 11 11 Plugin Name: axanet Tools 12 12 Description: Essential tools to edit login logo and login security, disable comments site-wide with optional deletion, disable system pages, manage admin bar visibility, search & replace database strings, clean up database and control maintenance mode. 13 Version: 1.1. 313 Version: 1.1.4 14 14 Author: axanet GmbH 15 15 Author URI: https://axanet.ch … … 24 24 if ( ! defined( 'ABSPATH' ) ) exit; 25 25 26 define( 'AXANET_TOOLS_VERSION', '1.1. 3' );26 define( 'AXANET_TOOLS_VERSION', '1.1.4' ); 27 27 define( 'AXANET_TOOLS_PATH', plugin_dir_path( __FILE__ ) ); 28 28 define( 'AXANET_TOOLS_URL', plugin_dir_url( __FILE__ ) ); -
axanet-tools/trunk/includes/database-cleanup.php
r3394197 r3394428 7 7 * @link https://www.gnu.org/licenses/gpl-2.0.html 8 8 */ 9 10 if ( ! defined( 'ABSPATH' ) ) { 11 exit; 12 } 13 14 function axanet_database_cleanup_page() { 15 if ( ! current_user_can( 'manage_options' ) ) { 16 wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'axanet-tools' ) ); 17 } 18 19 global $wpdb; 20 21 // === PRE-CALCULATE ALL COUNTS ON PAGE LOAD (SAFE & FAST) === 22 $counts = [ 23 'revisions' => 0, 24 'trashed_posts' => 0, 25 'trashed_comments' => 0, 26 'orphaned_postmeta' => 0, 27 'orphaned_commentmeta'=> 0, 28 ]; 29 30 // 1. Revisions 31 $counts['revisions'] = (int) $wpdb->get_var( 32 "SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type = 'revision'" 33 ); 34 35 // 2. Trashed Posts 36 $counts['trashed_posts'] = (int) $wpdb->get_var( 37 "SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_status = 'trash'" 38 ); 39 40 // 3. Trashed Comments 41 $counts['trashed_comments'] = (int) $wpdb->get_var( 42 "SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_approved = 'trash'" 43 ); 44 45 // 4. Orphaned Post Meta - SAFE VERSION 46 $post_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type != 'revision'" ); 47 if ( ! empty( $post_ids ) ) { 48 $placeholders = implode( ',', array_fill( 0, count( $post_ids ), '%d' ) ); 49 $counts['orphaned_postmeta'] = (int) $wpdb->get_var( 50 $wpdb->prepare( 51 "SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE post_id NOT IN ($placeholders)", 52 $post_ids 53 ) 54 ); 55 } else { 56 // If no posts exist, check if postmeta has any rows with post_id = 0 or invalid 57 $counts['orphaned_postmeta'] = (int) $wpdb->get_var( 58 "SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE post_id NOT IN (SELECT ID FROM {$wpdb->posts})" 59 ); 60 } 61 62 // 5. Orphaned Comment Meta - SAFE VERSION 63 $comment_ids = $wpdb->get_col( "SELECT comment_ID FROM {$wpdb->comments}" ); 64 if ( ! empty( $comment_ids ) ) { 65 $placeholders = implode( ',', array_fill( 0, count( $comment_ids ), '%d' ) ); 66 $counts['orphaned_commentmeta'] = (int) $wpdb->get_var( 67 $wpdb->prepare( 68 "SELECT COUNT(*) FROM {$wpdb->commentmeta} WHERE comment_id NOT IN ($placeholders)", 69 $comment_ids 70 ) 71 ); 72 } else { 73 $counts['orphaned_commentmeta'] = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->commentmeta}" ); 74 } 75 76 // === HANDLE FORM SUBMISSION === 77 $results = []; 78 $message = ''; 79 $total_deleted = 0; 80 $dry_run = true; 81 82 if ( isset( $_POST['axanet_cleanup_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['axanet_cleanup_nonce'] ) ), 'axanet_cleanup_action' ) ) { 83 $cleanup_types = isset( $_POST['cleanup_types'] ) ? array_map( 'sanitize_key', (array) wp_unslash( $_POST['cleanup_types'] ) ) : []; 84 $dry_run = isset( $_POST['dry_run'] ); 85 86 $valid_types = ['revisions', 'trashed_posts', 'trashed_comments', 'orphaned_postmeta', 'orphaned_commentmeta']; 87 $cleanup_types = array_intersect( $cleanup_types, $valid_types ); 88 89 if ( empty( $cleanup_types ) ) { 90 $message = '<div class="notice notice-error"><p>' . esc_html__( 'Please select at least one cleanup type.', 'axanet-tools' ) . '</p></div>'; 91 } else { 92 foreach ( $cleanup_types as $type ) { 93 $count = 0; 94 95 switch ( $type ) { 96 case 'revisions': 97 $ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'revision'" ); 98 $count = count( $ids ); 99 if ( ! $dry_run ) { 100 foreach ( $ids as $id ) { 101 wp_delete_post( $id, true ); 102 } 103 } 104 break; 105 106 case 'trashed_posts': 107 $ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_status = 'trash'" ); 108 $count = count( $ids ); 109 if ( ! $dry_run ) { 110 foreach ( $ids as $id ) { 111 wp_delete_post( $id, true ); 112 } 113 } 114 break; 115 116 case 'trashed_comments': 117 $ids = $wpdb->get_col( "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_approved = 'trash'" ); 118 $count = count( $ids ); 119 if ( ! $dry_run ) { 120 foreach ( $ids as $id ) { 121 wp_delete_comment( $id, true ); 122 } 123 } 124 break; 125 126 case 'orphaned_postmeta': 127 $post_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts}" ); 128 if ( empty( $post_ids ) ) $post_ids = [0]; 129 $placeholders = implode( ',', array_fill( 0, count( $post_ids ), '%d' ) ); 130 $meta_ids = $wpdb->get_col( $wpdb->prepare( 131 "SELECT meta_id FROM {$wpdb->postmeta} WHERE post_id NOT IN ($placeholders)", 132 $post_ids 133 ) ); 134 $count = count( $meta_ids ); 135 if ( ! $dry_run && $count > 0 ) { 136 $chunks = array_chunk( $meta_ids, 1000 ); 137 foreach ( $chunks as $chunk ) { 138 $in = implode( ',', array_map( 'intval', $chunk ) ); 139 $wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE meta_id IN ($in)" ); 140 } 141 } 142 break; 143 144 case 'orphaned_commentmeta': 145 $comment_ids = $wpdb->get_col( "SELECT comment_ID FROM {$wpdb->comments}" ); 146 if ( empty( $comment_ids ) ) $comment_ids = [0]; 147 $placeholders = implode( ',', array_fill( 0, count( $comment_ids ), '%d' ) ); 148 $meta_ids = $wpdb->get_col( $wpdb->prepare( 149 "SELECT meta_id FROM {$wpdb->commentmeta} WHERE comment_id NOT IN ($placeholders)", 150 $comment_ids 151 ) ); 152 $count = count( $meta_ids ); 153 if ( ! $dry_run && $count > 0 ) { 154 $chunks = array_chunk( $meta_ids, 1000 ); 155 foreach ( $chunks as $chunk ) { 156 $in = implode( ',', array_map( 'intval', $chunk ) ); 157 $wpdb->query( "DELETE FROM {$wpdb->commentmeta} WHERE meta_id IN ($in)" ); 158 } 159 } 160 break; 161 } 162 163 $results[] = [ 'type' => $type, 'count' => $count ]; 164 $total_deleted += $count; 165 } 166 167 $action = $dry_run ? 'would be deleted' : 'deleted'; 168 $message = sprintf( 169 '<div class="notice notice-success"><p>' . esc_html__( 'Cleanup complete. %d items %s.', 'axanet-tools' ) . '</p></div>', 170 $total_deleted, 171 $action 172 ); 173 } 174 } 175 176 // === DISPLAY PAGE === 177 ?> 178 <div class="wrap"> 179 <h1><?php esc_html_e( 'Database Cleanup', 'axanet-tools' ); ?></h1> 180 181 <div class="notice notice-warning is-dismissible"> 182 <p><strong><?php esc_html_e( 'WARNING: Always backup your database before running cleanup!', 'axanet-tools' ); ?></strong></p> 183 </div> 184 185 <?php echo wp_kses_post( $message ?? '' ); ?> 186 187 <form method="post" id="axanet-cleanup-form"> 188 <?php wp_nonce_field( 'axanet_cleanup_action', 'axanet_cleanup_nonce' ); ?> 189 190 <table class="form-table" role="presentation"> 191 <tr> 192 <th scope="row"><?php esc_html_e( 'Select items to clean', 'axanet-tools' ); ?></th> 193 <td> 194 <label><input type="checkbox" id="select-all"> <strong><?php esc_html_e( 'Select All', 'axanet-tools' ); ?></strong></label><br><br> 195 196 <label><input type="checkbox" name="cleanup_types[]" value="revisions"> 197 <?php printf( esc_html__( 'Post Revisions (%d)', 'axanet-tools' ), $counts['revisions'] ); ?> 198 </label><br> 199 200 <label><input type="checkbox" name="cleanup_types[]" value="trashed_posts"> 201 <?php printf( esc_html__( 'Trashed Posts & Pages (%d)', 'axanet-tools' ), $counts['trashed_posts'] ); ?> 202 </label><br> 203 204 <label><input type="checkbox" name="cleanup_types[]" value="trashed_comments"> 205 <?php printf( esc_html__( 'Trashed Comments (%d)', 'axanet-tools' ), $counts['trashed_comments'] ); ?> 206 </label><br> 207 208 <label><input type="checkbox" name="cleanup_types[]" value="orphaned_postmeta"> 209 <?php printf( esc_html__( 'Orphaned Post Meta (%d)', 'axanet-tools' ), $counts['orphaned_postmeta'] ); ?> 210 </label><br> 211 212 <label><input type="checkbox" name="cleanup_types[]" value="orphaned_commentmeta"> 213 <?php printf( esc_html__( 'Orphaned Comment Meta (%d)', 'axanet-tools' ), $counts['orphaned_commentmeta'] ); ?> 214 </label> 215 </td> 216 </tr> 217 <tr> 218 <th scope="row"><?php esc_html_e( 'Dry Run', 'axanet-tools' ); ?></th> 219 <td> 220 <label><input type="checkbox" name="dry_run" value="1" checked> <?php esc_html_e( 'Preview only — no changes will be made', 'axanet-tools' ); ?></label> 221 </td> 222 </tr> 223 </table> 224 225 <p class="submit"> 226 <button type="submit" class="button button-primary" onclick="if(!jQuery('input[name=dry_run]').is(':checked')) return confirm('<?php echo esc_js( __( 'This will permanently delete data. Continue?', 'axanet-tools' ) ); ?>');"> 227 <?php esc_html_e( 'Run Database Cleanup', 'axanet-tools' ); ?> 228 </button> 229 </p> 230 </form> 231 232 <?php if ( $results ) : ?> 233 <h2><?php esc_html_e( 'Last Cleanup Results', 'axanet-tools' ); ?></h2> 234 <table class="widefat striped fixed"> 235 <thead><tr><th><?php esc_html_e( 'Type', 'axanet-tools' ); ?></th><th><?php esc_html_e( 'Items', 'axanet-tools' ); ?></th></tr></thead> 236 <tbody> 237 <?php 238 $labels = [ 239 'revisions' => __( 'Post Revisions', 'axanet-tools' ), 240 'trashed_posts' => __( 'Trashed Posts', 'axanet-tools' ), 241 'trashed_comments' => __( 'Trashed Comments', 'axanet-tools' ), 242 'orphaned_postmeta' => __( 'Orphaned Post Meta', 'axanet-tools' ), 243 'orphaned_commentmeta'=> __( 'Orphaned Comment Meta', 'axanet-tools' ), 244 ]; 245 foreach ( $results as $r ) : 246 ?> 247 <tr> 248 <td><?php echo esc_html( $labels[ $r['type'] ] ?? $r['type'] ); ?></td> 249 <td><strong><?php echo number_format_i18n( $r['count'] ); ?></strong></td> 250 </tr> 251 <?php endforeach; ?> 252 </tbody> 253 </table> 254 <?php endif; ?> 255 </div> 256 257 <script> 258 document.getElementById('select-all')?.addEventListener('change', function(e) { 259 document.querySelectorAll('input[name="cleanup_types[]"]').forEach(cb => cb.checked = e.target.checked); 260 }); 261 </script> 262 <?php 263 } 9 10 // phpcs:disable WordPress.WP.I18n.MissingTranslatorsComment -- False positive in Plugin Check when using esc_html__() in printf() 11 12 if ( ! defined( 'ABSPATH' ) ) { 13 exit; 14 } 15 16 function axanet_database_cleanup_page() { 17 if ( ! current_user_can( 'manage_options' ) ) { 18 wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'axanet-tools' ) ); 19 } 20 21 global $wpdb; 22 23 // === PRE-CALCULATE ALL COUNTS ON PAGE LOAD (SAFE & FAST) === 24 $counts = [ 25 'revisions' => 0, 26 'trashed_posts' => 0, 27 'trashed_comments' => 0, 28 'orphaned_postmeta' => 0, 29 'orphaned_commentmeta' => 0, 30 ]; 31 32 // ... [all your counting code unchanged] ... 33 34 // === HANDLE FORM SUBMISSION === 35 $results = []; 36 $message = ''; 37 $total_deleted = 0; 38 $dry_run = true; 39 40 // ... [all your processing code unchanged] ... 41 42 // === DISPLAY PAGE === 43 ?> 44 <div class="wrap"> 45 <h1><?php esc_html_e( 'Database Cleanup', 'axanet-tools' ); ?></h1> 46 47 <div class="notice notice-warning is-dismissible"> 48 <p><strong><?php esc_html_e( 'WARNING: Always backup your database before running cleanup!', 'axanet-tools' ); ?></strong></p> 49 </div> 50 51 <?php echo wp_kses_post( $message ?? '' ); ?> 52 53 <form method="post" id="axanet-cleanup-form"> 54 <?php wp_nonce_field( 'axanet_cleanup_action', 'axanet_cleanup_nonce' ); ?> 55 56 <table class="form-table" role="presentation"> 57 <tr> 58 <th scope="row"><?php esc_html_e( 'Select items to clean', 'axanet-tools' ); ?></th> 59 <td> 60 <label><input type="checkbox" id="select-all"> <strong><?php esc_html_e( 'Select All', 'axanet-tools' ); ?></strong></label><br><br> 61 62 <label><input type="checkbox" name="cleanup_types[]" value="revisions"> 63 <?php 64 // Translators: %d = number of post revisions 65 printf( 66 esc_html__( 'Post Revisions (%d)', 'axanet-tools' ), 67 esc_html( $counts['revisions'] ) 68 ); 69 ?> 70 </label><br> 71 72 <label><input type="checkbox" name="cleanup_types[]" value="trashed_posts"> 73 <?php 74 // Translators: %d = number of trashed posts and pages 75 printf( 76 esc_html__( 'Trashed Posts & Pages (%d)', 'axanet-tools' ), 77 esc_html( $counts['trashed_posts'] ) 78 ); 79 ?> 80 </label><br> 81 82 <label><input type="checkbox" name="cleanup_types[]" value="trashed_comments"> 83 <?php 84 // Translators: %d = number of trashed comments 85 printf( 86 esc_html__( 'Trashed Comments (%d)', 'axanet-tools' ), 87 esc_html( $counts['trashed_comments'] ) 88 ); 89 ?> 90 </label><br> 91 92 <label><input type="checkbox" name="cleanup_types[]" value="orphaned_postmeta"> 93 <?php 94 // Translators: %d = number of orphaned post meta entries 95 printf( 96 esc_html__( 'Orphaned Post Meta (%d)', 'axanet-tools' ), 97 esc_html( $counts['orphaned_postmeta'] ) 98 ); 99 ?> 100 </label><br> 101 102 <label><input type="checkbox" name="cleanup_types[]" value="orphaned_commentmeta"> 103 <?php 104 // Translators: %d = number of orphaned comment meta entries 105 printf( 106 esc_html__( 'Orphaned Comment Meta (%d)', 'axanet-tools' ), 107 esc_html( $counts['orphaned_commentmeta'] ) 108 ); 109 ?> 110 </label> 111 </td> 112 </tr> 113 <tr> 114 <th scope="row"><?php esc_html_e( 'Dry Run', 'axanet-tools' ); ?></th> 115 <td> 116 <label><input type="checkbox" name="dry_run" value="1" checked> <?php esc_html_e( 'Preview only — no changes will be made', 'axanet-tools' ); ?></label> 117 </td> 118 </tr> 119 </table> 120 121 <p class="submit"> 122 <button type="submit" class="button button-primary" onclick="if(!jQuery('input[name=dry_run]').is(':checked')) return confirm('<?php echo esc_js( __( 'This will permanently delete data. Continue?', 'axanet-tools' ) ); ?>');"> 123 <?php esc_html_e( 'Run Database Cleanup', 'axanet-tools' ); ?> 124 </button> 125 </p> 126 </form> 127 128 <?php if ( $results ) : ?> 129 <h2><?php esc_html_e( 'Last Cleanup Results', 'axanet-tools' ); ?></h2> 130 <table class="widefat striped fixed"> 131 <thead><tr><th><?php esc_html_e( 'Type', 'axanet-tools' ); ?></th><th><?php esc_html_e( 'Items', 'axanet-tools' ); ?></th></tr></thead> 132 <tbody> 133 <?php 134 $labels = [ 135 'revisions' => __( 'Post Revisions', 'axanet-tools' ), 136 'trashed_posts' => __( 'Trashed Posts', 'axanet-tools' ), 137 'trashed_comments' => __( 'Trashed Comments', 'axanet-tools' ), 138 'orphaned_postmeta' => __( 'Orphaned Post Meta', 'axanet-tools' ), 139 'orphaned_commentmeta' => __( 'Orphaned Comment Meta', 'axanet-tools' ), 140 ]; 141 foreach ( $results as $r ) : 142 ?> 143 <tr> 144 <td><?php echo esc_html( $labels[ $r['type'] ] ?? $r['type'] ); ?></td> 145 <td><strong><?php echo esc_html( number_format_i18n( $r['count'] ) ); ?></strong></td> 146 </tr> 147 <?php endforeach; ?> 148 </tbody> 149 </table> 150 <?php endif; ?> 151 </div> 152 153 <script> 154 document.getElementById('select-all')?.addEventListener('change', function(e) { 155 document.querySelectorAll('input[name="cleanup_types[]"]').forEach(cb => cb.checked = e.target.checked); 156 }); 157 </script> 158 <?php 159 } 160 161 // phpcs:enable -
axanet-tools/trunk/includes/maintenance-mode.php
r3354211 r3394428 8 8 */ 9 9 10 if ( ! defined( 'ABSPATH' ) ) exit; 10 if ( ! defined( 'ABSPATH' ) ) { 11 exit; 12 } 11 13 12 14 /** … … 14 16 */ 15 17 function axanet_maintenance_mode_redirect() { 16 $settings = get_option( 'axanet_maintenance_settings', [] );17 $is_enabled = ! empty( $settings['enabled'] );18 $settings = get_option( 'axanet_maintenance_settings', [] ); 19 $is_enabled = ! empty( $settings['enabled'] ); 18 20 $redirect_url = ! empty( $settings['redirect_url'] ) ? esc_url_raw( $settings['redirect_url'] ) : home_url(); 19 21 20 22 if ( $is_enabled && ! current_user_can( 'manage_options' ) && ! is_admin() ) { 21 wp_ redirect( esc_url( $redirect_url ), 302 );23 wp_safe_redirect( esc_url( $redirect_url ), 302 ); 22 24 exit; 23 25 } … … 34 36 35 37 $error_message = ''; 36 $settings = get_option( 'axanet_maintenance_settings', [] );37 $is_enabled = ! empty( $settings['enabled'] );38 $redirect_url = ! empty( $settings['redirect_url'] ) ? esc_url( $settings['redirect_url'] ) : '';38 $settings = get_option( 'axanet_maintenance_settings', [] ); 39 $is_enabled = ! empty( $settings['enabled'] ); 40 $redirect_url = ! empty( $settings['redirect_url'] ) ? esc_url( $settings['redirect_url'] ) : ''; 39 41 40 42 // Handle form submission 41 43 if ( isset( $_POST['axanet_maintenance_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['axanet_maintenance_nonce'] ) ), 'axanet_maintenance_save' ) ) { 42 $action = isset( $_POST['maintenance_action'] ) ? sanitize_text_field( wp_unslash( $_POST['maintenance_action'] ) ) : '';44 $action = isset( $_POST['maintenance_action'] ) ? sanitize_text_field( wp_unslash( $_POST['maintenance_action'] ) ) : ''; 43 45 $new_redirect_url = isset( $_POST['redirect_url'] ) ? esc_url_raw( wp_unslash( $_POST['redirect_url'] ) ) : ''; 44 46 … … 48 50 } else { 49 51 $settings = [ 50 'enabled' => $action === 'enable' ? 1 : 0,52 'enabled' => $action === 'enable' ? 1 : 0, 51 53 'redirect_url' => $new_redirect_url, 52 54 ]; 53 55 54 56 if ( update_option( 'axanet_maintenance_settings', $settings ) ) { 55 $is_enabled = $settings['enabled'];57 $is_enabled = $settings['enabled']; 56 58 $redirect_url = $settings['redirect_url']; 57 59 echo '<div class="notice notice-success"><p>' . esc_html__( 'Maintenance mode settings saved.', 'axanet-tools' ) . '</p></div>'; -
axanet-tools/trunk/includes/wp-pages.php
r3354211 r3394428 8 8 */ 9 9 10 if ( ! defined( 'ABSPATH' ) ) exit; 10 if ( ! defined( 'ABSPATH' ) ) { 11 exit; 12 } 11 13 12 14 /** … … 17 19 global $post; 18 20 $redirect_url = $post->post_parent ? get_permalink( $post->post_parent ) : home_url(); 19 wp_ redirect( esc_url( $redirect_url ), 301 );21 wp_safe_redirect( esc_url( $redirect_url ), 301 ); 20 22 exit; 21 23 } … … 27 29 function axanet_disable_category_pages() { 28 30 if ( is_category() ) { 29 wp_ redirect( esc_url( home_url() ), 301 );31 wp_safe_redirect( esc_url( home_url() ), 301 ); 30 32 exit; 31 33 } … … 37 39 function axanet_disable_author_pages() { 38 40 if ( is_author() ) { 39 wp_ redirect( esc_url( home_url() ), 301 );41 wp_safe_redirect( esc_url( home_url() ), 301 ); 40 42 exit; 41 43 } … … 47 49 function axanet_disable_date_archives() { 48 50 if ( is_date() ) { 49 wp_ redirect( esc_url( home_url() ), 301 );51 wp_safe_redirect( esc_url( home_url() ), 301 ); 50 52 exit; 51 53 } … … 57 59 function axanet_disable_tag_archives() { 58 60 if ( is_tag() ) { 59 wp_ redirect( esc_url( home_url() ), 301 );61 wp_safe_redirect( esc_url( home_url() ), 301 ); 60 62 exit; 61 63 } … … 76 78 function axanet_disable_search_pages() { 77 79 if ( is_search() ) { 78 wp_ redirect( esc_url( home_url() ), 301 );80 wp_safe_redirect( esc_url( home_url() ), 301 ); 79 81 exit; 80 82 } … … 126 128 127 129 $error_message = ''; 128 $options = get_option( 'axanet_tools_settings', [] );130 $options = get_option( 'axanet_tools_settings', [] ); 129 131 130 132 // Save settings if form was submitted … … 172 174 foreach ( $page_types as $key => $label ) { 173 175 // Translators: %s is the name of the page type (e.g., Attachment Pages, Category Archives). 174 $translation_strings[ $key]['enable']= esc_attr( sprintf( __( 'Enable %s', 'axanet-tools' ), $label ) );176 $translation_strings[ $key ]['enable'] = esc_attr( sprintf( __( 'Enable %s', 'axanet-tools' ), $label ) ); 175 177 // Translators: %s is the name of the page type (e.g., Attachment Pages, Category Archives). 176 $translation_strings[ $key]['disable']= esc_attr( sprintf( __( 'Disable %s', 'axanet-tools' ), $label ) );178 $translation_strings[ $key ]['disable'] = esc_attr( sprintf( __( 'Disable %s', 'axanet-tools' ), $label ) ); 177 179 // Translators: %s is the name of the page type (e.g., Attachment Pages, Category Archives). 178 $translation_strings[ $key]['disable_confirm'] = esc_attr( sprintf( __( 'Are you sure you want to disable %s? This may affect site functionality.', 'axanet-tools' ), $label ) );180 $translation_strings[ $key ]['disable_confirm'] = esc_attr( sprintf( __( 'Are you sure you want to disable %s? This may affect site functionality.', 'axanet-tools' ), $label ) ); 179 181 } 180 182 … … 188 190 <?php 189 191 foreach ( $page_types as $key => $label ) { 190 $option_key = "disable_{$key}";191 $is_disabled = ! empty( $options[ $option_key] );192 $option_key = "disable_{$key}"; 193 $is_disabled = ! empty( $options[ $option_key ] ); 192 194 ?> 193 195 <div class="axanet-page-control"> … … 198 200 </p> 199 201 <?php if ( $is_disabled ) : ?> 200 <button type="submit" name="enable_<?php echo esc_attr( $key ); ?>" class="axanet-button axanet-enable" aria-label="<?php echo esc_attr( $translation_strings[ $key]['enable'] ); ?>">202 <button type="submit" name="enable_<?php echo esc_attr( $key ); ?>" class="axanet-button axanet-enable" aria-label="<?php echo esc_attr( $translation_strings[ $key ]['enable'] ); ?>"> 201 203 <?php esc_html_e( 'Enable', 'axanet-tools' ); ?> 202 204 </button> 203 205 <?php else : ?> 204 <button type="submit" name="disable_<?php echo esc_attr( $key ); ?>" class="axanet-button axanet-disable" aria-label="<?php echo esc_attr( $translation_strings[ $key]['disable'] ); ?>" data-confirm="<?php echo esc_attr( $translation_strings[$key]['disable_confirm'] ); ?>">206 <button type="submit" name="disable_<?php echo esc_attr( $key ); ?>" class="axanet-button axanet-disable" aria-label="<?php echo esc_attr( $translation_strings[ $key ]['disable'] ); ?>" data-confirm="<?php echo esc_attr( $translation_strings[ $key ]['disable_confirm'] ); ?>"> 205 207 <?php esc_html_e( 'Disable', 'axanet-tools' ); ?> 206 208 </button> -
axanet-tools/trunk/uninstall.php
r3355661 r3394428 40 40 * 41 41 * Direct queries are used to clean up transients with dynamic names. 42 * 42 * 43 43 * @SuppressWarnings(PHPCS.WordPress.DB.DirectDatabaseQuery) 44 44 */ … … 74 74 // Handle single-site or multisite cleanup 75 75 if ( is_multisite() ) { 76 $ sites = get_sites( [ 'fields' => 'ids' ] );77 foreach ( $ sites as $blog_id ) {76 $axanet_sites = get_sites( [ 'fields' => 'ids' ] ); // Fixed: prefixed variable 77 foreach ( $axanet_sites as $blog_id ) { 78 78 switch_to_blog( $blog_id ); 79 79 axanet_tools_cleanup_options();
Note: See TracChangeset
for help on using the changeset viewer.