Skip to content

Instantly share code, notes, and snippets.

View taras's full-sized avatar

Taras Mankovski taras

View GitHub Profile
@taras
taras / wp-config.php
Created July 17, 2012 11:35
Sunrise Production Configuration
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
* by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
@taras
taras / plugin-loader.php
Created July 17, 2012 11:56
Great Jakes Rainmaker Required Plugin Loader
<?php
/*
Plugin Name: Great Jakes Rainmaker Required Plugin Loader
Description: Loads all the required plugins for the Great Jakes Rainmaker
Version: 0.2
Author: Great Jakes
Author URI: http://www.greatjakes.com
Location: /wp-content/mu-plugins/
*/
<?php
/**
* This script allows to update any directory from its repository if one exists.
*
* Setup:
* 1. Upload update.php file into wp-content directory
* 2. Make update.php executable
* 3. Add the following rewrite rule to your .htaccess at the top
* RewriteRule ^(.*)update$ /wp-content/update.php?path=$1 [QSA,PT]
*
<?php
/*
Plugin Name: Great Jakes Rainmaker Required Plugin Loader
Description: Loads all the required plugins for the Great Jakes Rainmaker
Version: 0.2
Author: Great Jakes
Author URI: http://www.greatjakes.com
Location: /wp-content/mu-plugins/
*/
@taras
taras / class.Post.php
Created October 6, 2012 16:20
PHP function to extract URLs from post text.
/**
* Extract URLs from post text.
* Find syntactically correct URLs such as http://foobar.com/data.php and some plausible URL fragments, e.g.
* bit.ly/asb12 www.google.com, and fix URL fragments to be valid URLs.
* Only return valid URLs
* Regex pattern based on http://daringfireball.net/2010/07/improved_regex_for_matching_urls
* with a modification in the third group to ensure that https?:/// (third slash) doesn't match.
* @param string $post_text
* @return array $matches
*/
@taras
taras / gist:4022609
Created November 6, 2012 04:38
My failed attempt at getting dynamic_sidebar() to work with switch_to_blog()
<?php
if ( !is_admin() ) {
add_filter('sidebars_widgets', 'ichannel_load_parent_widgets');
}
/**
* Filter loads sidebars from the parent site if current site's sidebar is empty.
* Also loads widgets from parent site into current site.
*
* @param $sidebar_widgets array
@taras
taras / purge.php
Created November 13, 2012 15:26
Script that empties Varnish Cache
# get param
$url = $_POST["url"];
$host = $_POST["host"];
$ip = "127.0.0.1";
$port = "80";
$timeout = 1;
$verbose = 1;
@taras
taras / gist:4113921
Created November 19, 2012 21:10
Show a list of videos associated to a comedian
<?php
# save the current $post because we'll be overwriting it later
# we want to make sure he doesn't get lost
$comedian = $post;
# get the videos associated to this comedian
if ( $videos = get_field('featured_in_videos') ) : ?>
<div class="row">
<h3>Comedian Videos</h3>
<?php
@taras
taras / video-thumbnail.php
Created November 19, 2012 21:17
Example of Video Thumbnail Template
<div class="post <?php echo get_post_type() ?>">
<a href="<?php the_permalink() ?>">
<?php the_post_thumbnail('video-thumbnail'); ?>
</a>
</div>
@taras
taras / single.php
Created November 21, 2012 22:29
Twitter Bootstrap single.php
<?php get_header(); ?>
<div id="content-wrap" class="container-fluid">
<div class="row-fluid">
<?php if ( have_posts() ) : ?>
<div id="content" class="span8">