| @@ -34,8 +34,16 @@ | ||
| 34 | 34 | * Entry point – hooked to admin_init. |
| 35 | 35 | */ |
| 36 | 36 | public static function maybe_resign_shortcodes() |
| 37 | 37 | { |
| 38 | + if (function_exists('wp_doing_ajax') && wp_doing_ajax()) { | |
| 39 | + return; | |
| 40 | + } | |
| 41 | + | |
| 42 | + if (!current_user_can('manage_options')) { | |
| 43 | + return; | |
| 44 | + } | |
| 45 | + | |
| 38 | 46 | if (!self::should_run()) { |
| 39 | 47 | return; |
| 40 | 48 | } |
| 41 | 49 | |
| @@ -65,9 +73,8 @@ | ||
| 65 | 73 | |
| 66 | 74 | $updated = self::resign_templates(); |
| 67 | 75 | |
| 68 | 76 | if ($updated > 0) { |
| 69 | - error_log("MetaSync Oxygen Compat: Re-signed shortcodes in {$updated} template(s)."); | |
| 70 | 77 | $full_fp = self::build_full_fingerprint(); // Recompute after DB writes |
| 71 | 78 | } |
| 72 | 79 | |
| 73 | 80 | update_option(self::OPTION_KEY, $light_fp . '|' . $full_fp, true); |
| @@ -118,9 +125,9 @@ | ||
| 118 | 125 | global $wpdb; |
| 119 | 126 | |
| 120 | 127 | $key = get_option('oxygen_private_key', ''); |
| 121 | 128 | |
| 122 | - $row = $wpdb->get_row( | |
| 129 | + $row = $wpdb->get_row( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- reads Oxygen builder template storage — the third-party builder has no WordPress API | |
| 123 | 130 | "SELECT COUNT(*) AS cnt, MAX(p.post_modified_gmt) AS latest |
| 124 | 131 | FROM {$wpdb->posts} p |
| 125 | 132 | INNER JOIN {$wpdb->postmeta} pm ON pm.post_id = p.ID AND pm.meta_key = '_ct_builder_json' |
| 126 | 133 | WHERE p.post_type = 'ct_template' |
| @@ -142,9 +149,9 @@ | ||
| 142 | 149 | global $wpdb; |
| 143 | 150 | |
| 144 | 151 | $key = get_option('oxygen_private_key', ''); |
| 145 | 152 | |
| 146 | - $json_rows = $wpdb->get_col( | |
| 153 | + $json_rows = $wpdb->get_col( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- reads Oxygen builder template storage — the third-party builder has no WordPress API | |
| 147 | 154 | "SELECT pm.meta_value |
| 148 | 155 | FROM {$wpdb->postmeta} pm |
| 149 | 156 | INNER JOIN {$wpdb->posts} p ON p.ID = pm.post_id |
| 150 | 157 | WHERE p.post_type = 'ct_template' |
| @@ -168,9 +175,9 @@ | ||
| 168 | 175 | if (!$signer) { |
| 169 | 176 | return 0; |
| 170 | 177 | } |
| 171 | 178 | |
| 172 | - $template_ids = $wpdb->get_col( | |
| 179 | + $template_ids = $wpdb->get_col( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- reads Oxygen builder template storage — the third-party builder has no WordPress API | |
| 173 | 180 | "SELECT p.ID |
| 174 | 181 | FROM {$wpdb->posts} p |
| 175 | 182 | WHERE p.post_type = 'ct_template' |
| 176 | 183 | AND p.post_status = 'publish' |