-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextrachill-studio.php
More file actions
190 lines (172 loc) · 6.16 KB
/
Copy pathextrachill-studio.php
File metadata and controls
190 lines (172 loc) · 6.16 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php
/**
* Plugin Name: Extra Chill Studio
* Plugin URI: https://extrachill.com
* Description: Internal studio workspace for the Extra Chill team with a team-gated block shell for publishing and AI-assisted workflows.
* Version: 0.26.0
* Author: Chris Huber
* Author URI: https://chubes.net
* Requires Plugins: extrachill-users
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: extrachill-studio
* Requires at least: 6.9
* Tested up to: 6.9
* Requires PHP: 7.4
* Network: false
*
* @package ExtraChillStudio
* @since 0.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'EXTRACHILL_STUDIO_VERSION', '0.26.0' );
define( 'EXTRACHILL_STUDIO_PLUGIN_FILE', __FILE__ );
define( 'EXTRACHILL_STUDIO_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'EXTRACHILL_STUDIO_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'EXTRACHILL_STUDIO_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
require_once EXTRACHILL_STUDIO_PLUGIN_DIR . 'inc/team-experience/events.php';
require_once EXTRACHILL_STUDIO_PLUGIN_DIR . 'inc/assets.php';
require_once EXTRACHILL_STUDIO_PLUGIN_DIR . 'inc/breadcrumbs.php';
require_once EXTRACHILL_STUDIO_PLUGIN_DIR . 'inc/social-drafts.php';
require_once EXTRACHILL_STUDIO_PLUGIN_DIR . 'inc/compose-editor.php';
require_once EXTRACHILL_STUDIO_PLUGIN_DIR . 'inc/compose/rest.php';
require_once EXTRACHILL_STUDIO_PLUGIN_DIR . 'inc/compose/notify-on-publish.php';
require_once EXTRACHILL_STUDIO_PLUGIN_DIR . 'inc/compose/strand-detector.php';
require_once EXTRACHILL_STUDIO_PLUGIN_DIR . 'inc/review-queue.php';
require_once EXTRACHILL_STUDIO_PLUGIN_DIR . 'inc/abilities/resolve-instagram-media.php';
require_once EXTRACHILL_STUDIO_PLUGIN_DIR . 'inc/abilities/run-giveaway.php';
require_once EXTRACHILL_STUDIO_PLUGIN_DIR . 'inc/abilities/sweatpants-token.php';
require_once EXTRACHILL_STUDIO_PLUGIN_DIR . 'inc/transcription/email-template.php';
require_once EXTRACHILL_STUDIO_PLUGIN_DIR . 'inc/transcription/callback.php';
/*
* Defer loading of GiveawayTask until after Data Machine has registered its
* PSR-4 autoloader. The class extends DataMachine\Engine\AI\System\Tasks\SystemTask,
* and PHP resolves the parent class at class-declaration time. Loading at the
* top of this file races DM's bootstrap and produces a fatal when DM's
* autoloader has not yet been registered (see issue #36). plugins_loaded
* priority 20 guarantees DM's main plugin file (priority 10) has run.
*/
add_action( 'plugins_loaded', static function () {
require_once EXTRACHILL_STUDIO_PLUGIN_DIR . 'inc/tasks/giveaway-task.php';
}, 20 );
/**
* Register Studio's ability category before abilities are registered.
*
* @return void
*/
function extrachill_studio_register_ability_category() {
if ( ! function_exists( 'wp_register_ability_category' ) ) {
return;
}
// Core's wp_abilities_api_categories_init action can fire more than once per
// request on multisite; guard against re-registration to avoid a
// _doing_it_wrong notice from WP_Ability_Categories_Registry::register().
if ( function_exists( 'wp_has_ability_category' ) && wp_has_ability_category( 'extrachill' ) ) {
return;
}
wp_register_ability_category(
'extrachill',
array(
'label' => __( 'Extra Chill', 'extrachill-studio' ),
'description' => __( 'Extra Chill platform tools and workflows.', 'extrachill-studio' ),
)
);
}
add_action( 'wp_abilities_api_categories_init', 'extrachill_studio_register_ability_category' );
/**
* Register the giveaway task with the Data Machine Task System.
*
* @param array $tasks Registered task classes.
* @return array
*/
add_filter( 'datamachine_tasks', function ( array $tasks ): array {
$tasks['giveaway'] = \ExtraChillStudio\Tasks\GiveawayTask::class;
return $tasks;
} );
/**
* Pin Instagram to the top of the social platforms response.
*
* Studio's primary social workflow targets Instagram, so the platform
* sidebar should default to Instagram instead of the alphabetically-first
* authenticated platform. Studio prepends 'instagram' to whatever priority
* list other plugins may have set, rather than replacing it.
*
* Filter contract is documented in
* data-machine-socials/inc/RestApi.php::get_platforms (since v0.13.1).
*
* @param array $priority Ordered list of platform slugs.
* @return array
*/
add_filter( 'datamachine_socials_platform_priority', function ( array $priority ): array {
return array_values( array_unique( array_merge( array( 'instagram' ), $priority ) ) );
} );
register_activation_hook( __FILE__, 'extrachill_studio_activate' );
register_deactivation_hook( __FILE__, 'extrachill_studio_deactivate' );
/**
* Activation hook.
*
* @return void
*/
function extrachill_studio_activate() {
flush_rewrite_rules();
}
/**
* Deactivation hook.
*
* @return void
*/
function extrachill_studio_deactivate() {
flush_rewrite_rules();
}
/**
* Load translations.
*
* @return void
*/
function extrachill_studio_load_textdomain() {
load_plugin_textdomain(
'extrachill-studio',
false,
dirname( EXTRACHILL_STUDIO_PLUGIN_BASENAME ) . '/languages'
);
}
add_action( 'init', 'extrachill_studio_load_textdomain' );
/**
* Register Studio block.
*
* @return void
*/
function extrachill_studio_register_blocks() {
$blocks_dir = file_exists( EXTRACHILL_STUDIO_PLUGIN_DIR . 'build/blocks/studio' )
? 'build/blocks'
: 'src/blocks';
register_block_type( EXTRACHILL_STUDIO_PLUGIN_DIR . $blocks_dir . '/studio' );
}
add_action( 'init', 'extrachill_studio_register_blocks' );
/**
* Hide the theme page title on the Studio homepage.
*
* The Studio block shell renders its own headline/description, so the page
* template H1 should not duplicate that chrome.
*
* @param bool $show Whether to show the page title.
* @return bool
*/
function extrachill_studio_hide_page_title( $show ) {
if ( is_front_page() || is_home() ) {
return false;
}
return $show;
}
add_filter( 'extrachill_show_page_title', 'extrachill_studio_hide_page_title' );
/**
* Render homepage content for studio.extrachill.com.
*
* @return void
*/
function extrachill_studio_render_homepage() {
include EXTRACHILL_STUDIO_PLUGIN_DIR . 'inc/templates/studio-homepage.php';
}
add_action( 'extrachill_homepage_content', 'extrachill_studio_render_homepage' );