← All changes
|
src/content-helper/editor-sidebar/class-editor-sidebar.php
+59
-0
3.23.3
→
3.24.2
View file →
| @@ -184,8 +184,43 @@ | ||
| 184 | 184 | 'window.wpParselyTrackableStatuses = ' . wp_json_encode( $trackable_statuses ) . ';', |
| 185 | 185 | 'before' |
| 186 | 186 | ); |
| 187 | 187 | |
| 188 | + // Inject the tones and personas, so that PHP stays their single source | |
| 189 | + // and the settings page can offer the same choices as the editor. | |
| 190 | + wp_add_inline_script( | |
| 191 | + static::get_script_id(), | |
| 192 | + 'window.wpParselyContentHelperTones = ' . | |
| 193 | + wp_json_encode( Suggestion_Defaults::get_tones() ) . ';' . | |
| 194 | + 'window.wpParselyContentHelperPersonas = ' . | |
| 195 | + wp_json_encode( Suggestion_Defaults::get_personas() ) . ';', | |
| 196 | + 'before' | |
| 197 | + ); | |
| 198 | + | |
| 199 | + // Inject the site-wide tone and persona. The stored settings carry them | |
| 200 | + // already, but not once a user's own value is the custom sentinel, | |
| 201 | + // which is exactly when the editor needs them. The desired length has | |
| 202 | + // no sentinel, so it is not needed here. | |
| 203 | + $excerpt_options = Suggestion_Defaults::get_feature_options( $this->parsely, 'excerpt_suggestions' ); | |
| 204 | + $title_options = Suggestion_Defaults::get_feature_options( $this->parsely, 'title_suggestions' ); | |
| 205 | + | |
| 206 | + wp_add_inline_script( | |
| 207 | + static::get_script_id(), | |
| 208 | + 'window.wpParselyContentHelperDefaults = ' . wp_json_encode( | |
| 209 | + array( | |
| 210 | + 'excerptSuggestions' => array( | |
| 211 | + 'persona' => Suggestion_Defaults::get_default_persona( $excerpt_options ), | |
| 212 | + 'tone' => Suggestion_Defaults::get_default_tone( $excerpt_options ), | |
| 213 | + ), | |
| 214 | + 'titleSuggestions' => array( | |
| 215 | + 'persona' => Suggestion_Defaults::get_default_persona( $title_options ), | |
| 216 | + 'tone' => Suggestion_Defaults::get_default_tone( $title_options ), | |
| 217 | + ), | |
| 218 | + ) | |
| 219 | + ) . ';', | |
| 220 | + 'before' | |
| 221 | + ); | |
| 222 | + | |
| 188 | 223 | $use_category_slugs_in_searches = apply_filters( 'wp_parsely_use_category_slugs_in_searches', false ); |
| 189 | 224 | wp_add_inline_script( |
| 190 | 225 | static::get_script_id(), |
| 191 | 226 | 'window.wpParselyUseCategorySlugsInSearches = ' . wp_json_encode( $use_category_slugs_in_searches ) . ';', |
| @@ -194,8 +229,32 @@ | ||
| 194 | 229 | |
| 195 | 230 | wp_enqueue_style( |
| 196 | 231 | static::get_style_id(), |
| 197 | 232 | $built_assets_url . 'editor-sidebar.css', |
| 233 | + array(), | |
| 234 | + $asset_php['version'] | |
| 235 | + ); | |
| 236 | + } | |
| 237 | + | |
| 238 | + /** | |
| 239 | + * Inserts the styles that need to be loaded inside the Editor canvas. | |
| 240 | + * | |
| 241 | + * Runs on `enqueue_block_assets`, which is the only hook that reaches the | |
| 242 | + * iframed Editor canvas. `enqueue_block_editor_assets` only loads assets in | |
| 243 | + * the admin document. | |
| 244 | + * | |
| 245 | + * @since 3.23.6 | |
| 246 | + */ | |
| 247 | + public function run_canvas_styles(): void { | |
| 248 | + if ( ! is_admin() || ! $this->can_enable_feature() ) { | |
| 249 | + return; | |
| 250 | + } | |
| 251 | + | |
| 252 | + $asset_php = Utils::get_asset_info( 'build/content-helper/block-overlay.asset.php' ); | |
| 253 | + | |
| 254 | + wp_enqueue_style( | |
| 255 | + static::get_style_id() . '-canvas', | |
| 256 | + plugin_dir_url( PARSELY_FILE ) . 'build/content-helper/block-overlay.css', | |
| 198 | 257 | array(), |
| 199 | 258 | $asset_php['version'] |
| 200 | 259 | ); |
| 201 | 260 | } |