Skip to content

Instantly share code, notes, and snippets.

View rinatkhaziev's full-sized avatar
🤖
Cache rules everything around me

Rinat K rinatkhaziev

🤖
Cache rules everything around me
View GitHub Profile
@rinatkhaziev
rinatkhaziev / acm_dfp.php
Created January 18, 2012 05:15
ACM DFP Setup
<?php
// Whitelist default double click url
add_filter( 'acm_whitelisted_script_urls', 'rk_acm_whiltelisted_script_urls');
function rk_acm_whiltelisted_script_urls( $whitelisted_urls ) {
$whitelisted_urls = array( 'ad.doubleclick.net' );
return $whitelisted_urls;
}
// Tokenize url
add_filter( 'acm_default_url', 'rk_acm_default_url' ) ;
@rinatkhaziev
rinatkhaziev / google-cse-shortcode.php
Created February 13, 2012 23:34
Google Custom Search Engine for WordPress (shortcode)
<?php
/** Use it as [google-cse id="your-google-cse-id"]
* Might need a little tweaking
*/
add_shortcode( 'google-cse', 'localtv_google_cse_shortcode' );
function localtv_google_cse_shortcode( $atts ) {
extract(
shortcode_atts(
array(
@rinatkhaziev
rinatkhaziev / cmb_get_meta.php
Created February 15, 2012 03:07
Easily get post meta values for Custom Metaboxes and Fields plugin
<?php
/**
* Easily get post meta value for Custom Metaboxes and Fields plugin
*
* @see https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress
*
* @param string $key to retrieve
* @param bool $echo if true then echo value
* @param string $sanitize_callback sanitize value with this callback
* @param string $cmb_prefix prefix of post meta
<?php
/**
* Additional setup for our freshly baked Ad Code Manager v0.2
* Not tested with v0.1
*
* Quick config for DFP JS API
*
*/
// Add additional output tokens
@rinatkhaziev
rinatkhaziev / video5.php
Created June 5, 2012 20:26
HTML5 video shortcode for WordPress
<?php
/**
* Shortcode callback [video5 src="" width="" height=""]
*
* @param array atts shortcode atts
* @return string HTML5 video tag
*/
add_shortcode( 'video5', function( $atts, $content = null ) {
global $content_width;
@rinatkhaziev
rinatkhaziev / dfp-iframes-example.php
Created June 22, 2012 22:08
Ad Code Manager DFP Iframes example
<?php
add_filter( 'acm_output_html', 'my_acm_output_html', 10, 2 );
function my_acm_output_html( $output_html, $tag_id ) {
switch ( $tag_id ) {
case 'my_leaderboard':
$output_html = '<a href="%url%"><img src="%image_url%" /></a>';
break;
case 'rich_media_leaderboard':
$output_html = '<script> // omitted </script>';
break;
@rinatkhaziev
rinatkhaziev / nginx-server-example-config.conf
Created July 10, 2012 00:26
Example config of an nginx server (aka site)
server {
## Your website name goes here.
server_name example.com;
listen 80;
## Your only path reference.
root /home/my/example/path/to/site;
error_log logs/example-error.log error;
access_log logs/example-access.log;
client_body_timeout 180;
client_body_buffer_size 8K;
@rinatkhaziev
rinatkhaziev / s-maintenance-mode.php
Created August 18, 2012 01:36 — forked from mjangda/s-maintenance-mode.php
Custom WordPress maintenance mode that allows super admins access to the Dashboard
<?php
add_action( 'init', 'x_maintenance_mode' );
function x_maintenance_mode() {
if ( defined( 'X_MAINTENANCE_MODE' ) && true === X_MAINTENANCE_MODE ) {
if ( is_super_admin() && is_admin() )
return;
die( 'Site is currently under maintenance' );
@rinatkhaziev
rinatkhaziev / git-to-svn.sh
Created October 22, 2012 19:37
Easily sync updates from a git repo to a svn repo
#/bin/bash
#use it like this: git-to-svn.sh /path/to/git/repo /path/to/svn/trunk
if [ -z "$1" ]; then
printf "\033[31;40mYou haven\'t specified the path to copy from\n"
printf "\033[00m"
fi
if [ -z "$2" ]; then
printf "\033[31;40mYou haven\'t specified the path to copy to\n"
printf "\033[00m"
exit
@rinatkhaziev
rinatkhaziev / git-svn-diff
Created May 24, 2013 16:29
Format git diff in svn patch
#!/bin/bash
#
# git-svn-diff originally by (http://mojodna.net/2009/02/24/my-work-git-workflow.html)
# modified by [email protected]
# modified by aconway@[redacted] - handle diffs that introduce new files
#
# Generate an SVN-compatible diff against the tip of the tracking branch
# Get the tracking branch (if we're on a branch)
TRACKING_BRANCH=`git svn info | grep URL | sed -e 's/.*\/branches\///'`