Override Constants in Child theme

Constants can not be redefined that easily. https://stackoverflow.com/questions/8465155/redefine-constants-in-php So, the constants from child themes will be used instead of parents one. Though, there will be a warning, but that shouldn’t create any problem if you disable warning. You should add constants like this if you don’t want any warning: if ( !defined(‘CONSTANT’) ) define(‘CONSTANT’, ‘constant_value’); … Read more

Are we allowed to use the Allman (BSD) indent style when coding WordPress plugins and themes?

WordPress.org does not have any hard requirements for code styles for plugins or themes. In the plugin guidelines, the relevant section is #4, “Keep your code (mostly) human readable.” Mainly it is about obfuscation. The most relevant line is this: We recommend following WordPress Core Coding Standards. Note the word recommend, there. This is not … Read more

WordPress codex: apply_filters – clarification on creating a new hook on the fly. How do we use it?

How to use the filter single_product_archive_thumbnail_size I’ve searched for the tag single_product_archive_thumbnail_size in woocommerce repository on github. There is only the single occurrence of it as you see here. So how do we use it? The author’s of WooCommerce added this filter so that other developers would be able to modify the product’s archive thumbnail … Read more

*Just curious* I erroneously used hook add_action() instead of add_filter() and there was no error and the result was correct. Why is that?

add_action() uses add_filter() behind the hood. function add_action( $hook_name, $callback, $priority = 10, $accepted_args = 1 ) { return add_filter( $hook_name, $callback, $priority, $accepted_args ); } Source: https://developer.wordpress.org/reference/functions/add_action/ So basically it doesn’t matter if you use add_filter or add_action. But it doesn’t mean you should, using the appropriate function for a event will make your … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)