Category Archives: Snippets

Git: Delete Last Commit

Everyone who’s used Git for long enough has committed something they didn’t mean to — a debug print left in, a config file with the wrong values, a commit message that’s just “wip.” The fix depends entirely on one question: has that commit been pushed anywhere yet? This post walks through both cases. It’s the twelfth post in this site’s Git command guide, following Git Log.

Continue reading Git: Delete Last Commit

Working With wp_register_script()

WordPress lets you register your own script files with your theme or plugin instead of hardcoding a <script> tag into your header or footer. The traditional approach loads scripts unconditionally on every page, whether they’re needed or not, and gives WordPress no way to manage load order or avoid duplicate copies of the same library. Registering scripts with wp_register_script() (and loading them with wp_enqueue_script()) lets WordPress handle dependencies, versioning, and placement for you, which keeps your site faster and your script loading predictable.

So how do you register a script?

Use the following syntax to register a script. This is typically called inside a function hooked to wp_enqueue_scripts (more on that below).


wp_register_script( $handle, $src, $deps, $ver, $in_footer );
Continue reading Working With wp_register_script()

Git – Autocorrect Spelling

Git has a built-in typo handler that most people never turn on: help.autocorrect. By default Git just suggests the command it thinks you meant, but you can configure it to run the correction automatically, with or without a delay. This is the thirteenth and last post in this site’s Git command guide — a smaller, more personal config topic to close out with, following Git: Delete Last Commit.

Continue reading Git – Autocorrect Spelling

Hide the Admin Bar in WordPress

As you know whenever an user login to WordPress system, who-ever it may be admin or just a subscriber, WordPress automatically shows an admin bar at top of the screen. If the user is administrator then this admin bar provides some useful functionality such as links to navigate to various admin panels of websites, moderating comments, shows available updates etc. The options may be vary depending upon the plugins you have installed.

You might know that this admin bar can be hidden form Profile > Toolbar > Uncheck “Show Toolbar when viewing site”. This is something depends on user’s will. If they like that admin bar they will not hide it. But it may happen that, you want to hide admin bar for all users maybe due to it interferes with your design. Both methods below are still valid in current WordPress: the show_admin_bar filter hides the bar sitewide for every user, while the show_admin_bar_front user meta lets you hide it for a specific user only.

Option 1: Hide for all users (sitewide)

Add this to your theme’s functions.php or a site-specific plugin:
add_filter( 'show_admin_bar', '__return_false' );

Option 2: Hide for the current user only

Call this once (e.g. on a settings save or a one-time migration) to set the preference for the currently logged-in user:
// Hide admin bar for the current user only
update_user_meta( get_current_user_id(), 'show_admin_bar_front', false );
Now the admin bar will be hidden from all users (Option 1) or just the chosen user (Option 2). That’s all. Thank you WordPress hooks!