Skip to content

Instantly share code, notes, and snippets.

Stanislav Khromov khromov

Block or report user

Report or block khromov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@khromov
khromov / fix-broken-instagram.php
Last active Mar 1, 2018
Fix broken / overlapping Instagram embed for WordPress
View fix-broken-instagram.php
<?php
/**
* Plugin Name: Fix broken Instagram oEmbed
* Description: Fixes an issue with Instagram posts being broken when multiple posts are oEmbedded.
* Version: 1.0
* Author: khromov
*/
/**
* Remove Instagram embed.js script on each embed
@khromov
khromov / infogram-oembed.php
Created Oct 19, 2017
Infogram oEmbed plugin
View infogram-oembed.php
<?php
/*
Plugin Name: Infogram oEmbed
Plugin URI:
Description: Adds oEmbed support for infogr.am and infogram.com urls.
Author: khromov
Version: 1.0
Author URI: https://khromov.se
*/
@khromov
khromov / disable-rest-api-for-anonymous-users.php
Created Oct 13, 2017
Disable WordPress REST API for anonymous users
View disable-rest-api-for-anonymous-users.php
<?php
/*
Plugin Name: Disable REST API for anonymous users
*/
/**
* Remove all endpoints except SAML / oEmbed for unauthenticated users
*/
add_filter( 'rest_authentication_errors', function($result) {
if ( ! empty( $result ) ) {
@khromov
khromov / acf-nowhere-location-rule.php
Created Oct 2, 2017
"Nowhere" location rule for Advanced Custom Fields - never matches
View acf-nowhere-location-rule.php
<?php
/*
Plugin Name: Advanced Custom Fields: Nowhere location rules
Description: Adds a "Nowhere" location rule in ACF
*/
add_filter('acf/location/rule_types', function($rules) {
$rules['Extra']['nowhere'] = 'Nowhere';
View rock-paper-scissors-js.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width">
<title>Rock, Paper, Scissors</title>
<style>
*{margin:0;padding:0;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}::selection{background:#fb9fe5;text-shadow:none}a{color:#0088CC;text-decoration:none;outline:0}a:hover{color:#005580}a img{border:none}img{max-width:100%}html{font-size:100%}body{padding:5%;font:300 1.25em/1.6 monospace;background:#fff;color:#000;}h1{font-family:"Helvetica Neue",sans-serif;line-height:1;font-weight:300;margin-bottom:1em;}.game{padding:2em;background:#eee;}
@khromov
khromov / deploy.php
Last active Aug 16, 2018
Deploying WordPress with Deployer 4
View deploy.php
<?php
namespace Deployer;
require 'recipe/common.php';
set('ssh_type', 'native');
set('ssh_multiplexing', true);
// Set configurations
set('repository', 'git@github.com:user/repo.git');
@khromov
khromov / print-tax.php
Created Mar 15, 2017
Print taxonomy terms starting from specific slug in WordPress
View print-tax.php
<?php
/*
* Plugin Name: Print taxonomy terms starting from specific slug
* Description: Usage: [print_taxonomy slug="product-category"] or <?php echo do_shortcode('[print_taxonomy slug="product-category"]'); ?>
*/
add_shortcode('print_taxonomy', function($atts, $content) {
$atts = shortcode_atts( array(
'slug' => '',
), $atts, 'print_taxonomy' );
@khromov
khromov / functions.php
Created Feb 14, 2017
Load WPFacet facets from facets.json file in theme
View functions.php
<?php
//...
add_filter( 'facetwp_facets', function($facets) {
//Load facets.json file located in theme folder
$imported_facets = json_decode(file_get_contents(trailingslashit(dirname(__FILE__)) . 'facets.json'), true);
//Import facets
foreach($imported_facets['facets'] as $single_facet) {
$facets[] = $single_facet;
@khromov
khromov / deploy.php
Created Jun 8, 2016
Deploy WordPress with Deployer on EasyEngine
View deploy.php
<?php
require 'recipe/common.php';
// Set configurations
set('repository', 'ssh://gogs@git.server.com:22/user/repo.git');
set('shared_files', ['public/wp-config.php']);
set('shared_dirs', ['public/wp-content/uploads']);
set('writable_dirs', []);
set('keep_releases', 10);
set('composer_command', 'composer');
@khromov
khromov / 404.php
Created May 24, 2016
Set a page with slug "404-error" as your 404 page in WordPress
View 404.php
<?php get_header(); ?>
<div class="container-fluid">
<div class="content">
<main role='main'>
<?php
$query_404 = new WP_Query(array(
'posts_per_page' => 1,
'post_type' => 'page',
'post_name' => '404-error'
));
You can’t perform that action at this time.