“Add Media” button in custom plugin

If you want to add a add media button to your admin panels: You need to use wp_enqueue_media(); add_action ( ‘admin_enqueue_scripts’, function () { if (is_admin ()) wp_enqueue_media (); } ); Then use this js: jQuery(document).ready(function() { var $ = jQuery; if ($(‘.set_custom_images’).length > 0) { if ( typeof wp !== ‘undefined’ && wp.media && … Read more

How I prevent a plugin to be loaded when doing WP-CLI?

One of the first things WordPress does to load plugins is get the active plugins as saved in the database: $active_plugins = (array) get_option( ‘active_plugins’, array() ); Since it uses get_option() we can use the option_active_plugins filter to modify the list of active plugins on the fly. function wpse_301282_disable_plugin( $active_plugins ) { if ( defined( … Read more

How to check if a theme is active?

You can use wp_get_theme: <?php $theme = wp_get_theme(); // gets the current theme if ( ‘Twenty Twelve’ == $theme->name || ‘Twenty Twelve’ == $theme->parent_theme ) { // if you’re here Twenty Twelve is the active theme or is // the current theme’s parent theme } Or, you can simply check if a function in twentytwelve … Read more

Woocommerce Add Variation Product to Cart from custom link [closed]

i currently work on a woocommerce v2.1.12 shop and it seems they chaged that behavior. my ajax url to add items to the cart has to look like this: ?add-to-cart=[PRODUCT-ID]&variation_id=[VARIATION-ID]&attribute_[ATTRIBUTE-NAME]=[ATTRIBUTE-SLUG]&attribute_[ATTRIBUTE-NAME]=[ATTRIBUTE-SLUG] example: http://example.com/store/category/product/?add-to-cart=239&variation_id=240&attribute_pa_size=48-2&attribute_pa_color=gold this adds a specific product to the cart and also sets the variation attributes in the cart. you can even set the quantity … Read more

Contact form 7 select box different value-text than content-text in option [closed]

It looks like this is supported by Contact Form 7 natively, it’s just not very obvious on how to make it happen. Here’s a documentation page explaining the functionality: http://contactform7.com/selectable-recipient-with-pipes/ Basically, all you have to do is put the values like so: “Visible Value|actual-form-value” What comes before the pipe | character will be shown in … Read more

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