Automatic updates in plugin – not hosted on wordpress repository

You actually have several questions in there, so I’ll answer them one by one: However, if I simply do this on my main plugin file, it doesn’t work: add_filter(‘pre_set_site_transient_update_plugins’, array(‘XYZ’, ‘check_update’)); First of all, I’d like to understand what’s the difference between the two scenarios. This is failing because you are calling the method statically, … Read more

Get list of scripts / styles and show file which enqueued them

This is not possible the way you think. It would maybe be possible if you use Reflections or debug_backtrace(), but there’s no reliable way to do this. WordPress does not keep a stack or queue where it tracks file names. The only thing I could imagine is just hooking into the action and inside wp_enqueue_scripts(): … Read more

Can I use the wp media uploader for my own plugin?

You can use wp_enqueue_media() in your admin_enqueue_scripts hook. In a javascript file hook it into a button and use insert event to capture the selected image’s details $(‘.media-button’).click(function() { var media_uploader = wp.media({ frame: “post”, text : “Add image”, state: “insert”, multiple: false }); media_uploader.on(“insert”, function(){ var json = media_uploader.state().get(“selection”).first().toJSON(); var image_name = json.filename; var … Read more

Add Custom User Capabilities Before or After the Custom User Role has Been Added?

There’s a reason why add_role() has the $capabilities as 3rd parameter. First some insights on what happens, when you use the function. It calls WP_Roles->add_role() – the class method The method then does a check if the role already exists. If yes, it aborts. The next step is, that it adds the role to WP_Roles->roles[] … Read more

How to add custom content template part for a custom post type on main query using a plugin

Background Unfortunately get_template_part() function doesn’t have any suitable filter to achieve what you want. It’s possible to use the get_template_part_{$slug} action hook to inject template parts, however, without any change to your theme or a child theme, the original template part will be added anyway. So this way you’ll not be able to replace existing … Read more

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