|
Server : LiteSpeed System : Linux srv107862549.host 5.15.0-124-generic #134-Ubuntu SMP Fri Sep 27 20:20:17 UTC 2024 x86_64 User : malam2778 ( 1069) PHP Version : 8.0.30 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /proc/self/cwd/wp-content/plugins/wordpress-seo/src/conditionals/ |
Upload File : |
<?php
namespace Yoast\WP\SEO\Conditionals;
use Yoast\WP\SEO\Helpers\Current_Page_Helper;
/**
* Conditional that is only met when in frontend or page is a post overview or post add/edit form.
*/
class Primary_Category_Conditional implements Conditional {
/**
* The current page helper.
*
* @var Current_Page_Helper
*/
private $current_page;
/**
* Primary_Category_Conditional constructor.
*
* @param Current_Page_Helper $current_page The current page helper.
*/
public function __construct( Current_Page_Helper $current_page ) {
$this->current_page = $current_page;
}
/**
* Returns `true` when on the frontend,
* or when on the post overview, post edit or new post admin page,
* or when on additional admin pages, allowed by filter.
*
* @return bool `true` when on the frontend, or when on the post overview,
* post edit, new post admin page or additional admin pages, allowed by filter.
*/
public function is_met() {
if ( ! \is_admin() ) {
return true;
}
$current_page = $this->current_page->get_current_admin_page();
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reason: We are not processing form information.
if ( $current_page === 'admin-ajax.php' && isset( $_POST['action'] ) && $_POST['action'] === 'wp-link-ajax' ) {
return true;
}
/**
* Filter: Adds the possibility to use primary category at additional admin pages.
*
* @param array $admin_pages List of additional admin pages.
*/
$additional_pages = \apply_filters( 'wpseo_primary_category_admin_pages', [] );
return \in_array( $current_page, \array_merge( [ 'edit.php', 'post.php', 'post-new.php' ], $additional_pages ), true );
}
}