Snippets frequently used with Sage
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 | |
/** | |
* adds custom js file to handle inline error messages | |
*/ | |
add_action( 'woocommerce_after_checkout_form', 'add_custom_validation_script', 20 ); | |
function add_custom_validation_script() { | |
wp_enqueue_script( |
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
//Woocommerce Checkout JS events | |
$( document.body ).trigger( 'init_checkout' ); | |
$( document.body ).trigger( 'payment_method_selected' ); | |
$( document.body ).trigger( 'update_checkout' ); | |
$( document.body ).trigger( 'updated_checkout' ); | |
$( document.body ).trigger( 'checkout_error' ); | |
//Woocommerce cart page JS events | |
$( document.body ).trigger( 'wc_cart_emptied' ); | |
$( document.body ).trigger( 'update_checkout' ); |
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 | |
// Adds a custom rule type. | |
add_filter( 'acf/location/rule_types', function( $choices ){ | |
$choices[ __("Other",'acf') ]['wc_prod_attr'] = 'WC Product Attribute'; | |
return $choices; | |
} ); | |
// Adds custom rule values. | |
add_filter( 'acf/location/rule_values/wc_prod_attr', function( $choices ){ |
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 | |
namespace Soderlind\WP_Editor; | |
add_filter( 'wp_link_query', __NAMESPACE__ . '\on_wp_link_query', 10, 2 ); | |
add_filter( 'wp_link_query_args', __NAMESPACE__ . '\on_wp_link_query_args' ); | |
add_filter( 'the_permalink', __NAMESPACE__ . '\on_permalink', 10, 2 ); | |
add_filter( 'attachment_link', __NAMESPACE__ . '\on_permalink', 10, 2 ); | |
/** |
Fix for FOUC :
At the top of your HTML:
<!doctype html>
<html>
<head>
<style>html{visibility: hidden;opacity:0;}</style>
- Edit the file at
/Library/Backblaze.bzpkg/bzdata/bzexcluderules_editable.xml
. - Add these rules inside the
bzexclusions
tag:
<!-- Exclude node_modules. -->
<excludefname_rule plat="mac" osVers="*" ruleIsOptional="t" skipFirstCharThenStartsWith="users/" contains_1="/node_modules/" contains_2="*" doesNotContain="*" endsWith="*" hasFileExtension="*" />
<excludefname_rule plat="mac" osVers="*" ruleIsOptional="t" skipFirstCharThenStartsWith="users/" contains_1="/.git/" contains_2="*" doesNotContain="*" endsWith="*" hasFileExtension="*" />
Errors from Laravel logs:
MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.
ERR Error running script (call to f_1af8e79ebe56ad4d7910f2e116e2555983099baf): @user_script:8: @user_script: 8: -MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.
Errors from Redis logs (/var/log/redis/redis-server.log
):
* 1 changes in 900 seconds. Saving...
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 | |
if(!function_exists('wc_get_products')) { | |
return; | |
} | |
$paged = (get_query_var('paged')) ? absint(get_query_var('paged')) : 1; | |
$ordering = WC()->query->get_catalog_ordering_args(); | |
$ordering['orderby'] = array_shift(explode(' ', $ordering['orderby'])); | |
$ordering['orderby'] = stristr($ordering['orderby'], 'price') ? 'meta_value_num' : $ordering['orderby']; |
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 | |
/* | |
################### READ ME ################################# | |
You'll pass the URL to your feed/file to this function inside the "Download from URL" option when creating an import. | |
Image examples: https://d.pr/hCfNek and https://d.pr/MnerNb. | |
1. [custom_file_download("ftp://username:password@hostname.com/full/path/to/file.csv","csv")] | |
2. [custom_file_download("http://example.com/full/path/to/file.csv","csv")] |
NewerOlder