What is an alternative method to the WordPress private _doing_it_wrong() function

What is an alternative method to the WordPress private _doing_it_wrong() function? There’s no way that WordPress is ever going to get rid of the _doing_it_wrong() function, so it’s perfectly safe to use it. But if for some reason you don’t want to use it because it’s marked private, then you could create a plugin that … Read more

Custom action button in Gutenberg editor (post_submitbox_misc_actions – equivalent)

wp_enqueue_script( ‘some-slug’, ‘/path/to/script.js’, array( ‘wp-edit-post’, ‘wp-plugins’, ‘wp-i18n’, ‘wp-element’ ), ‘0.1’ ); script.js: var el = wp.element.createElement; var __ = wp.i18n.__; var registerPlugin = wp.plugins.registerPlugin; var PluginPostStatusInfo = wp.editPost.PluginPostStatusInfo; var TextControl = wp.components.TextControl; function MyPostStatusInfoPlugin({}) { return el( PluginPostStatusInfo, { className: ‘my-post-status-info’ }, el( TextControl, { name: ‘my_edit_summary’, label: __( ‘Edit summary’ ), help: __( ‘Briefly … Read more

Completely remove WP_Admin_Bar for specific user roles

Add the following to your functions.php file as detailed here. Disable Admin Bar for everyone: // Disable Admin Bar for everyone if (!function_exists(‘disable_admin_bar’)) { function disable_admin_bar() { // for the admin page remove_action(‘admin_footer’, ‘wp_admin_bar_render’, 1000); // for the front-end remove_action(‘wp_footer’, ‘wp_admin_bar_render’, 1000); // css override for the admin page function remove_admin_bar_style_backend() { echo ‘<style>body.admin-bar #wpcontent, … Read more

WordPress 4.5 deprecated get_currentuserinfo()

The answer lies within the wp_get_current_user() pluggable function. I simply changed the function name get_currentuserinfo() to wp_get_current_uesr() then made sure the returns were not boolean but return $current_user. This seems to be working well, including caching, etc. Hopefully this helps others. if ( ! function_exists( ‘wp_get_current_user’ ) ) : /** * This replacement function will … Read more

Strategies to implement selective loading of plugins

Filter option_active_plugins. You can change the result of get_option() here without actually changing the database. if ( defined( ‘DOING_AJAX’ ) && DOING_AJAX ) add_filter( ‘option_active_plugins’, ‘disable_plugins_temporary’ ); function disable_plugins_temporary( $plugins ) { // unset plugins you don’t need, then return $plugins; } Background wp_get_active_and_valid_plugins() calls get_option( ‘active_plugins’, array() ) to get the active plugins. In … Read more

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