Plugin Directory

Changeset 3292255


Ignore:
Timestamp:
05/13/2025 05:35:57 AM (10 months ago)
Author:
findkit
Message:

Update to version 1.4.2 from GitHub

Location:
findkit
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • findkit/tags/1.4.2/CHANGELOG.md

    r3288265 r3292255  
     1## v1.4.2
     2
     32025-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
     10All changes https://github.com/findkit/wp-findkit/compare/v1.4.1...v1.4.2
     11
    112## v1.4.1
    213
  • findkit/tags/1.4.2/plugin.php

    r3288265 r3292255  
    1010 * Description: WordPress Plugin for Findkit Site Search. See findkit.com for details
    1111 * Author: Findkit Team <findkit@findkit.com>
    12  * Version: 1.4.1
     12 * Version: 1.4.2
    1313 * License: GPLv2 or later
    1414 */
  • findkit/tags/1.4.2/readme.txt

    r3288265 r3292255  
    44Requires at least: 6.0
    55Tested up to: 6.7.1
    6 Stable tag: 1.4.1
     6Stable tag: 1.4.2
    77Requires PHP: 7.2
    88Donate link: https://www.findkit.com/
  • findkit/tags/1.4.2/src/LiveUpdate.php

    r3288265 r3292255  
    1515     */
    1616    private $pending_posts = null;
     17
     18    /**
     19     * Old permalinks to be removed from the index
     20     */
     21    private static $old_permalinks = [];
    1722
    1823    /**
     
    3742        );
    3843
     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
    3953        // Send updates on shutdown when we can be sure that post changes have been saved
    4054        \add_action('shutdown', [$this, 'flush_updates']);
     
    4963        $urls = [];
    5064
    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);
    5474
    5575        return $this->api_client->manual_crawl($urls);
     
    7797        // because then we would ignore legit standalone updates via REST API.
    7898        $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
    79116        if (
    80117            !$is_rest_request &&
     118            !$is_bulk_or_trash_action &&
    81119            \use_block_editor_for_post_type($post->post_type)
    82120        ) {
     
    132170        return false;
    133171    }
     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    }
    134223}
  • findkit/tags/1.4.2/vendor/composer/installed.php

    r3288265 r3292255  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => '7c24028c72591fedca974658d3bfa5c1f2730382',
     6        'reference' => 'dd640127eaa33ea5a884d4bf19aaefeb4f93605d',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => '7c24028c72591fedca974658d3bfa5c1f2730382',
     16            'reference' => 'dd640127eaa33ea5a884d4bf19aaefeb4f93605d',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
  • findkit/trunk/CHANGELOG.md

    r3288265 r3292255  
     1## v1.4.2
     2
     32025-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
     10All changes https://github.com/findkit/wp-findkit/compare/v1.4.1...v1.4.2
     11
    112## v1.4.1
    213
  • findkit/trunk/plugin.php

    r3288265 r3292255  
    1010 * Description: WordPress Plugin for Findkit Site Search. See findkit.com for details
    1111 * Author: Findkit Team <findkit@findkit.com>
    12  * Version: 1.4.1
     12 * Version: 1.4.2
    1313 * License: GPLv2 or later
    1414 */
  • findkit/trunk/readme.txt

    r3288265 r3292255  
    44Requires at least: 6.0
    55Tested up to: 6.7.1
    6 Stable tag: 1.4.1
     6Stable tag: 1.4.2
    77Requires PHP: 7.2
    88Donate link: https://www.findkit.com/
  • findkit/trunk/src/LiveUpdate.php

    r3288265 r3292255  
    1515     */
    1616    private $pending_posts = null;
     17
     18    /**
     19     * Old permalinks to be removed from the index
     20     */
     21    private static $old_permalinks = [];
    1722
    1823    /**
     
    3742        );
    3843
     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
    3953        // Send updates on shutdown when we can be sure that post changes have been saved
    4054        \add_action('shutdown', [$this, 'flush_updates']);
     
    4963        $urls = [];
    5064
    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);
    5474
    5575        return $this->api_client->manual_crawl($urls);
     
    7797        // because then we would ignore legit standalone updates via REST API.
    7898        $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
    79116        if (
    80117            !$is_rest_request &&
     118            !$is_bulk_or_trash_action &&
    81119            \use_block_editor_for_post_type($post->post_type)
    82120        ) {
     
    132170        return false;
    133171    }
     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    }
    134223}
  • findkit/trunk/vendor/composer/installed.php

    r3288265 r3292255  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => '7c24028c72591fedca974658d3bfa5c1f2730382',
     6        'reference' => 'dd640127eaa33ea5a884d4bf19aaefeb4f93605d',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => '7c24028c72591fedca974658d3bfa5c1f2730382',
     16            'reference' => 'dd640127eaa33ea5a884d4bf19aaefeb4f93605d',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.