| 1 |
<?php |
| 2 |
|
| 3 |
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong |
| 4 |
// phpcs:disable Yoast.NamingConventions.NamespaceName.MaxExceeded |
| 5 |
namespace Yoast\WP\SEO\Editors\Framework\Seo\Terms; |
| 6 |
|
| 7 |
use WPSEO_Taxonomy_Meta; |
| 8 |
use Yoast\WP\SEO\Editors\Domain\Seo\Keyphrase; |
| 9 |
use Yoast\WP\SEO\Editors\Domain\Seo\Seo_Plugin_Data_Interface; |
| 10 |
use Yoast\WP\SEO\Editors\Framework\Seo\Keyphrase_Interface; |
| 11 |
|
| 12 |
/** |
| 13 |
* Describes if the keyphrase SEO data. |
| 14 |
*/ |
| 15 |
class Keyphrase_Data_Provider extends Abstract_Term_Seo_Data_Provider implements Keyphrase_Interface { |
| 16 |
|
| 17 |
/** |
| 18 |
* Counting the number of given keyphrase used for other term than given term_id. |
| 19 |
* |
| 20 |
* @return array<string> |
| 21 |
*/ |
| 22 |
public function get_focus_keyphrase_usage(): array { |
| 23 |
$focuskp = WPSEO_Taxonomy_Meta::get_term_meta( $this->term, $this->term->taxonomy, 'focuskw' ); |
| 24 |
|
| 25 |
return WPSEO_Taxonomy_Meta::get_keyword_usage( $focuskp, $this->term->term_id, $this->term->taxonomy ); |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Method to return the keyphrase domain object with SEO data. |
| 30 |
* |
| 31 |
* @return Seo_Plugin_Data_Interface The specific seo data. |
| 32 |
*/ |
| 33 |
public function get_data(): Seo_Plugin_Data_Interface { |
| 34 |
$keyphrase_usage = $this->get_focus_keyphrase_usage(); |
| 35 |
return new Keyphrase( $keyphrase_usage, [] ); |
| 36 |
} |
| 37 |
} |
| 38 |
|