Skip to content

Instantly share code, notes, and snippets.

View ihorvorotnov's full-sized avatar
🇺🇦
Working remotely since 1999

Ihor Vorotnov ihorvorotnov

🇺🇦
Working remotely since 1999
View GitHub Profile
@ihorvorotnov
ihorvorotnov / phone-codes.php
Created February 9, 2016 23:49
Telephone codes by country
<?php
$countries = array();
$countries[] = array("code"=>"AF","name"=>"Afghanistan","d_code"=>"+93");
$countries[] = array("code"=>"AL","name"=>"Albania","d_code"=>"+355");
$countries[] = array("code"=>"DZ","name"=>"Algeria","d_code"=>"+213");
$countries[] = array("code"=>"AS","name"=>"American Samoa","d_code"=>"+1");
$countries[] = array("code"=>"AD","name"=>"Andorra","d_code"=>"+376");
$countries[] = array("code"=>"AO","name"=>"Angola","d_code"=>"+244");
$countries[] = array("code"=>"AI","name"=>"Anguilla","d_code"=>"+1");
$countries[] = array("code"=>"AG","name"=>"Antigua","d_code"=>"+1");
@ihorvorotnov
ihorvorotnov / whatissoslow.php
Created March 7, 2016 23:06 — forked from Viper007Bond/whatissoslow.php
WordPress: Times how long it takes each filter and action to run and displays results at the end of the page. Quick and dirty.
<?php
/**
* This little class records how long it takes each WordPress action or filter
* to execute which gives a good indicator of what hooks are being slow.
* You can then debug those hooks to see what hooked functions are causing problems.
*
* This class does NOT time the core WordPress code that is being run between hooks.
* You could use similar code to this that doesn't have an end processor to do that.
*
@ihorvorotnov
ihorvorotnov / remove_hover_rule.js
Created April 5, 2016 20:06 — forked from rcmachado/remove_hover_rule.js
Remove CSS :hover rules for touch devices to avoid iOS double-tap behavior. Copied and adapted from http://retrogamecrunch.com/tmp/hover (just a fix for sheet.cssRules)
// disable :hover on touch devices
// based on https://gist.github.com/4404503
// via https://twitter.com/javan/status/284873379062890496
// + https://twitter.com/pennig/status/285790598642946048
// re http://retrogamecrunch.com/tmp/hover
// NOTE: we should use .no-touch class on CSS
// instead of relying on this JS code
function removeHoverCSSRule() {
if ('createTouch' in document) {
try {
@ihorvorotnov
ihorvorotnov / gist:38c843e7b95e3336321d6d78fb55b2a1
Created April 9, 2016 01:02 — forked from johnbillion/hierarchy.php
WordPress Template Hierarchy (as of WordPress 4.4)
<?php
/* WordPress Template Hierarchy as of WordPress 4.4
is_404() ---------------------------------------------------------------------------------------------------> 404.php
is_search() ------------------------------------------------------------------------------------------------> search.php
is_front_page() --------------------------------------------------------------------------------------------> front-page.php
is_home() --------------------------------------------------------------------------------------------------> home.php
[alias]
changelog = "!_() { t=$(git describe --abbrev=0 --tags); git log ${t}..HEAD --no-merges --pretty=format:'* %s'; }; _"
@ihorvorotnov
ihorvorotnov / render-taxonomy-tree.php
Created April 16, 2016 02:20 — forked from nmedia82/render-taxonomy-tree.php
Rendering Taxonomy Tree for custom post types in Wordpress Plugin or Theme as checkbox input
/**
* Following script will render Taxonomy Tree attached with specified post type
* in following example post_type use: books
* output can be seen here: https://www.diigo.com/item/image/4xv00/xrhq
*/
$posttype = 'books'
//getting all taxonomies with attached with $posttype
$taxonomy_names = get_object_taxonomies( $posttype );
@ihorvorotnov
ihorvorotnov / keybase.md
Created November 22, 2016 15:51
keybase.md

Keybase proof

I hereby claim:

  • I am ihorvorotnov on github.
  • I am ihorvorotnov (https://keybase.io/ihorvorotnov) on keybase.
  • I have a public key whose fingerprint is A866 1403 6C25 E295 B6B4 CC47 C82E B589 1154 9391

To claim this, I am signing this object:

<?php
/**
* Move image inside <p> tag above the <p> tag while preserving any link around image.
* Can be prevented by adding any attribute or whitespace to <p> tag, e.g. <p class="yolo"> or even <p >
*/
function gc_remove_p_tags_around_images($content)
{
$contentWithFixedPTags = preg_replace_callback('/<p>((?:.(?!p>))*?)(<a[^>]*>)?\s*(<img[^>]+>)(<\/a>)?(.*?)<\/p>/is', function($matches)
{
/*
@ihorvorotnov
ihorvorotnov / wordpress-default.css
Created November 29, 2016 07:50 — forked from madalinignisca/wordpress-default.css
Default WordPress classes for using with CSS
/**
* Default Body Class Styles
*/
.rtl {}
.home {}
.blog {}
.archive {}
.date {}
.search {}
@ihorvorotnov
ihorvorotnov / log.php
Last active June 29, 2017 10:11 — forked from evanre/log.php
Simple debug trace to wp-content/debug.log
<?php
/**
* Simple debug trace to wp-content/debug.log
*
* @usage _log( $var );
*
* @param $log mixed A string|array|object you want to dump into wp-content/debug.log
*/
if ( ! function_exists( '_log' ) ) {