Clean-up script tags

If you really want to do this, then it should already be possible. The global $wp_scripts is an instance of the WP_Scripts class, which is an instance of the WP_Dependencies class. So in theory (not tested), you should be able to do something like this: function alter_script_tags() { echo ‘<pre>’; print $GLOBALS[‘wp_scripts’]->print_html; echo ‘</pre>’; } … Read more

Changing post category from dropdown

Your form is using ‘get’ ( $_GET ), but addcat.php is looking for $_POST values. That is never going to work. But beyond that, you’ve got a pretty convoluted thing going on here. You don’t really both the hooked function and addcat.php. You need one or the other, and the hooked function is probably the … Read more

Actions according to image type and size

That function looks like the kind of thing that would slow down a site. 🙂 The first thing I’d recommend is that you not run that function on the front end. Run it when the image is uploaded and store the result in the database using wp_update_attachment_metadata. You can then retrieve the data with wp_get_attachment_metadata. … 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