Skip to content

Instantly share code, notes, and snippets.

View kamirbarron's full-sized avatar
👠
yes

Korronka kamirbarron

👠
yes
View GitHub Profile
@Shelob9
Shelob9 / remove-query-vars.js
Created May 12, 2016 22:35
Remove all query vars from current URL.
$( '.something' ).on( 'click', function (e) {
e.preventDefault();
var location = window.location;
var url = location.origin + location.pathname + location.hash;
history.replaceState( null, '', url );
});
<?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 ) ) . '"';
@Shelob9
Shelob9 / orderby-custom-field.php
Created March 14, 2015 19:38
Order a post type archive by a custom field
<?php
add_action( 'pre_get_posts', function ( $query ) {
if ( $query->is_main_query() && !is_admin() && $query->is_post_type_archive( 'name_of_post_type') ) {
$query->set('orderby', 'meta_value_num');
$query->set('meta_key', 'custom_field_name');
$query->set('order', 'ASC');
}
}
add_filter( 'json_query_vars', 'slug_allow_meta' );
function slug_allow_meta( $valid_vars ) {
$valid_vars = array_merge( $valid_vars, array( 'meta_key', 'meta_value' ) );
return $valid_vars;
}
//
$url = 'posts?filter[meta_key]=foo&filter[meta_value]=bar';
@inhies
inhies / twrp.sh
Last active February 18, 2025 21:53
Creates TWRP compatible backups over USB using ADB without any files ever touching your SD card.
#!/bin/bash
#
# Version 1.4
#
# twrp.sh -- a TWRP compatible backup script for your computer
# Brought to you by inhies
#
# This script creates TWRP compatible backups over usb using adb and magikz
# By default it makes a folder in the standard TWRP date--time format (I think)
# To restore these backups, place the folder in /sdcard/TWRP/BACKUPS/<serialnumber>/