PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.5
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
← All changes | src/helpers/indexable-helper.php +66 -0 18.428.5 View file →
@@ -107,8 +107,10 @@
107 107 *
108 108 * @required
109 109 *
110 110 * @param Indexable_Repository $repository The indexable repository.
111 + *
112 + * @return void
111 113 */
112 114 public function set_indexable_repository( Indexable_Repository $repository ) {
113 115 $this->repository = $repository;
114 116 }
@@ -160,8 +162,10 @@
160 162 *
161 163 * @param string|null $type The type of the indexable.
162 164 * @param string|null $subtype The subtype. Can be null.
163 165 * @param string $reason The reason that the permalink has been changed.
166 + *
167 + * @return void
164 168 */
165 169 public function reset_permalink_indexables( $type = null, $subtype = null, $reason = Indexing_Reasons::REASON_PERMALINK_SETTINGS ) {
166 170 $result = $this->repository->reset_permalink( $type, $subtype );
167 171
@@ -174,8 +178,30 @@
174 178 }
175 179 }
176 180
177 181 /**
182 + * Determines whether indexing the specific indexable is appropriate at this time.
183 + *
184 + * @param Indexable $indexable The indexable.
185 + *
186 + * @return bool Whether indexing the specific indexable is appropriate at this time.
187 + */
188 + public function should_index_indexable( $indexable ) {
189 + $intend_to_save = $this->should_index_indexables();
190 +
191 + /**
192 + * Filter: 'wpseo_should_save_indexable' - Allow developers to enable / disable
193 + * saving the indexable when the indexable is updated. Warning: overriding
194 + * the intended action may cause problems when moving from a staging to a
195 + * production environment because indexable permalinks may get set incorrectly.
196 + *
197 + * @param bool $intend_to_save True if YoastSEO intends to save the indexable.
198 + * @param Indexable $indexable The indexable to be saved.
199 + */
200 + return \apply_filters( 'wpseo_should_save_indexable', $intend_to_save, $indexable );
201 + }
202 +
203 + /**
178 204 * Determines whether indexing indexables is appropriate at this time.
179 205 *
180 206 * @return bool Whether the indexables should be indexed.
181 207 */
@@ -256,6 +282,46 @@
256 282 return true;
257 283 }
258 284
259 285 return false;
286 + }
287 +
288 + /**
289 + * Saves and returns an indexable (on production environments only).
290 + *
291 + * Moved from Yoast\WP\SEO\Builders\Indexable_Builder.
292 + *
293 + * @param Indexable $indexable The indexable.
294 + * @param Indexable|null $indexable_before The indexable before possible changes.
295 + *
296 + * @return bool True if default value.
297 + */
298 + public function save_indexable( $indexable, $indexable_before = null ) {
299 + if ( ! $this->should_index_indexable( $indexable ) ) {
300 + return $indexable;
301 + }
302 +
303 + // Save the indexable before running the WordPress hook.
304 + $indexable->save();
305 +
306 + if ( $indexable_before ) {
307 + /**
308 + * Action: 'wpseo_save_indexable' - Allow developers to perform an action
309 + * when the indexable is updated.
310 + *
311 + * @param Indexable $indexable The saved indexable.
312 + * @param Indexable $indexable_before The indexable before saving.
313 + */
314 + \do_action( 'wpseo_save_indexable', $indexable, $indexable_before );
315 + }
316 +
317 + /**
318 + * Action: 'wpseo_save_indexable' - Allow developers to perform an action
319 + * right after the indexable is created or updated.
320 + *
321 + * @param Indexable $indexable The saved indexable.
322 + */
323 + \do_action( 'wpseo_saved_indexable', $indexable );
324 +
325 + return $indexable;
260 326 }
261 327 }