PluginProbe
Parse.ly / 3.24.2
Parse.ly v3.24.2
3.24.3 3.24.2 3.24.1 3.24.0 3.23.7 3.23.6 3.23.5 3.23.4 3.23.3 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.17.0 3.18.0 3.18.1 3.19.0 3.19.1 3.19.2 3.19.3 3.2.0 3.2.1 3.20.0 3.20.1 All 107 releases
← All changes | src/content-helper/editor-sidebar/class-editor-sidebar.php +75 -2 3.17.0 → 3.24.2 View file →
@@ -105,13 +105,13 @@
105 105
106 106 /**
107 107 * The post object.
108 108 *
109 - * @var WP_Post $post
109 + * @var WP_Post|null $post
110 110 */
111 111 $post = get_post( $post_id );
112 112
113 - if ( ! Dashboard_Link::can_show_link( $post, $this->parsely ) ) {
113 + if ( null === $post || ! Dashboard_Link::can_show_link( $post, $this->parsely ) ) {
114 114 return null;
115 115 }
116 116
117 117 if ( ! $add_utm_params ) {
@@ -169,8 +169,15 @@
169 169 'before'
170 170 );
171 171 }
172 172
173 + // Inject the admin URL for generating admin page links.
174 + wp_add_inline_script(
175 + static::get_script_id(),
176 + 'window.wpParselyAdminUrl = ' . wp_json_encode( admin_url() ) . ';',
177 + 'before'
178 + );
179 +
173 180 // Inject the trackable statuses.
174 181 $trackable_statuses = Parsely::get_trackable_statuses();
175 182 wp_add_inline_script(
176 183 static::get_script_id(),
@@ -177,11 +184,77 @@
177 184 'window.wpParselyTrackableStatuses = ' . wp_json_encode( $trackable_statuses ) . ';',
178 185 'before'
179 186 );
180 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 +
223 + $use_category_slugs_in_searches = apply_filters( 'wp_parsely_use_category_slugs_in_searches', false );
224 + wp_add_inline_script(
225 + static::get_script_id(),
226 + 'window.wpParselyUseCategorySlugsInSearches = ' . wp_json_encode( $use_category_slugs_in_searches ) . ';',
227 + 'before'
228 + );
229 +
181 230 wp_enqueue_style(
182 231 static::get_style_id(),
183 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',
184 257 array(),
185 258 $asset_php['version']
186 259 );
187 260 }