']; $noImageIndex = $robotsMeta['noimageindex']; if ( ! $noImageIndex && $maxImagePreview && in_array( $maxImagePreview, [ 'none', 'standard', 'large' ], true ) ) { $this->attributes['max-image-preview'] = "max-image-preview:$maxImagePreview"; } $maxVideoPreview = $robotsMeta['maxVideoPreview']; if ( isset( $maxVideoPreview ) && is_numeric( $maxVideoPreview ) ) { $this->attributes['max-video-preview'] = "max-video-preview:$maxVideoPreview"; } // Check this last so that we can prevent max-image-preview from being output if noimageindex is enabled. if ( $noImageIndex ) { $this->attributes['max-image-preview'] = ''; $this->attributes['noimageindex'] = 'noimageindex'; } } /** * Sets the attributes from the meta data. * * @since 4.0.0 * * @param \AIOSEO\Plugin\Common\Models\Post|\AIOSEO\Plugin\Pro\Models\Term $metaData The post/term meta data. * @return void */ protected function metaValues( $metaData ) { if ( $metaData->robots_noindex || $this->isPasswordProtected() ) { $this->attributes['noindex'] = 'noindex'; } if ( $metaData->robots_nofollow ) { $this->attributes['nofollow'] = 'nofollow'; } if ( $metaData->robots_noarchive ) { $this->attributes['noarchive'] = 'noarchive'; } if ( $metaData->robots_nosnippet ) { $this->attributes['nosnippet'] = 'nosnippet'; } if ( $metaData->robots_noodp ) { $this->attributes['noodp'] = 'noodp'; } if ( $metaData->robots_notranslate ) { $this->attributes['notranslate'] = 'notranslate'; } if ( ! $metaData->robots_nosnippet && $metaData->robots_max_snippet && intval( $metaData->robots_max_snippet ) ) { $this->attributes['max-snippet'] = "max-snippet:$metaData->robots_max_snippet"; } if ( ! $metaData->robots_noimageindex && $metaData->robots_max_imagepreview && in_array( $metaData->robots_max_imagepreview, [ 'none', 'standard', 'large' ], true ) ) { $this->attributes['max-image-preview'] = "max-image-preview:$metaData->robots_max_imagepreview"; } if ( isset( $metaData->robots_max_videopreview ) && is_numeric( $metaData->robots_max_videopreview ) ) { $this->attributes['max-video-preview'] = "max-video-preview:$metaData->robots_max_videopreview"; } // Check this last so that we can prevent max-image-preview from being output if noimageindex is enabled. if ( $metaData->robots_noimageindex ) { $this->attributes['max-image-preview'] = ''; $this->attributes['noimageindex'] = 'noimageindex'; } } /** * Checks whether the current post is password protected. * * @since 4.0.0 * * @return bool Whether the post is password protected. */ private function isPasswordProtected() { $post = aioseo()->helpers->getPost(); return is_object( $post ) && $post->post_password; } }