File Editor
Directories:
.. (Back)
admin
third-party
traits
Files:
addon-installation-conditional.php
admin-conditional.php
attachment-redirections-enabled-conditional.php
check-required-version-conditional.php
conditional-interface.php
deactivating-yoast-seo-conditional.php
development-conditional.php
feature-flag-conditional.php
front-end-conditional.php
get-request-conditional.php
headless-rest-endpoints-enabled-conditional.php
import-tool-selected-conditional.php
jetpack-conditional.php
migrations-conditional.php
new-settings-ui-conditional.php
news-conditional.php
no-conditionals-trait.php
no-tool-selected-conditional.php
non-multisite-conditional.php
not-admin-ajax-conditional.php
open-graph-conditional.php
premium-active-conditional.php
premium-inactive-conditional.php
primary-category-conditional.php
robots-txt-conditional.php
semrush-enabled-conditional.php
settings-conditional.php
should-index-links-conditional.php
text-formality-conditional.php
updated-importer-framework-conditional.php
user-can-edit-users-conditional.php
user-can-manage-wpseo-options-conditional.php
user-can-publish-posts-and-pages-conditional.php
user-edit-conditional.php
user-profile-conditional.php
web-stories-conditional.php
wincher-automatically-track-conditional.php
wincher-conditional.php
wincher-enabled-conditional.php
wincher-token-conditional.php
woocommerce-conditional.php
wp-cron-enabled-conditional.php
wp-robots-conditional.php
xmlrpc-conditional.php
yoast-admin-and-dashboard-conditional.php
yoast-tools-page-conditional.php
Create New File
Create
Edit File: robots-txt-conditional.php
<?php namespace Yoast\WP\SEO\Conditionals; /** * Conditional that is only met when on the front end or Yoast file editor page. */ class Robots_Txt_Conditional implements Conditional { /** * Holds the Front_End_Conditional instance. * * @var Front_End_Conditional */ protected $front_end_conditional; /** * Constructs the class. * * @param Front_End_Conditional $front_end_conditional The front end conditional. */ public function __construct( Front_End_Conditional $front_end_conditional ) { $this->front_end_conditional = $front_end_conditional; } /** * Returns whether or not this conditional is met. * * @return bool Whether or not the conditional is met. */ public function is_met() { return $this->front_end_conditional->is_met() || $this->is_file_editor_page(); } /** * Returns whether the current page is the file editor page. * * This checks for two locations: * - Multisite network admin file editor page * - Single site file editor page (under tools) * * @return bool */ protected function is_file_editor_page() { global $pagenow; if ( $pagenow !== 'admin.php' ) { return false; } // phpcs:ignore WordPress.Security.NonceVerification -- This is not a form. if ( isset( $_GET['page'] ) && $_GET['page'] === 'wpseo_files' && \is_multisite() && \is_network_admin() ) { return true; } // phpcs:ignore WordPress.Security.NonceVerification -- This is not a form. if ( ! ( isset( $_GET['page'] ) && $_GET['page'] === 'wpseo_tools' ) ) { return false; } // phpcs:ignore WordPress.Security.NonceVerification -- This is not a form. if ( isset( $_GET['tool'] ) && $_GET['tool'] === 'file-editor' ) { return true; } return false; } }
Save Changes
Rename File
Rename