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 / simple-ndn-embed.php
Last active August 29, 2015 14:01
Simple shortcode callback for v2 NDN player
<?php
/*
Plugin Name: Doejo NDN Shortcode
Description: Simple NDN Shortcode
Author: Rinat Khaziev, doejo
Version: 0.7.5
Author URI: http://digitallyconscious.com
GNU General Public License, Free Software Foundation <http://creativecommons.org/licenses/GPL/2.0/>
{
"suggest": {
"text": keyword,
"title-suggest": {
"term": { "field": "title" },
"size": 3
},
}
@rinatkhaziev
rinatkhaziev / filter_wpcom_elasticsearch_query_args.php
Created October 6, 2014 14:25
wpcom_elasticsearch_query_args example nested boolean OR filter
<?php
/**
* ES Query args filter
*/
add_filter( 'wpcom_elasticsearch_query_args', function( $args, $query ) {
// Modify sort query
$args['sort'] = array(
array(
'modified' => array( "order" => 'desc' ),
),
@rinatkhaziev
rinatkhaziev / fu-akismet.php
Created October 22, 2014 01:01
Akismet 3 integration for Frontend Uploader
<?php
/**
* Akismet 3 integration
*/
add_filter( 'fu_should_process_content_upload', 'fu_akismet_check_submission', 10, 2 );
function fu_akismet_check_submission( $should_process, $layout ) {
// Akismet is not enabled or not configured, or too old, just return the filter value
if ( ! class_exists( 'Akismet' ) || !method_exists( 'Akismet', 'get_api_key' ) || ! Akismet::get_api_key() )
return $should_process;
@rinatkhaziev
rinatkhaziev / dfp-async-mulltisizes.php
Created September 15, 2015 20:32
Multiple sizes per slot
<?php
add_filter( 'acm_ad_tag_ids', 'my_acm_ad_tag_ids' );
function my_acm_ad_tag_ids( $tag_ids ) {
$tag_ids[] = array(
'tag' => 'flex-leaderboard', // tag_id
'url_vars' => array(
'sizes' => array(
array(
'width' => '728',
'height' => '90'
@rinatkhaziev
rinatkhaziev / post_thumbnail_html-placeholder.php
Created September 21, 2015 17:03
Display placeholder image when there's no thumbnail for the post
<?php
/**
* Filter to put a placeholder in, when there's no thumbnail set for post (which is the case for a lot of legacy posts)
*/
add_filter( 'post_thumbnail_html', function( $html, $post_id, $post_thumbnail_id, $size, $attr ) {
// We have a thumb, return it
if ( $html )
return $html;
$placeholder_url = 'http://full.url.to/placeholder_image';
@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