Changeset 3358399
- Timestamp:
- 09/09/2025 08:13:37 AM (6 months ago)
- Location:
- site-suggest
- Files:
-
- 32 added
- 6 edited
-
tags/1.3.0 (added)
-
tags/1.3.0/app (added)
-
tags/1.3.0/app/ajax-controller.php (added)
-
tags/1.3.0/app/cron-controller.php (added)
-
tags/1.3.0/app/info-controller.php (added)
-
tags/1.3.0/app/main-controller.php (added)
-
tags/1.3.0/assets (added)
-
tags/1.3.0/assets/css (added)
-
tags/1.3.0/assets/css/style.css (added)
-
tags/1.3.0/assets/js (added)
-
tags/1.3.0/assets/js/script.js (added)
-
tags/1.3.0/index.php (added)
-
tags/1.3.0/license.txt (added)
-
tags/1.3.0/readme.txt (added)
-
tags/1.3.0/site-suggest.php (added)
-
tags/1.3.0/vendor (added)
-
tags/1.3.0/vendor/DetectLanguage (added)
-
tags/1.3.0/vendor/DetectLanguage/Client.php (added)
-
tags/1.3.0/vendor/DetectLanguage/DetectLanguage.php (added)
-
tags/1.3.0/vendor/DetectLanguage/Error.php (added)
-
tags/1.3.0/vendor/detectlanguage.php (added)
-
tags/1.3.0/views (added)
-
tags/1.3.0/views/admin (added)
-
tags/1.3.0/views/admin-parts (added)
-
tags/1.3.0/views/admin-parts/admin-settings-fields.php (added)
-
tags/1.3.0/views/admin-parts/admin-site-info.php (added)
-
tags/1.3.0/views/admin/admin-robots-txt.php (added)
-
tags/1.3.0/views/admin/admin-server.php (added)
-
tags/1.3.0/views/admin/admin-settings.php (added)
-
tags/1.3.0/views/admin/admin-tool-content.php (added)
-
tags/1.3.0/views/admin/stsgt-log-single.php (added)
-
tags/1.3.0/views/admin/stsgt-log.php (added)
-
trunk/app/ajax-controller.php (modified) (41 diffs)
-
trunk/app/info-controller.php (modified) (4 diffs)
-
trunk/app/main-controller.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/site-suggest.php (modified) (2 diffs)
-
trunk/views/admin-parts/admin-site-info.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
site-suggest/trunk/app/ajax-controller.php
r3350957 r3358399 16 16 function __construct() 17 17 { 18 add_action('wp_ajax_stsgt_save_prev_log', array($this, 'save_prev_log')); 19 add_action('wp_ajax_stsgt_run_audit', array($this, 'run_audit')); 20 add_action('wp_ajax_stsgt_save_admin_settings', array($this, 'save_admin_settings')); 21 22 add_action('wp_ajax_clear_stsgt_log_all', array($this, 'clear_stsgt_log_all_clbk')); 23 add_action('wp_ajax_nopriv_clear_stsgt_log_all', array($this, 'clear_stsgt_log_all_clbk')); 24 25 add_action('wp_ajax_remove_stsgt_log_item', array($this, 'remove_stsgt_log_item_clbk')); 26 add_action('wp_ajax_nopriv_remove_stsgt_log_item', array($this, 'remove_stsgt_log_item_clbk')); 27 28 add_action('wp_ajax_stsgt_delete_revisions', array($this, 'delete_revisions')); 29 add_action('wp_ajax_nopriv_stsgt_delete_revisions', array($this, 'delete_revisions')); 30 31 add_action('wp_ajax_stsgt_delete_drafts', array($this, 'delete_drafts')); 32 add_action('wp_ajax_nopriv_stsgt_delete_drafts', array($this, 'delete_drafts')); 33 34 add_action('wp_ajax_stsgt_delete_spam_comments', array($this, 'spam_comments')); 35 add_action('wp_ajax_nopriv_stsgt_delete_spam_comments', array($this, 'spam_comments')); 36 37 add_action('wp_ajax_stsgt_delete_trash_comments', array($this, 'trash_comments')); 38 add_action('wp_ajax_nopriv_stsgt_delete_trash_comments', array($this, 'trash_comments')); 39 40 add_action('wp_ajax_stsgt_delete_trash', array($this, 'delete_trash')); 41 add_action('wp_ajax_nopriv_stsgt_delete_trash', array($this, 'delete_trash')); 42 43 add_action('wp_ajax_stsgt_delete_transients', array($this, 'delete_transients')); 44 add_action('wp_ajax_nopriv_stsgt_delete_transients', array($this, 'delete_transients')); 45 46 add_action('wp_ajax_stsgt_export_images_csv', array($this, 'stsgt_export_images_csv_callback')); 47 add_action('wp_ajax_nopriv_stsgt_export_images_csv', array($this, 'stsgt_export_images_csv_callback')); 48 49 add_action('wp_ajax_stsgt_import_images_csv', array($this, 'stsgt_import_images_csv_callback')); 50 add_action('wp_ajax_nopriv_stsgt_import_images_csv', array($this, 'stsgt_import_images_csv_callback')); 51 52 add_action('wp_ajax_stsgt_run_audit_cron_observer', array($this, 'stsgt_run_audit_cron_observer_callback')); 53 add_action('wp_ajax_nopriv_stsgt_run_audit_cron_observer', array($this, 'stsgt_run_audit_cron_observer_callback')); 54 add_action('stsgt_every_min_cron', array($this, 'stsgt_audit_cron_observer')); 55 56 add_action('wp_ajax_stsgt_save_fetched_audit_data', array($this, 'stsgt_save_fetched_audit_data_callback')); 57 add_action('wp_ajax_nopriv_stsgt_save_fetched_audit_data', array($this, 'stsgt_save_fetched_audit_data_callback')); 58 59 add_action('wp_ajax_stsgt_start_cron_run_audit', array($this, 'stsgt_start_cron_run_audit_callback')); 60 61 add_action('wp_ajax_stsgt_approve_share_tech_data', array($this, 'approve_share_tech_data')); 62 63 add_action('wp_ajax_stsgt_robots_txt_content', array($this, 'stsgt_robots_txt_content_clbk')); 64 65 add_action('wp_ajax_stsgt_clear_404_logs', array($this, 'stsgt_clear_404_logs_callback')); 66 add_action('wp_ajax_stsgt_update_banner_update', array($this, 'stsgt_update_banner_update_callback')); 67 18 // Ajax Request Handlers 19 add_action('wp_ajax_stsgt_save_prev_log', [$this, 'save_prev_log']); 20 add_action('wp_ajax_stsgt_run_audit', [$this, 'run_audit']); 21 add_action('wp_ajax_stsgt_save_admin_settings', [$this, 'save_admin_settings']); 22 add_action('wp_ajax_clear_stsgt_log_all', [$this, 'clear_stsgt_log_all_clbk']); 23 add_action('wp_ajax_remove_stsgt_log_item', [$this, 'remove_stsgt_log_item_clbk']); 24 add_action('wp_ajax_stsgt_delete_revisions', [$this, 'delete_revisions']); 25 add_action('wp_ajax_stsgt_delete_drafts', [$this, 'delete_drafts']); 26 add_action('wp_ajax_stsgt_delete_spam_comments', [$this, 'spam_comments']); 27 add_action('wp_ajax_stsgt_delete_trash_comments', [$this, 'trash_comments']); 28 add_action('wp_ajax_stsgt_delete_trash', [$this, 'delete_trash']); 29 add_action('wp_ajax_stsgt_delete_transients', [$this, 'delete_transients']); 30 add_action('wp_ajax_stsgt_export_images_csv', [$this, 'stsgt_export_images_csv_callback']); 31 add_action('wp_ajax_stsgt_import_images_csv', [$this, 'stsgt_import_images_csv_callback']); 32 add_action('wp_ajax_stsgt_run_audit_cron_observer', [$this, 'stsgt_run_audit_cron_observer_callback']); 33 add_action('wp_ajax_stsgt_save_fetched_audit_data', [$this, 'stsgt_save_fetched_audit_data_callback']); 34 add_action('wp_ajax_stsgt_start_cron_run_audit', [$this, 'stsgt_start_cron_run_audit_callback']); 35 add_action('wp_ajax_stsgt_approve_share_tech_data', [$this, 'approve_share_tech_data']); 36 add_action('wp_ajax_stsgt_robots_txt_content', [$this, 'stsgt_robots_txt_content_clbk']); 37 add_action('wp_ajax_stsgt_clear_404_logs', [$this, 'stsgt_clear_404_logs_callback']); 38 add_action('wp_ajax_stsgt_update_banner_update', [$this, 'stsgt_update_banner_update_callback']); 68 39 add_action('wp_ajax_reset_scanning_process', [$this, 'stsgt_reset_scanning_process']); 69 70 40 add_action('wp_ajax_stsgt_cron_checker', [$this, 'stsgt_cron_checker_clbk']); 71 72 41 add_action('wp_ajax_stsgt_dismiss_admin_notice', [$this, 'stsgt_dismiss_admin_notice_clbk']); 73 74 42 add_action('wp_ajax_stsgt_send_bug_report', [$this, 'report_request']); 75 add_action('wp_ajax_nopriv_stsgt_send_bug_report', [$this, 'report_request']); 43 44 // Cron Handler 45 add_action('stsgt_every_min_cron', [$this, 'stsgt_audit_cron_observer']); 46 } 47 48 /** 49 * Validate User Capabilities 50 * @return bool 51 */ 52 private function is_valid_request(){ 53 if (current_user_can('administrator')) { 54 return true; 55 } 56 return false; 57 } 58 59 /** 60 * Send Invalid Response 61 * @return void 62 */ 63 private function invalid_request(){ 64 wp_send_json(['status' => 400, 'message' => 'Invalid Request!']); 76 65 } 77 66 78 67 public function stsgt_dismiss_admin_notice_clbk() 79 68 { 69 if(!$this->is_valid_request()){ 70 $this->invalid_request(); 71 } 72 80 73 if (isset($_POST['_']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_'])), 'stsgt_nonce')) { 81 74 update_option('stsgt_cron_scanning_complete', []); … … 90 83 public function stsgt_cron_checker_clbk() 91 84 { 85 if(!$this->is_valid_request()){ 86 $this->invalid_request(); 87 } 88 92 89 if (isset($_POST['_']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_'])), 'stsgt_nonce')) { 93 90 $is_cron = get_option('stsgt_real_cron_obsv_started'); … … 121 118 public function stsgt_reset_scanning_process() 122 119 { 120 if(!$this->is_valid_request()){ 121 $this->invalid_request(); 122 } 123 123 124 $resp = []; 124 125 if (isset($_POST['_']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_'])), 'stsgt_nonce')) { … … 149 150 public function stsgt_update_banner_update_callback() 150 151 { 152 if(!$this->is_valid_request()){ 153 $this->invalid_request(); 154 } 155 151 156 $resp = []; 152 157 … … 168 173 public function stsgt_clear_404_logs_callback() 169 174 { 175 if(!$this->is_valid_request()){ 176 $this->invalid_request(); 177 } 178 170 179 $resp = []; 171 180 if (isset($_POST['_']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_'])), 'stsgt_nonce')) { … … 198 207 ob_start(); 199 208 $is_404_page = true; 200 $_404_monitor_tab_keys = ['_404_error_monitor'];201 $new_site_info_data = [];209 $_404_monitor_tab_keys = ['_404_error_monitor']; 210 $new_site_info_data = []; 202 211 foreach ($_404_monitor_tab_keys as $_404_monitor_tab_item) { 203 212 $new_site_info_data[$_404_monitor_tab_item] = $prev_opt_data[$_404_monitor_tab_item] ?? ''; … … 216 225 private function read_file($path) 217 226 { 218 if (! function_exists('request_filesystem_credentials')) {227 if (!function_exists('request_filesystem_credentials')) { 219 228 require_once ABSPATH . 'wp-admin/includes/file.php'; 220 229 } … … 232 241 private function overwrite_file($path, $data) 233 242 { 234 if (! function_exists('request_filesystem_credentials')) {243 if (!function_exists('request_filesystem_credentials')) { 235 244 require_once ABSPATH . 'wp-admin/includes/file.php'; 236 245 } … … 245 254 public function stsgt_robots_txt_content_clbk() 246 255 { 256 if(!$this->is_valid_request()){ 257 $this->invalid_request(); 258 } 259 247 260 $resp = []; 248 261 if (isset($_POST['_']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_'])), 'stsgt_nonce')) { … … 270 283 public function save_prev_log() 271 284 { 285 if(!$this->is_valid_request()){ 286 $this->invalid_request(); 287 } 288 272 289 if (isset($_POST['_']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_'])), 'stsgt_nonce')) { 273 290 $stsgt_site_speed_data = get_option('stsgt_site_speed_data'); … … 292 309 public function approve_share_tech_data() 293 310 { 311 if(!$this->is_valid_request()){ 312 $this->invalid_request(); 313 } 314 294 315 if (isset($_POST['_']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_'])), 'stsgt_nonce')) { 295 316 $status = isset($_POST['sts']) ? sanitize_text_field(wp_unslash($_POST['sts'])) : 'no'; … … 310 331 public function stsgt_start_cron_run_audit_callback() 311 332 { 333 if(!$this->is_valid_request()){ 334 $this->invalid_request(); 335 } 336 312 337 if (isset($_POST['_']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_'])), 'stsgt_nonce')) { 313 338 $checklist = isset($_POST['checklist']) ? json_decode(base64_decode(sanitize_text_field(wp_unslash($_POST['checklist']))), true) : []; … … 349 374 require_once ABSPATH . 'wp-admin/includes/file.php'; 350 375 $credentials = request_filesystem_credentials('', '', false, false, null); 351 if (! WP_Filesystem($credentials)) {376 if (!WP_Filesystem($credentials)) { 352 377 return false; 353 378 } … … 358 383 public function stsgt_save_fetched_audit_data_callback() 359 384 { 385 if(!$this->is_valid_request()){ 386 $this->invalid_request(); 387 } 388 360 389 if (wp_verify_nonce(sanitize_text_field(wp_unslash((isset($_POST['nonce']) ? $_POST['nonce'] : ''))), 'stsgt_nonce')) { 361 390 $stsgt_site_speed_data = get_option('stsgt_site_speed_data') ?: []; … … 569 598 $link = $hom_link . $link; 570 599 } 571 600 572 601 add_filter('http_request_timeout', function ($time, $url) { 573 602 $time = 60; … … 592 621 public function remove_stsgt_log_item_clbk() 593 622 { 623 if(!$this->is_valid_request()){ 624 $this->invalid_request(); 625 } 626 594 627 if (isset($_POST['_']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_'])), 'stsgt_nonce')) { 595 628 $post_id = isset($_POST['post_id']) ? sanitize_text_field(wp_unslash($_POST['post_id'])) : 0; … … 606 639 public function clear_stsgt_log_all_clbk() 607 640 { 641 if(!$this->is_valid_request()){ 642 $this->invalid_request(); 643 } 644 608 645 if (isset($_POST['_']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_'])), 'stsgt_nonce')) { 609 646 $res = []; 610 647 $stsgt_args = array( 611 'post_type' => 'stsgt-log',648 'post_type' => 'stsgt-log', 612 649 'posts_per_page' => -1, 613 'post_status' => 'any',650 'post_status' => 'any', 614 651 ); 615 652 … … 730 767 731 768 769 private function get_schema_json($url){ 770 $resp = false; 771 $url = 'https://validator.schema.org/validate?url=' . urlencode($url); 772 773 $response = wp_remote_post( $url, array( 774 'headers' => array( 775 'Content-Length' => '0', 776 ), 777 'timeout' => 30, // you can adjust like CURLOPT_TIMEOUT 778 'redirection' => 10, // like CURLOPT_MAXREDIRS 779 ) ); 780 781 if ( is_wp_error( $response ) ) { 782 $error_message = $response->get_error_message(); 783 } else { 784 $resp = wp_remote_retrieve_body( $response ); 785 } 786 return $resp; 787 } 788 789 private function get_schema_warnings($jsonString){ 790 $data = json_decode($jsonString, true); 791 792 $results = [ 793 'errors' => [], 794 'warnings' => [] 795 ]; 796 797 // Recursive scanner 798 $scan = function($node) use (&$scan, &$results) { 799 if (isset($node['errors']) && is_array($node['errors'])) { 800 foreach ($node['errors'] as $error) { 801 $severity = $error['ownerToSeverity']['SPORE'] ?? ''; 802 $item = [ 803 'type' => $error['errorType'] ?? '', 804 'args' => $error['args'] ?? [], 805 'severity' => $severity, 806 'isSevere' => $error['isSevere'] ?? false, 807 'begin' => $error['begin'] ?? null, 808 'end' => $error['end'] ?? null, 809 ]; 810 if ($severity === 'ERROR') { 811 $results['errors'][] = $item; 812 } else { 813 $results['warnings'][] = $item; 814 } 815 } 816 } 817 if(is_array($node)){ 818 foreach ($node as $child) { 819 if (is_array($child)) { 820 $scan($child); 821 } 822 } 823 } 824 }; 825 826 $scan($data); 827 828 return $results; 829 } 732 830 733 831 /** … … 736 834 public function schema_markup_check($html_content, $post_id) 737 835 { 836 $warnings = []; 837 $errors = []; 738 838 $checked_schema_markups = get_option('stsgt_checked_schema_markups', []); 739 839 740 840 $this_post = get_post($post_id); 741 841 $this_post_type = $this_post->post_type; 742 743 preg_match_all('/<script[^>]*type=["\']application\/ld\+json["\'][^>]*>(.*?)<\/script>/is', $html_content, $matches); 744 $ json_ld_blocks = $matches[1];745 $ json_ld_blocks = isset($json_ld_blocks[0]) ? json_decode($json_ld_blocks[0], true) : [];746 747 if (!in_array($this_post_type, $checked_schema_markups)) {748 $ld_schemas_arr = $this->check_nested_schmark($json_ld_blocks);749 $ld_schemas = $ld_schemas_arr[0]; 750 $page_title = $ld_schemas_arr[1];751 $un_ld_schemas = $ld_schemas_arr[2];752 if ($this_post_type != "page"){753 $checked_schema_markups[] = $this_post_type;754 }755 update_option('stsgt_checked_schema_markups', $checked_schema_markups);756 $ld_schemas = array_intersect(array_unique($ld_schemas), $this->recognized_schema_types);757 $final_out = '<strong>Recognized schemas</strong>: ' . implode(', ', $ld_schemas);758 759 if (!empty($un_ld_schemas)) {760 $final_out .= '<br><strong>Unrecognized schemas</strong>: ' . implode(', ', $un_ld_schemas);761 }762 return [$page_title => $final_out]; 763 }764 765 return null;842 $this_post_link = get_the_permalink($this_post->ID); 843 844 $this_json = $this->get_schema_json($this_post_link); 845 $this_result = $this->get_schema_warnings($this_json); 846 847 $warnings = $this_result['warnings']; 848 $errors = $this_result['errors']; 849 850 $warning_string = ''; 851 $errors_string = ''; 852 if(!empty(($warnings))){ 853 foreach($warnings as $warnings_key => $warnings_value){ 854 $warning_string .= $warnings_value['type'].' - '.implode(', ', $warnings_value['args']); 855 } 856 } 857 if(!empty(($errors))){ 858 foreach($errors as $errors_key => $errors_value){ 859 $errors_string .= $errors_value['type'].' - '.implode(', ', $errors_value['args']); 860 } 861 } 862 863 $this_return = ['<strong>Warnings</strong>:- '.$warning_string.' <br> '.' <strong>Errors</strong>:- '.$errors_string]; 864 865 return $this_return; 766 866 } 767 867 … … 866 966 if (!empty($stsgt_site_speed_data) && isset($stsgt_site_speed_data[$key])) { 867 967 if (is_array($stsgt_site_speed_data[$key])) { 868 $stsgt_site_speed_data[$key] = array_merge($stsgt_site_speed_data[$key], $new_audit_item); 968 if(is_array($new_audit_item)){ 969 $stsgt_site_speed_data[$key] = array_merge($stsgt_site_speed_data[$key], $new_audit_item); 970 }else{ 971 $stsgt_site_speed_data[$key] = $new_audit_item; 972 } 869 973 } else { 870 974 $stsgt_site_speed_data[$key] = $new_audit_item; … … 892 996 public function stsgt_run_audit_cron_observer_callback() 893 997 { 998 if(!$this->is_valid_request()){ 999 $this->invalid_request(); 1000 } 1001 894 1002 // sleep(1); 895 1003 if (wp_verify_nonce(sanitize_text_field(wp_unslash((isset($_POST['nonce']) ? $_POST['nonce'] : ''))), 'stsgt_audt_nonce')) { … … 974 1082 public function stsgt_export_images_csv_callback() 975 1083 { 1084 if(!$this->is_valid_request()){ 1085 $this->invalid_request(); 1086 } 1087 976 1088 global $wp_filesystem; 977 1089 978 1090 // Initialize WP Filesystem 979 if (! function_exists('WP_Filesystem')) {1091 if (!function_exists('WP_Filesystem')) { 980 1092 require_once ABSPATH . 'wp-admin/includes/file.php'; 981 1093 } … … 983 1095 984 1096 $args = array( 985 'post_type' => 'attachment',986 'post_status' => 'inherit',1097 'post_type' => 'attachment', 1098 'post_status' => 'inherit', 987 1099 'posts_per_page' => -1 988 1100 ); … … 998 1110 $attachment_id = get_the_ID(); 999 1111 $attachment_guid = get_the_guid(); 1000 $url_separator = '/wp-content/';1112 $url_separator = '/wp-content/'; 1001 1113 $url_prefix = get_site_url(); 1002 1114 $attachment_guid_arr = explode($url_separator, $attachment_guid); … … 1061 1173 public function stsgt_import_images_csv_callback() 1062 1174 { 1175 if(!$this->is_valid_request()){ 1176 $this->invalid_request(); 1177 } 1178 1063 1179 if (wp_verify_nonce((isset($_POST['nonce']) ? sanitize_text_field(wp_unslash($_POST['nonce'])) : ''), 'stsgt_nonce')) { 1064 1180 global $wp_filesystem; … … 1108 1224 foreach ($csv_data as $csv_data_item) { 1109 1225 $attachment_name = $csv_data_item['URL']; 1110 $url_separator = '/wp-content/';1226 $url_separator = '/wp-content/'; 1111 1227 $attachment_guid_arr = explode($url_separator, $attachment_name); 1112 1228 $attachment_name = isset($attachment_guid_arr[1]) ? $url_separator . $attachment_guid_arr[1] : ''; … … 1161 1277 public function run_audit() 1162 1278 { 1279 if(!$this->is_valid_request()){ 1280 $this->invalid_request(); 1281 } 1282 1163 1283 if (wp_verify_nonce((isset($_POST['nonce']) ? sanitize_text_field(wp_unslash($_POST['nonce'])) : ''), 'stsgt_nonce')) { 1164 1284 $check_name = isset($_POST['check_name']) ? sanitize_text_field(wp_unslash($_POST['check_name'])) : ''; 1165 1285 $audit_type = isset($_POST['audit_type']) ? sanitize_text_field(wp_unslash($_POST['audit_type'])) : ''; 1166 1286 1167 $cron_observers = ['HTTP_links_found', 'broken_links_detected_[Beta]', 'Large_image_check', 'H1_tag_check', 'Form_Check[experimental]' ]; //, 'reCaptcha_enabled'];1287 $cron_observers = ['HTTP_links_found', 'broken_links_detected_[Beta]', 'Large_image_check', 'H1_tag_check', 'Form_Check[experimental]', 'schema_markup_check']; //, 'reCaptcha_enabled']; 1168 1288 $current_cron_observers = get_option('stsgt_cron_observers', []); 1169 1289 … … 1210 1330 endswitch; 1211 1331 1212 $new_site_info_data = [];1332 $new_site_info_data = []; 1213 1333 foreach ($new_tab_keys as $new_tab_item) { 1214 1334 $new_site_info_data[$new_tab_item] = $wp_site_info[$new_tab_item] ?? ''; … … 1256 1376 public function save_admin_settings() 1257 1377 { 1378 if(!$this->is_valid_request()){ 1379 $this->invalid_request(); 1380 } 1381 1258 1382 if (wp_verify_nonce((isset($_POST['stsgt_settings_data_nonce']) ? sanitize_text_field(wp_unslash($_POST['stsgt_settings_data_nonce'])) : ''), 'stsgt_settings_field')) { 1259 1383 $resp = array('status' => 200, 'message' => esc_html__('Connection working', 'site-suggest')); … … 1264 1388 1265 1389 $data = array( 1266 'stsgt_api_share_diagnostic_data' => $stsgt_api_share_diagnostic_data,1267 'stsgt_api_delete_plugin_data' => $stsgt_api_delete_plugin_data,1268 'stsgt_api_disable_safari_zoom' => $stsgt_api_disable_safari_zoom,1390 'stsgt_api_share_diagnostic_data' => $stsgt_api_share_diagnostic_data, 1391 'stsgt_api_delete_plugin_data' => $stsgt_api_delete_plugin_data, 1392 'stsgt_api_disable_safari_zoom' => $stsgt_api_disable_safari_zoom, 1269 1393 ); 1270 1394 … … 1280 1404 public function deleteRevisions() 1281 1405 { 1406 if(!$this->is_valid_request()){ 1407 $this->invalid_request(); 1408 } 1409 1282 1410 $args = [ 1283 'post_type' => 'revision',1284 'post_status' => 'any',1411 'post_type' => 'revision', 1412 'post_status' => 'any', 1285 1413 'posts_per_page' => -1, // Get all revisions 1286 'fields' => 'ids', // Only fetch IDs (better performance)1414 'fields' => 'ids', // Only fetch IDs (better performance) 1287 1415 ]; 1288 1416 … … 1305 1433 public function delete_revisions() 1306 1434 { 1435 if(!$this->is_valid_request()){ 1436 $this->invalid_request(); 1437 } 1438 1307 1439 $stsgt_site_speed_data = get_option('stsgt_site_speed_data') ?: []; 1308 1440 … … 1323 1455 public function delete_draft_posts() 1324 1456 { 1457 if(!$this->is_valid_request()){ 1458 $this->invalid_request(); 1459 } 1460 1325 1461 $args = [ 1326 1462 'post_type' => $post_types = get_post_types([], 'names'), 1327 'post_status' => 'draft',1463 'post_status' => 'draft', 1328 1464 'posts_per_page' => -1, // Get all draft posts 1329 'fields' => 'ids', // Fetch only post IDs (optimized)1465 'fields' => 'ids', // Fetch only post IDs (optimized) 1330 1466 ]; 1331 1467 … … 1349 1485 public function delete_drafts() 1350 1486 { 1487 if(!$this->is_valid_request()){ 1488 $this->invalid_request(); 1489 } 1490 1351 1491 $stsgt_site_speed_data = get_option('stsgt_site_speed_data') ?: []; 1352 1492 … … 1367 1507 public function delete_spam_comments() 1368 1508 { 1509 if(!$this->is_valid_request()){ 1510 $this->invalid_request(); 1511 } 1512 1369 1513 $spam_comments = get_comments([ 1370 1514 'status' => 'spam', … … 1406 1550 public function delete_trashed_posts() 1407 1551 { 1552 if(!$this->is_valid_request()){ 1553 $this->invalid_request(); 1554 } 1555 1408 1556 $args = [ 1409 1557 'post_type' => get_post_types(['public' => true], 'names'), 1410 'post_status' => 'trash',1558 'post_status' => 'trash', 1411 1559 'posts_per_page' => -1, // Get all trashed posts 1412 'fields' => 'ids', // Only get post IDs (better performance)1560 'fields' => 'ids', // Only get post IDs (better performance) 1413 1561 ]; 1414 1562 … … 1455 1603 public function delete_transients() 1456 1604 { 1605 if(!$this->is_valid_request()){ 1606 $this->invalid_request(); 1607 } 1457 1608 1458 1609 $stsgt_site_speed_data = get_option('stsgt_site_speed_data') ?: []; … … 1503 1654 { 1504 1655 $trashed_comments = get_comments([ 1505 'status' => 'trash',1506 'fields' => 'ids', // Only get IDs for better performance1656 'status' => 'trash', 1657 'fields' => 'ids', // Only get IDs for better performance 1507 1658 ]); 1508 1659 … … 1524 1675 public function trash_comments() 1525 1676 { 1677 if(!$this->is_valid_request()){ 1678 $this->invalid_request(); 1679 } 1680 1526 1681 $stsgt_site_speed_data = get_option('stsgt_site_speed_data') ?: []; 1527 1682 … … 1539 1694 exit(); 1540 1695 } 1541 1696 1542 1697 1543 1698 public function report_request() 1544 1699 { 1700 if(!$this->is_valid_request()){ 1701 $this->invalid_request(); 1702 } 1703 1545 1704 if (isset($_POST['_']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_'])), 'stsgt_nonce')) { 1546 1705 $data_for = isset($_POST['data_for']) ? sanitize_text_field(wp_unslash($_POST['data_for'])) : ''; … … 1570 1729 ]); 1571 1730 } 1572 } else{1731 } else { 1573 1732 wp_send_json_error([ 1574 1733 'message' => 'Invalid Nonce.', -
site-suggest/trunk/app/info-controller.php
r3350957 r3358399 509 509 return 1024; // 1 GB 510 510 } 511 return $suggested_limit;511 return 256;//$suggested_limit; 512 512 } 513 513 … … 542 542 $peak_memory_text = 'Peak Usage - ' . $real_peak_used_memory . 'M'; 543 543 $sgst_limit = ''; 544 $sgst_limit = $current_mb . 'M - Suggested memory limit ' . $recommended . 'M.'; // . $peak_memory_text; 544 $sgst_limit = 'WP_MEMORY_LIMIT ('.$current_mb . 'M) - Suggested memory limit ' . $recommended . 'M.'; 545 $sgst_limit .= '<br>WP_MAX_MEMORY_LIMIT (256M) - Suggested memory limit 512M.'; 545 546 return $sgst_limit; 546 547 } … … 973 974 public function schema_markup_check() 974 975 { 976 return ''; 975 977 preg_match_all('/<script[^>]*type=["\']application\/ld\+json["\'][^>]*>(.*?)<\/script>/is', $this->html, $matches); 976 978 $json_ld_blocks = $matches[1]; … … 1699 1701 $resp_arr = get_option('stsgt_analytics_data', []); 1700 1702 } 1701 if ( $resp_arr) {1703 if (empty($resp_arr)) { 1702 1704 $remote_data = wp_remote_get('https://c.sitesuggest.io/?url=' . get_site_url(), ['timeout' => 60]); 1703 1705 if (!is_wp_error($remote_data)) { -
site-suggest/trunk/app/main-controller.php
r3350957 r3358399 22 22 23 23 // Required static files 24 add_filter('script_loader_tag', array($this, 'add_sri_attributes'), 10, 3); 24 25 add_action('admin_enqueue_scripts', array($this, 'stsgt_enqueue_scripts')); 25 26 add_action('admin_enqueue_scripts', array($this, 'head_snippet')); … … 39 40 add_action('init', [$this, 'terminate_page_for_www']); 40 41 } 42 43 private function get_sri_hash($handle, $src) 44 { 45 $cache_key = 'sri_hash_' . md5($src); 46 $hash = get_transient($cache_key); 47 48 if (!$hash) { 49 $response = wp_remote_get($src); 50 if (!is_wp_error($response)) { 51 $body = wp_remote_retrieve_body($response); 52 if ($body) { 53 $rawHash = base64_encode(hash('sha384', $body, true)); 54 $hash = 'sha384-' . $rawHash; 55 set_transient($cache_key, $hash, WEEK_IN_SECONDS); // cache for a week 56 } 57 } 58 } 59 return $hash; 60 } 61 62 public function add_sri_attributes($html, $handle, $src) 63 { 64 if (strpos($handle, 'stsgt-') !== false) { 65 $hash = $this->get_sri_hash($handle, $src); 66 $html = str_replace('></script>', ' integrity="' . esc_attr($hash) . '" crossorigin="anonymous"></script>', $html); 67 } 68 return $html; 69 } 70 41 71 42 72 public function terminate_page_for_www() -
site-suggest/trunk/readme.txt
r3350957 r3358399 4 4 Tested up to: 6.8 5 5 Requires PHP: 7.2 6 Stable tag: 1. 2.96 Stable tag: 1.3.0 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 151 151 == Changelog == 152 152 153 = 1.3.0 - 2025-09-09 = 154 * Refined Google Analytics Detection 155 * Improved Content Security Policy. 156 * Bug fixes. 157 158 = 1.2.9 - 2025-09-02 = 159 * Improved Security and Access Control. 160 * Bug fixes. 161 153 162 = 1.2.9 - 2025-08-27 = 154 163 * Added report feature (Users can report issues to plugin author). -
site-suggest/trunk/site-suggest.php
r3350957 r3358399 6 6 * Author: Blurr Studio 7 7 * Author URI: https://blurr.it/ 8 * Version: 1. 2.98 * Version: 1.3.0 9 9 * License: GPL v2 or later 10 10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 36 36 define('stsgt_URL', plugin_dir_url(__FILE__)); 37 37 define('stsgt_SLUG', 'site-suggest'); 38 define('stsgt_VERSION', '1. 2.9');38 define('stsgt_VERSION', '1.3.0'); 39 39 } 40 40 -
site-suggest/trunk/views/admin-parts/admin-site-info.php
r3350957 r3358399 422 422 if (!is_numeric($title)) { 423 423 ?> 424 <div class="title_wrap asd<?php echo esc_html($has_progress); ?>" data_total="<?php echo esc_html($cron_total_progress); ?>" data_current="<?php echo esc_html($cron_progress); ?>" data_item="<?php echo esc_html($title); ?>" style="--stsgt_cron_progress: <?php echo esc_html($cron_progress_perc); ?>%;">424 <div class="title_wrap <?php echo esc_html($has_progress); ?>" data_total="<?php echo esc_html($cron_total_progress); ?>" data_current="<?php echo esc_html($cron_progress); ?>" data_item="<?php echo esc_html($title); ?>" style="--stsgt_cron_progress: <?php echo esc_html($cron_progress_perc); ?>%;"> 425 425 <?php 426 426 if ($has_progress != '') { … … 510 510 ?> 511 511 <li stsgt_check_name="<?php echo esc_attr($title, 'site-suggest') ?>"> 512 <div class="title_wrap rweee<?php echo esc_html($has_progress); ?>" data_total="<?php echo esc_html($cron_total_progress); ?>" data_current="<?php echo esc_html($cron_progress); ?>" data_item="<?php echo esc_html($title); ?>" style="--stsgt_cron_progress: <?php echo esc_html($cron_progress_perc); ?>%;">512 <div class="title_wrap <?php echo esc_html($has_progress); ?>" data_total="<?php echo esc_html($cron_total_progress); ?>" data_current="<?php echo esc_html($cron_progress); ?>" data_item="<?php echo esc_html($title); ?>" style="--stsgt_cron_progress: <?php echo esc_html($cron_progress_perc); ?>%;"> 513 513 <?php 514 514 if ($has_progress != '') {
Note: See TracChangeset
for help on using the changeset viewer.