', '

' ); } else { echo '
'; buddyx_get_breadcrumb(); echo '
'; } // Store the generated breadcrumb. $breadcrumb = ob_get_clean(); wp_cache_set( $cache_key, $breadcrumb, 'buddyx_breadcrumb', 12 * HOUR_IN_SECONDS ); // Cache for 12 hours. } // Output the breadcrumb. echo wp_kses_post( $breadcrumb ); } } // Site Loader if ( ! function_exists( 'buddyx_site_loader' ) ) { function buddyx_site_loader() { $loader = get_theme_mod( 'site_loader', buddyx_defaults( 'site-loader' ) ); if ( $loader == '1' ) { echo '
'; } } } // Site Search and WooCommerce Cart Icon. if ( ! function_exists( 'buddyx_site_menu_icon' ) ) { /** * Renders site menu icons, including a search icon and a WooCommerce cart icon. * The function checks the theme settings to determine if the icons should be displayed. */ function buddyx_site_menu_icon() { // Get the settings for search and cart icons from the theme customizer. $searchicon = (int) get_theme_mod( 'site_search', buddyx_defaults( 'site-search' ) ); $carticon = (int) get_theme_mod( 'site_cart', buddyx_defaults( 'site-cart' ) ); // Check if either search or cart icon is enabled. if ( ! empty( $searchicon ) || ! empty( $carticon ) ) : ?> ' . esc_html__( 'BuddyX WordPress Theme', 'buddyx' ) . '', // Theme author link. ), $copyright ); } else { // Generate default copyright text. $output = sprintf( 'Copyright © %s %s | Powered by %s', date_i18n( 'Y' ), // Current year. esc_url( home_url( '/' ) ), // Site URL. esc_html( get_bloginfo( 'name' ) ), // Site title. esc_url( 'https://wbcomdesigns.com/downloads/buddyx-theme/' ), // Theme URL. esc_html__( 'BuddyX WordPress Theme', 'buddyx' ) // Translated theme name. ); } // Apply filter to allow modifications to the footer text. return apply_filters( 'buddyx_footer_copyright_text', $output ); } } /** * Categorized Blog * Find out if blog has more than one category. */ if ( ! function_exists( 'buddyx_categorized_blog' ) ) { function buddyx_categorized_blog() { if ( false === ( $all_the_cool_cats = get_transient( 'buddyx_category_count' ) ) ) { $all_the_cool_cats = get_categories( array( 'hide_empty' => 1 ) ); $all_the_cool_cats = count( $all_the_cool_cats ); set_transient( 'buddyx_category_count', $all_the_cool_cats ); } if ( 1 !== (int) $all_the_cool_cats ) { return true; } else { return false; } } } /** * Blog Post Meta */ if ( ! function_exists( 'buddyx_posted_on' ) ) { function buddyx_posted_on() { global $post; if ( is_sticky() && is_home() && ! is_paged() ) { echo '' . esc_html__( 'Sticky', 'buddyx' ) . ''; } if ( in_array( 'category', get_object_taxonomies( get_post_type() ) ) && buddyx_categorized_blog() ) { echo '' . get_the_category_list( ', ' ) . ''; } if ( ! is_search() ) { if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) { echo ''; comments_popup_link( esc_html__( 'Leave a comment', 'buddyx' ), esc_html__( '1 Comment', 'buddyx' ), esc_html__( '% Comments', 'buddyx' ) ); echo ''; } } edit_post_link( esc_html__( 'Edit', 'buddyx' ), '', '' ); } } /** * Managing 404 URL in Frontend */ if ( ! function_exists( 'buddyx_404_redirect' ) ) { /** * Redirects 404 error pages to a custom page set in the theme customizer. * This optimized version only runs necessary code when on a 404 page and * adds more efficient checks. * * @return void */ function buddyx_404_redirect() { // Only proceed if we're on a 404 page - avoid unnecessary processing. if ( ! is_404() ) { return; } // Check for rtMedia routes early to avoid unnecessary theme mod retrieval. if ( isset( $_SERVER['REQUEST_URI'] ) && strpos( $_SERVER['REQUEST_URI'], '/media/' ) !== false ) { return; } // Get the custom 404 page ID - retrieve from theme mod only once. $redirect_page_id = get_theme_mod( 'buddyx_404_page', 0 ); // Only proceed with redirection if a valid page ID exists. if ( ! empty( $redirect_page_id ) && get_post_status( $redirect_page_id ) === 'publish' ) { $redirect_url = get_permalink( $redirect_page_id ); // Only redirect if we got a valid URL. if ( ! empty( $redirect_url ) ) { wp_safe_redirect( $redirect_url, 301 ); exit; } } } // Hook the function to the `template_redirect` action. add_action( 'template_redirect', 'buddyx_404_redirect', 10 ); } /** * Add Elementor Locations Support */ if ( ! function_exists( 'buddyx_register_elementor_locations' ) ) { function buddyx_register_elementor_locations( $elementor_theme_manager ) { $elementor_theme_manager->register_location( 'header' ); $elementor_theme_manager->register_location( 'footer' ); } add_action( 'elementor/theme/register_locations', 'buddyx_register_elementor_locations' ); } /** * Display LifterLMS Course and Lesson sidebars * on courses and lessons in place of the sidebar returned by * this function * * @param string $id default sidebar id (an empty string) * @return string */ if ( ! function_exists( 'buddyx_llms_sidebar_function' ) ) { function buddyx_llms_sidebar_function( $id ) { $my_sidebar_id = 'sidebar-right'; // replace this with your theme's sidebar ID return $my_sidebar_id; } add_filter( 'llms_get_theme_default_sidebar', 'buddyx_llms_sidebar_function' ); } /** * Declare explicit theme support for LifterLMS course and lesson sidebars * * @return void */ if ( ! function_exists( 'buddyx_llms_theme_support' ) ) { function buddyx_llms_theme_support() { add_theme_support( 'lifterlms-sidebars' ); } add_action( 'after_setup_theme', 'buddyx_llms_theme_support' ); } /** * Example usage for learndash-focus-header-usermenu-after action. */ add_action( 'learndash-focus-header-usermenu-after', function ( $course_id, $user_id ) { ?> ID; $title_overwrite = get_post_meta( $post_id, '_post_title_overwrite', true ); $title_position = get_post_meta( $post_id, '_post_title_position', true ); ?>

ID; $post_video = get_post_meta( $post_id, '_buddyx_post_video', true ); $post_audio = get_post_meta( $post_id, '_buddyx_post_audio', true ); $post_quote = get_post_meta( $post_id, '_buddyx_post_quote', true ); $post_quote_author = get_post_meta( $post_id, '_buddyx_post_quote_author', true ); $post_link_title = get_post_meta( $post_id, '_buddyx_post_link_title', true ); $post_link_url = get_post_meta( $post_id, '_buddyx_post_link_url', true ); $post_image_gallery = get_post_meta( $post_id, '_buddyx_image_gallery', true ); ?>

'_buddyx_post_video', 'buddyx_post_audio' => '_buddyx_post_audio', 'buddyx_post_quote' => '_buddyx_post_quote', 'buddyx_post_quote_author' => '_buddyx_post_quote_author', 'buddyx_post_link_title' => '_buddyx_post_link_title', 'buddyx_post_link_url' => '_buddyx_post_link_url', 'buddyx_image_gallery' => '_buddyx_image_gallery', ); // Process and save text fields. foreach ( $text_fields as $field_name => $meta_key ) { if ( isset( $_POST[ $field_name ] ) ) { $value = sanitize_text_field( wp_unslash( $_POST[ $field_name ] ) ); update_post_meta( $post_id, $meta_key, $value ); } } // Handle checkbox for title overwrite (separate because it needs different handling). if ( isset( $_POST['_post_title_overwrite'] ) ) { update_post_meta( $post_id, '_post_title_overwrite', sanitize_text_field( $_POST['_post_title_overwrite'] ) ); } else { // Remove the meta if the checkbox is unchecked. delete_post_meta( $post_id, '_post_title_overwrite' ); } // Handle title position. if ( isset( $_POST['_post_title_position'] ) ) { // Validate against allowed values (optional security enhancement). $allowed_positions = array( 'title-over', 'half', 'title-above', 'title-below' ); $position = sanitize_text_field( wp_unslash( $_POST['_post_title_position'] ) ); if ( in_array( $position, $allowed_positions ) ) { update_post_meta( $post_id, '_post_title_position', $position ); } } } } /** * Function will add feature image for blog post in the activity feed content. * * @param string $content * @param int $blog_post_id * * @return string $content * * @since 4.2.2 */ function buddyx_add_feature_image_blog_post_as_activity_content_callback( $content, $blog_post_id ) { if ( function_exists( 'buddypress' ) && ! isset( buddypress()->buddyboss ) ) { if ( ! empty( $blog_post_id ) && ! empty( get_post_thumbnail_id( $blog_post_id ) ) ) { $content .= sprintf( ' ', esc_url( get_permalink( $blog_post_id ) ), esc_url( wp_get_attachment_image_url( get_post_thumbnail_id( $blog_post_id ), 'full' ) ) ); } } return $content; } add_filter( 'buddyx_add_feature_image_blog_post_as_activity_content', 'buddyx_add_feature_image_blog_post_as_activity_content_callback', 10, 2 ); add_action( 'bp_before_activity_activity_content', 'buddyx_bp_blogs_activity_content_set_temp_content' ); /** * Function which set the temporary content on the blog post activity. * * @since 4.2.2 */ function buddyx_bp_blogs_activity_content_set_temp_content() { if ( function_exists( 'buddypress' ) && ! isset( buddypress()->buddyboss ) ) { global $activities_template; $activity = $activities_template->activity; if ( ( 'blogs' === $activity->component ) && isset( $activity->secondary_item_id ) && 'new_blog_' . get_post_type( $activity->secondary_item_id ) === $activity->type ) { $content = get_post( $activity->secondary_item_id ); // If we converted $content to an object earlier, flip it back to a string. if ( is_a( $content, 'WP_Post' ) ) { $activities_template->activity->content = '​'; } } elseif ( 'blogs' === $activity->component && 'new_blog_comment' === $activity->type && $activity->secondary_item_id && $activity->secondary_item_id > 0 ) { $activities_template->activity->content = '​'; } } } add_filter( 'bp_get_activity_content_body', 'buddyx_bp_blogs_activity_content_with_read_more', 9999, 2 ); /** * Function which enhances activity blog post content with formatting, featured images, and read more links. * * @param string $content The current activity content. * @param object $activity The activity object. * * @return string Modified activity content. * * @since 4.2.2 */ function buddyx_bp_blogs_activity_content_with_read_more( $content, $activity ) { // Only proceed if BuddyPress is active and not BuddyBoss. if ( ! function_exists( 'buddypress' ) || isset( buddypress()->buddyboss ) ) { return $content; } // Handle blog posts in activity stream. if ( 'blogs' === $activity->component && isset( $activity->secondary_item_id ) ) { // Handle new blog posts. if ( 'new_blog_' . get_post_type( $activity->secondary_item_id ) === $activity->type ) { $blog_post = get_post( $activity->secondary_item_id ); if ( ! is_a( $blog_post, 'WP_Post' ) ) { return $content; } // Get featured image. $content_img = apply_filters( 'buddyx_add_feature_image_blog_post_as_activity_content', '', $blog_post->ID ); // Format post title with link. $post_title = sprintf( '%s', esc_url( get_permalink( $blog_post->ID ) ), esc_html( $blog_post->post_title ) ); // Get and process post excerpt. $excerpt = bp_create_excerpt( bp_strip_script_and_style_tags( html_entity_decode( get_the_excerpt( $blog_post->ID ) ) ) ); // Check if excerpt ends with ellipsis. $has_ellipsis = ( strpos( $excerpt, __( '…', 'buddyx' ) ) !== false ); // Clean up the excerpt. if ( $has_ellipsis ) { $excerpt = str_replace( ' […]', '…', $excerpt ); } // Apply BP filters. $excerpt = apply_filters_ref_array( 'bp_get_activity_content', array( $excerpt, $activity ) ); // Extract and preserve iframes. $has_iframe = preg_match( '/<\/iframe>/isU', $excerpt, $matches ); // Strip tags but preserve links and allowed elements. if ( $has_iframe && ! empty( $matches[0] ) ) { $iframe = $matches[0]; $excerpt = strip_tags( preg_replace( '//i', '', $excerpt ), '' ); $excerpt .= $iframe; } else { $excerpt = strip_tags( $excerpt, '