Skip to content

Instantly share code, notes, and snippets.

View illucent's full-sized avatar
🎯
Focusing

Andrew Starodubtsev illucent

🎯
Focusing
View GitHub Profile
@illucent
illucent / gist:e9084fb6e116f6a5adb2
Last active August 27, 2015 06:57 — forked from isGabe/gist:3072378
Load jQuery fron Google CDN with local fallback - WordPress style
<?php
/*
**** Load jQuery from Google CDN if available, local fallback if not ****
** Place in your theme's functions.php or relevant file. Edit local jQuery path if needed.
** Works as-is with WordPress Bones Theme v1.2 https://github.com/eddiemachado/bones (replace wp_enqueue_script( 'jquery' ); on line 142
** reference: http://wp.tutsplus.com/tutorials/load-jquery-from-google-cdn-with-local-fallback-for-wordpress/
*/
@illucent
illucent / gist:8845269
Created February 6, 2014 14:31
list wp page eg. sitemap
<?php
$parent = "PARENT_PAGE_ID";
$args = array(
'depth' => 0,
'show_date' => '',
'date_format' => get_option('date_format'),
'child_of' => $parent,
'exclude' => '',
'include' => '',
'title_li' => __(''),
@illucent
illucent / gist:8862662
Created February 7, 2014 13:31
colums
<?php
query_posts('YOUR QUERY HERE');
$i = 0;
// Thanks to PaoloVIP for the suggestion to add round() for loops with an odd # of results
if ( have_posts() ) : while ( have_posts() ) : the_post();
if ($i == 0) echo '<div id="left">';
if ($i == (round($wp_query->post_count / 2))) echo '</div><div id="right">';
the_content(); // or whatever custom content you desire
if ($i == round($wp_query->post_count)) echo '</div>';
$i++;
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/query.php
* http://www.inteligraphics.ro/2013/06/20/wordpress-wp_query-args-parameters-list/
*/
<?php
function revconcept_get_images($post_id) {
global $post;
$thumbnail_ID = get_post_thumbnail_id();
$images = get_children( array('post_parent' => $post_id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
if ($images) :
<?php
/**
* Get a list of downloads
*
* Return an array of downloads suitable for CMB's select field.
*
* Example CMB select field usage:
*
* array(
* 'name' => 'Download',
function ajax_get_latest_posts(){
$attachments = get_children(array('post_parent' => $post->ID,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order ID'));
$allimagesizes = array();
foreach($attachments as $att_id => $attachment) {
<?php
// Reduced to the minimum
class ThumbnailFilter extends FilterIterator
{
private $wp_query;
public function __construct( Iterator $iterator, WP_Query $wp_query )
{
NULL === $this->wp_query AND $this->wp_query = $wp_query;
parent::__construct( $iterator );
<?php
/**
* Settings
*/
define('API_KEY', $_GET['apikey']); // CloudFlare API key
define('USERNAME', 'user@example.com'); // Email address used to login into CloudFlare
define('IP', getCurrentIP()); // Current IP address
echo 'Setting IP address to "' . IP . '"...<br />';
--- ddclient-3.8.1/ddclient 2011-07-11 15:04:21.000000000 -0600
+++ ddclient 2013-10-30 19:51:54.056629680 -0600
@@ -1,4 +1,3 @@
-#!/usr/bin/perl -w
#!/usr/local/bin/perl -w
######################################################################
# $Id: ddclient 130 2011-07-11 21:02:07Z wimpunk $
@@ -13,12 +12,18 @@
# Support for multiple IP numbers added by
# Astaro AG, Ingo Schwarze <ischwarze-OOs/4mkCeqbQT0dZR+AlfA@public.gmane.org> September 16, 2008