Skip to content

Instantly share code, notes, and snippets.

@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
*
@aahan
aahan / WordPress Custom Global Variables.md
Last active March 28, 2024 19:26
Creating and using custom global variables in wordpress.

First create global variables (in functions.php or as a mu-plugin):

<?php

/*
 * CUSTOM GLOBAL VARIABLES
 */
function wtnerd_global_vars() {
@aahan
aahan / wp-seo-filters.php
Created November 13, 2013 13:36
WordPress SEO by Yoast filters
<?php
// Remove Canonical Link Added By Yoast WordPress SEO Plugin
function at_remove_dup_canonical_link() {
return false;
}
add_filter( 'wpseo_canonical', 'at_remove_dup_canonical_link' );
function wpseo_attachment_canonical_parent( $canonical ) {
@aahan
aahan / fetch_kindle.js
Created January 17, 2021 13:13 — forked from yangchenyun/fetch_kindle.js
Get back my books from Kindle
/*
* @fileoverview Program to free the content in kindle books as plain HTML.
*
* This is largely based on reverse engineering kindle cloud app
* (https://read.amazon.com) to read book data from webSQL.
*
* Access to kindle library is required to download this book.
*/
// The Kindle Compression Module copied from http://read.amazon.com application
@aahan
aahan / WordPress Custom Sender Name & Email Address.php
Last active October 14, 2016 08:11
Different solutions that've found to replace WordPress' default admin email address and name. Should be added to your theme's functions.php file.
<?php
/*
* DESCRIPTION: All WordPress email notifications are sent from
* wordpress@yourdomain.com with the sender's name as "WordPress".
* Any one of these functions should help you change that.
*
* Relevant WordPress core file is /wp-includes/pluggable.php
*/
@aahan
aahan / nginx.conf
Created August 15, 2016 11:18 — forked from markjaquith/nginx.conf
My WordPress Nginx setup
upstream phpfpm {
server unix:/var/run/php5-fpm.sock;
}
upstream hhvm {
server unix:/var/run/hhvm/hhvm.sock;
}
# SSL
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;