This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// How to use: | |
// 1. Copy the class at the end of the file into your code. | |
// 2. Follow the examples below for usage. | |
// ----------------------- | |
// Example #1: Basic usage | |
// Start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
Microcontroller Name: Rate of Change | |
Description: Take an input value and outputs the rate of change per second. | |
Inputs: | |
1) Value (number, required): Input number (eg, fuel tank capacity) | |
2) Refresh Rate (number, optional, default 60): Game ticks between each update | |
Outputs: | |
1) Number: Change since last update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// get list of category IDs that this post belongs to | |
$cats = array(); | |
if ( $categories = get_the_category() ) { | |
foreach ( $categories as $category ) { | |
$cats[] = $category->term_id; | |
} | |
} | |
$blogname = get_bloginfo( 'name', 'display' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Displays a link to edit a field group in the title of a field group for user and taxonomy pages on the backend. | |
* I recommend moving the JS/CSS to your plugin/theme instead of loading it here. But this is a nice way to keep it portable. | |
* | |
* @param $fields | |
* @param $post_id | |
* | |
* @return mixed | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Fix duplicate users appearing in WP_User_Query by specifying an OR meta query. | |
* This solution makes no sense but it works. ¯\_(ツ)_/¯ | |
* | |
* See: | |
* 1. https://gist.github.com/RadGH/877ee20d99eee73fb0e933f199d4b8fb | |
* 2: https://wordpress.stackexchange.com/questions/220307/user-appears-twice-in-a-wp-user-query | |
* 3: https://core.trac.wordpress.org/ticket/17582 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: GF Editable by Radley | |
Description: Example classes to make a particular gravity form editable on the front-end. | |
Author: Radley Sustaire | |
Author URI: https://radleysustaire.com/ | |
Version: 1.0.0 | |
*/ | |
// QUICK TEST INSTRUCTIONS: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: RS Process Users Daily | |
Description: Provides an API action for developers which iterates all users once per day, based on cofigurable settings. Usage: <code class="code">add_action( 'aa_process_all_users_daily/user', 'example_process_user' );</code> | |
Author: Radley Sustaire | |
Version: 1.1.0 | |
*/ | |
/* | |
// EXAMPLE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Radley's WP development structure. Git repo should be based in the wp-content folder. | |
# | |
# Alternatively, try the Github official WordPress gitignore structure from the document root: | |
# https://github.com/github/gitignore/blob/master/WordPress.gitignore | |
# File Extensions | |
*.log | |
*.sql | |
*.sqlite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Check expiration date for a set of users. | |
* | |
* @return string | |
*/ | |
function dtl_course_expiry_check( $debug = false ) { | |
// option to start over when used manually via query string | |
if ( isset($_REQUEST['startover']) ) update_option( 'dtl-ce-user-index', 0, false ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Step 1. Add the filters surrounding the get_terms (which should be used in your code) | |
add_filter( 'terms_clauses', 'rs_replace_inner_with_straight_joins', 20 ); | |
$terms = get_terms( $args ); | |
remove_filter( 'terms_clauses', 'rs_replace_inner_with_straight_joins', 20 ); | |
// Step 2. Add to functions.php or similar: | |
function rs_replace_inner_with_straight_joins( $pieces, $taxonomies = null, $args = null ) { | |
global $wpdb; | |