Skip to content

Instantly share code, notes, and snippets.

View kovshenin's full-sized avatar

Konstantin Kovshenin kovshenin

View GitHub Profile
<?php
add_filter( 'request', 'my_request' );
function my_request( $request ) {
$request['tag'] = 'my-tag-slug';
return $request;
}
<?php
/**
* Plugin Name: Language Redirect
*/
add_action( 'init', 'language_redirect_init' ) {
// Map language to blog id
$sites = array(
'default' => 1,
'en' => 2,
@kovshenin
kovshenin / plugin.php
Created October 26, 2012 07:55
Settings API Demo
<?php
/**
* Plugin Name: My Plugin
* Plugin Description: Settings API Demo
*/
add_action( 'admin_menu', 'my_admin_menu' );
function my_admin_menu() {
add_options_page( 'My Plugin', 'My Plugin', 'manage_options', 'my-plugin', 'my_options_page' );
}
<?php
/**
* Plugin Name: My Plugin
* Plugin Description: http://core.trac.wordpress.org/ticket/10702
*/
class My_Plugin_Test_10702 {
public $cycles = 1000;
function __construct() {
<?php
/**
* In theory should support the following subdir sites as port of a subdomain network:
* - subdomain.example.org/site1
* - subdomain.example.org/site2
*/
function can_i_haz_subdomain_and_subdir() {
global $wpdb, $current_blog, $current_site, $blog_id, $site_id;
// Taken from ms-settings.php
<?php
/**
* Plugin Name: My Plugin 21689
*/
class My_Plugin_Test_21689 {
function __construct() {
add_action( 'init', array( $this, 'init' ) );
}
<?php
/**
* Campaign Monitor Shortcode & Reversal
*/
/**
* Embed Reversal
*
* Looks form a <form> that looks like a Campaign Monitor subscribe
* form during pre_kses, and converts it into a shortcode if possible.
@kovshenin
kovshenin / test-ajax-scripts.php
Created November 29, 2012 07:27
Lazy load a script enqueued in a shortcode during and AJAX callback? Sure!
<?php
/**
* Plugin Name: My Plugin
*/
class My_Plugin_Test_AJAX_Scripts {
function __construct() {
add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
add_action( 'wp_head', array( $this, 'wp_head' ), 99 );
@kovshenin
kovshenin / test-ajax-scripts.js
Created November 29, 2012 07:28
Goes with test-ajax-scripts.php
alert('foo!');
@kovshenin
kovshenin / paypal-combine-rows.py
Last active December 10, 2015 23:19
When working with a full export it'll contain extra rows called Shopping Cart Item. This script removes such rows and copies the Item Titles of into the Item Title column of the original transaction row.
"""
I hate PayPal. When working with a full export it'll contain extra rows called
Shopping Cart Item. This script removes such rows and copies the Item Titles of
into the Item Title column of the original transaction row.
Usage:
# python paypal-combine-rows.py input_file.csv > output_file.csv
"""
import csv
import sys