Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working remotely since 1999

Ihor Vorotnov ihorvorotnov

🏠
Working remotely since 1999
View GitHub Profile
@ihorvorotnov
ihorvorotnov / render-taxonomy-tree.php
Created Apr 16, 2016 — forked from nmedia82/render-taxonomy-tree.php
Rendering Taxonomy Tree for custom post types in Wordpress Plugin or Theme as checkbox input
View render-taxonomy-tree.php
/**
* 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 );
View gist:857a9587fd33e1ba62cacf5187b5b0cd
[alias]
changelog = "!_() { t=$(git describe --abbrev=0 --tags); git log ${t}..HEAD --no-merges --pretty=format:'* %s'; }; _"
@ihorvorotnov
ihorvorotnov / gist:38c843e7b95e3336321d6d78fb55b2a1
Created Apr 9, 2016 — forked from johnbillion/hierarchy.php
WordPress Template Hierarchy (as of WordPress 4.4)
View gist:38c843e7b95e3336321d6d78fb55b2a1
<?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
@ihorvorotnov
ihorvorotnov / remove_hover_rule.js
Created Apr 5, 2016 — 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)
View remove_hover_rule.js
// 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 / whatissoslow.php
Created Mar 7, 2016 — 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.
View whatissoslow.php
<?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 / phone-codes.php
Created Feb 9, 2016
Telephone codes by country
View phone-codes.php
<?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 / nav_metabox.php
Last active Feb 3, 2016 — forked from johnmorris/gist:5221875
Custom metabox for navigation menus
View nav_metabox.php
if ( !class_exists('JMO_Custom_Nav')) {
class JMO_Custom_Nav {
public function add_nav_menu_meta_boxes() {
add_meta_box(
'wl_login_nav_link',
__('WishList Login'),
array( $this, 'nav_menu_link'),
'nav-menus',
'side',
'low'
@ihorvorotnov
ihorvorotnov / wp-translation-strings.php
Last active Oct 22, 2015
Complex translation strings in WordPress themes and plugins
View wp-translation-strings.php
<?php
/**
* The following is the proper way to handle complex translation strings.
* By Justin Tadlock
* @see https://wpchat.com/t/do-you-use-format-placeholders-s-and-d-in-translatable-strings/1138/11
*/
$number = get_donation_count();
$string = sprintf(
// translators: %s is the number of donations.
@ihorvorotnov
ihorvorotnov / publickey-git-error.markdown
Created Oct 3, 2015 — forked from adamjohnson/publickey-git-error.markdown
Fix "Permission denied (publickey)" error when pushing with Git
View publickey-git-error.markdown

"Help, I keep getting a 'Permission Denied (publickey)' error when I push!"

This means, on your local machine, you haven't made any SSH keys. Not to worry. Here's how to fix:

  1. Open git bash (Use the Windows search. To find it, type "git bash") or the Mac Terminal. Pro Tip: You can use any *nix based command prompt (but not the default Windows Command Prompt!)
  2. Type cd ~/.ssh. This will take you to the root directory for Git (Likely C:\Users\[YOUR-USER-NAME]\.ssh\ on Windows)
  3. Within the .ssh folder, there should be these two files: id_rsa and id_rsa.pub. These are the files that tell your computer how to communicate with GitHub, BitBucket, or any other Git based service. Type ls to see a directory listing. If those two files don't show up, proceed to the next step. NOTE: Your SSH keys must be named id_rsa and id_rsa.pub in order for Git, GitHub, and BitBucket to recognize them by default.
  4. To create the SSH keys, type ssh-keygen -t rsa -C "your_email@example.com". Th
@ihorvorotnov
ihorvorotnov / gist:6e2acd9badecea2b0f77
Created Sep 30, 2015
Remove WP.org logo and links from toolbar
View gist:6e2acd9badecea2b0f77
add_action( 'admin_bar_menu', 'remove_wp_logo', 999 );
function remove_wp_logo( $wp_admin_bar ) {
$wp_admin_bar->remove_node( 'wp-logo' );
}