Changeset 3482478
- Timestamp:
- 03/14/2026 10:32:08 AM (2 weeks ago)
- Location:
- rc-site-manager-optimization/trunk
- Files:
-
- 1 added
- 6 edited
-
crons/pagespeed.php (modified) (5 diffs)
-
includes/database.php (modified) (2 diffs)
-
includes/database_migration.php (added)
-
rc-site-manager-optimization.php (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
-
top_url/index.php (modified) (1 diff)
-
top_url/top_url_function.php (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
rc-site-manager-optimization/trunk/crons/pagespeed.php
r3482178 r3482478 6 6 add_action('wp', 'rc_sm_pagespeed_schedule_cron'); 7 7 function rc_sm_pagespeed_schedule_cron() { 8 if (!wp_next_scheduled('rc_sm_pagespeed_daily_cron')) { 9 // Calcola prossime 06:00 nel timezone del sito 10 $timezone = new DateTimeZone(wp_timezone_string()); 11 $now = new DateTime('now', $timezone); 12 $next_run = new DateTime('today 06:00', $timezone); 13 14 // Se le 06:00 sono già passate oggi, schedula per domani 15 if ($now >= $next_run) { 16 $next_run->modify('+1 day'); 17 } 18 19 wp_schedule_event($next_run->getTimestamp(), 'daily', 'rc_sm_pagespeed_daily_cron'); 8 if (!wp_next_scheduled('rc_sm_pagespeed_cron')) { 9 wp_schedule_event(time(), 'hourly', 'rc_sm_pagespeed_cron'); 20 10 } 21 11 } … … 23 13 register_deactivation_hook(RC_SM_PLUGIN_DIR . 'rc-site-manager-optimization.php', 'rc_sm_pagespeed_unschedule_cron'); 24 14 function rc_sm_pagespeed_unschedule_cron() { 25 $timestamp = wp_next_scheduled('rc_sm_pagespeed_ daily_cron');15 $timestamp = wp_next_scheduled('rc_sm_pagespeed_cron'); 26 16 if ($timestamp) { 27 wp_unschedule_event($timestamp, 'rc_sm_pagespeed_ daily_cron');28 } 29 } 30 31 add_action('rc_sm_pagespeed_ daily_cron', 'rc_sm_pagespeed_run_job');17 wp_unschedule_event($timestamp, 'rc_sm_pagespeed_cron'); 18 } 19 } 20 21 add_action('rc_sm_pagespeed_cron', 'rc_sm_pagespeed_run_job'); 32 22 33 23 // ─── Job principale ─────────────────────────────────────────────────────────── … … 39 29 $log_file = WP_CONTENT_DIR . '/debug.log'; 40 30 31 // Calcola soglia giornaliera: oggi alle 06:00 nel timezone del sito 32 $timezone = new DateTimeZone(wp_timezone_string()); 33 $now = new DateTime('now', $timezone); 34 $daily_threshold = new DateTime('today 06:00', $timezone); 35 41 36 rc_sm_pagespeed_log('=== INIZIO JOB PAGESPEED ===', $log_file); 42 43 $records = rc_sm_pagespeed_get_all();44 $total = count($records); 45 46 rc_sm_pagespeed_log("Record da processare: {$total}", $log_file);37 rc_sm_pagespeed_log('Ora attuale: ' . $now->format('Y-m-d H:i:s'), $log_file); 38 rc_sm_pagespeed_log('Soglia giornaliera: ' . $daily_threshold->format('Y-m-d H:i:s'), $log_file); 39 40 $all_records = rc_sm_pagespeed_get_all(); 41 $total = count($all_records); 47 42 48 43 if ($total === 0) { 49 rc_sm_pagespeed_log("Nessun record da processare. Uscita.", $log_file); 44 rc_sm_pagespeed_log('Nessun record. Uscita.', $log_file); 45 return; 46 } 47 48 // Filtra i record da processare 49 $records = []; 50 foreach ($all_records as $record) { 51 52 if (empty($record->last_check) || $record->last_check === '0000-00-00 00:00:00') { 53 // Mai verificato → processa subito 54 $records[] = $record; 55 56 } else { 57 // Già verificato → processa solo se: 58 // 1. Sono passate le 06:00 di oggi 59 // 2. L'ultimo check è precedente alle 06:00 di oggi 60 $last_check_dt = new DateTime($record->last_check, $timezone); 61 if ($now >= $daily_threshold && $last_check_dt < $daily_threshold) { 62 $records[] = $record; 63 } 64 } 65 } 66 67 $to_process = count($records); 68 rc_sm_pagespeed_log("Record totali: {$total} | Da processare: {$to_process}", $log_file); 69 70 if ($to_process === 0) { 71 rc_sm_pagespeed_log('Nessun record da processare in questo ciclo.', $log_file); 50 72 return; 51 73 } … … 73 95 74 96 // Delay tra URL (non dopo l'ultimo) 75 if ($index < $to tal- 1) {97 if ($index < $to_process - 1) { 76 98 sleep(5); 77 99 } … … 79 101 80 102 rc_sm_pagespeed_log("=== FINE JOB ===", $log_file); 81 rc_sm_pagespeed_log("Processati: {$processed}/{$to tal}", $log_file);82 rc_sm_pagespeed_log("Falliti: {$failed}/{$to tal}", $log_file);103 rc_sm_pagespeed_log("Processati: {$processed}/{$to_process}", $log_file); 104 rc_sm_pagespeed_log("Falliti: {$failed}/{$to_process}", $log_file); 83 105 rc_sm_pagespeed_log("================\n", $log_file); 84 106 } -
rc-site-manager-optimization/trunk/includes/database.php
r3482178 r3482478 13 13 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, 14 14 post_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, 15 term_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, 15 16 url TEXT NULL, 16 17 action VARCHAR(100) NULL, … … 364 365 ); 365 366 } 367 368 369 include 'database_migration.php'; -
rc-site-manager-optimization/trunk/rc-site-manager-optimization.php
r3482178 r3482478 3 3 * Plugin Name: RC Site Manager & Optimization 4 4 * Description: All-in-one Wordpress manager: control WooCommerce, SEO, caching, media, and multilingual tools from one dashboard. 5 * Version: 2.4. 35 * Version: 2.4.4 6 6 * Author: Rocket Comunicazione 7 7 * Author URI: https://www.rocketcomunicazione.com … … 18 18 19 19 20 define('RC_SM_PLUGIN_VERSION', '2.4. 3');20 define('RC_SM_PLUGIN_VERSION', '2.4.4'); 21 21 22 22 define( 'RC_SM_SITE_URL', home_url() ); -
rc-site-manager-optimization/trunk/readme.txt
r3482178 r3482478 5 5 Tested up to: 6.9 6 6 Requires PHP: 8.1 7 Stable tag: 2.4. 37 Stable tag: 2.4.4 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 160 160 == Changelog == 161 161 162 163 = 2.4.4 - March 14, 2026 = 164 * Minor bug fixes and improvement 162 165 163 166 = 2.4.3 - March 13, 2026 = … … 307 310 == Upgrade Notice == 308 311 312 = 2.4.4 - March 14, 2026 = 313 Minor bug fixes. 314 309 315 = 2.4.3 - March 13, 2026 = 310 316 Minor bug fixes. -
rc-site-manager-optimization/trunk/top_url/index.php
r3482178 r3482478 103 103 $columns = [ 104 104 'id' => ['label' => 'ID', 'class' => 'rc_sm_table_column_hide'], 105 'post_id' => ['label' => 'ID' . ' (post_id)','class' => 'rc_sm_width_1'],105 'post_id' => ['label' => 'ID', 'class' => 'rc_sm_width_1'], 106 106 'url' => ['label' => 'URL', 'class' => 'rc_sm_width_4'], 107 107 'type' => ['label' => __('Type', 'rc-site-manager-optimization'), 'class' => 'rc_sm_width_1'], 108 'info' => ['label' => __('Informations', 'rc-site-manager-optimization') . ' (post_id)','class' => 'rc_sm_width_2'],108 'info' => ['label' => __('Informations', 'rc-site-manager-optimization'), 'class' => 'rc_sm_width_2'], 109 109 'rucss' => ['label' => 'WP-Rocket / ' . __('Used CSS', 'rc-site-manager-optimization'), 'class' => 'rc_sm_width_2'], 110 110 'pagespeed' => ['label' => 'Page Speed', 'class' => 'rc_sm_width_2'], -
rc-site-manager-optimization/trunk/top_url/top_url_function.php
r3482178 r3482478 2 2 3 3 if (!defined('ABSPATH')) { exit; } 4 5 6 /** 7 * Resolve any URL to an internal ID. 8 * Works on any WordPress site regardless of permalink structure. 9 * Returns array: ['post_id' => int, 'term_id' => int] 10 */ 11 function rc_sm_url_to_id($clean_url) { 12 13 // 1. Post, pages, CPT (includes WooCommerce products) 14 $post_id = url_to_postid($clean_url); 15 if ($post_id) return ['post_id' => (int) $post_id, 'term_id' => 0]; 16 17 // 2. All registered taxonomies — try every segment of the path 18 // Works regardless of category_base, tag_base, or custom permalink settings 19 $path = parse_url($clean_url, PHP_URL_PATH); 20 $segments = array_filter(explode('/', trim($path, '/'))); 21 22 $skip_slugs = array_filter([ 23 get_option('category_base'), 24 get_option('tag_base'), 25 'category', 'tag', 26 ]); 27 28 foreach (array_reverse($segments) as $slug) { 29 if (in_array($slug, $skip_slugs, true)) continue; 30 foreach (get_taxonomies() as $taxonomy) { 31 $term = get_term_by('slug', $slug, $taxonomy); 32 if ($term && !is_wp_error($term)) return ['post_id' => 0, 'term_id' => (int) $term->term_id]; 33 } 34 } 35 36 // 3. Not found 37 return ['post_id' => 0, 'term_id' => 0]; 38 } 39 4 40 5 41 add_action('wp_ajax_rc_sm_top_url', function () { … … 7 43 header('Content-Type: application/json'); 8 44 9 // Security verification10 45 if (!rc_sm_security_ajax_verify()) { 11 46 return; … … 17 52 $page = max(1, rc_sm_security_ajax_get_int('pagination', 1)); 18 53 19 $allowed_orderby = ['url', 'post_id', ' control'];54 $allowed_orderby = ['url', 'post_id', 'term_id', 'control']; 20 55 $orderby = in_array($orderby, $allowed_orderby, true) ? $orderby : 'url'; 21 56 $order = in_array($order, ['ASC', 'DESC'], true) ? $order : 'ASC'; … … 23 58 $per_page = RC_SM_PAGINATION_ORDER_OFFSET; 24 59 $offset = ($page - 1) * $per_page; 25 26 $table = RC_SM_TABLE_CONTROL; 60 $table = RC_SM_TABLE_CONTROL; 27 61 28 62 if ($search) { … … 30 64 } 31 65 32 // Count total results33 66 if ($search) { 34 67 $count = (int) $wpdb->get_var( … … 49 82 $pages = (int) ceil($count / $per_page); 50 83 51 // Retrieve paginated results52 84 if ($search) { 53 85 $results = $wpdb->get_results( … … 74 106 if (!empty($results)) { 75 107 foreach ($results as $row) { 76 $post_id = absint($row->post_id); 77 $url = untrailingslashit($row->url); 78 $post = get_post($post_id); 79 if (!$post) continue; 80 81 $type_label = get_post_type_object($post->post_type)->labels->singular_name ?? $post->post_type; 82 $status_obj = get_post_status_object($post->post_status); 83 $status = $status_obj->label ?? $post->post_status; 84 85 $status_html = $post->post_status === 'publish' 86 ? "<span class='rc_sm_bold rc_sm_color_success'>" . esc_html($status) . "</span>" 87 : "<span class='rc_sm_bold rc_sm_color_warning'>" . esc_html($status) . "</span>"; 88 89 // Retrieve data from WP Rocket table 108 109 $post_id = (int) $row->post_id; 110 $term_id = (int) $row->term_id; 111 $url = untrailingslashit($row->url); 112 $url_view = rc_sm_url_slash($url); 113 114 if ($post_id > 0) { 115 // Post / page / CPT 116 $post = get_post($post_id); 117 if (!$post) continue; 118 $type_label = get_post_type_object($post->post_type)->labels->singular_name ?? $post->post_type; 119 $type_slug = $post->post_type; 120 $status_obj = get_post_status_object($post->post_status); 121 $status = $status_obj->label ?? $post->post_status; 122 $status_html = $post->post_status === 'publish' 123 ? "<span class='rc_sm_bold rc_sm_color_success'>" . esc_html($status) . "</span>" 124 : "<span class='rc_sm_bold rc_sm_color_warning'>" . esc_html($status) . "</span>"; 125 $is_public = $post->post_status === 'publish'; 126 $id_display = $post_id; 127 128 } elseif ($term_id > 0) { 129 // Term (category, tag, custom taxonomy) 130 $term = get_term($term_id); 131 if (!$term || is_wp_error($term)) continue; 132 $taxonomy_obj = get_taxonomy($term->taxonomy); 133 $type_label = $taxonomy_obj->labels->singular_name ?? $term->taxonomy; 134 $type_slug = $term->taxonomy; 135 $status_html = "<span class='rc_sm_bold rc_sm_color_success'>" . esc_html__('Published', 'rc-site-manager-optimization') . "</span>"; 136 $is_public = true; 137 $id_display = $term_id; 138 139 } else { 140 // No ID found 141 $type_label = ''; 142 $type_slug = ''; 143 $status_html = ''; 144 $is_public = true; 145 $id_display = 0; 146 } 147 90 148 $rucss_table = $wpdb->prefix . 'wpr_rucss_used_css'; 91 149 $rucss_rows = $wpdb->get_results( … … 96 154 ); 97 155 98 $rucss_map = ['0' => ' -', '1' => '-'];156 $rucss_map = ['0' => '', '1' => '']; 99 157 foreach ($rucss_rows as $r) { 100 158 $rucss_map[$r->is_mobile] = $r->status; … … 104 162 if ($status === 'completed') { 105 163 return "<span class='rc_sm_bold rc_sm_color_success'>" . esc_html('completed') . "</span>"; 106 } elseif ($status === ' -') {107 return "<span class='rc_sm_bold rc_sm_color_error'>-</span>";164 } elseif ($status === '') { 165 return ''; 108 166 } 109 167 return "<span class='rc_sm_bold rc_sm_color_warning'>" . esc_html($status) . "</span>"; 110 168 }; 111 169 112 // Retrieve last PageSpeed data 113 $ps_html = rc_sm_pagespeed_performance_html($url); 114 115 $url_view = rc_sm_url_slash($url); 170 $ps_html = rc_sm_pagespeed_performance_html($url); 171 $id_display = $id_display > 0 ? esc_html($id_display) : ''; 172 116 173 echo "<tr>"; 117 174 echo "<td class='rc_sm_table_column_hide'>" . esc_html($row->id) . "</td>"; 118 echo "<td>" . esc_html($post_id). "</td>";119 echo "<td>" . ($ post->post_status === 'publish'175 echo "<td>" . $id_display . "</td>"; 176 echo "<td>" . ($is_public 120 177 ? "<a href='" . esc_url($url_view) . "' target='_blank'>" . esc_html($url_view) . "</a>" 121 178 : esc_html($url_view)) . "</td>"; 122 echo "<td>" . esc_html($type_label) . " <code>(" . esc_html($post->post_type) . ")</code></td>"; 123 echo '<td>' . esc_html('ID: ') . esc_html($post_id) . '<br>' . esc_html(__('Status:', 'rc-site-manager-optimization')) . wp_kses_post(' ' . $status_html) . '</td>'; 179 echo "<td>" . ($type_label !== '' ? esc_html($type_label) . " <code>(" . esc_html($type_slug) . ")</code>" : '') . "</td>"; 180 $type_source = $post_id > 0 ? 'post_id' : ($term_id > 0 ? 'term_id' : ''); 181 echo '<td>' 182 . ($id_display !== '' ? esc_html(__('ID:', 'rc-site-manager-optimization')) . ' ' . $id_display . '<br>' : '') 183 . ($type_source !== '' ? esc_html(__('Type:', 'rc-site-manager-optimization')) . ' <code>' . esc_html($type_source) . '</code><br>' : '') 184 . esc_html(__('Status:', 'rc-site-manager-optimization')) . wp_kses_post(' ' . $status_html) 185 . '</td>'; 124 186 echo '<td>' . esc_html('Desktop: ') . wp_kses_post($label($rucss_map[0])) . '<br>' . esc_html('Mobile: ') . wp_kses_post($label($rucss_map[1])) . '</td>'; 125 187 echo '<td>' . wp_kses_post($ps_html) . '</td>'; … … 133 195 } 134 196 } 135 $html_rows = ob_get_clean();197 $html_rows = ob_get_clean(); 136 198 $pagination = rc_sm_pagination_render($page, $pages); 137 199 … … 153 215 global $wpdb; 154 216 155 // Nonce check156 217 $nonce = rc_sm_security_ajax_get_param('rc_sm_url_add_nonce'); 157 218 … … 160 221 } 161 222 162 // Retrieve and validate URL163 223 $raw_url = rc_sm_security_ajax_get_param('rc_sm_url_new'); 164 $check = rc_sm_url_validate($raw_url);224 $check = rc_sm_url_validate($raw_url); 165 225 166 226 if (!$check['valid']) { … … 171 231 $table = RC_SM_TABLE_CONTROL; 172 232 173 // Check for duplicates174 233 $exists = $wpdb->get_var( 175 234 $wpdb->prepare( … … 183 242 } 184 243 185 // Get post_id from URL 186 $post_id = url_to_postid($clean_url); 187 188 if (!$post_id) { 189 // Fallback on GUID 190 $post_id = $wpdb->get_var( 191 $wpdb->prepare( 192 "SELECT ID FROM " . esc_sql($wpdb->posts) . " WHERE guid = %s LIMIT 1", 193 $clean_url 194 ) 195 ); 196 } 197 198 if (!$post_id) { 199 return '<div class="rc_sm_notice_error">' . esc_html(__('No published content matches this URL.', 'rc-site-manager-optimization')) . '</div>'; 200 } 201 202 // Insert record 244 $ids = rc_sm_url_to_id($clean_url); 245 203 246 $inserted = $wpdb->insert( 204 247 $table, 205 248 [ 206 'post_id' => $post_id, 249 'post_id' => $ids['post_id'], 250 'term_id' => $ids['term_id'], 207 251 'url' => esc_url_raw($clean_url), 208 252 'action' => 'top_url', 209 253 ], 210 ['%d', '% s', '%s']254 ['%d', '%d', '%s', '%s'] 211 255 ); 212 256 … … 223 267 global $wpdb; 224 268 225 // Security verification226 269 if (!rc_sm_security_ajax_verify()) { 227 270 return; … … 236 279 $table = RC_SM_TABLE_CONTROL; 237 280 238 // Recupera URL prima di cancellare239 281 $url = $wpdb->get_var( 240 282 $wpdb->prepare(
Note: See TracChangeset
for help on using the changeset viewer.