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
<?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 October 24, 2020 16:17 — forked from mishterk/LocalValetDriver.php
A local Valet driver for proxying images to a remote host
<?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 {
(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 / functions.php
Created August 7, 2020 11:55
Custom wrapper for require() instead of get_template_part()
<?php
define( 'THEME_PATH', __DIR__ );
/**
* A faster alternative to native get_template_part() function.
*
* @param string $template
* @param mixed $data
*
* @return void
@ihorvorotnov
ihorvorotnov / functions.php
Last active March 17, 2021 10:01
Painless 3rd party marketing scripts in WordPress
<?php
// Enqueue all js codes combined in a single file.
function enqueue_theme_assets()
{
wp_enqueue_script(
'trackers',
get_stylesheet_directory_uri() . '/js/trackers.js',
null,
null,
@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 / 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: