Skip to content

Instantly share code, notes, and snippets.

Official Discourse Install Guide

Recommended Server Hardware

  • 2 GB of RAM
  • 2 GB of swap
  • 2 processor cores

With 2 GB of memory and dual cores, you can run two instances of the thin server (NUM_WEBS=2), and easily host anything but the largest of forums.

@aahan
aahan / wp-code-shortcode.php
Last active March 28, 2024 19:27
Enclose code blocks within [code] shortcode, and let PHP and WordPress take care of the rest.
<?php
/*
* Functionality to set up custom shortcode correctly.
*
* This function is attached to the 'the_content' filter hook.
*/
add_filter( 'the_content', 'run_bbcodes', 7 );
function run_bbcodes( $content ) {
<?php
/**
* Plugin Name: Snippets Shortcode
* Plugin URI: http://wordpress.stackexchange.com/q/116044/12615
* Description: Add code snippets as a Custom Post Type. Display in regular posts and pages using a Shortcode. Rendered with Google Prettify in frontend.
* Version: 1.0
* Author: Rodolfo Buaiz
* Author URI: http://brasofilo.com
* License: GPLv2 or later
*
<!-- Published Date -->
<span class="posted-on"><time class="entry-date published" datetime="<?php the_time('c'); ?>" pubdate title="Published on <?php the_time('d M, Y \a\t H:i:s T'); ?>"><?php the_time('d M Y'); ?></time></span>
<!-- Last Modified Date -->
<span class="modified-on"><time class="updated" datetime="<?php the_modified_time('c'); ?>" title="Last updated on <?php the_modified_time('d M, Y \a\t H:i:s T'); ?>"><?php the_modified_time('j F, Y'); ?></time></span>
<!-- Post Author (Anchor) -->
<?php
/* Register custom post types on the 'init' hook. */
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 0.1.0
* @access public
<?php
/*
* How to use `get_post_type_object` function
* http://wordpress.stackexchange.com/q/6731
*/
if( !in_array( $post->post_type, array( 'post', 'page' ) ) ) {
// if( 'post' != get_post_type() || 'page' != get_post_type() ) {
@aahan
aahan / convert-date-format.php
Last active December 25, 2015 22:49
Convert date to a different format.
<?php
/*
* Always input date in ISO 8601 format (YYYY-MM-DDThh:mm:ss.sTZD) to
* allow for conversion to a different format before display.
*
* e.g. 1997-07-16T19:20:30.45+01:00, 1997-07-16
*
* http://www.w3.org/TR/NOTE-datetime
* http://php.net/manual/en/function.date.php
<?php
function h5bs_enqueue_scripts() {
wp_enqueue_script( 'typekit', '//use.typekit.net/xxxxxxx.js' );
}
add_action( 'wp_enqueue_scripts', 'h5bs_enqueue_scripts' );
function h5bs_typekit_inline() {