Skip to content

Instantly share code, notes, and snippets.

View maintenance-mode.php
// Activate WordPress Maintenance Mode
function wp_maintenance_mode(){
if(!current_user_can('edit_themes') || !is_user_logged_in()){
wp_die('<h1 style="color:red">Website under Maintenance</h1><br />We are performing scheduled maintenance. We will be back online shortly!');
add_action('get_header', 'wp_maintenance_mode');
View handling-plurals.php
'One comment',
'%s comments',
number_format_i18n( get_comments_number() )
View link-in-paragraph-translation.php
View translating-html.php
<div class="site-info">
<a href="" >< ?php _e( 'Proudly powered by WordPress.', 'sample-plugin' ); ?></a>
View placeholders-print-function.php
__( 'Your color is %s.', 'sample-plugin' ),
View load-text-domain-plugin-function.php
function load_plugin_textdomain() {
load_plugin_textdomain( 'sample-plugin', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
add_action( 'plugins_loaded', 'load_plugin_textdomain' );
View internationalized-plugin-header.php
Plugin Name: Sample Plugin
Plugin URI:
Description: Sample plugin that's ready for translation
Author: John Doe
Version: 1.0
Author URI:
Text Domain: sample-plugin
Domain Path: /languages/
View open-graph-tags.php
<meta property="og:title" content="<?php echo the_title(); ?>"/>
<meta property="og:description" content="<?php echo $excerpt; ?>"/>
<meta property="og:type" content="article"/>
<meta property="og:url" content="<?php echo the_permalink(); ?>"/>
<meta property="og:site_name" content="<?php echo get_bloginfo(); ?>"/>
View open-graph-no-thumbnail.php
function fb_opengraph() {
global $post;
if(is_single()) {
if(has_post_thumbnail($post->ID)) {
View open-graph-other-html.php
function doctype_opengraph($output) {
return $output . '