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 | |
/** | |
* @credits https://jeroensormani.com/adding-a-custom-woocommerce-product-type/ | |
*/ | |
//error_reporting(E_ALL); | |
//ini_set('display_errors', 1); | |
add_action('init' , 'wc_pm_load_product_type'); | |
function wc_pm_load_product_type() { | |
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 | |
$posts = maybeCache('remote_posts_data', 7200, function () { | |
return do_remote_get('https://jsonplaceholder.typicode.com/posts/'); | |
}); | |
foreach ($posts as $post) { | |
echo "<h2>{$post->title}</h2>"; | |
} |
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 | |
add_action('wp_enqueue_scripts', 'enqueue_if_shortcode'); | |
function enqueue_if_shortcode(){ | |
global $post; | |
if ( $post && has_shortcode( $post->post_content, 'your_shortcode_tag' ) { | |
// Enqueue | |
} |
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 | |
// Modify the fields to search in | |
add_action( 'elementor/query/searched_query', function( $query ) { | |
$s = get_search_query(); | |
if ( is_search() ) { | |
$query->set( 'post_type', 'leverandor' ); | |
if( strlen($s) >= 3 ) { |
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 | |
// For variations | |
add_action( 'woocommerce_variation_options_pricing', 'yanco_add_custom_field_to_variations', 10, 3 ); | |
function yanco_add_custom_field_to_variations( $loop, $variation_data, $variation ) { | |
woocommerce_wp_text_input( array( | |
'id' => 'custom_field[' . $loop . ']', | |
'class' => 'short', | |
'label' => __( 'Custom Field', 'woocommerce' ), | |
'value' => get_post_meta( $variation->ID, 'custom_field', true ) |
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 | |
add_shortcode( 'user_company_link', 'yanco_user_company_link' ); | |
function yanco_user_company_link() { | |
if( ! is_user_logged_in() ) { | |
return; | |
} | |
$html = ''; |
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 | |
add_action( 'wp_login_failed', 'yanco_elementor_form_login_fail' ); | |
function yanco_elementor_form_login_fail( $username ) { | |
// where did the post submission come from? | |
$referrer = $_SERVER['HTTP_REFERER']; | |
// if there's a valid referrer, and it's not the default log-in screen | |
if ( !empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') ) { |
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 | |
/** | |
* Add privacy policy tick box at checkout | |
*/ | |
add_action( 'woocommerce_review_order_before_submit', 'yanco_add_checkout_privacy_policy', 9 ); | |
function yanco_add_checkout_privacy_policy() { | |
woocommerce_form_field( 'privacy_policy', array( | |
'type' => 'checkbox', | |
'class' => array('form-row privacy'), |
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 file contains a bunch of helper functions that handle add caching to core WordPress functions. | |
*/ | |
/** | |
* Cached version of get_category_by_slug. | |
* | |
* @param string $slug Category slug | |
* @return object|null|bool Term Row from database. Will return null if $slug doesn't match a term. If taxonomy does not exist then false will be returned. |
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($){ | |
$(function(){ | |
$(document.body).on( 'change', '#min_price, #max_price', function(){ | |
var minPrice = parseFloat( $('#min_price').val() ); | |
var maxPrice = parseFloat( $('#max_price').val() ); | |
$('.item-list li').each(function(){ | |
var price = parseFloat( $(this).attr('data-price') ); |
NewerOlder