Check if term object is in array

I want to check if a term object is in an get_terms array, but i really can’t figure out how to do it. $subcat_terms = get_terms([ ‘taxonomy’ => ‘product_cat’ ]); $subcat_terms generates an array like this: array (size=3) 0 => object(WP_Term)[10551] public ‘term_id’ => int 16 public ‘name’ => string ‘Hardware’ (length=8) public ‘slug’ => … Read more

Use is_product_category() properly

I have two product category MULTILINGUAL DIGITAL MARKETING (ID 75) INTERNATIONAL SALES CHANNELS (ID 107) I want to run some code via if condition for these two category only. I tried using this code but it didn’t worked if( is_product_category(107 || 75) ) { $term = get_queried_object(); $parent = $term->parent; if (!empty($parent)) { $child_of = … Read more

Refactor create_function

I’m getting several create_function is depreciated errors from a plugin as the result of a recent WP upgrade to 5.2. The plugin is no longer supported which means I need to refactor the code myself. Would anyone be able to get me pointed in the right direction? function _options_page(){ if($this->args[‘page_type’] == ‘submenu’){ if(!isset($this->args[‘page_parent’]) || empty($this->args[‘page_parent’])){ … Read more

Generating add_settings_section() calls dynamically

I have some pieces of code within functions.php that I could easly replace with much shorter functions, like, for example: function register_sections() { add_settings_section(‘SOMETHING_settings’, ‘SOMETHING Settings’, ‘generate’, ‘SOMETHING_page’ ); add_settings_section(‘SOMETHING2_settings’, ‘SOMETHING2 Settings’, ‘generate’, ‘SOMETHING2_page’ ); add_settings_section(‘SOMETHING3_settings’, ‘SOMETHING3 Settings’, ‘generate’, ‘SOMETHING3_page’ ); add_settings_section(‘SOMETHING4_settings’, ‘SOMETHING4 Settings’, ‘generate’, ‘SOMETHING4_page’ ); (…) } add_action(‘admin_init’, ‘register_sections’); I guess function replacing … Read more