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 | |
//Use PHP semaphores to ensure only one (or $max) instances of a script can run at once. | |
//Semaphores can auto-release if the script crashes, unlike a lock file or database flag which require the script to be functional to release them | |
//USAGE: Simply include this file at the top of your script. When run, it will die if it finds another instance of itself already running. | |
// include_once('/path/to/script_run_once.php'); | |
//All we need is a unique 4-digit integer to represent our script. I will hash the current script file path to get this, but you can hard-code $key if you like |
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 | |
/* | |
* When using the 'pay for order' link with a WooCommerce Subscriptions renewal order, WCS recreates the order in the cart (setup_cart() in class-wcs-cart-renewal.php) | |
* However it does not copy custom order item meta to the cart items as cart item meta. This has to be done with the filter woocommerce_order_again_cart_item_data | |
*/ | |
function my_custom_add_renewal_cart_item_data($cart_item_data, $line_item, $subscription){ | |
//there will be only one set of cart item data, WCS just packages it as an array for this filter | |
$cart_item_data = array_shift($cart_item_data); |
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 | |
//You need an API key and an address (as a string) to geocode | |
//ACF Google Maps field data looks like: | |
/* | |
array( | |
'address' => '123 My Street, Mytown, Mycountry, Mypostcode', | |
'lat' => '123.45678', | |
'lng' => '-125.67890', | |
) |
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 | |
/* | |
This goes in your functions.php or similar. It works the same for selects and radio buttons | |
In this example, we will provide dynamic values for a select named 'example-field1' | |
CF7 form tag: [select example-field1] | |
*/ | |
function mytheme_cf7_dynamic_values($tag){ |
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 a list of Mogul Framework layers to update the wiki | |
require_once('wp-load.php'); | |
global $wpdb; | |
$args = array( | |
'post_type' => 'acf-field-group', | |
'posts_per_page' => -1, |
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
/** | |
* When used by other plugins, the Redux Framework adds obtrusive dashboard widgets, notices and menu items when wp_debug is enabled, on the assumption that nobody uses WP_DEBUG_LOG on production sites. | |
* This code removes these | |
*/ | |
//Remove widget | |
function my_framework_remove_redux_stuff(){ | |
global $wp_meta_boxes; | |
if(!empty($wp_meta_boxes['dashboard']['side']['high']['redux_dashboard_widget'])){ |
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
#!/bin/bash | |
# one argument: the directory of a wp-config.php file | |
wpconfig=$1/wp-config.php | |
if [ ! -f "$wpconfig" ]; then | |
echo "$wpconfig not found." | |
exit | |
fi |
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
#!/bin/bash | |
# one argument: the directory of a wp-config.php file | |
wpconfig=$1/wp-config.php | |
if [ ! -f "$wpconfig" ]; then | |
echo "$wpconfig not found." | |
exit | |
fi |
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 | |
//based on https://wordpress.stackexchange.com/a/298323/88160 but standalone | |
require_once('wp-load.php'); | |
ini_set("memory_limit","512M"); | |
//error_reporting(E_ALL); | |
//ini_set('display_errors', 1); | |
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
jQuery(document).ready(function($){ | |
//Modify select2 ajax request to include a parent_id parameter, used by custom_acf_taxonomy_hierarchy() | |
acf.add_filter('select2_ajax_data', function( data, args, $input, field, instance ){ | |
var target_field_key = 'field_5c7634ca3413f'; //YOUR TARGET FIELD KEY HERE | |
if(data.field_key == target_field_key){ | |
var parent_id = 0; //by default we want terms with parent of 0 (top level) |
OlderNewer