first commit

This commit is contained in:
CHIEFSOFT\ameye
2023-12-28 16:20:07 -05:00
commit b114fdf4fa
5377 changed files with 1850677 additions and 0 deletions
@@ -0,0 +1,121 @@
<?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;
$id = $model['id'];
$collection = array_key_exists( 'collection', $model ) ? $model['collection'] : array();
// Store the parent model
// => used when calculating the width of the column to be added
$parent_model = Nimble_Manager()->parent_model;
// if ( defined('DOING_AJAX') && DOING_AJAX ) {
// error_log( print_r( $parent_model, true ) );
// }
// sek_error_log( 'PARENT MODEL WHEN RENDERING', $parent_model );
// SETUP THE DEFAULT CSS CLASS
// Note : the css rules for custom width are generated in Sek_Dyn_CSS_Builder::sek_add_rules_for_column_width
$col_number = ( array_key_exists( 'collection', $parent_model ) && is_array( $parent_model['collection'] ) ) ? count( $parent_model['collection'] ) : 1;
$col_number = 12 < $col_number ? 12 : $col_number;
$col_width_in_percent = 100/$col_number;
//@note : we use the same logic in the customizer preview js to compute the column css classes when dragging them
//@see sek_preview::makeColumnsSortableInSektion
//TODO, we might want to be sure the $col_suffix is related to an allowed size
$col_suffix = floor( $col_width_in_percent );
// SETUP THE GLOBAL CUSTOM BREAKPOINT CSS CLASS
$global_custom_breakpoint = intval( sek_get_global_custom_breakpoint() );
// SETUP THE LEVEL CUSTOM BREAKPOINT CSS CLASS
// nested section should inherit the custom breakpoint of the parent
// @fixes https://github.com/presscustomizr/nimble-builder/issues/554
// the 'for_responsive_columns' param has been introduced for https://github.com/presscustomizr/nimble-builder/issues/564
// so we can differentiate when the custom breakpoint is requested for column responsiveness or for css rules generation
// when for columns, we always apply the custom breakpoint defined by the user
// otherwise, when generating CSS rules like alignment, the custom breakpoint is applied if user explicitely checked the 'apply_to_all' option
// 'for_responsive_columns' is set to true when sek_get_closest_section_custom_breakpoint() is invoked from Nimble_Manager()::render()
$section_custom_breakpoint = intval( sek_get_closest_section_custom_breakpoint( array(
'searched_level_id' => $parent_model['id'],
'for_responsive_columns' => true
)));
$grid_column_class = "sek-col-{$col_suffix}";
if ( is_int($section_custom_breakpoint) && $section_custom_breakpoint >= 1 ) {
$grid_column_class = "sek-section-custom-breakpoint-col-{$col_suffix}";
} else if ( $global_custom_breakpoint >= 1 ) {
$grid_column_class = "sek-global-custom-breakpoint-col-{$col_suffix}";
}
$bg_attributes = Nimble_Manager()->sek_maybe_add_bg_attributes( $model );
$stringified_bg_attributes = implode(' ', array_map(function ($k, $v) {return $k . '="' . $v . '"'; },array_keys($bg_attributes), array_values($bg_attributes)) );
// if there's a lazy loaded img background let's print a CSS loader removed when lazy loaded
$has_bg_img = false;
if ( false !== strpos( $stringified_bg_attributes, 'data-sek-src="http') ) {
$has_bg_img = true;
}
$level_custom_attr = Nimble_Manager()->level_custom_attr;
printf('<div data-sek-level="column" data-sek-id="%1$s" class="sek-column sek-col-base %2$s %3$s %4$s %5$s" %6$s %7$s %8$s %9$s %10$s>%11$s',
esc_attr($id),
esc_attr($grid_column_class),
esc_attr(Nimble_Manager()->get_level_visibility_css_class( $model )),
$has_bg_img ? 'sek-has-bg' : '',
esc_attr(Nimble_Manager()->level_css_classes),
empty( $collection ) ? 'data-sek-no-modules="true"' : '',
// add smartload + parallax attributes
implode(' ', array_map(function ($k, $v) {return $k . '="' . esc_attr($v) . '"'; }, array_keys($bg_attributes), array_values($bg_attributes))),
is_null( Nimble_Manager()->level_custom_anchor ) ? '' : 'id="' . ltrim( esc_attr(Nimble_Manager()->level_custom_anchor) , '#' ) . '"',// make sure we clean the hash if user left it
// introduced for https://github.com/presscustomizr/nimble-builder/issues/494
( skp_is_customizing() || ( defined('DOING_AJAX') && DOING_AJAX ) ) ? sprintf( 'data-sek-preview-level-guid="%1$s"', esc_attr( Nimble_Manager()->sek_get_preview_level_guid() ) ) : '' ,
is_array($level_custom_attr) ? implode(' ', array_map(function ($k, $v) {return $k . '="' . esc_attr($v) . '"'; }, array_keys($level_custom_attr), array_values($level_custom_attr))) : wp_kses_post( $level_custom_attr ),
( $has_bg_img && !skp_is_customizing() && sek_is_img_smartload_enabled() ) ? '<div class="sek-css-loader sek-mr-loader"><div></div><div></div><div></div></div>' : ''
);
if ( false !== strpos($stringified_bg_attributes, 'data-sek-video-bg-src') ) {
sek_emit_js_event('nb-needs-videobg-js');
}
if ( false !== strpos($stringified_bg_attributes, 'data-sek-bg-parallax="true"') ) {
sek_emit_js_event('nb-needs-parallax');
}
?>
<?php
// Drop zone : if no modules, the drop zone is wrapped in sek-no-modules-columns
// if at least one module, the sek-drop-zone is the .sek-column-inner wrapper
?>
<div class="sek-column-inner <?php echo empty( $collection ) ? 'sek-empty-col' : ''; ?>">
<?php
// the drop zone is inserted when customizing but not when previewing a changeset post
// since https://github.com/presscustomizr/nimble-builder/issues/351
if ( skp_is_customizing() && !sek_is_customize_previewing_a_changeset_post() && empty( $collection ) ) {
//$content_type = 1 === $col_number ? 'section' : 'module';
$content_type = 'module';
$title = 'section' === $content_type ? __('Drag and drop a section or a module here', 'text_doma' ) : __('Drag and drop a block of content here', 'text_doma' );
?>
<div class="sek-no-modules-column">
<div class="sek-module-drop-zone-for-first-module sek-content-module-drop-zone sek-drop-zone">
<i data-sek-click-on="pick-content" data-sek-content-type="<?php echo esc_attr($content_type); ?>" class="material-icons sek-click-on" title="<?php echo esc_html($title); ?>">add_circle_outline</i>
<span class="sek-injection-instructions"><?php _e('Drag and drop or double-click the content that you want to insert here.', 'text_domain_to_rep'); ?></span>
</div>
</div>
<?php
} else {
// Set the parent model now
Nimble_Manager()->parent_model = $model;
foreach ( $collection as $module_or_nested_section_model ) {
?>
<?php
Nimble_Manager()->render( $module_or_nested_section_model );
}
?>
<?php
}
?>
</div>
</div><?php //data-sek-level="column" ?>
@@ -0,0 +1,85 @@
<?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;
$id = $model['id'];
$collection = array_key_exists( 'collection', $model ) ? $model['collection'] : array();
$is_header_location = true === sek_get_registered_location_property( $id, 'is_header_location' );
$is_footer_location = true === sek_get_registered_location_property( $id, 'is_footer_location' );
//sek_error_log( __FUNCTION__ . ' WHAT ARE WE RENDERING? ' . $id , $collection );
// Store the header-footer location boolean in the manager
// Used to determine if we are allowed to lazyload
// @see https://github.com/presscustomizr/nimble-builder/issues/705
Nimble_Manager()->current_location_is_header = $is_header_location;
Nimble_Manager()->current_location_is_footer = $is_footer_location;
// PASSWORD PROTECTION see #673 and #679
// If the page/post is password protect, and this is not a header or footer location,
// => stop the recursive walker here and print the password form
// for https://github.com/presscustomizr/nimble-builder/issues/673
// Nimble_Manager()->is_content_restricted is set at 'wp', see ::sek_maybe_empty_password_form
// 1) we want to protect content added with Nimble Builder, but not if header or footer
// 2) we want to apply the protection on front, not when customizing
// 3) we need to check if the single page or post is password protected
// 4) we don't want to render the password form multiple times
$has_content_restriction_for_location = Nimble_Manager()->is_content_restricted && !$is_header_location && !$is_footer_location;
$location_needs_css_class_to_style_password_form = false;
if ( $has_content_restriction_for_location ) {
// in the case of the built-in WP password form, we only print it once, so we don't need to add the CSS class to each locations
$location_needs_css_class_to_style_password_form = !did_action('nimble_wp_pwd_form_rendered');
}
// NOTE : empty sektions wrapper are only printed when customizing
?>
<?php if ( skp_is_customizing() || ( !skp_is_customizing() && !empty( $collection ) ) ) : ?>
<?php
Nimble_Manager()->nimble_customizing_or_content_is_printed_on_this_page = true;
printf( '<div class="sektion-wrapper nb-loc %6$s" data-sek-level="location" data-sek-id="%1$s" %2$s %3$s %4$s %5$s>',
$id,
esc_attr(sprintf('data-sek-is-global-location="%1$s"', sek_is_global_location( $id ) ? 'true' : 'false')),
$is_header_location ? 'data-sek-is-header-location="true"' : '',
$is_footer_location ? 'data-sek-is-footer-location="true"' : '',
// introduced for https://github.com/presscustomizr/nimble-builder/issues/494
( skp_is_customizing() || ( defined('DOING_AJAX') && DOING_AJAX ) ) ? sprintf( 'data-sek-preview-level-guid="%1$s"', esc_attr( Nimble_Manager()->sek_get_preview_level_guid() ) ) : '' ,
$location_needs_css_class_to_style_password_form ? 'sek-password-protected' : ''//<= added for #673
);
?>
<?php
if ( $has_content_restriction_for_location ) {
// april 2020 : added for https://github.com/presscustomizr/nimble-builder/issues/685
do_action('nimble_content_restriction_for_location', $model );
} else {
Nimble_Manager()->parent_model = $model;
foreach ( $collection as $_key => $sec_model ) { Nimble_Manager()->render( $sec_model ); }
}
?>
<?php
// empty global locations placeholders are only printed when customizing But not previewing a changeset post
// since https://github.com/presscustomizr/nimble-builder/issues/351
?>
<?php if ( empty( $collection ) && !sek_is_customize_previewing_a_changeset_post() ) : ?>
<div class="sek-empty-location-placeholder">
<?php
if ( $is_header_location || $is_footer_location ) {
printf('<span class="sek-header-footer-location-placeholder">%1$s %2$s</span>',
sprintf( '<span class="sek-nimble-icon"><img src="%1$s"/></span>',
esc_url(NIMBLE_BASE_URL.'/assets/img/nimble/nimble_icon.svg?ver='.NIMBLE_VERSION)
),
$is_header_location ? __('Start designing the header', 'text_doma') : __('Start designing the footer', 'text_doma')
);
}
?>
</div>
<?php endif; ?>
</div><?php //class="sektion-wrapper" ?>
<?php endif; ?>
@@ -0,0 +1,127 @@
<?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;
$id = $model['id'];
if ( empty( $model['module_type'] ) ) {
sek_error_log( __CLASS__ . '::' . __FUNCTION__ . ' => missing module_type for a module', $model );
return;
}
$module_type = $model['module_type'];
if ( !CZR_Fmk_Base()->czr_is_module_registered($module_type) ) {
sek_error_log( __CLASS__ . '::' . __FUNCTION__ . ' => module_type not registered', $module_type );
return;
}
$model = sek_normalize_module_value_with_defaults( $model );
// update the current cached model
Nimble_Manager()->model = $model;
$title_attribute = '';
if ( skp_is_customizing() ) {
$title_attribute = __('Edit module settings', 'text-domain');
}
// SETUP MODULE TEMPLATE PATH
// introduced for #532, october 2019
// Default tmpl path looks like : NIMBLE_BASE_PATH . "/tmpl/modules/image_module_tmpl.php",
//
// Important note :
// @fixes https://github.com/presscustomizr/nimble-builder/issues/537
// since #532, module registered in Nimble Builder core have a render_tmpl_path property looking like 'render_tmpl_path' => "simple_html_module_tmpl.php",
// But if a developer wants to register a custom module with a specific template path, it is still possible by using a full path
// 1) We first check if the file exists, if it is a full path this will return TRUE and the render tmpl path will be set this way
// , for example, we use a custom gif module on presscustomizr.com, for which the render_tmpl_path is a full path:
// 'render_tmpl_path' => TC_BASE_CHILD . "inc/nimble-modules/modules-registration/tmpl/modules/gif_image_module_tmpl.php",
// 2) then we check if there's an override
// 3) finally we use the default Nimble Builder path
// render_tmpl_path can be
// 1) simple_html_module_tmpl.php <= most common case, the module is registered by Nimble Builder
// 2) srv/www/pc-dev/htdocs/wp-content/themes/tc/inc/nimble-modules/modules-registration/tmpl/modules/gif_image_module_tmpl.php <= case of a custom module
$template_name_or_path = sek_get_registered_module_type_property( $module_type, 'render_tmpl_path' );
$template_name = basename( $template_name_or_path );
$template_name = ltrim( $template_name_or_path, '/' );
if ( file_exists( $template_name_or_path ) ) {
$template_path = $template_name_or_path;
} else {
$template_path = sek_get_templates_dir() . "/modules/{$template_name}";
}
// make this filtrable
$render_tmpl_path = apply_filters( 'nimble_module_tmpl_path', $template_path, $module_type );
// Then check if there's an override
$overriden_template_path = Nimble_Manager()->sek_maybe_get_overriden_template_path_for_module( $template_name );
$is_module_template_overriden = false;
if ( !empty( $overriden_template_path ) ) {
$render_tmpl_path = $overriden_template_path;
$is_module_template_overriden = true;
}
// if there's a lazy loaded img background let's print a CSS loader removed when lazy loaded
$bg_attributes = Nimble_Manager()->sek_maybe_add_bg_attributes( $model );
$stringified_bg_attributes = implode(' ', array_map(function ($k, $v) {return $k . '="' . $v . '"'; },array_keys($bg_attributes), array_values($bg_attributes)) );
// if there's a lazy loaded img background let's print a CSS loader removed when lazy loaded
$has_bg_img = false;
if ( false !== strpos( $stringified_bg_attributes, 'data-sek-src="http') ) {
$has_bg_img = true;
}
if ( false !== strpos($stringified_bg_attributes, 'data-sek-bg-parallax="true"') ) {
sek_emit_js_event('nb-needs-parallax');
}
$module_classes = [
Nimble_Manager()->get_level_visibility_css_class( $model ),
$has_bg_img ? 'sek-has-bg' : '',
Nimble_Manager()->level_css_classes
];
$level_custom_attr = Nimble_Manager()->level_custom_attr;
printf('<div data-sek-level="module" data-sek-id="%1$s" data-sek-module-type="%2$s" class="sek-module %3$s" %4$s %5$s %6$s %7$s %8$s %9$s>%10$s',
esc_attr($id),
esc_attr($module_type),
esc_attr(implode(' ', $module_classes )),
'title="'.esc_html($title_attribute).'"',
// add smartload + parallax attributes
implode(' ', array_map(function ($k, $v) {return $k . '="' . esc_attr($v) . '"'; }, array_keys($bg_attributes), array_values($bg_attributes))),
is_null( Nimble_Manager()->level_custom_anchor ) ? '' : 'id="' . ltrim( esc_attr(Nimble_Manager()->level_custom_anchor ) , '#' ) . '"',// make sure we clean the hash if user left it
// introduced for https://github.com/presscustomizr/nimble-builder/issues/494
( skp_is_customizing() || ( defined('DOING_AJAX') && DOING_AJAX ) ) ? sprintf( 'data-sek-preview-level-guid="%1$s"', esc_attr( Nimble_Manager()->sek_get_preview_level_guid() ) ) : '' ,
$is_module_template_overriden ? 'data-sek-module-template-overriden="true"': '',// <= added for #532
is_array($level_custom_attr) ? implode(' ', array_map(function ($k, $v) {return $k . '="' . esc_attr($v) . '"'; }, array_keys($level_custom_attr), array_values($level_custom_attr))) : (!empty($level_custom_attr) ? wp_kses_post( $level_custom_attr ) : '' ),
( $has_bg_img && !skp_is_customizing() && sek_is_img_smartload_enabled() ) ? '<div class="sek-css-loader sek-mr-loader"><div></div><div></div><div></div></div>' : ''
);
?>
<div class="sek-module-inner">
<?php
if ( skp_is_customizing() && sek_is_debug_mode() ) {
// added for https://github.com/presscustomizr/nimble-builder/issues/688
// allows us to print the structure without the potentially broken javascript content ( hard coded or generated by a shortcode )
printf('<p class="sek-debug-modules">Module type : %1$s | id : %2$s</p>',
ucfirst( str_replace( array( 'czr_', '_' ), array( '', ' ' ), esc_attr($module_type) ) ),
esc_html($id)
);
} else if ( !empty( $render_tmpl_path ) && file_exists( $render_tmpl_path ) ) {
load_template( $render_tmpl_path, false );
} else {
error_log( __FUNCTION__ . ' => no template found for module type ' . $module_type );
}
?>
</div>
</div><?php //data-sek-level="module" ?>
@@ -0,0 +1,68 @@
<?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;
$id = $model['id'];
$collection = array_key_exists( 'collection', $model ) ? $model['collection'] : array();
$is_nested = array_key_exists( 'is_nested', $model ) && true == $model['is_nested'];
$has_at_least_one_module = sek_section_has_modules( $collection );
$column_container_class = 'sek-container-fluid';
//when boxed use proper container class
if ( !empty( $model[ 'options' ][ 'layout' ][ 'boxed-wide' ] ) && 'boxed' == $model[ 'options' ][ 'layout' ][ 'boxed-wide' ] ) {
$column_container_class = 'sek-container';
}
// if there's a video background or a parallax bg we need to inform js api
$bg_attributes = Nimble_Manager()->sek_maybe_add_bg_attributes( $model );
$stringified_bg_attributes = implode(' ', array_map(function ($k, $v) {return $k . '="' . $v . '"'; },array_keys($bg_attributes), array_values($bg_attributes)) );
// if there's a lazy loaded img background let's print a CSS loader removed when lazy loaded
$has_bg_img = false;
if ( false !== strpos( $stringified_bg_attributes, 'data-sek-src="http') ) {
$has_bg_img = true;
}
// June 2020 : introduced for https://github.com/presscustomizr/nimble-builder-pro/issues/6
$section_classes = apply_filters( 'nimble_section_level_css_classes', array(), $model );
array_push( $section_classes, Nimble_Manager()->level_css_classes );
$level_custom_attr = Nimble_Manager()->level_custom_attr;
printf('<div data-sek-level="section" data-sek-id="%1$s" %2$s class="sek-section %3$s %4$s %5$s %6$s" %7$s %8$s %9$s %10$s>%11$s',
esc_attr($id),
$is_nested ? 'data-sek-is-nested="true"' : '',
$has_at_least_one_module ? 'sek-has-modules' : '',
esc_attr(Nimble_Manager()->get_level_visibility_css_class( $model )),
$has_bg_img ? 'sek-has-bg' : '',
esc_attr(implode(' ', $section_classes)),
is_null( Nimble_Manager()->level_custom_anchor ) ? '' : 'id="' . ltrim( esc_attr(Nimble_Manager()->level_custom_anchor) , '#' ) . '"',// make sure we clean the hash if user left it
// add smartload + parallax attributes
implode(' ', array_map(function ($k, $v) {return $k . '="' . esc_attr($v) . '"'; }, array_keys($bg_attributes), array_values($bg_attributes) )),
// introduced for https://github.com/presscustomizr/nimble-builder/issues/494
( skp_is_customizing() || ( defined('DOING_AJAX') && DOING_AJAX ) ) ? sprintf( 'data-sek-preview-level-guid="%1$s"', esc_attr( Nimble_Manager()->sek_get_preview_level_guid() ) ) : '' ,
is_array($level_custom_attr) ? implode(' ', array_map(function ($k, $v) {return $k . '="' . esc_attr($v) . '"'; }, array_keys($level_custom_attr), array_values($level_custom_attr))) : (!empty($level_custom_attr) ? wp_kses_post( $level_custom_attr ) : '' ),
( $has_bg_img && !skp_is_customizing() && sek_is_img_smartload_enabled() ) ? '<div class="sek-css-loader sek-mr-loader"><div></div><div></div><div></div></div>' : ''
);
if ( false !== strpos($stringified_bg_attributes, 'data-sek-video-bg-src') ) {
sek_emit_js_event('nb-needs-videobg-js');
}
if ( false !== strpos($stringified_bg_attributes, 'data-sek-bg-parallax="true"') ) {
sek_emit_js_event('nb-needs-parallax');
}
?>
<div class="<?php echo esc_attr($column_container_class); ?>">
<div class="sek-row sek-sektion-inner">
<?php
// Set the parent model now
Nimble_Manager()->parent_model = $model;
foreach ( $collection as $col_model ) {Nimble_Manager()->render( $col_model ); }
?>
</div>
</div>
</div><?php //data-sek-level="section" ?>