PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
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 | admin/watchers/class-slug-change-watcher.php +32 -26 18.2 → trunk View file →
@@ -49,9 +49,9 @@
49 49 $asset_manager->enqueue_script( 'quick-edit-handler' );
50 50 }
51 51
52 52 /**
53 - * Shows an message when a post is about to get trashed.
53 + * Shows a message when a post is about to get trashed.
54 54 *
55 55 * @param int $post_id The current post ID.
56 56 *
57 57 * @return void
@@ -60,17 +60,20 @@
60 60 if ( ! $this->is_post_viewable( $post_id ) ) {
61 61 return;
62 62 }
63 63
64 + $post_label = $this->get_post_type_label( get_post_type( $post_id ) );
65 +
64 66 /* translators: %1$s expands to the translated name of the post type. */
65 - $first_sentence = sprintf( __( 'You just trashed a %1$s.', 'wordpress-seo' ), $this->get_post_type_label( get_post_type( $post_id ) ) );
66 - $message = $this->get_message( $first_sentence );
67 + $first_sentence = sprintf( __( 'You just trashed a %1$s.', 'wordpress-seo' ), $post_label );
68 + $second_sentence = __( 'Search engines and other websites can still send traffic to your trashed content.', 'wordpress-seo' );
69 + $message = $this->get_message( $first_sentence, $second_sentence );
67 70
68 71 $this->add_notification( $message );
69 72 }
70 73
71 74 /**
72 - * Shows an message when a post is about to get trashed.
75 + * Shows a message when a post is about to get trashed.
73 76 *
74 77 * @param int $post_id The current post ID.
75 78 *
76 79 * @return void
@@ -79,11 +82,14 @@
79 82 if ( ! $this->is_post_viewable( $post_id ) ) {
80 83 return;
81 84 }
82 85
86 + $post_label = $this->get_post_type_label( get_post_type( $post_id ) );
87 +
83 88 /* translators: %1$s expands to the translated name of the post type. */
84 - $first_sentence = sprintf( __( 'You just deleted a %1$s.', 'wordpress-seo' ), $this->get_post_type_label( get_post_type( $post_id ) ) );
85 - $message = $this->get_message( $first_sentence );
89 + $first_sentence = sprintf( __( 'You just deleted a %1$s.', 'wordpress-seo' ), $post_label );
90 + $second_sentence = __( 'Search engines and other websites can still send traffic to your deleted content.', 'wordpress-seo' );
91 + $message = $this->get_message( $first_sentence, $second_sentence );
86 92
87 93 $this->add_notification( $message );
88 94 }
89 95
@@ -89,24 +95,24 @@
89 95
90 96 /**
91 97 * Shows a message when a term is about to get deleted.
92 98 *
93 - * @param int $term_id The term ID that will be deleted.
99 + * @param int $term_taxonomy_id The term taxonomy ID that will be deleted.
94 100 *
95 101 * @return void
96 102 */
97 - public function detect_term_delete( $term_id ) {
98 - if ( ! $this->is_term_viewable( $term_id ) ) {
103 + public function detect_term_delete( $term_taxonomy_id ) {
104 + if ( ! $this->is_term_viewable( $term_taxonomy_id ) ) {
99 105 return;
100 106 }
101 107
102 - $first_sentence = sprintf(
103 - /* translators: 1: term label */
104 - __( 'You just deleted a %1$s.', 'wordpress-seo' ),
105 - $this->get_taxonomy_label_for_term( $term_id )
106 - );
108 + $term = get_term_by( 'term_taxonomy_id', (int) $term_taxonomy_id );
109 + $term_label = $this->get_taxonomy_label_for_term( $term->term_id );
107 110
108 - $message = $this->get_message( $first_sentence );
111 + /* translators: %1$s expands to the translated name of the term. */
112 + $first_sentence = sprintf( __( 'You just deleted a %1$s.', 'wordpress-seo' ), $term_label );
113 + $second_sentence = __( 'Search engines and other websites can still send traffic to your deleted content.', 'wordpress-seo' );
114 + $message = $this->get_message( $first_sentence, $second_sentence );
109 115
110 116 $this->add_notification( $message );
111 117 }
112 118
@@ -133,14 +139,14 @@
133 139
134 140 /**
135 141 * Checks if the term is viewable.
136 142 *
137 - * @param string $term_id The term ID to check.
143 + * @param int $term_taxonomy_id The term taxonomy ID to check.
138 144 *
139 145 * @return bool Whether the term is viewable or not.
140 146 */
141 - protected function is_term_viewable( $term_id ) {
142 - $term = get_term( $term_id );
147 + protected function is_term_viewable( $term_taxonomy_id ) {
148 + $term = get_term_by( 'term_taxonomy_id', (int) $term_taxonomy_id );
143 149
144 150 if ( ! $term || is_wp_error( $term ) ) {
145 151 return false;
146 152 }
@@ -177,11 +183,9 @@
177 183 protected function get_post_type_label( $post_type ) {
178 184 $post_type_object = get_post_type_object( $post_type );
179 185
180 186 // If the post type of this post wasn't registered default back to post.
181 - if ( $post_type_object === null ) {
182 - $post_type_object = get_post_type_object( 'post' );
183 - }
187 + $post_type_object ??= get_post_type_object( 'post' );
184 188
185 189 return $post_type_object->labels->singular_name;
186 190 }
187 191
@@ -204,24 +208,26 @@
204 208
205 209 /**
206 210 * Returns the message around changed URLs.
207 211 *
208 - * @param string $first_sentence The first sentence of the notification.
212 + * @param string $first_sentence The first sentence of the notification.
213 + * @param string $second_sentence The second sentence of the notification.
209 214 *
210 215 * @return string The full notification.
211 216 */
212 - protected function get_message( $first_sentence ) {
217 + protected function get_message( $first_sentence, $second_sentence ) {
213 218 return '<h2>' . __( 'Make sure you don\'t miss out on traffic!', 'wordpress-seo' ) . '</h2>'
214 219 . '<p>'
215 220 . $first_sentence
216 - . ' ' . __( 'Search engines and other websites can still send traffic to your deleted post.', 'wordpress-seo' )
221 + . ' ' . $second_sentence
217 222 . ' ' . __( 'You should create a redirect to ensure your visitors do not get a 404 error when they click on the no longer working URL.', 'wordpress-seo' )
218 223 /* translators: %s expands to Yoast SEO Premium */
219 224 . ' ' . sprintf( __( 'With %s, you can easily create such redirects.', 'wordpress-seo' ), 'Yoast SEO Premium' )
220 225 . '</p>'
221 - . '<p><a class="yoast-button-upsell" href="' . WPSEO_Shortlinker::get( 'https://yoa.st/1d0' ) . '" target="_blank">'
226 + . '<p><a class="yoast-button-upsell" data-action="load-nfd-ctb" data-ctb-id="f6a84663-465f-4cb5-8ba5-f7a6d72224b2" href="' . WPSEO_Shortlinker::get( 'https://yoa.st/1d0' ) . '" target="_blank">'
222 227 /* translators: %s expands to Yoast SEO Premium */
223 228 . sprintf( __( 'Get %s', 'wordpress-seo' ), 'Yoast SEO Premium' )
229 + /* translators: Hidden accessibility text. */
224 230 . '<span class="screen-reader-text">' . __( '(Opens in a new browser tab)', 'wordpress-seo' ) . '</span>'
225 231 . '<span aria-hidden="true" class="yoast-button-upsell__caret"></span>'
226 232 . '</a></p>';
227 233 }
@@ -238,9 +244,9 @@
238 244 $message,
239 245 [
240 246 'type' => 'notice-warning is-dismissible',
241 247 'yoast_branding' => true,
242 - ]
248 + ],
243 249 );
244 250
245 251 $notification_center = Yoast_Notification_Center::get();
246 252 $notification_center->add_notification( $notification );