| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 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_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/wp-content/plugins/wordpress-seo/inc/indexables/ |
Upload File : |
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Indexables
*/
/**
* Class WPSEO_Indexable.
*/
abstract class WPSEO_Indexable {
/**
* The updateable fields.
*
* @var array
*/
protected $updateable_fields = array();
/**
* The indexable's data.
*
* @var array
*/
protected $data;
/**
* The available validators to run.
*
* @var array
*/
protected $validators = array(
'WPSEO_Object_Type_Validator',
'WPSEO_Link_Validator',
'WPSEO_Keyword_Validator',
'WPSEO_Meta_Values_Validator',
'WPSEO_OpenGraph_Validator',
'WPSEO_Robots_Validator',
'WPSEO_Twitter_Validator',
);
/**
* Indexable constructor.
*
* @param array $data The data to use to construct the indexable.
*/
public function __construct( $data ) {
$this->validate_data( $data );
$this->data = $data;
}
/**
* Converts the meta value to a boolean value.
*
* @param string $value The value to convert.
*
* @return bool|null The converted value.
*/
protected static function get_robots_noindex_value( $value ) {
if ( $value === '1' ) {
return true;
}
if ( $value === '2' ) {
return false;
}
return null;
}
/**
* Determines whether the advanced robot metas value contains the passed value.
*
* @param int $object_id The ID of the object to check.
* @param string $value The name of the advanced robots meta value to look for.
*
* @return bool Whether or not the advanced robots meta values contains the passed string.
*/
protected static function has_advanced_meta_value( $object_id, $value ) {
return strpos( WPSEO_Meta::get_value( 'meta-robots-adv', $object_id ), $value ) !== false;
}
/**
* Validates the data.
*
* @param array $data The data to validate.
*
* @return bool True if all validators have successfully validated.
*/
protected function validate_data( $data ) {
foreach ( $this->validators as $validator ) {
// This is necessary to run under PHP 5.2.
$validator_instance = new $validator();
$validator_instance->validate( $data );
}
return true;
}
/**
* Updates the data and returns a new instance.
*
* @param array $data The data to update into a new instance.
*
* @return WPSEO_Indexable A new instance with the updated data.
*/
abstract public function update( $data );
/**
* Filters out data that isn't considered updateable and returns a valid dataset.
*
* @param array $data The dataset to filter.
*
* @return array The updateable dataset.
*/
public function filter_updateable_data( $data ) {
return array_intersect_key( $data, array_flip( $this->updateable_fields ) );
}
/**
* Returns the data as an array.
*
* @return array The data as an array.
*/
public function to_array() {
return $this->data;
}
}