Skip to content

Instantly share code, notes, and snippets.

@zeropointdevelopment
zeropointdevelopment / 1-Gruntfile.js
Last active January 1, 2016 11:59
[WordPress] Code examples from our blog post - Installing and Using Grunt http://www.limecanvas.com/installing-and-using-grunt/
module.exports = function(grunt) {
// 1. All configuration goes here
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// 2. The plugin configuration
uglify: {
my_target: {
files: {
@zeropointdevelopment
zeropointdevelopment / functions.php
Created December 27, 2013 02:01
[WordPress] Code from our blog post - Using WordPress Transients to Reduce Database Load http://www.limecanvas.com/using-wordpress-transients-reduce-database-load/
global $wpdb;
$transient_name = 'lc-latest-10-posts';
$post_ids = get_transient( $transient_name );
if ( $post_ids == FALSE ){
$sql = "SELECT post.ID
FROM $wpdb->posts post
WHERE
post.post_type = 'post'
AND post.post_status = 'publish'
ORDER BY post.post_date
@zeropointdevelopment
zeropointdevelopment / conf.maldet
Created December 27, 2013 04:13
[WordPress] Code for out blog post - Installing Linux Malware Detect on a CentOS 6 VPS - http://www.limecanvas.com/installing-linux-malware-detect-centos-6-vps/
# [ EMAIL ALERTS ]
##
# The default email alert toggle
# [0 = disabled, 1 = enabled]
email_alert=1
# The subject line for email alerts
email_subj="maldet alert from $(hostname)"
# The destination addresses for email alerts
@zeropointdevelopment
zeropointdevelopment / functions.php
Created December 27, 2013 04:18
[WordPress] Code from our blog post - Changing the Default Outgoing WordPress Email Address - http://www.limecanvas.com/changing-the-default-outgoing-wordpress-email-address/
function lc_new_mail_from( $email ) {
$email = '[email protected]';
return $email;
}
add_filter( 'wp_mail_from', 'lc_new_mail_from' );
function lc_new_mail_from_name( $name ) {
$name = 'My Business Website';
@zeropointdevelopment
zeropointdevelopment / functions.php
Last active January 1, 2016 12:09
[WordPress] Code from our blog post - Passing Variables between PHP and jQuery - http://www.limecanvas.com/passing-variables-between-php-and-jquery/
// Load our jQuery script
function lc_load_jquery(){
wp_enqueue_script('lcjquerytest', get_stylesheet_directory_uri() . '/js/lc-jquery.js', array('jquery'), '1.0', true);
global $post;
$data = array( 'somestring' => 'pooky', 'post_id' => $post->ID, 'post_title' => $post->post_title )
wp_localize_script( 'lcjquerytest', 'lc_jqpost_info', $data );
}
add_action( 'wp_enqueue_scripts', 'lc_load_jquery' );
@zeropointdevelopment
zeropointdevelopment / functions.php
Created December 27, 2013 04:33
[WordPress] Code from our blog post How to Move Jetpack Social Buttons with Genesis - http://www.limecanvas.com/how-to-move-jetpack-social-buttons-with-genesis/
/** Jetpack Share Buttons **/
function lc_add_jetpack_share_buttons(){
remove_filter( 'the_content', 'sharing_display', 19 );
remove_filter( 'the_excerpt', 'sharing_display', 19 );
if ( function_exists( 'sharing_display' ) ) {
echo sharing_display();
}
}
add_action( 'genesis_before_post_content', 'lc_add_jetpack_share_buttons' );
@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" ]
@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
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: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();
}