get_option / wp_localize_script Not Working in OOP Plug In

The second parameter for register_setting() is the database option name which you would use with get_option() just as you’ve done successfully with the title_char_count_settings option: register_setting( ‘pluginPage’, ‘title_char_count_settings’ ) and get_option( ‘title_char_count_settings’ );. So I’m guessing that you either: Made a typo in the register_setting() call in your ebay_keyword_suggest_settings_init() function: // You used this: register_setting( … Read more

How can I add “last updated” in plugin descripton?

Use this code instead: function range_plu_plugin_meta( $plugin_meta, $plugin_file ) { list( $slug ) = explode( “https://wordpress.stackexchange.com/”, $plugin_file ); $slug_hash = md5( $slug ); $last_updated = get_transient( “range_plu_{$slug_hash}” ); if ( false === $last_updated ) { $last_updated = range_plu_get_last_updated( $slug ); set_transient( “range_plu_{$slug_hash}”, $last_updated, 86400 ); } if ( $last_updated ) { $last_updated = strtotime( $last_updated … Read more

The XXX plugin has been deactivated due to an error: The plugin does not have a valid header

The active_plugins data is incorrect. Here’s a sample from one of my test sites: a:3:{i:0;s:34:”advanced-custom-fields-pro/acf.php”;i:4;s:31:”code-snippets/code-snippets.php”;i:21;s:24:”wordpress-seo/wp-seo.php”;} Or: Array ( [0] => advanced-custom-fields-pro/acf.php [4] => code-snippets/code-snippets.php [21] => wordpress-seo/wp-seo.php ) Notice that the plugins are referred to by the path to the main plugin file, relative to the plugins folder. The main plugin folder is what contains … Read more

How to do the simplest possible frontend ajax call from a plugin?

From codex: wp_ajax_{$action} and wp_ajax_nopriv{$action} the dinamic part {$action} must be the same name as the function, so instead of: add_action( ‘wp_ajax_the_ajax_hook’, ‘the_action_function’ ); add_action( ‘wp_ajax_nopriv_the_ajax_hook’, ‘the_action_function’ ); do: add_action( ‘wp_ajax_the_action_function’, ‘the_action_function’ ); add_action( ‘wp_ajax_nopriv_the_action_function’, ‘the_action_function’ );

Readable titles in mobile

It’s important not to use <h1> tags (and other headings) just to affect font size. You should use CSS to target whatever HTML element is already there. It’s also important not to edit a theme directly, because when you update that theme, all of your changes will be lost. To avoid that problem, see if … Read more

Conditional Shipping Options if Certain Products are in Cart WooCommerce

My solution is based off of this source snippet: https://www.xadapter.com/woocommerce-hide-shipping-methods-if-items-of-specific-shipping-class-is-not-in-cart/ I created a new Shipping class in WooCommerce called “no-free-shipping” (the slug is important as this must be replaced in the code if you have something different.) In the functions.php file in your WordPress theme, add the following code: add_filter(‘woocommerce_package_rates’, ‘xa_hide_shipping_method_when_shipping_class_product_is_in_cart’, 10, 2); function xa_hide_shipping_method_when_shipping_class_product_is_in_cart($available_shipping_methods, … Read more

add_submenu_page returns null

Your code is correct but just you have called wrong capability in add_submenu_page. You just need to replace this ‘manage_options’ instead of ‘manage-options’. And please check it. It’s works. Reference: https://developer.wordpress.org/reference/functions/add_submenu_page/

Redeclare function after plugin activation

Ok with helps it’s working. So theme was ok in front of wordpress but wasn’t able to load in the admin so we changed the previous condition by : if (!function_exists(‘get_field’) && !is_admin()) { function get_field() { return; } function the_field() { return; } } but same problem with activation in the admin and it … Read more