Maintenance Mode in WordPress

In WordPress 3.0 wp_maintenance() function introduced to die with a maintenance message when conditions are met. You need to create a file .maintenance in the WordPress root directory. In this file, you need to add variable $upgrading and set to the time the file was created. If the file was created less than 10 minutes ago, WordPress enters maintenance mode and displays a message.

You can also display maintenance message more than 10 minutes by adding following code in .maintenance file.

$upgrading = time();

Here, we’ve set current time in $upgrading variable. So WordPress will display maintenance message until you delete .maintenance file.

In WordPress 4.6, enable_maintenance_mode filter introduced to enable/disable maintenance mode. This filter runs before it can be used by plugins. It is designed for non-web runtimes. If this filter returns true, maintenance mode will be active and the request will end. If false, the request will be allowed to continue processing even if maintenance mode should be active.

Default maintenance message is Briefly unavailable for scheduled maintenance. Check back in a minute. The default message can be replaced by using a drop-in (maintenance.php in the wp-content directory).

How to get sample permalink

My colleague was working on an issue where we needed a permalink of the draft post. So he used get_permalink() function to get post permalink. However the get_permalink() returns URL something like and we needed full permalink something like

The get_permalink() function returns full permalink for the published post only. He explored WordPress codebase and he found get_sample_permalink() which returns an array containing the sample permalink with a placeholder for the post name, and the post name.

Visual Studio Code Editor for WordPress Development

I’m using Visual Studio Code editor for WordPress Development. Following are the list of extensions and theme I have installed.


WordPress Toolbox – The ultimate WordPress snippet collection for Visual Studio Code.

WooCommerce – Snippets & autocomplete – A collection of WooCommerce snippets and autocompletion.

PHP IntelliSense – Advanced Auto completion and Refactoring support for PHP

PHP Intelephense – High performance, feature rich PHP intellisense

phpcs – PHP CodeSniffer for Visual Studio Code

phpcbf – PHP Code Beautifier and Fixer

PHP DocBlocker – A simple, dependency free PHP specific DocBlocking package

PHP Debug – Debug support for PHP with Xdebug

GitLens — Git supercharged – Supercharge the Git capabilities built into Visual Studio Code — Visualize code authorship at a glance via Git blame annotations and code lens, seamlessly navigate and explore Git repositories, gain valuable insights via powerful comparison commands, and so much more

Git History – View git log, file history, compare branches or commits

GitHub Pull Requests – Pull Request Provider for GitHub

WPCS Whitelist Flags – Add WordPress Coding Standards whitelist flags to your code.

Prettify Selected JSON – VS Code Extension to prettify selected JSON blocks

XML Tools – XML Formatting, XQuery, and XPath Tools for Visual Studio Code

Rainbow CSV – highlight csv and tsv files in different colors

Excel Viewer – View Excel spreadsheets and CSV files within Visual Studio Code workspaces.

Code Runner – Run code snippet or code file for multiple languages

Debugger for Chrome – Debug your JavaScript code in the Chrome browser, or any other target that supports the Chrome Debugger protocol.

Remote – SSH – Open any folder on a remote machine using SSH and take advantage of VS Code’s full feature set.

Remote – Containers – Open any folder inside (or mounted into) a container and take advantage of Visual Studio Code’s full feature set.

Settings Sync – Synchronize Settings, Snippets, Themes, File Icons, Launch, Keybindings, Workspaces and Extensions Across Multiple Machines Using GitHub Gist.


Shades of Purple – ⚡ A professional theme with hand-picked & bold shades of purple 💜 to go along with your VS Code. A custom VS Code theme with style.


Following are the settings I’ve set. Some settings for the Shades of Purple theme and extensions I’ve installed. I’m using Fira Code font.

Refer User and Workspace Settings document page to learn more.

"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"breadcrumbs.enabled": true,
"window.zoomLevel": 0,
"explorer.confirmDragAndDrop": false,
"explorer.confirmDelete": false,
"diffEditor.ignoreTrimWhitespace": false,
"window.restoreFullscreen": true,

"workbench.colorTheme": "Shades of Purple",
"workbench.sideBar.location": "left",
"workbench.settings.editor": "json",
"workbench.startupEditor": "newUntitledFile",
"workbench.editor.enablePreview": false,
"workbench.fontAliasing": "auto",
"": false,
"workbench.editor.tabCloseButton": "off",
"workbench.panel.defaultLocation": "right",

"php.suggest.basic": false,
"[php]": {
	"editor.formatOnSave": false,
	"editor.formatOnPaste": false,
	"editor.defaultFormatter": "persoderlind.vscode-phpcbf"
"phpcs.enable": true,
"phpcs.standard": "WordPress",
"phpcs.ignorePatterns": [
"phpcbf.enable": true,
"phpcbf.standard": "WordPress",
"php-docblocker.useShortNames": true,

"editor.fontSize": 14,
"editor.insertSpaces": false,
"editor.detectIndentation": false,
"editor.minimap.enabled": false,
"editor.fontFamily": "Fira Code, Menlo, Monaco, 'Courier New', monospace",
"editor.lineHeight": 24.65,
"editor.letterSpacing": 0.5,
"editor.fontWeight": "300",
"editor.fontLigatures": true,
"editor.cursorStyle": "line",
"editor.cursorBlinking": "solid",
"editor.renderWhitespace": "all",
"editor.snippetSuggestions": "top",
"editor.glyphMargin": true,
"editor.quickSuggestionsDelay": 0,

"terminal.integrated.fontFamily": "Fira Code, Menlo, Monaco, 'Courier New', monospace",
"terminal.integrated.fontSize": 14,
"terminal.integrated.fontWeight": "300",
"terminal.integrated.fontWeightBold": "normal",
"terminal.integrated.macOptionIsMeta": true,
"terminal.integrated.drawBoldTextInBrightColors": false,

"emmet.triggerExpansionOnTab": true,
"emmet.includeLanguages": {
	"javascript": "javascriptreact"

wp_cache_flush() – Think twice before using it

wp_cache_flush() is WordPress core function which can be used to flush entire object cache. But why I said, “Think twice before using it“. There is a reason why not to use this function in the plugin/theme.

Continue reading “wp_cache_flush() – Think twice before using it”

Functions and Hooks for Comment Template

Following are the list of functions and hooks for Comment Template. Continue reading “Functions and Hooks for Comment Template”

Functions and Hooks in Comment API

Following are the list of functions and hooks of Comment API. Continue reading “Functions and Hooks in Comment API”

Hooks and Functions for Meta Box

Following are the hooks and functions which use to add custom meta boxes to one or more screens.



WordPress widgets – where and how they are saved in database

In this article, I will tell you how WordPress widgets stored in {prefix}_options table as key/value pair when you set widget in a sidebar.

sidebars_widgets and widget_{widget_ID}  are the options.

Continue reading “WordPress widgets – where and how they are saved in database”

REST API – Filter REST URL prefix

REST API architecture is included in WordPress 4.4 version. So you can register custom REST API endpoints. Default REST API URL prefix is wp-json. Continue reading “REST API – Filter REST URL prefix”

WordPress is Now Fully Translated Into Gujarati

હવે વર્ડપ્રેસ ગુજરાતી બોલશે. It was great experience as General Translation Editors (GTE) and Translation Contributors. I have started use of WordPress in Gujarati language on one of my blog. Thanks to all contributors. Continue reading “WordPress is Now Fully Translated Into Gujarati”

%d bloggers like this: