Plugin uninstall function is not working

register_deactivation_hook() is launched when a plugin is deactivated. For plugin uninstall, there is register_uninstall_hook(). WordPress plugins can also have a file called uninstall.php that is ran whenever the plugin is uninstalled. To prevent the uninstall.php file from being triggered directly, the state of a constant called WP_UNINSTALL_PLUGIN should be checked before launching the codes for … Read more

Silently register plugin pages

The mighty Codex holds the answers: If you’re running into the »You do not have sufficient permissions to access this page.« message in a wp_die() screen, then you’ve hooked too early. The hook you should use is admin_menu. $parent_slug: Use NULL or set to options.php if you want to create a page that doesn’t appear … Read more

Can’t find where to modify attrbitutes

If you can’t edit your header.php, or would prefer not to, most decent WordPress themes should have (and certainly any that pass theme review to be in the official repository) <html <?php language_attributes();?> > in the opening html tag in the header.php template. There is a filter in the language_attributes() function that allows plugins/child themes … Read more

wordpress is adding a second backslash when I use addslashes

In your code json_encode() function causes to add second backslash on the following line. $data = json_encode($item_data); Add the following code in place of above code so it will replace double backslashes with single backslash in data returned by json_encode function. $data = str_replace(“\\\'”,”\\'”,json_encode($item_data )); Visit following links for more information on json_encode function. json_encode … Read more

json_decode does not work on WordPress

I tried to parse your JSON into this and got an error that you have bad escaped characters (backslash must be escaped). Taking into account Vinod Dalvi’s comment, the definition of json_encode in WordPress is wrapped by function_exists(). I guess if you have PHP version of 5.2 or above (which I think you have, because … Read more

jquery & ajax sending data to php

First of all, your js is wrong, you are mixing the syntax of jQuery.post() and of jQuery.ajax() You should use jQuery.ajax({ type: “POST”, url: ajaxurl, data: { action: “lu_ajax”, status: “enabled” }, success: function( data ) { alert(data); } }); or jQuery.post( ajaxurl, { action: “lu_ajax”, status: “enabled” }, function(data) { alert(data); } ); After … Read more

Declare plugin dependency [duplicate]

It’s not possible in the core. There are a few ways to approach this. 1. Hook into plugins_loaded check to see if X from your dependency plugin exists. add_action(‘plugins_loaded’, ‘wpse120377_load’); function wpse120377_load() { if (!class_exists(‘Some_Class_From_Another_Plugin’)) { // dependency not installed, bail return; } // load the rest of your plugin stuff here } Hooking into … Read more