How do I determine if a category exists by ID?
There is category_exists() function, but it seems to be for internal use in admin so you can try term_exists() instead.
There is category_exists() function, but it seems to be for internal use in admin so you can try term_exists() instead.
There is plugin_basename() call some levels inside which seems to use WP_PLUGIN_DIR and WPMU_PLUGIN_DIR constants, so my guess would be this function is only meant to be used for things inside plugin directories and not other places like theme.
WordPress has no convention for naming of main file. It scans whole plugins directory (see get_plugins() ) and looks for plugin header (with get_plugin_data())in every PHP file on appropriate directory levels. This is only performed when you actually need full list of plugins. Thing like active plugins are calculated and stored separately so that for … Read more
Most complex plugins do that in one form or another. Unfortunately, many plugins start with a god class and don’t use a clean OOP approach. WooCommerce is a popular example. Plugins cannot provide a real front controller, because they are loaded after WordPress has set up most of its environment. And all plugins are almost … Read more
Try using preventDefault(), it’s a jQuery function for preventing default actions called by the browser. First you should call an event handler by firing up your submitter. You can do this as follow: $(‘#my_upload_form’).submit(function (event) { After catching a submit and giving an event with it, you should prevent the default refresh of a browser: … Read more
If you want to rewrite example.com/test123 (a standard WordPress Page) to example.com/test234 (another standard WordPress Page) without having to save the rewrite rules in the database, then one option is using the request filter hook: add_filter( ‘request’, function ( $query_vars ) { if ( isset( $query_vars[‘pagename’] ) ) { $slug = $query_vars[‘pagename’]; // Define a … Read more
Plugin vs. Theme vs. MU-Plugin vs. Drop-In »Would this application require building a plug-in, or just adding code to my theme?« Basically all four are the same. They differ only in two points: Location and MU-Plugins are in the mu-plugins folder 1) Plugins are in the plugins directory Drop-Ins live in the wp-content folder as … Read more
Hello Please add following code snippet in your theme’s functions.php file if (!function_exists(‘write_log’)) { function write_log ( $log ) { if ( true === WP_DEBUG ) { if ( is_array( $log ) || is_object( $log ) ) { error_log( print_r( $log, true ) ); } else { error_log( $log ); } } } } Now … Read more
I would suggest adding a “virtual” coupon to the order which would represent the store credit. Coupons are applied on the cart page before checkout, this is where I would hook in. You can use something like the woocommerce_cart_subtotal filter as per my example below: function royal_woocommerce_filter_checkout_for_coupons( $subtotal, $compound, $cart ) { // Your logic … Read more
The problem is, by the time your WooCommerce_Chilexpress_Tags_Settings is defined, WC_Settings_Page has indeed not yet loaded; hence you got the fatal error. And if you want to do it the same way that WooCommerce does it, place the WooCommerce_Chilexpress_Tags_Settings in a separate PHP file, e.g. includes/class-woocommerce-chilexpress-tags-tettings.php, and initialize the class from that file — i.e. … Read more