sc_audio_enqueued) && !pagelayer_is_live_iframe()){
wp_enqueue_script('wp-mediaelement');
wp_enqueue_style( 'wp-mediaelement' );
$pagelayer->sc_audio_enqueued = 1;
}
return;
$el['atts']['a_url'] = '';
if ($el['atts']['source'] == 'external'){
$el['atts']['a_url'] = $el['atts']['url'];
}
if ($el['atts']['source'] == 'library'){
$el['atts']['a_url'] = wp_get_attachment_url($el['atts']['id']);
}
if(!empty($el['atts']['a_url'])){
$filename=$el['atts']['a_url'];
//Get the file extension
$extension = pathinfo($filename, PATHINFO_EXTENSION);
//Create source tag according to audio file
switch($extension){
default:
case 'mp3':
$el['atts']['a_type'] = 'audio/mpeg';
break;
case 'ogg':
$el['atts']['a_type']= 'audio/ogg';
break;
case 'wav':
$el['atts']['a_type'] = 'audio/wav';
break;
}
}
if(!empty($el['atts']['a_url']) && !empty($el['atts']['a_type'])){
$el['attr'][]= ['source' => 'src="{{a_url}}'];
$el['attr'][]= ['source' => 'type="{{a_type}}'];
}
}
// Image Portfolio
function pagelayer_sc_single_img(&$el){
// Decide the image URL
$img_size = pagelayer_isset($el['atts'], 'img-size');
$el['atts']['func_img'] = pagelayer_isset($el['tmp'], 'img-'.$img_size.'-url');
$el['atts']['func_img'] = empty($el['atts']['func_img']) ? pagelayer_isset($el['tmp'], 'img-url') : $el['atts']['func_img'];
// What is the link ?
if(!empty($el['atts']['link_type'])){
// Custom url
if($el['atts']['link_type'] == 'custom_url'){
// Backward compatibility for new link props
pagelayer_add_link_backward($el, array( 'rel' => '', 'selector' => '.pagelayer-ele-link'));
$el['atts']['func_link'] = empty($el['tmp']['link']) ? '' : $el['tmp']['link'];
}
// Link to the media file itself
if($el['atts']['link_type'] == 'media_file'){
$el['atts']['func_link'] = $el['atts']['func_img'];
}
// Lightbox
if($el['atts']['link_type'] == 'lightbox'){
$el['atts']['func_link'] = $el['atts']['func_img'];
}
}
}
// Posts Grid
function pagelayer_sc_wp_posts_grid($atts, $content = '', $tag = ''){
$args = array(
'numberposts' => -1,
'post_type' => 'post',
'post_status' => array('publish', 'pending', 'draft', 'future', 'private', 'inherit', 'trash')
);
$all_posts = get_posts($args);
$html = '
' . __( 'Your cart is currently empty.') . '
';
}
}
// If the content is empty
if(empty($content)){
$content = '' . __( 'Page content not found.') . '
';
}
$el['atts']['page_content'] = $content;
}
// Product Pages - 2C
function pagelayer_sc_product_categories(&$el){
$attributes = '';
$attributes .= ' number="'. (isset($el['atts']['number']) ? $el['atts']['number'] : '').'" ';
$attributes .= ' columns="'. (isset($el['atts']['columns']) ? $el['atts']['columns'] : '').'" ';
$attributes .= ' hide_empty="'. (!empty($el['atts']['hide_empty']) ? 1 : 0) .'" ';
$attributes .= ' orderby="'. (isset($el['atts']['nuorderbymber']) ? $el['atts']['nuorderbymber'] : '') .'" ';
$attributes .= ' order="'. (isset($el['atts']['order']) ? $el['atts']['order'] : '') .'" ';
$source = isset($el['atts']['source']) ? $el['atts']['source'] : '';
if ( 'by_id' === $source ) {
$attributes .= ' ids="'. $el['atts']['by_id'] .'" ';
} elseif ( 'by_parent' === $source ) {
$attributes .= ' parent="'. $el['atts']['parent'] .'" ';
} elseif ( 'current_subcategories' === $source ) {
$attributes .= ' parent="'. get_queried_object_id() .'" ';
}
$shortcode = '[product_categories '. $attributes .']';
// do_shortcode the shortcode
$el['atts']['product_categories'] = pagelayer_the_content($shortcode);
}
// Products - 2C
function pagelayer_sc_products(&$el){
if( WC()->session ){
wc_print_notices();
}
$no_found = $el['atts']['no_found'];
$attributes = '';
$type = $el['atts']['source'];
$attributes .= ' columns="'. $el['atts']['columns'] .'" ';
$attributes .= ' rows="'. $el['atts']['rows'] .'" ';
$attributes .= ' paginate="'. (!empty($el['atts']['paginate']) ? true : false) .'" ';
$attributes .= ' orderby="'. $el['atts']['orderby'] .'" ';
$attributes .= ' order="'. $el['atts']['order'] .'" ';
$attributes .= ' cache="false" ';
// Hide the catalog order
if( empty($el['atts']['allow_order']) ){
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
}
// Hide the result count
if( empty($el['atts']['show_result']) ){
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
}
if( $type == 'by_id' ){
$type = 'products';
$attributes .= ' ids="'. (!empty($el['atts']['ids']) ? $el['atts']['ids'] : '') .'" ';
}elseif( $type == 'pagelayer_current_query' ){
$atts['paginate'] = (!empty($el['atts']['paginate']) ? true : false);
$atts['cache'] = false;
$type = 'pagelayer_current_query';
// Set the current query
add_action( 'woocommerce_shortcode_products_query', 'pagelayer_shortcode_current_query', 10, 10);
// If product not found
add_action( "woocommerce_shortcode_{$type}_loop_no_results", function ($attributes) use ($no_found){
echo ''. __($no_found) .'
';
}
$el['atts']['products_content'] = $content;
}
// Archives Product Pages - 2C
function pagelayer_sc_product_archives(&$el){
global $post;
if ( WC()->session ) {
wc_print_notices();
}
$atts['paginate'] = true;
$atts['cache'] = false;
$no_found = $el['atts']['no_found'];
if( empty($el['atts']['allow_order']) ){
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
}
if( empty($el['atts']['show_result']) ){
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
}
$type = 'pagelayer_current_query';
// We need to define costom
if( (isset($post->post_type) && $post->post_type == 'pagelayer-template') || wp_doing_ajax()){
$type = '';
}
// Set the current query
add_action( 'woocommerce_shortcode_products_query', 'pagelayer_shortcode_current_query', 10, 10);
// If product not found
add_action( "woocommerce_shortcode_{$type}_loop_no_results", function ($attributes) use ($no_found){
echo '
'. ob_get_clean() .'
';
}
// Product rating render - 2C
function pagelayer_sc_product_rating(&$el) {
if( ! post_type_supports( 'product', 'comments' ) ){
return;
}
global $product;
$product = pagelayer_get_product();
$product_rating = '';
if( empty( $product ) && (pagelayer_is_live_template() || wp_doing_ajax())){
$product_rating = __pl('no_woo_product');
}
if ( empty( $product ) ) {
$el['atts']['product_rating'] = $product_rating;
return;
}
ob_start();
wc_get_template( '/single-product/rating.php' );
$product_rating = ob_get_clean();
if( empty( $product_rating ) && pagelayer_is_live_template()){
$product_rating = __('No Rating Found!');
}
$el['atts']['product_rating'] = $product_rating;
}
/*
// Product stock render - 2C
function pagelayer_product_stock() {
global $product;
$product = wc_get_product();
if ( empty( $product ) ) {
return;
}
return wc_get_stock_html( $product );
} */
// Product meta render - 2C
function pagelayer_sc_product_meta(&$el) {
global $product;
$product = pagelayer_get_product();
$product_meta = '';
if( empty( $product ) && (pagelayer_is_live_template() || wp_doing_ajax())){
$product_meta = __pl('no_woo_product');
}
if ( empty( $product ) ) {
$el['atts']['product_meta'] = $product_meta;
return;
}
ob_start();
wc_get_template( '/single-product/meta.php' );
$el['atts']['product_meta'] = ob_get_clean();
}
// Product short description render - 2C
function pagelayer_sc_product_short_desc(&$el) {
global $product, $post;
$product = pagelayer_get_product();
$product_short_desc = '';
if( empty( $product ) && (pagelayer_is_live_template() || wp_doing_ajax())){
$product_short_desc = __pl('no_woo_product');
}
if ( empty( $product ) ) {
$el['atts']['product_short_desc'] = $product_short_desc;
return;
}
if((isset($post->post_type) && $post->post_type == 'pagelayer-template') || wp_doing_ajax()){
$el['atts']['product_short_desc'] = '';
$hier = (empty($el['atts']['hierarchical']) ? '' : $el['atts']['hierarchical']);
$depth = (empty($el['atts']['depth']) ? '' : $el['atts']['depth']);
if($el['atts']['sitemap_type'] == 'post_type'){
if(empty($el['atts']['title'])){
$el['atts']['title'] = 'Pages';
}
$html_element .= $el['atts']['title'];
$args = array(
'post_type' => $el['atts']['source_post'],
'orderby' => $el['atts']['order_post'],
'order' => $el['atts']['order'],
'hierarchical' => $hier,
'number' => $depth,
'posts_per_page' => -1,
);
$option .= '
'.$html_element.'';
$option .= '
';
$pages = new WP_Query($args);
$posts = $pages->posts;
foreach ( $posts as $page ) {
$option .= '- '.$page->post_name.'
';
}
$option .= '
';
}else{
if(empty($el['atts']['title'])){
$el['atts']['title'] = 'Categories';
}
$html_element .= $el['atts']['title'];
$args = array(
'title_li' => 0,
'orderby' => $el['atts']['order_taxonomy'],
'order' => $el['atts']['order'],
'style' => '',
'hide_empty' => $el['atts']['hide_empty'],
'echo' => false,
'hierarchical' => $hier,
'taxonomy' => $el['atts']['source_taxonomy'],
'depth' => $depth,
);
$taxonomies = get_categories( $args );
$option .= '
'.$html_element.'';
$option .= '
';
}
$option .= '
';
$el['atts']['sitemap_html'] = $option;
}
function pagelayer_sc_slides(&$el) {
if( !pagelayer_is_live() ) {
return;
}
foreach($el['inner_blocks'] as $key => $inner_block) {
if('pagelayer/pl_slide' != $inner_block['blockName']) {
continue;
}
$slide = serialize_block($inner_block);
$col = get_comment_delimited_block_content('pagelayer/pl_col', [] , $slide);
$row = get_comment_delimited_block_content('pagelayer/pl_inner_row', ['col_gap' => '0.0'] , $col);
$el['inner_blocks'][$key] = array(
'blockName' => 'pagelayer/pl_content_slide',
'innerBlocks' => parse_blocks($row),
'innerHTML' => '',
'attrs' => array(),
'innerContent' => array(),
);
}
}
function pagelayer_sc_chart(&$el){
$el['atts']['xcolor'] = empty($el['atts']['xcolor']) ? '' : pagelayer_parse_color($el['atts']['xcolor'], false);
$el['atts']['ycolor'] = empty($el['atts']['ycolor']) ? '' : pagelayer_parse_color($el['atts']['ycolor'], false);
}
function pagelayer_sc_chart_datasets(&$el){
$el['atts']['chart_border_color'] = empty($el['atts']['chart_border_color']) ? '' : pagelayer_parse_color($el['atts']['chart_border_color'], false);
$el['atts']['bg_color'] = empty($el['atts']['bg_color']) ? '' : pagelayer_parse_color($el['atts']['bg_color'], false);
}
// Render the image map
function pagelayer_sc_image_map(&$el) {
$map_size = pagelayer_isset($el['atts'], 'img_map-size');
$map_key = 'img_map-id-' . $map_size . '-url';
$el['atts']['map_img_id'] = isset($el['tmp'][$map_key]) ? $el['tmp'][$map_key] : pagelayer_isset($el['tmp'], 'map_img-id-url');
$el['atts']['pagelayer-srcset'] = $el['atts']['map_img_id'] . ', ' . $el['atts']['map_img_id'] . ' 1x, ';
// Handle multiple paths
if(isset($el['atts']['pagelayer_image_map']) && is_array($el['atts']['pagelayer_image_map'])){
$el['atts']['pagelayer_map_path'] = ''; // Initialize as empty
foreach ($el['atts']['pagelayer_image_map'] as $key => $data) {
$data_cord = isset($data['path']) ? $data['path'] : '';
$data_id = isset($key) ? $key : '';
$data_link = isset($data['link']) ? $data['link'] : '';
$el['atts']['pagelayer_map_path'] .= "