Edit File by line
/home/barbar84/www/wp-conte.../plugins/wordpres.../src/helpers
File: taxonomy-helper.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Helpers;
[2] Fix | Delete
[3] Fix | Delete
use WP_Taxonomy;
[4] Fix | Delete
use WP_Term;
[5] Fix | Delete
use WPSEO_Taxonomy_Meta;
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* A helper object for terms.
[9] Fix | Delete
*/
[10] Fix | Delete
class Taxonomy_Helper {
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* The options helper.
[14] Fix | Delete
*
[15] Fix | Delete
* @var Options_Helper
[16] Fix | Delete
*/
[17] Fix | Delete
private $options;
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* The string helper.
[21] Fix | Delete
*
[22] Fix | Delete
* @var String_Helper
[23] Fix | Delete
*/
[24] Fix | Delete
private $string;
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* Taxonomy_Helper constructor.
[28] Fix | Delete
*
[29] Fix | Delete
* @codeCoverageIgnore It only sets dependencies.
[30] Fix | Delete
*
[31] Fix | Delete
* @param Options_Helper $options The options helper.
[32] Fix | Delete
* @param String_Helper $string The string helper.
[33] Fix | Delete
*/
[34] Fix | Delete
public function __construct( Options_Helper $options, String_Helper $string ) {
[35] Fix | Delete
$this->options = $options;
[36] Fix | Delete
$this->string = $string;
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* Checks if the requested term is indexable.
[41] Fix | Delete
*
[42] Fix | Delete
* @param string $taxonomy The taxonomy slug.
[43] Fix | Delete
*
[44] Fix | Delete
* @return bool True when taxonomy is set to index.
[45] Fix | Delete
*/
[46] Fix | Delete
public function is_indexable( $taxonomy ) {
[47] Fix | Delete
return ! $this->options->get( 'noindex-tax-' . $taxonomy, false );
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
/**
[51] Fix | Delete
* Returns an array with the public taxonomies.
[52] Fix | Delete
*
[53] Fix | Delete
* @param string $output The output type to use.
[54] Fix | Delete
*
[55] Fix | Delete
* @return string[]|WP_Taxonomy[] Array with all the public taxonomies.
[56] Fix | Delete
* The type depends on the specified output variable.
[57] Fix | Delete
*/
[58] Fix | Delete
public function get_public_taxonomies( $output = 'names' ) {
[59] Fix | Delete
return \get_taxonomies( [ 'public' => true ], $output );
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* Retrieves the term description (without tags).
[64] Fix | Delete
*
[65] Fix | Delete
* @param int $term_id Term ID.
[66] Fix | Delete
*
[67] Fix | Delete
* @return string Term description (without tags).
[68] Fix | Delete
*/
[69] Fix | Delete
public function get_term_description( $term_id ) {
[70] Fix | Delete
return $this->string->strip_all_tags( \term_description( $term_id ) );
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
/**
[74] Fix | Delete
* Retrieves the taxonomy term's meta values.
[75] Fix | Delete
*
[76] Fix | Delete
* @codeCoverageIgnore We have to write test when this method contains own code.
[77] Fix | Delete
*
[78] Fix | Delete
* @param WP_Term $term Term to get the meta value for.
[79] Fix | Delete
*
[80] Fix | Delete
* @return array|bool Array of all the meta data for the term.
[81] Fix | Delete
* False if the term does not exist or the $meta provided is invalid.
[82] Fix | Delete
*/
[83] Fix | Delete
public function get_term_meta( $term ) {
[84] Fix | Delete
return WPSEO_Taxonomy_Meta::get_term_meta( $term, $term->taxonomy, null );
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
/**
[88] Fix | Delete
* Gets the passed taxonomy's slug.
[89] Fix | Delete
*
[90] Fix | Delete
* @param string $taxonomy The name of the taxonomy.
[91] Fix | Delete
*
[92] Fix | Delete
* @return string The slug for the taxonomy. Returns the taxonomy's name if no slug could be found.
[93] Fix | Delete
*/
[94] Fix | Delete
public function get_taxonomy_slug( $taxonomy ) {
[95] Fix | Delete
$taxonomy_object = \get_taxonomy( $taxonomy );
[96] Fix | Delete
[97] Fix | Delete
if ( $taxonomy_object && \property_exists( $taxonomy_object, 'rewrite' ) && \is_array( $taxonomy_object->rewrite ) && isset( $taxonomy_object->rewrite['slug'] ) ) {
[98] Fix | Delete
return $taxonomy_object->rewrite['slug'];
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
return \strtolower( $taxonomy_object->name );
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
/**
[105] Fix | Delete
* Returns an array with the custom taxonomies.
[106] Fix | Delete
*
[107] Fix | Delete
* @param string $output The output type to use.
[108] Fix | Delete
*
[109] Fix | Delete
* @return string[]|WP_Taxonomy[] Array with all the custom taxonomies.
[110] Fix | Delete
* The type depends on the specified output variable.
[111] Fix | Delete
*/
[112] Fix | Delete
public function get_custom_taxonomies( $output = 'names' ) {
[113] Fix | Delete
return \get_taxonomies( [ '_builtin' => false ], $output );
[114] Fix | Delete
}
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function