function load_vc_page_custom_css( $id = null, $inline_css = true ) {
if ( defined( 'WPB_VC_VERSION' ) ) {
if ( $id === null && ( is_front_page() || is_home() ) ) {
$id = get_queried_object_id();
} elseif ( is_singular() ) {
if ( ! $id ) {
$id = get_the_ID();
}
}
if ( $id ) {
if ( 'true' === vc_get_param( 'preview' ) ) {
$latest_revision = wp_get_post_revisions( $id );
if ( ! empty( $latest_revision ) ) {
$array_values = array_values( $latest_revision );
$id = $array_values[0]->ID;
}
}
$post_custom_css = get_metadata( 'post', $id, '_wpb_post_custom_css', true );
if ( ! empty( $post_custom_css ) ) {
$post_custom_css = wp_strip_all_tags( $post_custom_css );
if ( false === $inline_css ) {
return $post_custom_css;
}
echo '';
}
}
} else {
return;
}
}
function load_vc_shortcode_custom_css( $id = null, $inline_css = true ) {
if ( defined( 'WPB_VC_VERSION' ) ) {
// if ( ! is_singular() ) {
// return;
// }
if ( ! $id ) {
$id = get_the_ID();
}
if ( $id ) {
if ( 'true' === vc_get_param( 'preview' ) ) {
$latest_revision = wp_get_post_revisions( $id );
if ( ! empty( $latest_revision ) ) {
$array_values = array_values( $latest_revision );
$id = $array_values[0]->ID;
}
}
$shortcodes_custom_css = get_metadata( 'post', $id, '_wpb_shortcodes_custom_css', true );
if ( ! empty( $shortcodes_custom_css ) ) {
$shortcodes_custom_css = wp_strip_all_tags( $shortcodes_custom_css );
if ( false === $inline_css ) {
return $shortcodes_custom_css;
}
echo '';
}
}
} else {
return;
}
}
function jeg_render_builder_content( $page_id ) {
if ( defined( 'ELEMENTOR_VERSION' ) && \Elementor\Plugin::$instance->db->is_built_with_elementor( $page_id ) ) {
$frontend = \Elementor\Plugin::$instance->frontend;
add_action( 'wp_enqueue_scripts', array( $frontend, 'enqueue_styles' ) );
add_action( 'wp_head', array( $frontend, 'print_fonts_links' ) );
add_action( 'wp_footer', array( $frontend, 'wp_footer' ) );
if ( method_exists( $frontend, 'add_menu_in_admin_bar' ) ) {
jnews_admin_topbar_menu( array( $frontend, 'add_menu_in_admin_bar' ), 200 );
}
add_action( 'wp_enqueue_scripts', array( $frontend, 'register_scripts' ), 5 );
add_action( 'wp_enqueue_scripts', array( $frontend, 'register_styles' ), 5 );
$html = $frontend->get_builder_content( $page_id );
add_filter( 'get_the_excerpt', array( $frontend, 'start_excerpt_flag' ), 1 );
add_filter( 'get_the_excerpt', array( $frontend, 'end_excerpt_flag' ), 20 );
} else {
load_vc_page_custom_css($page_id);
load_vc_shortcode_custom_css($page_id);
$page = get_post( $page_id );
$html = do_shortcode( $page->post_content );
}
return apply_filters( 'jeg_render_builder_content', $html, $page_id );
}