Skip to content

Instantly share code, notes, and snippets.

add_filter('trp_before_translate_content', 'trpc_fix_html_attributes_without_spaces');
function trpc_fix_html_attributes_without_spaces($output){
$size = strlen($output);
$pos = 0;
$pos_c = 0;
while ($pos_c < $size){
$len = strcspn($output, '<' , $pos);
<?php
function word_hash($str){
$hash =0;
$str = str_split($str);
foreach($str as $key => $char){
$hash += ord($char) * $key;
}
return $hash;
}
<?php
/*
Plugin Name: Disable Specific Plugins in Dev - translatepress.com
Plugin URI: http://translatepress.com
Description: Disable specified plugins in development environment
Author: TranslatePress
Version: 1.1
Author URI: http://translatepress.com
*/
<?php
/**
* Plugin Name: Easy Digital Downloads - TranslatePress Customizations
* Plugin URI: http://translatepress.com
* Description: TranslatePress customizations for edd
* Version: 1.0.0
* Author: Madalin Ungureanu
*/
@sareiodata
sareiodata / frugal_budget.php
Created October 26, 2016 11:54
load a template for a particular URL
// http://wordpress.stackexchange.com/questions/9870/how-do-you-create-a-virtual-page-in-wordpress
add_action( 'init', 'frugal_add_rewrite_rule' );
function frugal_add_rewrite_rule()
{
add_rewrite_rule( 'budget$', 'index.php?budget=1', 'top' );
}
add_filter( 'query_vars', 'frugal_query_vars' );
function frugal_query_vars( $query_vars )
{
@sareiodata
sareiodata / custom.php
Last active October 24, 2016 14:16
filters for improving user listing SEO stuff
/*
* Make user listing work with the nicename. Tags: user listing, nicename
*/
add_filter('wppb_userlisting_get_user_by_id', create_function('', 'return false;'));
// Filter wp_title for single user listing
function single_user_list_filter_wp_title( $title, $sep ) {
$userID = wppb_get_query_var('username');
@sareiodata
sareiodata / php-html-css-js-minifier.php
Created June 2, 2016 12:56 — forked from taufik-nurrohman/php-html-css-js-minifier.php
PHP Function to Minify HTML, CSS and JavaScript
<?php
/**
* -----------------------------------------------------------------------------------------
* Based on `https://github.com/mecha-cms/mecha-cms/blob/master/engine/kernel/converter.php`
* -----------------------------------------------------------------------------------------
*/
// HTML Minifier
function minify_html($input) {
<?php
/**
* The template used for displaying private page content
*
* @package WordPress
* @subpackage Twenty_Sixteen
* @since Twenty Sixteen 1.0
*/
$private_page_class = 'class="type-page ' . join( ' ', get_post_class( $class, $post_id ) ) . '"';
<?php
/**
* The template for displaying pages
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages and that
* other "pages" on your WordPress site will use a different template.
*
* @package WordPress
* @subpackage Twenty_Sixteen
@sareiodata
sareiodata / gist:49949cea584f55326823
Last active March 22, 2016 07:55
bbpress close all topics
/*
* Close all bbpress topics
*/
/**
* Hook into 'the_posts' and check the topic status on single topic pages. If
* the topic is not closed, set it to closed.
*
* @since 0.1.0
*