Yoast\WP\SEO\Actions\Importing\Aioseo

Aioseo_Validate_Data_Action::validate_post_robot_settingspublicYoast 1.0

Validates the post AIOSEO robots settings from the options table.

Метод класса: Aioseo_Validate_Data_Action{}

Хуков нет.

Возвращает

true|false. Whether the post AIOSEO robots settings from the options table exist and have the structure we expect.

Использование

$Aioseo_Validate_Data_Action = new Aioseo_Validate_Data_Action();
$Aioseo_Validate_Data_Action->validate_post_robot_settings();

Код Aioseo_Validate_Data_Action::validate_post_robot_settings() Yoast 25.3

public function validate_post_robot_settings() {
	$post_robot_mapping = $this->post_importing_action->enhance_mapping();
	// We're gonna validate against posttype robot settings only for posts, assuming the robot settings stay the same for other post types.
	$post_robot_mapping['subtype'] = 'post';

	// Let's get both the aioseo_options and the aioseo_options_dynamic options.
	$aioseo_global_settings = $this->aioseo_helper->get_global_option();
	$aioseo_posts_settings  = \json_decode( \get_option( $post_robot_mapping['option_name'], '' ), true );

	$needed_robots_data = $this->post_importing_action->get_needed_robot_data();
	\array_push( $needed_robots_data, 'default', 'noindex' );

	foreach ( $needed_robots_data as $robot_setting ) {
		// Validate against global settings.
		if ( ! isset( $aioseo_global_settings['searchAppearance']['advanced']['globalRobotsMeta'][ $robot_setting ] ) ) {
			return false;
		}

		// Validate against posttype settings.
		if ( ! isset( $aioseo_posts_settings['searchAppearance'][ $post_robot_mapping['type'] ][ $post_robot_mapping['subtype'] ]['advanced']['robotsMeta'][ $robot_setting ] ) ) {
			return false;
		}
	}

	return true;
}