Skip to content

Instantly share code, notes, and snippets.

View maxchirkov's full-sized avatar

Max maxchirkov

  • Phoenix, Arizona
View GitHub Profile
@maxchirkov
maxchirkov / dump-wp-hooks.php
Last active November 26, 2018 14:37
Dumps WP Hooks (Filters and Actions) in the order of execution in Markdown format.
/**
* Dumps WP Hooks (Filters and Actions)
* in the order of execution in Markdown format.
*
* File hooks.md in the root location of the WP setup.
*
* @param bool $actions - render actions
* @param bool $filters - render filters
* @param bool $unique - render unique hooks
*/
/**
* All Area Widgets
*
* Parameters:
* @param data-init string widgets/area
* @param data-id string Area ID
* @param data-chooser boolean Render Chooser true|false
* @param data-chooser-limit number of items to be returned within the chooser
* @param data-widgets JSON Array '["age", "cost", "education", "employment",
* "occupancy", "summary", "weather", "details"]'
@maxchirkov
maxchirkov / widget_mapper.php
Last active August 29, 2015 14:13
Widgets Mapper from previous to the current theme
<?php
add_action('after_setup_theme', 'mapThemeWidgets');
function mapThemeWidgets()
{
$theme_slug = 'twentytwelve';
// Hash of old to new sidebar IDs
$map = array(
'sidebar-1' => 'hjitw-right-widgets',
'sidebar-2' => 'hjitw-footerwidgets'
@maxchirkov
maxchirkov / gist:e586683bd21614adc0b5
Created July 28, 2014 18:10
Neighborhood data based on listing
<?php
add_action('the_content', 'demographics');
function demographics($content)
{
global $post;
if (!isset($post->listing))
return $content;
@maxchirkov
maxchirkov / .gitignore
Last active August 29, 2015 14:00 — forked from octocat/.gitignore
# PHP Storm #
###############
.idea
.idea/*
# FROM: https://gist.github.com/octocat/9257657
# Compiled source #
###################
*.com
@maxchirkov
maxchirkov / new_gist_file
Created April 2, 2013 22:02
Resolving conflicts by accepting "theirs" version of the file.
http://stackoverflow.com/questions/161813/how-do-i-fix-merge-conflicts-in-git#3407920
@maxchirkov
maxchirkov / jquery-ui-tabs
Created February 16, 2012 23:27
jQuery UI Tabs Test
<?php
if(isset($_GET['q']))
die($_GET['q']);
?>
<html>
<head>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" type="text/css" media="all" />
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js'></script>
@maxchirkov
maxchirkov / http_xml()
Created January 26, 2012 18:08
HTTP XML Request
<?php
/**
* Simple HTTP request for API usage - converts XML into object
*/
function http_xml($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@maxchirkov
maxchirkov / re-queue
Created December 20, 2011 15:41
re-queue javascript in WP with a different handle
/** re-queue Google Maps script in Simple Real Estate Pack
* under different handle to avoid conflicts with other plugins
*/
add_action('wp_print_styles', 'custom_script_requeue');
function custom_script_requeue(){
//check if Simple Real Estate Pack's function that registeres the script exists
if( !function_exists('srp_default_headScripts') )
return;
//dequeue Google Maps script with "google" handle
@maxchirkov
maxchirkov / whitelist-alert
Created August 26, 2011 19:28
Alerts users to whilte-list your email address whenever they submit a form. Alerts could be customized to appear for only selected domain names like aol.com, earthlink.net etc.
//Script assumes that you have jQuery loaded. Most WordPress themes do.
jQuery(document).ready(function(){
//Check email addresses
//All domains have to be be lower case
var check_emails = new Array("earthlink.net", "aol.com");
var email_warning = "Please make sure to white-list our email address test@test.com so it doesn't get stuck in your SPAM folder.";
var form_selector = 'form'; //change to '#form_id' - to apply to a specific form ID.
jQuery(form_selector).submit(function(){
jQuery('input').each(function(){
//check if form field values contain @ - we assume that's email address