Skip to content

Instantly share code, notes, and snippets.

View kamirbarron's full-sized avatar
👠
yes

Korronka kamirbarron

👠
yes
View GitHub Profile
@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>/
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';
@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');
}
}
<?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 / 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 );
});
@Shelob9
Shelob9 / functions.php
Created June 28, 2016 18:13 — forked from mathetos/functions.php
Custom Autopopulate Dropdown for CalderaForms
add_filter( 'caldera_forms_autopopulate_options_post_value_field', 'givewp_customer_addon_purchases', 24, 2 );
function givewp_customer_addon_purchases()
{
$current_user = wp_get_current_user();
$purchases = edd_get_users_purchases($current_user->user_email, 100, false, 'any');
if ( $purchases ) {
foreach ($purchases as $purchase) {
$licenses = edd_software_licensing()->get_licenses_of_purchase( $purchase->ID );
@Shelob9
Shelob9 / cdn-jquery.php
Last active April 6, 2023 10:52
Replace WordPress' jQuery with CDN jQuery of the right version
add_action( 'init', function(){
if ( ! is_admin()) {
if( is_ssl() ){
$protocol = 'https';
}else {
$protocol = 'http';
}
/** @var WP_Scripts $wp_scripts */
global $wp_scripts;
<?php
namespace App;
class WpApi {
protected static $url = 'https://calderaforms.com/wp-json/wp/v2/';
public static function getPost(int $id )
@Shelob9
Shelob9 / caldera-forms-entry-viewer-and-form-in-content
Last active September 18, 2020 08:23
Examples of how to show the Caldera Forms entry viewer in the front end of your WordPress site. See: https://calderaforms.com/doc/caldera-forms-wordpress-form-entry-viewer/
<?php
add_filter( 'the_content', function( $content ){
$post = get_post();
if( 42 ===$post->ID ){
$form = 'cf1234567';
$content .= Caldera_Forms::render_form( $form );
$content .= Caldera_Forms_Entry_Viewer::form_entry_viewer_2( $form );
}
});
<?php
add_filter( 'caldera_forms_render_get_field', function( $field ) {
if( 'fld123456' == $field[ 'ID' ] ){
$field[ 'config' ][ 'default' ] = esc_url_raw( caldera_forms_get_current_url() );
}
return $field;
});