Skip to content

Instantly share code, notes, and snippets.

@zeropointdevelopment
zeropointdevelopment / code-snippet-1.php
Created December 27, 2013 05:38
[WordPress] Code from our blog post Adding Custom Image Sizes to WordPress 3.5 Media Manager - http://www.limecanvas.com/adding-custom-image-sizes-to-wordpress-3-5-media-manager/
// Add new image sizes
function lc_insert_custom_image_sizes( $image_sizes ) {
// get the custom image sizes
global $_wp_additional_image_sizes;
// if there are none, just return the built-in sizes
if ( empty( $_wp_additional_image_sizes ) )
return $image_sizes;
// add all the custom sizes to the built-in sizes
foreach ( $_wp_additional_image_sizes as $id => $data ) {
@zeropointdevelopment
zeropointdevelopment / code-snippet-1.txt
Created December 27, 2013 05:34
[WordPress] Code from our blog post Speed Up Your Website using Caching and .htaccess - http://www.limecanvas.com/speed-up-your-website-using-caching-and-htaccess/
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault A300
# Expires after 1 month
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType application/pdf A2592000
@zeropointdevelopment
zeropointdevelopment / code-snippet-1.php
Last active January 1, 2016 12:09
[WordPress] Code from our blog post Integrating JetPack Infinite Scroll with Genesis - http://www.limecanvas.com/integrating-jetpack-infinite-scroll-with-genesis/
/**
* Add support for JetPack infinite scroll
**/
function lc_infinite_scroll_init() {
add_theme_support( 'infinite-scroll', array(
'container' =&gt; 'content',
'footer' =&gt; 'footer',
'render' =&gt; 'genesis_do_loop'
) );
}
@zeropointdevelopment
zeropointdevelopment / code-snippet-1.bash
Created December 27, 2013 05:26
[WordPress] Code from our blog post Recursively Set WordPress File Permissions - http://www.limecanvas.com/recursively-set-wordpress-file-permissions/
#!/bin/sh
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Wil Brown
#
# @uses /bin/sh scriptname.sh path
# @params text path to your WordPress folder from the www root e.g. / or /WordPress
#
@zeropointdevelopment
zeropointdevelopment / code-snippet-1.php
Last active January 1, 2016 12:09
[WordPress] Code from our blog post Customising the JetPack Infinite Scroll Footer - http://www.limecanvas.com/customising-the-jetpack-infinite-scroll-footer/
/**
* The Infinite Blog Footer
*
* @uses self::get_settings, self::set_last_post_time, self::archive_supports_infinity, __, wp_get_theme, get_current_theme, apply_filters, home_url, esc_attr, get_bloginfo, bloginfo
* @return string or null
*/
function footer() {
// Bail if theme requested footer not show
if ( false == self::get_settings()->footer )
return;
@zeropointdevelopment
zeropointdevelopment / code-snippet-1.php
Last active January 1, 2016 12:09
[WordPress] Code from our blog post Using the Infinite Scroll Module in JetPack - http://www.limecanvas.com/using-the-infinite-scroll-module-in-jetpack/
/**
* Add support for JetPack infinite scroll
**/
add_theme_support( 'infinite-scroll', array(
'container' =&gt; 'content',
'footer' =&gt; 'page',
)
);
@zeropointdevelopment
zeropointdevelopment / code-snippet-1.php
Created December 27, 2013 04:59
[WordPress] Code from our blog post Pimp My WordPress Maintenance Mode Message - http://www.limecanvas.com/pimp-my-wordpress-maintenance-mode-message/
if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
require_once( WP_CONTENT_DIR . '/maintenance.php' );
die();
}
@zeropointdevelopment
zeropointdevelopment / code-snippet-1.php
Created December 27, 2013 04:54
[WordPress] Code from our blog post How to get Gallery Images in WordPress 3.5 - http://www.limecanvas.com/how-to-get-gallery-images-in-wordpress-3-5/
/** Grab IDs from new WP 3.5 gallery **/
function lc_grab_ids_from_gallery() {
global $post;
$attachment_ids = array();
$pattern = get_shortcode_regex();
$ids = array();
if (preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches ) ) { //finds the "gallery" shortcode and puts the image ids in an associative array at $matches[3]
$count=count($matches[3]); //in case there is more than one gallery in the post.
@zeropointdevelopment
zeropointdevelopment / code-snippet-1.php
Created December 27, 2013 04:46
[WordPress] Code from our blog post Passing Parameters to a Video Link in a WordPress Custom Field - http://www.limecanvas.com/passing-parameters-to-a-video-link-in-a-wordpress-custom-field/
// Filter video output
add_filter('oembed_result','lc_oembed_result', 10, 3);
function lc_oembed_result($html, $url, $args) {
// $args includes custom argument
$newargs = $args;
// get rid of discover=true argument
array_pop( $newargs );
@zeropointdevelopment
zeropointdevelopment / code-snippet-1.php
Last active January 1, 2016 12:09
[WordPress] Code from our blog post A MailChimp Opt-in Field for Contact Form 7 - http://www.limecanvas.com/a-mailchimp-opt-in-field-for-contact-form-7/
[ text* your-name 58/ ]
[ email* your-email 58/ ]
[ checkbox mailchimp-optin default:1 use_label_element "Subscribe to our newsletter" ]