MemberPress: Exclude Protected Posts from Search Results

function maybe_exclude_protected_posts($query) { if(!$query->is_admin && $query->is_search && $query->is_main_query()) { $posts_to_exclude = array(); $posts = get_posts(array( ‘post_type’ => get_post_types(), ‘numberposts’ => -1 )); foreach($posts as $post) { if(MeprRule::is_locked($post)) { $posts_to_exclude[] = $post->ID; } } if(!empty($posts_to_exclude)) { $query->set(‘post__not_in’, $posts_to_exclude); } } }…Continue reading

WPForms: new smart tag – Current Unix Time

// Register the smart tag. add_filter( ‘wpforms_smart_tags’, static function( $tags ) { // Key is the tag, value is the tag name. $tags[‘current_unix_time’] = ‘Current Unix Time’; return $tags; } ); // Replace its value on form render on front-end.…Continue reading

Custom Countries

function pw_edd_custom_countries( $countries = array() ) { $countries = array( ‘US’ => ‘United States’, ‘CA’ => ‘Canada’ ); return $countries; } add_filter( ‘edd_countries’, ‘pw_edd_custom_countries’ );Continue reading