Changeset 3292255
- Timestamp:
- 05/13/2025 05:35:57 AM (10 months ago)
- Location:
- findkit
- Files:
-
- 10 edited
- 1 copied
-
tags/1.4.2 (copied) (copied from findkit/trunk)
-
tags/1.4.2/CHANGELOG.md (modified) (1 diff)
-
tags/1.4.2/plugin.php (modified) (1 diff)
-
tags/1.4.2/readme.txt (modified) (1 diff)
-
tags/1.4.2/src/LiveUpdate.php (modified) (5 diffs)
-
tags/1.4.2/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/CHANGELOG.md (modified) (1 diff)
-
trunk/plugin.php (modified) (1 diff)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/src/LiveUpdate.php (modified) (5 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
findkit/tags/1.4.2/CHANGELOG.md
r3288265 r3292255 1 ## v1.4.2 2 3 2025-05-13 4 5 - Fix live update issues [58bd260](https://github.com/findkit/wp-findkit/commit/58bd260) - Lauri Saarni 6 - Moving post to trash from post list now triggers liveupdate 7 - Bulk save posts when change state to publish now trigger liveupdate (note that manual crawl can handle 10 max urls) 8 - Permalink changes should trigger live update for old and new urls to prevent duplicates in the search index 9 10 All changes https://github.com/findkit/wp-findkit/compare/v1.4.1...v1.4.2 11 1 12 ## v1.4.1 2 13 -
findkit/tags/1.4.2/plugin.php
r3288265 r3292255 10 10 * Description: WordPress Plugin for Findkit Site Search. See findkit.com for details 11 11 * Author: Findkit Team <findkit@findkit.com> 12 * Version: 1.4. 112 * Version: 1.4.2 13 13 * License: GPLv2 or later 14 14 */ -
findkit/tags/1.4.2/readme.txt
r3288265 r3292255 4 4 Requires at least: 6.0 5 5 Tested up to: 6.7.1 6 Stable tag: 1.4. 16 Stable tag: 1.4.2 7 7 Requires PHP: 7.2 8 8 Donate link: https://www.findkit.com/ -
findkit/tags/1.4.2/src/LiveUpdate.php
r3288265 r3292255 15 15 */ 16 16 private $pending_posts = null; 17 18 /** 19 * Old permalinks to be removed from the index 20 */ 21 private static $old_permalinks = []; 17 22 18 23 /** … … 37 42 ); 38 43 44 add_filter( 45 'wp_insert_post_data', 46 [__CLASS__, 'pre_save_store_old_permalink'], 47 10, 48 2 49 ); 50 51 add_action('save_post', [$this, 'on_save_post'], 10, 3); 52 39 53 // Send updates on shutdown when we can be sure that post changes have been saved 40 54 \add_action('shutdown', [$this, 'flush_updates']); … … 49 63 $urls = []; 50 64 51 foreach ($this->pending_posts as $post) { 52 $urls[] = Utils::get_public_permalink($post); 53 } 65 foreach ($this->pending_posts as $item) { 66 if ($item instanceof \WP_Post) { 67 $urls[] = Utils::get_public_permalink($item); 68 } elseif (is_string($item)) { 69 $urls[] = $item; 70 } 71 } 72 73 $urls = array_unique($urls); 54 74 55 75 return $this->api_client->manual_crawl($urls); … … 77 97 // because then we would ignore legit standalone updates via REST API. 78 98 $is_rest_request = defined('REST_REQUEST') && REST_REQUEST; 99 100 // Detect bulk or trash actions from post list (not REST) 101 $is_bulk_or_trash_action = false; 102 if ( 103 isset($_REQUEST['action']) && 104 in_array($_REQUEST['action'], ['trash', 'delete', 'edit'], true) 105 ) { 106 $is_bulk_or_trash_action = true; 107 } 108 if ( 109 isset($_REQUEST['action2']) && 110 in_array($_REQUEST['action2'], ['trash', 'delete', 'edit'], true) 111 ) { 112 $is_bulk_or_trash_action = true; 113 } 114 115 // If not REST, and not a bulk/trash action, and using block editor, skip to avoid duplicate 79 116 if ( 80 117 !$is_rest_request && 118 !$is_bulk_or_trash_action && 81 119 \use_block_editor_for_post_type($post->post_type) 82 120 ) { … … 132 170 return false; 133 171 } 172 173 public static function pre_save_store_old_permalink($data, $postarr) 174 { 175 if (empty($postarr['ID'])) { 176 return $data; 177 } 178 $post_id = (int) $postarr['ID']; 179 $old_post = get_post($post_id); 180 if ($old_post) { 181 $old_permalink = get_permalink($old_post); 182 self::$old_permalinks[$post_id] = $old_permalink; 183 } 184 return $data; 185 } 186 187 public function on_save_post($post_id, $post, $update) 188 { 189 // Only for published posts 190 if ($post->post_status !== 'publish') { 191 return; 192 } 193 194 $old_permalink = self::$old_permalinks[$post_id] ?? null; 195 $new_permalink = get_permalink($post); 196 197 if ($old_permalink && $old_permalink !== $new_permalink) { 198 $this->enqueue_url($old_permalink); 199 } 200 } 201 202 function enqueue_url(string $url) 203 { 204 $is_development = defined('WP_ENV') && WP_ENV === 'development'; 205 206 $can_live_update = apply_filters( 207 'findkit_can_live_update_post', 208 php_sapi_name() !== 'cli' && !$is_development, 209 null // No post object 210 ); 211 212 if (!$can_live_update) { 213 return; 214 } 215 216 if ($this->pending_posts === null) { 217 $this->pending_posts = []; 218 } 219 220 // Store as a string URL 221 $this->pending_posts[] = $url; 222 } 134 223 } -
findkit/tags/1.4.2/vendor/composer/installed.php
r3288265 r3292255 4 4 'pretty_version' => 'dev-main', 5 5 'version' => 'dev-main', 6 'reference' => ' 7c24028c72591fedca974658d3bfa5c1f2730382',6 'reference' => 'dd640127eaa33ea5a884d4bf19aaefeb4f93605d', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-main', 15 15 'version' => 'dev-main', 16 'reference' => ' 7c24028c72591fedca974658d3bfa5c1f2730382',16 'reference' => 'dd640127eaa33ea5a884d4bf19aaefeb4f93605d', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../', -
findkit/trunk/CHANGELOG.md
r3288265 r3292255 1 ## v1.4.2 2 3 2025-05-13 4 5 - Fix live update issues [58bd260](https://github.com/findkit/wp-findkit/commit/58bd260) - Lauri Saarni 6 - Moving post to trash from post list now triggers liveupdate 7 - Bulk save posts when change state to publish now trigger liveupdate (note that manual crawl can handle 10 max urls) 8 - Permalink changes should trigger live update for old and new urls to prevent duplicates in the search index 9 10 All changes https://github.com/findkit/wp-findkit/compare/v1.4.1...v1.4.2 11 1 12 ## v1.4.1 2 13 -
findkit/trunk/plugin.php
r3288265 r3292255 10 10 * Description: WordPress Plugin for Findkit Site Search. See findkit.com for details 11 11 * Author: Findkit Team <findkit@findkit.com> 12 * Version: 1.4. 112 * Version: 1.4.2 13 13 * License: GPLv2 or later 14 14 */ -
findkit/trunk/readme.txt
r3288265 r3292255 4 4 Requires at least: 6.0 5 5 Tested up to: 6.7.1 6 Stable tag: 1.4. 16 Stable tag: 1.4.2 7 7 Requires PHP: 7.2 8 8 Donate link: https://www.findkit.com/ -
findkit/trunk/src/LiveUpdate.php
r3288265 r3292255 15 15 */ 16 16 private $pending_posts = null; 17 18 /** 19 * Old permalinks to be removed from the index 20 */ 21 private static $old_permalinks = []; 17 22 18 23 /** … … 37 42 ); 38 43 44 add_filter( 45 'wp_insert_post_data', 46 [__CLASS__, 'pre_save_store_old_permalink'], 47 10, 48 2 49 ); 50 51 add_action('save_post', [$this, 'on_save_post'], 10, 3); 52 39 53 // Send updates on shutdown when we can be sure that post changes have been saved 40 54 \add_action('shutdown', [$this, 'flush_updates']); … … 49 63 $urls = []; 50 64 51 foreach ($this->pending_posts as $post) { 52 $urls[] = Utils::get_public_permalink($post); 53 } 65 foreach ($this->pending_posts as $item) { 66 if ($item instanceof \WP_Post) { 67 $urls[] = Utils::get_public_permalink($item); 68 } elseif (is_string($item)) { 69 $urls[] = $item; 70 } 71 } 72 73 $urls = array_unique($urls); 54 74 55 75 return $this->api_client->manual_crawl($urls); … … 77 97 // because then we would ignore legit standalone updates via REST API. 78 98 $is_rest_request = defined('REST_REQUEST') && REST_REQUEST; 99 100 // Detect bulk or trash actions from post list (not REST) 101 $is_bulk_or_trash_action = false; 102 if ( 103 isset($_REQUEST['action']) && 104 in_array($_REQUEST['action'], ['trash', 'delete', 'edit'], true) 105 ) { 106 $is_bulk_or_trash_action = true; 107 } 108 if ( 109 isset($_REQUEST['action2']) && 110 in_array($_REQUEST['action2'], ['trash', 'delete', 'edit'], true) 111 ) { 112 $is_bulk_or_trash_action = true; 113 } 114 115 // If not REST, and not a bulk/trash action, and using block editor, skip to avoid duplicate 79 116 if ( 80 117 !$is_rest_request && 118 !$is_bulk_or_trash_action && 81 119 \use_block_editor_for_post_type($post->post_type) 82 120 ) { … … 132 170 return false; 133 171 } 172 173 public static function pre_save_store_old_permalink($data, $postarr) 174 { 175 if (empty($postarr['ID'])) { 176 return $data; 177 } 178 $post_id = (int) $postarr['ID']; 179 $old_post = get_post($post_id); 180 if ($old_post) { 181 $old_permalink = get_permalink($old_post); 182 self::$old_permalinks[$post_id] = $old_permalink; 183 } 184 return $data; 185 } 186 187 public function on_save_post($post_id, $post, $update) 188 { 189 // Only for published posts 190 if ($post->post_status !== 'publish') { 191 return; 192 } 193 194 $old_permalink = self::$old_permalinks[$post_id] ?? null; 195 $new_permalink = get_permalink($post); 196 197 if ($old_permalink && $old_permalink !== $new_permalink) { 198 $this->enqueue_url($old_permalink); 199 } 200 } 201 202 function enqueue_url(string $url) 203 { 204 $is_development = defined('WP_ENV') && WP_ENV === 'development'; 205 206 $can_live_update = apply_filters( 207 'findkit_can_live_update_post', 208 php_sapi_name() !== 'cli' && !$is_development, 209 null // No post object 210 ); 211 212 if (!$can_live_update) { 213 return; 214 } 215 216 if ($this->pending_posts === null) { 217 $this->pending_posts = []; 218 } 219 220 // Store as a string URL 221 $this->pending_posts[] = $url; 222 } 134 223 } -
findkit/trunk/vendor/composer/installed.php
r3288265 r3292255 4 4 'pretty_version' => 'dev-main', 5 5 'version' => 'dev-main', 6 'reference' => ' 7c24028c72591fedca974658d3bfa5c1f2730382',6 'reference' => 'dd640127eaa33ea5a884d4bf19aaefeb4f93605d', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-main', 15 15 'version' => 'dev-main', 16 'reference' => ' 7c24028c72591fedca974658d3bfa5c1f2730382',16 'reference' => 'dd640127eaa33ea5a884d4bf19aaefeb4f93605d', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.