first commit
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
namespace Nimble;
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_print_accordion' ) ) {
|
||||
function sek_print_accordion( $accord_opts, $model, $accord_collec = array() ) {
|
||||
$accord_collec = is_array( $accord_collec ) ? $accord_collec : array();
|
||||
|
||||
$is_accordion_multi_item = count( $accord_collec ) > 1;
|
||||
$first_expanded = true === sek_booleanize_checkbox_val( $accord_opts['first_expanded'] ) ? "true" : "false";
|
||||
|
||||
//sek_error_log('$accord_opts??' . $first_expanded, $accord_opts );
|
||||
|
||||
$global_border_width = sek_extract_numeric_value( $accord_opts['border_width_css']);
|
||||
$title_border_width = sek_extract_numeric_value( $accord_opts['title_border_w_css']);
|
||||
|
||||
?>
|
||||
<?php printf('<div class="sek-accord-wrapper" data-sek-accord-id="%1$s" data-sek-is-multi-item="%2$s" data-sek-first-expanded="%3$s" data-sek-one-expanded="%4$s" data-sek-has-global-border="%5$s" data-sek-has-title-border="%6$s" role="tablist">',
|
||||
esc_attr($model['id']),
|
||||
$is_accordion_multi_item ? "true" : "false",
|
||||
esc_attr($first_expanded),
|
||||
true === sek_booleanize_checkbox_val( $accord_opts['one_expanded'] ) ? "true" : "false",
|
||||
$global_border_width > 0 ? "true" : "false",
|
||||
$title_border_width > 0 ? "true" : "false"
|
||||
); ?>
|
||||
<?php if ( is_array( $accord_collec ) && count( $accord_collec ) > 0 ) : ?>
|
||||
<?php
|
||||
$ind = 1;
|
||||
foreach( $accord_collec as $key => $item ) {
|
||||
$title = !empty( $item['title_text'] ) ? $item['title_text'] : sprintf( '%s %s', __('Accordion title', 'text_dom'), '#' . $ind );
|
||||
$item_html_content = $item['text_content'];
|
||||
|
||||
$item_html_content = sek_maybe_decode_richtext($item_html_content);
|
||||
// added may 2020 related to https://github.com/presscustomizr/nimble-builder/issues/688
|
||||
$item_html_content = sek_strip_script_tags( $item_html_content );
|
||||
|
||||
// Use our own content filter instead of $content = apply_filters( 'the_content', $tiny_mce_content );
|
||||
// because of potential third party plugins corrupting 'the_content' filter. https://github.com/presscustomizr/nimble-builder/issues/233
|
||||
// added may 2020 for #699
|
||||
// 'the_nimble_tinymce_module_content' includes parsing template tags
|
||||
// Put them together
|
||||
$title_attr = esc_attr( $item['title_attr'] );
|
||||
printf( '<div class="sek-accord-item" %1$s data-sek-item-id="%2$s" data-sek-expanded="%5$s"><div id="sek-tab-title-%2$s" class="sek-accord-title" role="tab" aria-controls="sek-tab-content-%2$s"><span class="sek-inner-accord-title">%3$s</span><div class="expander"><span></span><span></span></div></div><div id="sek-tab-content-%2$s" class="sek-accord-content" role="tabpanel" aria-labelledby="sek-tab-title-%2$s">%4$s</div></div>',
|
||||
empty($title_attr) ? '' : 'title="'. esc_html($title_attr) . '"',
|
||||
esc_attr($item['id']),
|
||||
wp_kses_post(sek_maybe_decode_richtext($title)),// convert into a json to prevent emoji breaking global json data structure
|
||||
!skp_is_customizing() ? apply_filters( 'nimble_parse_for_smart_load', apply_filters( 'the_nimble_tinymce_module_content', wp_kses_post($item_html_content) )) : apply_filters( 'the_nimble_tinymce_module_content', wp_kses_post($item_html_content) ),
|
||||
( 'true' === $first_expanded && 1 === $ind ) ? "true" : "false"
|
||||
);
|
||||
$ind++;
|
||||
}//foreach
|
||||
?>
|
||||
<?php endif; ?>
|
||||
</div><?php //.sek-accord-wrapper ?>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
$model = Nimble_Manager()->model;
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
$accord_collec = !empty($value['accord_collec']) ? $value['accord_collec'] : array();
|
||||
$accord_opts = !empty($value['accord_opts']) ? $value['accord_opts'] : array();
|
||||
|
||||
if ( !empty( $accord_collec ) ) {
|
||||
sek_print_accordion( $accord_opts, $model, $accord_collec );
|
||||
sek_emit_js_event('nb-needs-accordion');
|
||||
} else {
|
||||
if ( skp_is_customizing() ) {
|
||||
printf( '<div class="sek-mod-preview-placeholder"><div class="sek-preview-ph-text" style="%2$s"><p>%1$s</p></div></div>',
|
||||
__('Click to start adding items.', 'text_doma'),
|
||||
'background: url(' . esc_url(NIMBLE_MODULE_ICON_PATH) . 'Nimble_accordion_icon.svg) no-repeat 50% 75%;background-size: 170px;'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
namespace Nimble;
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$model = Nimble_Manager()->model;
|
||||
$module_type = $model['module_type'];
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
$content_settings = $value['content'];
|
||||
$design_settings = $value['design'];
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_get_button_module_link' ) ) {
|
||||
function sek_get_button_module_link( $content_settings ) {
|
||||
$link = 'javascript:void(0);';
|
||||
// if ( skp_is_customizing() ) {
|
||||
// return $link;
|
||||
// }
|
||||
if ( 'url' == $content_settings['link-to'] ) {
|
||||
if ( !empty( $content_settings['link-pick-url'] ) && !empty( $content_settings['link-pick-url']['id'] ) ) {
|
||||
if ( '_custom_' == $content_settings['link-pick-url']['id'] && !empty( $content_settings['link-custom-url'] ) ) {
|
||||
$link = $content_settings['link-custom-url'];
|
||||
} else if ( !empty( $content_settings['link-pick-url']['url'] ) ) {
|
||||
$link = $content_settings['link-pick-url']['url'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_get_button_module_icon' ) ) {
|
||||
function sek_get_button_module_icon( $content_settings ) {
|
||||
return !empty( $content_settings[ 'icon' ] ) ? sprintf( '<i class="%1$s"></i>', esc_attr($content_settings[ 'icon' ]) ) : '';
|
||||
}
|
||||
}
|
||||
|
||||
$visual_effect_class = '';
|
||||
//visual effect classes
|
||||
if ( isset( $design_settings['use_box_shadow'] ) && true === sek_booleanize_checkbox_val( $design_settings['use_box_shadow'] ) ) {
|
||||
$visual_effect_class = ' box-shadow';
|
||||
if ( isset( $design_settings['push_effect'] ) && true === sek_booleanize_checkbox_val( $design_settings['push_effect'] ) ) {
|
||||
$visual_effect_class .= ' push-effect';
|
||||
}
|
||||
}
|
||||
|
||||
// Print
|
||||
// Feb 2021 : now saved as a json to fix emojis issues
|
||||
// see fix for https://github.com/presscustomizr/nimble-builder/issues/544
|
||||
// to ensure retrocompatibility with data previously not saved as json, we need to perform a json validity check
|
||||
$btn_text = sek_maybe_decode_richtext( $content_settings[ 'button_text'] );
|
||||
$btb_text = sek_strip_script_tags($btn_text);
|
||||
$icon_side = empty($content_settings['icon-side']) ? 'left' : $content_settings['icon-side'];
|
||||
|
||||
if ( !isset( $content_settings['link-to'] ) || isset( $content_settings['link-to'] ) && 'no-link' === $content_settings['link-to'] ) {
|
||||
printf('<button %5$s class="sek-btn%3$s"><span class="sek-btn-inner">%1$s<span class="sek-btn-text">%2$s</span>%4$s</span></button>',
|
||||
( 'left' === $icon_side && !empty( $content_settings[ 'icon' ] ) ) ? sprintf( '<i class="%1$s"></i>', esc_attr($content_settings[ 'icon' ]) ) : '',
|
||||
convert_smilies( wp_kses_post($btb_text) ),
|
||||
esc_attr($visual_effect_class),
|
||||
( 'right' === $icon_side && !empty( $content_settings[ 'icon' ] ) ) ? sprintf( '<i class="%1$s"></i>', esc_attr($content_settings[ 'icon' ]) ) : '',
|
||||
!empty($content_settings['btn_text_on_hover']) ? 'title="' . esc_html( $content_settings['btn_text_on_hover'] ) . '"' : ''
|
||||
);
|
||||
} else {
|
||||
printf('<a %7$s class="sek-btn%5$s" href="%1$s" %2$s><span class="sek-btn-inner">%3$s<span class="sek-btn-text">%4$s</span>%6$s</span></a>',
|
||||
esc_url( sek_get_button_module_link( $content_settings ) ),
|
||||
true === sek_booleanize_checkbox_val( $content_settings['link-target'] ) ? 'target="_blank" rel="noopener noreferrer"' : '',
|
||||
( 'left' === $icon_side && !empty( $content_settings[ 'icon' ] ) ) ? sprintf( '<i class="%1$s"></i>', esc_attr($content_settings[ 'icon' ]) ) : '',
|
||||
convert_smilies( wp_kses_post($btb_text) ),
|
||||
esc_attr($visual_effect_class),
|
||||
( 'right' === $icon_side && !empty( $content_settings[ 'icon' ] ) ) ? sprintf( '<i class="%1$s"></i>', esc_attr($content_settings[ 'icon' ]) ) : '',
|
||||
!empty($content_settings['btn_text_on_hover']) ? 'title="' . esc_html( $content_settings['btn_text_on_hover'] ) . '"' : ''
|
||||
);
|
||||
}
|
||||
if ( !empty(sek_get_button_module_icon( $content_settings )) ) {
|
||||
sek_emit_js_event('nb-needs-fa');
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
echo '<span class="sek-divider"></span>';
|
||||
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
namespace Nimble;
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_get_gal_img_item_html') ) {
|
||||
function sek_get_gal_img_item_html( $item, $gallery_opts ) {
|
||||
$item = is_array( $item ) ? $item : [];
|
||||
$gallery_opts = is_array( $gallery_opts ) ? $gallery_opts : [];
|
||||
$img = $item['img'];
|
||||
$img_size = array_key_exists('img_size', $gallery_opts ) ? $gallery_opts['img_size'] : 'large';
|
||||
$img_size = ( !is_null($img_size) && is_string( $img_size ) ) ? $img_size : '';
|
||||
$html = '';
|
||||
if ( is_int( $img ) ) {
|
||||
// Nov 2020 : removes any additional styles added by a theme ( Twenty Twenty one ) or a plugin to the image
|
||||
add_filter( 'wp_get_attachment_image_attributes', '\Nimble\sek_remove_image_style_attr', 999 );
|
||||
$html = wp_get_attachment_image( $img, empty( $img_size ) ? 'large' : $img_size);
|
||||
remove_filter( 'wp_get_attachment_image_attributes', '\Nimble\sek_remove_image_style_attr', 999 );
|
||||
} else if ( !empty( $img ) && is_string( $img ) ) {
|
||||
// the default img is excluded from the smart loading parsing @see nimble_regex_callback()
|
||||
// => this is needed because this image has no specific dimensions set. And therefore can create false javascript computations of other element's distance to top on page load.
|
||||
// in particular when calculting if is_visible() to decide if we smart load.
|
||||
if ( false !== wp_http_validate_url( $img ) ) {
|
||||
$html = sprintf( '<img alt="default img" data-skip-lazyload="true" src="%1$s" title="%2$s"/>',
|
||||
esc_url( $img ),
|
||||
esc_attr(sek_get_gal_img_title( $item, $gallery_opts ))
|
||||
);
|
||||
}
|
||||
} else {
|
||||
//falls back on an icon if previewing
|
||||
if ( skp_is_customizing() ) {
|
||||
$html = sprintf('<div style="min-height:50px">%1$s</div>', wp_kses_post(Nimble_Manager()->sek_get_input_placeholder_content( 'upload' )));
|
||||
}
|
||||
}
|
||||
|
||||
// Do we have something ? If not print the placeholder
|
||||
if ( empty($html) && skp_is_customizing() ) {
|
||||
$html = sprintf('<div style="min-height:50px">%1$s</div>', wp_kses_post(Nimble_Manager()->sek_get_input_placeholder_content( 'upload' )));
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_get_gal_img_link' ) ) {
|
||||
function sek_get_gal_img_link( $item, $opts ) {
|
||||
$link = 'javascript:void(0);';
|
||||
// if ( skp_is_customizing() ) {
|
||||
// return $link;
|
||||
// }
|
||||
switch( $opts['link-to'] ) {
|
||||
case 'url' :
|
||||
if ( !empty( $opts['link-pick-url'] ) && !empty( $opts['link-pick-url']['id'] ) ) {
|
||||
if ( '_custom_' == $opts['link-pick-url']['id'] && !empty( $opts['link-custom-url'] ) ) {
|
||||
$custom_url = apply_filters( 'nimble_parse_template_tags', $opts['link-custom-url'] );
|
||||
$link = $custom_url;
|
||||
} else if ( !empty( $opts['link-pick-url']['url'] ) ) {
|
||||
$link = esc_url( $opts['link-pick-url']['url'] );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'img-file' :
|
||||
case 'img-lightbox' :
|
||||
if ( is_int( $item['img'] ) ) {
|
||||
$link = wp_get_attachment_url( $item['img'] );
|
||||
}
|
||||
break;
|
||||
case 'img-page' :
|
||||
if ( is_int( $item['img'] ) ) {
|
||||
$link = get_attachment_link( $item['img'] );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_get_gal_img_title' ) ) {
|
||||
function sek_get_gal_img_title( $item, $opts ) {
|
||||
$title = '';
|
||||
$img = $item['img'];
|
||||
if ( !empty($item['custom_caption']) ) {
|
||||
$title = strip_tags( $item['custom_caption'] );
|
||||
// convert into a json to prevent emoji breaking global json data structure
|
||||
// fix for https://github.com/presscustomizr/nimble-builder/issues/544
|
||||
$title = sek_maybe_decode_richtext($title);
|
||||
} else {
|
||||
// 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
|
||||
// 'caption' => $attachment->post_excerpt,
|
||||
// 'description' => $attachment->post_content,
|
||||
// 'href' => get_permalink( $attachment->ID ),
|
||||
// 'src' => $attachment->guid,
|
||||
// 'title' => $attachment->post_title
|
||||
if ( is_int( $img ) ) {
|
||||
$img_post = get_post( $img );
|
||||
if ( !is_wp_error( $img_post ) && is_object( $img_post ) && 'attachment' === $img_post->post_type ) {
|
||||
$caption = $img_post->post_excerpt;
|
||||
$description = $img_post->post_content;
|
||||
$img_title = $img_post->post_title;
|
||||
if ( !empty( $caption ) ) {
|
||||
$title = $caption;
|
||||
} else if ( !empty( $description ) ) {
|
||||
$title = $description;
|
||||
} else if ( !empty( $img_title ) ) {
|
||||
$title = $img_title;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $title;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_print_gallery_mod' ) ) {
|
||||
function sek_print_gallery_mod( $model, $gallery_opts, $gallery_collec = array() ) {
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
$gallery_collec = is_array( $gallery_collec ) ? $gallery_collec : array();
|
||||
$gallery_opts = is_array( $gallery_opts ) ? $gallery_opts : array();
|
||||
|
||||
$is_gallery_multi_item = count( $gallery_collec ) > 1;
|
||||
|
||||
$columns_by_device = $gallery_opts['columns'];
|
||||
|
||||
$columns_by_device = is_array( $columns_by_device ) ? $columns_by_device : array();
|
||||
$columns_by_device = wp_parse_args( $columns_by_device, array(
|
||||
'desktop' => 2,
|
||||
'tablet' => '',
|
||||
'mobile' => ''
|
||||
));
|
||||
|
||||
$gal_wrapper_classes = [];
|
||||
$gal_wrapper_classes = apply_filters('nb_gal_wrapper_classes', $gal_wrapper_classes, $value );
|
||||
$gal_wrapper_classes = implode(' ', $gal_wrapper_classes );
|
||||
|
||||
$normalized_columns_by_device = array();
|
||||
|
||||
// normalizes
|
||||
foreach ( $columns_by_device as $device => $column_nb ) {
|
||||
$column_nb = (int)$column_nb;
|
||||
if ( !empty( $column_nb ) ) {
|
||||
$column_nb = $column_nb > 24 ? 24 : $column_nb;
|
||||
$column_nb = $column_nb < 1 ? 1 : $column_nb;
|
||||
}
|
||||
$normalized_columns_by_device[$device] = $column_nb;
|
||||
}
|
||||
$gal_items_classes = 'img-lightbox' === $gallery_opts['link-to'] ? ['sek-gallery-lightbox'] : [];
|
||||
foreach ( $normalized_columns_by_device as $device => $column_nb ) {
|
||||
if ( empty( $column_nb ) )
|
||||
continue;
|
||||
$gal_items_classes[] = "sek-{$device}-col-{$column_nb}";
|
||||
if ( 'desktop' === $device ) {
|
||||
$gal_items_classes[] = "sek-all-col-{$column_nb}";
|
||||
}
|
||||
}
|
||||
|
||||
$gal_items_classes = apply_filters('nb_gal_item_classes', $gal_items_classes, $value );
|
||||
$gal_items_classes = implode(' ', $gal_items_classes );
|
||||
|
||||
if ( 'img-lightbox' === $gallery_opts['link-to'] ) {
|
||||
sek_emit_js_event('nb-needs-swipebox');
|
||||
}
|
||||
// wrapper should be data-sek-gallery-id, used as 'css_selectors' on registration
|
||||
do_action( 'nb_before_post_gal_wrapper' );
|
||||
?>
|
||||
|
||||
<div class="sek-gal-wrapper <?php echo esc_attr($gal_wrapper_classes); ?>" id="<?php echo esc_attr($model['id']); ?>">
|
||||
<div class="sek-gal-items <?php echo esc_attr($gal_items_classes); ?>">
|
||||
<?php foreach ( $gallery_collec as $index => $item ) : ?>
|
||||
<figure class="sek-img-gal-item" data-sek-item-id="<?php echo esc_attr($item['id']); ?>">
|
||||
<?php
|
||||
if ( 'no-link' === $gallery_opts['link-to'] ) {
|
||||
$html = sek_get_gal_img_item_html( $item, $gallery_opts );
|
||||
echo apply_filters( 'nimble_parse_for_smart_load', wp_kses_post($html) );
|
||||
if ( !skp_is_customizing() && false !== strpos($html, 'data-sek-src="http') ) {
|
||||
echo '<div class="sek-css-loader sek-mr-loader"><div></div><div></div><div></div></div>';
|
||||
}
|
||||
} else {
|
||||
$link = sek_get_gal_img_link( $item, $gallery_opts );
|
||||
$html = sek_get_gal_img_item_html( $item, $gallery_opts );
|
||||
|
||||
printf('<a class="%4$s %5$s" href="%1$s" %2$s title="%6$s">%3$s</a>',
|
||||
esc_url($link),
|
||||
true === sek_booleanize_checkbox_val( $gallery_opts['link-target'] ) ? 'target="_blank" rel="noopener noreferrer"' : '',
|
||||
apply_filters( 'nimble_parse_for_smart_load', wp_kses_post($html) ),
|
||||
esc_attr( 'sek-gal-link-to-'.$gallery_opts['link-to'] ), // sek-gal-link-to-img-lightbox
|
||||
false === strpos($link,'http') ? 'sek-no-img-link' : 'sek-gal-img-has-link',
|
||||
esc_attr(sek_get_gal_img_title( $item, $gallery_opts ))
|
||||
);
|
||||
}
|
||||
?>
|
||||
</figure>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$model = Nimble_Manager()->model;
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
$gallery_collec = !empty($value['gallery_collec']) ? $value['gallery_collec'] : array();
|
||||
$gallery_opts = !empty($value['gallery_opts']) ? $value['gallery_opts'] : array();
|
||||
|
||||
if ( !empty( $gallery_collec ) ) {
|
||||
sek_emit_js_event('nb-needs-gallery');
|
||||
sek_print_gallery_mod( $model, $gallery_opts, $gallery_collec );
|
||||
} else {
|
||||
if ( skp_is_customizing() ) {
|
||||
printf( '<div class="sek-mod-preview-placeholder"><div class="sek-preview-ph-text" style="%2$s"><p>%1$s</p></div></div>',
|
||||
__('Click to start adding images.', 'text_doma'),
|
||||
'background: url(' . esc_url(NIMBLE_MODULE_ICON_PATH) . 'Nimble_gallery_icon.svg) no-repeat 50% 75%;background-size: 170px;'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
namespace Nimble;
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
$model = Nimble_Manager()->model;
|
||||
$module_type = $model['module_type'];
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
$value = $value['main_settings'];
|
||||
|
||||
// Utility to print the text content generated with tinyMce
|
||||
// should be wrapped in a specific selector when customizing,
|
||||
// => so we can listen to user click actions and open the editor on for each separate tiny_mce_editor input
|
||||
if ( !function_exists( 'Nimble\sek_get_text_heading_content' ) ) {
|
||||
function sek_get_text_heading_content( $heading_content, $input_id, $module_model ) {
|
||||
if ( empty( $heading_content ) ) {
|
||||
$to_print = Nimble_Manager()->sek_get_input_placeholder_content( 'text', $input_id );
|
||||
} else {
|
||||
// filter added since text editor implementation https://github.com/presscustomizr/nimble-builder/issues/403
|
||||
// Use our own content filter instead of $content = apply_filters( 'the_content', $tiny_mce_content );
|
||||
// because of potential third party plugins corrupting 'the_content' filter. https://github.com/presscustomizr/nimble-builder/issues/233
|
||||
remove_filter( 'the_nimble_tinymce_module_content', 'wpautop');
|
||||
|
||||
// Feb 2021 : now saved as a json to fix emojis issues
|
||||
// see fix for https://github.com/presscustomizr/nimble-builder/issues/544
|
||||
// to ensure retrocompatibility with data previously not saved as json, we need to perform a json validity check
|
||||
$heading_content = sek_maybe_decode_richtext($heading_content);
|
||||
|
||||
$heading_content = apply_filters( 'the_nimble_tinymce_module_content', $heading_content );
|
||||
$heading_content = sek_strip_script_tags($heading_content);
|
||||
add_filter( 'the_nimble_tinymce_module_content', 'wpautop');
|
||||
if ( skp_is_customizing() ) {
|
||||
$to_print = sprintf('<div title="%3$s" data-sek-input-type="textarea" data-sek-input-id="%1$s">%2$s</div>',
|
||||
esc_attr($input_id),
|
||||
$heading_content,
|
||||
__( 'Click to edit', 'textdomain_to_be_replaced' )
|
||||
);
|
||||
} else {
|
||||
$to_print = $heading_content;
|
||||
}
|
||||
}
|
||||
// Make sure to strip possible heading tags added as html content
|
||||
if ( is_string($to_print) ) {
|
||||
foreach (['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as $tag) {
|
||||
$to_print = preg_replace("/<\\/?" . $tag . "(.|\\s)*?>/",'', $to_print );
|
||||
}
|
||||
}
|
||||
return $to_print;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_get_heading_module_link') ) {
|
||||
function sek_get_heading_module_link( $value ) {
|
||||
$link = 'javascript:void(0);';
|
||||
// if ( skp_is_customizing() ) {
|
||||
// return $link;
|
||||
// }
|
||||
if ( true === sek_booleanize_checkbox_val( $value['link-to'] ) ) {
|
||||
if ( !empty( $value['link-pick-url'] ) && !empty( $value['link-pick-url']['id'] ) ) {
|
||||
if ( '_custom_' == $value['link-pick-url']['id'] && !empty( $value['link-custom-url'] ) ) {
|
||||
$custom_url = apply_filters( 'nimble_parse_template_tags', $value['link-custom-url'] );
|
||||
$link = $custom_url;
|
||||
} else if ( !empty( $value['link-pick-url']['url'] ) ) {
|
||||
$link = $value['link-pick-url']['url'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
}
|
||||
|
||||
// print the module content if not empty
|
||||
if ( array_key_exists('heading_text', $value ) ) {
|
||||
$tag = empty( $value[ 'heading_tag' ] ) ? 'h1' : $value[ 'heading_tag' ];
|
||||
// Feb 2021 : now saved as a json to fix emojis issues
|
||||
// see fix for https://github.com/presscustomizr/nimble-builder/issues/544
|
||||
// to ensure retrocompatibility with data previously not saved as json, we need to perform a json validity check
|
||||
$heading_title = sek_maybe_decode_richtext( empty( $value['heading_title'] ) ? '' : $value['heading_title'] );
|
||||
if ( false === sek_booleanize_checkbox_val( $value['link-to'] ) ) {
|
||||
printf( '<%1$s %3$s class="sek-heading">%2$s</%1$s>',
|
||||
esc_attr($tag),
|
||||
wp_kses_post(sek_get_text_heading_content( $value['heading_text'], 'heading_text', $model )),
|
||||
!empty( $heading_title ) ? 'title="' . esc_html( $heading_title ) . '"' : ''
|
||||
);
|
||||
} else {
|
||||
printf( '<%1$s %3$s class="sek-heading">%2$s</%1$s>',
|
||||
esc_attr($tag),
|
||||
sprintf('<a href="%1$s" %2$s>%3$s</a>',
|
||||
esc_url(sek_get_heading_module_link( $value )),
|
||||
true === sek_booleanize_checkbox_val( $value['link-target'] ) ? 'target="_blank" rel="noopener noreferrer"' : '',
|
||||
wp_kses_post(sek_get_text_heading_content( $value['heading_text'], 'heading_text', $model ))
|
||||
),
|
||||
!empty( $heading_title ) ? 'title="' . esc_html( $heading_title ) . '"' : ''
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
namespace Nimble;
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
$model = Nimble_Manager()->model;
|
||||
$module_type = $model['module_type'];
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
/* $value looks like
|
||||
Array
|
||||
(
|
||||
[icon] => fab fa-adversal
|
||||
[link-to] => url
|
||||
[link-pick-url] => Array
|
||||
(
|
||||
[id] => 3126
|
||||
[type_label] => Page
|
||||
[title] => Test foogallery
|
||||
[object_type] => page
|
||||
[url] => http://customizr-tests.wordpress.test/test-foogallery/
|
||||
)
|
||||
|
||||
[link-custom-url] =>
|
||||
[link-target] => 1
|
||||
[font_size_css] => 15
|
||||
[h_alignment_css] => right
|
||||
[color_css] => #590505
|
||||
[color_hover_css] => #590606
|
||||
)
|
||||
*/
|
||||
if ( !function_exists( 'Nimble\sek_get_icon_module_icon_html') ) {
|
||||
function sek_get_icon_module_icon_html( $value ) {
|
||||
$html = '';
|
||||
$icon_settings = $value['icon_settings'];
|
||||
$spacing_border = $value['spacing_border'];
|
||||
|
||||
if ( !empty( $icon_settings['icon'] ) ) {
|
||||
$html = sprintf( '<div class="sek-icon-wrapper"><i class="%1$s"></i></div>', esc_attr($icon_settings[ 'icon' ]) );
|
||||
} else {
|
||||
//falls back on an icon if previewing
|
||||
if ( skp_is_customizing() ) {
|
||||
$html = Nimble_Manager()->sek_get_input_placeholder_content( 'icon' );
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_get_icon_module_icon_link' ) ) {
|
||||
function sek_get_icon_module_icon_link( $icon_settings ) {
|
||||
$link = 'javascript:void(0);';
|
||||
// if ( skp_is_customizing() ) {
|
||||
// return $link;
|
||||
// }
|
||||
if ( 'url' == $icon_settings['link-to'] ) {
|
||||
if ( !empty( $icon_settings['link-pick-url'] ) && !empty( $icon_settings['link-pick-url']['id'] ) ) {
|
||||
if ( '_custom_' == $icon_settings['link-pick-url']['id'] && !empty( $icon_settings['link-custom-url'] ) ) {
|
||||
$link = $icon_settings['link-custom-url'];
|
||||
} else if ( !empty( $icon_settings['link-pick-url']['url'] ) ) {
|
||||
$link = $icon_settings['link-pick-url']['url'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
}
|
||||
|
||||
$icon_settings = $value['icon_settings'];
|
||||
$spacing_border = $value['spacing_border'];
|
||||
|
||||
$visual_effect_class = '';
|
||||
//visual effect classes
|
||||
if ( isset( $spacing_border['use_box_shadow'] ) && true === sek_booleanize_checkbox_val( $spacing_border['use_box_shadow'] ) ) {
|
||||
$visual_effect_class = 'box-shadow';
|
||||
}
|
||||
|
||||
// Print
|
||||
$icon_html = sek_get_icon_module_icon_html( $value );
|
||||
if ( 'no-link' === $icon_settings['link-to'] ) :
|
||||
printf('<div class="sek-icon %2$s">%1$s</div>',
|
||||
wp_kses_post($icon_html),
|
||||
esc_attr($visual_effect_class)
|
||||
);
|
||||
else :
|
||||
printf('<a class="sek-icon %4$s" href="%1$s" %2$s>%3$s</a>',
|
||||
esc_url(sek_get_icon_module_icon_link( $icon_settings )),
|
||||
true === sek_booleanize_checkbox_val( $icon_settings['link-target'] ) ? 'target="_blank" rel="noopener noreferrer"' : '',
|
||||
wp_kses_post($icon_html),
|
||||
esc_attr($visual_effect_class)
|
||||
);
|
||||
endif;
|
||||
if ( !empty($icon_html) ) {
|
||||
sek_emit_js_event('nb-needs-fa');
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
namespace Nimble;
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
// this.defaultItemModel = {
|
||||
// img : '',
|
||||
// 'img-size' : 'large',
|
||||
// 'alignment' : '',
|
||||
// 'link-to' : '',
|
||||
// 'link-pick-url' : '',
|
||||
// 'link-custom-url' : '',
|
||||
// 'link-target' : '',
|
||||
// 'lightbox' : true
|
||||
// };
|
||||
$model = Nimble_Manager()->model;
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
$main_settings = $value['main_settings'];
|
||||
//$borders_corners_settings = $value['borders_corners'];
|
||||
|
||||
|
||||
if ( !function_exists( 'Nimble\remove_attachment_image_style_attr' ) ) {
|
||||
function remove_attachment_image_style_attr( $attr ) {
|
||||
if ( is_array($attr) && isset($attr['style']) ) {
|
||||
unset($attr['style']);
|
||||
}
|
||||
return $attr;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_get_img_module_img_html') ) {
|
||||
function sek_get_img_module_img_html( $value, $for_mobile = false, $img = null, $img_size = null ) {
|
||||
$img = !is_null($img) ? $img : $value['img'];
|
||||
$img_size = !is_null($img_size) ? $img_size : $value['img-size'];
|
||||
$use_post_thumbnail = !empty( $value['use-post-thumb'] ) && sek_is_checked( $value['use-post-thumb'] );
|
||||
|
||||
if ( $use_post_thumbnail ) {
|
||||
$current_post_id = sek_get_post_id_on_front_and_when_customizing();
|
||||
$is_attachment = is_attachment();
|
||||
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && skp_is_customizing() ) {
|
||||
$is_attachment = sek_get_posted_query_param_when_customizing( 'is_attachment' );
|
||||
}
|
||||
if ( $is_attachment ) {
|
||||
$img = $current_post_id;
|
||||
} else {
|
||||
$img = ( has_post_thumbnail( $current_post_id ) ) ? get_post_thumbnail_id( $current_post_id ) : $img;
|
||||
}
|
||||
}
|
||||
|
||||
$img_figure_classes = '';
|
||||
//visual effect classes
|
||||
if ( true === sek_booleanize_checkbox_val( $value['use_box_shadow'] ) ) {
|
||||
$img_figure_classes = ' box-shadow';
|
||||
}
|
||||
if ( 'none' !== $value['img_hover_effect']) {
|
||||
$img_figure_classes .= " sek-hover-effect-" . $value['img_hover_effect'];
|
||||
}
|
||||
|
||||
$img_figure_classes .= $for_mobile ? " sek-is-mobile-logo" : " sek-img";
|
||||
|
||||
if ( true === sek_booleanize_checkbox_val( $value['use_custom_height'] ) ) {
|
||||
$img_figure_classes .= " has-custom-height";
|
||||
}
|
||||
|
||||
$html = '';
|
||||
if ( is_int( $img ) ) {
|
||||
// Nov 2020 : removes any additional styles added by a theme ( Twenty Twenty one ) or a plugin to the image
|
||||
add_filter( 'wp_get_attachment_image_attributes', '\Nimble\sek_remove_image_style_attr', 999 );
|
||||
$html = wp_get_attachment_image( $img, empty( $img_size ) ? 'large' : $img_size);
|
||||
remove_filter( 'wp_get_attachment_image_attributes', '\Nimble\sek_remove_image_style_attr', 999 );
|
||||
} else if ( !empty( $img ) && is_string( $img ) ) {
|
||||
// the default img is excluded from the smart loading parsing @see nimble_regex_callback()
|
||||
// => this is needed because this image has no specific dimensions set. And therefore can create false javascript computations of other element's distance to top on page load.
|
||||
// in particular when calculting if is_visible() to decide if we smart load.
|
||||
if ( false !== wp_http_validate_url( $img ) ) {
|
||||
$html = sprintf( '<img alt="default img" data-skip-lazyload="true" src="%1$s"/>', esc_url( $img ) );
|
||||
}
|
||||
} else {
|
||||
//falls back on an icon if previewing
|
||||
if ( skp_is_customizing() ) {
|
||||
$html = sprintf('<div style="min-height:50px">%1$s</div>', wp_kses_post(Nimble_Manager()->sek_get_input_placeholder_content( 'upload' )));
|
||||
}
|
||||
}
|
||||
|
||||
// Do we have something ? If not print the placeholder
|
||||
if ( empty($html) && skp_is_customizing() ) {
|
||||
$html = sprintf('<div style="min-height:50px">%1$s</div>', wp_kses_post(Nimble_Manager()->sek_get_input_placeholder_content( 'upload' )));
|
||||
}
|
||||
|
||||
$title = '';
|
||||
if ( false !== sek_booleanize_checkbox_val( $value['use_custom_title_attr']) ) {
|
||||
$title = strip_tags( $value['heading_title'] );
|
||||
// convert into a json to prevent emoji breaking global json data structure
|
||||
// fix for https://github.com/presscustomizr/nimble-builder/issues/544
|
||||
$title = sek_maybe_decode_richtext($title);
|
||||
} else {
|
||||
// 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
|
||||
// 'caption' => $attachment->post_excerpt,
|
||||
// 'description' => $attachment->post_content,
|
||||
// 'href' => get_permalink( $attachment->ID ),
|
||||
// 'src' => $attachment->guid,
|
||||
// 'title' => $attachment->post_title
|
||||
if ( is_int( $img ) ) {
|
||||
$img_post = get_post( $img );
|
||||
if ( !is_wp_error( $img_post ) && is_object( $img_post ) && 'attachment' === $img_post->post_type ) {
|
||||
$caption = $img_post->post_excerpt;
|
||||
$description = $img_post->post_content;
|
||||
$img_title = $img_post->post_title;
|
||||
if ( !empty( $caption ) ) {
|
||||
$title = $caption;
|
||||
} else if ( !empty( $description ) ) {
|
||||
$title = $description;
|
||||
} else if ( !empty( $img_title ) ) {
|
||||
$title = $img_title;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( !skp_is_customizing() && false !== strpos($html, 'data-sek-src="http') ) {
|
||||
$html = $html.Nimble_Manager()->css_loader_html;
|
||||
}
|
||||
return sprintf('<figure class="%1$s" title="%3$s">%2$s</figure>',
|
||||
esc_attr($img_figure_classes),
|
||||
$html,
|
||||
esc_html( $title )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_get_img_module_img_link' ) ) {
|
||||
function sek_get_img_module_img_link( $value ) {
|
||||
$link = 'javascript:void(0);';
|
||||
// if ( skp_is_customizing() ) {
|
||||
// return $link;
|
||||
// }
|
||||
switch( $value['link-to'] ) {
|
||||
case 'url' :
|
||||
if ( !empty( $value['link-pick-url'] ) && !empty( $value['link-pick-url']['id'] ) ) {
|
||||
if ( '_custom_' == $value['link-pick-url']['id'] && !empty( $value['link-custom-url'] ) ) {
|
||||
$custom_url = apply_filters( 'nimble_parse_template_tags', $value['link-custom-url'] );
|
||||
$link = $custom_url;
|
||||
} else if ( !empty( $value['link-pick-url']['url'] ) ) {
|
||||
$link = $value['link-pick-url']['url'];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'img-file' :
|
||||
case 'img-lightbox' :
|
||||
if ( is_int( $value['img'] ) ) {
|
||||
$link = wp_get_attachment_url( $value['img'] );
|
||||
}
|
||||
break;
|
||||
case 'img-page' :
|
||||
if ( is_int( $value['img'] ) ) {
|
||||
$link = get_attachment_link( $value['img'] );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
}
|
||||
|
||||
// Print
|
||||
if ( 'no-link' === $main_settings['link-to'] ) {
|
||||
$to_render = apply_filters('nb_img_module_html', sek_get_img_module_img_html( $main_settings ), $main_settings );
|
||||
echo apply_filters( 'nimble_parse_for_smart_load', wp_kses_post($to_render));
|
||||
} else {
|
||||
$link = sek_get_img_module_img_link( $main_settings );
|
||||
$to_render = sprintf('<a class="%4$s %5$s" href="%1$s" %2$s>%3$s</a>',
|
||||
esc_url($link),
|
||||
true === sek_booleanize_checkbox_val( $main_settings['link-target'] ) ? 'target="_blank" rel="noopener noreferrer"' : '',
|
||||
apply_filters('nb_img_module_html', sek_get_img_module_img_html( $main_settings ), $main_settings ),
|
||||
'sek-link-to-'.esc_attr($main_settings['link-to']), // sek-link-to-img-lightbox
|
||||
false === strpos($link,'http') ? 'sek-no-img-link' : ''
|
||||
);
|
||||
echo apply_filters( 'nimble_parse_for_smart_load', wp_kses_post($to_render));
|
||||
}
|
||||
if ( 'img-lightbox' === $main_settings['link-to'] ) {
|
||||
sek_emit_js_event('nb-needs-swipebox');
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
namespace Nimble;
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_slider_find_pattern_match') ) {
|
||||
function sek_slider_find_pattern_match( $matches, $item ) {
|
||||
$img_attr = '';
|
||||
if ( empty( $item ) )
|
||||
return $img_attr;
|
||||
$replace_values = array('caption', 'title', 'description');
|
||||
if ( !in_array( $matches[1], $replace_values ) )
|
||||
return $img_attr;
|
||||
|
||||
|
||||
$requested_img_attr = $matches[1];
|
||||
// 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
|
||||
// 'caption' => $attachment->post_excerpt,
|
||||
// 'description' => $attachment->post_content,
|
||||
// 'href' => get_permalink( $attachment->ID ),
|
||||
// 'src' => $attachment->guid,
|
||||
// 'title' => $attachment->post_title
|
||||
$img_post = get_post( $item['img'] );
|
||||
if ( is_int( $item['img'] ) ) {
|
||||
$img_post = get_post( $item['img'] );
|
||||
if ( !is_wp_error( $img_post ) && is_object( $img_post ) && 'attachment' === $img_post->post_type ) {
|
||||
switch( $requested_img_attr ) {
|
||||
case 'caption' :
|
||||
$img_attr = $img_post->post_excerpt;
|
||||
break;
|
||||
case 'description' :
|
||||
$img_attr = $img_post->post_content;
|
||||
break;
|
||||
case 'title' :
|
||||
$img_attr = $img_post->post_title;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $img_attr;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_slider_parse_template_tags') ) {
|
||||
// fired @filter 'nimble_parse_template_tags'
|
||||
function sek_slider_parse_template_tags( $val, $item = array() ) {
|
||||
//the pattern could also be '!\{\{(\w+)\}\}!', but adding \s? allows us to allow spaces around the term inside curly braces
|
||||
//see https://stackoverflow.com/questions/959017/php-regex-templating-find-all-occurrences-of-var#comment71815465_959026
|
||||
return is_string( $val ) ? preg_replace_callback( '!\{\{\s?(\w+)\s?\}\}!', function( $matches ) use( $item ) {
|
||||
return sek_slider_find_pattern_match( $matches, $item );
|
||||
}, $val) : $val;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( !function_exists('Nimble\sek_maybe_parse_slider_img_html_for_lazyload') ) {
|
||||
// @return html string
|
||||
function sek_maybe_parse_slider_img_html_for_lazyload( $attachment_id, $is_first_img, $lazy_load_on, $size = 'thumbnail' ) {
|
||||
// Skip when :
|
||||
// - is customizing
|
||||
// - slider lazy loading is not active
|
||||
// - global Nimble lazy load is active, and this is the first image ( in this case we want to lazy load the first image of the slider if offscreen )
|
||||
if ( skp_is_customizing() || !$lazy_load_on || ( sek_is_img_smartload_enabled() && $is_first_img ) ) {
|
||||
// Nov 2020 : removes any additional styles added by a theme ( Twenty Twenty one ) or a plugin to the image
|
||||
add_filter( 'wp_get_attachment_image_attributes', '\Nimble\sek_remove_image_style_attr', 999 );
|
||||
$img_html = wp_get_attachment_image( $attachment_id, $size );
|
||||
remove_filter( 'wp_get_attachment_image_attributes', '\Nimble\sek_remove_image_style_attr', 999 );
|
||||
return $img_html;
|
||||
}
|
||||
|
||||
// If lazy loaded, preprocess the image like wp_get_attachment_image()
|
||||
// added in dec 2019 for https://github.com/presscustomizr/nimble-builder/issues/570
|
||||
$html = '';
|
||||
$image = wp_get_attachment_image_src( $attachment_id, $size, $icon = false );
|
||||
if ( $image ) {
|
||||
list($src, $width, $height) = $image;
|
||||
$hwstring = image_hwstring( $width, $height );
|
||||
$size_class = $size;
|
||||
if ( is_array( $size_class ) ) {
|
||||
$size_class = join( 'x', $size_class );
|
||||
}
|
||||
$attachment = get_post( $attachment_id );
|
||||
$default_attr = array(
|
||||
'src' => $src,
|
||||
'class' => "attachment-$size_class size-$size_class swiper-lazy",// add swiper class for lazyloading @see https://swiperjs.com/api/#lazy
|
||||
'alt' => trim( strip_tags( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) ),
|
||||
);
|
||||
|
||||
$attr = $default_attr;
|
||||
|
||||
// Generate 'srcset' and 'sizes' if not already present.
|
||||
if ( empty( $attr['srcset'] ) ) {
|
||||
$image_meta = wp_get_attachment_metadata( $attachment_id );
|
||||
|
||||
if ( is_array( $image_meta ) ) {
|
||||
$size_array = array( absint( $width ), absint( $height ) );
|
||||
$srcset = wp_calculate_image_srcset( $size_array, $src, $image_meta, $attachment_id );
|
||||
$sizes = wp_calculate_image_sizes( $size_array, $src, $image_meta, $attachment_id );
|
||||
|
||||
if ( $srcset && ( $sizes || !empty( $attr['sizes'] ) ) ) {
|
||||
$attr['srcset'] = $srcset;
|
||||
|
||||
if ( empty( $attr['sizes'] ) ) {
|
||||
$attr['sizes'] = $sizes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the list of attachment image attributes.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param array $attr Attributes for the image markup.
|
||||
* @param WP_Post $attachment Image attachment post.
|
||||
* @param string|array $size Requested size. Image size or array of width and height values
|
||||
* (in that order). Default 'thumbnail'.
|
||||
*/
|
||||
// Nov 2020 : removes any additional styles added by a theme ( Twenty Twenty one ) or a plugin to the image
|
||||
add_filter( 'wp_get_attachment_image_attributes', '\Nimble\sek_remove_image_style_attr', 999 );
|
||||
$attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $size );
|
||||
remove_filter( 'wp_get_attachment_image_attributes', '\Nimble\sek_remove_image_style_attr', 999 );
|
||||
|
||||
// add swiper data-* stuffs for lazyloading now, after all filters
|
||||
// @see https://swiperjs.com/api/#lazy
|
||||
if ( !empty( $attr['srcset'] ) ) {
|
||||
$attr['data-srcset'] = $attr['srcset'];
|
||||
unset( $attr['srcset'] );
|
||||
}
|
||||
|
||||
// april 22 : deactivated when implementing late escape for #885 because it breaks data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
|
||||
// No idea how to escape this without breaking it for now
|
||||
// if ( !empty( $attr['src'] ) ) {
|
||||
// $attr['data-src'] = $attr['src'];
|
||||
// $attr['src'] = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
||||
// //unset( $attr['src'] );
|
||||
// }
|
||||
if ( !empty( $attr['sizes'] ) ) {
|
||||
$attr['data-sek-img-sizes'] = $attr['sizes'];
|
||||
unset( $attr['sizes'] );
|
||||
}
|
||||
|
||||
$attr = array_map( 'esc_attr', $attr );
|
||||
$html = rtrim( "<img $hwstring" );
|
||||
foreach ( $attr as $name => $value ) {
|
||||
$html .= " $name=" . '"' . $value . '"';
|
||||
}
|
||||
$html .= ' />';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_get_img_slider_module_img_html') ) {
|
||||
function sek_get_img_slider_module_img_html( $item, $lazy_load_on, $index ) {
|
||||
$html = '';
|
||||
$is_first_img = 0 == $index;
|
||||
if ( is_int( $item['img'] ) ) {
|
||||
// don't parse the first image of the carousel for lazyloading
|
||||
// @see https://github.com/presscustomizr/nimble-builder/issues/596 ( Lazy load break layout of first slide )
|
||||
// if ( $lazy_load_on && !$is_first_img ) {
|
||||
// $html = sek_maybe_parse_slider_img_html_for_lazyload(
|
||||
// $item['img'],
|
||||
// empty( $item['img-size'] ) ? 'large' : $item['img-size'],
|
||||
// $is_first_img//<= // when lazy load is active, we want to lazy load the first image of the slider if offscreen by adding 'data-sek-src' attribute
|
||||
// );
|
||||
// $html .= '<div class="swiper-lazy-preloader"></div>';//this element is removed by swiper.js once the image is loaded @see https://swiperjs.com/api/#lazy
|
||||
// } else {
|
||||
// $html = wp_get_attachment_image( $item['img'], empty( $item['img-size'] ) ? 'large' : $item['img-size']);
|
||||
// }
|
||||
|
||||
$html = sek_maybe_parse_slider_img_html_for_lazyload(
|
||||
$item['img'],
|
||||
$is_first_img,//<= // when lazy load is active, we want to lazy load the first image of the slider if offscreen by adding 'data-sek-src' attribute
|
||||
$lazy_load_on,
|
||||
empty( $item['img-size'] ) ? 'large' : $item['img-size']
|
||||
);
|
||||
if ( $lazy_load_on && !$is_first_img ) {
|
||||
$html .= '<div class="swiper-lazy-preloader"></div>';//this element is removed by swiper.js once the image is loaded @see https://swiperjs.com/api/#lazy
|
||||
}
|
||||
} else if ( !empty( $item['img'] ) && is_string( $item['img'] ) ) {
|
||||
// the default img is excluded from the Nimble Builder smart loading parsing @see nimble_regex_callback()
|
||||
// => this is needed because this image has no specific dimensions set. And therefore can create false javascript computations of other element's distance to top on page load.
|
||||
// in particular when calculting if is_visible() to decide if we smart load.
|
||||
$html = sprintf( '<img alt="default img" data-skip-lazyload="true" src="%1$s"/>', esc_url( $item['img'] ) );
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_print_img_slider' ) ) {
|
||||
function sek_print_img_slider( $img_collection, $slider_options, $model ) {
|
||||
$img_collection = is_array( $img_collection ) ? $img_collection : array();
|
||||
$is_multislide = count( $img_collection ) > 1;
|
||||
$autoplay = ( !skp_is_customizing() && true === sek_booleanize_checkbox_val( $slider_options['autoplay'] ) ) ? "true" : "false";
|
||||
// don't authorize value < 300 ms
|
||||
$autoplay_delay = intval( $slider_options['autoplay_delay'] ) < 300 ? 1000 : intval( $slider_options['autoplay_delay'] );
|
||||
$pause_on_hover = true === sek_booleanize_checkbox_val( $slider_options['pause_on_hover'] ) ? "true" : "false";
|
||||
$loop_on = true === sek_booleanize_checkbox_val( $slider_options['infinite_loop'] ) ? "true" : "false";
|
||||
$lazy_load_on = true === sek_booleanize_checkbox_val( $slider_options['lazy_load'] ) ? "true" : "false";
|
||||
$nav_type = ( is_string( $slider_options['nav_type'] ) && !empty( $slider_options['nav_type'] ) ) ? esc_attr($slider_options['nav_type']) : 'arrows_dots';
|
||||
$hide_nav_on_mobiles = true === sek_booleanize_checkbox_val( $slider_options['hide_nav_on_mobiles'] );
|
||||
?>
|
||||
<?php printf('<div class="swiper sek-swiper-loading sek-swiper%1$s" data-sek-swiper-id="%1$s" data-sek-autoplay="%2$s" data-sek-autoplay-delay="%3$s" data-sek-pause-on-hover="%4$s" data-sek-loop="%5$s" data-sek-image-layout="%6$s" data-sek-navtype="%7$s" data-sek-is-multislide="%8$s" data-sek-hide-nav-on-mobile="%9$s" data-sek-lazyload="%10$s" %11$s>',
|
||||
esc_attr($model['id']),
|
||||
esc_attr($autoplay),
|
||||
esc_attr($autoplay_delay),
|
||||
esc_attr($pause_on_hover),
|
||||
esc_attr($loop_on),
|
||||
esc_attr($slider_options['image-layout']),
|
||||
esc_attr($nav_type),
|
||||
$is_multislide ? 'true' : 'false',
|
||||
$hide_nav_on_mobiles ? 'true' : 'false',
|
||||
esc_attr($lazy_load_on),
|
||||
wp_kses_post(apply_filters('nb_slider_wrapper_custom_attributes', '', $slider_options, $model ))
|
||||
); ?>
|
||||
<?php if ( is_array( $img_collection ) && count( $img_collection ) > 0 ) : ?>
|
||||
<div class="swiper-wrapper">
|
||||
<?php
|
||||
foreach( $img_collection as $index => $item ) {
|
||||
$is_text_enabled = true === sek_booleanize_checkbox_val( $item['enable_text'] );
|
||||
$text_content = $is_text_enabled ? $item['text_content'] : '';
|
||||
$has_text_content = !empty( $text_content );
|
||||
|
||||
// Feb 2021 : now saved as a json to fix emojis issues
|
||||
// see fix for https://github.com/presscustomizr/nimble-builder/issues/544
|
||||
// to ensure retrocompatibility with data previously not saved as json, we need to perform a json validity check
|
||||
$text_content = sek_maybe_decode_richtext( $text_content );
|
||||
$text_content = sek_strip_script_tags( $text_content );
|
||||
$text_html = sprintf('<div class="sek-slider-text-wrapper"><div class="sek-slider-text-content">%1$s</div></div>', $text_content );
|
||||
if ( !skp_is_customizing() ) {
|
||||
$text_html = !$has_text_content ? '' : $text_html;
|
||||
}
|
||||
|
||||
$has_overlay = true === sek_booleanize_checkbox_val( $item['apply-overlay'] );
|
||||
|
||||
// Put them together
|
||||
$to_render = sprintf( '<div class="swiper-slide" title="%1$s" data-sek-item-id="%4$s" data-sek-has-overlay="%5$s" %6$s><figure class="sek-carousel-img">%2$s</figure>%3$s</div>',
|
||||
sek_slider_parse_template_tags( strip_tags( esc_attr( $item['title_attr'] ) ), $item ),
|
||||
sek_get_img_slider_module_img_html( $item, "true" === $lazy_load_on, $index ),
|
||||
sek_slider_parse_template_tags( $text_html, $item ),
|
||||
esc_attr($item['id']),
|
||||
true === sek_booleanize_checkbox_val( $has_overlay ) ? 'true' : 'false',
|
||||
esc_attr( apply_filters('nb_single_slide_custom_attributes', '', $item, $model ) )
|
||||
);
|
||||
echo skp_is_customizing() ? wp_kses_post($to_render) : apply_filters( 'nimble_parse_for_smart_load', wp_kses_post($to_render) );
|
||||
|
||||
}//foreach
|
||||
?>
|
||||
</div><?php //.swiper-wrapper ?>
|
||||
<?php endif; ?>
|
||||
<?php if ( in_array($nav_type,array('arrows_dots', 'dots') ) && $is_multislide ) : ?>
|
||||
<div class="swiper-pagination swiper-pagination<?php echo esc_attr($model['id']); ?>"></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( in_array($nav_type,array('arrows_dots', 'arrows') ) && $is_multislide ) : ?>
|
||||
<div class="sek-swiper-nav">
|
||||
<div class="sek-swiper-arrows sek-swiper-prev sek-swiper-prev<?php echo esc_attr($model['id']); ?>" title="<?php _e('previous', 'textdom'); ?>"><div class="sek-chevron"></div></div>
|
||||
<div class="sek-swiper-arrows sek-swiper-next sek-swiper-next<?php echo esc_attr($model['id']); ?>" title="<?php _e('next', 'textdom'); ?>"><div class="sek-chevron"></div></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
if ( !skp_is_customizing() ) {
|
||||
echo '<div class="sek-css-loader sek-mr-loader"><div></div><div></div><div></div></div>';
|
||||
}
|
||||
?>
|
||||
</div><?php //.swiper ?>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
$model = Nimble_Manager()->model;
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
$img_collection = !empty($value['img_collection']) ? $value['img_collection'] : array();
|
||||
$slider_options = !empty($value['slider_options']) ? $value['slider_options'] : array();
|
||||
|
||||
if ( !empty( $img_collection ) ) {
|
||||
sek_print_img_slider( $img_collection, $slider_options, $model );
|
||||
sek_emit_js_event('nb-needs-swiper');
|
||||
} else {
|
||||
if ( skp_is_customizing() ) {
|
||||
printf( '<div class="sek-mod-preview-placeholder"><div class="sek-preview-ph-text" style="%2$s"><p>%1$s</p></div></div>',
|
||||
__('Click to start adding images.', 'text_doma'),
|
||||
'background: url(' . esc_url(NIMBLE_MODULE_ICON_PATH) . 'Nimble_slideshow_icon.svg) no-repeat 50% 75%;background-size: 200px;'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
namespace Nimble;
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
$model = Nimble_Manager()->model;
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
|
||||
|
||||
if ( empty( $value['address'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 0 === absint( $value['zoom'] ) ) {
|
||||
$value['zoom'] = 10;
|
||||
}
|
||||
|
||||
printf(
|
||||
'<div class="sek-embed"><iframe style="border:none;overflow:hidden" marginheight="0" marginwidth="0" %s="https://maps.google.com/maps?q=%s&t=m&z=%d&output=embed&iwloc=near" aria-label="%s"></iframe></div>',
|
||||
( !skp_is_customizing() && true === sek_booleanize_checkbox_val( $value['lazyload'] ) ) ? 'data-sek-iframe-src' : 'src',
|
||||
rawurlencode( $value['address'] ),
|
||||
absint( $value['zoom'] ),
|
||||
esc_attr( $value['address'] )
|
||||
);
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
namespace Nimble;
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
$model = Nimble_Manager()->model;
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
$menu_content = $value['content'];
|
||||
$mobile_options = $value['mobile_options'];
|
||||
//test
|
||||
$sek_nav_collapse_additional_classes = 'sek-submenu-fade sek-submenu-move';
|
||||
$expand_below = true === sek_booleanize_checkbox_val( $mobile_options['expand_below'] ) ? 'yes' : 'no';
|
||||
|
||||
// June 2020 => nav classes filter added for https://github.com/presscustomizr/nimble-builder-pro/issues/12
|
||||
$nav_classes = apply_filters( 'nb_nav_menu_classes', array( 'sek-nav-wrap' ), $model );
|
||||
if ( is_array( $nav_classes ) ) {
|
||||
$nav_classes = implode(' ', $nav_classes );
|
||||
}
|
||||
$nav_classes = is_string($nav_classes) ? $nav_classes : 'sek-nav-wrap';
|
||||
sek_emit_js_event('nb-needs-menu-js');
|
||||
?>
|
||||
|
||||
<?php do_action('nb_menu_module_before_nav', $model ); ?>
|
||||
<?php
|
||||
// janv 2021 => added data-sek-mobile-menu-breakpoint attribute which is hard coded to min-width:768px for the moment
|
||||
// in the future, this value could be set by users, see $grid-breakpoints in scss variables
|
||||
?>
|
||||
<nav class="<?php echo esc_attr($nav_classes); ?>" data-sek-expand-below="<?php echo esc_attr($expand_below); ?>" data-sek-mobile-menu-breakpoint=768>
|
||||
<button class="sek-nav-toggler sek-collapsed" type="button" data-target="#<?php echo esc_attr($model['id']); ?>" aria-controls="<?php echo esc_attr($model['id']); ?>" aria-expanded="false" aria-label="<?php esc_attr_e( 'Toggle navigation', 'textdomain_to_be_replaced' ) ?>">
|
||||
<span class="sek-ham__span-wrapper">
|
||||
<span class="line line-1"></span>
|
||||
<span class="line line-2"></span>
|
||||
<span class="line line-3"></span>
|
||||
</span>
|
||||
</button>
|
||||
<?php
|
||||
// WHY DO WE ADD this inline style display:none ?
|
||||
// in the stylesheet, .sek-nav-collapse {display: flex!important;} => This hack allows us to prevent a Content Layout Shift on page load
|
||||
?>
|
||||
<div class="sek-nav-collapse <?php echo esc_attr($sek_nav_collapse_additional_classes); ?>" id="<?php echo esc_attr($model['id']); ?>" data-sek-mm-state="collapsed" style="display:none">
|
||||
<?php
|
||||
// june 2020 : filter menu classes => added for https://github.com/presscustomizr/nimble-builder-pro/issues/9
|
||||
$menu_classes = apply_filters( 'nb_wp_menu_classes', array( 'sek-menu-module', 'sek-nav' ), $model );
|
||||
if ( is_array( $menu_classes ) ) {
|
||||
$menu_classes = implode(' ', $menu_classes );
|
||||
}
|
||||
$menu_classes = is_string($menu_classes) ? $menu_classes : 'sek-menu-module sek-nav';
|
||||
|
||||
do_action('nb_menu_module_before_wp_menu', $model );
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- *
|
||||
* PRINT THE MENU + prevent running a filter used in twenty twenty one ( nov 2020 )
|
||||
/* ------------------------------------------------------------------------- */
|
||||
// Twenty Twenty One filters 'walker_nav_menu_start_el' and adds a button
|
||||
// see https://github.com/WordPress/twentytwentyone/blob/trunk/inc/menu-functions.php
|
||||
global $wp_filter;
|
||||
$menu_wp_hook = null;
|
||||
// Remove and cache the filter
|
||||
if ( isset( $wp_filter[ 'walker_nav_menu_start_el' ] ) && is_object($wp_filter[ 'walker_nav_menu_start_el' ] ) ) {
|
||||
$menu_wp_hook = $wp_filter[ 'walker_nav_menu_start_el' ];
|
||||
unset( $wp_filter[ 'walker_nav_menu_start_el' ] );
|
||||
}
|
||||
//error_log( print_r( get_terms( 'nav_menu', array( 'hide_empty' => true ) ), true) );
|
||||
wp_nav_menu(
|
||||
array(
|
||||
'theme_location' => '__nimble__',//<= if no theme location is specified, WP assigns the first non empty one available (see wp-includes/nav-menu-template.php:106, the comment reads: // get the first menu that has items if we still can't find a menu ) which we don't want.
|
||||
'menu' => empty( $menu_content['menu-id'] ) ? '' : $menu_content['menu-id'],// Ex : 'top-menu',//(int|string|WP_Term) Desired menu. Accepts a menu ID, slug, name, or object.
|
||||
'menu_class' => $menu_classes,//CSS class to use for the ul element which forms the menu. Default 'menu'.
|
||||
'container' => '',//Whether to wrap the ul, and what to wrap it with. Default 'div'.
|
||||
'menu_id' => '',//The ID that is applied to the ul element which forms the menu. Default is the menu slug, incremented.
|
||||
'fallback_cb' => '\Nimble\sek_page_menu_fallback',//(callable|bool) If the menu doesn't exists, a callback function will fire. Default is 'wp_page_menu'. Set to false for no fallback.
|
||||
'link_before' => '<span class="sek-nav__title">',
|
||||
'link_after' => '</span>'
|
||||
)
|
||||
);
|
||||
|
||||
// Add back the filter
|
||||
if ( is_object($menu_wp_hook) ) {
|
||||
$wp_filter[ 'walker_nav_menu_start_el' ] = $menu_wp_hook;
|
||||
}
|
||||
|
||||
?>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -0,0 +1,583 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
namespace Nimble;
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
$model = Nimble_Manager()->model;
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
$main_settings = $value['grid_main'];
|
||||
$metas_settings = $value['grid_metas'];
|
||||
$thumb_settings = $value['grid_thumb'];
|
||||
|
||||
// filter for 'get_pagenum_link' and 'paginate_links'
|
||||
// for https://github.com/presscustomizr/nimble-builder/issues/672
|
||||
// June 2020 updated for https://github.com/presscustomizr/nimble-builder/issues/716
|
||||
if ( !function_exists( 'Nimble\sek_filter_pagination_nav_url') ) {
|
||||
function sek_filter_pagination_nav_url( $result ) {
|
||||
$url = add_query_arg(
|
||||
array('nb_grid_module_go_to' => Nimble_Manager()->model['id'] ),
|
||||
$result
|
||||
);
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The template for displaying the pagination links
|
||||
*/
|
||||
if ( !function_exists( 'Nimble\sek_render_post_navigation') ) {
|
||||
function sek_render_post_navigation( $post_query ) {
|
||||
$next_dir = is_rtl() ? 'right' : 'left';
|
||||
$prev_dir = is_rtl() ? 'left' : 'right';
|
||||
$tnext_align_class = "sek-text-{$next_dir}";
|
||||
$tprev_align_class = "sek-text-{$prev_dir}";
|
||||
$_older_label = __( 'Older' , 'text_doma' );
|
||||
$_newer_label = __( 'Newer' , 'text_doma' );
|
||||
|
||||
// filter to add nimble module id ( ex : #__nimble__b4b942df40e5 ) at the end of the url so we focus on grid when navigating pagination
|
||||
add_filter('get_pagenum_link', 'Nimble\sek_filter_pagination_nav_url' );
|
||||
/* Generate links */
|
||||
$prev_link = get_next_posts_link(
|
||||
'<span class="sek-meta-nav"><span class="sek-meta-nav-title">' . $_older_label . '</span></span>', //label
|
||||
$post_query->max_num_pages //max pages
|
||||
);
|
||||
|
||||
$next_link = get_previous_posts_link(
|
||||
'<span class="sek-meta-nav"><span class="sek-meta-nav-title">' . $_newer_label . '</span></span>', //label
|
||||
$post_query->max_num_pages //max pages
|
||||
);
|
||||
remove_filter('get_pagenum_link', 'Nimble\sek_filter_pagination_nav_url' );
|
||||
|
||||
/* If no links are present do not display this */
|
||||
if ( null != $prev_link || null != $next_link ) :
|
||||
|
||||
?>
|
||||
<div class="sek-row sek-post-navigation">
|
||||
<nav id="sek-nav-below" class="sek-col-100">
|
||||
<h2 class="sek-screen-reader-text"><?php _e('Posts navigation', 'text_doma') ?></h2>
|
||||
<ul class="sek-czr-pager sek-row">
|
||||
<li class="sek-next-posts sek-col-base sek-col-33 <?php echo esc_attr($tnext_align_class); ?> ">
|
||||
<?php if ( null != $next_link ) : ?>
|
||||
<span class="sek-screen-reader-text"><?php echo wp_kses_post($_newer_label); ?></span>
|
||||
<span class="sek-nav-next sek-nav-dir"><?php echo wp_kses_post($next_link); ?></span>
|
||||
<?php endif ?>
|
||||
</li>
|
||||
<li class="sek-pagination sek-col-base sek-col-33">
|
||||
<ul class="sek-pag-list">
|
||||
<?php
|
||||
// April 2020 : fixes pagination not working on a static page used as front page
|
||||
// see https://github.com/presscustomizr/nimble-builder/issues/664
|
||||
// https://developer.wordpress.org/reference/classes/wp_query/#pagination-parameters
|
||||
$pagination_query_var = Nimble_Manager()->is_viewing_static_front_page ? 'page' :'paged';
|
||||
$paged = get_query_var($pagination_query_var);
|
||||
$paged = $paged ? $paged : 1;
|
||||
$model = Nimble_Manager()->model;
|
||||
$is_nimble_pagination = isset($_GET['nb_grid_module_go_to']);
|
||||
$is_current_grid_paginated = $is_nimble_pagination && $model['id'] === sanitize_text_field($_GET['nb_grid_module_go_to']);
|
||||
// When user clicked on a pagination link, NB adds query params to the url ( removed via js once the page is loaded )
|
||||
// in this case, if there are several grids printed on the page we want to paginate only the paginated one
|
||||
// otherwise, if the pagination is accessed directly, or if the page is refreshed, all grids should be paginated according to the get_query_var($pagination_query_var) param
|
||||
if ( $is_nimble_pagination ) {
|
||||
$paged = $is_current_grid_paginated ? $paged : 1;
|
||||
}
|
||||
|
||||
// filter to add nimble module id ( ex : #__nimble__b4b942df40e5 ) at the end of the url so we focus on grid when navigating pagination
|
||||
add_filter('paginate_links', 'Nimble\sek_filter_pagination_nav_url' );
|
||||
$_paginate_links = paginate_links( array(
|
||||
'prev_next' => false,
|
||||
'mid_size' => 1,
|
||||
'type' => 'array',
|
||||
'current' => max( 1, $paged ),
|
||||
'total' => $post_query->max_num_pages
|
||||
));
|
||||
remove_filter('paginate_links', 'Nimble\sek_filter_pagination_nav_url' );
|
||||
|
||||
if ( is_array( $_paginate_links ) ) {
|
||||
foreach ( $_paginate_links as $_page ) {
|
||||
echo wp_kses_post("<li class='sek-paginat-item'>$_page</li>");
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="sek-previous-posts sek-col-base sek-col-33 <?php echo esc_attr($tprev_align_class); ?>">
|
||||
<?php if ( null != $prev_link ) : ?>
|
||||
<span class="sek-screen-reader-text"><?php echo wp_kses_post($_older_label); ?></span>
|
||||
<span class="sek-nav-previous sek-nav-dir"><?php echo wp_kses_post($prev_link); ?></span>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<?php endif;
|
||||
}
|
||||
}//sek_render_post_navigation
|
||||
|
||||
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_render_post') ) {
|
||||
function sek_render_post( $main_settings, $metas_settings, $thumb_settings ) {
|
||||
global $post;
|
||||
|
||||
if ( is_object($post) && isset($post->ID) ) {
|
||||
$post_id = $post->ID;
|
||||
} else {
|
||||
$post_id = $post;
|
||||
}
|
||||
// thumb, title, excerpt visibility
|
||||
foreach ( ['thumb'] as $element ) {
|
||||
${'show_' . $element} = sek_booleanize_checkbox_val( $thumb_settings["show_{$element}"] );
|
||||
}
|
||||
foreach ( ['title', 'excerpt'] as $element ) {
|
||||
${'show_' . $element} = sek_booleanize_checkbox_val( $main_settings["show_{$element}"] );
|
||||
}
|
||||
// meta visibility
|
||||
foreach ( ['cats', 'comments', 'author', 'date'] as $meta) {
|
||||
${'show_' . $meta} = sek_booleanize_checkbox_val( $metas_settings["show_{$meta}"] );
|
||||
}
|
||||
$has_post_thumbnail = has_post_thumbnail();
|
||||
$use_post_thumb_placeholder = true === sek_booleanize_checkbox_val( $thumb_settings['use_post_thumb_placeholder'] );
|
||||
$post_thumb_class = ( $show_thumb && ( $has_post_thumbnail || $use_post_thumb_placeholder ) ) ? 'sek-has-thumb' : '';
|
||||
$post_classes = array( $post_thumb_class );// get_post_class( $post_thumb_class, $post_id );
|
||||
// note : not using WP generated post classes to avoid collision with theme styles often using those CSS classes to style posts
|
||||
?>
|
||||
<article id="sek-pg-<?php the_ID(); ?>" class="<?php echo esc_attr( implode( ' ', $post_classes ) ); ?>">
|
||||
<?php if ( $show_thumb && ( $has_post_thumbnail || $use_post_thumb_placeholder ) ) : ?>
|
||||
<figure class="sek-pg-thumbnail">
|
||||
<?php // when title is not displayed, print it as an attribute of the image ?>
|
||||
<?php if ( $show_title ) : ?>
|
||||
<a href="<?php the_permalink(); ?>">
|
||||
<?php else : ?>
|
||||
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
if( $has_post_thumbnail ) {
|
||||
// Nov 2020 : removes any additional styles added by a theme ( Twenty Twenty one ) or a plugin to the image
|
||||
add_filter( 'wp_get_attachment_image_attributes', '\Nimble\sek_remove_image_style_attr', 999 );
|
||||
$img_html = wp_get_attachment_image( get_post_thumbnail_id(), empty( $thumb_settings['img_size'] ) ? 'medium' : $thumb_settings['img_size']);
|
||||
remove_filter( 'wp_get_attachment_image_attributes', '\Nimble\sek_remove_image_style_attr', 999 );
|
||||
|
||||
if ( !skp_is_customizing() && false !== strpos($img_html, 'data-sek-src="http') ) {
|
||||
$img_html = $img_html.Nimble_Manager()->css_loader_html;
|
||||
}
|
||||
if ( !skp_is_customizing() ) {
|
||||
// april 2020 : when customizing, smart load randomly breaks when refreshing the grids
|
||||
// so let's apply smart load only on front for now
|
||||
echo apply_filters( 'nimble_parse_for_smart_load', wp_kses_post($img_html) );
|
||||
} else {
|
||||
echo wp_kses_post($img_html);
|
||||
}
|
||||
} else if ( $use_post_thumb_placeholder ) {
|
||||
echo apply_filters( 'nimble_post_grid_module_default_featured_image', sprintf( '<img alt="default img" class="no-lazy" data-skip-lazyload="true" src="%1$s"/>', esc_url(NIMBLE_BASE_URL . '/assets/img/default-img.png' ) ) );
|
||||
}
|
||||
?>
|
||||
</a>
|
||||
</figure>
|
||||
<?php endif; ?>
|
||||
<?php if ( $show_cats || $show_title || $show_author || $show_date || $show_comments || $show_excerpt ) : ?>
|
||||
<div class="sek-pg-content">
|
||||
<?php if ( $show_cats ) : ?>
|
||||
<div class="sek-pg-category"><?php the_category(' / '); ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ( $show_title ) : ?>
|
||||
<h2 class="sek-pg-title">
|
||||
<a href="<?php the_permalink(); ?>" rel="bookmark"><?php echo get_the_title($post_id); ?></a>
|
||||
</h2><!--/.pg-title-->
|
||||
<?php endif; ?>
|
||||
<?php if ( $show_author || $show_date || $show_comments ) : ?>
|
||||
<aside class="sek-pg-metas">
|
||||
<?php if ( $show_author ) : ?>
|
||||
<span><?php the_author_posts_link(); ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if ( $show_date ) : ?>
|
||||
<span class="published updated"><?php echo get_the_date( get_option('date_format') ); ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if ( $show_comments ) : ?>
|
||||
<span><?php comments_number( __('0 comments', 'text_doma'), __('1 comment', 'text_doma'), __('% comments', 'text_doma') ); ?></span>
|
||||
<?php endif; ?>
|
||||
</aside><!--/.pg-meta-->
|
||||
<?php endif; ?>
|
||||
<?php if ( $show_excerpt ) : ?>
|
||||
<div class="sek-excerpt">
|
||||
<?php
|
||||
// note : using add_filter( 'excerpt_length' ) do not work when using a custom excerpt
|
||||
// code inspired from WP core formatting.php
|
||||
?>
|
||||
<?php echo apply_filters( 'the_excerpt', wp_trim_words( get_the_excerpt(), sek_pg_get_excerpt_length( 55 ), ' ' . '[…]' ) ); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div><?php //.sek-pg-content ?>
|
||||
<?php endif; ?>
|
||||
</article><!--/#sek-pg-->
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// // Solves the problem of setting both the maximum number of posts and the posts_per_page in a custom WP_Query
|
||||
// // Filter is added and removed before and after the query call
|
||||
// if ( !function_exists( 'Nimble\sek_filter_found_posts') ) {
|
||||
// function sek_filter_found_posts() {
|
||||
// $model = Nimble_Manager()->model;
|
||||
// $value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
// $main_settings = $value['grid_main'];
|
||||
// $post_nb = (int)$main_settings['post_number'];
|
||||
// $post_nb = $post_nb < 0 ? 0 : $post_nb;
|
||||
// return $post_nb;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// filters @hook 'excerpt_length'
|
||||
if ( !function_exists( 'Nimble\sek_pg_get_excerpt_length') ) {
|
||||
function sek_pg_get_excerpt_length( $original_length ) {
|
||||
$model = Nimble_Manager()->model;
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
$main_settings = $value['grid_main'];
|
||||
$_custom = (int)$main_settings['excerpt_length'];
|
||||
$_custom = $_custom < 1 ? 1 : $_custom;
|
||||
|
||||
return !is_numeric($_custom) ? $original_length : $_custom;
|
||||
}
|
||||
}
|
||||
|
||||
$user_selected_cat_slugs = $main_settings['categories'];
|
||||
$must_have_all_cats = sek_booleanize_checkbox_val( $main_settings['must_have_all_cats'] );
|
||||
|
||||
// October 2019
|
||||
// To solve the problem of children cats being displayed when picking the parent, we introduced 'category__in' Query param
|
||||
// But we need to keep the "category_name" param when user checks "must have all cats" option because 'category__in' does not allow to do a + statement
|
||||
// @see https://developer.wordpress.org/reference/classes/wp_query/#category-parameters
|
||||
$category_names = null;
|
||||
$categories_in = null;
|
||||
|
||||
$categories_id_raw = [];
|
||||
foreach ($user_selected_cat_slugs as $cat_slug ) {
|
||||
$cat_object = get_category_by_slug( $cat_slug );
|
||||
if ( is_object($cat_object) ) {
|
||||
$categories_id_raw[] = $cat_object->term_id;
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_array( $user_selected_cat_slugs ) ) {
|
||||
if ( count( $user_selected_cat_slugs ) > 1 ) {
|
||||
if ( $must_have_all_cats ) {
|
||||
// https://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters
|
||||
$category_names = implode( '+', $user_selected_cat_slugs );
|
||||
} else {
|
||||
$categories_in = $categories_id_raw;
|
||||
}
|
||||
} else {
|
||||
// https://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters
|
||||
$categories_in = $categories_id_raw;
|
||||
}
|
||||
}//is_array( $main_settings['categories'] )
|
||||
|
||||
|
||||
|
||||
$order = 'DESC';
|
||||
$orderby = 'title';
|
||||
|
||||
if ( !empty( $main_settings['order_by'] ) && is_string( $main_settings['order_by'] ) ) {
|
||||
$order_params = explode('_', $main_settings['order_by'] );
|
||||
// 'date_desc' will give orderby = date and order = DESC
|
||||
if ( is_array( $order_params ) && 2 === count($order_params) ) {
|
||||
$order = strtoupper( $order_params[1] );
|
||||
$orderby = $order_params[0];
|
||||
}
|
||||
}
|
||||
|
||||
$post_nb = (int)$main_settings['post_number'];
|
||||
$post_nb = $post_nb < 0 ? 0 : $post_nb;
|
||||
$query_params = $default_query_params = [
|
||||
'no_found_rows' => false,
|
||||
'update_post_meta_cache' => false,
|
||||
'update_post_term_cache' => false,
|
||||
'ignore_sticky_posts' => 1,
|
||||
'post_status' => 'publish',// because otherwise 'draft' posts are showing up. (wp bug) fixes https://github.com/presscustomizr/nimble-builder/issues/466
|
||||
'posts_per_page' => $post_nb,
|
||||
//@see https://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters
|
||||
'category_name' => $category_names,
|
||||
'category__in' => $categories_in,
|
||||
'order' => $order,
|
||||
'orderby' => $orderby,
|
||||
// may 2020 : querying ids is enough and much more performant on large queries
|
||||
// @see : https://pluginrepublic.com/how-to-handle-large-queries-in-wordpress/
|
||||
'fields' => 'ids'
|
||||
];
|
||||
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_maybe_add_sticky_posts_to_query') ) {
|
||||
// inspired from WP core way to add sticky posts. @see class WP_Query
|
||||
function sek_maybe_add_sticky_posts_to_query( $query, $query_params, $paged ) {
|
||||
// Put sticky posts at the top of the posts array.
|
||||
$sticky_posts = get_option( 'sticky_posts' );
|
||||
if ( $paged <= 1 && is_array( $sticky_posts ) && ! empty( $sticky_posts ) && ! $query_params['ignore_sticky_posts'] ) {
|
||||
$num_posts = count( $query->posts );
|
||||
$sticky_offset = 0;
|
||||
// Loop over posts and relocate stickies to the front.
|
||||
for ( $i = 0; $i < $num_posts; $i++ ) {
|
||||
if ( in_array( $query->posts[ $i ], $sticky_posts, true ) ) {
|
||||
$sticky_post = $query->posts[ $i ];
|
||||
// Remove sticky from current position.
|
||||
array_splice( $query->posts, $i, 1 );
|
||||
// Move to front, after other stickies.
|
||||
array_splice( $query->posts, $sticky_offset, 0, array( $sticky_post ) );
|
||||
// Increment the sticky offset. The next sticky will be placed at this offset.
|
||||
$sticky_offset++;
|
||||
// Remove post from sticky posts array.
|
||||
$offset = array_search( $sticky_post, $sticky_posts, true );
|
||||
unset( $sticky_posts[ $offset ] );
|
||||
}
|
||||
}
|
||||
|
||||
// If any posts have been excluded specifically, Ignore those that are sticky.
|
||||
if ( ! empty( $sticky_posts ) && ! empty( $query_params['post__not_in'] ) ) {
|
||||
$sticky_posts = array_diff( $sticky_posts, $query_params['post__not_in'] );
|
||||
}
|
||||
|
||||
$post_type = ( array_key_exists('post_type', $query_params ) && !empty($query_params['post_type'] ) ) ? $query_params['post_type'] : 'post';
|
||||
// Fetch sticky posts that weren't in the query results.
|
||||
if ( ! empty( $sticky_posts ) ) {
|
||||
$stickies = get_posts(
|
||||
array(
|
||||
'post__in' => $sticky_posts,
|
||||
'post_type' => $post_type,
|
||||
'post_status' => 'publish',
|
||||
'nopaging' => true,
|
||||
)
|
||||
);
|
||||
|
||||
foreach ( $stickies as $sticky_post ) {
|
||||
array_splice( $query->posts, $sticky_offset, 0, array( $sticky_post ) );
|
||||
$sticky_offset++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
||||
$use_current_query = array_key_exists('use_current_query', $main_settings ) && sek_booleanize_checkbox_val($main_settings['use_current_query']);
|
||||
$replace_current_query = true;// when user checks use_current_query, $replace_current_query is set to false
|
||||
|
||||
// Shall NB use current WP query ?
|
||||
if ( $use_current_query ) {
|
||||
if ( skp_is_customizing() && defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
||||
$query_params = sek_get_posted_query_param_when_customizing('query_vars');
|
||||
$query_params['post_status'] = 'publish';// because otherwise 'draft' posts are showing up. (wp bug) fixes https://github.com/presscustomizr/nimble-builder/issues/466
|
||||
} else {
|
||||
global $wp_query;
|
||||
$query_params = $wp_query->query_vars;
|
||||
}
|
||||
// make sure we didn't lose the query params at this point.
|
||||
$query_params = is_array($query_params) ? $query_params : $default_query_params;
|
||||
|
||||
// When using the current query, NB uses normally only WP query vars. Unless user checks 'replace_query' option.
|
||||
$replace_current_query = array_key_exists('replace_query', $main_settings ) && sek_booleanize_checkbox_val($main_settings['replace_query']);
|
||||
if ( $replace_current_query ) {
|
||||
$query_params['posts_per_page'] = $post_nb;
|
||||
$query_params['orderby'] = $orderby;
|
||||
$query_params['order'] = $order;
|
||||
}
|
||||
}
|
||||
|
||||
$paged = 1;
|
||||
$is_nimble_pagination_on = isset($_GET['nb_grid_module_go_to']);
|
||||
$is_current_grid_paginated = isset($_GET['nb_grid_module_go_to']) && $model['id'] === sanitize_text_field($_GET['nb_grid_module_go_to']);
|
||||
// may 2020 => is_front_page() was wrong to check if home was a static front page.
|
||||
// fixes https://github.com/presscustomizr/nimble-builder/issues/664
|
||||
Nimble_Manager()->is_viewing_static_front_page = is_front_page() && 'page' == get_option( 'show_on_front' );
|
||||
if ( !$use_current_query && $replace_current_query && true === sek_booleanize_checkbox_val($main_settings['display_pagination']) ) {
|
||||
$posts_per_page = (int)$main_settings['posts_per_page'];
|
||||
$posts_per_page = $posts_per_page <= 0 ? 1 : $posts_per_page;
|
||||
// April 2020 : fixes pagination not working on a static page used as front page
|
||||
// see https://github.com/presscustomizr/nimble-builder/issues/664
|
||||
// https://developer.wordpress.org/reference/classes/wp_query/#pagination-parameters
|
||||
$pagination_query_var = Nimble_Manager()->is_viewing_static_front_page ? 'page' :'paged';
|
||||
$paged = get_query_var($pagination_query_var);
|
||||
if ( $is_nimble_pagination_on ) {
|
||||
$query_params['paged'] = ( $paged && $is_current_grid_paginated ) ? $paged : 1;
|
||||
} else {
|
||||
$query_params['paged'] = $paged;
|
||||
}
|
||||
$query_params['posts_per_page'] = $posts_per_page;
|
||||
}
|
||||
|
||||
$post_query = null;
|
||||
if ( $replace_current_query && $post_nb > 0 ) {
|
||||
$cache_key = 'nb_post_q_' . $model['id'] . '_paged_' . $paged;
|
||||
$cache_group = 'nb_post_queries';
|
||||
// Use cached data when not customizing
|
||||
$cached = false;
|
||||
if ( !skp_is_customizing() ) {
|
||||
$cached = wp_cache_get( $cache_key, $cache_group );
|
||||
}
|
||||
if ( false !== $cached ) {
|
||||
$post_query = $cached;
|
||||
} else {
|
||||
// Sticky posts
|
||||
$include_sticky = array_key_exists('include_sticky', $main_settings ) && sek_booleanize_checkbox_val($main_settings['include_sticky']);
|
||||
if ( $include_sticky ) {
|
||||
$query_params['ignore_sticky_posts'] = 0;
|
||||
}
|
||||
$query_params = apply_filters( 'nimble_post_grid_module_query_params', $query_params , Nimble_Manager()->model );
|
||||
if ( is_array( $query_params ) ) {
|
||||
//add_filter( 'found_posts', '\Nimble\sek_filter_found_posts', 10, 2 );
|
||||
// Query featured entries
|
||||
$post_query = new \WP_Query($query_params);
|
||||
if ( $include_sticky ) {
|
||||
$post_query = sek_maybe_add_sticky_posts_to_query( $post_query, $query_params, $paged );
|
||||
}
|
||||
//remove_filter( 'found_posts', '\Nimble\sek_filter_found_posts', 10, 2 );
|
||||
} else {
|
||||
sek_error_log('post_grid_module_tmpl => query params is invalid');
|
||||
}
|
||||
if ( !skp_is_customizing() ) {
|
||||
wp_cache_add( $cache_key, $post_query, $cache_group );
|
||||
}
|
||||
}
|
||||
} else if ( !$replace_current_query ) {
|
||||
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && skp_is_customizing() ) {
|
||||
$post_query = new \WP_Query($query_params);
|
||||
} else {
|
||||
global $wp_query;
|
||||
$post_query = $wp_query;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Copy of WP_Query::have_post(), without do_action_ref_array( 'loop_start', array( &$this ) );
|
||||
// implemented to fix https://github.com/presscustomizr/nimble-builder/issues/467
|
||||
if ( !function_exists( 'Nimble\sek_pg_the_nimble_have_post') ) {
|
||||
function sek_pg_the_nimble_have_post( $query ) {
|
||||
if ( $query->current_post + 1 < $query->post_count ) {
|
||||
return true;
|
||||
} elseif ( $query->current_post + 1 == $query->post_count && $query->post_count > 0 ) {
|
||||
/**
|
||||
* Fires once the loop has ended.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param WP_Query $this The WP_Query instance (passed by reference).
|
||||
*/
|
||||
//do_action_ref_array( 'loop_end', array( &$this ) );
|
||||
// Do some cleaning up after the loop
|
||||
$query->rewind_posts();
|
||||
} elseif ( 0 === $query->post_count ) {
|
||||
/**
|
||||
* Fires if no results are found in a post query.
|
||||
*
|
||||
* @since 4.9.0
|
||||
*
|
||||
* @param WP_Query $this The WP_Query instance.
|
||||
*/
|
||||
do_action( 'loop_no_results', $query );
|
||||
}
|
||||
|
||||
$query->in_the_loop = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Copy of WP_Query::the_post(), without do_action_ref_array( 'loop_start', array( &$this ) );
|
||||
// implemented to fix https://github.com/presscustomizr/nimble-builder/issues/467
|
||||
if ( !function_exists( 'Nimble\sek_pg_the_nimble_post') ) {
|
||||
function sek_pg_the_nimble_post( $query ) {
|
||||
global $post;
|
||||
$query->in_the_loop = true;
|
||||
$post = $query->next_post();
|
||||
$query->setup_postdata( $post );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( is_object( $post_query ) && $post_query->have_posts() ) {
|
||||
$columns_by_device = $main_settings['columns'];
|
||||
$columns_by_device = is_array( $columns_by_device ) ? $columns_by_device : array();
|
||||
$columns_by_device = wp_parse_args( $columns_by_device, array(
|
||||
'desktop' => 2,
|
||||
'tablet' => '',
|
||||
'mobile' => ''
|
||||
));
|
||||
$normalized_columns_by_device = array();
|
||||
// normalizes
|
||||
foreach ( $columns_by_device as $device => $column_nb ) {
|
||||
$column_nb = (int)$column_nb;
|
||||
if ( !empty( $column_nb ) ) {
|
||||
$column_nb = $column_nb > 12 ? 12 : $column_nb;
|
||||
$column_nb = $column_nb < 1 ? 1 : $column_nb;
|
||||
}
|
||||
$normalized_columns_by_device[$device] = $column_nb;
|
||||
}
|
||||
|
||||
|
||||
$layout_class = 'list' === $main_settings['layout'] ? 'sek-list-layout' : 'sek-grid-layout';
|
||||
|
||||
$shadow_class = true === sek_booleanize_checkbox_val( $main_settings['apply_shadow_on_hover'] ) ? 'sek-shadow-on-hover' : '';
|
||||
|
||||
$has_thumb_custom_height = true === sek_booleanize_checkbox_val( $thumb_settings['img_has_custom_height'] ) ? 'sek-thumb-custom-height' : 'sek-thumb-no-custom-height';
|
||||
|
||||
$tablet_breakpoint_class = true === sek_booleanize_checkbox_val( $main_settings['has_tablet_breakpoint'] ) ? 'sek-has-tablet-breakpoint' : '';
|
||||
$mobile_breakpoint_class = true === sek_booleanize_checkbox_val( $main_settings['has_mobile_breakpoint'] ) ? 'sek-has-mobile-breakpoint' : '';
|
||||
|
||||
$grid_wrapper_classes = [ $tablet_breakpoint_class, $mobile_breakpoint_class ];
|
||||
$grid_wrapper_classes = apply_filters('nb_grid_wrapper_classes', $grid_wrapper_classes, $value );
|
||||
$grid_wrapper_classes = implode(' ', $grid_wrapper_classes );
|
||||
|
||||
$grid_items_classes = [ $layout_class, $has_thumb_custom_height, $shadow_class ];
|
||||
|
||||
if ( 'grid' === $main_settings['layout'] ) {
|
||||
foreach ( $normalized_columns_by_device as $device => $column_nb ) {
|
||||
if ( empty( $column_nb ) )
|
||||
continue;
|
||||
$grid_items_classes[] = "sek-{$device}-col-{$column_nb}";
|
||||
if ( 'desktop' === $device ) {
|
||||
$grid_items_classes[] = "sek-all-col-{$column_nb}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$grid_items_classes = implode(' ', $grid_items_classes );
|
||||
do_action( 'nb_before_post_grid_wrapper' );
|
||||
?>
|
||||
<div class="sek-post-grid-wrapper <?php echo esc_attr($grid_wrapper_classes); ?>" id="<?php echo esc_attr($model['id']); ?>">
|
||||
<div class="sek-grid-items <?php echo esc_attr($grid_items_classes); ?>">
|
||||
<?php
|
||||
// $post_query->have_posts() fires 'loop_end', which we don't want
|
||||
while ( sek_pg_the_nimble_have_post( $post_query ) ) {
|
||||
sek_pg_the_nimble_post( $post_query );// implemented to fix https://github.com/presscustomizr/nimble-builder/issues/467 because when using core $post_query->the_post(), the action 'loop_start' is fired
|
||||
sek_render_post( $main_settings, $metas_settings, $thumb_settings );
|
||||
}//while
|
||||
?>
|
||||
</div><?php //.sek-grid-item ?>
|
||||
|
||||
<?php
|
||||
if ( true === sek_booleanize_checkbox_val($main_settings['display_pagination']) ) {
|
||||
sek_render_post_navigation( $post_query );
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
// After looping through a separate query, this function restores the $post global to the current post in the main query.
|
||||
wp_reset_postdata();
|
||||
// This will remove obscure bugs that occur when the previous WP_Query object is not destroyed properly before another is set up.
|
||||
// $GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
|
||||
wp_reset_query();
|
||||
?>
|
||||
</div><?php //.sek-post-grid-wrapper ?>
|
||||
<?php
|
||||
}//if ( $post_query->have_posts() )
|
||||
|
||||
else if ( skp_is_customizing() ) {
|
||||
?>
|
||||
<div class="sek-module-placeholder sek-post-grid"><i class="material-icons">view_list</i></div>
|
||||
<?php
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
namespace Nimble;
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
$model = Nimble_Manager()->model;
|
||||
$module_type = $model['module_type'];
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
$quote_content_settings = $value['quote_content'];
|
||||
$cite_content_settings = $value['cite_content'];
|
||||
$design_settings = $value['design'];
|
||||
|
||||
// Utility to print the text content generated with tinyMce
|
||||
// should be wrapped in a specific selector when customizing,
|
||||
// => so we can listen to user click actions and open the editor on for each separate tiny_mce_editor input
|
||||
if ( !function_exists( __NAMESPACE__ . '\sek_print_quote_content' ) ) {
|
||||
function sek_print_quote_content( $quote_content, $input_id, $module_model ) {
|
||||
// added september 2020 related to https://github.com/presscustomizr/nimble-builder/issues/688
|
||||
$quote_content = sek_strip_script_tags( $quote_content );
|
||||
|
||||
// filter added since text editor implementation https://github.com/presscustomizr/nimble-builder/issues/403
|
||||
// Use our own content filter instead of $content = apply_filters( 'the_content', $tiny_mce_content );
|
||||
// because of potential third party plugins corrupting 'the_content' filter. https://github.com/presscustomizr/nimble-builder/issues/233
|
||||
//$quote_content = apply_filters( 'the_nimble_tinymce_module_content', $quote_content );
|
||||
|
||||
if ( skp_is_customizing() ) {
|
||||
$to_print = sprintf('<div title="%3$s" data-sek-input-type="textarea" data-sek-input-id="%1$s">%2$s</div>', esc_attr($input_id), $quote_content, __( 'Click to edit', 'textdomain_to_be_replaced' ) );
|
||||
} else {
|
||||
$to_print = $quote_content;
|
||||
}
|
||||
|
||||
echo apply_filters( 'the_nimble_tinymce_module_content', wp_kses_post($to_print) );
|
||||
}
|
||||
}
|
||||
|
||||
// print the module content if not empty
|
||||
if ( !empty( $quote_content_settings['quote_text'] ) ) {
|
||||
$cite_text = '';
|
||||
if ( !empty( $cite_content_settings['cite_text'] ) ) {
|
||||
// Feb 2021 : now saved as a json to fix emojis issues
|
||||
// see fix for https://github.com/presscustomizr/nimble-builder/issues/544
|
||||
// to ensure retrocompatibility with data previously not saved as json, we need to perform a json validity check
|
||||
$cite_text = sek_maybe_decode_richtext( $cite_content_settings['cite_text'] );
|
||||
}
|
||||
|
||||
sek_print_quote_content(
|
||||
sprintf( '<blockquote class="sek-quote%3$s" data-sek-quote-design="%4$s"><div class="sek-quote-inner"><div class="sek-quote-content">%1$s</div>%2$s</div></blockquote>',
|
||||
// Feb 2021 : now saved as a json to fix emojis issues
|
||||
// see fix for https://github.com/presscustomizr/nimble-builder/issues/544
|
||||
// to ensure retrocompatibility with data previously not saved as json, we need to perform a json validity check
|
||||
wp_kses_post(sek_maybe_decode_richtext( $quote_content_settings['quote_text'] )),
|
||||
!empty( $cite_text ) ? sprintf( '<footer class="sek-quote-footer"><cite class="sek-cite">%1$s</cite></footer>', sek_strip_script_tags( $cite_text ) ) : '',
|
||||
empty( $design_settings['quote_design'] ) || 'none' == $design_settings['quote_design'] ? '' : " sek-quote-design sek-{$design_settings['quote_design']}",
|
||||
$design_settings['quote_design']
|
||||
),
|
||||
'quote_text',
|
||||
$model
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
namespace Nimble;
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$model = Nimble_Manager()->model;
|
||||
$module_type = $model['module_type'];
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
if ( !function_exists( 'Nimble\sek_print_shortcode_module_content' ) ) {
|
||||
function sek_print_shortcode_module_content( $value = array() ) {
|
||||
// Feb 2021 : now saved as a json to fix emojis issues
|
||||
// see fix for https://github.com/presscustomizr/nimble-builder/issues/544
|
||||
// to ensure retrocompatibility with data previously not saved as json, we need to perform a json validity check
|
||||
$shortcode_mod_html_content = sek_maybe_decode_richtext( $value['text_content'] );
|
||||
|
||||
$shortcode_mod_html_content = sek_strip_script_tags( $shortcode_mod_html_content );
|
||||
|
||||
// Use our own content filter instead of $content = apply_filters( 'the_content', $tiny_mce_content );
|
||||
// because of potential third party plugins corrupting 'the_content' filter. https://github.com/presscustomizr/nimble-builder/issues/233
|
||||
printf( '<div class="sek-shortcode-content" data-sek-use-flexbox="%2$s">%1$s</div>',
|
||||
true === sek_booleanize_checkbox_val( $value['lazyload'] ) ? apply_filters( 'nimble_parse_for_smart_load', apply_filters( 'the_nimble_tinymce_module_content', wp_kses_post($shortcode_mod_html_content) ) ) : apply_filters( 'the_nimble_tinymce_module_content', wp_kses_post($shortcode_mod_html_content) ),
|
||||
( array_key_exists( 'use_flex', $value ) && true === sek_booleanize_checkbox_val( $value['use_flex'] ) ) ? "true" : "false"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( !empty( $value['text_content'] ) ) {
|
||||
sek_print_shortcode_module_content( $value );
|
||||
} else {
|
||||
if ( skp_is_customizing() ) {
|
||||
printf( '<div class="sek-mod-preview-placeholder"><div class="sek-preview-ph-text" style="%2$s"><p>%1$s</p></div></div>',
|
||||
__('Click to edit the shortcode module.', 'text_doma'),
|
||||
'background: url(' . esc_url(NIMBLE_MODULE_ICON_PATH) . 'Nimble_shortcode_icon.svg) no-repeat 50% 75%;background-size: 170px;'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
namespace Nimble;
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$model = Nimble_Manager()->model;
|
||||
$module_type = $model['module_type'];
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
|
||||
//sek_error_log('Simple form value', $value);
|
||||
$visual_effect_class = '';
|
||||
//visual effect classes
|
||||
if ( true === sek_booleanize_checkbox_val( $value['fields_design']['use_outset_shadow'] ) ) {
|
||||
$visual_effect_class .= 'use-outset-shadow';
|
||||
}
|
||||
if ( true === sek_booleanize_checkbox_val( $value['fields_design']['use_inset_shadow'] ) ) {
|
||||
$visual_effect_class .= ' use-inset-shadow';
|
||||
}
|
||||
?>
|
||||
<div class="sek-simple-form-wrapper <?php echo esc_attr($visual_effect_class); ?>">
|
||||
<?php // output secured in Nimble_Manager()->get_simple_form_html() ?>
|
||||
<?php echo wp_kses(Nimble_Manager()->get_simple_form_html( $model ), sek_get_allowed_html_in_forms()); ?>
|
||||
</div>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
namespace Nimble;
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$model = Nimble_Manager()->model;
|
||||
$module_type = $model['module_type'];
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
|
||||
// Utility to print the html content
|
||||
// should be wrapped in a specific selector when customizing,
|
||||
if ( !function_exists( 'Nimble\sek_print_html_content') ) {
|
||||
function sek_print_html_content( $html_content, $input_id ) {
|
||||
if ( empty( $html_content ) ) {
|
||||
echo wp_kses_post(Nimble_Manager()->sek_get_input_placeholder_content( 'text', 'html_content' ));
|
||||
} else {
|
||||
// Feb 2021 : now saved as a json to fix emojis issues
|
||||
// see fix for https://github.com/presscustomizr/nimble-builder/issues/544
|
||||
// to ensure retrocompatibility with data previously not saved as json, we need to perform a json validity check
|
||||
$html_content = sek_maybe_decode_richtext( $html_content );
|
||||
|
||||
// added September 2019 when revamping presscustomizr.com
|
||||
$html_content = sek_parse_template_tags( $html_content );
|
||||
|
||||
// added may 2020 related to https://github.com/presscustomizr/nimble-builder/issues/688
|
||||
$html_content = sek_strip_script_tags_and_print_js_inline( $html_content, Nimble_Manager()->model );
|
||||
|
||||
//TODO: move add_filter 'sek_html_content' somewhere else so it's called once
|
||||
//and we won't need to remove it
|
||||
//Also consider to add several other filter callbacks e.g. wptexturize, wpemoji... : see default-filters for 'the_content' in wp-incudes/default-filters.php
|
||||
//The html widget for sure doesn't conver emojis
|
||||
add_filter( 'sek_html_content', 'do_shortcode' );
|
||||
if ( !skp_is_customizing() ) {
|
||||
echo apply_filters( 'nimble_parse_for_smart_load',apply_filters( 'sek_html_content', htmlspecialchars_decode(esc_html($html_content) )) );
|
||||
} else {
|
||||
add_filter( 'safe_style_css', 'nimble_allow_display_attribute' );
|
||||
echo wp_kses_post($html_content);
|
||||
remove_filter( 'safe_style_css', 'nimble_allow_display_attribute' );
|
||||
}
|
||||
remove_filter( 'sek_html_content', 'do_shortcode' );
|
||||
}
|
||||
}
|
||||
}
|
||||
// print the module content
|
||||
if ( array_key_exists( 'html_content', $value ) ) {
|
||||
sek_print_html_content( $value['html_content'], 'html_content' );
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
namespace Nimble;
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_print_social_links' ) ) {
|
||||
function sek_print_social_links( $icons_collection, $icons_style ) {
|
||||
// Add more protocols to be allowed as safe urls. See: https://github.com/presscustomizr/nimble-builder/issues/461:wq
|
||||
$allowed_protocols = array_merge( (array) wp_allowed_protocols(), array( 'skype', 'callto' ) );
|
||||
|
||||
echo '<ul class="sek-social-icons-wrapper">';
|
||||
foreach( $icons_collection as $item ) {
|
||||
// normalize
|
||||
$item = !is_array( $item ) ? array() : $item;
|
||||
$default_item = array(
|
||||
'id' => '',
|
||||
'icon' => '',
|
||||
'link' => '',
|
||||
'title_attr' => '',
|
||||
'link_target' => false,
|
||||
'color_css' => '',
|
||||
'use_custom_color_on_hover' => false,
|
||||
'color_hover' => ''
|
||||
);
|
||||
|
||||
$item = wp_parse_args( $item, $default_item );
|
||||
|
||||
$link_attr = array();
|
||||
// target attr.
|
||||
$link_attr[] = false != $item['link_target'] ? 'target="_blank"' : '';
|
||||
// rel attr.
|
||||
$link_attr[] = false != $item['link_target'] ? 'rel="nofollow noopener noreferrer"' : 'rel="nofollow"';
|
||||
|
||||
// Put them together
|
||||
printf( '<li data-sek-item-id="%5$s"><a title="%1$s" aria-label="%1$s" href="%2$s" %3$s>%4$s<span class="screen-reader-text">%6$s</span></a></li>',
|
||||
esc_attr( $item['title_attr'] ),
|
||||
(isset($item['link']) && !empty( $item['link'] )) ? esc_url( $item['link'], $allowed_protocols ) : 'javascript:void(0)',
|
||||
esc_attr( implode( ' ', $link_attr ) ),
|
||||
wp_kses_post( ( ( empty( $item['icon'] ) || !is_string( $item['icon'] ) ) && skp_is_customizing() ) ? '<i class="material-icons">pan_tool</i>' : '<i class="sek-social-icon ' . $item['icon'] .'"></i>' ),
|
||||
esc_attr( $item['id'] ),
|
||||
wp_kses_post(( empty( $item['icon'] ) || !is_string( $item['icon'] ) ) ? 'social-link' : $item['icon'] )
|
||||
);
|
||||
}//foreach
|
||||
echo '</ul>';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$model = Nimble_Manager()->model;
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
$icons_collection = !empty($value['icons_collection']) ? $value['icons_collection'] : array();
|
||||
$icons_style = !empty($value['icons_style']) ? $value['icons_style'] : array();
|
||||
|
||||
if ( !empty( $icons_collection ) ) {
|
||||
sek_print_social_links( $icons_collection, $icons_style );
|
||||
sek_emit_js_event('nb-needs-fa');
|
||||
} else {
|
||||
if ( skp_is_customizing() ) {
|
||||
printf( '<div class="sek-mod-preview-placeholder"><div class="sek-preview-ph-text" style="%2$s"><p>%1$s</p></div></div>',
|
||||
__('Click to start adding social icons.', 'text_doma'),
|
||||
'background: url(' . esc_url(NIMBLE_MODULE_ICON_PATH) . 'Nimble_social_icon.svg) no-repeat 50% 75%;background-size: 150px;'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
echo '<div class="sek-spacer"></div>';
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
namespace Nimble;
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
// this.defaultItemModel = {
|
||||
// img : '',
|
||||
// 'img-size' : 'large',
|
||||
// 'alignment' : '',
|
||||
// 'link-to' : '',
|
||||
// 'link-pick-url' : '',
|
||||
// 'link-custom-url' : '',
|
||||
// 'link-target' : '',
|
||||
// 'lightbox' : true
|
||||
// };
|
||||
$model = Nimble_Manager()->model;
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
$main_settings = $value['main_settings'];
|
||||
//$borders_corners_settings = $value['borders_corners'];
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_get_img_module_img_html') ) {
|
||||
function sek_get_img_module_img_html( $value ) {
|
||||
// 'round' => rounded shape
|
||||
// 'expanded' => already expaded
|
||||
$visual_effect_class = array( 'round' );
|
||||
|
||||
$html = '';
|
||||
if ( is_int( $value['img'] ) ) {
|
||||
$img_src = wp_get_attachment_image_src( $value['img'], empty( $value['img-size'] ) ? 'large' : $value['img-size']);
|
||||
}
|
||||
if ( !empty( $img_src ) && isset( $img_src[0] ) ) {
|
||||
$img_url = $img_src[0];
|
||||
} else {
|
||||
$img_url = $value['img'];
|
||||
}
|
||||
|
||||
if ( !empty( $img_url ) && is_string( $img_url ) ) {
|
||||
$html = sprintf( '<div class="sek-nimble-image" style="background-image:url(%1$s)"></div>', esc_url($img_url ) );
|
||||
} else {
|
||||
//falls back on an icon if previewing
|
||||
if ( skp_is_customizing() ) {
|
||||
$html = Nimble_Manager()->sek_get_input_placeholder_content( 'upload' );
|
||||
}
|
||||
}
|
||||
|
||||
$title = '';
|
||||
// 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
|
||||
// 'caption' => $attachment->post_excerpt,
|
||||
// 'description' => $attachment->post_content,
|
||||
// 'href' => get_permalink( $attachment->ID ),
|
||||
// 'src' => $attachment->guid,
|
||||
// 'title' => $attachment->post_title
|
||||
$img_post = get_post( $value['img'] );
|
||||
if ( is_int( $value['img'] ) ) {
|
||||
$img_post = get_post( $value['img'] );
|
||||
if ( !is_wp_error( $img_post ) && is_object( $img_post ) && 'attachment' === $img_post->post_type ) {
|
||||
$caption = $img_post->post_excerpt;
|
||||
$description = $img_post->post_content;
|
||||
$img_title = $img_post->post_title;
|
||||
if ( false !== sek_booleanize_checkbox_val( $value['use_custom_title_attr']) ) {
|
||||
$title = esc_html( $value['heading_title'] );
|
||||
} elseif ( !empty( $caption ) ) {
|
||||
$title = $caption;
|
||||
} else if ( !empty( $description ) ) {
|
||||
$title = $description;
|
||||
} else if ( !empty( $img_title ) ) {
|
||||
$title = $img_title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'no-link' === $value['link-to'] ) {
|
||||
$html = sprintf('<div class="sek-nimble-image-mask"></div>%1$s',
|
||||
$html
|
||||
);
|
||||
} else {
|
||||
$html = sprintf('<a href="%1$s" class="sek-nimble-image-mask" %2$s></a>%3$s',
|
||||
sek_get_img_module_img_link( $value ),
|
||||
true === sek_booleanize_checkbox_val( $value['link-target'] ) ? 'target="_blank" rel="noopener noreferrer"' : '',
|
||||
$html
|
||||
);
|
||||
}
|
||||
// Would be great if this would be able to parse also the background-url inline style and move it into the data-sek-lazy-bg attribute
|
||||
return apply_filters( 'nimble_parse_for_smart_load', sprintf('<figure class="sek-nimble-image-wrapper %1$s" title="%3$s">%2$s</figure>', esc_attr(implode( ' ', $visual_effect_class)), wp_kses_post($html), esc_html( $title ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_get_img_module_img_link' ) ) {
|
||||
function sek_get_img_module_img_link( $value ) {
|
||||
$link = 'javascript:void(0);';
|
||||
// if ( skp_is_customizing() ) {
|
||||
// return $link;
|
||||
// }
|
||||
switch( $value['link-to'] ) {
|
||||
case 'url' :
|
||||
if ( !empty( $value['link-pick-url'] ) && !empty( $value['link-pick-url']['id'] ) ) {
|
||||
if ( '_custom_' == $value['link-pick-url']['id'] && !empty( $value['link-custom-url'] ) ) {
|
||||
$custom_url = apply_filters( 'nimble_parse_template_tags', $value['link-custom-url'] );
|
||||
$link = esc_url( $custom_url );
|
||||
} else if ( !empty( $value['link-pick-url']['url'] ) ) {
|
||||
$link = esc_url( $value['link-pick-url']['url'] );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'img-file' :
|
||||
if ( is_int( $value['img'] ) ) {
|
||||
$link = wp_get_attachment_url( $value['img'] );
|
||||
}
|
||||
break;
|
||||
case 'img-page' :
|
||||
if ( is_int( $value['img'] ) ) {
|
||||
$link = get_attachment_link( $value['img'] );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
}
|
||||
|
||||
// Print
|
||||
echo wp_kses_post(sek_get_img_module_img_html( $main_settings ));
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
namespace Nimble;
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
$model = Nimble_Manager()->model;
|
||||
$module_type = $model['module_type'];
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
$value = $value['main_settings'];
|
||||
|
||||
// Utility to print the text content generated with tinyMce
|
||||
// should be wrapped in a specific selector when customizing,
|
||||
// => so we can listen to user click actions and open the editor on for each separate tiny_mce_editor input
|
||||
if ( !function_exists( 'Nimble\sek_print_tiny_mce_text_content') ) {
|
||||
function sek_print_tiny_mce_text_content( $tiny_mce_content, $input_id, $value ) {
|
||||
if ( empty( $tiny_mce_content ) ) {
|
||||
echo wp_kses_post(Nimble_Manager()->sek_get_input_placeholder_content( 'detached_tinymce_editor', $input_id ));
|
||||
} else {
|
||||
if ( false === sek_booleanize_checkbox_val( $value['autop'] ) ) {
|
||||
remove_filter( 'the_nimble_tinymce_module_content', 'wpautop');
|
||||
}
|
||||
|
||||
// Feb 2021 : now saved as a json to fix emojis issues
|
||||
// see fix for https://github.com/presscustomizr/nimble-builder/issues/544
|
||||
// to ensure retrocompatibility with data previously not saved as json, we need to perform a json validity check
|
||||
$content = sek_maybe_decode_richtext( $tiny_mce_content );
|
||||
$content = sek_strip_script_tags_and_print_js_inline( $content, Nimble_Manager()->model );
|
||||
// Use our own content filter instead of $content = apply_filters( 'the_content', $tiny_mce_content );
|
||||
// because of potential third party plugins corrupting 'the_content' filter. https://github.com/presscustomizr/nimble-builder/issues/233
|
||||
if ( false === sek_booleanize_checkbox_val( $value['autop'] ) ) {
|
||||
add_filter( 'the_nimble_tinymce_module_content', 'wpautop');
|
||||
}
|
||||
if ( skp_is_customizing() ) {
|
||||
printf('<div title="%3$s" data-sek-input-type="detached_tinymce_editor" data-sek-input-id="%1$s">%2$s</div>', esc_attr($input_id), apply_filters( 'the_nimble_tinymce_module_content', wp_kses_post($content)), __( 'Click to edit', 'textdomain_to_be_replaced' ) );
|
||||
} else {
|
||||
echo apply_filters( 'nimble_parse_for_smart_load', apply_filters( 'the_nimble_tinymce_module_content', htmlspecialchars_decode(esc_html($content))) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// print the module content if not empty
|
||||
if ( array_key_exists('content', $value ) ) {
|
||||
sek_print_tiny_mce_text_content( $value['content'], 'content', $value );
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/* Developers : you can override this template from a theme with a file that has this path : 'nimble_templates/modules/{original-module-template-file-name}.php' */
|
||||
namespace Nimble;
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$model = Nimble_Manager()->model;
|
||||
$module_type = $model['module_type'];
|
||||
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
|
||||
$widget_area_has_at_least_one_widget = is_active_sidebar( $value['widget-area-id'] );
|
||||
|
||||
if ( !function_exists( 'Nimble\sek_maybe_print_widget_placeholder') ) {
|
||||
function sek_maybe_print_widget_placeholder( $id ) {
|
||||
global $wp_registered_sidebars;
|
||||
if ( !sek_is_nimble_widget_id( $id ) || !array_key_exists( $id, $wp_registered_sidebars ) ) {
|
||||
$placeholder_text = __('Select a Nimble widget area and start adding widgets.', 'text_domain_to_replace');
|
||||
} else {
|
||||
$widget_area_model = $wp_registered_sidebars[ $id ];
|
||||
$placeholder_text = sprintf( '%1$s <span class="zone-name" style="font-weight:bold">%2$s</span>',
|
||||
__('Add widgets to', 'text_domain_to_replace'),
|
||||
isset( $widget_area_model['name'] ) ? $widget_area_model['name'] : $widget_area_model['id']
|
||||
);
|
||||
}
|
||||
|
||||
printf('<div class="widget" data-czr-panel-focus="widgets"><div class="czr-placeholder-widget" %1$s><h3 %2$s>%3$s</h3></div></div>',
|
||||
'style="background:#f7f8f9;padding:30px;text-align:center;outline:3px dotted #858585;;font-size:.875em;"',
|
||||
'style="margin:0.5em;font-size:17px;line-height:1.5em;color:#444"',
|
||||
wp_kses_post($placeholder_text)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! sek_is_widget_module_disabled() ) {
|
||||
if ( array_key_exists( 'widget-area-id', $value ) && is_string( $value['widget-area-id'] ) ) {
|
||||
if ( is_active_sidebar( $value['widget-area-id'] ) ) {
|
||||
dynamic_sidebar( $value['widget-area-id'] );
|
||||
} else {
|
||||
if ( skp_is_customizing() ) {
|
||||
sek_maybe_print_widget_placeholder( $value['widget-area-id'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user