How to provide a plugin which requires CMB2 (plugin dependencies)?

On your plugin activation hook method you can check if CMB plugin is installed and/or activated. You can check this using the following methods: is_plugin_active(): only available from within the admin pages function_exists() or class_exists(): available anywhere once they are PHP core methods If CMB is not installed, you can throw an error message in … Read more

Why is an action callback function from an instance of a class always invoking the same function from an instance?

It’s possible I’m misunderstanding your question, but the way it is written it seems as though every instance of your FilterBuilder class will always get called. Each instance of your class has in its constructor: add_action(‘wp_ajax_myfilter’, array($this, ‘filter_function’)); (as well as the non-logged-in-user version) There is no conditional here telling it when to run based … Read more

How can sanitize $_FILES[‘haq_slider’] field

You don’t say where this code is running – for users or just for admins. Here are a few tips, taken heavily from this article on Wordfence. The first check you can run is current_user_can to see if the current user is allowed to upload files using: if(current_user_can(‘upload_files’)) { …. Next you can use wp_check_filetype … Read more

“add_post_type_support” with Custom Post Type & ACF

You need to use filters to hook into manage_posts_columns and manage_posts_custom_column which will let you add the table heading and dates. The filters are slightly special as you need to include the name of your custom post type manage_{$post_type}_posts_columns manage_{$post_type}_posts_custom_column where {$post_type} in your case is conferences // Add the table heading function conf_columns_head($defaults) { … Read more

WooCommerce E-Check payment gateway disappeared when site switched to multi-site

It’s because of this: if ( in_array( ‘woocommerce/woocommerce.php’, apply_filters( ‘active_plugins’, get_option( ‘active_plugins’ ) ), true ) ) { self::$instance->setup_constants(); self::$instance->hooks(); self::$instance->includes(); self::$instance->load_textdomain(); add_filter( ‘woocommerce_payment_gateways’, array( self::$instance, ‘add_wc_gateway’ ) ); } The entire class doesn’t do anything if this condition isn’t true: in_array( ‘woocommerce/woocommerce.php’, apply_filters( ‘active_plugins’, get_option( ‘active_plugins’ ) ), true ) The problem is that … Read more

Namespaces declared by a theme/plugin should start with the theme/plugin prefix. Found: “eustatos\test_plugin”

At first, we need to update phpcs.xml. Let’s replace “my_prefix” with your plugin name (then, assuming “eustatos”): <rule ref=”WordPress.NamingConventions.PrefixAllGlobals”> <properties> <property name=”prefixes” type=”array”> <element value=”eustatos”/> </property> </properties> </rule> Then, you can use namespace start with eustatos in project PHP file. ex: namespace eustatos\test_plugin; cf. Customizable sniff properties · WordPress/WordPress-Coding-Standards Wiki To execute this check one … Read more