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
// Let page builders like Elementor control the display of single events | |
function dont_let_tec_hijack( $should_hijack, $query ) { | |
if ( $query->is_single() ) $should_hijack = false; | |
return $should_hijack; | |
} | |
add_filter( 'tribe_events_views_v2_should_hijack_page_template', 'dont_let_tec_hijack', 10, 2 ); |
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 | |
/* Make BB status obvious */ | |
add_filter( 'display_post_states', 'sg_bb_post_state', 10, 2 ); | |
function sg_bb_post_state( $post_states, $post ) { | |
if ( FLBuilderModel::is_builder_enabled( $post->ID ) ) { | |
$post_states[] = 'Beaver Builder'; | |
} | |
return $post_states; | |
} |
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
/** | |
* Default event recap slug | |
* If has parent and is in category Recap, set slug to "recap". | |
* Can't use `wp_insert_post_data` because taxonomy data isn't included, frustratingly. | |
*/ | |
// Catch changes in block editor | |
add_filter( 'rest_post_dispatch', 'recap_slug_rest', 10, 3 ); | |
function recap_slug_rest( $result, $server, $request ) { | |
if ( 'PUT' == $request->get_method() ) { | |
$post_id = $request->get_param( '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 | |
function rlv_html_tag_boost( $content ) { | |
$weightings = [ | |
'h1' => 5, | |
'h2' => 4, | |
'h3' => 2, | |
'strong' => 1, | |
]; | |
foreach ( $weightings as $tag => $weight ) { |
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
/* Prefer Pages over CPT */ | |
function sg_page_before_cpt( $query ) { | |
$cpt_slug = 'my_cpt_slug'; | |
$cpt_rewrite_slug = 'my_cpt_rewrite_slug'; | |
if( isset( $query->query_vars[$cpt_slug] ) && $slug = $query->query_vars[$cpt_slug] ) { | |
$slug = "$cpt_rewrite_slug/$slug"; | |
if( get_page_by_path( $slug ) ) { |
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
// Based on code from https://ashton.codes/avoid-showing-wordpress-post-multiple-loops/ | |
function sg_track_displayed_posts( $permalink, $post ) { | |
global $sg_displayed_posts; | |
$sg_displayed_posts[ $post->post_type ][] = get_the_ID(); | |
return $permalink; | |
} | |
add_filter( 'post_link', 'sg_track_displayed_posts', 10, 2 ); | |
add_filter( 'post_type_link', 'sg_track_displayed_posts', 10, 2 ); |
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
/* Copy compiled Oxygen page content to post_content for search */ | |
function sg_save_rendered_page_content( $meta_id, $object_id, $meta_key, $meta_value ) { | |
// Debugging | |
// $debug .= preg_replace( '#(\[/[^\]]+?\])#', "$1\n", $meta_value ); | |
// file_put_contents( plugin_dir_path( __FILE__ ) . 'debug.html', $debug ); | |
if ( 'ct_builder_shortcodes' != $meta_key ) return; | |
// Don't try to render anything with inner content | |
if ( false !== strpos( $meta_value, '[ct_inner_content' ) ) return; |
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
// Allow links in excerpts | |
function sg_trim_words( $text, $num_words, $more, $original_text ) { | |
$text = strip_tags( $original_text, '<a>' ); | |
// @See wp_trim_words in wp-includes/formatting.php | |
if ( strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { | |
$text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' ); | |
preg_match_all( '/./u', $text, $words_array ); | |
$words_array = array_slice( $words_array[0], 0, $num_words + 1 ); | |
$sep = ''; | |
} else { |
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
<? | |
/** | |
* Hook into Broadcast | |
* Modify links in the broadcasted post content | |
* "Replace Site URL" checkbox appears in child post meta box to show if this was applied | |
*/ | |
add_action( 'threewp_broadcast_prepare_meta_box', 'my_custom_prepare_meta_box' ); | |
function my_custom_prepare_meta_box( $action ) { | |
$meta_box_data = $action->meta_box_data; // Convenience. |