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 / SnapshotCommand.php
Created August 6, 2019 12:42 — forked from ralphschindler/SnapshotCommand.php
An example Laravel app command to create and load database snapshots using S3
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
class SnapshotCommand extends Command
{
@ihorvorotnov
ihorvorotnov / wp-get-content
Created February 21, 2014 11:20
WordPress: get post content by ID
/**
* You often need to get the content or title from a specific post.
* Sometimes, using a custom loop is the better option, but when you only need
* to get information from a specific post, there’s a better option
*/
echo get_post_field('post_content', $post_id);
@ihorvorotnov
ihorvorotnov / wp-sharedcount
Last active October 28, 2017 15:00
WordPress - count shares via Sharedcount.com
/**
* http://www.sharedcount.com/documentation.php
*/
function social_shares() {
$url = get_permalink( $post_id );
$json = file_get_contents("http://api.sharedcount.com/?url=" . rawurlencode($url));
$counts = json_decode($json, true);
$totalcounts= array(
"twitter" => $counts["Twitter"],
"facebook" => $counts["Facebook"]["total_count"],
@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' ) ) {
@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 {}
<?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 / 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:

@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 );
[alias]
changelog = "!_() { t=$(git describe --abbrev=0 --tags); git log ${t}..HEAD --no-merges --pretty=format:'* %s'; }; _"
@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