| @@ -26,17 +26,31 @@ | ||
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Returns `true` when on the frontend, |
| 30 | - * or when on the post overview, post edit or new post admin page. | |
| 30 | + * or when on the post overview, post edit or new post admin page, | |
| 31 | + * or when on additional admin pages, allowed by filter. | |
| 31 | 32 | * |
| 32 | 33 | * @return bool `true` when on the frontend, or when on the post overview, |
| 33 | - * post edit or new post admin page. | |
| 34 | + * post edit, new post admin page or additional admin pages, allowed by filter. | |
| 34 | 35 | */ |
| 35 | 36 | public function is_met() { |
| 37 | + | |
| 36 | 38 | if ( ! \is_admin() ) { |
| 37 | 39 | return true; |
| 38 | 40 | } |
| 39 | 41 | |
| 40 | - return \in_array( $this->current_page->get_current_admin_page(), [ 'edit.php', 'post.php', 'post-new.php' ], true ); | |
| 42 | + $current_page = $this->current_page->get_current_admin_page(); | |
| 43 | + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reason: We are not processing form information. | |
| 44 | + if ( $current_page === 'admin-ajax.php' && isset( $_POST['action'] ) && $_POST['action'] === 'wp-link-ajax' ) { | |
| 45 | + return true; | |
| 46 | + } | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * Filter: Adds the possibility to use primary category at additional admin pages. | |
| 50 | + * | |
| 51 | + * @param array $admin_pages List of additional admin pages. | |
| 52 | + */ | |
| 53 | + $additional_pages = \apply_filters( 'wpseo_primary_category_admin_pages', [] ); | |
| 54 | + return \in_array( $current_page, \array_merge( [ 'edit.php', 'post.php', 'post-new.php' ], $additional_pages ), true ); | |
| 41 | 55 | } |
| 42 | 56 | } |