Using has_filter with a class based plugin to check whether the plugin is active or not

To do literally what you’re wanting here, the easiest way is to store the instance of the plugin class in a global variable at the end of your plugin: class My_Plugin { static $instance; function __construct(){} /* or private, with singleton get_instance() method */ function setup(){ … } } $my_plugin_instance = new My_Plugin(); add_action( ‘plugins_loaded’, … Read more

How to load some jquery code to make validation in the theme customizer?

Create a /js subfolder in your theme directory, if such does not exist already. Save your script to a file in said folder. Then, in functions.php: if ( is_admin() ) { global $pagenow; if ( ‘customize.php’ === $pagenow ) { add_action( ‘admin_enqueue_scripts’, ‘wpse107236_enqueue_customizer_script’ ); } } function wpse107236_enqueue_customizer_script() { wp_enqueue_script( ‘your-script-handle’, get_template_directory_uri . ‘/js/your-script.js’, array( … Read more

Create dropdown of users in admin dashboard

wp_dropdown_users accept for show arguments only field from the users table, not from user_meta table. If you enable debug, with your code, using ‘companyname’ for $show argument you will see something like: WordPress database error: [Unknown column ‘wp_users.companyname’ in ‘field list’] SELECT wp_users.ID,wp_users.user_login,wp_users.companyname FROM wp_users WHERE 1=1 ORDER BY display_name ASC So, solution is create … Read more

Ajaxing function in widget class

If this is in a widget class, you need… add_action(‘wp_ajax_my_func’, array($this,’my_func’)); … not just… add_action(‘wp_ajax_my_func’, ‘my_func’); However, I suspect there to be more problems than just that due to the context you are using this in. But without more code, that is all I’ve got. Based on new information in the question… Both your function … Read more

Delete pages and Create default pages for all new network sites

I’m really not sure where your logic is failing and haven’t revised each one of your insert/delete hooks. But the code can be greatly simplified to only call each function once, thus making it easy to make it work. add_action( ‘wpmu_new_blog’, ‘setup_blog_wpse_114119’, 10, 2 ); function setup_blog_wpse_114119( $blog_id, $user_id ) { create_pages_wpse_114119( $blog_id, $user_id ); … Read more

How can I customize wp_footer, where is the code that controls what this function does?

This could be multiple things. I’m not sure what the credits do. However, the chance is quite big that the search field is being created by a widget, shown in the get_sidebar(‘main’). Under “Appearance” > “Widgets”, you should be able to find more information. The template being called is probably sidebar-main.php. If it is a … Read more

Adding a class to tag list in a function

If you are passing the before parameter that you can simply add any class that you want. You then style that class in style.css. <?php if ( get_the_tag_list() ) { echo get_the_tag_list(‘<ul class=”tag-list”><li class=”tag-item”>’,'</li><li class=”tag-item”>’,'</li></ul>’); } ?>