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( 'admin_post_cart_to_quote', 'do_cart_to_quote' ); | |
add_action( 'admin_post_nopriv_cart_to_quote', 'do_cart_to_quote' ); | |
function w_cart_to_quote() { | |
$inst = YITH_Request_Quote::get_instance(); | |
foreach( WC()->cart->get_cart() as $k => $data ) { | |
$product_id = $data['product_id']; | |
$obj = array( | |
'context' => 'frontend', |
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 | |
/* NE PAS OUBLIER DE SUPPRIMER CE FICHIER */ | |
require_once( 'wp-load.php' ); | |
require_once( './wp-admin/includes/user.php' ); | |
if ( is_multisite() && function_exists('get_super_admins') && $admins = get_super_admins() ) { | |
$user = get_user_by( 'login', $admins[0] ); | |
$user_id = $user->ID; | |
} else { | |
$admins = get_users( array( 'role' => 'administrator' ) ); |
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 | |
function trace_hooks() { | |
global $wp_filter; | |
foreach ( $wp_filter[current_filter()]->callbacks as $f ) { | |
var_dump( current_filter(), $f ); | |
} | |
} | |
add_action( 'all', 'trace_hooks' ); |
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 | |
/** | |
* Cette action permet lors d'une sauvegarde d'article, de le dupliquer automatiquement dans toutes les langues | |
*/ | |
add_action( 'pll_save_post', 'w_force_duplicate_post', 10, 3 ); | |
function w_force_duplicate_post( $post_id, $post, $translations ) { | |
remove_filter( 'pll_save_post', 'w_force_duplicate_post' ); | |
if ( 'event' != get_post_type( $post ) ) { | |
return 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 | |
add_filter( 'astra_display_on_list', 'w_astra_display_on_list_pro' ); | |
function w_astra_display_on_list_pro( $rules ) { | |
// look at $rules array to see where you should add your filter | |
$rules['basic']['value']['pro_only'] = 'Pages professionnels'; | |
return $rules; | |
} | |
function my_condition_is_ok_here( $id ) { |
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 | |
$with_photos = get_posts( array( | |
'post_type' => 'posts', | |
'suppress_filters' => false, | |
'only_with_attachments' => true, | |
'posts_per_page' => 10, | |
) ); | |
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_filter('terms_clauses', 'w_term_search_clauses', 10, 3 ); | |
function w_term_search_clauses( $clauses, $taxonomies, $args ) { | |
if ( ! empty( $taxonomies ) && in_array( 'product_cat', $taxonomies ) ) { | |
if ( ! empty( $args['search'] ) ) { | |
global $wpdb; | |
$like = '%' . $wpdb->esc_like( $args['search'] ) . '%'; | |
$clauses['join'] .= " INNER JOIN {$wpdb->termmeta} AS tm ON t.term_id = tm.term_id"; | |
$clauses['where'] = preg_replace( '/\)$/', $wpdb->prepare(" OR (tm.meta_key = 'analog_search' AND tm.meta_value LIKE %s))", $like ), $clauses['where'] ); |
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( 'menu-product-filter', 'w_product_filters' ); | |
function w_product_filters() { | |
$cat = get_queried_object_id(); // si on est sur un ontenu, si c'est une archive on force la valeur (sans tirets) | |
$current = array(); | |
if ( ! empty( $_COOKIE['w_filters'] ) ) { | |
$filters = json_decode( stripslashes( $_COOKIE['w_filters'] ) ); | |
if ( ! empty( $filters->$cat ) ) { |
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 | |
wp_dropdown_categories( array( | |
'taxonomy' => 'category', | |
'multiple' => true, | |
'walker' => new Willy_Walker_CategoryDropdown(), | |
'selected' => array( 10, 12 ), // selected terms… | |
'hide_empty' => 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 | |
add_action( 'init', 'register_my_taxo' ); | |
function register_my_taxo() { | |
register_taxonomy( 'immo_cat', 'immobilier', array( | |
'hierarchical' => false, | |
'label' => 'Type de biens', | |
// je déclare le slug de taxo de manière à pouvoir le traduire | |
'rewrite' => array( 'slug' => icl_t('nebula', 'property-type-slug', 'type-bien-immobilier' ) ), | |
) ); | |
} |