Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../public_h.../wp-conte.../plugins/wordpres.../src/integrat.../third-pa...
File: woocommerce-permalinks.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Integrations\Third_Party;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\SEO\Conditionals\Migrations_Conditional;
[4] Fix | Delete
use Yoast\WP\SEO\Conditionals\WooCommerce_Conditional;
[5] Fix | Delete
use Yoast\WP\SEO\Helpers\Indexable_Helper;
[6] Fix | Delete
use Yoast\WP\SEO\Integrations\Integration_Interface;
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* The permalink watcher.
[10] Fix | Delete
*/
[11] Fix | Delete
class Woocommerce_Permalinks implements Integration_Interface {
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Represents the indexable helper.
[15] Fix | Delete
*
[16] Fix | Delete
* @var Indexable_Helper
[17] Fix | Delete
*/
[18] Fix | Delete
protected $indexable_helper;
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* Returns the conditionals based in which this loadable should be active.
[22] Fix | Delete
*
[23] Fix | Delete
* @return array
[24] Fix | Delete
*/
[25] Fix | Delete
public static function get_conditionals() {
[26] Fix | Delete
return [ WooCommerce_Conditional::class, Migrations_Conditional::class ];
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
/**
[30] Fix | Delete
* Constructor.
[31] Fix | Delete
*
[32] Fix | Delete
* @param Indexable_Helper $indexable_helper Indexable Helper.
[33] Fix | Delete
*/
[34] Fix | Delete
public function __construct( Indexable_Helper $indexable_helper ) {
[35] Fix | Delete
$this->indexable_helper = $indexable_helper;
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* Registers the hooks.
[40] Fix | Delete
*
[41] Fix | Delete
* @codeCoverageIgnore
[42] Fix | Delete
*
[43] Fix | Delete
* @return void
[44] Fix | Delete
*/
[45] Fix | Delete
public function register_hooks() {
[46] Fix | Delete
\add_filter( 'wpseo_post_types_reset_permalinks', [ $this, 'filter_product_from_post_types' ] );
[47] Fix | Delete
\add_action( 'update_option_woocommerce_permalinks', [ $this, 'reset_woocommerce_permalinks' ], 10, 2 );
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
/**
[51] Fix | Delete
* Filters the product post type from the post type.
[52] Fix | Delete
*
[53] Fix | Delete
* @param array $post_types The post types to filter.
[54] Fix | Delete
*
[55] Fix | Delete
* @return array The filtered post types.
[56] Fix | Delete
*/
[57] Fix | Delete
public function filter_product_from_post_types( $post_types ) {
[58] Fix | Delete
unset( $post_types['product'] );
[59] Fix | Delete
[60] Fix | Delete
return $post_types;
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* Resets the indexables for WooCommerce based on the changed permalink fields.
[65] Fix | Delete
*
[66] Fix | Delete
* @param array $old_value The old value.
[67] Fix | Delete
* @param array $new_value The new value.
[68] Fix | Delete
*
[69] Fix | Delete
* @return void
[70] Fix | Delete
*/
[71] Fix | Delete
public function reset_woocommerce_permalinks( $old_value, $new_value ) {
[72] Fix | Delete
$changed_options = \array_diff( $old_value, $new_value );
[73] Fix | Delete
[74] Fix | Delete
if ( \array_key_exists( 'product_base', $changed_options ) ) {
[75] Fix | Delete
$this->indexable_helper->reset_permalink_indexables( 'post', 'product' );
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
if ( \array_key_exists( 'attribute_base', $changed_options ) ) {
[79] Fix | Delete
$attribute_taxonomies = $this->get_attribute_taxonomies();
[80] Fix | Delete
[81] Fix | Delete
foreach ( $attribute_taxonomies as $attribute_name ) {
[82] Fix | Delete
$this->indexable_helper->reset_permalink_indexables( 'term', $attribute_name );
[83] Fix | Delete
}
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
if ( \array_key_exists( 'category_base', $changed_options ) ) {
[87] Fix | Delete
$this->indexable_helper->reset_permalink_indexables( 'term', 'product_cat' );
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
if ( \array_key_exists( 'tag_base', $changed_options ) ) {
[91] Fix | Delete
$this->indexable_helper->reset_permalink_indexables( 'term', 'product_tag' );
[92] Fix | Delete
}
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
/**
[96] Fix | Delete
* Retrieves the taxonomies based on the attributes.
[97] Fix | Delete
*
[98] Fix | Delete
* @return array The taxonomies.
[99] Fix | Delete
*/
[100] Fix | Delete
protected function get_attribute_taxonomies() {
[101] Fix | Delete
$taxonomies = [];
[102] Fix | Delete
foreach ( \wc_get_attribute_taxonomies() as $attribute_taxonomy ) {
[103] Fix | Delete
$taxonomies[] = \wc_attribute_taxonomy_name( $attribute_taxonomy->attribute_name );
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
$taxonomies = \array_filter( $taxonomies );
[107] Fix | Delete
[108] Fix | Delete
return $taxonomies;
[109] Fix | Delete
}
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function