Skip to content

Instantly share code, notes, and snippets.

@shrimp2t
shrimp2t / customify- export-default
Created April 23, 2018 08:49
Customify Export Default Theme Mod
<?php
/**
* Plugin Name: Customify Export Default
* Plugin URI: #
* Description:
* Author:
* Version: 1.0
*/
<?php
/*
Plugin Name: Customify Sites REST API
Plugin URI: http://customifysites.com/
Description: Add REST API end point for customify demo importer
Author: shrimp2t
Author URI: http://customifysites.com/
Version: 0.0.1
Text Domain: customify-sites-api
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@shrimp2t
shrimp2t / intall-active-theme.php
Created May 10, 2018 03:54
Install and active by url or ajax
<?php
// get_current_screen()
//$class= 'updated notice notice-success notice-alt is-dismissible';
// install theme url esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) )
$theme_slug = 'twentyseventeen';
$install_url = add_query_arg( array(
'action' => 'install-theme',
'theme' => $theme_slug,
<?php
if (is_admin() || is_customize_preview()) {
if( class_exists( 'WP_Customize_Section' ) ) {
class Customify_Section_Pro extends WP_Customize_Section
{
/**
* The type of customize section being rendered.
*
* @since 1.0.0
<?php
// Set the file size header
header( "Content-Length: " . @filesize( $file_path ) );
// Now deliver the file based on the kind of software the server is running / has enabled
if ( stristr( getenv( 'SERVER_SOFTWARE' ), 'lighttpd' ) ) {
header( "X-LIGHTTPD-send-file: $file_path" );
@shrimp2t
shrimp2t / search-proximity.php
Last active July 30, 2018 00:55
Get distance from lat and long
<?php
/**
* Get the SQL query for getting listings within a given proximity.
*
* @link https://wordpress.stackexchange.com/a/206560/123815
* @since 1.0.0
*/
public function get_proximity_sql() {
global $wpdb;
@shrimp2t
shrimp2t / get-semantic-ui-icons.js
Created August 10, 2018 09:46
Get semantic ui icons. Go to https://semantic-ui.com/elements/icon.html paste this code to console.
var icons = [];
$('.icon.example').each( function( ) {
var group = $( this );
$( '.column > i', group ).each( function(){
var icon = $(this).attr('class') || '';
icons.push( icon );
} );
} );
(function ($, window, document) {
"use strict";
var customifyWCFiterXHR = false;
$.fn.customifyOffCanvas = function ( options ) {
var opts = $.extend({
selector : '.woocommerce-listing',
}, options );
@shrimp2t
shrimp2t / ruleset.xml
Last active January 29, 2019 18:56
Copy it in to ~/.composer/vendor/squizlabs/php_codesniffer/src/Standards/WordPress/ruleset.xml
<?xml version="1.0"?>
<ruleset name="WordPress" namespace="WordPress">
<description>WordPress Coding Standards</description>
<autoload>./PHPCSAliases.php</autoload>
<!--<rule ref="WordPress-Core"/> -->
<rule ref="WordPress-Core">
<exclude name="Generic.Commenting.DocComment.MissingShort" />
<?php
// The function to count words in Unicode strings
function count_unicode_words( $unicode_string ){
// First remove all the punctuation marks & digits
$unicode_string = preg_replace('/[[:punct:][:digit:]]/', '', $unicode_string);
// Now replace all the whitespaces (tabs, new lines, multiple spaces) by single space
$unicode_string = preg_replace('/[[:space:]]/', ' ', $unicode_string);
// The words are now separated by single spaces and can be splitted to an array
// I have included \n\r\t here as well, but only space will also suffice
$words_array = preg_split( "/[\n\r\t ]+/", $unicode_string, 0, PREG_SPLIT_NO_EMPTY );