- Define the acf key
- grab the choices
- create a select with choices
- request on the meta key/meta value
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://github.com/mecha-cms/x.minify> | |
namespace x\minify\_ { // start namespace | |
$n = __NAMESPACE__; | |
\define($n . "\\token_boolean", '\b(?:true|false)\b'); | |
\define($n . "\\token_number", '-?(?:(?:\d+)?\.)?\d+'); |
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
var string_to_slug = function (str) | |
{ | |
str = str.replace(/^\s+|\s+$/g, ''); // trim | |
str = str.toLowerCase(); | |
// remove accents, swap ñ for n, etc | |
var from = "àáäâèéëêìíïîòóöôùúüûñçěščřžýúůďťň·/_,:;"; | |
var to = "aaaaeeeeiiiioooouuuuncescrzyuudtn------"; | |
for (var i=0, l=from.length ; i<l ; i++) |
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
function wc_ninja_manipulate_shipping( $rates, $package ) { | |
// All available rates and their costs | |
//print_r($rates); | |
// All products in the cart and their costs | |
//print_r($package); | |
// Example of manipulating the cost of | |
// a shipping method based on the above variables. | |
if ( isset( $rates['flat_rate'] ) ) { |
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 | |
/* | |
* Dependent Plugin Activation/Deactivation | |
* | |
* Sources: | |
* 1. https://pippinsplugins.com/checking-dependent-plugin-active/ | |
* 2. http://10up.com/blog/2012/wordpress-plug-in-self-deactivation/ | |
* | |
*/ | |
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
{ | |
"repositories": [ | |
{ | |
"type": "package", | |
"package": { | |
"name": "advanced-custom-fields/advanced-custom-fields-pro", | |
"version": "5.0", | |
"type": "wordpress-plugin", | |
"dist": { | |
"type": "zip", |
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
# Backup | |
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql | |
# Restore | |
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE | |
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 | |
/* Wordpress Custom Search by title, ACF, post_meta */ | |
// Wordpress ?s= redirect to /search/ | |
function wpa_search_redirect() { | |
global $wp_rewrite; | |
if (!isset($wp_rewrite) || !is_object($wp_rewrite) || !$wp_rewrite->using_permalinks()) { return; } | |
$search_base = $wp_rewrite->search_base; | |
if (is_search() && !is_admin() && strpos($_SERVER['REQUEST_URI'], "/{$search_base}/") === false) { | |
wp_redirect(home_url("/{$search_base}/" . urlencode(get_query_var('s')))); |
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 | |
// Code goes in theme functions.php or a custom plugin | |
add_filter( 'pre_option_woocommerce_enable_guest_checkout', 'conditional_guest_checkout_based_on_product' ); | |
function conditional_guest_checkout_based_on_product( $value ) { | |
$restrict_ids = array( 1, 2, 3 ); // Replace with product ids which cannot use guest checkout | |
if ( WC()->cart ) { | |
$cart = WC()->cart->get_cart(); |
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
"use strict"; | |
(function ($) { | |
/** | |
* Detects all component attributes that have only a single value option and adds the '.single-choice' class | |
* to the respective table row. Additionally, a <span> with the class '.single-choice-label' is added, containing | |
* the options name. | |
* | |
* If executed twice, the previous changes are reverted first (in order to account for possible scenario changes). | |
* Default values or previous selections are saved and restored if the option becomes available again. |