ub dir. foreach ( $this->graphSubDirectories as $dirName ) { $namespace = "\AIOSEO\Plugin\Common\Schema\Graphs\\{$dirName}\\{$graphName}"; if ( class_exists( $namespace ) ) { return $namespace; } } return ''; } /** * Determines the smart graphs that need to be output by default, as well as the current context for the breadcrumbs. * * @since 4.2.5 * * @return void */ protected function determineSmartGraphsAndContext() { $this->graphs = array_merge( $this->graphs, $this->getDefaultGraphs() ); $contextInstance = new Context(); $this->context = $contextInstance->defaults(); if ( aioseo()->helpers->isDynamicHomePage() ) { $this->graphs[] = 'CollectionPage'; $this->context = $contextInstance->home(); return; } if ( is_home() || aioseo()->helpers->isWooCommerceShopPage() ) { $this->graphs[] = 'CollectionPage'; $this->context = $contextInstance->post(); return; } if ( is_singular() ) { $this->determineContextSingular( $contextInstance ); } if ( is_category() || is_tag() || is_tax() ) { $this->graphs[] = 'CollectionPage'; $this->context = $contextInstance->term(); return; } if ( is_author() ) { $this->graphs[] = 'ProfilePage'; $this->graphs[] = 'PersonAuthor'; $this->context = $contextInstance->author(); } if ( is_post_type_archive() ) { $this->graphs[] = 'CollectionPage'; $this->context = $contextInstance->postArchive(); return; } if ( is_date() ) { $this->graphs[] = 'CollectionPage'; $this->context = $contextInstance->date(); return; } if ( is_search() ) { $this->graphs[] = 'SearchResultsPage'; $this->context = $contextInstance->search(); return; } if ( is_404() ) { $this->context = $contextInstance->notFound(); } } /** * Determines the smart graphs and context for singular pages. * * @since 4.2.6 * * @param Context $contextInstance The Context class instance. * @return void */ protected function determineContextSingular( $contextInstance ) { // Check if we're on a BuddyPress member page. if ( function_exists( 'bp_is_user' ) && bp_is_user() ) { $this->graphs[] = 'ProfilePage'; } // If the current request is for the validator, we can't include the default graph here. // We need to include the default graph that the validator sent. // Don't do this if we're in Pro since we then need to get it from the post meta. if ( ! $this->generatingValidatorOutput ) { $this->graphs[] = $this->getDefaultPostGraph(); } $this->context = $contextInstance->post(); } /** * Returns the default graph for the post type. * * @since 4.2.6 * * @return string The default graph. */ public function getDefaultPostGraph() { return $this->getDefaultPostTypeGraph(); } /** * Returns the default graph for the current post type. * * @since 4.2.5 * * @param \WP_Post $post The post object. * @return string The default graph. */ public function getDefaultPostTypeGraph( $post = null ) { $post = $post ? $post : aioseo()->helpers->getPost(); if ( ! is_a( $post, 'WP_Post' ) ) { return ''; } $dynamicOptions = aioseo()->dynamicOptions->noConflict(); if ( ! $dynamicOptions->searchAppearance->postTypes->has( $post->post_type ) ) { return ''; } $defaultType = $dynamicOptions->searchAppearance->postTypes->{$post->post_type}->schemaType; switch ( $defaultType ) { case 'Article': return $dynamicOptions->searchAppearance->postTypes->{$post->post_type}->articleType; case 'WebPage': return $dynamicOptions->searchAppearance->postTypes->{$post->post_type}->webPageType; default: return $defaultType; } } /** * Returns the default graphs that should be output on every page, regardless of its type. * * @since 4.2.5 * * @return array The default graphs. */ protected function getDefaultGraphs() { $siteRepresents = ucfirst( aioseo()->options->searchAppearance->global->schema->siteRepresents ); return [ 'BreadcrumbList', 'Kg' . $siteRepresents, 'WebSite' ]; } }