Skip to content

Instantly share code, notes, and snippets.

Rinat K rinatkhaziev

  • Chicago
Block or report user

Report or block rinatkhaziev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rinatkhaziev
rinatkhaziev / nginx-wp-in-subfolder.rewrite.conf
Last active Nov 15, 2018
Nginx rewrite rules when WordPress core files are in a subfolder
View nginx-wp-in-subfolder.rewrite.conf
# Files are physically in `wp` subfolder but we'd like to serve requests /
# Goes inside server { } block
if (!-e $request_filename) {
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$request_uri/ permanent;
# WordPress in a subdirectory rewrite rules
rewrite ^/([_0-9a-zA-Z-]+/)?(wp-.*|xmlrpc.php) /wp/$2 break;
}
@rinatkhaziev
rinatkhaziev / list-duplicate-terms-in-the-taxonomy.php
Created Oct 17, 2018
WP CLI: list terms with the same name in a hierarchical taxonomy for sites in multisite network.
View list-duplicate-terms-in-the-taxonomy.php
<?php
/**
* List terms (categories) with the same name for each of the blog with a sticker.
*
* This is a one-off, but could be easily abstracted to be more versatile.
*
* @subcommand list-multiple-terms-with-the-same-name
* @synopsis [--taxonomy=<category>]
*/
View make-donald-drumpf-again.php
<?php
add_filter( 'the_content', 'make_donald_drumpf_again', 666 );
add_filter( 'the_title', 'make_donald_drumpf_again', 666 );
add_filter( 'comment_text', 'make_donald_drumpf_again', 666 );
function make_donald_drumpf_again( $content ) {
return str_replace( 'Trump', 'Drumpf', $content );
}
@rinatkhaziev
rinatkhaziev / post_thumbnail_html-placeholder.php
Created Sep 21, 2015
Display placeholder image when there's no thumbnail for the post
View post_thumbnail_html-placeholder.php
<?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';
View dfp-async-mulltisizes.php
<?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 / fu-akismet.php
Created Oct 22, 2014
Akismet 3 integration for Frontend Uploader
View fu-akismet.php
<?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 / filter_wpcom_elasticsearch_query_args.php
Created Oct 6, 2014
wpcom_elasticsearch_query_args example nested boolean OR filter
View filter_wpcom_elasticsearch_query_args.php
<?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' ),
),
View example-suggester,js
{
"suggest": {
"text": keyword,
"title-suggest": {
"term": { "field": "title" },
"size": 3
},
}
@rinatkhaziev
rinatkhaziev / simple-ndn-embed.php
Last active Aug 29, 2015
Simple shortcode callback for v2 NDN player
View simple-ndn-embed.php
<?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/>
@rinatkhaziev
rinatkhaziev / dfp-async-sample.php
Created Jul 23, 2013
Sample code of DFP Async setTargeting support for ACM
View dfp-async-sample.php
<?php
class Doubleclick_For_Publishers_Async_ACM_Provider extends ACM_Provider {
public $crawler_user_agent = 'Mediapartners-Google';
function filter_output_html( $output_html, $tag_id ) {
// .. omitted
$targeting_params_array = apply_filters( 'acm_targeting_params', array( 'kw' => 'testkeyword' ), $tag_id );
$targeting_string = $this->format_targeting_string( $targeting_params_array );
You can’t perform that action at this time.