File Editor
Directories:
.. (Back)
open-graph
schema
twitter
Files:
aioseo-helper.php
asset-helper.php
attachment-cleanup-helper.php
author-archive-helper.php
blocks-helper.php
capability-helper.php
crawl-cleanup-helper.php
curl-helper.php
current-page-helper.php
date-helper.php
environment-helper.php
first-time-configuration-notice-helper.php
home-url-helper.php
image-helper.php
import-cursor-helper.php
import-helper.php
indexable-helper.php
indexable-to-postmeta-helper.php
indexing-helper.php
language-helper.php
meta-helper.php
notification-helper.php
options-helper.php
pagination-helper.php
permalink-helper.php
post-helper.php
post-type-helper.php
primary-term-helper.php
product-helper.php
redirect-helper.php
require-file-helper.php
robots-helper.php
robots-txt-helper.php
sanitization-helper.php
score-icon-helper.php
short-link-helper.php
site-helper.php
social-profiles-helper.php
string-helper.php
taxonomy-helper.php
url-helper.php
user-helper.php
wincher-helper.php
woocommerce-helper.php
wordpress-helper.php
wpdb-helper.php
Create New File
Create
Edit File: primary-term-helper.php
<?php namespace Yoast\WP\SEO\Helpers; use stdClass; /** * A helper object for primary terms. */ class Primary_Term_Helper { /** * Generate the primary term taxonomies. * * @param int $post_id ID of the post. * * @return array The taxonomies. */ public function get_primary_term_taxonomies( $post_id ) { $post_type = \get_post_type( $post_id ); $all_taxonomies = \get_object_taxonomies( $post_type, 'objects' ); $all_taxonomies = \array_filter( $all_taxonomies, [ $this, 'filter_hierarchical_taxonomies' ] ); /** * Filters which taxonomies for which the user can choose the primary term. * * @param array $taxonomies An array of taxonomy objects that are primary_term enabled. * @param string $post_type The post type for which to filter the taxonomies. * @param array $all_taxonomies All taxonomies for this post types, even ones that don't have primary term * enabled. */ $taxonomies = (array) \apply_filters( 'wpseo_primary_term_taxonomies', $all_taxonomies, $post_type, $all_taxonomies ); return $taxonomies; } /** * Returns whether or not a taxonomy is hierarchical. * * @param stdClass $taxonomy Taxonomy object. * * @return bool True for hierarchical taxonomy. */ protected function filter_hierarchical_taxonomies( $taxonomy ) { return (bool) $taxonomy->hierarchical; } }
Save Changes
Rename File
Rename