l_url' === $k ) { $oldPostMeta['canonicalUrl'] = $v; } } $this->data['currentPost'] = array_merge( $this->data['currentPost'], $oldPostMeta ); } } /** * Set Vue dashboard data. * * @since 4.4.9 * * @return void */ private function setDashboardData() { if ( 'dashboard' !== $this->args['page'] ) { return; } $this->data['setupWizard']['isCompleted'] = aioseo()->standalone->setupWizard->isCompleted(); $this->data['seoOverview'] = aioseo()->postSettings->getPostTypesOverview(); $this->data['importers'] = aioseo()->importExport->plugins(); } /** * Set Vue search statistics data. * * @since 4.4.9 * * @return void */ private function setSearchStatisticsData() { $this->data['searchStatistics'] = [ 'isConnected' => aioseo()->searchStatistics->api->auth->isConnected(), 'sitemapsWithErrors' => aioseo()->searchStatistics->sitemap->getSitemapsWithErrors(), ]; if ( 'post' === $this->args['page'] ) { $this->data['keywordRankTracker'] = aioseo()->searchStatistics->keywordRankTracker->getVueDataEdit(); } if ( 'search-statistics' === $this->args['page'] ) { $this->data['seoOverview'] = aioseo()->postSettings->getPostTypesOverview(); $this->data['searchStatistics'] = array_merge( $this->data['searchStatistics'], aioseo()->searchStatistics->getVueData() ); $this->data['keywordRankTracker'] = aioseo()->searchStatistics->keywordRankTracker->getVueData(); } } /** * Set Vue sitemaps data. * * @since 4.4.9 * * @return void */ private function setSitemapsData() { if ( 'sitemaps' !== $this->args['page'] ) { return; } $this->data['data']['sitemapUrls'] = aioseo()->sitemap->helpers->getSitemapUrls(); try { if ( as_next_scheduled_action( 'aioseo_static_sitemap_regeneration' ) ) { $this->data['scheduledActions']['sitemap'][] = 'staticSitemapRegeneration'; } } catch ( \Exception $e ) { // Do nothing. } } /** * Set Vue setup wizard data. * * @since 4.4.9 * * @return void */ private function setSetupWizardData() { if ( 'setup-wizard' !== $this->args['page'] ) { return; } $isStaticHomePage = 'page' === get_option( 'show_on_front' ); $staticHomePage = intval( get_option( 'page_on_front' ) ); $this->data['users'] = $this->getSiteUsers( [ 'administrator', 'editor', 'author' ] ); $this->data['importers'] = aioseo()->importExport->plugins(); $this->data['data'] += [ 'staticHomePageTitle' => $isStaticHomePage ? aioseo()->meta->title->getTitle( $staticHomePage ) : '', 'staticHomePageDescription' => $isStaticHomePage ? aioseo()->meta->description->getDescription( $staticHomePage ) : '', ]; } /** * Set Vue search appearance data. * * @since 4.4.9 * * @return void */ private function setSearchAppearanceData() { if ( 'search-appearance' !== $this->args['page'] ) { return; } $isStaticHomePage = 'page' === get_option( 'show_on_front' ); $staticHomePage = intval( get_option( 'page_on_front' ) ); $this->data['users'] = $this->getSiteUsers( [ 'administrator', 'editor', 'author' ] ); $this->data['data'] += [ 'staticHomePageTitle' => $isStaticHomePage ? aioseo()->meta->title->getTitle( $staticHomePage ) : '', 'staticHomePageDescription' => $isStaticHomePage ? aioseo()->meta->description->getDescription( $staticHomePage ) : '', ]; } /** * Set Vue social networks data. * * @since 4.4.9 * * @return void */ private function setSocialNetworksData() { if ( 'social-networks' !== $this->args['page'] ) { return; } $isStaticHomePage = 'page' === get_option( 'show_on_front' ); $staticHomePage = intval( get_option( 'page_on_front' ) ); $this->data['data'] += [ 'staticHomePageOgTitle' => $isStaticHomePage ? aioseo()->social->facebook->getTitle( $staticHomePage ) : '', 'staticHomePageOgDescription' => $isStaticHomePage ? aioseo()->social->facebook->getDescription( $staticHomePage ) : '', 'staticHomePageTwitterTitle' => $isStaticHomePage ? aioseo()->social->twitter->getTitle( $staticHomePage ) : '', 'staticHomePageTwitterDescription' => $isStaticHomePage ? aioseo()->social->twitter->getDescription( $staticHomePage ) : '', ]; } /** * Set Vue seo revisions data. * * @since 4.4.9 * * @return void */ private function setSeoRevisionsData() { if ( 'post' === $this->args['page'] ) { $this->data['seoRevisions'] = aioseo()->seoRevisions->getVueDataEdit(); } if ( 'seo-revisions' === $this->args['page'] ) { $this->data['seoRevisions'] = aioseo()->seoRevisions->getVueDataCompare(); } } /** * Set Vue tools or settings data. * * @since 4.4.9 * * @return void */ private function setToolsOrSettingsData() { if ( 'tools' !== $this->args['page'] && 'settings' !== $this->args['page'] ) { return; } if ( 'tools' === $this->args['page'] ) { $this->data['backups'] = array_reverse( aioseo()->backup->all() ); $this->data['importers'] = aioseo()->importExport->plugins(); $this->data['data']['robots'] = [ 'defaultRules' => $this->args['page'] ? aioseo()->robotsTxt->extractRules( aioseo()->robotsTxt->getDefaultRobotsTxtContent() ) : [], 'hasPhysicalRobots' => aioseo()->robotsTxt->hasPhysicalRobotsTxt(), 'rewriteExists' => aioseo()->robotsTxt->rewriteRulesExist(), 'sitemapUrls' => array_merge( aioseo()->sitemap->helpers->getSitemapUrlsPrefixed(), aioseo()->sitemap->helpers->extractSitemapUrlsFromRobotsTxt() ) ]; $this->data['data']['logSizes'] = [ 'badBotBlockerLog' => $this->convertFileSize( aioseo()->badBotBlocker->getLogSize() ) ]; $this->data['data']['status'] = Tools\SystemStatus::getSystemStatusInfo(); $this->data['data']['htaccess'] = aioseo()->htaccess->getContents(); $this->data['data']['v3Options'] = ! empty( get_option( 'aioseop_options' ) ); $this->data['integrations']['wpcode'] = [ 'snippets' => WpCodeIntegration::loadWpCodeSnippets(), 'pluginInstalled' => WpCodeIntegration::isPluginInstalled(), 'pluginActive' => WpCodeIntegration::isPluginActive(), 'pluginNeedsUpdate' => WpCodeIntegration::pluginNeedsUpdate() ]; } if ( 'settings' === $this->args['page'] ) { $this->data['breadcrumbs']['defaultTemplate'] = aioseo()->helpers->encodeOutputHtml( aioseo()->breadcrumbs->frontend->getDefaultTemplate() ); } if ( is_multisite() && is_network_admin() ) { $this->data['data']['network'] = [ 'sites' => aioseo()->helpers->getSites( aioseo()->settings->tablePagination['networkDomains'] ), 'backups' => [] ]; } } /** * Set Vue Page Builder data. * * @since 4.4.9 * @version 4.5.2 Renamed. * * @return void */ private function setPageBuilderData() { if ( empty( $this->args['integration'] ) ) { return; } if ( 'divi' === $this->args['integration'] ) { // This needs to be dropped in order to prevent JavaScript errors in Divi's visual builder. // Some of the data from the site analysis can contain HTML tags, e.g. the search preview, and somehow that causes JSON.parse to fail on our localized Vue data. unset( $this->data['internalOptions']['internal']['siteAnalysis'] ); } } /** * Returns Jed-formatted localization data. Added for backwards-compatibility. * * @since 4.0.0 * * @param string $domain Translation domain. * @return array The information of the locale. */ public function getJedLocaleData( $domain ) { $translations = get_translations_for_domain( $domain ); $locale = [ '' => [ 'domain' => $domain, 'lang' => is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(), ], ]; if ( ! empty( $translations->headers['Plural-Forms'] ) ) { $locale['']['plural_forms'] = $translations->headers['Plural-Forms']; } foreach ( $translations->entries as $entry ) { if ( empty( $entry->translations ) || ! is_array( $entry->translations ) ) { continue; } foreach ( $entry->translations as $translation ) { // If any of the translated strings contains an HTML line break, we need to ignore it. Otherwise, logging into the admin breaks. if ( preg_match( '//', $translation ) ) { continue 2; } } // Set the translation data using the singular string as the index. This is how Jed expects it, even for plural strings. $locale[ $entry->singular ] = $entry->translations; } return $locale; } /** * Whether the notifications drawer should be shown or not. * * @since 4.4.9 * * @return bool True if it should be shown, false otherwise. */ private function showNotificationsDrawer() { static $showNotificationsDrawer = null; if ( null === $showNotificationsDrawer ) { $showNotificationsDrawer = (bool) aioseo()->core->cache->get( 'show_notifications_drawer' ); // If this is set to true, let's disable it now, so it doesn't pop up again. if ( $showNotificationsDrawer ) { aioseo()->core->cache->delete( 'show_notifications_drawer' ); } } return $showNotificationsDrawer; } }