Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working remotely since 1999

Ihor Vorotnov ihorvorotnov

🏠
Working remotely since 1999
View GitHub Profile
View flush-redis-cache.php
<?php
# Check: https://onexa.nl/wordpress/toolbar-link-redis-object-cache/
/**
* Add a link to the Admin Toolbar to easily flush the Redis cache (Redis Object Cache plugin)
*
* @author Hiranthi Herlaar, onexa.nl
* @version 2.0
*
@ihorvorotnov
ihorvorotnov / LocalValetDriver.php
Created Oct 24, 2020 — forked from mishterk/LocalValetDriver.php
A local Valet driver for proxying images to a remote host
View LocalValetDriver.php
<?php
/**
* Class LocalValetDriver
*
* This class demonstrates how we might go about proxying any missing local images to a remote host. i.e; the production
* site. This has been created with WordPress in mind but could be adjusted to work with any other system.
*/
class LocalValetDriver extends WordPressValetDriver {
View minimal-analytics-snippet.js
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@ihorvorotnov
ihorvorotnov / SnapshotCommand.php
Created Aug 6, 2019 — forked from ralphschindler/SnapshotCommand.php
An example Laravel app command to create and load database snapshots using S3
View SnapshotCommand.php
<?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 / log.php
Last active Jun 29, 2017 — forked from evanre/log.php
Simple debug trace to wp-content/debug.log
View log.php
<?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 Nov 29, 2016 — forked from madalinignisca/wordpress-default.css
Default WordPress classes for using with CSS
View wordpress-default.css
/**
* Default Body Class Styles
*/
.rtl {}
.home {}
.blog {}
.archive {}
.date {}
.search {}
View remove_wrapping_p_tag.php
<?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 / 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