Can my hooked uninstall class function access a global var declared in main plugin file?

The problem is that you aren’t declaring $dg_options as global here: define(‘DG_OPTION_NAME’, ‘document_gallery’); $dg_options = get_option(DG_OPTION_NAME); During uninstall you aren’t in the global scope, your file is being included by uninstall_plugin(). So you need to add this at the top of the main plugin file: global $dg_options; Really, any time you want a variable to … Read more

remove all submenus from plugin

Not without touching the global $submenu directly (which I wouldn’t recommend – using only purposefully exposed APIs provides, in general, better stability). However, if you wanted a function to remove all submenus: /** * Removes all submenus of given menu item * * @param string $menu_slug The slug of the parent menu to remove submenus … Read more

How do I add some javascript validation to the admin interface form’s onsubmit?

Every post / page / post type is wrapped around a universal form with the ID of #post. So if you want to validate a page before submitting it you just need to say something like: jQuery(document).ready(function($){ $(‘#post’).submit(function(){ // Validate Stuff return false; }); }); Then you’ll want to actually enqueue your javascript – View … Read more

Slashes stripped in ACF

Until this gets fixed, the only workaround I can see is to intercept the $_POST data and add extra slashes prior to ACF stripping them: /** * @link http://wordpress.stackexchange.com/q/143555/1685 */ function wpse_143555_acf_add_slashes() { if ( ! empty( $_POST[‘fields’] ) ) { foreach ( $_POST[‘fields’] as $k => $v ) { if ( ! is_array( $v … Read more

Proper way to use plugin functions in functions.php

The active theme’s functions.php is included on the backend because a theme can be configurable from the backend. If your theme depends on the functions of a plug-in being available, then you must either make sure the plug-in is always available or make your theme robust enough to handle situations where it isn’t. You could … Read more