Loading shortcode with ajax

You cannot load a file directly like this: $(‘.homepage__slider’).load(‘wp-content/themes/mytheme/slider.php’); Also note that WordPress loads jQuery in noConflict mode, so the $ alias does not work. If you load a file directly none of the WordPress functions will work. You should be using the AJAX API so that everything loads in WordPress context. You would wrap … Read more

Custom wp_nav_menu output (displaying all child elements of top menu element in current branch)

The idea Instead of create a custom walker I thought was easier filter the items using the filter wp_nav_menu_objects hook. This hook is defined in /wp-includes/nav-menu-templates.php and whe is fired, it pass to functions hooking into it an array $sorted_menu_items that contains all the elements of the menu being printed, if the function alter that … Read more

Additional, optional fee on Woocommerce Checkout [closed]

Ok, so this is how i did it. Create a product called Shipping Insurance which is $3, make sure its a hidden product(Catalog Visibility on the right side) Use the following code in your theme’s functions.php file: add_action(‘woocommerce_cart_totals_after_shipping’, ‘wc_shipping_insurance_note_after_cart’); function wc_shipping_insurance_note_after_cart() { global $woocommerce; $product_id = 669; foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) … Read more

How to add a help tab to all admin pages – including plugin pages

This is how you can add help tabs to all admin pages—no matter if there already are any, or not: add_action(‘in_admin_header’, ‘wpse_124979_add_help_tabs’); function wpse_124979_add_help_tabs() { if ($screen = get_current_screen()) { $help_tabs = $screen->get_help_tabs(); $screen->remove_help_tabs(); $screen->add_help_tab(array( ‘id’ => ‘my_help_tab’, ‘title’ => ‘My Help’, ‘content’ => ‘<p>My help content…</p>’, )); if (count($help_tabs)) foreach ($help_tabs as $help_tab) $screen->add_help_tab($help_tab); … Read more

How to parse nested shortcodes?

There’s a solution for that, actually. The shortcode you are using has the variable $content, whithout the filter do_shortcode, like this: do_shortcode($content) Open the file where there are the shortcodes and change $content for do_shortcode($content). It will work.

How to add meta box to plugin admin page?

add_meta_boxes is for adding meta boxes to post types. What you’re looking for is the Settings API. In your add_menu_page function you are calling a function named test_plugin_admin_options. This function will hold the content of your options page. You will also need to register your settings with register_setting(). //add menu page add_action(‘admin_menu’, ‘test’); function test(){ … Read more

To remove plugin notices for non-admin users

The simplest way would be to hide the notifications via CSS, see below: function hide_update_msg_non_admins(){ if (!current_user_can( ‘manage_options’ )) { // non-admin users echo ‘<style>#setting-error-tgmpa>.updated settings-error notice is-dismissible, .update-nag, .updated { display: none; }</style>’; } } add_action( ‘admin_head’, ‘hide_update_msg_non_admins’); A more detailed answer can be found here.

Are orders of magnitude used for “Active Installs”?

I was curious and checked out the lists of popular plugins, newest plugins (not in the Plugin Directory menu), last updated plugins (not in the Plugin Directory menu). This seems to be the range for the active installs: 1+ million 900.000+ 800.000+ 700.000+ 600.000+ 500.000+ 400.000+ 300.000+ 200.000+ 100.000+ 90.000+ 80.000+ 70.000+ 60.000+ 50.000+ 40.000+ … Read more

How to handel multiple checkbox field in the admin settings page with Settings API

add_action( ‘admin_init’, ‘register_page_options’ ); function register_page_options() { if (false == get_option(‘aicp_settings_options’)) { add_option(‘aicp_settings_options’); } // Add Section for option fields add_settings_section( ‘aicp_section’, __( ‘….text here….’, ‘aicp’ ), ‘display_section’, ‘aicp_settings’ ); // id, title, display cb, page // Add Field for selecting countries for which you wanna ban ads add_settings_field( ‘aicp_country_list’, __( ‘Select the countries’, ‘aicp’ … Read more

How do I check what plugins are enabled via the database?

You can do it like this: SQL SELECT * FROM wp_options WHERE option_name=”active_plugins”; But for better approach will be the WordPress way: WordPress if ( ! function_exists( ‘get_plugins’ ) ) { require_once ABSPATH . ‘wp-admin/includes/plugin.php’; } $active_plugins = get_option(‘active_plugins’); $all_plugins = get_plugins(); $activated_plugins = array(); foreach ($active_plugins as $plugin){ if(isset($all_plugins[$plugin])){ array_push($activated_plugins, $all_plugins[$plugin]); } }