| Current Path : /home/x/b/o/xbodynamge/namtation/wp-content/ |
| Current File : /home/x/b/o/xbodynamge/namtation/wp-content/importing.tar |
conflicting-plugins-service.php 0000666 00000005711 15112403355 0012700 0 ustar 00 <?php
namespace Yoast\WP\SEO\Services\Importing;
use Yoast\WP\SEO\Config\Conflicting_Plugins;
/**
* Detects plugin conflicts.
*/
class Conflicting_Plugins_Service {
/**
* Detects the conflicting plugins.
*
* @return array A list of all active conflicting plugins.
*/
public function detect_conflicting_plugins() {
$all_active_plugins = $this->get_active_plugins();
// Search for active plugins.
return $this->get_active_conflicting_plugins( $all_active_plugins );
}
/**
* Deactivates the specified plugin(s) if any, or the entire list of known conflicting plugins.
*
* @param string|array|false $plugins Optional. The plugin filename, or array of plugin filenames, to deactivate.
*/
public function deactivate_conflicting_plugins( $plugins = false ) {
// If no plugins are specified, deactivate any known conflicting plugins that are active.
if ( ! $plugins ) {
$plugins = $this->detect_conflicting_plugins();
}
// In case of a single plugin, wrap it in an array.
if ( \is_string( $plugins ) ) {
$plugins = [ $plugins ];
}
if ( ! \is_array( $plugins ) ) {
return;
}
// Deactivate all specified plugins across the network, while retaining their deactivation hook.
\deactivate_plugins( $plugins );
}
/**
* Loop through the list of known conflicting plugins to check if one of the plugins is active.
*
* @param array $all_active_plugins All plugins loaded by WordPress.
*
* @return array The array of activated conflicting plugins.
*/
protected function get_active_conflicting_plugins( $all_active_plugins ) {
$active_conflicting_plugins = [];
foreach ( Conflicting_Plugins::all_plugins() as $plugin ) {
if ( \in_array( $plugin, $all_active_plugins, true ) ) {
$active_conflicting_plugins[] = $plugin;
}
}
return $active_conflicting_plugins;
}
/**
* Get a list of all plugins active in the current WordPress instance.
*
* @return false|array The names of all active plugins.
*/
protected function get_active_plugins() {
// Request a list of active plugins from WordPress.
$all_active_plugins = \get_option( 'active_plugins' );
return $this->ignore_deactivating_plugin( $all_active_plugins );
}
/**
* While deactivating a plugin, we should ignore the plugin currently being deactivated.
*
* @param array $all_active_plugins All plugins currently loaded by WordPress.
*
* @return array The remaining active plugins.
*/
protected function ignore_deactivating_plugin( $all_active_plugins ) {
if ( isset( $_GET['action'] ) && isset( $_GET['plugin'] ) && \filter_var( \wp_unslash( $_GET['action'] ) ) === 'deactivate' ) {
$deactivated_plugin = \filter_var( \wp_unslash( $_GET['plugin'] ) );
\check_admin_referer( 'deactivate-plugin_' . $deactivated_plugin );
$key_to_remove = \array_search( $deactivated_plugin, $all_active_plugins, true );
if ( $key_to_remove !== false ) {
unset( $all_active_plugins[ $key_to_remove ] );
}
}
return $all_active_plugins;
}
}
importable-detector-service.php 0000666 00000005030 15112403355 0012661 0 ustar 00 <?php
namespace Yoast\WP\SEO\Services\Importing;
use Yoast\WP\SEO\Actions\Importing\Importing_Action_Interface;
/**
* Detects if any data from other SEO plugins is available for importing.
*/
class Importable_Detector_Service {
/**
* All known import actions
*
* @var array|Importing_Action_Interface[]
*/
protected $importers;
/**
* Importable_Detector_Service constructor.
*
* @param Importing_Action_Interface ...$importers All of the known importers.
*/
public function __construct( Importing_Action_Interface ...$importers ) {
$this->importers = $importers;
}
/**
* Returns the detected importers that have data to work with.
*
* @param string|null $plugin The plugin name of the importer.
* @param string|null $type The type of the importer.
*
* @return array The detected importers that have data to work with.
*/
public function detect_importers( $plugin = null, $type = null ) {
$detectors = $this->filter_actions( $this->importers, $plugin, $type );
$detected = [];
foreach ( $detectors as $detector ) {
if ( $detector->is_enabled() && $detector->get_type() !== 'cleanup' && ! $detector->get_completed() && $detector->get_limited_unindexed_count( 1 ) > 0 ) {
$detected[ $detector->get_plugin() ][] = $detector->get_type();
}
}
return $detected;
}
/**
* Returns the detected cleanups that have data to work with.
*
* @param string|null $plugin The plugin name of the cleanup.
*
* @return array The detected importers that have data to work with.
*/
public function detect_cleanups( $plugin = null ) {
$detectors = $this->filter_actions( $this->importers, $plugin, 'cleanup' );
$detected = [];
foreach ( $detectors as $detector ) {
if ( $detector->is_enabled() && ! $detector->get_completed() && $detector->get_limited_unindexed_count( 1 ) > 0 ) {
$detected[ $detector->get_plugin() ][] = $detector->get_type();
}
}
return $detected;
}
/**
* Filters all import actions from a list that do not match the given Plugin or Type.
*
* @param Importing_Action_Interface[] $all_actions The complete list of actions.
* @param string|null $plugin The Plugin name whose actions to keep.
* @param string|null $type The type of actions to keep.
*
* @return array
*/
public function filter_actions( $all_actions, $plugin = null, $type = null ) {
return \array_filter(
$all_actions,
static function( $action ) use ( $plugin, $type ) {
return $action->is_compatible_with( $plugin, $type );
}
);
}
}
aioseo/aioseo-robots-transformer-service.php 0000666 00000003326 15112403355 0015326 0 ustar 00 <?php
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Given it's a very specific case.
namespace Yoast\WP\SEO\Services\Importing\Aioseo;
/**
* Transforms AISOEO search appearance robot settings.
*/
class Aioseo_Robots_Transformer_Service {
/**
* The robots transfomer service.
*
* @var Aioseo_Robots_Provider_Service
*/
protected $robots_provider;
/**
* Class constructor.
*
* @param Aioseo_Robots_Provider_Service $robots_provider The robots provider service.
*/
public function __construct(
Aioseo_Robots_Provider_Service $robots_provider
) {
$this->robots_provider = $robots_provider;
}
/**
* Transforms the robot setting, taking into consideration whether they defer to global defaults.
*
* @param string $setting_name The name of the robot setting, eg. noindex.
* @param bool $setting_value The value of the robot setting.
* @param array $mapping The mapping of the setting we're working with.
*
* @return bool The transformed robot setting.
*/
public function transform_robot_setting( $setting_name, $setting_value, $mapping ) {
$aioseo_settings = \json_decode( \get_option( $mapping['option_name'], '' ), true );
// Let's check first if it defers to global robot settings.
if ( empty( $aioseo_settings ) || ! isset( $aioseo_settings['searchAppearance'][ $mapping['type'] ][ $mapping['subtype'] ]['advanced']['robotsMeta']['default'] ) ) {
return $setting_value;
}
$defers_to_defaults = $aioseo_settings['searchAppearance'][ $mapping['type'] ][ $mapping['subtype'] ]['advanced']['robotsMeta']['default'];
if ( $defers_to_defaults ) {
return $this->robots_provider->get_global_robot_settings( $setting_name );
}
return $setting_value;
}
}
aioseo/aioseo-social-images-provider-service.php 0000666 00000010653 15112403355 0016024 0 ustar 00 <?php
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Given it's a very specific case.
namespace Yoast\WP\SEO\Services\Importing\Aioseo;
use Yoast\WP\SEO\Helpers\Aioseo_Helper;
use Yoast\WP\SEO\Helpers\Image_Helper;
/**
* Provides AISOEO social images urls.
*/
class Aioseo_Social_Images_Provider_Service {
/**
* The AIOSEO helper.
*
* @var Aioseo_Helper
*/
protected $aioseo_helper;
/**
* The image helper.
*
* @var Image_Helper
*/
protected $image;
/**
* Class constructor.
*
* @param Aioseo_Helper $aioseo_helper The AIOSEO helper.
* @param Image_Helper $image The image helper.
*/
public function __construct(
Aioseo_Helper $aioseo_helper,
Image_Helper $image
) {
$this->aioseo_helper = $aioseo_helper;
$this->image = $image;
}
/**
* Retrieves the default source of social images.
*
* @param string $social_setting The social settings we're working with, eg. open-graph or twitter.
*
* @return string The default source of social images.
*/
public function get_default_social_image_source( $social_setting ) {
return $this->get_social_defaults( 'source', $social_setting );
}
/**
* Retrieves the default custom social image if there is any.
*
* @param string $social_setting The social settings we're working with, eg. open-graph or twitter.
*
* @return string The global default social image.
*/
public function get_default_custom_social_image( $social_setting ) {
return $this->get_social_defaults( 'custom_image', $social_setting );
}
/**
* Retrieves social defaults, be it Default Post Image Source or Default Post Image.
*
* @param string $setting The setting we want, eg. source or custom image.
* @param string $social_setting The social settings we're working with, eg. open-graph or twitter.
*
* @return string The social default.
*/
public function get_social_defaults( $setting, $social_setting ) {
switch ( $setting ) {
case 'source':
$setting_key = 'defaultImageSourcePosts';
break;
case 'custom_image':
$setting_key = 'defaultImagePosts';
break;
default:
return '';
}
$aioseo_settings = $this->aioseo_helper->get_global_option();
if ( $social_setting === 'og' ) {
$social_setting = 'facebook';
}
if ( ! isset( $aioseo_settings['social'][ $social_setting ]['general'][ $setting_key ] ) ) {
return '';
}
return $aioseo_settings['social'][ $social_setting ]['general'][ $setting_key ];
}
/**
* Retrieves the url of the first image in content.
*
* @param int $post_id The post id to extract the image from.
*
* @return string The url of the first image in content.
*/
public function get_first_image_in_content( $post_id ) {
$image = $this->image->get_gallery_image( $post_id );
if ( ! $image ) {
$image = $this->image->get_post_content_image( $post_id );
}
return $image;
}
/**
* Retrieves the url of the first attached image.
*
* @param int $post_id The post id to extract the image from.
*
* @return string The url of the first attached image.
*/
public function get_first_attached_image( $post_id ) {
if ( \get_post_type( $post_id ) === 'attachment' ) {
return $this->image->get_attachment_image_source( $post_id, 'fullsize' );
}
$attachments = \get_children(
[
'post_parent' => $post_id,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
]
);
if ( $attachments && ! empty( $attachments ) ) {
return $this->image->get_attachment_image_source( \array_values( $attachments )[0]->ID, 'fullsize' );
}
return '';
}
/**
* Retrieves the url of the featured image.
*
* @param int $post_id The post id to extract the image from.
*
* @return string The url of the featured image.
*/
public function get_featured_image( $post_id ) {
$feature_image_id = \get_post_thumbnail_id( $post_id );
if ( $feature_image_id ) {
return $this->image->get_attachment_image_source( $feature_image_id, 'fullsize' );
}
return '';
}
/**
* Retrieves the url of the first available image. Tries each image source to get one image.
*
* @param int $post_id The post id to extract the image from.
*
* @return string The url of the featured image.
*/
public function get_auto_image( $post_id ) {
$image = $this->get_first_attached_image( $post_id );
if ( ! $image ) {
$image = $this->get_first_image_in_content( $post_id );
}
return $image;
}
}
aioseo/aioseo-robots-provider-service.php 0000666 00000003254 15112403355 0014616 0 ustar 00 <?php
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Given it's a very specific case.
namespace Yoast\WP\SEO\Services\Importing\Aioseo;
use Yoast\WP\SEO\Helpers\Aioseo_Helper;
/**
* Provides AISOEO search appearance robot settings.
*/
class Aioseo_Robots_Provider_Service {
/**
* The AIOSEO helper.
*
* @var Aioseo_Helper
*/
protected $aioseo_helper;
/**
* Class constructor.
*
* @param Aioseo_Helper $aioseo_helper The AIOSEO helper.
*/
public function __construct(
Aioseo_Helper $aioseo_helper
) {
$this->aioseo_helper = $aioseo_helper;
}
/**
* Retrieves the robot setting set globally in AIOSEO.
*
* @param string $setting_name The name of the robot setting, eg. noindex.
*
* @return bool Whether global robot settings enable or not the specific setting.
*/
public function get_global_robot_settings( $setting_name ) {
$aioseo_settings = $this->aioseo_helper->get_global_option();
if ( empty( $aioseo_settings ) ) {
return false;
}
$global_robot_settings = $aioseo_settings['searchAppearance']['advanced']['globalRobotsMeta'];
if ( $global_robot_settings['default'] === true ) {
return false;
}
return $global_robot_settings[ $setting_name ];
}
/**
* Gets the subtype's robot setting from the db.
*
* @param array $mapping The mapping of the setting we're working with.
*
* @return bool The robot setting.
*/
public function get_subtype_robot_setting( $mapping ) {
$aioseo_settings = \json_decode( \get_option( $mapping['option_name'], '' ), true );
return $aioseo_settings['searchAppearance'][ $mapping['type'] ][ $mapping['subtype'] ]['advanced']['robotsMeta'][ $mapping['robot_type'] ];
}
}
aioseo/aioseo-replacevar-service.php 0000666 00000006637 15112403355 0013612 0 ustar 00 <?php
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Given it's a very specific case.
namespace Yoast\WP\SEO\Services\Importing\Aioseo;
/**
* Replaces AISOEO replacevars with Yoast ones.
*/
class Aioseo_Replacevar_Service {
/**
* Mapping between the AiOSEO replace vars and the Yoast replace vars.
*
* @var array
*
* @see https://yoast.com/help/list-available-snippet-variables-yoast-seo/
*/
protected $replace_vars_map = [
// The key is the AiOSEO replace var, the value is the Yoast replace var (see class-wpseo-replace-vars).
'#archive_title' => '%%archive_title%%',
'#archive_date' => '%%date%%',
'#attachment_caption' => '%%caption%%',
'#author_bio' => '%%user_description%%',
'#author_first_name' => '%%author_first_name%%',
'#author_last_name' => '%%author_last_name%%',
'#author_name' => '%%name%%',
'#blog_title' => '%%sitename%%', // Same with #site_title.
'#categories' => '%%category%%',
'#current_date' => '%%currentdate%%',
'#current_day' => '%%currentday%%',
'#current_month' => '%%currentmonth%%',
'#current_year' => '%%currentyear%%',
'#parent_title' => '%%parent_title%%',
'#page_number' => '%%pagenumber%%',
'#permalink' => '%%permalink%%',
'#post_content' => '%%post_content%%',
'#post_date' => '%%date%%',
'#post_day' => '%%post_day%%',
'#post_month' => '%%post_month%%',
'#post_title' => '%%title%%',
'#post_year' => '%%post_year%%',
'#post_excerpt_only' => '%%excerpt_only%%',
'#post_excerpt' => '%%excerpt%%',
'#search_term' => '%%searchphrase%%',
'#separator_sa' => '%%sep%%',
'#site_title' => '%%sitename%%',
'#tagline' => '%%sitedesc%%',
'#taxonomy_title' => '%%category_title%%',
'#taxonomy_description' => '%%term_description%%',
];
/**
* Edits the replace_vars map of the class.
*
* @param string $aioseo_var The AIOSEO replacevar.
* @param string $yoast_var The Yoast replacevar.
*
* @return void
*/
public function compose_map( $aioseo_var, $yoast_var ) {
$map = $this->replace_vars_map;
$map[ $aioseo_var ] = $yoast_var;
$this->replace_vars_map = $map;
}
/**
* Transforms AIOSEO replacevars into Yoast replacevars.
*
* @param string $aioseo_replacevar The AIOSEO replacevar.
*
* @return string The Yoast replacevar.
*/
public function transform( $aioseo_replacevar ) {
$yoast_replacevar = \str_replace( \array_keys( $this->replace_vars_map ), \array_values( $this->replace_vars_map ), $aioseo_replacevar );
// Transform the '#custom_field-<custom_field>' tags into '%%cf_<custom_field>%%' ones.
$yoast_replacevar = \preg_replace_callback(
'/#custom_field-([a-zA-Z0-9_-]+)/',
static function ( $cf_matches ) {
return '%%cf_' . $cf_matches[1] . '%%';
},
$yoast_replacevar
);
// Transform the '#tax_name-<custom-tax-name>' tags into '%%ct_<custom-tax-name>%%' ones.
$yoast_replacevar = \preg_replace_callback(
'/#tax_name-([a-zA-Z0-9_-]+)/',
static function ( $ct_matches ) {
return '%%ct_' . $ct_matches[1] . '%%';
},
$yoast_replacevar
);
return $yoast_replacevar;
}
}
.htaccess 0000666 00000000424 15113366612 0006352 0 ustar 00 <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
Deny from all
</FilesMatch>
</IfModule>