Commit inicial powerservice

This commit is contained in:
Gabriel
2026-10-19 12:45:45 -06:00
commit ad85486fe2
10158 changed files with 2736804 additions and 0 deletions
@@ -0,0 +1,214 @@
<?php
namespace AIOSEO\TableOfContents\Utils;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Access {
/**
* Capabilities for our users.
*
* @since 1.0.0
*
* @var array
*/
protected $capabilities = [
'aioseo_table_of_contents_about_us_page'
];
/**
* Roles we check capabilities against.
*
* @since 1.0.0
*
* @var array
*/
protected $roles = [
'superadmin' => 'superadmin',
'administrator' => 'administrator'
];
/**
* Whether or not we are updating roles.
*
* @since 1.1.0
*
* @var bool
*/
private $isUpdatingRoles = false;
/**
* Adds capabilities into WordPress for the current user.
*
* @since 1.0.0
*
* @return void
*/
public function addCapabilities() {
foreach ( $this->roles as $wpRole => $role ) {
$roleObject = get_role( $wpRole );
if ( ! is_object( $roleObject ) ) {
continue;
}
if ( current_user_can( 'edit_posts' ) || $this->isAdmin() ) {
foreach ( $this->capabilities as $cap ) {
$roleObject->add_cap( $cap );
}
}
}
$this->removeCapabilities();
}
/**
* Removes capabilities for any unknown role.
*
* @since 1.0.0
*
* @return void
*/
public function removeCapabilities() {
$this->isUpdatingRoles = true;
// Clear out capabilities for unknown roles.
$wpRoles = wp_roles();
$allRoles = $wpRoles->roles;
foreach ( $allRoles as $key => $wpRole ) {
$checkRole = is_multisite() ? 'superadmin' : 'administrator';
if ( $checkRole === $key ) {
continue;
}
if ( in_array( $key, $this->roles, true ) ) {
continue;
}
$role = get_role( $key );
if ( empty( $role ) ) {
continue;
}
if ( $this->isAdmin( $key ) ) {
continue;
}
foreach ( $this->capabilities as $capability ) {
if ( $role->has_cap( $capability ) ) {
$role->remove_cap( $capability );
}
}
}
}
/**
* Checks if the current user has the capability.
*
* @since 1.0.0
*
* @param string $capability The capability to check against.
* @param string|null $checkRole A role to check against.
* @return bool Whether or not the user has this capability.
*/
public function hasCapability( $capability, $checkRole = null ) {
// Only admins have access.
if ( $this->isAdmin( $checkRole ) ) {
return true;
}
if (
(
$this->can( 'publish_posts', $checkRole ) ||
$this->can( 'edit_posts', $checkRole )
) &&
false !== strpos( $capability, 'aioseo_table_of_contents_' )
) {
return true;
}
return false;
}
/**
* Gets all the capabilities for the current user.
*
* @since 1.0.0
*
* @param string|null $role A role to check against.
* @return array An array of capabilities.
*/
public function getAllCapabilities( $role = null ) {
$capabilities = [];
foreach ( $this->capabilities as $cap ) {
$capabilities[ $cap ] = $this->hasCapability( $cap, $role );
}
return $capabilities;
}
/**
* If the current user is an admin, or superadmin, they have access to all caps regardless.
*
* @since 1.0.0
*
* @param string|null $role The role to check admin privileges if we have one.
* @return bool Whether not the user/role is an admin.
*/
public function isAdmin( $role = null ) {
if ( $role ) {
if ( ( is_multisite() && 'superadmin' === $role ) || 'administrator' === $role ) {
return true;
}
return false;
}
if ( ( is_multisite() && current_user_can( 'superadmin' ) ) || current_user_can( 'administrator' ) ) {
return true;
}
return false;
}
/**
* Whether the current user (or role) can manage the plugin.
*
* @since 1.0.0
*
* @param string|null $checkRole The role to check.
* @return bool Whether the user/role can manage the plugin.
*/
public function canManage( $checkRole = null ) {
return $this->isAdmin( $checkRole );
}
/**
* Check if the passed in role can publish posts.
*
* @since 1.0.0
*
* @param string $capability The capability to check against.
* @param string $role The role to check.
* @return boolean True if the role can publish.
*/
protected function can( $capability, $role ) {
if ( empty( $role ) ) {
return current_user_can( $capability );
}
$wpRoles = wp_roles();
$allRoles = $wpRoles->roles;
foreach ( $allRoles as $key => $wpRole ) {
if ( $key === $role ) {
$r = get_role( $key );
if ( $r->has_cap( $capability ) ) {
return true;
}
}
}
return false;
}
}
@@ -0,0 +1,304 @@
<?php
namespace AIOSEO\TableOfContents\Utils;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* This class makes sure the Action Scheduler tables always exist.
*
* @since 1.0.0
*/
class ActionScheduler {
/**
* The Action Scheduler group.
*
* @since 1.0.0
*
* @var string
*/
private $actionSchedulerGroup = 'aioseo_table_of_contents';
/**
* Class constructor.
*
* @since 1.0.0
*/
public function __construct() { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
add_action( 'action_scheduler_after_execute', [ $this, 'cleanup' ], 1000, 2 );
add_action( 'plugins_loaded', [ $this, 'maybeRecreateTables' ] );
}
/**
* Maybe register the `{$table_prefix}_actionscheduler_{$suffix}` tables with WordPress and create them if needed.
* Hooked into `plugins_loaded` action hook.
*
* @since 1.0.0
*
* @return void
*/
public function maybeRecreateTables() {
if ( ! is_admin() ) {
return;
}
if ( ! apply_filters( 'action_scheduler_enable_recreate_data_store', true ) ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
return;
}
if (
! class_exists( 'ActionScheduler' ) ||
! class_exists( 'ActionScheduler_HybridStore' ) ||
! class_exists( 'ActionScheduler_StoreSchema' ) ||
! class_exists( 'ActionScheduler_LoggerSchema' )
) {
return;
}
$store = \ActionScheduler::store();
if ( ! is_a( $store, 'ActionScheduler_HybridStore' ) ) {
$store = new \ActionScheduler_HybridStore();
}
$tableList = [
'actionscheduler_actions',
'actionscheduler_logs',
'actionscheduler_groups',
'actionscheduler_claims',
];
foreach ( $tableList as $tableName ) {
if ( ! aioseoTableOfContents()->core->db->tableExists( $tableName ) ) {
add_action( 'action_scheduler/created_table', [ $store, 'set_autoincrement' ], 10, 2 );
$storeSchema = new \ActionScheduler_StoreSchema();
$loggerSchema = new \ActionScheduler_LoggerSchema();
$storeSchema->register_tables( true );
$loggerSchema->register_tables( true );
remove_action( 'action_scheduler/created_table', [ $store, 'set_autoincrement' ] );
break;
}
}
}
/**
* Cleans up the Action Scheduler tables after one of our actions completes.
* Hooked into `action_scheduler_after_execute` action hook.
*
* @since 1.0.0
*
* @param int $actionId The action ID processed.
* @param \ActionScheduler_Action $action Class instance.
* @return void
*/
public function cleanup( $actionId, $action ) {
if (
// Bail if this isn't one of our actions or if we're in a dev environment.
$this->actionSchedulerGroup !== $action->get_group() ||
defined( 'AIOSEO_TABLE_OF_CONTENTS_DEV_VERSION' ) ||
// Bail if the tables don't exist.
! aioseoTableOfContents()->core->db->tableExists( 'actionscheduler_actions' ) ||
! aioseoTableOfContents()->core->db->tableExists( 'actionscheduler_groups' )
) {
return;
}
$prefix = aioseoTableOfContents()->core->db->db->prefix;
// Clean up logs associated with entries in the actions table.
aioseoTableOfContents()->core->db->execute(
"DELETE al FROM {$prefix}actionscheduler_logs as al
JOIN {$prefix}actionscheduler_actions as aa on `aa`.`action_id` = `al`.`action_id`
JOIN {$prefix}actionscheduler_groups as ag on `ag`.`group_id` = `aa`.`group_id`
WHERE `ag`.`slug` = '{$this->actionSchedulerGroup}'
AND `aa`.`status` IN ('complete', 'failed', 'canceled');"
);
// Clean up actions.
aioseoTableOfContents()->core->db->execute(
"DELETE aa FROM {$prefix}actionscheduler_actions as aa
JOIN {$prefix}actionscheduler_groups as ag on `ag`.`group_id` = `aa`.`group_id`
WHERE `ag`.`slug` = '{$this->actionSchedulerGroup}'
AND `aa`.`status` IN ('complete', 'failed', 'canceled');"
);
// Clean up logs where there was no group.
aioseoTableOfContents()->core->db->execute(
"DELETE al FROM {$prefix}actionscheduler_logs as al
JOIN {$prefix}actionscheduler_actions as aa on `aa`.`action_id` = `al`.`action_id`
WHERE `aa`.`hook` LIKE '{$this->actionSchedulerGroup}_%'
AND `aa`.`group_id` = 0
AND `aa`.`status` IN ('complete', 'failed', 'canceled');"
);
// Clean up actions that start with aioseo_ and have no group.
aioseoTableOfContents()->core->db->execute(
"DELETE aa FROM {$prefix}actionscheduler_actions as aa
WHERE `aa`.`hook` LIKE '{$this->actionSchedulerGroup}_%'
AND `aa`.`group_id` = 0
AND `aa`.`status` IN ('complete', 'failed', 'canceled');"
);
}
/**
* Schedules a single action at a specific time in the future.
* @NOTE: This method differs from the one in the main plugin!
*
* @since 1.0.0
* @version 202608.2 Added the $forceSchedule parameter.
*
* @param string $actionName The action name.
* @param int $time The time to add to the current time.
* @param array $args Args passed down to the action.
* @param bool $forceSchedule Whether we should schedule a new action regardless of whether one is already set.
* @return boolean Whether the action was scheduled.
*/
public function scheduleSingle( $actionName, $time, $args = [], $forceSchedule = false ) {
try {
if ( $forceSchedule || empty( $this->getPendingActions( $actionName, $args ) ) ) {
as_schedule_single_action( time() + $time, $actionName, $args, $this->actionSchedulerGroup );
return true;
}
} catch ( \RuntimeException $e ) {
// Nothing needs to happen.
}
return false;
}
/**
* Checks if a given action is already scheduled.
*
* @since 1.0.0
*
* @param string $actionName The action name.
* @param array $args Args passed down to the action.
* @return boolean Whether the action is already scheduled.
*/
public function isScheduled( $actionName, $args = [] ) {
$actions = array_merge(
$this->getRunningActions( $actionName, $args ),
$this->getPendingActions( $actionName, $args )
);
return ! empty( $actions );
}
/**
* Returns the running actions for a given action.
*
* @since 1.0.0
*
* @param string $actionName The action name.
* @param array $args Args passed down to the action.
* @return array The actions.
*/
public function getRunningActions( $actionName, $args = [] ) {
$runningArgs = [
'hook' => $actionName,
'status' => \ActionScheduler_Store::STATUS_RUNNING,
'per_page' => 1
];
if ( empty( $args ) ) {
$runningArgs['args'] = $args;
}
$actions = as_get_scheduled_actions( $runningArgs );
return $actions;
}
/**
* Returns the pending actions for a given action.
*
* @since 1.0.0
*
* @param string $actionName The action name.
* @param array $args Args passed down to the action.
* @return array The actions.
*/
public function getPendingActions( $actionName, $args = [] ) {
$pendingArgs = [
'hook' => $actionName,
'status' => \ActionScheduler_Store::STATUS_PENDING,
'per_page' => 1
];
if ( empty( $args ) ) {
$pendingArgs['args'] = $args;
}
$actions = as_get_scheduled_actions( $pendingArgs );
return $actions;
}
/**
* Unschedule an action.
*
* @since 1.0.0
*
* @param string $actionName The action name to unschedule.
* @param array $args Args passed down to the action.
* @return void
*/
public function unschedule( $actionName, $args = [] ) {
try {
if ( as_next_scheduled_action( $actionName ) ) {
as_unschedule_action( $actionName, $args, $this->actionSchedulerGroup );
}
} catch ( \Exception $e ) {
// Do nothing.
}
}
/**
* Schedules a recurring action.
*
* @since 1.0.0
*
* @param string $actionName The action name.
* @param int $time The seconds to add to the current time.
* @param int $interval The interval in seconds.
* @param array $args Args passed down to the action.
* @return boolean Whether the action was scheduled.
*/
public function scheduleRecurrent( $actionName, $time, $interval = 60, $args = [] ) {
try {
if ( ! $this->isScheduled( $actionName ) ) {
as_schedule_recurring_action( time() + $time, $interval, $actionName, $args, $this->actionSchedulerGroup );
return true;
}
} catch ( \RuntimeException $e ) {
// Nothing needs to happen.
}
return false;
}
/**
* Schedule a single async action.
*
* @since 1.0.0
*
* @param string $actionName The name of the action.
* @param array $args Any relevant arguments.
* @return void
*/
public function scheduleAsync( $actionName, $args = [] ) {
try {
// Run the task immediately using an async action.
as_enqueue_async_action( $actionName, $args, $this->actionSchedulerGroup );
} catch ( \Exception $e ) {
// Do nothing.
}
}
}
@@ -0,0 +1,124 @@
<?php
namespace AIOSEO\TableOfContents\Utils;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\TableOfContents\Traits\Helpers as TraitHelpers;
/**
* Contains helper functions
*
* @since 1.0.0
*/
class Helpers {
use TraitHelpers\Api;
use TraitHelpers\Arrays;
use TraitHelpers\Constants;
use TraitHelpers\DateTime;
use TraitHelpers\Strings;
use TraitHelpers\ThirdParty;
use TraitHelpers\Vue;
use TraitHelpers\Wp;
use TraitHelpers\WpContext;
use TraitHelpers\WpMultisite;
use TraitHelpers\WpUri;
/**
* Checks if we are in a dev environment or not.
*
* @since 1.0.0
*
* @return boolean True if we are, false if not.
*/
public function isDev() {
return aioseoTableOfContents()->isDev || isset( $_REQUEST['aioseo-dev'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
}
/**
* Generates a UTM URL from the URL and medium/content that are passed in.
*
* @since 1.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' => 'toc-plugin',
'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;
}
/**
* Returns the excluded domains.
*
* @since 1.1.1
*
* @return array The excluded domains.
*/
public function getExcludedDomains() {
if ( ! aioseoTableOfContents()->options->advanced->enable ) {
return [];
}
$excludedDomains = aioseoTableOfContents()->options->advanced->excludeDomains;
if ( ! is_string( $excludedDomains ) ) {
return [];
}
$pattern = '/([\.?!][\r\n\s]+|\r|\n|\s{2,})/u';
return array_map( 'trim', preg_split( $pattern, (string) $excludedDomains, -1, PREG_SPLIT_NO_EMPTY ) );
}
/**
* 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 1.2.0
*
* @param string $string The string.
* @return string|array The string or unserialized data.
*/
public function maybeUnserialize( $string ) {
if ( ! is_string( $string ) ) {
return $string;
}
$string = trim( $string );
if ( is_serialized( $string ) && ! $this->stringContains( $string, ';O:' ) ) {
// We want to add extra hardening for PHP versions greater than 5.6.
return version_compare( PHP_VERSION, '7.0', '<' )
? @unserialize( $string )
: @unserialize( $string, [ 'allowed_classes' => false ] ); // phpcs:disable PHPCompatibility.FunctionUse.NewFunctionParameters.unserialize_optionsFound
}
return $string;
}
}
@@ -0,0 +1,222 @@
<?php
namespace AIOSEO\TableOfContents\Utils;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use WP_Error;
/** \WP_Upgrader class */
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
/** \Plugin_Upgrader class */
require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php';
/**
* In WP 5.3 a PHP 5.6 splat operator (...$args) was added to \WP_Upgrader_Skin::feedback().
* We need to remove all calls to *Skin::feedback() method, as we can't override it in own Skins
* without breaking support for PHP 5.3-5.5.
*
* @internal Please do not use this class outside of core AIOSEO development.
*
* @since 1.0.0
*/
class PluginUpgraderSilentAjax extends \Plugin_Upgrader {
/**
* An array of links to install the plugins from.
*
* @since 1.0.0
*
* @var array
*/
public $pluginLinks = [
'aioseo' => 'https://downloads.wordpress.org/plugins/all-in-one-seo-pack.zip',
'brokenLinkChecker' => 'https://downloads.wordpress.org/plugin/broken-link-checker-seo.zip',
'optinMonster' => 'https://downloads.wordpress.org/plugin/optinmonster.zip',
'wpForms' => 'https://downloads.wordpress.org/plugin/wpforms-lite.zip',
'wpConsent' => 'https://downloads.wordpress.org/plugin/wpconsent-cookies-banner-privacy-suite.zip',
'wpVibe' => 'https://downloads.wordpress.org/plugin/vibe-ai.zip',
'universally' => 'https://downloads.wordpress.org/plugin/universally-language-translation-multilingual-tool.zip',
'miLite' => 'https://downloads.wordpress.org/plugin/google-analytics-for-wordpress.zip',
'emLite' => 'https://downloads.wordpress.org/plugin/google-analytics-dashboard-for-wp.zip',
'wpMail' => 'https://downloads.wordpress.org/plugin/wp-mail-smtp.zip',
'rafflePress' => 'https://downloads.wordpress.org/plugin/rafflepress.zip',
'seedProd' => 'https://downloads.wordpress.org/plugin/coming-soon.zip',
'instagramFeed' => 'https://downloads.wordpress.org/plugin/instagram-feed.zip',
'facebookFeed' => 'https://downloads.wordpress.org/plugin/custom-facebook-feed.zip',
'twitterFeed' => 'https://downloads.wordpress.org/plugin/custom-twitter-feeds.zip',
'youTubeFeed' => 'https://downloads.wordpress.org/plugin/feeds-for-youtube.zip',
'pushEngage' => 'https://downloads.wordpress.org/plugins/pushengage.zip',
'sugarCalendar' => 'https://downloads.wordpress.org/plugins/sugar-calendar-lite.zip',
'wpSimplePay' => 'https://downloads.wordpress.org/plugins/stripe.zip',
'easyDigitalDownloads' => 'https://downloads.wordpress.org/plugins/easy-digital-downloads.zip',
'wpcode' => 'https://downloads.wordpress.org/plugin/insert-headers-and-footers.zip',
'searchWp' => '',
'affiliateWp' => '',
'charitable' => 'https://downloads.wordpress.org/plugin/charitable.zip',
'duplicator' => 'https://downloads.wordpress.org/plugin/duplicator.zip',
'uncannyAutomator' => 'https://downloads.wordpress.org/plugin/uncanny-automator.zip',
'pdfEmbedder' => 'https://downloads.wordpress.org/plugin/pdf-embedder.zip',
'reviewsFeed' => 'https://downloads.wordpress.org/plugin/reviews-feed.zip',
'enviraGallery' => 'https://downloads.wordpress.org/plugin/envira-gallery-lite.zip',
'userFeedback' => 'https://downloads.wordpress.org/plugin/userfeedback-lite.zip',
'activeLayer' => 'https://downloads.wordpress.org/plugin/activelayer-anti-spam-spam-protection-for-forms-comments.zip',
'wpChat' => 'https://downloads.wordpress.org/plugin/smashballoon-wpchat-livechat-customer-support.zip'
];
/**
* An array of links to install the plugins from wordpress.org.
*
* @since 1.0.0
*
* @var array
*/
public $wpPluginLinks = [
'aioseo' => 'https://wordpress.org/plugins/all-in-one-seo-pack/',
'optinMonster' => 'https://wordpress.org/plugin/optinmonster/',
'wpForms' => 'https://wordpress.org/plugin/wpforms-lite/',
'wpConsent' => 'https://wordpress.org/plugins/wpconsent-cookies-banner-privacy-suite/',
'wpVibe' => 'https://wordpress.org/plugins/vibe-ai/',
'universally' => 'https://wordpress.org/plugins/universally-language-translation-multilingual-tool/',
'miLite' => 'https://wordpress.org/plugin/google-analytics-for-wordpress/',
'emLite' => 'https://wordpress.org/plugin/google-analytics-dashboard-for-wp/',
'wpMail' => 'https://wordpress.org/plugin/wp-mail-smtp/',
'rafflePress' => 'https://wordpress.org/plugin/rafflepress/',
'seedProd' => 'https://wordpress.org/plugin/coming-soon/',
'instagramFeed' => 'https://wordpress.org/plugin/instagram-feed/',
'facebookFeed' => 'https://wordpress.org/plugin/custom-facebook-feed/',
'twitterFeed' => 'https://wordpress.org/plugin/custom-twitter-feeds/',
'youTubeFeed' => 'https://wordpress.org/plugin/feeds-for-youtube/',
'pushEngage' => 'https://wordpress.org/plugins/pushengage/',
'sugarCalendar' => 'https://wordpress.org/plugins/sugar-calendar-lite/',
'wpSimplePay' => 'https://wordpress.org/plugins/stripe/',
'searchWp' => 'https://searchwp.com/',
'affiliateWp' => 'https://affiliatewp.com/',
'wpcode' => 'https://wordpress.org/plugins/insert-headers-and-footers/',
'charitable' => 'https://wordpress.org/plugins/charitable/',
'duplicator' => 'https://wordpress.org/plugins/duplicator/',
'uncannyAutomator' => 'https://wordpress.org/plugins/uncanny-automator/',
'pdfEmbedder' => 'https://wordpress.org/plugins/pdf-embedder/',
'reviewsFeed' => 'https://wordpress.org/plugins/reviews-feed/',
'enviraGallery' => 'https://wordpress.org/plugins/envira-gallery-lite/',
'userFeedback' => 'https://wordpress.org/plugins/userfeedback-lite/',
'activeLayer' => 'https://wordpress.org/plugins/activelayer-anti-spam-spam-protection-for-forms-comments/',
'wpChat' => 'https://wordpress.org/plugins/smashballoon-wpchat-livechat-customer-support/'
];
/**
* An array of slugs to check if plugins are activated.
*
* @since 1.0.0
*
* @var array
*/
public $pluginSlugs = [
'aioseo' => 'all-in-one-seo-pack/all_in_one_seo_pack.php',
'aioseoPro' => 'all-in-one-seo-pack-pro/all_in_one_seo_pack.php',
'brokenLinkChecker' => 'broken-link-checker-seo/aioseo-broken-link-checker.php',
'optinMonster' => 'optinmonster/optin-monster-wp-api.php',
'wpForms' => 'wpforms-lite/wpforms.php',
'wpFormsPro' => 'wpforms/wpforms.php',
'wpConsent' => 'wpconsent-cookies-banner-privacy-suite/wpconsent.php',
'wpVibe' => 'vibe-ai/vibe-ai.php',
'universally' => 'universally-language-translation-multilingual-tool/universally.php',
'miLite' => 'google-analytics-for-wordpress/googleanalytics.php',
'miPro' => 'google-analytics-premium/googleanalytics-premium.php',
'emLite' => 'google-analytics-dashboard-for-wp/gadwp.php',
'emPro' => 'exactmetrics-premium/exactmetrics-premium.php',
'wpMail' => 'wp-mail-smtp/wp_mail_smtp.php',
'wpMailPro' => 'wp-mail-smtp-pro/wp_mail_smtp.php',
'rafflePress' => 'rafflepress/rafflepress.php',
'rafflePressPro' => 'rafflepress-pro/rafflepress-pro.php',
'seedProd' => 'coming-soon/coming-soon.php',
'seedProdPro' => 'seedprod-coming-soon-pro-5/seedprod-coming-soon-pro-5.php',
'instagramFeed' => 'instagram-feed/instagram-feed.php',
'instagramFeedPro' => 'instagram-feed-pro/instagram-feed.php',
'facebookFeed' => 'custom-facebook-feed/custom-facebook-feed.php',
'facebookFeedPro' => 'custom-facebook-feed-pro/custom-facebook-feed.php',
'twitterFeed' => 'custom-twitter-feeds/custom-twitter-feed.php',
'twitterFeedPro' => 'custom-twitter-feeds-pro/custom-twitter-feed.php',
'youTubeFeed' => 'feeds-for-youtube/youtube-feed.php',
'youTubeFeedPro' => 'youtube-feed-pro/youtube-feed.php',
'pushEngage' => 'pushengage/main.php',
'sugarCalendar' => 'sugar-calendar-lite/sugar-calendar-lite.php',
'sugarCalendarPro' => 'sugar-calendar/sugar-calendar.php',
'wpSimplePay' => 'stripe/stripe-checkout.php',
'wpSimplePayPro' => 'wp-simple-pay-pro-3/simple-pay.php',
'easyDigitalDownloads' => 'easy-digital-downloads/easy-digital-downloads.php',
'easyDigitalDownloadsPro' => 'easy-digital-downloads-pro/easy-digital-downloads.php',
'searchWp' => 'searchwp/index.php',
'affiliateWp' => 'affiliate-wp/affiliate-wp.php',
'wpcode' => 'insert-headers-and-footers/ihaf.php',
'wpcodePro' => 'wpcode-premium/wpcode.php',
'charitable' => 'charitable/charitable.php',
'duplicator' => 'duplicator/duplicator.php',
'uncannyAutomator' => 'uncanny-automator/uncanny-automator.php',
'pdfEmbedder' => 'pdf-embedder/pdf_embedder.php',
'reviewsFeed' => 'reviews-feed/sb-reviews.php',
'enviraGallery' => 'envira-gallery-lite/envira-gallery-lite.php',
'userFeedback' => 'userfeedback-lite/userfeedback.php',
'activeLayer' => 'activelayer-anti-spam-spam-protection-for-forms-comments/activelayer-anti-spam-spam-protection-for-forms-comments.php',
'wpChat' => 'smashballoon-wpchat-livechat-customer-support/wp-chat.php'
];
/**
* An array of links for admin settings.
*
* @since 1.0.0
*
* @var array
*/
public $pluginAdminUrls = [
'aioseo' => 'admin.php?page=aioseo-settings',
'aioseoPro' => 'admin.php?page=aioseo-settings',
'brokenLinkChecker' => 'admin.php?page=broken-link-checker',
'optinMonster' => 'admin.php?page=optin-monster-api-settings',
'wpForms' => 'admin.php?page=wpforms-settings',
'wpFormsPro' => 'admin.php?page=wpforms-settings',
'wpConsent' => 'admin.php?page=wpconsent',
'wpVibe' => 'admin.php?page=vibe-ai',
'universally' => 'admin.php?page=universally_settings',
'miLite' => 'admin.php?page=monsterinsights_settings#/',
'miPro' => 'admin.php?page=monsterinsights_settings#/',
'emLite' => 'admin.php?page=exactmetrics_settings#/',
'emPro' => 'admin.php?page=exactmetrics_settings#/',
'wpMail' => 'admin.php?page=wp-mail-smtp',
'wpMailPro' => 'admin.php?page=wp-mail-smtp',
'seedProd' => 'admin.php?page=seedprod_lite',
'seedProdPro' => 'admin.php?page=seedprod_pro',
'rafflePress' => 'admin.php?page=rafflepress_lite#/settings',
'rafflePressPro' => 'admin.php?page=rafflepress_pro#/settings',
'instagramFeed' => 'admin.php?page=sb-instagram-feed',
'instagramFeedPro' => 'admin.php?page=sb-instagram-feed',
'facebookFeed' => 'admin.php?page=cff-top',
'facebookFeedPro' => 'admin.php?page=cff-top',
'twitterFeed' => 'admin.php?page=ctf-settings',
'twitterFeedPro' => 'admin.php?page=ctf-settings',
'youTubeFeed' => 'admin.php?page=youtube-feed-settings',
'youTubeFeedPro' => 'admin.php?page=youtube-feed-settings',
'pushEngage' => 'admin.php?page=pushengage',
'sugarCalendar' => 'admin.php?page=sugar-calendar',
'sugarCalendarPro' => 'admin.php?page=sugar-calendar',
'wpSimplePay' => 'edit.php?post_type=simple-pay',
'wpSimplePayPro' => 'edit.php?post_type=simple-pay',
'easyDigitalDownloads' => 'edit.php?post_type=download&page=edd-settings',
'easyDigitalDownloadsPro' => 'edit.php?post_type=download&page=edd-settings',
'searchWp' => 'options-general.php?page=searchwp',
'affiliateWp' => 'admin.php?page=affiliate-wp',
'wpcode' => 'admin.php?page=wpcode',
'wpcodePro' => 'admin.php?page=wpcode',
'charitable' => 'admin.php?page=charitable-settings',
'duplicator' => 'admin.php?page=duplicator-settings',
'uncannyAutomator' => 'edit.php?post_type=uo-recipe',
'pdfEmbedder' => 'options-general.php?page=pdf_embedder',
'reviewsFeed' => 'admin.php?page=sbr',
'enviraGallery' => 'edit.php?post_type=envira',
'userFeedback' => 'admin.php?page=userfeedback',
'activeLayer' => 'admin.php?page=activelayer',
'wpChat' => 'admin.php?page=wpchat'
];
}
@@ -0,0 +1,67 @@
<?php
namespace AIOSEO\TableOfContents\Utils;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
require_once ABSPATH . 'wp-admin/includes/plugin.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader-skin.php';
/**
* The PluginSilentUpgraderSkin class.
*
* @internal Please do not use this class outside of core AIOSEO development.
*
* @since 1.0.0
*/
class PluginUpgraderSkin extends \WP_Upgrader_Skin {
/**
* Empty out the header of its HTML content and only check to see if it has
* been performed or not.
*
* @since 1.0.0
*/
public function header() {}
/**
* Empty out the footer of its HTML contents.
*
* @since 1.0.0
*/
public function footer() {}
/**
* Instead of outputting HTML for errors, just return them.
* AJAX request will just ignore it.
*
* @since 1.0.0
*
* @param array $errors Array of errors with the install process.
* @return void
*/
public function error( $errors ) {
if ( ! empty( $errors ) ) {
wp_send_json_error( $errors );
}
}
/**
* Empty out JavaScript output that calls function to decrement the update counts.
*
* @since 1.0.0
*
* @param string $type Type of update count to decrement.
*/
public function decrement_update_count( $type ) {} // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable, PSR1.Methods.CamelCapsMethodName.NotCamelCaps
/**
* @since 1.0.0
*
* @param string $feedback Message data.
* @param mixed ...$args Optional text replacements.
* @return void
*/
public function feedback( $feedback, ...$args ) {} // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
}
@@ -0,0 +1,166 @@
<?php
namespace AIOSEO\TableOfContents\Utils;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Vue Settings for the user.
*
* @since 1.0.0
*/
class VueSettings {
/**
* The name to lookup the settings with.
*
* @since 1.0.0
*
* @var string
*/
private $settingsName = '';
/**
* The settings array.
*
* @since 1.0.0
*
* @var array
*/
private $settings = [];
/**
* All the default settings.
*
* @since 1.0.0
*
* @var array
*/
private $defaults = [
'toggledRadio' => [],
'tablePagination' => []
];
/**
* Class constructor.
*
* @since 1.0.0
*
* @param string $settings List of settings.
*/
public function __construct( $settings = '_aioseo_table_of_contents_settings' ) {
$this->settingsName = $settings;
$userMeta = get_user_meta( get_current_user_id(), $settings, true );
$this->settings = ! empty( $userMeta ) ? array_replace_recursive( $this->defaults, $userMeta ) : $this->defaults;
}
/**
* Retrieves all settings.
*
* @since 1.0.0
*
* @return array List of settings.
*/
public function all() {
return array_replace_recursive( $this->defaults, $this->settings );
}
/**
* Retrieve a setting or null if missing.
*
* @since 1.0.0
*
* @param string $name The name of the property that is missing on the class.
* @param array $arguments The arguments passed into the method.
* @return mixed The value from the settings or default/null.
*/
public function __call( $name, $arguments = [] ) {
$value = isset( $this->settings[ $name ] ) ? $this->settings[ $name ] : ( ! empty( $arguments[0] ) ? $arguments[0] : $this->getDefault( $name ) );
return $value;
}
/**
* Retrieve a setting or null if missing.
*
* @since 1.0.0
*
* @param string $name The name of the property that is missing on the class.
* @return mixed The value from the settings or default/null.
*/
public function __get( $name ) {
$value = isset( $this->settings[ $name ] ) ? $this->settings[ $name ] : $this->getDefault( $name );
return $value;
}
/**
* Sets the settings value and saves to the database.
*
* @since 1.0.0
*
* @param string $name The name of the settings.
* @param mixed $value The value to set.
* @return void
*/
public function __set( $name, $value ) {
$this->settings[ $name ] = $value;
$this->update();
}
/**
* Checks if an settings is set or returns null if not.
*
* @since 1.0.0
*
* @param string $name The name of the settings.
* @return mixed True or null.
*/
public function __isset( $name ) {
return isset( $this->settings[ $name ] ) ? false === empty( $this->settings[ $name ] ) : null;
}
/**
* Unsets the settings value and saves to the database.
*
* @since 1.0.0
*
* @param string $name The name of the settings.
* @return void
*/
public function __unset( $name ) {
if ( ! isset( $this->settings[ $name ] ) ) {
return;
}
unset( $this->settings[ $name ] );
$this->update();
}
/**
* Gets the default value for a setting.
*
* @since 1.0.0
*
* @param string $name The settings name.
* @return mixed The default value.
*/
public function getDefault( $name ) {
return isset( $this->defaults[ $name ] ) ? $this->defaults[ $name ] : null;
}
/**
* Updates the settings in the database.
*
* @since 1.0.0
*
* @return void
*/
public function update() {
update_user_meta( get_current_user_id(), $this->settingsName, $this->settings );
}
}