Changeset 3448175
- Timestamp:
- 01/27/2026 08:33:31 PM (2 months ago)
- Location:
- ghost-update/trunk
- Files:
-
- 4 edited
-
ghost-update.php (modified) (1 diff)
-
includes/class-ghost-update-feedback-banner.php (modified) (1 diff)
-
includes/updater.php (modified) (5 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ghost-update/trunk/ghost-update.php
r3448117 r3448175 3 3 * Plugin Name: Ghost Update 4 4 * Description: Keeps your WordPress site fresh by rotating post/page publish dates & pinging Google Search Console. 5 * Version: 1.2. 15 * Version: 1.2.2 6 6 * License: GPLv2 or later 7 7 * Author: IpodGuy79 -
ghost-update/trunk/includes/class-ghost-update-feedback-banner.php
r3287022 r3448175 1 1 <?php 2 3 if ( ! defined( 'ABSPATH' ) ) { 4 exit; 5 } 6 2 7 3 8 class GhostUpdateFeedbackBanner { -
ghost-update/trunk/includes/updater.php
r3448117 r3448175 10 10 * Debug logs are available when ghostupdate_log_level = 2. 11 11 */ 12 13 /** 14 * Append text to a file using WP_Filesystem (PluginCheck compliant). 15 * 16 * @param string $path Absolute path. 17 * @param string $text Text to append. 18 * @return bool 19 */ 20 function ghostupdate_fs_append($path, $text) { 21 if (!function_exists('WP_Filesystem')) { 22 require_once ABSPATH . 'wp-admin/includes/file.php'; 23 } 24 25 // Initialize filesystem (direct if possible). 26 global $wp_filesystem; 27 if (!$wp_filesystem) { 28 WP_Filesystem(); 29 } 30 if (!$wp_filesystem) { 31 return false; 32 } 33 34 $existing = ''; 35 if ($wp_filesystem->exists($path)) { 36 $existing = (string) $wp_filesystem->get_contents($path); 37 } else { 38 // Ensure parent dir exists. 39 $dir = wp_normalize_path(dirname($path)); 40 if (!$wp_filesystem->is_dir($dir)) { 41 $wp_filesystem->mkdir($dir); 42 } 43 } 44 45 // Preserve behavior: "append" exactly. 46 return (bool) $wp_filesystem->put_contents($path, $existing . $text, FS_CHMOD_FILE); 47 } 48 49 12 50 13 51 function ghostupdate_log_level() { … … 91 129 92 130 /** 93 * Tail reader for admin UI (reads from end; does NOT load entire file). 131 * Tail reader for admin UI (PluginCheck compliant: uses WP_Filesystem). 132 * Note: This reads the whole file; OK because your logs are small/rotated daily. 94 133 */ 95 134 function ghostupdate_tail_lines($file, $max_lines = 100, $chunk_size = 8192) { 96 if (!file_exists($file)) return []; 97 $max_lines = max(1, (int)$max_lines); 98 99 $fp = @fopen($file, 'rb'); 100 if (!$fp) return []; 101 102 $buffer = ''; 103 $pos = -1; 104 $lines = []; 105 106 fseek($fp, 0, SEEK_END); 107 $filesize = ftell($fp); 108 109 while (count($lines) <= $max_lines && abs($pos) < $filesize) { 110 $read = min($chunk_size, $filesize - abs($pos)); 111 $pos -= $read; 112 fseek($fp, $pos, SEEK_END); 113 $buffer = fread($fp, $read) . $buffer; 114 $lines = preg_split("/\r\n|\n|\r/", $buffer); 115 } 116 117 fclose($fp); 135 unset($chunk_size); // kept for back-compat signature 136 $max_lines = max(1, (int) $max_lines); 137 138 if (!function_exists('WP_Filesystem')) { 139 require_once ABSPATH . 'wp-admin/includes/file.php'; 140 } 141 142 global $wp_filesystem; 143 if (!$wp_filesystem) { 144 WP_Filesystem(); 145 } 146 if (!$wp_filesystem) { 147 return []; 148 } 149 150 if (!$wp_filesystem->exists($file)) return []; 151 152 $content = (string) $wp_filesystem->get_contents($file); 153 if ($content === '') return []; 154 155 $lines = preg_split("/\r\n|\n|\r/", $content); 118 156 119 157 // Remove potential trailing empty line … … 124 162 return array_slice($lines, -$max_lines); 125 163 } 164 126 165 127 166 function ghostupdate_get_excluded_ids() { … … 146 185 $limit = max(1, (int) $limit); 147 186 148 $sql = "SELECT ID FROM {$wpdb->posts}187 $sql = "SELECT ID FROM {$wpdb->posts} 149 188 WHERE post_status = 'publish' 150 189 AND post_type IN ('post','page') … … 161 200 $args[] = $limit; 162 201 163 $prepared = $wpdb->prepare($sql, $args); 164 return $wpdb->get_col($prepared); 202 // Cache to satisfy PHPCS NoCaching + reduce repeated selects during runs. 203 $cache_group = 'ghost-update'; 204 $cache_key = 'cand_ids_' . md5($cursor . '|' . $limit . '|' . implode(',', array_map('intval', (array) $excluded))); 205 $cached = wp_cache_get($cache_key, $cache_group); 206 if ($cached !== false) { 207 return $cached; 208 } 209 210 // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared 211 // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery 212 $ids = $wpdb->get_col( 213 $wpdb->prepare($sql, ...$args) 214 ); 215 // phpcs:enable WordPress.DB.PreparedSQL.NotPrepared 216 // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery 217 wp_cache_set($cache_key, $ids, $cache_group, 30); 218 219 return $ids; 165 220 } 166 221 -
ghost-update/trunk/readme.txt
r3448117 r3448175 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.2 7 Stable tag: 1.2. 17 Stable tag: 1.2.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.