-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathatmosphere.php
More file actions
108 lines (95 loc) · 3.43 KB
/
Copy pathatmosphere.php
File metadata and controls
108 lines (95 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/**
* Plugin Name: ATmosphere
* Plugin URI: https://github.com/pfefferle/atmosphere
* Description: Publish WordPress posts to AT Protocol (Bluesky + standard.site) via native OAuth.
* Version: 1.2.0
* Author: Automattic
* Author URI: https://automattic.com
* License: GPL-2.0-or-later
* License URI: https://spdx.org/licenses/GPL-2.0-or-later.html
* Text Domain: atmosphere
* Requires PHP: 8.2
* Requires at least: 6.5
*
* @package Atmosphere
*/
namespace Atmosphere;
\defined( 'ABSPATH' ) || exit;
\define( 'ATMOSPHERE_VERSION', '1.2.0' );
\define( 'ATMOSPHERE_PLUGIN_DIR', \plugin_dir_path( __FILE__ ) );
\define( 'ATMOSPHERE_PLUGIN_URL', \plugin_dir_url( __FILE__ ) );
\define( 'ATMOSPHERE_PLUGIN_FILE', __FILE__ );
/**
* Post meta key: per-post opt-out from sharing to Bluesky.
*
* Stored as a registered, REST-exposed boolean so the block-editor panel
* can bind a toggle to it. '1' (true) means the author switched sharing
* off for this post; absent/empty means the default — sharing is on.
*/
\define( 'ATMOSPHERE_META_DISABLED', 'atmosphere_disabled' );
/**
* Post meta key: per-post custom text for the Bluesky post.
*
* Stored as a registered, REST-exposed string so the block-editor panel
* can bind a textarea to it. When set, this exact text is posted to
* Bluesky (with a link card back to the post) instead of the text the
* normal short-form / long-form composition would generate — the
* Bluesky equivalent of the post excerpt. Empty means the default
* composition runs unchanged.
*/
\define( 'ATMOSPHERE_META_CUSTOM_TEXT', 'atmosphere_custom_text' );
/*
* Custom autoloader for Atmosphere classes — maps the Atmosphere
* namespace to includes/ using WordPress filename conventions.
*/
require_once ATMOSPHERE_PLUGIN_DIR . 'includes/class-autoloader.php';
Autoloader::register_path( __NAMESPACE__ . '\Integrations', ATMOSPHERE_PLUGIN_DIR . 'integrations' );
Autoloader::register_path( __NAMESPACE__, ATMOSPHERE_PLUGIN_DIR . 'includes' );
// Helper functions.
require_once ATMOSPHERE_PLUGIN_DIR . 'includes/functions.php';
/**
* Initialize the plugin.
*/
function init() {
$atmosphere = new Atmosphere();
$atmosphere->init();
}
\add_action( 'plugins_loaded', __NAMESPACE__ . '\init' );
/*
* Register WP-CLI commands when running under WP-CLI. Gated so the
* regular web-request path never autoloads the CLI classes.
*/
if ( \defined( 'WP_CLI' ) && \WP_CLI ) {
Cli::register();
}
/**
* Activation hook.
*/
function activate() {
// Generate publication TID on first activation.
if ( ! \get_option( 'atmosphere_publication_tid' ) ) {
$tid = Transformer\TID::generate();
\update_option( 'atmosphere_publication_tid', $tid, false );
}
// Flush rewrite rules for client metadata endpoint.
\flush_rewrite_rules();
}
\register_activation_hook( __FILE__, __NAMESPACE__ . '\activate' );
/**
* Deactivation hook.
*/
function deactivate() {
/*
* Use the all-hooks variant: deactivation is the user-visible
* "stop running everything" moment, so any still-queued one-shot
* cron event (notably `atmosphere_revoke_refresh_token`, which
* `Client::disconnect()` schedules outside the regular
* `clear_scheduled_hooks()` set) must be cleared too. Otherwise
* its encrypted ciphertexts sit in `wp_options['cron']` waiting
* for a callback the deactivated plugin no longer registers.
*/
clear_scheduled_hooks_all();
\flush_rewrite_rules();
}
\register_deactivation_hook( __FILE__, __NAMESPACE__ . '\deactivate' );