Plugin Directory

Changeset 3474122


Ignore:
Timestamp:
03/04/2026 03:03:32 AM (4 weeks ago)
Author:
floyi
Message:

Release 1.0.1 - Add webhook for permanent post deletions

Location:
floyi
Files:
26 added
2 edited

Legend:

Unmodified
Added
Removed
  • floyi/trunk/floyi.php

    r3463064 r3474122  
    44 * Plugin URI: https://floyi.com/wordpress-plugin
    55 * Description: Connect your WordPress site to Floyi for seamless content publishing from your topical authority platform.
    6  * Version: 1.0.0
     6 * Version: 1.0.1
    77 * Author: Floyi
    88 * Author URI: https://floyi.com
     
    2323
    2424// Plugin constants
    25 define('FLOYI_CONNECT_VERSION', '1.0.0');
     25define('FLOYI_CONNECT_VERSION', '1.0.1');
    2626define('FLOYI_CONNECT_PLUGIN_DIR', plugin_dir_path(__FILE__));
    2727define('FLOYI_CONNECT_PLUGIN_URL', plugin_dir_url(__FILE__));
     
    103103        // Track post status changes for Floyi-managed posts
    104104        add_action('transition_post_status', array($this, 'handle_post_status_change'), 10, 3);
     105
     106        // Track permanent deletions (emptying trash) for Floyi-managed posts
     107        add_action('before_delete_post', array($this, 'handle_post_deleted'), 10, 2);
    105108    }
    106109
     
    146149            // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- Guarded by WP_DEBUG check.
    147150            error_log("[Floyi] Queued webhook for post {$post->ID}: " . ($queue_id ? "id={$queue_id}" : 'FAILED'));
     151        }
     152
     153        // Process queue immediately instead of waiting for cron
     154        Floyi_Webhook_Queue::process_queue();
     155    }
     156
     157    /**
     158     * Handle permanent post deletion for Floyi-managed posts.
     159     *
     160     * Fires when a post is permanently deleted (emptying trash or force delete).
     161     * Queues a webhook notification so Floyi can clean up its publish record.
     162     *
     163     * @param int     $post_id Post ID being deleted.
     164     * @param WP_Post $post    Post object.
     165     */
     166    public function handle_post_deleted($post_id, $post) {
     167        // Skip if not connected to Floyi
     168        if (!self::is_connected()) {
     169            return;
     170        }
     171
     172        // Only track posts that were published via Floyi
     173        $floyi_article_id = get_post_meta($post_id, '_floyi_article_id', true);
     174        if (!$floyi_article_id) {
     175            return;
     176        }
     177
     178        // Queue webhook event
     179        $queue_id = Floyi_Webhook_Queue::add('post_deleted', array(
     180            'wp_post_id'       => $post_id,
     181            'floyi_article_id' => $floyi_article_id,
     182            'post_title'       => $post->post_title,
     183        ));
     184
     185        if (defined('WP_DEBUG') && WP_DEBUG) {
     186            // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- Guarded by WP_DEBUG check.
     187            error_log("[Floyi] Queued post_deleted webhook for post {$post_id}: " . ($queue_id ? "id={$queue_id}" : 'FAILED'));
    148188        }
    149189
  • floyi/trunk/readme.txt

    r3463070 r3474122  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.0.0
     7Stable tag: 1.0.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    125125== Changelog ==
    126126
     127= 1.0.1 =
     128* Added webhook notification for permanent post deletions so Floyi cleans up publish records
     129* Hooks into `before_delete_post` to detect when Floyi-managed posts are permanently removed
     130
    127131= 1.0.0 =
    128132* Initial release
     
    142146== Upgrade Notice ==
    143147
     148= 1.0.1 =
     149Fixes publish record cleanup when posts are permanently deleted from WordPress.
     150
    144151= 1.0.0 =
    145152Initial release of Floyi Connect.
Note: See TracChangeset for help on using the changeset viewer.