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 get_adherents() { | |
if ( function_exists( 'wcs_get_subscriptions' ) ) { | |
if ( ! $adherents_wpfr = get_transient( 'adherents_wpfr' ) ) { | |
$subscriptions_pro = wcs_get_subscriptions( array( | |
'subscriptions_per_page' => 10, | |
'variation_id' => 11, | |
'subscription_status' => 'active', | |
)); |
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( 'updated_post_meta', 'update_post_modified_on__bbp_last_active_time_update', 10, 4 ); | |
function update_post_modified_on__bbp_last_active_time_update( $meta_id, $object_id, $meta_key, $_meta_value ) { | |
if ( '_bbp_last_active_time' == $meta_key ) { | |
$obj = get_post( $object_id ); | |
if ( 'topic' == $obj->post_type ) { | |
$obj->post_modified = $_meta_value; | |
$obj->post_modified_gmt = gmdate('Y-m-d H:i:s', strtotime( $_meta_value ) ); | |
wp_insert_post( $obj ); | |
} |
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_insert_post', 'willy_set_default_term', 10, 3 ); | |
function willy_set_default_term( $post_id, $post, $update ) { | |
if ( 'cpt' == $post->post_type ) { // replace `cpt` with your custom post type slug | |
/** | |
* Replace `taxo` by the taxonomy slug you want to control/set | |
* … and replace `default-term` by the default term slug (or name) | |
* (or you can use a `get_option( 'my-default-term', 'default term' )` option instead, which is much better) | |
*/ | |
if ( empty( wp_get_post_terms( $post_id, 'taxo' ) ) ) { |
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 data-manual attribute, then call Prism in async way | |
add_filter( 'script_loader_tag', 'pastacode_async', 10, 3 ); | |
function pastacode_async ( $tag, $handle, $src ) { | |
if ( 'prismjs' == $handle ) { | |
$tag = str_replace( '<script ', '<script data-manual ', $tag ); | |
$tag .= '<script>jQuery(document).ready(function($){Prism.highlightAll(true);});</script>'; | |
} | |
return $tag; | |
} |
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 | |
// To work, this function require to bypass has_post_thumbnail() test into templates… | |
add_filter( 'post_thumbnail_html', 'default_post_thumbnail_html', 10, 5 ); | |
function default_post_thumbnail_html( $html, $post_ID, $post_thumbnail_id, $size, $attr ) { | |
// If no thumbnail is sendback by get_post_thumbail(), return a default image | |
if ( '' == $html && in_array( get_post_type( $post_ID ), array( 'post', 'page' ) ) ) { | |
// Get a default thumbnail ID into a list | |
$thumbs = get_option( 'options_default_thumbnails', array() ); | |
$thumb = $thumbs[ array_rand( $thumbs ) ]; | |
remove_filter( 'post_thumbnail_html', 'default_post_thumbnail_html', 10, 5 ); |
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 | |
/** | |
* Whiteliste shortcode | |
*/ | |
add_filter( 'bbp_get_reply_content', 'strip_shortcodes_whitelist', 9 ); | |
add_filter( 'bbp_get_topic_content', 'strip_shortcodes_whitelist', 9 ); | |
function strip_shortcodes_whitelist( $content ) { | |
global $shortcode_tags; |
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( 'query_vars', 'agenda_add_query_vars' ); | |
function agenda_add_query_vars( $vars ){ | |
$vars[] = "passe"; | |
return $vars; | |
} | |
add_filter( 'pre_get_posts', 'agenda_date_pre_get_posts' ); | |
function agenda_date_pre_get_posts( $q ) { | |
if ( ! is_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 | |
/** | |
* Hook on pre_get_posts to set new query vars | |
*/ | |
add_filter( 'pre_get_posts', 'willy_dump_search' ); | |
function willy_dump_search( $q ) { | |
if ( isset( $_GET['search-bb-request'] ) | |
&& $q->is_main_query() | |
&& $_GET['search-bb-request'] == 1) { | |
$text = $q->query_vars['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 | |
add_filter( 'pre_get_posts', 'willy_pre_get_posts' ); | |
function willy_pre_get_posts( $q ) { | |
$moncpt = 'post'; | |
$mataxo = 'category'; | |
if ( $q->is_main_query() && ! is_admin() && is_archive( $moncpt ) ) { | |
$q->set( 'tax_query', array( | |
array( | |
'taxonomy' => $mataxo, | |
'terms' => wp_list_pluck( get_terms( $mataxo ), 'term_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 | |
add_action( 'woocommerce_before_main_content', 'willy_woocommerce_before_main_content_thumbnails', 9 ); | |
function willy_woocommerce_before_main_content_thumbnails() { | |
if ( is_tax( 'product_cat' ) ) { | |
global $wp_query; | |
$cat = $wp_query->get_queried_object(); | |
$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true ); | |
if ( $thumbnail_id ) { | |
echo '<div class="image-single thumbnail-home big-thumb">'; |