This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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( 'pre_get_posts', 'w_filter_query' ); | |
function w_filter_query( $q ) { | |
if ( ! is_admin() && $q->is_main_query() && is_post_type_archive( 'recipe' ) ) { | |
$q->set( 'posts_per_page', -1 ); | |
$q->set( 'need_special_order', 'type-recette' ); | |
} | |
} | |
add_filter('posts_clauses', 'w_orderby_tax_clauses', 10, 2 ); |
This file contains hidden or 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( 'post_link', 'w_post_link', 10, 3 ); | |
function w_post_link( $url, $post, $leavename=false ) { | |
if ( $post->post_type == 'post' ) { | |
global $sitepress; | |
$lang = apply_filters( 'wpml_post_language_details', 'fr', $post->ID ); | |
$base = get_permalink( icl_object_id( get_option( 'page_for_posts' ), 'page', true, $lang['language_code'] ) ); | |
$url = str_replace( $sitepress->language_url( $lang['language_code'] ), $base, $url ); | |
} |
This file contains hidden or 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( 'the_title', 'willy_insert_missing_unsecable' ); | |
add_filter( 'the_content', 'willy_insert_missing_unsecable' ); | |
function willy_insert_missing_unsecable( $text ) { | |
$patterns = array( | |
'« ' => '« ', | |
' »' => ' »', | |
' :' => ' :', | |
' !' => ' !', |
This file contains hidden or 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, | |
) ); |