| Current Path : /home/x/b/o/xbodynamge/namtation/wp-content/ |
| Current File : /home/x/b/o/xbodynamge/namtation/wp-content/Helpers.php.tar |
home/xbodynamge/dev/wp-content/plugins/all-in-one-seo-pack/app/Lite/Utils/Helpers.php 0000644 00000001314 15113513324 0024506 0 ustar 00 <?php
namespace AIOSEO\Plugin\Lite\Utils;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Utils as CommonUtils;
/**
* Contains helper functions.
*
* @since 4.2.4
*/
class Helpers extends CommonUtils\Helpers {
/**
* Get the headers for internal API requests.
*
* @since 4.2.4
*
* @return array An array of headers.
*/
public function getApiHeaders() {
return [];
}
/**
* Get the User Agent for internal API requests.
*
* @since 4.2.4
*
* @return string The User Agent.
*/
public function getApiUserAgent() {
return 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ) . '; AIOSEO/Lite/' . AIOSEO_VERSION;
}
} home/xbodynamge/namtation/wp-content/plugins/all-in-one-seo-pack/app/Common/Migration/Helpers.php 0000644 00000020076 15113615647 0027127 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Migration;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Models;
/**
* Contains a number of helper functions for the V3 migration.
*
* @since 4.0.0
*/
class Helpers {
/**
* Maps a list of old settings from V3 to their counterparts in V4.
*
* @since 4.0.0
*
* @param array $mappings The old settings, mapped to their new settings.
* @param array $group The old settings group.
* @param bool $convertMacros Whether to convert the old V3 macros to V4 smart tags.
* @return void
*/
public function mapOldToNew( $mappings, $group, $convertMacros = false ) {
if (
! is_array( $mappings ) ||
! is_array( $group ) ||
! count( $mappings ) ||
! count( $group )
) {
return;
}
$mainOptions = aioseo()->options->noConflict();
$dynamicOptions = aioseo()->dynamicOptions->noConflict();
foreach ( $mappings as $name => $values ) {
if ( ! isset( $group[ $name ] ) ) {
continue;
}
$error = false;
$options = ! empty( $values['dynamic'] ) ? $dynamicOptions : $mainOptions;
$lastOption = '';
for ( $i = 0; $i < count( $values['newOption'] ); $i++ ) {
$lastOption = $values['newOption'][ $i ];
if ( ! $options->has( $lastOption, false ) ) {
$error = true;
break;
}
if ( count( $values['newOption'] ) - 1 !== $i ) {
$options = $options->$lastOption;
}
}
if ( $error ) {
continue;
}
switch ( $values['type'] ) {
case 'boolean':
if ( ! empty( $group[ $name ] ) ) {
$options->$lastOption = true;
break;
}
$options->$lastOption = false;
break;
case 'integer':
case 'float':
$value = aioseo()->helpers->sanitizeOption( $group[ $name ] );
if ( $value ) {
$options->$lastOption = $value;
}
break;
default:
$value = $group[ $name ];
if ( $convertMacros ) {
$value = $this->macrosToSmartTags( $value );
}
$options->$lastOption = aioseo()->helpers->sanitizeOption( $value );
break;
}
}
}
/**
* Replaces the macros from V3 with our new Smart Tags from V4.
*
* @since 4.0.0
*
* @param string $string The string.
* @return string $string The converted string.
*/
public function macrosToSmartTags( $string ) {
$macros = [
'%site_title%' => '#site_title',
'%blog_title%' => '#site_title',
'%site_description%' => '#tagline',
'%blog_description%' => '#tagline',
'%wp_title%' => '#post_title',
'%post_title%' => '#post_title',
'%page_title%' => '#post_title',
'%post_date%' => '#post_date',
'%post_month%' => '#post_month',
'%post_year%' => '#post_year',
'%date%' => '#archive_date',
'%day%' => '#post_day',
'%month%' => '#post_month',
'%monthnum%' => '#post_month',
'%year%' => '#post_year',
'%current_date%' => '#current_date',
'%current_day%' => '#current_day',
'%current_month%' => '#current_month',
'%current_month_i18n%' => '#current_month',
'%current_year%' => '#current_year',
'%category_title%' => '#taxonomy_title',
'%tag%' => '#taxonomy_title',
'%tag_title%' => '#taxonomy_title',
'%archive_title%' => '#archive_title',
'%taxonomy_title%' => '#taxonomy_title',
'%taxonomy_description%' => '#taxonomy_description',
'%tag_description%' => '#taxonomy_description',
'%category_description%' => '#taxonomy_description',
'%author%' => '#author_name',
'%search%' => '#search_term',
'%page%' => '#page_number',
'%site_link%' => '#site_link',
'%site_link_raw%' => '#site_link_alt',
'%post_link%' => '#post_link',
'%post_link_raw%' => '#post_link_alt',
'%author_name%' => '#author_name',
'%author_link%' => '#author_link',
'%image_title%' => '#image_title',
'%image_seo_title%' => '#image_seo_title',
'%image_seo_description%' => '#image_seo_description',
'%post_seo_title%' => '#post_seo_title',
'%post_seo_description%' => '#post_seo_description',
'%alt_tag%' => '#alt_tag',
'%description%' => '#description',
// These need to run last so we don't replace other known tags.
'%.*_title%' => '#post_title',
'%[^%]*_author_login%' => '#author_first_name #author_last_name',
'%[^%]*_author_nicename%' => '#author_first_name #author_last_name',
'%[^%]*_author_firstname%' => '#author_first_name',
'%[^%]*_author_lastname%' => '#author_last_name',
];
if ( preg_match_all( '#%cf_([^%]*)%#', (string) $string, $matches ) && ! empty( $matches[1] ) ) {
foreach ( $matches[1] as $name ) {
if ( preg_match( '#\s#', (string) $name ) ) {
$notification = Models\Notification::getNotificationByName( 'v3-migration-custom-field' );
if ( ! $notification->notification_name ) {
Models\Notification::addNotification( [
'slug' => uniqid(),
'notification_name' => 'v3-migration-custom-field',
'title' => __( 'Custom field names with spaces detected', 'all-in-one-seo-pack' ),
'content' => sprintf(
// Translators: 1 - The plugin short name ("AIOSEO"), 2 - Same as previous.
__( '%1$s has detected that you have one or more custom fields with spaces in their name.
In order for %2$s to correctly parse these custom fields, their names cannot contain any spaces.', 'all-in-one-seo-pack' ),
AIOSEO_PLUGIN_SHORT_NAME,
AIOSEO_PLUGIN_SHORT_NAME
),
'type' => 'warning',
'level' => [ 'all' ],
'button1_label' => __( 'Remind Me Later', 'all-in-one-seo-pack' ),
'button1_action' => 'http://action#notification/v3-migration-custom-field-reminder',
'start' => gmdate( 'Y-m-d H:i:s' )
] );
}
} else {
$string = aioseo()->helpers->pregReplace( "#%cf_$name%#", "#custom_field-$name", $string );
}
}
}
if ( preg_match_all( '#%tax_([^%]*)%#', (string) $string, $matches ) && ! empty( $matches[1] ) ) {
foreach ( $matches[1] as $name ) {
if ( ! preg_match( '#\s#', (string) $name ) ) {
$string = aioseo()->helpers->pregReplace( "#%tax_$name%#", "#tax_name-$name", $string );
}
}
}
foreach ( $macros as $macro => $tag ) {
$string = aioseo()->helpers->pregReplace( "#$macro(?![a-zA-Z0-9_])#im", $tag, $string );
}
$string = preg_replace( '/%([a-f0-9]{2}[^%]*)%/i', '#$1#', (string) $string );
return $string;
}
/**
* Converts the old comma-separated keywords format to the new JSON format.
*
* @since 4.0.0
*
* @param string $keywords A comma-separated list of keywords.
* @return string $keywords The keywords formatted in JSON.
*/
public function oldKeywordsToNewKeywords( $keywords ) {
if ( ! $keywords ) {
return '';
}
$oldKeywords = array_filter( explode( ',', $keywords ) );
if ( ! is_array( $oldKeywords ) ) {
return '';
}
$keywords = [];
foreach ( $oldKeywords as $oldKeyword ) {
$oldKeyword = aioseo()->helpers->sanitizeOption( $oldKeyword );
$keyword = new \stdClass();
$keyword->label = $oldKeyword;
$keyword->value = $oldKeyword;
$keywords[] = $keyword;
}
return $keywords;
}
/**
* Resets the plugin so that the migration can run again.
*
* @since 4.0.0
*
* @return void
*/
public static function redoMigration() {
aioseo()->core->db->delete( 'options' )
->whereRaw( "`option_name` LIKE 'aioseo_options_internal%'" )
->run();
aioseo()->core->cache->delete( 'v3_migration_in_progress_posts' );
aioseo()->core->cache->delete( 'v3_migration_in_progress_terms' );
aioseo()->actionScheduler->unschedule( 'aioseo_migrate_post_meta' );
aioseo()->actionScheduler->unschedule( 'aioseo_migrate_term_meta' );
}
} home/xbodynamge/dev/wp-content/plugins/all-in-one-seo-pack/app/Common/ImportExport/Helpers.php 0000644 00000004430 15114010645 0026416 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\ImportExport;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Contains helper methods for the import from other plugins.
*
* @since 4.0.0
*/
abstract class Helpers {
/**
* Converts macros to smart tags.
*
* @since 4.1.3
*
* @param string $value The string with macros.
* @return string The string with macros converted.
*/
abstract public function macrosToSmartTags( $value );
/**
* Maps a list of old settings from V3 to their counterparts in V4.
*
* @since 4.0.0
*
* @param array $mappings The old settings, mapped to their new settings.
* @param array $group The old settings group.
* @param bool $convertMacros Whether to convert the old V3 macros to V4 smart tags.
* @return void
*/
public function mapOldToNew( $mappings, $group, $convertMacros = false ) {
if (
! is_array( $mappings ) ||
! is_array( $group ) ||
! count( $mappings ) ||
! count( $group )
) {
return;
}
$mainOptions = aioseo()->options->noConflict();
$dynamicOptions = aioseo()->dynamicOptions->noConflict();
foreach ( $mappings as $name => $values ) {
if ( ! isset( $group[ $name ] ) ) {
continue;
}
$error = false;
$options = ! empty( $values['dynamic'] ) ? $dynamicOptions : $mainOptions;
$lastOption = '';
for ( $i = 0; $i < count( $values['newOption'] ); $i++ ) {
$lastOption = $values['newOption'][ $i ];
if ( ! $options->has( $lastOption, false ) ) {
$error = true;
break;
}
if ( count( $values['newOption'] ) - 1 !== $i ) {
$options = $options->$lastOption;
}
}
if ( $error ) {
continue;
}
switch ( $values['type'] ) {
case 'boolean':
if ( ! empty( $group[ $name ] ) ) {
$options->$lastOption = true;
break;
}
$options->$lastOption = false;
break;
case 'integer':
case 'float':
$value = aioseo()->helpers->sanitizeOption( $group[ $name ] );
if ( $value ) {
$options->$lastOption = $value;
}
break;
default:
$value = $group[ $name ];
if ( $convertMacros ) {
$value = $this->macrosToSmartTags( $value );
}
$options->$lastOption = aioseo()->helpers->sanitizeOption( $value );
break;
}
}
}
} home/xbodynamge/dev/wp-content/plugins/all-in-one-seo-pack/app/Common/Meta/Helpers.php 0000644 00000006324 15114111446 0024635 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Meta;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Contains helper methods for the title/description classes.
*
* @since 4.1.2
*/
class Helpers {
use Traits\Helpers\BuddyPress;
/**
* The name of the class where this instance is constructed.
*
* @since 4.1.2
*
* @param string $name The name of the class. Either "title" or "description".
*/
private $name;
/**
* Supported filters we can run after preparing the value.
*
* @since 4.1.2
*
* @var array
*/
private $supportedFilters = [
'title' => 'aioseo_title',
'description' => 'aioseo_description'
];
/**
* Class constructor.
*
* @since 4.1.2
*
* @param string $name The name of the class where this instance is constructed.
*/
public function __construct( $name ) {
$this->name = $name;
}
/**
* Sanitizes the title/description.
*
* @since 4.1.2
*
* @param string $value The value.
* @param int|bool $objectId The post/term ID.
* @param bool $replaceTags Whether the smart tags should be replaced.
* @return string The sanitized value.
*/
public function sanitize( $value, $objectId = false, $replaceTags = false ) {
$value = $replaceTags ? $value : aioseo()->tags->replaceTags( $value, $objectId );
$value = aioseo()->helpers->doShortcodes( $value );
$value = aioseo()->helpers->decodeHtmlEntities( $value );
$value = $this->encodeExceptions( $value );
$value = wp_strip_all_tags( strip_shortcodes( $value ) );
// Because we encoded the exceptions, we need to decode them again first to prevent double encoding later down the line.
$value = aioseo()->helpers->decodeHtmlEntities( $value );
// Trim internal and external whitespace.
$value = preg_replace( '/[\s]+/u', ' ', (string) trim( $value ) );
return aioseo()->helpers->internationalize( $value );
}
/**
* Prepares the title/description before returning it.
*
* @since 4.1.2
*
* @param string $value The value.
* @param int|bool $objectId The post/term ID.
* @param bool $replaceTags Whether the smart tags should be replaced.
* @return string The sanitized value.
*/
public function prepare( $value, $objectId = false, $replaceTags = false ) {
if (
! empty( $value ) &&
! is_admin() &&
1 < aioseo()->helpers->getPageNumber()
) {
$value .= ' ' . trim( aioseo()->options->searchAppearance->advanced->pagedFormat );
}
$value = $replaceTags ? $value : aioseo()->tags->replaceTags( $value, $objectId );
$value = apply_filters( $this->supportedFilters[ $this->name ], $value );
return $this->sanitize( $value, $objectId, $replaceTags );
}
/**
* Encodes a number of exceptions before we strip tags.
* We need this function to allow certain character (combinations) in the title/description.
*
* @since 4.1.1
*
* @param string $string The string.
* @return string $string The string with exceptions encoded.
*/
public function encodeExceptions( $string ) {
$exceptions = [ '<3' ];
foreach ( $exceptions as $exception ) {
$string = preg_replace( "/$exception/", aioseo()->helpers->encodeOutputHtml( $exception ), (string) $string );
}
return $string;
}
} home/xbodynamge/namtation/wp-content/plugins/all-in-one-seo-pack/app/Common/ImportExport/Helpers.php0000644 00000004430 15114236120 0027630 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\ImportExport;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Contains helper methods for the import from other plugins.
*
* @since 4.0.0
*/
abstract class Helpers {
/**
* Converts macros to smart tags.
*
* @since 4.1.3
*
* @param string $value The string with macros.
* @return string The string with macros converted.
*/
abstract public function macrosToSmartTags( $value );
/**
* Maps a list of old settings from V3 to their counterparts in V4.
*
* @since 4.0.0
*
* @param array $mappings The old settings, mapped to their new settings.
* @param array $group The old settings group.
* @param bool $convertMacros Whether to convert the old V3 macros to V4 smart tags.
* @return void
*/
public function mapOldToNew( $mappings, $group, $convertMacros = false ) {
if (
! is_array( $mappings ) ||
! is_array( $group ) ||
! count( $mappings ) ||
! count( $group )
) {
return;
}
$mainOptions = aioseo()->options->noConflict();
$dynamicOptions = aioseo()->dynamicOptions->noConflict();
foreach ( $mappings as $name => $values ) {
if ( ! isset( $group[ $name ] ) ) {
continue;
}
$error = false;
$options = ! empty( $values['dynamic'] ) ? $dynamicOptions : $mainOptions;
$lastOption = '';
for ( $i = 0; $i < count( $values['newOption'] ); $i++ ) {
$lastOption = $values['newOption'][ $i ];
if ( ! $options->has( $lastOption, false ) ) {
$error = true;
break;
}
if ( count( $values['newOption'] ) - 1 !== $i ) {
$options = $options->$lastOption;
}
}
if ( $error ) {
continue;
}
switch ( $values['type'] ) {
case 'boolean':
if ( ! empty( $group[ $name ] ) ) {
$options->$lastOption = true;
break;
}
$options->$lastOption = false;
break;
case 'integer':
case 'float':
$value = aioseo()->helpers->sanitizeOption( $group[ $name ] );
if ( $value ) {
$options->$lastOption = $value;
}
break;
default:
$value = $group[ $name ];
if ( $convertMacros ) {
$value = $this->macrosToSmartTags( $value );
}
$options->$lastOption = aioseo()->helpers->sanitizeOption( $value );
break;
}
}
}
} xbodynamge/dev/wp-content/plugins/all-in-one-seo-pack/app/Common/WritingAssistant/Utils/Helpers.php 0000644 00000043000 15114315041 0030272 0 ustar 00 home <?php
namespace AIOSEO\Plugin\Common\WritingAssistant\Utils;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Models;
/**
* Helper functions.
*
* @since 4.7.4
*/
class Helpers {
/**
* Gets the data for vue.
*
* @since 4.7.4
*
* @return array An array of data.
*/
public function getStandaloneVueData() {
$keyword = Models\WritingAssistantPost::getKeyword( get_the_ID() );
return [
'postId' => get_the_ID(),
'report' => $keyword,
'keywordText' => ! empty( $keyword->keyword ) ? $keyword->keyword : '',
'contentAnalysis' => Models\WritingAssistantPost::getContentAnalysis( get_the_ID() ),
'seoBoost' => [
'isLoggedIn' => aioseo()->writingAssistant->seoBoost->isLoggedIn(),
'loginUrl' => aioseo()->writingAssistant->seoBoost->getLoginUrl(),
'createAccountUrl' => aioseo()->writingAssistant->seoBoost->getCreateAccountUrl(),
'userOptions' => aioseo()->writingAssistant->seoBoost->getUserOptions()
]
];
}
/**
* Gets the data for vue.
*
* @since 4.7.4
*
* @return array An array of data.
*/
public function getSettingsVueData() {
return [
'seoBoost' => [
'isLoggedIn' => aioseo()->writingAssistant->seoBoost->isLoggedIn(),
'loginUrl' => aioseo()->writingAssistant->seoBoost->getLoginUrl(),
'createAccountUrl' => aioseo()->writingAssistant->seoBoost->getCreateAccountUrl(),
'userOptions' => aioseo()->writingAssistant->seoBoost->getUserOptions(),
'countries' => $this->getCountries(),
'languages' => $this->getLanguages(),
'searchEngines' => $this->getSearchEngines()
]
];
}
/**
* Returns the list of countries.
*
* @since 4.7.7.1
* @version 4.8.3 Moved from SeoBoost/SeoBoost.php
*
* @return array The list of countries.
*/
private function getCountries() {
$countries = [
'AF' => __( 'Afghanistan', 'all-in-one-seo-pack' ),
'AL' => __( 'Albania', 'all-in-one-seo-pack' ),
'DZ' => __( 'Algeria', 'all-in-one-seo-pack' ),
'AS' => __( 'American Samoa', 'all-in-one-seo-pack' ),
'AD' => __( 'Andorra', 'all-in-one-seo-pack' ),
'AO' => __( 'Angola', 'all-in-one-seo-pack' ),
'AI' => __( 'Anguilla', 'all-in-one-seo-pack' ),
'AG' => __( 'Antigua & Barbuda', 'all-in-one-seo-pack' ),
'AR' => __( 'Argentina', 'all-in-one-seo-pack' ),
'AM' => __( 'Armenia', 'all-in-one-seo-pack' ),
'AU' => __( 'Australia', 'all-in-one-seo-pack' ),
'AT' => __( 'Austria', 'all-in-one-seo-pack' ),
'AZ' => __( 'Azerbaijan', 'all-in-one-seo-pack' ),
'BS' => __( 'Bahamas', 'all-in-one-seo-pack' ),
'BH' => __( 'Bahrain', 'all-in-one-seo-pack' ),
'BD' => __( 'Bangladesh', 'all-in-one-seo-pack' ),
'BY' => __( 'Belarus', 'all-in-one-seo-pack' ),
'BE' => __( 'Belgium', 'all-in-one-seo-pack' ),
'BZ' => __( 'Belize', 'all-in-one-seo-pack' ),
'BJ' => __( 'Benin', 'all-in-one-seo-pack' ),
'BT' => __( 'Bhutan', 'all-in-one-seo-pack' ),
'BO' => __( 'Bolivia', 'all-in-one-seo-pack' ),
'BA' => __( 'Bosnia & Herzegovina', 'all-in-one-seo-pack' ),
'BW' => __( 'Botswana', 'all-in-one-seo-pack' ),
'BR' => __( 'Brazil', 'all-in-one-seo-pack' ),
'VG' => __( 'British Virgin Islands', 'all-in-one-seo-pack' ),
'BN' => __( 'Brunei', 'all-in-one-seo-pack' ),
'BG' => __( 'Bulgaria', 'all-in-one-seo-pack' ),
'BF' => __( 'Burkina Faso', 'all-in-one-seo-pack' ),
'BI' => __( 'Burundi', 'all-in-one-seo-pack' ),
'KH' => __( 'Cambodia', 'all-in-one-seo-pack' ),
'CM' => __( 'Cameroon', 'all-in-one-seo-pack' ),
'CA' => __( 'Canada', 'all-in-one-seo-pack' ),
'CV' => __( 'Cape Verde', 'all-in-one-seo-pack' ),
'CF' => __( 'Central African Republic', 'all-in-one-seo-pack' ),
'TD' => __( 'Chad', 'all-in-one-seo-pack' ),
'CL' => __( 'Chile', 'all-in-one-seo-pack' ),
'CO' => __( 'Colombia', 'all-in-one-seo-pack' ),
'CG' => __( 'Congo - Brazzaville', 'all-in-one-seo-pack' ),
'CD' => __( 'Congo - Kinshasa', 'all-in-one-seo-pack' ),
'CK' => __( 'Cook Islands', 'all-in-one-seo-pack' ),
'CR' => __( 'Costa Rica', 'all-in-one-seo-pack' ),
'CI' => __( 'Côte d’Ivoire', 'all-in-one-seo-pack' ),
'HR' => __( 'Croatia', 'all-in-one-seo-pack' ),
'CU' => __( 'Cuba', 'all-in-one-seo-pack' ),
'CY' => __( 'Cyprus', 'all-in-one-seo-pack' ),
'CZ' => __( 'Czechia', 'all-in-one-seo-pack' ),
'DK' => __( 'Denmark', 'all-in-one-seo-pack' ),
'DJ' => __( 'Djibouti', 'all-in-one-seo-pack' ),
'DM' => __( 'Dominica', 'all-in-one-seo-pack' ),
'DO' => __( 'Dominican Republic', 'all-in-one-seo-pack' ),
'EC' => __( 'Ecuador', 'all-in-one-seo-pack' ),
'EG' => __( 'Egypt', 'all-in-one-seo-pack' ),
'SV' => __( 'El Salvador', 'all-in-one-seo-pack' ),
'EE' => __( 'Estonia', 'all-in-one-seo-pack' ),
'ET' => __( 'Ethiopia', 'all-in-one-seo-pack' ),
'FJ' => __( 'Fiji', 'all-in-one-seo-pack' ),
'FI' => __( 'Finland', 'all-in-one-seo-pack' ),
'FR' => __( 'France', 'all-in-one-seo-pack' ),
'GA' => __( 'Gabon', 'all-in-one-seo-pack' ),
'GM' => __( 'Gambia', 'all-in-one-seo-pack' ),
'GE' => __( 'Georgia', 'all-in-one-seo-pack' ),
'DE' => __( 'Germany', 'all-in-one-seo-pack' ),
'GH' => __( 'Ghana', 'all-in-one-seo-pack' ),
'GI' => __( 'Gibraltar', 'all-in-one-seo-pack' ),
'GR' => __( 'Greece', 'all-in-one-seo-pack' ),
'GL' => __( 'Greenland', 'all-in-one-seo-pack' ),
'GT' => __( 'Guatemala', 'all-in-one-seo-pack' ),
'GG' => __( 'Guernsey', 'all-in-one-seo-pack' ),
'GY' => __( 'Guyana', 'all-in-one-seo-pack' ),
'HT' => __( 'Haiti', 'all-in-one-seo-pack' ),
'HN' => __( 'Honduras', 'all-in-one-seo-pack' ),
'HK' => __( 'Hong Kong', 'all-in-one-seo-pack' ),
'HU' => __( 'Hungary', 'all-in-one-seo-pack' ),
'IS' => __( 'Iceland', 'all-in-one-seo-pack' ),
'IN' => __( 'India', 'all-in-one-seo-pack' ),
'ID' => __( 'Indonesia', 'all-in-one-seo-pack' ),
'IQ' => __( 'Iraq', 'all-in-one-seo-pack' ),
'IE' => __( 'Ireland', 'all-in-one-seo-pack' ),
'IM' => __( 'Isle of Man', 'all-in-one-seo-pack' ),
'IL' => __( 'Israel', 'all-in-one-seo-pack' ),
'IT' => __( 'Italy', 'all-in-one-seo-pack' ),
'JM' => __( 'Jamaica', 'all-in-one-seo-pack' ),
'JP' => __( 'Japan', 'all-in-one-seo-pack' ),
'JE' => __( 'Jersey', 'all-in-one-seo-pack' ),
'JO' => __( 'Jordan', 'all-in-one-seo-pack' ),
'KZ' => __( 'Kazakhstan', 'all-in-one-seo-pack' ),
'KE' => __( 'Kenya', 'all-in-one-seo-pack' ),
'KI' => __( 'Kiribati', 'all-in-one-seo-pack' ),
'KW' => __( 'Kuwait', 'all-in-one-seo-pack' ),
'KG' => __( 'Kyrgyzstan', 'all-in-one-seo-pack' ),
'LA' => __( 'Laos', 'all-in-one-seo-pack' ),
'LV' => __( 'Latvia', 'all-in-one-seo-pack' ),
'LB' => __( 'Lebanon', 'all-in-one-seo-pack' ),
'LS' => __( 'Lesotho', 'all-in-one-seo-pack' ),
'LY' => __( 'Libya', 'all-in-one-seo-pack' ),
'LI' => __( 'Liechtenstein', 'all-in-one-seo-pack' ),
'LT' => __( 'Lithuania', 'all-in-one-seo-pack' ),
'LU' => __( 'Luxembourg', 'all-in-one-seo-pack' ),
'MG' => __( 'Madagascar', 'all-in-one-seo-pack' ),
'MW' => __( 'Malawi', 'all-in-one-seo-pack' ),
'MY' => __( 'Malaysia', 'all-in-one-seo-pack' ),
'MV' => __( 'Maldives', 'all-in-one-seo-pack' ),
'ML' => __( 'Mali', 'all-in-one-seo-pack' ),
'MT' => __( 'Malta', 'all-in-one-seo-pack' ),
'MU' => __( 'Mauritius', 'all-in-one-seo-pack' ),
'MX' => __( 'Mexico', 'all-in-one-seo-pack' ),
'FM' => __( 'Micronesia', 'all-in-one-seo-pack' ),
'MD' => __( 'Moldova', 'all-in-one-seo-pack' ),
'MN' => __( 'Mongolia', 'all-in-one-seo-pack' ),
'ME' => __( 'Montenegro', 'all-in-one-seo-pack' ),
'MS' => __( 'Montserrat', 'all-in-one-seo-pack' ),
'MA' => __( 'Morocco', 'all-in-one-seo-pack' ),
'MZ' => __( 'Mozambique', 'all-in-one-seo-pack' ),
'MM' => __( 'Myanmar (Burma)', 'all-in-one-seo-pack' ),
'NA' => __( 'Namibia', 'all-in-one-seo-pack' ),
'NR' => __( 'Nauru', 'all-in-one-seo-pack' ),
'NP' => __( 'Nepal', 'all-in-one-seo-pack' ),
'NL' => __( 'Netherlands', 'all-in-one-seo-pack' ),
'NZ' => __( 'New Zealand', 'all-in-one-seo-pack' ),
'NI' => __( 'Nicaragua', 'all-in-one-seo-pack' ),
'NE' => __( 'Niger', 'all-in-one-seo-pack' ),
'NG' => __( 'Nigeria', 'all-in-one-seo-pack' ),
'NU' => __( 'Niue', 'all-in-one-seo-pack' ),
'MK' => __( 'North Macedonia', 'all-in-one-seo-pack' ),
'NO' => __( 'Norway', 'all-in-one-seo-pack' ),
'OM' => __( 'Oman', 'all-in-one-seo-pack' ),
'PK' => __( 'Pakistan', 'all-in-one-seo-pack' ),
'PS' => __( 'Palestine', 'all-in-one-seo-pack' ),
'PA' => __( 'Panama', 'all-in-one-seo-pack' ),
'PG' => __( 'Papua New Guinea', 'all-in-one-seo-pack' ),
'PY' => __( 'Paraguay', 'all-in-one-seo-pack' ),
'PE' => __( 'Peru', 'all-in-one-seo-pack' ),
'PH' => __( 'Philippines', 'all-in-one-seo-pack' ),
'PN' => __( 'Pitcairn Islands', 'all-in-one-seo-pack' ),
'PL' => __( 'Poland', 'all-in-one-seo-pack' ),
'PT' => __( 'Portugal', 'all-in-one-seo-pack' ),
'PR' => __( 'Puerto Rico', 'all-in-one-seo-pack' ),
'QA' => __( 'Qatar', 'all-in-one-seo-pack' ),
'RO' => __( 'Romania', 'all-in-one-seo-pack' ),
'RU' => __( 'Russia', 'all-in-one-seo-pack' ),
'RW' => __( 'Rwanda', 'all-in-one-seo-pack' ),
'WS' => __( 'Samoa', 'all-in-one-seo-pack' ),
'SM' => __( 'San Marino', 'all-in-one-seo-pack' ),
'ST' => __( 'São Tomé & Príncipe', 'all-in-one-seo-pack' ),
'SA' => __( 'Saudi Arabia', 'all-in-one-seo-pack' ),
'SN' => __( 'Senegal', 'all-in-one-seo-pack' ),
'RS' => __( 'Serbia', 'all-in-one-seo-pack' ),
'SC' => __( 'Seychelles', 'all-in-one-seo-pack' ),
'SL' => __( 'Sierra Leone', 'all-in-one-seo-pack' ),
'SG' => __( 'Singapore', 'all-in-one-seo-pack' ),
'SK' => __( 'Slovakia', 'all-in-one-seo-pack' ),
'SI' => __( 'Slovenia', 'all-in-one-seo-pack' ),
'SB' => __( 'Solomon Islands', 'all-in-one-seo-pack' ),
'SO' => __( 'Somalia', 'all-in-one-seo-pack' ),
'ZA' => __( 'South Africa', 'all-in-one-seo-pack' ),
'KR' => __( 'South Korea', 'all-in-one-seo-pack' ),
'ES' => __( 'Spain', 'all-in-one-seo-pack' ),
'LK' => __( 'Sri Lanka', 'all-in-one-seo-pack' ),
'SH' => __( 'St. Helena', 'all-in-one-seo-pack' ),
'VC' => __( 'St. Vincent & Grenadines', 'all-in-one-seo-pack' ),
'SR' => __( 'Suriname', 'all-in-one-seo-pack' ),
'SE' => __( 'Sweden', 'all-in-one-seo-pack' ),
'CH' => __( 'Switzerland', 'all-in-one-seo-pack' ),
'TW' => __( 'Taiwan', 'all-in-one-seo-pack' ),
'TJ' => __( 'Tajikistan', 'all-in-one-seo-pack' ),
'TZ' => __( 'Tanzania', 'all-in-one-seo-pack' ),
'TH' => __( 'Thailand', 'all-in-one-seo-pack' ),
'TL' => __( 'Timor-Leste', 'all-in-one-seo-pack' ),
'TG' => __( 'Togo', 'all-in-one-seo-pack' ),
'TO' => __( 'Tonga', 'all-in-one-seo-pack' ),
'TT' => __( 'Trinidad & Tobago', 'all-in-one-seo-pack' ),
'TN' => __( 'Tunisia', 'all-in-one-seo-pack' ),
'TR' => __( 'Turkey', 'all-in-one-seo-pack' ),
'TM' => __( 'Turkmenistan', 'all-in-one-seo-pack' ),
'VI' => __( 'U.S. Virgin Islands', 'all-in-one-seo-pack' ),
'UG' => __( 'Uganda', 'all-in-one-seo-pack' ),
'UA' => __( 'Ukraine', 'all-in-one-seo-pack' ),
'AE' => __( 'United Arab Emirates', 'all-in-one-seo-pack' ),
'GB' => __( 'United Kingdom', 'all-in-one-seo-pack' ),
'US' => __( 'United States', 'all-in-one-seo-pack' ),
'UY' => __( 'Uruguay', 'all-in-one-seo-pack' ),
'UZ' => __( 'Uzbekistan', 'all-in-one-seo-pack' ),
'VU' => __( 'Vanuatu', 'all-in-one-seo-pack' ),
'VE' => __( 'Venezuela', 'all-in-one-seo-pack' ),
'VN' => __( 'Vietnam', 'all-in-one-seo-pack' ),
'ZM' => __( 'Zambia', 'all-in-one-seo-pack' ),
'ZW' => __( 'Zimbabwe', 'all-in-one-seo-pack' )
];
return $countries;
}
/**
* Returns the list of languages.
*
* @since 4.7.7.1
* @version 4.8.3 Moved from SeoBoost/SeoBoost.php
*
* @return array The list of languages.
*/
private function getLanguages() {
$languages = [
'ca' => __( 'Catalan', 'all-in-one-seo-pack' ),
'da' => __( 'Danish', 'all-in-one-seo-pack' ),
'nl' => __( 'Dutch', 'all-in-one-seo-pack' ),
'en' => __( 'English', 'all-in-one-seo-pack' ),
'fr' => __( 'French', 'all-in-one-seo-pack' ),
'de' => __( 'German', 'all-in-one-seo-pack' ),
'id' => __( 'Indonesian', 'all-in-one-seo-pack' ),
'it' => __( 'Italian', 'all-in-one-seo-pack' ),
'no' => __( 'Norwegian', 'all-in-one-seo-pack' ),
'pt' => __( 'Portuguese', 'all-in-one-seo-pack' ),
'ro' => __( 'Romanian', 'all-in-one-seo-pack' ),
'es' => __( 'Spanish', 'all-in-one-seo-pack' ),
'sv' => __( 'Swedish', 'all-in-one-seo-pack' ),
'tr' => __( 'Turkish', 'all-in-one-seo-pack' )
];
return $languages;
}
/**
* Returns the list of search engines.
*
* @since 4.7.7.1
* @version 4.8.3 Moved from SeoBoost/SeoBoost.php
*
* @return array The list of search engines.
*/
private function getSearchEngines() {
$searchEngines = [
'AF' => 'google.com.af',
'AL' => 'google.al',
'DZ' => 'google.dz',
'AS' => 'google.as',
'AD' => 'google.ad',
'AO' => 'google.it.ao',
'AI' => 'google.com.ai',
'AG' => 'google.com.ag',
'AR' => 'google.com.ar',
'AM' => 'google.am',
'AU' => 'google.com.au',
'AT' => 'google.at',
'AZ' => 'google.az',
'BS' => 'google.bs',
'BH' => 'google.com.bh',
'BD' => 'google.com.bd',
'BY' => 'google.com.by',
'BE' => 'google.be',
'BZ' => 'google.com.bz',
'BJ' => 'google.bj',
'BT' => 'google.bt',
'BO' => 'google.com.bo',
'BA' => 'google.ba',
'BW' => 'google.co.bw',
'BR' => 'google.com.br',
'VG' => 'google.vg',
'BN' => 'google.com.bn',
'BG' => 'google.bg',
'BF' => 'google.bf',
'BI' => 'google.bi',
'KH' => 'google.com.kh',
'CM' => 'google.cm',
'CA' => 'google.ca',
'CV' => 'google.cv',
'CF' => 'google.cf',
'TD' => 'google.td',
'CL' => 'google.cl',
'CO' => 'google.com.co',
'CG' => 'google.cg',
'CD' => 'google.cd',
'CK' => 'google.co.ck',
'CR' => 'google.co.cr',
'CI' => 'google.ci',
'HR' => 'google.hr',
'CU' => 'google.com.cu',
'CY' => 'google.com.cy',
'CZ' => 'google.cz',
'DK' => 'google.dk',
'DJ' => 'google.dj',
'DM' => 'google.dm',
'DO' => 'google.com.do',
'EC' => 'google.com.ec',
'EG' => 'google.com.eg',
'SV' => 'google.com.sv',
'EE' => 'google.ee',
'ET' => 'google.com.et',
'FJ' => 'google.com.fj',
'FI' => 'google.fi',
'FR' => 'google.fr',
'GA' => 'google.ga',
'GM' => 'google.gm',
'GE' => 'google.ge',
'DE' => 'google.de',
'GH' => 'google.com.gh',
'GI' => 'google.com.gi',
'GR' => 'google.gr',
'GL' => 'google.gl',
'GT' => 'google.com.gt',
'GG' => 'google.gg',
'GY' => 'google.gy',
'HT' => 'google.ht',
'HN' => 'google.hn',
'HK' => 'google.com.hk',
'HU' => 'google.hu',
'IS' => 'google.is',
'IN' => 'google.co.in',
'ID' => 'google.co.id',
'IQ' => 'google.iq',
'IE' => 'google.ie',
'IM' => 'google.co.im',
'IL' => 'google.co.il',
'IT' => 'google.it',
'JM' => 'google.com.jm',
'JP' => 'google.co.jp',
'JE' => 'google.co.je',
'JO' => 'google.jo',
'KZ' => 'google.kz',
'KE' => 'google.co.ke',
'KI' => 'google.ki',
'KW' => 'google.com.kw',
'KG' => 'google.com.kg',
'LA' => 'google.la',
'LV' => 'google.lv',
'LB' => 'google.com.lb',
'LS' => 'google.co.ls',
'LY' => 'google.com.ly',
'LI' => 'google.li',
'LT' => 'google.lt',
'LU' => 'google.lu',
'MG' => 'google.mg',
'MW' => 'google.mw',
'MY' => 'google.com.my',
'MV' => 'google.mv',
'ML' => 'google.ml',
'MT' => 'google.com.mt',
'MU' => 'google.mu',
'MX' => 'google.com.mx',
'FM' => 'google.fm',
'MD' => 'google.md',
'MN' => 'google.mn',
'ME' => 'google.me',
'MS' => 'google.ms',
'MA' => 'google.co.ma',
'MZ' => 'google.co.mz',
'MM' => 'google.com.mm',
'NA' => 'google.com.na',
'NR' => 'google.nr',
'NP' => 'google.com.np',
'NL' => 'google.nl',
'NZ' => 'google.co.nz',
'NI' => 'google.com.ni',
'NE' => 'google.ne',
'NG' => 'google.com.ng',
'NU' => 'google.nu',
'MK' => 'google.mk',
'NO' => 'google.no',
'OM' => 'google.com.om',
'PK' => 'google.com.pk',
'PS' => 'google.ps',
'PA' => 'google.com.pa',
'PG' => 'google.com.pg',
'PY' => 'google.com.py',
'PE' => 'google.com.pe',
'PH' => 'google.com.ph',
'PN' => 'google.pn',
'PL' => 'google.pl',
'PT' => 'google.pt',
'PR' => 'google.com.pr',
'QA' => 'google.com.qa',
'RO' => 'google.ro',
'RU' => 'google.ru',
'RW' => 'google.rw',
'WS' => 'google.as',
'SM' => 'google.sm',
'ST' => 'google.st',
'SA' => 'google.com.sa',
'SN' => 'google.sn',
'RS' => 'google.rs',
'SC' => 'google.sc',
'SL' => 'google.com.sl',
'SG' => 'google.com.sg',
'SK' => 'google.sk',
'SI' => 'google.si',
'SB' => 'google.com.sb',
'SO' => 'google.so',
'ZA' => 'google.co.za',
'KR' => 'google.co.kr',
'ES' => 'google.es',
'LK' => 'google.lk',
'SH' => 'google.sh',
'VC' => 'google.com.vc',
'SR' => 'google.sr',
'SE' => 'google.se',
'CH' => 'google.ch',
'TW' => 'google.com.tw',
'TJ' => 'google.com.tj',
'TZ' => 'google.co.tz',
'TH' => 'google.co.th',
'TL' => 'google.tl',
'TG' => 'google.tg',
'TO' => 'google.to',
'TT' => 'google.tt',
'TN' => 'google.tn',
'TR' => 'google.com.tr',
'TM' => 'google.tm',
'VI' => 'google.co.vi',
'UG' => 'google.co.ug',
'UA' => 'google.com.ua',
'AE' => 'google.ae',
'GB' => 'google.co.uk',
'US' => 'google.com',
'UY' => 'google.com.uy',
'UZ' => 'google.co.uz',
'VU' => 'google.vu',
'VE' => 'google.co.ve',
'VN' => 'google.com.vn',
'ZM' => 'google.co.zm',
'ZW' => 'google.co.zw'
];
return $searchEngines;
}
}xbodynamge/dev/wp-content/plugins/all-in-one-seo-pack/app/Common/ImportExport/RankMath/Helpers.php 0000644 00000007433 15114410721 0030051 0 ustar 00 home <?php
namespace AIOSEO\Plugin\Common\ImportExport\RankMath;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\ImportExport;
// phpcs:disable WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
/**
* Contains helper methods for the import from Rank Math.
*
* @since 4.0.0
*/
class Helpers extends ImportExport\Helpers {
/**
* Converts the macros from Rank Math to our own smart tags.
*
* @since 4.0.0
*
* @param string $string The string with macros.
* @param string $pageType The page type.
* @return string $string The string with smart tags.
*/
public function macrosToSmartTags( $string, $pageType = null ) {
$macros = $this->getMacros( $pageType );
if ( preg_match( '#%BLOGDESCLINK%#', (string) $string ) ) {
$blogDescriptionLink = '<a href="' .
aioseo()->helpers->decodeHtmlEntities( get_bloginfo( 'url' ) ) . '">' .
aioseo()->helpers->decodeHtmlEntities( get_bloginfo( 'name' ) ) . ' - ' .
aioseo()->helpers->decodeHtmlEntities( get_bloginfo( 'description' ) ) . '</a>';
$string = str_replace( '%BLOGDESCLINK%', $blogDescriptionLink, $string );
}
if ( preg_match_all( '#%customfield\(([^%\s]*)\)%#', (string) $string, $matches ) && ! empty( $matches[1] ) ) {
foreach ( $matches[1] as $name ) {
$string = aioseo()->helpers->pregReplace( "#%customfield\($name\)%#", "#custom_field-$name", $string );
}
}
if ( preg_match_all( '#%customterm\(([^%\s]*)\)%#', (string) $string, $matches ) && ! empty( $matches[1] ) ) {
foreach ( $matches[1] as $name ) {
$string = aioseo()->helpers->pregReplace( "#%customterm\($name\)%#", "#tax_name-$name", $string );
}
}
foreach ( $macros as $macro => $tag ) {
$string = aioseo()->helpers->pregReplace( "#$macro(?![a-zA-Z0-9_])#im", $tag, $string );
}
// Strip out all remaining tags.
$string = aioseo()->helpers->pregReplace( '/%[^\%\s]*\([^\%]*\)%/i', '', aioseo()->helpers->pregReplace( '/%[^\%\s]*%/i', '', $string ) );
return trim( $string );
}
/**
* Returns the macro mappings.
*
* @since 4.1.1
*
* @param string $pageType The page type.
* @return array $macros The macros.
*/
protected function getMacros( $pageType = null ) {
$macros = [
'%sitename%' => '#site_title',
'%blog_title%' => '#site_title',
'%blog_description%' => '#tagline',
'%sitedesc%' => '#tagline',
'%sep%' => '#separator_sa',
'%post_title%' => '#post_title',
'%page_title%' => '#post_title',
'%postname%' => '#post_title',
'%title%' => '#post_title',
'%seo_title%' => '#post_title',
'%excerpt%' => '#post_excerpt',
'%wc_shortdesc%' => '#post_excerpt',
'%category%' => '#taxonomy_title',
'%term%' => '#taxonomy_title',
'%term_description%' => '#taxonomy_description',
'%currentdate%' => '#current_date',
'%currentday%' => '#current_day',
'%currentyear%' => '#current_year',
'%currentmonth%' => '#current_month',
'%name%' => '#author_first_name #author_last_name',
'%author%' => '#author_first_name #author_last_name',
'%date%' => '#post_date',
'%year%' => '#current_year',
'%search_query%' => '#search_term',
// RSS Content tags.
'%AUTHORLINK%' => '#author_link',
'%POSTLINK%' => '#post_link',
'%BLOGLINK%' => '#site_link',
'%FEATUREDIMAGE%' => '#featured_image'
];
switch ( $pageType ) {
case 'archive':
$macros['%title%'] = '#archive_title';
break;
case 'term':
$macros['%title%'] = '#taxonomy_title';
break;
default:
$macros['%title%'] = '#post_title';
break;
}
// Strip all other tags.
$macros['%[^%]*%'] = '';
return $macros;
}
} xbodynamge/dev/wp-content/plugins/all-in-one-seo-pack/app/Common/ImportExport/SeoPress/Helpers.php 0000644 00000007264 15114410724 0030114 0 ustar 00 home <?php
namespace AIOSEO\Plugin\Common\ImportExport\SeoPress;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\ImportExport;
// phpcs:disable WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
/**
* Contains helper methods for the import from SEOPress.
*
* @since 4.1.4
*/
class Helpers extends ImportExport\Helpers {
/**
* Converts the macros from SEOPress to our own smart tags.
*
* @since 4.1.4
*
* @param string $string The string with macros.
* @param string $postType The post type.
* @return string The string with smart tags.
*/
public function macrosToSmartTags( $string, $postType = null ) {
$macros = $this->getMacros( $postType );
foreach ( $macros as $macro => $tag ) {
$string = aioseo()->helpers->pregReplace( "#$macro(?![a-zA-Z0-9_])#im", $tag, $string );
}
return trim( $string );
}
/**
* Returns the macro mappings.
*
* @since 4.1.4
*
* @param string $postType The post type.
* @param string $pageType The page type.
* @return array $macros The macros.
*/
protected function getMacros( $postType = null, $pageType = null ) {
$macros = [
'%%sep%%' => '#separator_sa',
'%%sitetitle%%' => '#site_title',
'%%sitename%%' => '#site_title',
'%%tagline%%' => '#tagline',
'%%sitedesc%%' => '#tagline',
'%%title%%' => '#site_title',
'%%post_title%%' => '#post_title',
'%%post_excerpt%%' => '#post_excerpt',
'%%excerpt%%' => '#post_excerpt',
'%%post_content%%' => '#post_content',
'%%post_url%%' => '#permalink',
'%%post_date%%' => '#post_date',
'%%post_permalink%%' => '#permalink',
'%%date%%' => '#post_date',
'%%post_author%%' => '#author_name',
'%%post_category%%' => '#categories',
'%%_category_title%%' => '#taxonomy_title',
'%%_category_description%%' => '#taxonomy_description',
'%%tag_title%%' => '#taxonomy_title',
'%%tag_description%%' => '#taxonomy_description',
'%%term_title%%' => '#taxonomy_title',
'%%term_description%%' => '#taxonomy_description',
'%%search_keywords%%' => '#search_term',
'%%current_pagination%%' => '#page_number',
'%%page%%' => '#page_number',
'%%archive_title%%' => '#archive_title',
'%%archive_date%%' => '#archive_date',
'%%wc_single_price%%' => '#woocommerce_price',
'%%wc_sku%%' => '#woocommerce_sku',
'%%currentday%%' => '#current_day',
'%%currentmonth%%' => '#current_month',
'%%currentmonth_short%%' => '#current_month',
'%%currentyear%%' => '#current_year',
'%%currentdate%%' => '#current_date',
'%%author_first_name%%' => '#author_first_name',
'%%author_last_name%%' => '#author_last_name',
'%%author_website%%' => '#author_link',
'%%author_nickname%%' => '#author_first_name',
'%%author_bio%%' => '#author_bio',
'%%currentmonth_num%%' => '#current_month',
];
if ( $postType ) {
$postType = get_post_type_object( $postType );
if ( ! empty( $postType ) ) {
$macros += [
'%%cpt_plural%%' => $postType->labels->name,
];
}
}
switch ( $pageType ) {
case 'archive':
$macros['%%title%%'] = '#archive_title';
break;
case 'term':
$macros['%%title%%'] = '#taxonomy_title';
break;
default:
$macros['%%title%%'] = '#post_title';
break;
}
// Strip all other tags.
$macros['%%[^%]*%%'] = '';
return $macros;
}
} namtation/wp-content/plugins/all-in-one-seo-pack/app/Common/ImportExport/SeoPress/Helpers.php 0000644 00000007264 15114412141 0031323 0 ustar 00 home/xbodynamge <?php
namespace AIOSEO\Plugin\Common\ImportExport\SeoPress;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\ImportExport;
// phpcs:disable WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
/**
* Contains helper methods for the import from SEOPress.
*
* @since 4.1.4
*/
class Helpers extends ImportExport\Helpers {
/**
* Converts the macros from SEOPress to our own smart tags.
*
* @since 4.1.4
*
* @param string $string The string with macros.
* @param string $postType The post type.
* @return string The string with smart tags.
*/
public function macrosToSmartTags( $string, $postType = null ) {
$macros = $this->getMacros( $postType );
foreach ( $macros as $macro => $tag ) {
$string = aioseo()->helpers->pregReplace( "#$macro(?![a-zA-Z0-9_])#im", $tag, $string );
}
return trim( $string );
}
/**
* Returns the macro mappings.
*
* @since 4.1.4
*
* @param string $postType The post type.
* @param string $pageType The page type.
* @return array $macros The macros.
*/
protected function getMacros( $postType = null, $pageType = null ) {
$macros = [
'%%sep%%' => '#separator_sa',
'%%sitetitle%%' => '#site_title',
'%%sitename%%' => '#site_title',
'%%tagline%%' => '#tagline',
'%%sitedesc%%' => '#tagline',
'%%title%%' => '#site_title',
'%%post_title%%' => '#post_title',
'%%post_excerpt%%' => '#post_excerpt',
'%%excerpt%%' => '#post_excerpt',
'%%post_content%%' => '#post_content',
'%%post_url%%' => '#permalink',
'%%post_date%%' => '#post_date',
'%%post_permalink%%' => '#permalink',
'%%date%%' => '#post_date',
'%%post_author%%' => '#author_name',
'%%post_category%%' => '#categories',
'%%_category_title%%' => '#taxonomy_title',
'%%_category_description%%' => '#taxonomy_description',
'%%tag_title%%' => '#taxonomy_title',
'%%tag_description%%' => '#taxonomy_description',
'%%term_title%%' => '#taxonomy_title',
'%%term_description%%' => '#taxonomy_description',
'%%search_keywords%%' => '#search_term',
'%%current_pagination%%' => '#page_number',
'%%page%%' => '#page_number',
'%%archive_title%%' => '#archive_title',
'%%archive_date%%' => '#archive_date',
'%%wc_single_price%%' => '#woocommerce_price',
'%%wc_sku%%' => '#woocommerce_sku',
'%%currentday%%' => '#current_day',
'%%currentmonth%%' => '#current_month',
'%%currentmonth_short%%' => '#current_month',
'%%currentyear%%' => '#current_year',
'%%currentdate%%' => '#current_date',
'%%author_first_name%%' => '#author_first_name',
'%%author_last_name%%' => '#author_last_name',
'%%author_website%%' => '#author_link',
'%%author_nickname%%' => '#author_first_name',
'%%author_bio%%' => '#author_bio',
'%%currentmonth_num%%' => '#current_month',
];
if ( $postType ) {
$postType = get_post_type_object( $postType );
if ( ! empty( $postType ) ) {
$macros += [
'%%cpt_plural%%' => $postType->labels->name,
];
}
}
switch ( $pageType ) {
case 'archive':
$macros['%%title%%'] = '#archive_title';
break;
case 'term':
$macros['%%title%%'] = '#taxonomy_title';
break;
default:
$macros['%%title%%'] = '#post_title';
break;
}
// Strip all other tags.
$macros['%%[^%]*%%'] = '';
return $macros;
}
} namtation/wp-content/plugins/all-in-one-seo-pack/app/Common/ImportExport/RankMath/Helpers.php 0000644 00000007433 15114414730 0031271 0 ustar 00 home/xbodynamge <?php
namespace AIOSEO\Plugin\Common\ImportExport\RankMath;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\ImportExport;
// phpcs:disable WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
/**
* Contains helper methods for the import from Rank Math.
*
* @since 4.0.0
*/
class Helpers extends ImportExport\Helpers {
/**
* Converts the macros from Rank Math to our own smart tags.
*
* @since 4.0.0
*
* @param string $string The string with macros.
* @param string $pageType The page type.
* @return string $string The string with smart tags.
*/
public function macrosToSmartTags( $string, $pageType = null ) {
$macros = $this->getMacros( $pageType );
if ( preg_match( '#%BLOGDESCLINK%#', (string) $string ) ) {
$blogDescriptionLink = '<a href="' .
aioseo()->helpers->decodeHtmlEntities( get_bloginfo( 'url' ) ) . '">' .
aioseo()->helpers->decodeHtmlEntities( get_bloginfo( 'name' ) ) . ' - ' .
aioseo()->helpers->decodeHtmlEntities( get_bloginfo( 'description' ) ) . '</a>';
$string = str_replace( '%BLOGDESCLINK%', $blogDescriptionLink, $string );
}
if ( preg_match_all( '#%customfield\(([^%\s]*)\)%#', (string) $string, $matches ) && ! empty( $matches[1] ) ) {
foreach ( $matches[1] as $name ) {
$string = aioseo()->helpers->pregReplace( "#%customfield\($name\)%#", "#custom_field-$name", $string );
}
}
if ( preg_match_all( '#%customterm\(([^%\s]*)\)%#', (string) $string, $matches ) && ! empty( $matches[1] ) ) {
foreach ( $matches[1] as $name ) {
$string = aioseo()->helpers->pregReplace( "#%customterm\($name\)%#", "#tax_name-$name", $string );
}
}
foreach ( $macros as $macro => $tag ) {
$string = aioseo()->helpers->pregReplace( "#$macro(?![a-zA-Z0-9_])#im", $tag, $string );
}
// Strip out all remaining tags.
$string = aioseo()->helpers->pregReplace( '/%[^\%\s]*\([^\%]*\)%/i', '', aioseo()->helpers->pregReplace( '/%[^\%\s]*%/i', '', $string ) );
return trim( $string );
}
/**
* Returns the macro mappings.
*
* @since 4.1.1
*
* @param string $pageType The page type.
* @return array $macros The macros.
*/
protected function getMacros( $pageType = null ) {
$macros = [
'%sitename%' => '#site_title',
'%blog_title%' => '#site_title',
'%blog_description%' => '#tagline',
'%sitedesc%' => '#tagline',
'%sep%' => '#separator_sa',
'%post_title%' => '#post_title',
'%page_title%' => '#post_title',
'%postname%' => '#post_title',
'%title%' => '#post_title',
'%seo_title%' => '#post_title',
'%excerpt%' => '#post_excerpt',
'%wc_shortdesc%' => '#post_excerpt',
'%category%' => '#taxonomy_title',
'%term%' => '#taxonomy_title',
'%term_description%' => '#taxonomy_description',
'%currentdate%' => '#current_date',
'%currentday%' => '#current_day',
'%currentyear%' => '#current_year',
'%currentmonth%' => '#current_month',
'%name%' => '#author_first_name #author_last_name',
'%author%' => '#author_first_name #author_last_name',
'%date%' => '#post_date',
'%year%' => '#current_year',
'%search_query%' => '#search_term',
// RSS Content tags.
'%AUTHORLINK%' => '#author_link',
'%POSTLINK%' => '#post_link',
'%BLOGLINK%' => '#site_link',
'%FEATUREDIMAGE%' => '#featured_image'
];
switch ( $pageType ) {
case 'archive':
$macros['%title%'] = '#archive_title';
break;
case 'term':
$macros['%title%'] = '#taxonomy_title';
break;
default:
$macros['%title%'] = '#post_title';
break;
}
// Strip all other tags.
$macros['%[^%]*%'] = '';
return $macros;
}
} home/xbodynamge/dev/wp-content/plugins/all-in-one-seo-pack/app/Common/Migration/Helpers.php 0000644 00000020076 15114431435 0025703 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Migration;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Models;
/**
* Contains a number of helper functions for the V3 migration.
*
* @since 4.0.0
*/
class Helpers {
/**
* Maps a list of old settings from V3 to their counterparts in V4.
*
* @since 4.0.0
*
* @param array $mappings The old settings, mapped to their new settings.
* @param array $group The old settings group.
* @param bool $convertMacros Whether to convert the old V3 macros to V4 smart tags.
* @return void
*/
public function mapOldToNew( $mappings, $group, $convertMacros = false ) {
if (
! is_array( $mappings ) ||
! is_array( $group ) ||
! count( $mappings ) ||
! count( $group )
) {
return;
}
$mainOptions = aioseo()->options->noConflict();
$dynamicOptions = aioseo()->dynamicOptions->noConflict();
foreach ( $mappings as $name => $values ) {
if ( ! isset( $group[ $name ] ) ) {
continue;
}
$error = false;
$options = ! empty( $values['dynamic'] ) ? $dynamicOptions : $mainOptions;
$lastOption = '';
for ( $i = 0; $i < count( $values['newOption'] ); $i++ ) {
$lastOption = $values['newOption'][ $i ];
if ( ! $options->has( $lastOption, false ) ) {
$error = true;
break;
}
if ( count( $values['newOption'] ) - 1 !== $i ) {
$options = $options->$lastOption;
}
}
if ( $error ) {
continue;
}
switch ( $values['type'] ) {
case 'boolean':
if ( ! empty( $group[ $name ] ) ) {
$options->$lastOption = true;
break;
}
$options->$lastOption = false;
break;
case 'integer':
case 'float':
$value = aioseo()->helpers->sanitizeOption( $group[ $name ] );
if ( $value ) {
$options->$lastOption = $value;
}
break;
default:
$value = $group[ $name ];
if ( $convertMacros ) {
$value = $this->macrosToSmartTags( $value );
}
$options->$lastOption = aioseo()->helpers->sanitizeOption( $value );
break;
}
}
}
/**
* Replaces the macros from V3 with our new Smart Tags from V4.
*
* @since 4.0.0
*
* @param string $string The string.
* @return string $string The converted string.
*/
public function macrosToSmartTags( $string ) {
$macros = [
'%site_title%' => '#site_title',
'%blog_title%' => '#site_title',
'%site_description%' => '#tagline',
'%blog_description%' => '#tagline',
'%wp_title%' => '#post_title',
'%post_title%' => '#post_title',
'%page_title%' => '#post_title',
'%post_date%' => '#post_date',
'%post_month%' => '#post_month',
'%post_year%' => '#post_year',
'%date%' => '#archive_date',
'%day%' => '#post_day',
'%month%' => '#post_month',
'%monthnum%' => '#post_month',
'%year%' => '#post_year',
'%current_date%' => '#current_date',
'%current_day%' => '#current_day',
'%current_month%' => '#current_month',
'%current_month_i18n%' => '#current_month',
'%current_year%' => '#current_year',
'%category_title%' => '#taxonomy_title',
'%tag%' => '#taxonomy_title',
'%tag_title%' => '#taxonomy_title',
'%archive_title%' => '#archive_title',
'%taxonomy_title%' => '#taxonomy_title',
'%taxonomy_description%' => '#taxonomy_description',
'%tag_description%' => '#taxonomy_description',
'%category_description%' => '#taxonomy_description',
'%author%' => '#author_name',
'%search%' => '#search_term',
'%page%' => '#page_number',
'%site_link%' => '#site_link',
'%site_link_raw%' => '#site_link_alt',
'%post_link%' => '#post_link',
'%post_link_raw%' => '#post_link_alt',
'%author_name%' => '#author_name',
'%author_link%' => '#author_link',
'%image_title%' => '#image_title',
'%image_seo_title%' => '#image_seo_title',
'%image_seo_description%' => '#image_seo_description',
'%post_seo_title%' => '#post_seo_title',
'%post_seo_description%' => '#post_seo_description',
'%alt_tag%' => '#alt_tag',
'%description%' => '#description',
// These need to run last so we don't replace other known tags.
'%.*_title%' => '#post_title',
'%[^%]*_author_login%' => '#author_first_name #author_last_name',
'%[^%]*_author_nicename%' => '#author_first_name #author_last_name',
'%[^%]*_author_firstname%' => '#author_first_name',
'%[^%]*_author_lastname%' => '#author_last_name',
];
if ( preg_match_all( '#%cf_([^%]*)%#', (string) $string, $matches ) && ! empty( $matches[1] ) ) {
foreach ( $matches[1] as $name ) {
if ( preg_match( '#\s#', (string) $name ) ) {
$notification = Models\Notification::getNotificationByName( 'v3-migration-custom-field' );
if ( ! $notification->notification_name ) {
Models\Notification::addNotification( [
'slug' => uniqid(),
'notification_name' => 'v3-migration-custom-field',
'title' => __( 'Custom field names with spaces detected', 'all-in-one-seo-pack' ),
'content' => sprintf(
// Translators: 1 - The plugin short name ("AIOSEO"), 2 - Same as previous.
__( '%1$s has detected that you have one or more custom fields with spaces in their name.
In order for %2$s to correctly parse these custom fields, their names cannot contain any spaces.', 'all-in-one-seo-pack' ),
AIOSEO_PLUGIN_SHORT_NAME,
AIOSEO_PLUGIN_SHORT_NAME
),
'type' => 'warning',
'level' => [ 'all' ],
'button1_label' => __( 'Remind Me Later', 'all-in-one-seo-pack' ),
'button1_action' => 'http://action#notification/v3-migration-custom-field-reminder',
'start' => gmdate( 'Y-m-d H:i:s' )
] );
}
} else {
$string = aioseo()->helpers->pregReplace( "#%cf_$name%#", "#custom_field-$name", $string );
}
}
}
if ( preg_match_all( '#%tax_([^%]*)%#', (string) $string, $matches ) && ! empty( $matches[1] ) ) {
foreach ( $matches[1] as $name ) {
if ( ! preg_match( '#\s#', (string) $name ) ) {
$string = aioseo()->helpers->pregReplace( "#%tax_$name%#", "#tax_name-$name", $string );
}
}
}
foreach ( $macros as $macro => $tag ) {
$string = aioseo()->helpers->pregReplace( "#$macro(?![a-zA-Z0-9_])#im", $tag, $string );
}
$string = preg_replace( '/%([a-f0-9]{2}[^%]*)%/i', '#$1#', (string) $string );
return $string;
}
/**
* Converts the old comma-separated keywords format to the new JSON format.
*
* @since 4.0.0
*
* @param string $keywords A comma-separated list of keywords.
* @return string $keywords The keywords formatted in JSON.
*/
public function oldKeywordsToNewKeywords( $keywords ) {
if ( ! $keywords ) {
return '';
}
$oldKeywords = array_filter( explode( ',', $keywords ) );
if ( ! is_array( $oldKeywords ) ) {
return '';
}
$keywords = [];
foreach ( $oldKeywords as $oldKeyword ) {
$oldKeyword = aioseo()->helpers->sanitizeOption( $oldKeyword );
$keyword = new \stdClass();
$keyword->label = $oldKeyword;
$keyword->value = $oldKeyword;
$keywords[] = $keyword;
}
return $keywords;
}
/**
* Resets the plugin so that the migration can run again.
*
* @since 4.0.0
*
* @return void
*/
public static function redoMigration() {
aioseo()->core->db->delete( 'options' )
->whereRaw( "`option_name` LIKE 'aioseo_options_internal%'" )
->run();
aioseo()->core->cache->delete( 'v3_migration_in_progress_posts' );
aioseo()->core->cache->delete( 'v3_migration_in_progress_terms' );
aioseo()->actionScheduler->unschedule( 'aioseo_migrate_post_meta' );
aioseo()->actionScheduler->unschedule( 'aioseo_migrate_term_meta' );
}
} home/xbodynamge/namtation/wp-content/plugins/all-in-one-seo-pack/app/Common/Schema/Helpers.php 0000644 00000006776 15114434570 0026404 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Contains helper methods for our schema classes.
*
* @since 4.2.5
*/
class Helpers {
/**
* Checks whether the schema markup feature is enabled.
*
* @since 4.2.5
*
* @return bool Whether the schema markup feature is enabled or not.
*/
public function isEnabled() {
$isEnabled = ! in_array( 'enableSchemaMarkup', aioseo()->internalOptions->deprecatedOptions, true ) || aioseo()->options->deprecated->searchAppearance->global->schema->enableSchemaMarkup;
return ! apply_filters( 'aioseo_schema_disable', ! $isEnabled );
}
/**
* Strips HTML and removes all blank properties in each of our graphs.
* Also parses properties that might contain smart tags.
*
* @since 4.0.13
* @version 4.2.5
*
* @param array $data The graph data.
* @param string $parentKey The key of the group parent (optional).
* @param bool $replaceTags Whether the smart tags should be replaced.
* @return array The cleaned graph data.
*/
public function cleanAndParseData( $data, $parentKey = '', $replaceTags = true ) {
foreach ( $data as $k => &$v ) {
if ( is_numeric( $v ) || is_bool( $v ) || is_null( $v ) ) {
// Do nothing.
} elseif ( is_array( $v ) ) {
$v = $this->cleanAndParseData( $v, $k, $replaceTags );
} else {
// Check if the prop can contain some HTML tags.
if (
isset( aioseo()->schema->htmlAllowedFields[ $parentKey ] ) &&
in_array( $k, aioseo()->schema->htmlAllowedFields[ $parentKey ], true )
) {
$v = trim( wp_kses_post( $v ) );
} else {
$v = trim( wp_strip_all_tags( $v ) );
}
$v = $replaceTags ? aioseo()->tags->replaceTags( $v, get_the_ID() ) : $v;
}
if ( empty( $v ) && ! in_array( $k, aioseo()->schema->nullableFields, true ) ) {
unset( $data[ $k ] );
} else {
$data[ $k ] = $v;
}
}
return $data;
}
/**
* Sorts the schema data and then returns it as JSON.
* We temporarily change the floating point precision in order to prevent rounding errors.
* Otherwise e.g. 4.9 could be output as 4.90000004.
*
* @since 4.2.7
*
* @param array $schema The schema data.
* @param bool $replaceTags Whether the smart tags should be replaced.
* @return string The schema as JSON.
*/
public function getOutput( $schema, $replaceTags = true ) {
$schema['@graph'] = apply_filters( 'aioseo_schema_output', $schema['@graph'] );
$schema['@graph'] = $this->cleanAndParseData( $schema['@graph'], '', $replaceTags );
// Sort the graphs alphabetically.
usort( $schema['@graph'], function ( $a, $b ) {
$typeA = $a['@type'] ?? null;
$typeB = $b['@type'] ?? null;
if ( is_null( $typeA ) || is_array( $typeA ) ) {
return 1;
}
if ( is_null( $typeB ) || is_array( $typeB ) ) {
return -1;
}
return strcmp( $typeA, $typeB );
} );
// Allow users to control the default json_encode flags.
// Some users report better SEO performance when non-Latin unicode characters are not escaped.
$jsonFlags = apply_filters( 'aioseo_schema_json_flags', 0 );
$json = isset( $_GET['aioseo-dev'] ) || aioseo()->schema->generatingValidatorOutput // phpcs:ignore HM.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Recommended
? aioseo()->helpers->wpJsonEncode( $schema, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE )
: aioseo()->helpers->wpJsonEncode( $schema, $jsonFlags );
return $json;
}
} namtation/wp-content/plugins/all-in-one-seo-pack/app/Common/ImportExport/YoastSeo/Helpers.php 0000644 00000011315 15114436657 0031340 0 ustar 00 home/xbodynamge <?php
namespace AIOSEO\Plugin\Common\ImportExport\YoastSeo;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\ImportExport;
// phpcs:disable WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
/**
* Contains helper methods for the import from Rank Math.
*
* @since 4.0.0
*/
class Helpers extends ImportExport\Helpers {
/**
* Converts the macros from Yoast SEO to our own smart tags.
*
* @since 4.0.0
*
* @param string $string The string with macros.
* @param string $postType The post type.
* @param string $pageType The page type.
* @return string $string The string with smart tags.
*/
public function macrosToSmartTags( $string, $postType = null, $pageType = null ) {
$macros = $this->getMacros( $postType, $pageType );
if ( preg_match( '#%%BLOGDESCLINK%%#', (string) $string ) ) {
$blogDescriptionLink = '<a href="' .
aioseo()->helpers->decodeHtmlEntities( get_bloginfo( 'url' ) ) . '">' .
aioseo()->helpers->decodeHtmlEntities( get_bloginfo( 'name' ) ) . ' - ' .
aioseo()->helpers->decodeHtmlEntities( get_bloginfo( 'description' ) ) . '</a>';
$string = str_replace( '%%BLOGDESCLINK%%', $blogDescriptionLink, $string );
}
if ( preg_match_all( '#%%cf_([^%]*)%%#', (string) $string, $matches ) && ! empty( $matches[1] ) ) {
foreach ( $matches[1] as $name ) {
if ( ! preg_match( '#\s#', (string) $name ) ) {
$string = aioseo()->helpers->pregReplace( "#%%cf_$name%%#", "#custom_field-$name", $string );
}
}
}
if ( preg_match_all( '#%%tax_([^%]*)%%#', (string) $string, $matches ) && ! empty( $matches[1] ) ) {
foreach ( $matches[1] as $name ) {
if ( ! preg_match( '#\s#', (string) $name ) ) {
$string = aioseo()->helpers->pregReplace( "#%%tax_$name%%#", "#tax_name-$name", $string );
}
}
}
foreach ( $macros as $macro => $tag ) {
$string = aioseo()->helpers->pregReplace( "#$macro(?![a-zA-Z0-9_])#im", $tag, $string );
}
// Strip out all remaining tags.
$string = aioseo()->helpers->pregReplace( '/%[^\%\s]*\([^\%]*\)%/i', '', aioseo()->helpers->pregReplace( '/%[^\%\s]*%/i', '', $string ) );
return trim( $string );
}
/**
* Returns the macro mappings.
*
* @since 4.1.1
*
* @param string $postType The post type.
* @param string $pageType The page type.
* @return array $macros The macros.
*/
protected function getMacros( $postType = null, $pageType = null ) {
$macros = [
'%%sitename%%' => '#site_title',
'%%sitedesc%%' => '#tagline',
'%%sep%%' => '#separator_sa',
'%%term_title%%' => '#taxonomy_title',
'%%term_description%%' => '#taxonomy_description',
'%%category_description%%' => '#taxonomy_description',
'%%tag_description%%' => '#taxonomy_description',
'%%primary_category%%' => '#taxonomy_title',
'%%archive_title%%' => '#archive_title',
'%%pagenumber%%' => '#page_number',
'%%caption%%' => '#attachment_caption',
'%%name%%' => '#author_first_name #author_last_name',
'%%user_description%%' => '#author_bio',
'%%date%%' => '#archive_date',
'%%currentday%%' => '#current_day',
'%%currentmonth%%' => '#current_month',
'%%currentyear%%' => '#current_year',
'%%searchphrase%%' => '#search_term',
'%%AUTHORLINK%%' => '#author_link',
'%%POSTLINK%%' => '#post_link',
'%%BLOGLINK%%' => '#site_link',
'%%category%%' => '#categories',
'%%parent_title%%' => '#parent_title',
'%%wc_sku%%' => '#woocommerce_sku',
'%%wc_price%%' => '#woocommerce_price',
'%%wc_brand%%' => '#woocommerce_brand',
'%%excerpt%%' => '#post_excerpt',
'%%excerpt_only%%' => '#post_excerpt_only'
/* '%%tag%%' => '',
'%%id%%' => '',
'%%page%%' => '',
'%%modified%%' => '',
'%%pagetotal%%' => '',
'%%focuskw%%' => '',
'%%term404%%' => '',
'%%ct_desc_[^%]*%%' => '' */
];
if ( $postType ) {
$postType = get_post_type_object( $postType );
if ( ! empty( $postType ) ) {
$macros += [
'%%pt_single%%' => $postType->labels->singular_name,
'%%pt_plural%%' => $postType->labels->name,
];
}
}
switch ( $pageType ) {
case 'archive':
$macros['%%title%%'] = '#archive_title';
break;
case 'term':
$macros['%%title%%'] = '#taxonomy_title';
break;
default:
$macros['%%title%%'] = '#post_title';
break;
}
// Strip all other tags.
$macros['%%[^%]*%%'] = '';
return $macros;
}
} home/xbodynamge/namtation/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Helpers.php 0000644 00000024225 15114440161 0026262 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Utils;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Traits\Helpers as TraitHelpers;
/**
* Contains helper functions
*
* @since 4.0.0
*/
class Helpers {
use TraitHelpers\Api;
use TraitHelpers\Arrays;
use TraitHelpers\Buffer;
use TraitHelpers\Constants;
use TraitHelpers\Deprecated;
use TraitHelpers\DateTime;
use TraitHelpers\Language;
use TraitHelpers\Numbers;
use TraitHelpers\PostType;
use TraitHelpers\Request;
use TraitHelpers\Shortcodes;
use TraitHelpers\Strings;
use TraitHelpers\Svg;
use TraitHelpers\ThirdParty;
use TraitHelpers\Url;
use TraitHelpers\Vue;
use TraitHelpers\Wp;
use TraitHelpers\WpContext;
use TraitHelpers\WpMultisite;
use TraitHelpers\WpUri;
/**
* Generate a UTM URL from the url and medium/content passed in.
*
* @since 4.0.0
*
* @param string $url The URL to parse.
* @param string $medium The UTM medium parameter.
* @param string|null $content The UTM content parameter or null.
* @param boolean $esc Whether or not to escape the URL.
* @return string The new URL.
*/
public function utmUrl( $url, $medium, $content = null, $esc = true ) {
// First, remove any existing utm parameters on the URL.
$url = remove_query_arg( [
'utm_source',
'utm_medium',
'utm_campaign',
'utm_content'
], $url );
// Generate the new arguments.
$args = [
'utm_source' => 'WordPress',
'utm_campaign' => aioseo()->pro ? 'proplugin' : 'liteplugin',
'utm_medium' => $medium
];
// Content is not used by default.
if ( $content ) {
$args['utm_content'] = $content;
}
// Return the new URL.
$url = add_query_arg( $args, $url );
return $esc ? esc_url( $url ) : $url;
}
/**
* Checks if we are in a dev environment or not.
*
* @since 4.1.0
*
* @return boolean True if we are, false if not.
*/
public function isDev() {
return aioseo()->isDev || isset( $_REQUEST['aioseo-dev'] ); // phpcs:ignore HM.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Recommended
}
/**
* Checks if the server is running on Apache.
*
* @since 4.0.0
*
* @return boolean Whether or not it is on apache.
*/
public function isApache() {
if ( ! isset( $_SERVER['SERVER_SOFTWARE'] ) ) {
return false;
}
return stripos( sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ), 'apache' ) !== false;
}
/**
* Checks if the server is running on nginx.
*
* @since 4.0.0
*
* @return bool Whether or not it is on nginx.
*/
public function isNginx() {
if ( ! isset( $_SERVER['SERVER_SOFTWARE'] ) ) {
return false;
}
$server = sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) );
if (
false !== stripos( $server, 'Flywheel' ) ||
false !== stripos( $server, 'nginx' )
) {
return true;
}
return false;
}
/**
* Checks if the server is running on LiteSpeed.
*
* @since 4.5.3
*
* @return bool Whether it is on LiteSpeed.
*/
public function isLiteSpeed() {
if ( ! isset( $_SERVER['SERVER_SOFTWARE'] ) ) {
return false;
}
$server = strtolower( sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) );
return false !== stripos( $server, 'litespeed' );
}
/**
* Returns the server name: Apache, nginx or LiteSpeed.
*
* @since 4.5.3
*
* @return string The server name. An empty string if it's unknown.
*/
public function getServerName() {
if ( aioseo()->helpers->isApache() ) {
return 'apache';
}
if ( aioseo()->helpers->isNginx() ) {
return 'nginx';
}
if ( aioseo()->helpers->isLiteSpeed() ) {
return 'litespeed';
}
return '';
}
/**
* Validate IP addresses.
*
* @since 4.0.0
*
* @param string $ip The IP address to validate.
* @return boolean If the IP address is valid or not.
*/
public function validateIp( $ip ) {
if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) {
return true;
}
if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) ) {
return true;
}
// Doesn't seem to be a valid IP.
return false;
}
/**
* Convert bytes to readable format.
*
* @since 4.0.0
*
* @param integer $bytes The size of the file.
* @return array The original and readable file size.
*/
public function convertFileSize( $bytes ) {
if ( empty( $bytes ) ) {
return [
'original' => 0,
'readable' => '0 B'
];
}
$i = floor( log( $bytes ) / log( 1024 ) );
$sizes = [ 'B', 'KB', 'MB', 'GB', 'TB' ];
return [
'original' => $bytes,
'readable' => sprintf( '%.02F', $bytes / pow( 1024, $i ) ) * 1 . ' ' . $sizes[ $i ]
];
}
/**
* Sanitizes a given option value before we store it in the DB.
*
* Used by the migration and importer classes.
*
* @since 4.0.0
*
* @param mixed $value The value.
* @return mixed $value The sanitized value.
*/
public function sanitizeOption( $value ) {
switch ( gettype( $value ) ) {
case 'boolean':
return (bool) $value;
case 'string':
$value = aioseo()->helpers->decodeHtmlEntities( $value );
return aioseo()->helpers->encodeOutputHtml( wp_strip_all_tags( wp_check_invalid_utf8( trim( $value ) ) ) );
case 'integer':
return intval( $value );
case 'double':
return floatval( $value );
case 'array':
$sanitized = [];
foreach ( (array) $value as $child ) {
$sanitized[] = aioseo()->helpers->sanitizeOption( $child );
}
return $sanitized;
default:
return false;
}
}
/**
* Checks if the given string is serialized, and if so, unserializes it.
* If the serialized string contains an object, we abort to prevent PHP object injection.
*
* @since 4.1.0.2
*
* @param string $string The string.
* @param array|boolean $allowedClasses The allowed classes for unserialize.
* @return string|array The string or unserialized data.
*/
public function maybeUnserialize( $string, $allowedClasses = false ) {
if ( ! is_string( $string ) ) {
return $string;
}
$string = trim( $string );
if ( is_serialized( $string ) ) {
return @unserialize( $string, [ 'allowed_classes' => $allowedClasses ] ); // phpcs:disable PHPCompatibility.FunctionUse.NewFunctionParameters.unserialize_optionsFound
}
return $string;
}
/**
* Returns a deep clone of the given object.
* The built-in PHP clone KW provides a shallow clone. This method returns a deep clone that also clones nested object properties.
* You can use this method to sever the reference to nested objects.
*
* @since 4.4.7
*
* @return object The cloned object.
*/
public function deepClone( $object ) {
return unserialize( serialize( $object ) );
}
/**
* Sanitizes a given variable
*
* @since 4.5.6
*
* @param mixed $variable The variable.
* @param bool $preserveHtml Whether or not to preserve HTML for ALL fields.
* @param array $fieldsToPreserveHtml Specific fields to preserve HTML for.
* @param string $fieldName The name of the current field (when looping over a list).
* @return mixed The sanitized variable.
*/
public function sanitize( $variable, $preserveHtml = false, $fieldsToPreserveHtml = [], $fieldName = '' ) {
$type = gettype( $variable );
switch ( $type ) {
case 'boolean':
return (bool) $variable;
case 'string':
if ( $preserveHtml || in_array( $fieldName, $fieldsToPreserveHtml, true ) ) {
return aioseo()->helpers->decodeHtmlEntities( sanitize_text_field( htmlspecialchars( $variable, ENT_NOQUOTES, 'UTF-8' ) ) );
}
return sanitize_text_field( $variable );
case 'integer':
return intval( $variable );
case 'float':
case 'double':
return floatval( $variable );
case 'array':
$array = [];
foreach ( (array) $variable as $k => $v ) {
$array[ $k ] = $this->sanitize( $v, $preserveHtml, $fieldsToPreserveHtml, $k );
}
return $array;
default:
return false;
}
}
/**
* Return the version number with a filter to enable users to hide the version.
*
* @since 4.3.7
*
* @return string The current version or empty if the filter is active. Using ?aioseo-dev will override the filter.
*/
public function getAioseoVersion() {
$version = aioseo()->version;
if ( ! $this->isDev() && apply_filters( 'aioseo_hide_version_number', false ) ) {
$version = '';
}
return $version;
}
/**
* Retrieves the marketing site articles.
*
* @since 4.7.2
*
* @param bool $fetchImage Whether to fetch the article image.
* @return array The articles or an empty array on failure.
*/
public function fetchAioseoArticles( $fetchImage = false ) {
$items = aioseo()->core->networkCache->get( 'rss_feed' );
if ( null !== $items ) {
return $items;
}
$options = [
'timeout' => 10,
'sslverify' => false,
];
$response = wp_remote_get( 'https://aioseo.com/wp-json/wp/v2/posts?per_page=4', $options );
$body = wp_remote_retrieve_body( $response );
if ( ! $body ) {
return [];
}
$cached = [];
$items = json_decode( $body, true );
foreach ( $items as $k => $item ) {
$cached[ $k ] = [
'url' => $item['link'],
'title' => $item['title']['rendered'],
'date' => date( get_option( 'date_format' ), strtotime( $item['date'] ) ),
'content' => wp_html_excerpt( $item['content']['rendered'], 128, '…' ),
];
if ( $fetchImage ) {
$response = wp_remote_get( $item['_links']['wp:featuredmedia'][0]['href'] ?? '', $options );
$body = wp_remote_retrieve_body( $response );
if ( ! $body ) {
continue;
}
$image = json_decode( $body, true );
$cached[ $k ]['image'] = [
'url' => $image['source_url'] ?? '',
'alt' => $image['alt_text'] ?? '',
'sizes' => $image['media_details']['sizes'] ?? ''
];
}
}
aioseo()->core->networkCache->update( 'rss_feed', $cached, 24 * HOUR_IN_SECONDS );
return $cached;
}
/**
* Returns if the admin bar is enabled.
*
* @since 4.8.1
*
* @return bool Whether the admin bar is enabled.
*/
public function isAdminBarEnabled() {
$showAdminBarMenu = aioseo()->options->advanced->adminBarMenu;
return is_admin_bar_showing() && ( $showAdminBarMenu ?? true );
}
} home/xbodynamge/namtation/wp-content/plugins/all-in-one-seo-pack/app/Common/Sitemap/Helpers.php 0000644 00000043214 15114446473 0026577 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Sitemap;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Contains general helper methods specific to the sitemap.
*
* @since 4.0.0
*/
class Helpers {
/**
* Used to track the performance of the sitemap.
*
* @since 4.0.0
*
* @var array
* $memory The peak memory that is required to generate the sitemap.
* $time The time that is required to generate the sitemap.
*/
private $performance;
/**
* Returns the sitemap filename.
*
* @since 4.0.0
*
* @param string $type The sitemap type. We pass it in when we need to get the filename for a specific sitemap outside of the context of the sitemap.
* @return string The sitemap filename.
*/
public function filename( $type = '' ) {
if ( ! $type ) {
$type = isset( aioseo()->sitemap->type ) ? aioseo()->sitemap->type : 'general';
}
return apply_filters( 'aioseo_sitemap_filename', aioseo()->options->sitemap->$type->filename );
}
/**
* Returns the last modified post.
*
* @since 4.0.0
*
* @param array $additionalArgs Any additional arguments for the post query.
* @return mixed WP_Post object or false.
*/
public function lastModifiedPost( $additionalArgs = [] ) {
$args = [
'post_status' => 'publish',
'posts_per_page' => 1,
'orderby ' => 'modified',
'order' => 'ASC'
];
if ( $additionalArgs ) {
foreach ( $additionalArgs as $k => $v ) {
$args[ $k ] = $v;
}
}
$query = ( new \WP_Query( $args ) );
if ( ! $query->post_count ) {
return false;
}
return $query->posts[0];
}
/**
* Returns the timestamp of the last modified post.
*
* @since 4.0.0
*
* @param array $postTypes The relevant post types.
* @param array $additionalArgs Any additional arguments for the post query.
* @return string Formatted date string (ISO 8601).
*/
public function lastModifiedPostTime( $postTypes = [ 'post', 'page' ], $additionalArgs = [] ) {
if ( is_array( $postTypes ) ) {
$postTypes = implode( "', '", $postTypes );
}
$query = aioseo()->core->db
->start( aioseo()->core->db->db->posts . ' as p', true )
->select( 'MAX(`p`.`post_modified_gmt`) as last_modified' )
->where( 'p.post_status', 'publish' )
->whereRaw( "( `p`.`post_type` IN ( '$postTypes' ) )" );
if ( isset( $additionalArgs['author'] ) ) {
$query->where( 'p.post_author', $additionalArgs['author'] );
}
$lastModified = $query->run()
->result();
return ! empty( $lastModified[0]->last_modified )
? aioseo()->helpers->dateTimeToIso8601( $lastModified[0]->last_modified )
: '';
}
/**
* Returns the timestamp of the last modified additional page.
*
* @since 4.0.0
*
* @return string Formatted date string (ISO 8601).
*/
public function lastModifiedAdditionalPagesTime() {
$pages = [];
if ( 'posts' === get_option( 'show_on_front' ) || ! in_array( 'page', $this->includedPostTypes(), true ) ) {
$frontPageId = (int) get_option( 'page_on_front' );
$post = aioseo()->helpers->getPost( $frontPageId );
$pages[] = $post ? strtotime( $post->post_modified_gmt ) : strtotime( aioseo()->sitemap->helpers->lastModifiedPostTime() );
}
foreach ( aioseo()->options->sitemap->general->additionalPages->pages as $page ) {
$additionalPage = json_decode( $page );
if ( empty( $additionalPage->url ) ) {
continue;
}
$pages[] = strtotime( $additionalPage->lastModified );
}
if ( empty( $pages ) ) {
$additionalPages = apply_filters( 'aioseo_sitemap_additional_pages', [] );
if ( empty( $additionalPages ) ) {
return false;
}
$lastModified = 0;
$timestamp = time();
foreach ( $additionalPages as $page ) {
if ( empty( $page['lastmod'] ) ) {
continue;
}
$timestamp = strtotime( $page['lastmod'] );
if ( ! $timestamp ) {
continue;
}
if ( $lastModified < $timestamp ) {
$lastModified = $timestamp;
}
}
return 0 !== $lastModified ? aioseo()->helpers->dateTimeToIso8601( gmdate( 'Y-m-d H:i:s', $timestamp ) ) : false;
}
return aioseo()->helpers->dateTimeToIso8601( gmdate( 'Y-m-d H:i:s', max( $pages ) ) );
}
/**
* Formats a given image URL for usage in the sitemap.
*
* @since 4.0.0
*
* @param string $url The URL.
* @return string The formatted URL.
*/
public function formatUrl( $url ) {
// Remove URL parameters.
$url = strtok( $url, '?' );
$url = htmlspecialchars( $url, ENT_COMPAT, 'UTF-8', false );
return aioseo()->helpers->makeUrlAbsolute( $url );
}
/**
* Logs the performance of the sitemap for debugging purposes.
*
* @since 4.0.0
*
* @return void
*/
public function logPerformance() {
// Start logging the performance.
if ( ! $this->performance ) {
$this->performance['time'] = microtime( true );
$this->performance['memory'] = ( memory_get_peak_usage( true ) / 1024 ) / 1024;
return;
}
// Stop logging the performance.
$time = microtime( true ) - $this->performance['time'];
$memory = $this->performance['memory'];
$type = aioseo()->sitemap->type;
$indexName = aioseo()->sitemap->indexName;
// phpcs:disable WordPress.PHP.DevelopmentFunctions
error_log( wp_json_encode( "$indexName index of $type sitemap generated in $time seconds using a maximum of $memory mb of memory." ) );
// phpcs:enable WordPress.PHP.DevelopmentFunctions
}
/**
* Returns the post types that should be included in the sitemap.
*
* @since 4.0.0
*
* @param boolean $hasArchivesOnly Whether or not to only include post types which have archives.
* @return array $postTypes The included post types.
*/
public function includedPostTypes( $hasArchivesOnly = false ) {
if ( aioseo()->options->sitemap->{aioseo()->sitemap->type}->postTypes->all ) {
$postTypes = aioseo()->helpers->getPublicPostTypes( true, $hasArchivesOnly );
} else {
$postTypes = aioseo()->options->sitemap->{aioseo()->sitemap->type}->postTypes->included;
}
if ( ! $postTypes ) {
return $postTypes;
}
$options = aioseo()->options->noConflict();
$dynamicOptions = aioseo()->dynamicOptions->noConflict();
$publicPostTypes = aioseo()->helpers->getPublicPostTypes( true, $hasArchivesOnly );
foreach ( $postTypes as $postType ) {
// Check if post type is no longer registered.
if ( ! in_array( $postType, $publicPostTypes, true ) || ! $dynamicOptions->searchAppearance->postTypes->has( $postType ) ) {
$postTypes = aioseo()->helpers->unsetValue( $postTypes, $postType );
continue;
}
// Check if post type isn't noindexed.
if ( aioseo()->helpers->isPostTypeNoindexed( $postType ) ) {
if ( ! $this->checkForIndexedPost( $postType ) ) {
$postTypes = aioseo()->helpers->unsetValue( $postTypes, $postType );
continue;
}
}
if (
$dynamicOptions->searchAppearance->postTypes->$postType->advanced->robotsMeta->default &&
! $options->searchAppearance->advanced->globalRobotsMeta->default &&
$options->searchAppearance->advanced->globalRobotsMeta->noindex
) {
if ( ! $this->checkForIndexedPost( $postType ) ) {
$postTypes = aioseo()->helpers->unsetValue( $postTypes, $postType );
}
}
}
return $postTypes;
}
/**
* Checks if any post is explicitly indexed when the post type is noindexed.
*
* @since 4.0.0
*
* @param string $postType The post type to check for.
* @return bool Whether or not there is an indexed post.
*/
private function checkForIndexedPost( $postType ) {
$db = aioseo()->core->db->noConflict();
$posts = $db->start( aioseo()->core->db->db->posts . ' as p', true )
->select( 'p.ID' )
->join( 'aioseo_posts as ap', '`ap`.`post_id` = `p`.`ID`' )
->where( 'p.post_status', 'attachment' === $postType ? 'inherit' : 'publish' )
->where( 'p.post_type', $postType )
->whereRaw( '( `ap`.`robots_default` = 0 AND `ap`.`robots_noindex` = 0 )' )
->limit( 1 )
->run()
->result();
if ( $posts && count( $posts ) ) {
return true;
}
return false;
}
/**
* Returns the taxonomies that should be included in the sitemap.
*
* @since 4.0.0
*
* @return array The included taxonomies.
*/
public function includedTaxonomies() {
$taxonomies = [];
if ( aioseo()->options->sitemap->{aioseo()->sitemap->type}->taxonomies->all ) {
$taxonomies = get_taxonomies();
} else {
$taxonomies = aioseo()->options->sitemap->{aioseo()->sitemap->type}->taxonomies->included;
}
if ( ! $taxonomies ) {
return [];
}
$options = aioseo()->options->noConflict();
$dynamicOptions = aioseo()->dynamicOptions->noConflict();
$publicTaxonomies = aioseo()->helpers->getPublicTaxonomies( true );
foreach ( $taxonomies as $taxonomy ) {
if (
aioseo()->helpers->isWooCommerceActive() &&
aioseo()->helpers->isWooCommerceProductAttribute( $taxonomy )
) {
$taxonomies = aioseo()->helpers->unsetValue( $taxonomies, $taxonomy );
if ( ! in_array( 'product_attributes', $taxonomies, true ) ) {
$taxonomies[] = 'product_attributes';
}
continue;
}
// Check if taxonomy is no longer registered.
if ( ! in_array( $taxonomy, $publicTaxonomies, true ) || ! $dynamicOptions->searchAppearance->taxonomies->has( $taxonomy ) ) {
$taxonomies = aioseo()->helpers->unsetValue( $taxonomies, $taxonomy );
continue;
}
// Check if taxonomy isn't noindexed.
if ( aioseo()->helpers->isTaxonomyNoindexed( $taxonomy ) ) {
$taxonomies = aioseo()->helpers->unsetValue( $taxonomies, $taxonomy );
continue;
}
if (
$dynamicOptions->searchAppearance->taxonomies->$taxonomy->advanced->robotsMeta->default &&
! $options->searchAppearance->advanced->globalRobotsMeta->default &&
$options->searchAppearance->advanced->globalRobotsMeta->noindex
) {
$taxonomies = aioseo()->helpers->unsetValue( $taxonomies, $taxonomy );
continue;
}
}
return $taxonomies;
}
/**
* Splits sitemap entries into chuncks based on the max. amount of URLs per index.
*
* @since 4.0.0
*
* @param array $entries The sitemap entries.
* @return array The chunked sitemap entries.
*/
public function chunkEntries( $entries ) {
return array_chunk( $entries, aioseo()->sitemap->linksPerIndex, true );
}
/**
* Formats the last Modified date of a user-submitted additional page as an ISO 8601 date.
*
* @since 4.0.0
*
* @param object $page The additional page object.
* @return string The formatted datetime.
*/
public function lastModifiedAdditionalPage( $page ) {
return aioseo()->helpers->isValidDate( $page->lastModified ) ? gmdate( 'c', strtotime( $page->lastModified ) ) : '';
}
/**
* Returns a list of excluded post IDs.
*
* @since 4.0.0
*
* @return string The excluded IDs.
*/
public function excludedPosts() {
static $excludedPosts = null;
if ( null === $excludedPosts ) {
$excludedPosts = $this->excludedObjectIds( 'excludePosts' );
}
return $excludedPosts;
}
/**
* Returns a list of excluded term IDs.
*
* @since 4.0.0
*
* @return string The excluded IDs.
*/
public function excludedTerms() {
static $excludedTerms = null;
if ( null === $excludedTerms ) {
$excludedTerms = $this->excludedObjectIds( 'excludeTerms' );
}
return $excludedTerms;
}
/**
* Returns a list of excluded IDs for a given option as a comma separated string.
*
* Helper method for excludedPosts() and excludedTerms().
*
* @since 4.0.0
* @version 4.4.7 Improved method name.
*
* @param string $option The option name.
* @return string The excluded IDs.
*/
private function excludedObjectIds( $option ) {
$type = aioseo()->sitemap->type;
// The RSS Sitemap needs to exclude whatever is excluded in the general sitemap.
if ( 'rss' === $type ) {
$type = 'general';
}
// Allow WPML to filter out hidden language posts/terms.
$hiddenObjectIds = [];
if ( aioseo()->helpers->isWpmlActive() ) {
$hiddenLanguages = apply_filters( 'wpml_setting', [], 'hidden_languages' );
foreach ( $hiddenLanguages as $language ) {
$objectTypes = [];
if ( 'excludePosts' === $option ) {
$objectTypes = aioseo()->sitemap->helpers->includedPostTypes();
$objectTypes = array_map( function( $postType ) {
return "post_{$postType}";
}, $objectTypes );
}
if ( 'excludeTerms' === $option ) {
$objectTypes = aioseo()->sitemap->helpers->includedTaxonomies();
$objectTypes = array_map( function( $taxonomy ) {
return "tax_{$taxonomy}";
}, $objectTypes );
}
$dbNoConflict = aioseo()->core->db->noConflict();
$rows = $dbNoConflict->start( 'icl_translations' )
->select( 'element_id' )
->whereIn( 'element_type', $objectTypes )
->where( 'language_code', $language )
->run()
->result();
$ids = array_map( function( $row ) {
return (int) $row->element_id;
}, $rows );
$hiddenObjectIds = array_merge( $hiddenObjectIds, $ids );
}
}
$hasFilter = has_filter( 'aioseo_sitemap_' . aioseo()->helpers->toSnakeCase( $option ) );
$advanced = aioseo()->options->sitemap->$type->advancedSettings->enable;
$excluded = array_merge( $hiddenObjectIds, aioseo()->options->sitemap->{$type}->advancedSettings->{$option} );
if (
! $advanced &&
empty( $excluded ) &&
! $hasFilter
) {
return '';
}
$ids = [];
foreach ( $excluded as $object ) {
if ( is_numeric( $object ) ) {
$ids[] = (int) $object;
continue;
}
$object = json_decode( $object );
if ( is_int( $object->value ) ) {
$ids[] = $object->value;
}
}
if ( 'excludePosts' === $option ) {
$ids = apply_filters( 'aioseo_sitemap_exclude_posts', $ids, $type );
}
if ( 'excludeTerms' === $option ) {
$ids = apply_filters( 'aioseo_sitemap_exclude_terms', $ids, $type );
}
return count( $ids ) ? esc_sql( implode( ', ', $ids ) ) : '';
}
/**
* Returns the URLs of all active sitemaps.
*
* @since 4.0.0
* @version 4.6.2 Removed the prefix from the list of URLs.
*
* @return array $urls The sitemap URLs.
*/
public function getSitemapUrls() {
static $urls = [];
if ( $urls ) {
return $urls;
}
$addonsUrls = array_filter( aioseo()->addons->doAddonFunction( 'helpers', 'getSitemapUrls' ) );
foreach ( $addonsUrls as $addonUrls ) {
$urls = array_merge( $urls, $addonUrls );
}
if ( aioseo()->options->sitemap->general->enable ) {
$urls[] = $this->getUrl( 'general' );
}
if ( aioseo()->options->sitemap->rss->enable ) {
$urls[] = $this->getUrl( 'rss' );
}
return $urls;
}
/**
* Returns the URLs of all active sitemaps with the 'Sitemap: ' prefix.
*
* @since 4.6.2
*
* @return array $urls The sitemap URLs.
*/
public function getSitemapUrlsPrefixed() {
$urls = $this->getSitemapUrls();
foreach ( $urls as &$url ) {
$url = 'Sitemap: ' . $url;
}
return $urls;
}
/**
* Extracts existing sitemap URLs from the robots.txt file.
* We need this in case users have existing sitemap directives added to their robots.txt file.
*
* @since 4.0.10
* @version 4.4.9
*
* @return array The sitemap URLs.
*/
public function extractSitemapUrlsFromRobotsTxt() {
// First, we need to remove our filter, so that it doesn't run unintentionally.
remove_filter( 'robots_txt', [ aioseo()->robotsTxt, 'buildRules' ], 10000 );
$robotsTxt = apply_filters( 'robots_txt', '', true );
add_filter( 'robots_txt', [ aioseo()->robotsTxt, 'buildRules' ], 10000 );
if ( ! $robotsTxt ) {
return [];
}
$lines = explode( "\n", $robotsTxt );
if ( ! is_array( $lines ) || ! count( $lines ) ) {
return [];
}
return aioseo()->robotsTxt->extractSitemapUrls( $robotsTxt );
}
/**
* Returns the URL of the given sitemap type.
*
* @since 4.1.5
*
* @param string $type The sitemap type.
* @return string The sitemap URL.
*/
public function getUrl( $type ) {
$url = home_url( 'sitemap.xml' );
if ( 'rss' === $type ) {
$url = home_url( 'sitemap.rss' );
}
if ( 'general' === $type ) {
// Check if user has a custom filename from the V3 migration.
$filename = $this->filename( 'general' ) ?: 'sitemap';
$url = home_url( $filename . '.xml' );
}
$addon = aioseo()->addons->getLoadedAddon( $type );
if ( ! empty( $addon->helpers ) && method_exists( $addon->helpers, 'getUrl' ) ) {
$url = $addon->helpers->getUrl();
}
return $url;
}
/**
* Returns if images should be excluded from the sitemap.
*
* @since 4.2.2
*
* @return bool
*/
public function excludeImages() {
$shouldExclude = aioseo()->options->sitemap->general->advancedSettings->enable && aioseo()->options->sitemap->general->advancedSettings->excludeImages;
return apply_filters( 'aioseo_sitemap_exclude_images', $shouldExclude );
}
/**
* Returns the post types to check against for the author sitemap.
*
* @since 4.4.4
*
* @return array The post types.
*/
public function getAuthorPostTypes() {
// By default, WP only considers posts for author archives, but users can include additional post types.
$postTypes = [ 'post' ];
return apply_filters( 'aioseo_sitemap_author_post_types', $postTypes );
}
/**
* Decode the Urls from Posts and Terms so they properly show in the Sitemap.
*
* @since 4.6.9
*
* @param mixed $data The data to decode.
* @return array $result The converted data with decoded URLs.
*/
public function decodeSitemapEntries( $data ) {
$result = [];
if ( empty( $data ) ) {
return $result;
}
// Decode Url to properly show Unicode Characters.
foreach ( $data as $item ) {
if ( isset( $item['loc'] ) ) {
$item['loc'] = aioseo()->helpers->decodeUrl( $item['loc'] );
}
// This is for the RSS Sitemap.
if ( isset( $item['guid'] ) ) {
$item['guid'] = aioseo()->helpers->decodeUrl( $item['guid'] );
}
$result[] = $item;
}
return $result;
}
} xbodynamge/dev/wp-content/plugins/all-in-one-seo-pack/app/Common/ImportExport/YoastSeo/Helpers.php 0000644 00000011315 15114447102 0030107 0 ustar 00 home <?php
namespace AIOSEO\Plugin\Common\ImportExport\YoastSeo;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\ImportExport;
// phpcs:disable WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
/**
* Contains helper methods for the import from Rank Math.
*
* @since 4.0.0
*/
class Helpers extends ImportExport\Helpers {
/**
* Converts the macros from Yoast SEO to our own smart tags.
*
* @since 4.0.0
*
* @param string $string The string with macros.
* @param string $postType The post type.
* @param string $pageType The page type.
* @return string $string The string with smart tags.
*/
public function macrosToSmartTags( $string, $postType = null, $pageType = null ) {
$macros = $this->getMacros( $postType, $pageType );
if ( preg_match( '#%%BLOGDESCLINK%%#', (string) $string ) ) {
$blogDescriptionLink = '<a href="' .
aioseo()->helpers->decodeHtmlEntities( get_bloginfo( 'url' ) ) . '">' .
aioseo()->helpers->decodeHtmlEntities( get_bloginfo( 'name' ) ) . ' - ' .
aioseo()->helpers->decodeHtmlEntities( get_bloginfo( 'description' ) ) . '</a>';
$string = str_replace( '%%BLOGDESCLINK%%', $blogDescriptionLink, $string );
}
if ( preg_match_all( '#%%cf_([^%]*)%%#', (string) $string, $matches ) && ! empty( $matches[1] ) ) {
foreach ( $matches[1] as $name ) {
if ( ! preg_match( '#\s#', (string) $name ) ) {
$string = aioseo()->helpers->pregReplace( "#%%cf_$name%%#", "#custom_field-$name", $string );
}
}
}
if ( preg_match_all( '#%%tax_([^%]*)%%#', (string) $string, $matches ) && ! empty( $matches[1] ) ) {
foreach ( $matches[1] as $name ) {
if ( ! preg_match( '#\s#', (string) $name ) ) {
$string = aioseo()->helpers->pregReplace( "#%%tax_$name%%#", "#tax_name-$name", $string );
}
}
}
foreach ( $macros as $macro => $tag ) {
$string = aioseo()->helpers->pregReplace( "#$macro(?![a-zA-Z0-9_])#im", $tag, $string );
}
// Strip out all remaining tags.
$string = aioseo()->helpers->pregReplace( '/%[^\%\s]*\([^\%]*\)%/i', '', aioseo()->helpers->pregReplace( '/%[^\%\s]*%/i', '', $string ) );
return trim( $string );
}
/**
* Returns the macro mappings.
*
* @since 4.1.1
*
* @param string $postType The post type.
* @param string $pageType The page type.
* @return array $macros The macros.
*/
protected function getMacros( $postType = null, $pageType = null ) {
$macros = [
'%%sitename%%' => '#site_title',
'%%sitedesc%%' => '#tagline',
'%%sep%%' => '#separator_sa',
'%%term_title%%' => '#taxonomy_title',
'%%term_description%%' => '#taxonomy_description',
'%%category_description%%' => '#taxonomy_description',
'%%tag_description%%' => '#taxonomy_description',
'%%primary_category%%' => '#taxonomy_title',
'%%archive_title%%' => '#archive_title',
'%%pagenumber%%' => '#page_number',
'%%caption%%' => '#attachment_caption',
'%%name%%' => '#author_first_name #author_last_name',
'%%user_description%%' => '#author_bio',
'%%date%%' => '#archive_date',
'%%currentday%%' => '#current_day',
'%%currentmonth%%' => '#current_month',
'%%currentyear%%' => '#current_year',
'%%searchphrase%%' => '#search_term',
'%%AUTHORLINK%%' => '#author_link',
'%%POSTLINK%%' => '#post_link',
'%%BLOGLINK%%' => '#site_link',
'%%category%%' => '#categories',
'%%parent_title%%' => '#parent_title',
'%%wc_sku%%' => '#woocommerce_sku',
'%%wc_price%%' => '#woocommerce_price',
'%%wc_brand%%' => '#woocommerce_brand',
'%%excerpt%%' => '#post_excerpt',
'%%excerpt_only%%' => '#post_excerpt_only'
/* '%%tag%%' => '',
'%%id%%' => '',
'%%page%%' => '',
'%%modified%%' => '',
'%%pagetotal%%' => '',
'%%focuskw%%' => '',
'%%term404%%' => '',
'%%ct_desc_[^%]*%%' => '' */
];
if ( $postType ) {
$postType = get_post_type_object( $postType );
if ( ! empty( $postType ) ) {
$macros += [
'%%pt_single%%' => $postType->labels->singular_name,
'%%pt_plural%%' => $postType->labels->name,
];
}
}
switch ( $pageType ) {
case 'archive':
$macros['%%title%%'] = '#archive_title';
break;
case 'term':
$macros['%%title%%'] = '#taxonomy_title';
break;
default:
$macros['%%title%%'] = '#post_title';
break;
}
// Strip all other tags.
$macros['%%[^%]*%%'] = '';
return $macros;
}
} home/xbodynamge/dev/wp-content/plugins/all-in-one-seo-pack/app/Common/Sitemap/Helpers.php 0000644 00000043214 15114514650 0025354 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Sitemap;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Contains general helper methods specific to the sitemap.
*
* @since 4.0.0
*/
class Helpers {
/**
* Used to track the performance of the sitemap.
*
* @since 4.0.0
*
* @var array
* $memory The peak memory that is required to generate the sitemap.
* $time The time that is required to generate the sitemap.
*/
private $performance;
/**
* Returns the sitemap filename.
*
* @since 4.0.0
*
* @param string $type The sitemap type. We pass it in when we need to get the filename for a specific sitemap outside of the context of the sitemap.
* @return string The sitemap filename.
*/
public function filename( $type = '' ) {
if ( ! $type ) {
$type = isset( aioseo()->sitemap->type ) ? aioseo()->sitemap->type : 'general';
}
return apply_filters( 'aioseo_sitemap_filename', aioseo()->options->sitemap->$type->filename );
}
/**
* Returns the last modified post.
*
* @since 4.0.0
*
* @param array $additionalArgs Any additional arguments for the post query.
* @return mixed WP_Post object or false.
*/
public function lastModifiedPost( $additionalArgs = [] ) {
$args = [
'post_status' => 'publish',
'posts_per_page' => 1,
'orderby ' => 'modified',
'order' => 'ASC'
];
if ( $additionalArgs ) {
foreach ( $additionalArgs as $k => $v ) {
$args[ $k ] = $v;
}
}
$query = ( new \WP_Query( $args ) );
if ( ! $query->post_count ) {
return false;
}
return $query->posts[0];
}
/**
* Returns the timestamp of the last modified post.
*
* @since 4.0.0
*
* @param array $postTypes The relevant post types.
* @param array $additionalArgs Any additional arguments for the post query.
* @return string Formatted date string (ISO 8601).
*/
public function lastModifiedPostTime( $postTypes = [ 'post', 'page' ], $additionalArgs = [] ) {
if ( is_array( $postTypes ) ) {
$postTypes = implode( "', '", $postTypes );
}
$query = aioseo()->core->db
->start( aioseo()->core->db->db->posts . ' as p', true )
->select( 'MAX(`p`.`post_modified_gmt`) as last_modified' )
->where( 'p.post_status', 'publish' )
->whereRaw( "( `p`.`post_type` IN ( '$postTypes' ) )" );
if ( isset( $additionalArgs['author'] ) ) {
$query->where( 'p.post_author', $additionalArgs['author'] );
}
$lastModified = $query->run()
->result();
return ! empty( $lastModified[0]->last_modified )
? aioseo()->helpers->dateTimeToIso8601( $lastModified[0]->last_modified )
: '';
}
/**
* Returns the timestamp of the last modified additional page.
*
* @since 4.0.0
*
* @return string Formatted date string (ISO 8601).
*/
public function lastModifiedAdditionalPagesTime() {
$pages = [];
if ( 'posts' === get_option( 'show_on_front' ) || ! in_array( 'page', $this->includedPostTypes(), true ) ) {
$frontPageId = (int) get_option( 'page_on_front' );
$post = aioseo()->helpers->getPost( $frontPageId );
$pages[] = $post ? strtotime( $post->post_modified_gmt ) : strtotime( aioseo()->sitemap->helpers->lastModifiedPostTime() );
}
foreach ( aioseo()->options->sitemap->general->additionalPages->pages as $page ) {
$additionalPage = json_decode( $page );
if ( empty( $additionalPage->url ) ) {
continue;
}
$pages[] = strtotime( $additionalPage->lastModified );
}
if ( empty( $pages ) ) {
$additionalPages = apply_filters( 'aioseo_sitemap_additional_pages', [] );
if ( empty( $additionalPages ) ) {
return false;
}
$lastModified = 0;
$timestamp = time();
foreach ( $additionalPages as $page ) {
if ( empty( $page['lastmod'] ) ) {
continue;
}
$timestamp = strtotime( $page['lastmod'] );
if ( ! $timestamp ) {
continue;
}
if ( $lastModified < $timestamp ) {
$lastModified = $timestamp;
}
}
return 0 !== $lastModified ? aioseo()->helpers->dateTimeToIso8601( gmdate( 'Y-m-d H:i:s', $timestamp ) ) : false;
}
return aioseo()->helpers->dateTimeToIso8601( gmdate( 'Y-m-d H:i:s', max( $pages ) ) );
}
/**
* Formats a given image URL for usage in the sitemap.
*
* @since 4.0.0
*
* @param string $url The URL.
* @return string The formatted URL.
*/
public function formatUrl( $url ) {
// Remove URL parameters.
$url = strtok( $url, '?' );
$url = htmlspecialchars( $url, ENT_COMPAT, 'UTF-8', false );
return aioseo()->helpers->makeUrlAbsolute( $url );
}
/**
* Logs the performance of the sitemap for debugging purposes.
*
* @since 4.0.0
*
* @return void
*/
public function logPerformance() {
// Start logging the performance.
if ( ! $this->performance ) {
$this->performance['time'] = microtime( true );
$this->performance['memory'] = ( memory_get_peak_usage( true ) / 1024 ) / 1024;
return;
}
// Stop logging the performance.
$time = microtime( true ) - $this->performance['time'];
$memory = $this->performance['memory'];
$type = aioseo()->sitemap->type;
$indexName = aioseo()->sitemap->indexName;
// phpcs:disable WordPress.PHP.DevelopmentFunctions
error_log( wp_json_encode( "$indexName index of $type sitemap generated in $time seconds using a maximum of $memory mb of memory." ) );
// phpcs:enable WordPress.PHP.DevelopmentFunctions
}
/**
* Returns the post types that should be included in the sitemap.
*
* @since 4.0.0
*
* @param boolean $hasArchivesOnly Whether or not to only include post types which have archives.
* @return array $postTypes The included post types.
*/
public function includedPostTypes( $hasArchivesOnly = false ) {
if ( aioseo()->options->sitemap->{aioseo()->sitemap->type}->postTypes->all ) {
$postTypes = aioseo()->helpers->getPublicPostTypes( true, $hasArchivesOnly );
} else {
$postTypes = aioseo()->options->sitemap->{aioseo()->sitemap->type}->postTypes->included;
}
if ( ! $postTypes ) {
return $postTypes;
}
$options = aioseo()->options->noConflict();
$dynamicOptions = aioseo()->dynamicOptions->noConflict();
$publicPostTypes = aioseo()->helpers->getPublicPostTypes( true, $hasArchivesOnly );
foreach ( $postTypes as $postType ) {
// Check if post type is no longer registered.
if ( ! in_array( $postType, $publicPostTypes, true ) || ! $dynamicOptions->searchAppearance->postTypes->has( $postType ) ) {
$postTypes = aioseo()->helpers->unsetValue( $postTypes, $postType );
continue;
}
// Check if post type isn't noindexed.
if ( aioseo()->helpers->isPostTypeNoindexed( $postType ) ) {
if ( ! $this->checkForIndexedPost( $postType ) ) {
$postTypes = aioseo()->helpers->unsetValue( $postTypes, $postType );
continue;
}
}
if (
$dynamicOptions->searchAppearance->postTypes->$postType->advanced->robotsMeta->default &&
! $options->searchAppearance->advanced->globalRobotsMeta->default &&
$options->searchAppearance->advanced->globalRobotsMeta->noindex
) {
if ( ! $this->checkForIndexedPost( $postType ) ) {
$postTypes = aioseo()->helpers->unsetValue( $postTypes, $postType );
}
}
}
return $postTypes;
}
/**
* Checks if any post is explicitly indexed when the post type is noindexed.
*
* @since 4.0.0
*
* @param string $postType The post type to check for.
* @return bool Whether or not there is an indexed post.
*/
private function checkForIndexedPost( $postType ) {
$db = aioseo()->core->db->noConflict();
$posts = $db->start( aioseo()->core->db->db->posts . ' as p', true )
->select( 'p.ID' )
->join( 'aioseo_posts as ap', '`ap`.`post_id` = `p`.`ID`' )
->where( 'p.post_status', 'attachment' === $postType ? 'inherit' : 'publish' )
->where( 'p.post_type', $postType )
->whereRaw( '( `ap`.`robots_default` = 0 AND `ap`.`robots_noindex` = 0 )' )
->limit( 1 )
->run()
->result();
if ( $posts && count( $posts ) ) {
return true;
}
return false;
}
/**
* Returns the taxonomies that should be included in the sitemap.
*
* @since 4.0.0
*
* @return array The included taxonomies.
*/
public function includedTaxonomies() {
$taxonomies = [];
if ( aioseo()->options->sitemap->{aioseo()->sitemap->type}->taxonomies->all ) {
$taxonomies = get_taxonomies();
} else {
$taxonomies = aioseo()->options->sitemap->{aioseo()->sitemap->type}->taxonomies->included;
}
if ( ! $taxonomies ) {
return [];
}
$options = aioseo()->options->noConflict();
$dynamicOptions = aioseo()->dynamicOptions->noConflict();
$publicTaxonomies = aioseo()->helpers->getPublicTaxonomies( true );
foreach ( $taxonomies as $taxonomy ) {
if (
aioseo()->helpers->isWooCommerceActive() &&
aioseo()->helpers->isWooCommerceProductAttribute( $taxonomy )
) {
$taxonomies = aioseo()->helpers->unsetValue( $taxonomies, $taxonomy );
if ( ! in_array( 'product_attributes', $taxonomies, true ) ) {
$taxonomies[] = 'product_attributes';
}
continue;
}
// Check if taxonomy is no longer registered.
if ( ! in_array( $taxonomy, $publicTaxonomies, true ) || ! $dynamicOptions->searchAppearance->taxonomies->has( $taxonomy ) ) {
$taxonomies = aioseo()->helpers->unsetValue( $taxonomies, $taxonomy );
continue;
}
// Check if taxonomy isn't noindexed.
if ( aioseo()->helpers->isTaxonomyNoindexed( $taxonomy ) ) {
$taxonomies = aioseo()->helpers->unsetValue( $taxonomies, $taxonomy );
continue;
}
if (
$dynamicOptions->searchAppearance->taxonomies->$taxonomy->advanced->robotsMeta->default &&
! $options->searchAppearance->advanced->globalRobotsMeta->default &&
$options->searchAppearance->advanced->globalRobotsMeta->noindex
) {
$taxonomies = aioseo()->helpers->unsetValue( $taxonomies, $taxonomy );
continue;
}
}
return $taxonomies;
}
/**
* Splits sitemap entries into chuncks based on the max. amount of URLs per index.
*
* @since 4.0.0
*
* @param array $entries The sitemap entries.
* @return array The chunked sitemap entries.
*/
public function chunkEntries( $entries ) {
return array_chunk( $entries, aioseo()->sitemap->linksPerIndex, true );
}
/**
* Formats the last Modified date of a user-submitted additional page as an ISO 8601 date.
*
* @since 4.0.0
*
* @param object $page The additional page object.
* @return string The formatted datetime.
*/
public function lastModifiedAdditionalPage( $page ) {
return aioseo()->helpers->isValidDate( $page->lastModified ) ? gmdate( 'c', strtotime( $page->lastModified ) ) : '';
}
/**
* Returns a list of excluded post IDs.
*
* @since 4.0.0
*
* @return string The excluded IDs.
*/
public function excludedPosts() {
static $excludedPosts = null;
if ( null === $excludedPosts ) {
$excludedPosts = $this->excludedObjectIds( 'excludePosts' );
}
return $excludedPosts;
}
/**
* Returns a list of excluded term IDs.
*
* @since 4.0.0
*
* @return string The excluded IDs.
*/
public function excludedTerms() {
static $excludedTerms = null;
if ( null === $excludedTerms ) {
$excludedTerms = $this->excludedObjectIds( 'excludeTerms' );
}
return $excludedTerms;
}
/**
* Returns a list of excluded IDs for a given option as a comma separated string.
*
* Helper method for excludedPosts() and excludedTerms().
*
* @since 4.0.0
* @version 4.4.7 Improved method name.
*
* @param string $option The option name.
* @return string The excluded IDs.
*/
private function excludedObjectIds( $option ) {
$type = aioseo()->sitemap->type;
// The RSS Sitemap needs to exclude whatever is excluded in the general sitemap.
if ( 'rss' === $type ) {
$type = 'general';
}
// Allow WPML to filter out hidden language posts/terms.
$hiddenObjectIds = [];
if ( aioseo()->helpers->isWpmlActive() ) {
$hiddenLanguages = apply_filters( 'wpml_setting', [], 'hidden_languages' );
foreach ( $hiddenLanguages as $language ) {
$objectTypes = [];
if ( 'excludePosts' === $option ) {
$objectTypes = aioseo()->sitemap->helpers->includedPostTypes();
$objectTypes = array_map( function( $postType ) {
return "post_{$postType}";
}, $objectTypes );
}
if ( 'excludeTerms' === $option ) {
$objectTypes = aioseo()->sitemap->helpers->includedTaxonomies();
$objectTypes = array_map( function( $taxonomy ) {
return "tax_{$taxonomy}";
}, $objectTypes );
}
$dbNoConflict = aioseo()->core->db->noConflict();
$rows = $dbNoConflict->start( 'icl_translations' )
->select( 'element_id' )
->whereIn( 'element_type', $objectTypes )
->where( 'language_code', $language )
->run()
->result();
$ids = array_map( function( $row ) {
return (int) $row->element_id;
}, $rows );
$hiddenObjectIds = array_merge( $hiddenObjectIds, $ids );
}
}
$hasFilter = has_filter( 'aioseo_sitemap_' . aioseo()->helpers->toSnakeCase( $option ) );
$advanced = aioseo()->options->sitemap->$type->advancedSettings->enable;
$excluded = array_merge( $hiddenObjectIds, aioseo()->options->sitemap->{$type}->advancedSettings->{$option} );
if (
! $advanced &&
empty( $excluded ) &&
! $hasFilter
) {
return '';
}
$ids = [];
foreach ( $excluded as $object ) {
if ( is_numeric( $object ) ) {
$ids[] = (int) $object;
continue;
}
$object = json_decode( $object );
if ( is_int( $object->value ) ) {
$ids[] = $object->value;
}
}
if ( 'excludePosts' === $option ) {
$ids = apply_filters( 'aioseo_sitemap_exclude_posts', $ids, $type );
}
if ( 'excludeTerms' === $option ) {
$ids = apply_filters( 'aioseo_sitemap_exclude_terms', $ids, $type );
}
return count( $ids ) ? esc_sql( implode( ', ', $ids ) ) : '';
}
/**
* Returns the URLs of all active sitemaps.
*
* @since 4.0.0
* @version 4.6.2 Removed the prefix from the list of URLs.
*
* @return array $urls The sitemap URLs.
*/
public function getSitemapUrls() {
static $urls = [];
if ( $urls ) {
return $urls;
}
$addonsUrls = array_filter( aioseo()->addons->doAddonFunction( 'helpers', 'getSitemapUrls' ) );
foreach ( $addonsUrls as $addonUrls ) {
$urls = array_merge( $urls, $addonUrls );
}
if ( aioseo()->options->sitemap->general->enable ) {
$urls[] = $this->getUrl( 'general' );
}
if ( aioseo()->options->sitemap->rss->enable ) {
$urls[] = $this->getUrl( 'rss' );
}
return $urls;
}
/**
* Returns the URLs of all active sitemaps with the 'Sitemap: ' prefix.
*
* @since 4.6.2
*
* @return array $urls The sitemap URLs.
*/
public function getSitemapUrlsPrefixed() {
$urls = $this->getSitemapUrls();
foreach ( $urls as &$url ) {
$url = 'Sitemap: ' . $url;
}
return $urls;
}
/**
* Extracts existing sitemap URLs from the robots.txt file.
* We need this in case users have existing sitemap directives added to their robots.txt file.
*
* @since 4.0.10
* @version 4.4.9
*
* @return array The sitemap URLs.
*/
public function extractSitemapUrlsFromRobotsTxt() {
// First, we need to remove our filter, so that it doesn't run unintentionally.
remove_filter( 'robots_txt', [ aioseo()->robotsTxt, 'buildRules' ], 10000 );
$robotsTxt = apply_filters( 'robots_txt', '', true );
add_filter( 'robots_txt', [ aioseo()->robotsTxt, 'buildRules' ], 10000 );
if ( ! $robotsTxt ) {
return [];
}
$lines = explode( "\n", $robotsTxt );
if ( ! is_array( $lines ) || ! count( $lines ) ) {
return [];
}
return aioseo()->robotsTxt->extractSitemapUrls( $robotsTxt );
}
/**
* Returns the URL of the given sitemap type.
*
* @since 4.1.5
*
* @param string $type The sitemap type.
* @return string The sitemap URL.
*/
public function getUrl( $type ) {
$url = home_url( 'sitemap.xml' );
if ( 'rss' === $type ) {
$url = home_url( 'sitemap.rss' );
}
if ( 'general' === $type ) {
// Check if user has a custom filename from the V3 migration.
$filename = $this->filename( 'general' ) ?: 'sitemap';
$url = home_url( $filename . '.xml' );
}
$addon = aioseo()->addons->getLoadedAddon( $type );
if ( ! empty( $addon->helpers ) && method_exists( $addon->helpers, 'getUrl' ) ) {
$url = $addon->helpers->getUrl();
}
return $url;
}
/**
* Returns if images should be excluded from the sitemap.
*
* @since 4.2.2
*
* @return bool
*/
public function excludeImages() {
$shouldExclude = aioseo()->options->sitemap->general->advancedSettings->enable && aioseo()->options->sitemap->general->advancedSettings->excludeImages;
return apply_filters( 'aioseo_sitemap_exclude_images', $shouldExclude );
}
/**
* Returns the post types to check against for the author sitemap.
*
* @since 4.4.4
*
* @return array The post types.
*/
public function getAuthorPostTypes() {
// By default, WP only considers posts for author archives, but users can include additional post types.
$postTypes = [ 'post' ];
return apply_filters( 'aioseo_sitemap_author_post_types', $postTypes );
}
/**
* Decode the Urls from Posts and Terms so they properly show in the Sitemap.
*
* @since 4.6.9
*
* @param mixed $data The data to decode.
* @return array $result The converted data with decoded URLs.
*/
public function decodeSitemapEntries( $data ) {
$result = [];
if ( empty( $data ) ) {
return $result;
}
// Decode Url to properly show Unicode Characters.
foreach ( $data as $item ) {
if ( isset( $item['loc'] ) ) {
$item['loc'] = aioseo()->helpers->decodeUrl( $item['loc'] );
}
// This is for the RSS Sitemap.
if ( isset( $item['guid'] ) ) {
$item['guid'] = aioseo()->helpers->decodeUrl( $item['guid'] );
}
$result[] = $item;
}
return $result;
}
} home/xbodynamge/dev/wp-content/plugins/all-in-one-seo-pack/app/Common/Schema/Helpers.php 0000644 00000006776 15114516557 0025176 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Contains helper methods for our schema classes.
*
* @since 4.2.5
*/
class Helpers {
/**
* Checks whether the schema markup feature is enabled.
*
* @since 4.2.5
*
* @return bool Whether the schema markup feature is enabled or not.
*/
public function isEnabled() {
$isEnabled = ! in_array( 'enableSchemaMarkup', aioseo()->internalOptions->deprecatedOptions, true ) || aioseo()->options->deprecated->searchAppearance->global->schema->enableSchemaMarkup;
return ! apply_filters( 'aioseo_schema_disable', ! $isEnabled );
}
/**
* Strips HTML and removes all blank properties in each of our graphs.
* Also parses properties that might contain smart tags.
*
* @since 4.0.13
* @version 4.2.5
*
* @param array $data The graph data.
* @param string $parentKey The key of the group parent (optional).
* @param bool $replaceTags Whether the smart tags should be replaced.
* @return array The cleaned graph data.
*/
public function cleanAndParseData( $data, $parentKey = '', $replaceTags = true ) {
foreach ( $data as $k => &$v ) {
if ( is_numeric( $v ) || is_bool( $v ) || is_null( $v ) ) {
// Do nothing.
} elseif ( is_array( $v ) ) {
$v = $this->cleanAndParseData( $v, $k, $replaceTags );
} else {
// Check if the prop can contain some HTML tags.
if (
isset( aioseo()->schema->htmlAllowedFields[ $parentKey ] ) &&
in_array( $k, aioseo()->schema->htmlAllowedFields[ $parentKey ], true )
) {
$v = trim( wp_kses_post( $v ) );
} else {
$v = trim( wp_strip_all_tags( $v ) );
}
$v = $replaceTags ? aioseo()->tags->replaceTags( $v, get_the_ID() ) : $v;
}
if ( empty( $v ) && ! in_array( $k, aioseo()->schema->nullableFields, true ) ) {
unset( $data[ $k ] );
} else {
$data[ $k ] = $v;
}
}
return $data;
}
/**
* Sorts the schema data and then returns it as JSON.
* We temporarily change the floating point precision in order to prevent rounding errors.
* Otherwise e.g. 4.9 could be output as 4.90000004.
*
* @since 4.2.7
*
* @param array $schema The schema data.
* @param bool $replaceTags Whether the smart tags should be replaced.
* @return string The schema as JSON.
*/
public function getOutput( $schema, $replaceTags = true ) {
$schema['@graph'] = apply_filters( 'aioseo_schema_output', $schema['@graph'] );
$schema['@graph'] = $this->cleanAndParseData( $schema['@graph'], '', $replaceTags );
// Sort the graphs alphabetically.
usort( $schema['@graph'], function ( $a, $b ) {
$typeA = $a['@type'] ?? null;
$typeB = $b['@type'] ?? null;
if ( is_null( $typeA ) || is_array( $typeA ) ) {
return 1;
}
if ( is_null( $typeB ) || is_array( $typeB ) ) {
return -1;
}
return strcmp( $typeA, $typeB );
} );
// Allow users to control the default json_encode flags.
// Some users report better SEO performance when non-Latin unicode characters are not escaped.
$jsonFlags = apply_filters( 'aioseo_schema_json_flags', 0 );
$json = isset( $_GET['aioseo-dev'] ) || aioseo()->schema->generatingValidatorOutput // phpcs:ignore HM.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Recommended
? aioseo()->helpers->wpJsonEncode( $schema, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE )
: aioseo()->helpers->wpJsonEncode( $schema, $jsonFlags );
return $json;
}
} home/xbodynamge/dev/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Helpers.php 0000644 00000024225 15114517201 0025046 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Utils;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Traits\Helpers as TraitHelpers;
/**
* Contains helper functions
*
* @since 4.0.0
*/
class Helpers {
use TraitHelpers\Api;
use TraitHelpers\Arrays;
use TraitHelpers\Buffer;
use TraitHelpers\Constants;
use TraitHelpers\Deprecated;
use TraitHelpers\DateTime;
use TraitHelpers\Language;
use TraitHelpers\Numbers;
use TraitHelpers\PostType;
use TraitHelpers\Request;
use TraitHelpers\Shortcodes;
use TraitHelpers\Strings;
use TraitHelpers\Svg;
use TraitHelpers\ThirdParty;
use TraitHelpers\Url;
use TraitHelpers\Vue;
use TraitHelpers\Wp;
use TraitHelpers\WpContext;
use TraitHelpers\WpMultisite;
use TraitHelpers\WpUri;
/**
* Generate a UTM URL from the url and medium/content passed in.
*
* @since 4.0.0
*
* @param string $url The URL to parse.
* @param string $medium The UTM medium parameter.
* @param string|null $content The UTM content parameter or null.
* @param boolean $esc Whether or not to escape the URL.
* @return string The new URL.
*/
public function utmUrl( $url, $medium, $content = null, $esc = true ) {
// First, remove any existing utm parameters on the URL.
$url = remove_query_arg( [
'utm_source',
'utm_medium',
'utm_campaign',
'utm_content'
], $url );
// Generate the new arguments.
$args = [
'utm_source' => 'WordPress',
'utm_campaign' => aioseo()->pro ? 'proplugin' : 'liteplugin',
'utm_medium' => $medium
];
// Content is not used by default.
if ( $content ) {
$args['utm_content'] = $content;
}
// Return the new URL.
$url = add_query_arg( $args, $url );
return $esc ? esc_url( $url ) : $url;
}
/**
* Checks if we are in a dev environment or not.
*
* @since 4.1.0
*
* @return boolean True if we are, false if not.
*/
public function isDev() {
return aioseo()->isDev || isset( $_REQUEST['aioseo-dev'] ); // phpcs:ignore HM.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Recommended
}
/**
* Checks if the server is running on Apache.
*
* @since 4.0.0
*
* @return boolean Whether or not it is on apache.
*/
public function isApache() {
if ( ! isset( $_SERVER['SERVER_SOFTWARE'] ) ) {
return false;
}
return stripos( sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ), 'apache' ) !== false;
}
/**
* Checks if the server is running on nginx.
*
* @since 4.0.0
*
* @return bool Whether or not it is on nginx.
*/
public function isNginx() {
if ( ! isset( $_SERVER['SERVER_SOFTWARE'] ) ) {
return false;
}
$server = sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) );
if (
false !== stripos( $server, 'Flywheel' ) ||
false !== stripos( $server, 'nginx' )
) {
return true;
}
return false;
}
/**
* Checks if the server is running on LiteSpeed.
*
* @since 4.5.3
*
* @return bool Whether it is on LiteSpeed.
*/
public function isLiteSpeed() {
if ( ! isset( $_SERVER['SERVER_SOFTWARE'] ) ) {
return false;
}
$server = strtolower( sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) );
return false !== stripos( $server, 'litespeed' );
}
/**
* Returns the server name: Apache, nginx or LiteSpeed.
*
* @since 4.5.3
*
* @return string The server name. An empty string if it's unknown.
*/
public function getServerName() {
if ( aioseo()->helpers->isApache() ) {
return 'apache';
}
if ( aioseo()->helpers->isNginx() ) {
return 'nginx';
}
if ( aioseo()->helpers->isLiteSpeed() ) {
return 'litespeed';
}
return '';
}
/**
* Validate IP addresses.
*
* @since 4.0.0
*
* @param string $ip The IP address to validate.
* @return boolean If the IP address is valid or not.
*/
public function validateIp( $ip ) {
if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) {
return true;
}
if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) ) {
return true;
}
// Doesn't seem to be a valid IP.
return false;
}
/**
* Convert bytes to readable format.
*
* @since 4.0.0
*
* @param integer $bytes The size of the file.
* @return array The original and readable file size.
*/
public function convertFileSize( $bytes ) {
if ( empty( $bytes ) ) {
return [
'original' => 0,
'readable' => '0 B'
];
}
$i = floor( log( $bytes ) / log( 1024 ) );
$sizes = [ 'B', 'KB', 'MB', 'GB', 'TB' ];
return [
'original' => $bytes,
'readable' => sprintf( '%.02F', $bytes / pow( 1024, $i ) ) * 1 . ' ' . $sizes[ $i ]
];
}
/**
* Sanitizes a given option value before we store it in the DB.
*
* Used by the migration and importer classes.
*
* @since 4.0.0
*
* @param mixed $value The value.
* @return mixed $value The sanitized value.
*/
public function sanitizeOption( $value ) {
switch ( gettype( $value ) ) {
case 'boolean':
return (bool) $value;
case 'string':
$value = aioseo()->helpers->decodeHtmlEntities( $value );
return aioseo()->helpers->encodeOutputHtml( wp_strip_all_tags( wp_check_invalid_utf8( trim( $value ) ) ) );
case 'integer':
return intval( $value );
case 'double':
return floatval( $value );
case 'array':
$sanitized = [];
foreach ( (array) $value as $child ) {
$sanitized[] = aioseo()->helpers->sanitizeOption( $child );
}
return $sanitized;
default:
return false;
}
}
/**
* Checks if the given string is serialized, and if so, unserializes it.
* If the serialized string contains an object, we abort to prevent PHP object injection.
*
* @since 4.1.0.2
*
* @param string $string The string.
* @param array|boolean $allowedClasses The allowed classes for unserialize.
* @return string|array The string or unserialized data.
*/
public function maybeUnserialize( $string, $allowedClasses = false ) {
if ( ! is_string( $string ) ) {
return $string;
}
$string = trim( $string );
if ( is_serialized( $string ) ) {
return @unserialize( $string, [ 'allowed_classes' => $allowedClasses ] ); // phpcs:disable PHPCompatibility.FunctionUse.NewFunctionParameters.unserialize_optionsFound
}
return $string;
}
/**
* Returns a deep clone of the given object.
* The built-in PHP clone KW provides a shallow clone. This method returns a deep clone that also clones nested object properties.
* You can use this method to sever the reference to nested objects.
*
* @since 4.4.7
*
* @return object The cloned object.
*/
public function deepClone( $object ) {
return unserialize( serialize( $object ) );
}
/**
* Sanitizes a given variable
*
* @since 4.5.6
*
* @param mixed $variable The variable.
* @param bool $preserveHtml Whether or not to preserve HTML for ALL fields.
* @param array $fieldsToPreserveHtml Specific fields to preserve HTML for.
* @param string $fieldName The name of the current field (when looping over a list).
* @return mixed The sanitized variable.
*/
public function sanitize( $variable, $preserveHtml = false, $fieldsToPreserveHtml = [], $fieldName = '' ) {
$type = gettype( $variable );
switch ( $type ) {
case 'boolean':
return (bool) $variable;
case 'string':
if ( $preserveHtml || in_array( $fieldName, $fieldsToPreserveHtml, true ) ) {
return aioseo()->helpers->decodeHtmlEntities( sanitize_text_field( htmlspecialchars( $variable, ENT_NOQUOTES, 'UTF-8' ) ) );
}
return sanitize_text_field( $variable );
case 'integer':
return intval( $variable );
case 'float':
case 'double':
return floatval( $variable );
case 'array':
$array = [];
foreach ( (array) $variable as $k => $v ) {
$array[ $k ] = $this->sanitize( $v, $preserveHtml, $fieldsToPreserveHtml, $k );
}
return $array;
default:
return false;
}
}
/**
* Return the version number with a filter to enable users to hide the version.
*
* @since 4.3.7
*
* @return string The current version or empty if the filter is active. Using ?aioseo-dev will override the filter.
*/
public function getAioseoVersion() {
$version = aioseo()->version;
if ( ! $this->isDev() && apply_filters( 'aioseo_hide_version_number', false ) ) {
$version = '';
}
return $version;
}
/**
* Retrieves the marketing site articles.
*
* @since 4.7.2
*
* @param bool $fetchImage Whether to fetch the article image.
* @return array The articles or an empty array on failure.
*/
public function fetchAioseoArticles( $fetchImage = false ) {
$items = aioseo()->core->networkCache->get( 'rss_feed' );
if ( null !== $items ) {
return $items;
}
$options = [
'timeout' => 10,
'sslverify' => false,
];
$response = wp_remote_get( 'https://aioseo.com/wp-json/wp/v2/posts?per_page=4', $options );
$body = wp_remote_retrieve_body( $response );
if ( ! $body ) {
return [];
}
$cached = [];
$items = json_decode( $body, true );
foreach ( $items as $k => $item ) {
$cached[ $k ] = [
'url' => $item['link'],
'title' => $item['title']['rendered'],
'date' => date( get_option( 'date_format' ), strtotime( $item['date'] ) ),
'content' => wp_html_excerpt( $item['content']['rendered'], 128, '…' ),
];
if ( $fetchImage ) {
$response = wp_remote_get( $item['_links']['wp:featuredmedia'][0]['href'] ?? '', $options );
$body = wp_remote_retrieve_body( $response );
if ( ! $body ) {
continue;
}
$image = json_decode( $body, true );
$cached[ $k ]['image'] = [
'url' => $image['source_url'] ?? '',
'alt' => $image['alt_text'] ?? '',
'sizes' => $image['media_details']['sizes'] ?? ''
];
}
}
aioseo()->core->networkCache->update( 'rss_feed', $cached, 24 * HOUR_IN_SECONDS );
return $cached;
}
/**
* Returns if the admin bar is enabled.
*
* @since 4.8.1
*
* @return bool Whether the admin bar is enabled.
*/
public function isAdminBarEnabled() {
$showAdminBarMenu = aioseo()->options->advanced->adminBarMenu;
return is_admin_bar_showing() && ( $showAdminBarMenu ?? true );
}
} home/xbodynamge/namtation/wp-content/plugins/all-in-one-seo-pack/app/Common/Meta/Helpers.php 0000644 00000006324 15114524430 0026052 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Meta;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Contains helper methods for the title/description classes.
*
* @since 4.1.2
*/
class Helpers {
use Traits\Helpers\BuddyPress;
/**
* The name of the class where this instance is constructed.
*
* @since 4.1.2
*
* @param string $name The name of the class. Either "title" or "description".
*/
private $name;
/**
* Supported filters we can run after preparing the value.
*
* @since 4.1.2
*
* @var array
*/
private $supportedFilters = [
'title' => 'aioseo_title',
'description' => 'aioseo_description'
];
/**
* Class constructor.
*
* @since 4.1.2
*
* @param string $name The name of the class where this instance is constructed.
*/
public function __construct( $name ) {
$this->name = $name;
}
/**
* Sanitizes the title/description.
*
* @since 4.1.2
*
* @param string $value The value.
* @param int|bool $objectId The post/term ID.
* @param bool $replaceTags Whether the smart tags should be replaced.
* @return string The sanitized value.
*/
public function sanitize( $value, $objectId = false, $replaceTags = false ) {
$value = $replaceTags ? $value : aioseo()->tags->replaceTags( $value, $objectId );
$value = aioseo()->helpers->doShortcodes( $value );
$value = aioseo()->helpers->decodeHtmlEntities( $value );
$value = $this->encodeExceptions( $value );
$value = wp_strip_all_tags( strip_shortcodes( $value ) );
// Because we encoded the exceptions, we need to decode them again first to prevent double encoding later down the line.
$value = aioseo()->helpers->decodeHtmlEntities( $value );
// Trim internal and external whitespace.
$value = preg_replace( '/[\s]+/u', ' ', (string) trim( $value ) );
return aioseo()->helpers->internationalize( $value );
}
/**
* Prepares the title/description before returning it.
*
* @since 4.1.2
*
* @param string $value The value.
* @param int|bool $objectId The post/term ID.
* @param bool $replaceTags Whether the smart tags should be replaced.
* @return string The sanitized value.
*/
public function prepare( $value, $objectId = false, $replaceTags = false ) {
if (
! empty( $value ) &&
! is_admin() &&
1 < aioseo()->helpers->getPageNumber()
) {
$value .= ' ' . trim( aioseo()->options->searchAppearance->advanced->pagedFormat );
}
$value = $replaceTags ? $value : aioseo()->tags->replaceTags( $value, $objectId );
$value = apply_filters( $this->supportedFilters[ $this->name ], $value );
return $this->sanitize( $value, $objectId, $replaceTags );
}
/**
* Encodes a number of exceptions before we strip tags.
* We need this function to allow certain character (combinations) in the title/description.
*
* @since 4.1.1
*
* @param string $string The string.
* @return string $string The string with exceptions encoded.
*/
public function encodeExceptions( $string ) {
$exceptions = [ '<3' ];
foreach ( $exceptions as $exception ) {
$string = preg_replace( "/$exception/", aioseo()->helpers->encodeOutputHtml( $exception ), (string) $string );
}
return $string;
}
} home/xbodynamge/namtation/wp-content/plugins/all-in-one-seo-pack/app/Lite/Utils/Helpers.php 0000644 00000001314 15114524470 0025727 0 ustar 00 <?php
namespace AIOSEO\Plugin\Lite\Utils;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Utils as CommonUtils;
/**
* Contains helper functions.
*
* @since 4.2.4
*/
class Helpers extends CommonUtils\Helpers {
/**
* Get the headers for internal API requests.
*
* @since 4.2.4
*
* @return array An array of headers.
*/
public function getApiHeaders() {
return [];
}
/**
* Get the User Agent for internal API requests.
*
* @since 4.2.4
*
* @return string The User Agent.
*/
public function getApiUserAgent() {
return 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ) . '; AIOSEO/Lite/' . AIOSEO_VERSION;
}
} namtation/wp-content/plugins/all-in-one-seo-pack/app/Common/WritingAssistant/Utils/Helpers.php 0000644 00000043000 15115165753 0031524 0 ustar 00 home/xbodynamge <?php
namespace AIOSEO\Plugin\Common\WritingAssistant\Utils;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Models;
/**
* Helper functions.
*
* @since 4.7.4
*/
class Helpers {
/**
* Gets the data for vue.
*
* @since 4.7.4
*
* @return array An array of data.
*/
public function getStandaloneVueData() {
$keyword = Models\WritingAssistantPost::getKeyword( get_the_ID() );
return [
'postId' => get_the_ID(),
'report' => $keyword,
'keywordText' => ! empty( $keyword->keyword ) ? $keyword->keyword : '',
'contentAnalysis' => Models\WritingAssistantPost::getContentAnalysis( get_the_ID() ),
'seoBoost' => [
'isLoggedIn' => aioseo()->writingAssistant->seoBoost->isLoggedIn(),
'loginUrl' => aioseo()->writingAssistant->seoBoost->getLoginUrl(),
'createAccountUrl' => aioseo()->writingAssistant->seoBoost->getCreateAccountUrl(),
'userOptions' => aioseo()->writingAssistant->seoBoost->getUserOptions()
]
];
}
/**
* Gets the data for vue.
*
* @since 4.7.4
*
* @return array An array of data.
*/
public function getSettingsVueData() {
return [
'seoBoost' => [
'isLoggedIn' => aioseo()->writingAssistant->seoBoost->isLoggedIn(),
'loginUrl' => aioseo()->writingAssistant->seoBoost->getLoginUrl(),
'createAccountUrl' => aioseo()->writingAssistant->seoBoost->getCreateAccountUrl(),
'userOptions' => aioseo()->writingAssistant->seoBoost->getUserOptions(),
'countries' => $this->getCountries(),
'languages' => $this->getLanguages(),
'searchEngines' => $this->getSearchEngines()
]
];
}
/**
* Returns the list of countries.
*
* @since 4.7.7.1
* @version 4.8.3 Moved from SeoBoost/SeoBoost.php
*
* @return array The list of countries.
*/
private function getCountries() {
$countries = [
'AF' => __( 'Afghanistan', 'all-in-one-seo-pack' ),
'AL' => __( 'Albania', 'all-in-one-seo-pack' ),
'DZ' => __( 'Algeria', 'all-in-one-seo-pack' ),
'AS' => __( 'American Samoa', 'all-in-one-seo-pack' ),
'AD' => __( 'Andorra', 'all-in-one-seo-pack' ),
'AO' => __( 'Angola', 'all-in-one-seo-pack' ),
'AI' => __( 'Anguilla', 'all-in-one-seo-pack' ),
'AG' => __( 'Antigua & Barbuda', 'all-in-one-seo-pack' ),
'AR' => __( 'Argentina', 'all-in-one-seo-pack' ),
'AM' => __( 'Armenia', 'all-in-one-seo-pack' ),
'AU' => __( 'Australia', 'all-in-one-seo-pack' ),
'AT' => __( 'Austria', 'all-in-one-seo-pack' ),
'AZ' => __( 'Azerbaijan', 'all-in-one-seo-pack' ),
'BS' => __( 'Bahamas', 'all-in-one-seo-pack' ),
'BH' => __( 'Bahrain', 'all-in-one-seo-pack' ),
'BD' => __( 'Bangladesh', 'all-in-one-seo-pack' ),
'BY' => __( 'Belarus', 'all-in-one-seo-pack' ),
'BE' => __( 'Belgium', 'all-in-one-seo-pack' ),
'BZ' => __( 'Belize', 'all-in-one-seo-pack' ),
'BJ' => __( 'Benin', 'all-in-one-seo-pack' ),
'BT' => __( 'Bhutan', 'all-in-one-seo-pack' ),
'BO' => __( 'Bolivia', 'all-in-one-seo-pack' ),
'BA' => __( 'Bosnia & Herzegovina', 'all-in-one-seo-pack' ),
'BW' => __( 'Botswana', 'all-in-one-seo-pack' ),
'BR' => __( 'Brazil', 'all-in-one-seo-pack' ),
'VG' => __( 'British Virgin Islands', 'all-in-one-seo-pack' ),
'BN' => __( 'Brunei', 'all-in-one-seo-pack' ),
'BG' => __( 'Bulgaria', 'all-in-one-seo-pack' ),
'BF' => __( 'Burkina Faso', 'all-in-one-seo-pack' ),
'BI' => __( 'Burundi', 'all-in-one-seo-pack' ),
'KH' => __( 'Cambodia', 'all-in-one-seo-pack' ),
'CM' => __( 'Cameroon', 'all-in-one-seo-pack' ),
'CA' => __( 'Canada', 'all-in-one-seo-pack' ),
'CV' => __( 'Cape Verde', 'all-in-one-seo-pack' ),
'CF' => __( 'Central African Republic', 'all-in-one-seo-pack' ),
'TD' => __( 'Chad', 'all-in-one-seo-pack' ),
'CL' => __( 'Chile', 'all-in-one-seo-pack' ),
'CO' => __( 'Colombia', 'all-in-one-seo-pack' ),
'CG' => __( 'Congo - Brazzaville', 'all-in-one-seo-pack' ),
'CD' => __( 'Congo - Kinshasa', 'all-in-one-seo-pack' ),
'CK' => __( 'Cook Islands', 'all-in-one-seo-pack' ),
'CR' => __( 'Costa Rica', 'all-in-one-seo-pack' ),
'CI' => __( 'Côte d’Ivoire', 'all-in-one-seo-pack' ),
'HR' => __( 'Croatia', 'all-in-one-seo-pack' ),
'CU' => __( 'Cuba', 'all-in-one-seo-pack' ),
'CY' => __( 'Cyprus', 'all-in-one-seo-pack' ),
'CZ' => __( 'Czechia', 'all-in-one-seo-pack' ),
'DK' => __( 'Denmark', 'all-in-one-seo-pack' ),
'DJ' => __( 'Djibouti', 'all-in-one-seo-pack' ),
'DM' => __( 'Dominica', 'all-in-one-seo-pack' ),
'DO' => __( 'Dominican Republic', 'all-in-one-seo-pack' ),
'EC' => __( 'Ecuador', 'all-in-one-seo-pack' ),
'EG' => __( 'Egypt', 'all-in-one-seo-pack' ),
'SV' => __( 'El Salvador', 'all-in-one-seo-pack' ),
'EE' => __( 'Estonia', 'all-in-one-seo-pack' ),
'ET' => __( 'Ethiopia', 'all-in-one-seo-pack' ),
'FJ' => __( 'Fiji', 'all-in-one-seo-pack' ),
'FI' => __( 'Finland', 'all-in-one-seo-pack' ),
'FR' => __( 'France', 'all-in-one-seo-pack' ),
'GA' => __( 'Gabon', 'all-in-one-seo-pack' ),
'GM' => __( 'Gambia', 'all-in-one-seo-pack' ),
'GE' => __( 'Georgia', 'all-in-one-seo-pack' ),
'DE' => __( 'Germany', 'all-in-one-seo-pack' ),
'GH' => __( 'Ghana', 'all-in-one-seo-pack' ),
'GI' => __( 'Gibraltar', 'all-in-one-seo-pack' ),
'GR' => __( 'Greece', 'all-in-one-seo-pack' ),
'GL' => __( 'Greenland', 'all-in-one-seo-pack' ),
'GT' => __( 'Guatemala', 'all-in-one-seo-pack' ),
'GG' => __( 'Guernsey', 'all-in-one-seo-pack' ),
'GY' => __( 'Guyana', 'all-in-one-seo-pack' ),
'HT' => __( 'Haiti', 'all-in-one-seo-pack' ),
'HN' => __( 'Honduras', 'all-in-one-seo-pack' ),
'HK' => __( 'Hong Kong', 'all-in-one-seo-pack' ),
'HU' => __( 'Hungary', 'all-in-one-seo-pack' ),
'IS' => __( 'Iceland', 'all-in-one-seo-pack' ),
'IN' => __( 'India', 'all-in-one-seo-pack' ),
'ID' => __( 'Indonesia', 'all-in-one-seo-pack' ),
'IQ' => __( 'Iraq', 'all-in-one-seo-pack' ),
'IE' => __( 'Ireland', 'all-in-one-seo-pack' ),
'IM' => __( 'Isle of Man', 'all-in-one-seo-pack' ),
'IL' => __( 'Israel', 'all-in-one-seo-pack' ),
'IT' => __( 'Italy', 'all-in-one-seo-pack' ),
'JM' => __( 'Jamaica', 'all-in-one-seo-pack' ),
'JP' => __( 'Japan', 'all-in-one-seo-pack' ),
'JE' => __( 'Jersey', 'all-in-one-seo-pack' ),
'JO' => __( 'Jordan', 'all-in-one-seo-pack' ),
'KZ' => __( 'Kazakhstan', 'all-in-one-seo-pack' ),
'KE' => __( 'Kenya', 'all-in-one-seo-pack' ),
'KI' => __( 'Kiribati', 'all-in-one-seo-pack' ),
'KW' => __( 'Kuwait', 'all-in-one-seo-pack' ),
'KG' => __( 'Kyrgyzstan', 'all-in-one-seo-pack' ),
'LA' => __( 'Laos', 'all-in-one-seo-pack' ),
'LV' => __( 'Latvia', 'all-in-one-seo-pack' ),
'LB' => __( 'Lebanon', 'all-in-one-seo-pack' ),
'LS' => __( 'Lesotho', 'all-in-one-seo-pack' ),
'LY' => __( 'Libya', 'all-in-one-seo-pack' ),
'LI' => __( 'Liechtenstein', 'all-in-one-seo-pack' ),
'LT' => __( 'Lithuania', 'all-in-one-seo-pack' ),
'LU' => __( 'Luxembourg', 'all-in-one-seo-pack' ),
'MG' => __( 'Madagascar', 'all-in-one-seo-pack' ),
'MW' => __( 'Malawi', 'all-in-one-seo-pack' ),
'MY' => __( 'Malaysia', 'all-in-one-seo-pack' ),
'MV' => __( 'Maldives', 'all-in-one-seo-pack' ),
'ML' => __( 'Mali', 'all-in-one-seo-pack' ),
'MT' => __( 'Malta', 'all-in-one-seo-pack' ),
'MU' => __( 'Mauritius', 'all-in-one-seo-pack' ),
'MX' => __( 'Mexico', 'all-in-one-seo-pack' ),
'FM' => __( 'Micronesia', 'all-in-one-seo-pack' ),
'MD' => __( 'Moldova', 'all-in-one-seo-pack' ),
'MN' => __( 'Mongolia', 'all-in-one-seo-pack' ),
'ME' => __( 'Montenegro', 'all-in-one-seo-pack' ),
'MS' => __( 'Montserrat', 'all-in-one-seo-pack' ),
'MA' => __( 'Morocco', 'all-in-one-seo-pack' ),
'MZ' => __( 'Mozambique', 'all-in-one-seo-pack' ),
'MM' => __( 'Myanmar (Burma)', 'all-in-one-seo-pack' ),
'NA' => __( 'Namibia', 'all-in-one-seo-pack' ),
'NR' => __( 'Nauru', 'all-in-one-seo-pack' ),
'NP' => __( 'Nepal', 'all-in-one-seo-pack' ),
'NL' => __( 'Netherlands', 'all-in-one-seo-pack' ),
'NZ' => __( 'New Zealand', 'all-in-one-seo-pack' ),
'NI' => __( 'Nicaragua', 'all-in-one-seo-pack' ),
'NE' => __( 'Niger', 'all-in-one-seo-pack' ),
'NG' => __( 'Nigeria', 'all-in-one-seo-pack' ),
'NU' => __( 'Niue', 'all-in-one-seo-pack' ),
'MK' => __( 'North Macedonia', 'all-in-one-seo-pack' ),
'NO' => __( 'Norway', 'all-in-one-seo-pack' ),
'OM' => __( 'Oman', 'all-in-one-seo-pack' ),
'PK' => __( 'Pakistan', 'all-in-one-seo-pack' ),
'PS' => __( 'Palestine', 'all-in-one-seo-pack' ),
'PA' => __( 'Panama', 'all-in-one-seo-pack' ),
'PG' => __( 'Papua New Guinea', 'all-in-one-seo-pack' ),
'PY' => __( 'Paraguay', 'all-in-one-seo-pack' ),
'PE' => __( 'Peru', 'all-in-one-seo-pack' ),
'PH' => __( 'Philippines', 'all-in-one-seo-pack' ),
'PN' => __( 'Pitcairn Islands', 'all-in-one-seo-pack' ),
'PL' => __( 'Poland', 'all-in-one-seo-pack' ),
'PT' => __( 'Portugal', 'all-in-one-seo-pack' ),
'PR' => __( 'Puerto Rico', 'all-in-one-seo-pack' ),
'QA' => __( 'Qatar', 'all-in-one-seo-pack' ),
'RO' => __( 'Romania', 'all-in-one-seo-pack' ),
'RU' => __( 'Russia', 'all-in-one-seo-pack' ),
'RW' => __( 'Rwanda', 'all-in-one-seo-pack' ),
'WS' => __( 'Samoa', 'all-in-one-seo-pack' ),
'SM' => __( 'San Marino', 'all-in-one-seo-pack' ),
'ST' => __( 'São Tomé & Príncipe', 'all-in-one-seo-pack' ),
'SA' => __( 'Saudi Arabia', 'all-in-one-seo-pack' ),
'SN' => __( 'Senegal', 'all-in-one-seo-pack' ),
'RS' => __( 'Serbia', 'all-in-one-seo-pack' ),
'SC' => __( 'Seychelles', 'all-in-one-seo-pack' ),
'SL' => __( 'Sierra Leone', 'all-in-one-seo-pack' ),
'SG' => __( 'Singapore', 'all-in-one-seo-pack' ),
'SK' => __( 'Slovakia', 'all-in-one-seo-pack' ),
'SI' => __( 'Slovenia', 'all-in-one-seo-pack' ),
'SB' => __( 'Solomon Islands', 'all-in-one-seo-pack' ),
'SO' => __( 'Somalia', 'all-in-one-seo-pack' ),
'ZA' => __( 'South Africa', 'all-in-one-seo-pack' ),
'KR' => __( 'South Korea', 'all-in-one-seo-pack' ),
'ES' => __( 'Spain', 'all-in-one-seo-pack' ),
'LK' => __( 'Sri Lanka', 'all-in-one-seo-pack' ),
'SH' => __( 'St. Helena', 'all-in-one-seo-pack' ),
'VC' => __( 'St. Vincent & Grenadines', 'all-in-one-seo-pack' ),
'SR' => __( 'Suriname', 'all-in-one-seo-pack' ),
'SE' => __( 'Sweden', 'all-in-one-seo-pack' ),
'CH' => __( 'Switzerland', 'all-in-one-seo-pack' ),
'TW' => __( 'Taiwan', 'all-in-one-seo-pack' ),
'TJ' => __( 'Tajikistan', 'all-in-one-seo-pack' ),
'TZ' => __( 'Tanzania', 'all-in-one-seo-pack' ),
'TH' => __( 'Thailand', 'all-in-one-seo-pack' ),
'TL' => __( 'Timor-Leste', 'all-in-one-seo-pack' ),
'TG' => __( 'Togo', 'all-in-one-seo-pack' ),
'TO' => __( 'Tonga', 'all-in-one-seo-pack' ),
'TT' => __( 'Trinidad & Tobago', 'all-in-one-seo-pack' ),
'TN' => __( 'Tunisia', 'all-in-one-seo-pack' ),
'TR' => __( 'Turkey', 'all-in-one-seo-pack' ),
'TM' => __( 'Turkmenistan', 'all-in-one-seo-pack' ),
'VI' => __( 'U.S. Virgin Islands', 'all-in-one-seo-pack' ),
'UG' => __( 'Uganda', 'all-in-one-seo-pack' ),
'UA' => __( 'Ukraine', 'all-in-one-seo-pack' ),
'AE' => __( 'United Arab Emirates', 'all-in-one-seo-pack' ),
'GB' => __( 'United Kingdom', 'all-in-one-seo-pack' ),
'US' => __( 'United States', 'all-in-one-seo-pack' ),
'UY' => __( 'Uruguay', 'all-in-one-seo-pack' ),
'UZ' => __( 'Uzbekistan', 'all-in-one-seo-pack' ),
'VU' => __( 'Vanuatu', 'all-in-one-seo-pack' ),
'VE' => __( 'Venezuela', 'all-in-one-seo-pack' ),
'VN' => __( 'Vietnam', 'all-in-one-seo-pack' ),
'ZM' => __( 'Zambia', 'all-in-one-seo-pack' ),
'ZW' => __( 'Zimbabwe', 'all-in-one-seo-pack' )
];
return $countries;
}
/**
* Returns the list of languages.
*
* @since 4.7.7.1
* @version 4.8.3 Moved from SeoBoost/SeoBoost.php
*
* @return array The list of languages.
*/
private function getLanguages() {
$languages = [
'ca' => __( 'Catalan', 'all-in-one-seo-pack' ),
'da' => __( 'Danish', 'all-in-one-seo-pack' ),
'nl' => __( 'Dutch', 'all-in-one-seo-pack' ),
'en' => __( 'English', 'all-in-one-seo-pack' ),
'fr' => __( 'French', 'all-in-one-seo-pack' ),
'de' => __( 'German', 'all-in-one-seo-pack' ),
'id' => __( 'Indonesian', 'all-in-one-seo-pack' ),
'it' => __( 'Italian', 'all-in-one-seo-pack' ),
'no' => __( 'Norwegian', 'all-in-one-seo-pack' ),
'pt' => __( 'Portuguese', 'all-in-one-seo-pack' ),
'ro' => __( 'Romanian', 'all-in-one-seo-pack' ),
'es' => __( 'Spanish', 'all-in-one-seo-pack' ),
'sv' => __( 'Swedish', 'all-in-one-seo-pack' ),
'tr' => __( 'Turkish', 'all-in-one-seo-pack' )
];
return $languages;
}
/**
* Returns the list of search engines.
*
* @since 4.7.7.1
* @version 4.8.3 Moved from SeoBoost/SeoBoost.php
*
* @return array The list of search engines.
*/
private function getSearchEngines() {
$searchEngines = [
'AF' => 'google.com.af',
'AL' => 'google.al',
'DZ' => 'google.dz',
'AS' => 'google.as',
'AD' => 'google.ad',
'AO' => 'google.it.ao',
'AI' => 'google.com.ai',
'AG' => 'google.com.ag',
'AR' => 'google.com.ar',
'AM' => 'google.am',
'AU' => 'google.com.au',
'AT' => 'google.at',
'AZ' => 'google.az',
'BS' => 'google.bs',
'BH' => 'google.com.bh',
'BD' => 'google.com.bd',
'BY' => 'google.com.by',
'BE' => 'google.be',
'BZ' => 'google.com.bz',
'BJ' => 'google.bj',
'BT' => 'google.bt',
'BO' => 'google.com.bo',
'BA' => 'google.ba',
'BW' => 'google.co.bw',
'BR' => 'google.com.br',
'VG' => 'google.vg',
'BN' => 'google.com.bn',
'BG' => 'google.bg',
'BF' => 'google.bf',
'BI' => 'google.bi',
'KH' => 'google.com.kh',
'CM' => 'google.cm',
'CA' => 'google.ca',
'CV' => 'google.cv',
'CF' => 'google.cf',
'TD' => 'google.td',
'CL' => 'google.cl',
'CO' => 'google.com.co',
'CG' => 'google.cg',
'CD' => 'google.cd',
'CK' => 'google.co.ck',
'CR' => 'google.co.cr',
'CI' => 'google.ci',
'HR' => 'google.hr',
'CU' => 'google.com.cu',
'CY' => 'google.com.cy',
'CZ' => 'google.cz',
'DK' => 'google.dk',
'DJ' => 'google.dj',
'DM' => 'google.dm',
'DO' => 'google.com.do',
'EC' => 'google.com.ec',
'EG' => 'google.com.eg',
'SV' => 'google.com.sv',
'EE' => 'google.ee',
'ET' => 'google.com.et',
'FJ' => 'google.com.fj',
'FI' => 'google.fi',
'FR' => 'google.fr',
'GA' => 'google.ga',
'GM' => 'google.gm',
'GE' => 'google.ge',
'DE' => 'google.de',
'GH' => 'google.com.gh',
'GI' => 'google.com.gi',
'GR' => 'google.gr',
'GL' => 'google.gl',
'GT' => 'google.com.gt',
'GG' => 'google.gg',
'GY' => 'google.gy',
'HT' => 'google.ht',
'HN' => 'google.hn',
'HK' => 'google.com.hk',
'HU' => 'google.hu',
'IS' => 'google.is',
'IN' => 'google.co.in',
'ID' => 'google.co.id',
'IQ' => 'google.iq',
'IE' => 'google.ie',
'IM' => 'google.co.im',
'IL' => 'google.co.il',
'IT' => 'google.it',
'JM' => 'google.com.jm',
'JP' => 'google.co.jp',
'JE' => 'google.co.je',
'JO' => 'google.jo',
'KZ' => 'google.kz',
'KE' => 'google.co.ke',
'KI' => 'google.ki',
'KW' => 'google.com.kw',
'KG' => 'google.com.kg',
'LA' => 'google.la',
'LV' => 'google.lv',
'LB' => 'google.com.lb',
'LS' => 'google.co.ls',
'LY' => 'google.com.ly',
'LI' => 'google.li',
'LT' => 'google.lt',
'LU' => 'google.lu',
'MG' => 'google.mg',
'MW' => 'google.mw',
'MY' => 'google.com.my',
'MV' => 'google.mv',
'ML' => 'google.ml',
'MT' => 'google.com.mt',
'MU' => 'google.mu',
'MX' => 'google.com.mx',
'FM' => 'google.fm',
'MD' => 'google.md',
'MN' => 'google.mn',
'ME' => 'google.me',
'MS' => 'google.ms',
'MA' => 'google.co.ma',
'MZ' => 'google.co.mz',
'MM' => 'google.com.mm',
'NA' => 'google.com.na',
'NR' => 'google.nr',
'NP' => 'google.com.np',
'NL' => 'google.nl',
'NZ' => 'google.co.nz',
'NI' => 'google.com.ni',
'NE' => 'google.ne',
'NG' => 'google.com.ng',
'NU' => 'google.nu',
'MK' => 'google.mk',
'NO' => 'google.no',
'OM' => 'google.com.om',
'PK' => 'google.com.pk',
'PS' => 'google.ps',
'PA' => 'google.com.pa',
'PG' => 'google.com.pg',
'PY' => 'google.com.py',
'PE' => 'google.com.pe',
'PH' => 'google.com.ph',
'PN' => 'google.pn',
'PL' => 'google.pl',
'PT' => 'google.pt',
'PR' => 'google.com.pr',
'QA' => 'google.com.qa',
'RO' => 'google.ro',
'RU' => 'google.ru',
'RW' => 'google.rw',
'WS' => 'google.as',
'SM' => 'google.sm',
'ST' => 'google.st',
'SA' => 'google.com.sa',
'SN' => 'google.sn',
'RS' => 'google.rs',
'SC' => 'google.sc',
'SL' => 'google.com.sl',
'SG' => 'google.com.sg',
'SK' => 'google.sk',
'SI' => 'google.si',
'SB' => 'google.com.sb',
'SO' => 'google.so',
'ZA' => 'google.co.za',
'KR' => 'google.co.kr',
'ES' => 'google.es',
'LK' => 'google.lk',
'SH' => 'google.sh',
'VC' => 'google.com.vc',
'SR' => 'google.sr',
'SE' => 'google.se',
'CH' => 'google.ch',
'TW' => 'google.com.tw',
'TJ' => 'google.com.tj',
'TZ' => 'google.co.tz',
'TH' => 'google.co.th',
'TL' => 'google.tl',
'TG' => 'google.tg',
'TO' => 'google.to',
'TT' => 'google.tt',
'TN' => 'google.tn',
'TR' => 'google.com.tr',
'TM' => 'google.tm',
'VI' => 'google.co.vi',
'UG' => 'google.co.ug',
'UA' => 'google.com.ua',
'AE' => 'google.ae',
'GB' => 'google.co.uk',
'US' => 'google.com',
'UY' => 'google.com.uy',
'UZ' => 'google.co.uz',
'VU' => 'google.vu',
'VE' => 'google.co.ve',
'VN' => 'google.com.vn',
'ZM' => 'google.co.zm',
'ZW' => 'google.co.zw'
];
return $searchEngines;
}
}