recommended_replace_vars ) ) { $this->recommended_replace_vars = new WPSEO_Admin_Recommended_Replace_Vars(); } return $this->recommended_replace_vars; } /** * Returns the editor specific replacements variables object, creating it if needed. * * @return \WPSEO_Admin_Editor_Specific_Replace_Vars */ protected function get_admin_editor_specific_replace_vars() { if ( is_null( $this->editor_specific_replace_vars ) ) { $this->editor_specific_replace_vars = new WPSEO_Admin_Editor_Specific_Replace_Vars(); } return $this->editor_specific_replace_vars; } /** * Build a set of social fields for the author archives in the Search Appearance section. * * @param Yoast_Form $yform The form builder. */ public function social_author_archives( $yform ) { $identifier = 'author-wpseo'; $page_type_recommended = $this->get_admin_recommended_replace_vars()->determine_for_archive( 'author' ); $page_type_specific = $this->get_admin_editor_specific_replace_vars()->determine_for_archive( 'author' ); $this->build_social_fields( $yform, $identifier, $page_type_recommended, $page_type_specific ); } /** * Build a set of social fields for the date archives in the Search Appearance section. * * @param Yoast_Form $yform The form builder. */ public function social_date_archives( $yform ) { $identifier = 'archive-wpseo'; $page_type_recommended = $this->get_admin_recommended_replace_vars()->determine_for_archive( 'date' ); $page_type_specific = $this->get_admin_editor_specific_replace_vars()->determine_for_archive( 'date' ); $this->build_social_fields( $yform, $identifier, $page_type_recommended, $page_type_specific ); } /** * Build a set of social fields for the post types in the Search Appearance section. * * @param Yoast_Form $yform The form builder. * @param string $post_type_name The name of the current post_type that gets the social fields added. */ public function social_post_type( $yform, $post_type_name ) { if ( $post_type_name === 'attachment' ) { return; } $page_type_recommended = $this->get_admin_recommended_replace_vars()->determine_for_post_type( $post_type_name ); $page_type_specific = $this->get_admin_editor_specific_replace_vars()->determine_for_post_type( $post_type_name ); $this->build_social_fields( $yform, $post_type_name, $page_type_recommended, $page_type_specific ); } /** * Build a set of social fields for the post types archives in the Search Appearance section. * * @param Yoast_Form $yform The form builder. * @param string $post_type_name The name of the current post_type that gets the social fields added. */ public function social_post_types_archive( $yform, $post_type_name ) { $identifier = 'ptarchive-' . $post_type_name; $page_type_recommended = $this->get_admin_recommended_replace_vars()->determine_for_archive( $post_type_name ); $page_type_specific = $this->get_admin_editor_specific_replace_vars()->determine_for_archive( $post_type_name ); $this->build_social_fields( $yform, $identifier, $page_type_recommended, $page_type_specific ); } /** * Build a set of social fields for the taxonomies in the Search Appearance section. * * @param Yoast_Form $yform The form builder. * @param WP_Taxonomy $taxonomy The taxonomy that gets the social fields added. */ public function social_taxonomies( $yform, $taxonomy ) { $identifier = 'tax-' . $taxonomy->name; $page_type_recommended = $this->get_admin_recommended_replace_vars()->determine_for_term( $taxonomy->name ); $page_type_specific = $this->get_admin_editor_specific_replace_vars()->determine_for_term( $taxonomy->name ); $this->build_social_fields( $yform, $identifier, $page_type_recommended, $page_type_specific ); } /** * Build a set of social fields for the Search Appearance section. * * @param Yoast_Form $yform The form builder. * @param string $identifier A page-wide unique identifier for data storage and unique DOM elements. * @param string $page_type_recommended Recommended type of page for a list of replaceable variables. * @param string $page_type_specific Editor specific type of page for a list of replaceable variables. */ protected function build_social_fields( Yoast_Form $yform, $identifier, $page_type_recommended, $page_type_specific ) { $image_url_field_id = 'social-image-url-' . $identifier; $image_id_field_id = 'social-image-id-' . $identifier; $is_premium = YoastSEO()->helpers->product->is_premium(); $is_premium_16_5_or_up = defined( '\WPSEO_PREMIUM_VERSION' ) && \version_compare( \WPSEO_PREMIUM_VERSION, '16.5-RC0', '>=' ); $is_form_enabled = $is_premium && $is_premium_16_5_or_up; $section_class = 'yoast-settings-section'; if ( ! $is_form_enabled ) { $section_class .= ' yoast-settings-section-disabled'; } \printf( '