led. * * @since 4.0.0 * * @return bool True if yes, false if not. */ public function canInstall() { if ( function_exists( 'wp_get_current_user' ) && is_user_logged_in() && ! current_user_can( 'install_plugins' ) && ! aioseo()->helpers->isDoingWpCli() ) { return false; } // Determine whether file modifications are allowed. if ( ! wp_is_file_mod_allowed( 'aioseo_can_install' ) ) { return false; } return true; } /** * Determine if addons/plugins can be updated. * * @since 4.1.6 * * @return bool True if yes, false if not. */ public function canUpdate() { if ( function_exists( 'wp_get_current_user' ) && is_user_logged_in() && ! current_user_can( 'update_plugins' ) && ! aioseo()->helpers->isDoingWpCli() ) { return false; } // Determine whether file modifications are allowed. if ( ! wp_is_file_mod_allowed( 'aioseo_can_update' ) ) { return false; } return true; } /** * Determine if addons/plugins can be activated. * * @since 4.1.3 * * @return bool True if yes, false if not. */ public function canActivate() { if ( function_exists( 'wp_get_current_user' ) && is_user_logged_in() && ! current_user_can( 'activate_plugins' ) && ! aioseo()->helpers->isDoingWpCli() ) { return false; } return true; } /** * Load an addon into aioseo. * * @since 4.1.0 * * @param string $slug * @param object $addon Addon class instance. * @return void */ public function loadAddon( $slug, $addon ) { $this->{$slug} = $addon; $this->loadedAddons[] = $slug; } /** * Return a loaded addon. * * @since 4.1.0 * * @param string $slug * @return object|null */ public function getLoadedAddon( $slug ) { return isset( $this->{$slug} ) ? $this->{$slug} : null; } /** * Returns loaded addons * * @since 4.1.0 * * @return array */ public function getLoadedAddons() { $loadedAddonsList = []; if ( ! empty( $this->loadedAddons ) ) { foreach ( $this->loadedAddons as $addonSlug ) { $loadedAddonsList[ $addonSlug ] = $this->{$addonSlug}; } } return $loadedAddonsList; } /** * Run a function through all addons that support it. * * @since 4.2.3 * * @param string $class The class name. * @param string $function The function name. * @param array $args The args for the function. * @return array The response from each addon. */ public function doAddonFunction( $class, $function, $args = [] ) { $addonResponses = []; foreach ( $this->getLoadedAddons() as $addonSlug => $addon ) { if ( isset( $addon->$class ) && method_exists( $addon->$class, $function ) ) { $addonResponses[ $addonSlug ] = call_user_func_array( [ $addon->$class, $function ], $args ); } } return $addonResponses; } /** * Merges the data for Vue. * * @since 4.4.1 * * @param array $data The data to merge. * @param string $page The current page. * @return array The data. */ public function getVueData( $data = [], $page = null ) { foreach ( $this->getLoadedAddons() as $addon ) { if ( isset( $addon->helpers ) && method_exists( $addon->helpers, 'getVueData' ) ) { $data = array_merge( $data, $addon->helpers->getVueData( $data, $page ) ); } } return $data; } /** * Retrieves a default addon with whatever information is needed if the API cannot be reached. * * @since 4.0.0 * * @param string $sku The sku of the addon. * @return array An array of addon data. */ public function getDefaultAddon( $sku ) { $addons = $this->getDefaultAddons(); $addon = []; foreach ( $addons as $a ) { if ( $a['sku'] === $sku ) { $addon = $a; } } return $addon; } /** * Retrieves a default list of addons if the API cannot be reached. * * @since 4.0.0 * * @return array An array of addons. */ protected function getDefaultAddons() { return json_decode( wp_json_encode( [ [ 'sku' => 'aioseo-eeat', 'name' => 'Author SEO (E-E-A-T)', 'version' => '1.0.0', 'image' => null, 'icon' => 'svg-eeat', 'levels' => [ 'plus', 'pro', 'elite', ], 'currentLevels' => [ 'plus', 'pro', 'elite' ], 'requiresUpgrade' => true, 'description' => '

Optimize your site for Google\'s E-E-A-T ranking factor by proving your writer\'s expertise through author schema markup and new UI elements.

', 'descriptionVersion' => 0, 'productUrl' => 'https://aioseo.com/author-seo-eeat/', 'learnMoreUrl' => 'https://aioseo.com/author-seo-eeat/', 'manageUrl' => 'https://route#aioseo-search-appearance:author-seo', 'basename' => 'aioseo-eeat/aioseo-eeat.php', 'installed' => false, 'isActive' => false, 'canInstall' => false, 'canActivate' => false, 'canUpdate' => false, 'capability' => $this->getManageCapability( 'aioseo-eeat' ), 'minimumVersion' => '0.0.0', 'hasMinimumVersion' => false, 'featured' => 300 ], [ 'sku' => 'aioseo-redirects', 'name' => 'Redirection Manager', 'version' => '1.0.0', 'image' => null, 'icon' => 'svg-redirect', 'levels' => [ 'agency', 'business', 'pro', 'elite' ], 'currentLevels' => [ 'pro', 'elite' ], 'requiresUpgrade' => true, 'description' => '

Our Redirection Manager allows you to easily create and manage redirects for your broken links to avoid confusing search engines and users, as well as losing valuable backlinks. It even automatically sends users and search engines from your old URLs to your new ones.

', // phpcs:ignore Generic.Files.LineLength.MaxExceeded 'descriptionVersion' => 0, 'productUrl' => 'https://aioseo.com/features/redirection-manager/', 'learnMoreUrl' => 'https://aioseo.com/features/redirection-manager/', 'manageUrl' => 'https://route#aioseo-redirects:redirects', 'basename' => 'aioseo-redirects/aioseo-redirects.php', 'installed' => false, 'isActive' => false, 'canInstall' => false, 'canActivate' => false, 'canUpdate' => false, 'capability' => $this->getManageCapability( 'aioseo-redirects' ), 'minimumVersion' => '0.0.0', 'hasMinimumVersion' => false, 'featured' => 200 ], [ 'sku' => 'aioseo-link-assistant', 'name' => 'Link Assistant', 'version' => '1.0.0', 'image' => null, 'icon' => 'svg-link-assistant', 'levels' => [ 'agency', 'pro', 'elite' ], 'currentLevels' => [ 'pro', 'elite' ], 'requiresUpgrade' => true, 'description' => '

Super-charge your SEO with Link Assistant! Get relevant suggestions for adding internal links to older content as well as finding any orphaned posts that have no internal links. Use our reporting feature to see all link suggestions or add them directly from any page or post.

', // phpcs:ignore Generic.Files.LineLength.MaxExceeded 'descriptionVersion' => 0, 'productUrl' => 'https://aioseo.com/feature/internal-link-assistant/', 'learnMoreUrl' => 'https://aioseo.com/feature/internal-link-assistant/', 'manageUrl' => 'https://route#aioseo-link-assistant:overview', 'basename' => 'aioseo-link-assistant/aioseo-link-assistant.php', 'installed' => false, 'isActive' => false, 'canInstall' => false, 'canActivate' => false, 'canUpdate' => false, 'capability' => $this->getManageCapability( 'aioseo-link-assistant' ), 'minimumVersion' => '0.0.0', 'hasMinimumVersion' => false, 'featured' => 100 ], [ 'sku' => 'aioseo-video-sitemap', 'name' => 'Video Sitemap', 'version' => '1.0.0', 'image' => null, 'icon' => 'svg-sitemaps-pro', 'levels' => [ 'individual', 'business', 'agency', 'pro', 'elite' ], 'currentLevels' => [ 'pro', 'elite' ], 'requiresUpgrade' => true, 'description' => '

The Video Sitemap works in much the same way as the XML Sitemap module, it generates an XML Sitemap specifically for video content on your site. Search engines use this information to display rich snippet information in search results.

', // phpcs:ignore Generic.Files.LineLength.MaxExceeded 'descriptionVersion' => 0, 'productUrl' => 'https://aioseo.com/video-sitemap', 'learnMoreUrl' => 'https://aioseo.com/video-sitemap', 'manageUrl' => 'https://route#aioseo-sitemaps:video-sitemap', 'basename' => 'aioseo-video-sitemap/aioseo-video-sitemap.php', 'installed' => false, 'isActive' => false, 'canInstall' => false, 'canActivate' => false, 'canUpdate' => false, 'capability' => $this->getManageCapability( 'aioseo-video-sitemap' ), 'minimumVersion' => '0.0.0', 'hasMinimumVersion' => false ], [ 'sku' => 'aioseo-local-business', 'name' => 'Local Business SEO', 'version' => '1.0.0', 'image' => null, 'icon' => 'svg-local-business', 'levels' => [ 'business', 'agency', 'plus', 'pro', 'elite' ], 'currentLevels' => [ 'plus', 'pro', 'elite' ], 'requiresUpgrade' => true, 'description' => '

Local Business schema markup enables you to tell Google about your business, including your business name, address and phone number, opening hours and price range. This information may be displayed as a Knowledge Graph card or business carousel.

', // phpcs:ignore Generic.Files.LineLength.MaxExceeded 'descriptionVersion' => 0, 'productUrl' => 'https://aioseo.com/local-business', 'learnMoreUrl' => 'https://aioseo.com/local-business', 'manageUrl' => 'https://route#aioseo-local-seo:locations', 'basename' => 'aioseo-local-business/aioseo-local-business.php', 'installed' => false, 'isActive' => false, 'canInstall' => false, 'canActivate' => false, 'canUpdate' => false, 'capability' => $this->getManageCapability( 'aioseo-local-business' ), 'minimumVersion' => '0.0.0', 'hasMinimumVersion' => false ], [ 'sku' => 'aioseo-news-sitemap', 'name' => 'News Sitemap', 'version' => '1.0.0', 'image' => null, 'icon' => 'svg-sitemaps-pro', 'levels' => [ 'business', 'agency', 'pro', 'elite' ], 'currentLevels' => [ 'pro', 'elite' ], 'requiresUpgrade' => true, 'description' => '

Our Google News Sitemap lets you control which content you submit to Google News and only contains articles that were published in the last 48 hours. In order to submit a News Sitemap to Google, you must have added your site to Google’s Publisher Center and had it approved.

', // phpcs:ignore Generic.Files.LineLength.MaxExceeded 'descriptionVersion' => 0, 'productUrl' => 'https://aioseo.com/news-sitemap', 'learnMoreUrl' => 'https://aioseo.com/news-sitemap', 'manageUrl' => 'https://route#aioseo-sitemaps:news-sitemap', 'basename' => 'aioseo-news-sitemap/aioseo-news-sitemap.php', 'installed' => false, 'isActive' => false, 'canInstall' => false, 'canActivate' => false, 'canUpdate' => false, 'capability' => $this->getManageCapability( 'aioseo-news-sitemap' ), 'minimumVersion' => '0.0.0', 'hasMinimumVersion' => false ], [ 'sku' => 'aioseo-index-now', 'name' => 'IndexNow', 'version' => '1.0.0', 'image' => null, 'icon' => 'svg-sitemaps-pro', 'levels' => [ 'agency', 'business', 'basic', 'plus', 'pro', 'elite' ], 'currentLevels' => [ 'basic', 'plus', 'pro', 'elite' ], 'requiresUpgrade' => true, 'description' => '

Add IndexNow support to instantly notify search engines when your content has changed. This helps the search engines to prioritize the changes on your website and helps you rank faster.

', // phpcs:ignore Generic.Files.LineLength.MaxExceeded 'descriptionVersion' => 0, 'downloadUrl' => '', 'productUrl' => 'https://aioseo.com/index-now/', 'learnMoreUrl' => 'https://aioseo.com/index-now/', 'manageUrl' => 'https://route#aioseo-settings:webmaster-tools', 'basename' => 'aioseo-index-now/aioseo-index-now.php', 'installed' => false, 'isActive' => false, 'canInstall' => false, 'canActivate' => false, 'canUpdate' => false, 'capability' => $this->getManageCapability( 'aioseo-index-now' ), 'minimumVersion' => '0.0.0', 'hasMinimumVersion' => false ], [ 'sku' => 'aioseo-rest-api', 'name' => 'REST API', 'version' => '1.0.0', 'image' => null, 'icon' => 'svg-code', 'levels' => [ 'plus', 'pro', 'elite' ], 'currentLevels' => [ 'plus', 'pro', 'elite' ], 'requiresUpgrade' => true, 'description' => '

Manage your post and term SEO meta via the WordPress REST API. This addon also works seamlessly with headless WordPress installs.

', // phpcs:ignore Generic.Files.LineLength.MaxExceeded 'descriptionVersion' => 0, 'downloadUrl' => '', 'productUrl' => 'https://aioseo.com/feature/rest-api/', 'learnMoreUrl' => 'https://aioseo.com/feature/rest-api/', 'manageUrl' => null, 'basename' => 'aioseo-rest-api/aioseo-rest-api.php', 'installed' => false, 'isActive' => false, 'canInstall' => false, 'canActivate' => false, 'canUpdate' => false, 'capability' => null, 'minimumVersion' => '0.0.0', 'hasMinimumVersion' => false ], [ 'sku' => 'aioseo-image-seo', 'name' => 'Image SEO', 'version' => '1.0.0', 'image' => null, 'icon' => 'svg-image-seo', 'levels' => [ 'individual', 'business', 'agency', 'plus', 'pro', 'elite', ], 'currentLevels' => [ 'plus', 'pro', 'elite' ], 'requiresUpgrade' => true, 'description' => '

Globally control the Title attribute and Alt text for images in your content. These attributes are essential for both accessibility and SEO.

', 'descriptionVersion' => 0, 'productUrl' => 'https://aioseo.com/image-seo', 'learnMoreUrl' => 'https://aioseo.com/image-seo', 'manageUrl' => 'https://route#aioseo-search-appearance:media', 'basename' => 'aioseo-image-seo/aioseo-image-seo.php', 'installed' => false, 'isActive' => false, 'canInstall' => false, 'canActivate' => false, 'canUpdate' => false, 'capability' => $this->getManageCapability( 'aioseo-image-seo' ), 'minimumVersion' => '0.0.0', 'hasMinimumVersion' => false ] ] ), true ); } /** * Check for updates for all addons. * * @since 4.2.4 * * @return void */ public function registerUpdateCheck() {} /** * Updates a given addon or plugin. * * @since 4.4.3 * * @param string $name The addon name/sku. * @param bool $network Whether we are in a network environment. * @return bool Whether the installation was succesful. */ public function upgradeAddon( $name, $network ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable return false; } /** * Get the download URL for the given addon. * * @since 4.4.3 * * @param string $sku The addon sku. * @return string The download url for the addon. */ public function getDownloadUrl( $sku ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable return ''; } }