Sync your WordPress posts to standard.site records on your PDS
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

cron refresh token

+48
+2
README.md
··· 53 53 54 54 A `<link rel="site.standard.document">` tag is added to the `<head>` of each synced post for verification. 55 55 56 + Note that Wireservice does not have a content lexicon yet. This is in development. 57 + 56 58 ### Per-Post Overrides 57 59 58 60 A **Wireservice** meta box appears on the post editor, allowing per-post overrides for:
+35
includes/Setup.php
··· 55 55 add_action("template_redirect", [$this, "handle_well_known_request"]); 56 56 add_filter("query_vars", [$this, "add_query_vars"]); 57 57 58 + // Scheduled token refresh. 59 + add_action("wireservice_refresh_token", [$this, "handle_scheduled_refresh"]); 60 + $this->ensure_cron_scheduled(); 61 + 58 62 // Document sync hooks. 59 63 // Use wp_after_insert_post (WP 5.6+) to ensure all meta (including Yoast) is saved first. 60 64 add_action("wp_after_insert_post", [$this, "maybe_sync_document"], 10, 2); ··· 73 77 add_action("add_meta_boxes", [$this, "add_document_meta_box"]); 74 78 add_action("save_post", [$this, "save_document_meta_box"], 10, 2); 75 79 add_action("admin_enqueue_scripts", [$this, "enqueue_meta_box_assets"]); 80 + } 81 + 82 + /** 83 + * Ensure the token refresh cron event is scheduled. 84 + * 85 + * Covers upgrades from older versions where activation won't re-run. 86 + * 87 + * @return void 88 + */ 89 + private function ensure_cron_scheduled(): void 90 + { 91 + if ( 92 + $this->connections_manager->is_connected() && 93 + !wp_next_scheduled("wireservice_refresh_token") 94 + ) { 95 + wp_schedule_event(time(), "twicedaily", "wireservice_refresh_token"); 96 + } 97 + } 98 + 99 + /** 100 + * Handle the scheduled token refresh. 101 + * 102 + * @return void 103 + */ 104 + public function handle_scheduled_refresh(): void 105 + { 106 + if (!$this->connections_manager->is_connected()) { 107 + return; 108 + } 109 + 110 + $this->connections_manager->get_access_token(); 76 111 } 77 112 78 113 /**
+3
uninstall.php
··· 9 9 die(); 10 10 } 11 11 12 + // Clear scheduled events. 13 + wp_clear_scheduled_hook("wireservice_refresh_token"); 14 + 12 15 // Remove plugin options. 13 16 delete_option("wireservice_connection"); 14 17 delete_option("wireservice_client_id");
+8
wireservice.php
··· 67 67 68 68 // Flush rewrite rules. 69 69 flush_rewrite_rules(); 70 + 71 + // Schedule token refresh cron event. 72 + if (!wp_next_scheduled("wireservice_refresh_token")) { 73 + wp_schedule_event(time(), "twicedaily", "wireservice_refresh_token"); 74 + } 70 75 } 71 76 register_activation_hook(__FILE__, "wireservice_activate"); 72 77 ··· 77 82 { 78 83 // Flush rewrite rules to remove our custom rules. 79 84 flush_rewrite_rules(); 85 + 86 + // Clear scheduled token refresh. 87 + wp_clear_scheduled_hook("wireservice_refresh_token"); 80 88 } 81 89 register_deactivation_hook(__FILE__, "wireservice_deactivate"); 82 90