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

Configure Feed

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

at main 98 lines 2.5 kB view raw
1<?php 2declare(strict_types=1); 3/** 4 * Plugin Name: Wireservice 5 * Plugin URI: https://wordpress.wireservice.net 6 * Description: A WordPress plugin for publishing posts to the AT Protocol based on the standard.site lexicon. 7 * Version: 1.2.0 8 * Author: Tyler Fisher 9 * Author URI: https://tylerjfisher.com 10 * License: AGPL-3.0+ 11 * License URI: https://www.gnu.org/licenses/agpl-3.0.html 12 * Requires at least: 6.4 13 * Requires PHP: 8.3 14 * Text Domain: wireservice 15 */ 16 17// If this file is called directly, abort. 18if (!defined("WPINC")) { 19 die(); 20} 21 22// Minimum WordPress version. 23define("WIRESERVICE_MIN_WP_VERSION", "6.4"); 24 25// Check WordPress version. 26global $wp_version; 27if (version_compare($wp_version, WIRESERVICE_MIN_WP_VERSION, "<")) { 28 add_action("admin_notices", function () { 29 printf( 30 '<div class="notice notice-error"><p>%s</p></div>', 31 sprintf( 32 /* translators: %s: minimum WordPress version */ 33 esc_html__( 34 "Wireservice requires WordPress %s or higher.", 35 "wireservice", 36 ), 37 esc_html(WIRESERVICE_MIN_WP_VERSION), 38 ), 39 ); 40 }); 41 return; 42} 43 44// Plugin version. 45define("WIRESERVICE_VERSION", "1.2.0"); 46 47// Plugin directory path. 48define("WIRESERVICE_PLUGIN_DIR", plugin_dir_path(__FILE__)); 49 50// Plugin directory URL. 51define("WIRESERVICE_PLUGIN_URL", plugin_dir_url(__FILE__)); 52 53// Load Composer autoloader. 54if (file_exists(WIRESERVICE_PLUGIN_DIR . "vendor/autoload.php")) { 55 require_once WIRESERVICE_PLUGIN_DIR . "vendor/autoload.php"; 56} 57 58/** 59 * Code that runs during plugin activation. 60 */ 61function wireservice_activate() 62{ 63 // Register rewrite rules. 64 $setup = new Wireservice\Setup(); 65 $setup->register_well_known_rewrite(); 66 67 // Flush rewrite rules. 68 flush_rewrite_rules(); 69 70 // Schedule token refresh cron event. 71 if (!wp_next_scheduled("wireservice_refresh_token")) { 72 wp_schedule_event(time(), "twicedaily", "wireservice_refresh_token"); 73 } 74} 75register_activation_hook(__FILE__, "wireservice_activate"); 76 77/** 78 * Code that runs during plugin deactivation. 79 */ 80function wireservice_deactivate() 81{ 82 // Flush rewrite rules to remove our custom rules. 83 flush_rewrite_rules(); 84 85 // Clear scheduled token refresh. 86 wp_clear_scheduled_hook("wireservice_refresh_token"); 87} 88register_deactivation_hook(__FILE__, "wireservice_deactivate"); 89 90/** 91 * Initialize the plugin. 92 */ 93function wireservice_init() 94{ 95 $setup = new Wireservice\Setup(); 96 $setup->init(); 97} 98add_action("plugins_loaded", "wireservice_init");