$list ) { $files[$list] = $directory . $list; } return $files; } return array(); } function lightspeed_list_files_with_uri( $directory, $uri ) { if ( file_exists( $directory ) ) { $lists = array_values( array_diff( scandir( $directory ), array( '..', '.', 'index.php' ) ) ); $files = array(); foreach ( $lists as $list_key => $list ) { $files[$list] = $uri . $list; } return $files; } return array(); } function lightspeed_get_custom_directory( $is_child = false ) { if ( $is_child ) { $template = get_stylesheet_directory(); } else { $template = get_template_directory(); } return $template . '/all-bootstrap-blocks/lightspeed/custom/'; } function lightspeed_get_custom_directory_uri( $is_child = false ) { if ( $is_child ) { $template = get_stylesheet_directory_uri(); } else { $template = get_template_directory_uri(); } return $template . '/all-bootstrap-blocks/lightspeed/custom/'; } function lightspeed_get_placeholder_path() { $placeholder = areoi2_get_option( 'areoi-lightspeed-company-stock-media', 'default' ); if ( !$placeholder ) $placeholder = 'default'; $directory = AREOI__PLUGIN_LIGHTSPEED_DIR . 'placeholders/'; $theme_directory = get_template_directory() . '/all-bootstrap-blocks/lightspeed/placeholders/'; if ( file_exists( $theme_directory . $placeholder ) ) { $directory = get_template_directory() . '/all-bootstrap-blocks/lightspeed/placeholders/'; } $theme_directory = get_stylesheet_directory() . '/all-bootstrap-blocks/lightspeed/placeholders/'; if ( file_exists( $theme_directory . $placeholder ) ) { $directory = get_stylesheet_directory() . '/all-bootstrap-blocks/lightspeed/placeholders/'; } return $directory . $placeholder; } function lightspeed_get_placeholder_uri() { $placeholder = areoi2_get_option( 'areoi-lightspeed-company-stock-media', 'default' ); if ( !$placeholder ) $placeholder = 'default'; $directory = AREOI__PLUGIN_LIGHTSPEED_URI . 'placeholders/'; $theme_directory = get_template_directory() . '/all-bootstrap-blocks/lightspeed/placeholders/'; if ( file_exists( $theme_directory . $placeholder ) ) { $directory = get_template_directory_uri() . '/all-bootstrap-blocks/lightspeed/placeholders/'; } $theme_directory = get_stylesheet_directory() . '/all-bootstrap-blocks/lightspeed/placeholders/'; if ( file_exists( $theme_directory . $placeholder ) ) { $directory = get_stylesheet_directory_uri() . '/all-bootstrap-blocks/lightspeed/placeholders/'; } return $directory . $placeholder; } function lightspeed_get_block_templates( $block_folders, $is_blocks = true ) { $templates = array(); foreach ( $block_folders as $block_folder_key => $block_folder ) { $directory = AREOI__PLUGIN_LIGHTSPEED_DIR . ( $is_blocks ? 'blocks/' : '' ) . $block_folder . '/'; $plugin_templates = lightspeed_list_files( $directory ); $theme_directory = get_template_directory() . '/all-bootstrap-blocks/lightspeed/' . $block_folder . '/'; $theme_templates = lightspeed_list_files( $theme_directory ); $child_templates = array(); if ( is_child_theme() ) { $child_directory = get_stylesheet_directory() . '/all-bootstrap-blocks/lightspeed/' . $block_folder . '/'; $child_templates = lightspeed_list_files( $child_directory ); } $all_templates = array_merge( $plugin_templates, $theme_templates, $child_templates ); sort( $all_templates, SORT_NATURAL | SORT_FLAG_CASE ); $block_templates = array( array( 'value' => '', 'label' => 'Default' ) ); foreach ( $all_templates as $template ) { $label = str_replace( '.php', '', $template ); $label = str_replace( '.svg', '', $label ); $label = str_replace( '-', ' ', $label ); $label = ucwords( $label ); $block_templates[] = array( 'value' => $template, 'label' => $label ); } $templates[$block_folder_key] = $block_templates; } return $templates; } function lightspeed_get_template( $block_type, $block_order, $with_path = true ) { $alternate = ( $block_order % 2 == 0 && in_array( $block_type, array( 'content-with-media' ) ) ) ? '-alternate' : ''; $fallback = areoi2_get_option( 'areoi-lightspeed-blocks-' . $block_type . $alternate ); if ( !$fallback ) $fallback = areoi2_get_option( 'areoi-lightspeed-blocks-' . $block_type ); if ( !$fallback ) $fallback = 'basic.php'; $template = lightspeed_get_template_directory( $block_type, 'templates/' . lightspeed_get_attribute( 'filename', $fallback ) ); if ( $with_path ) return $template; return lightspeed_get_attribute( 'filename', $fallback ); } function lightspeed_get_is_first_strip() { global $lightspeed_block_order; $header_template_part = get_block_template( get_stylesheet() . '//' . 'header', 'wp_template_part' ); $position = null; if ( $header_template_part ) { $header_blocks = parse_blocks( $header_template_part->content ); foreach ( $header_blocks as $block_key => $block ) { if ( !empty( $block['attrs']['position'] ) && in_array( $block['attrs']['position'], array( 'position-fixed', 'position-absolute' ) ) ) { $position = true; } } } $is_first_strip = false; if ( $position && $lightspeed_block_order == 1 ) $is_first_strip = true; return $is_first_strip; } function lightspeed_get_block_styles( $is_first_strip, $padding, $padding_top, $mobile_padding, $mobile_padding_top ) { $styles = ' .' . lightspeed_get_block_id() . '.areoi-lightspeed-block, .' . lightspeed_get_block_id() . ' .areoi-background-pattern-media { padding: ' . $mobile_padding . 'px 0; padding-top: ' . $mobile_padding_top . 'px; } .' . lightspeed_get_block_id() . '.areoi-lightspeed-block img, .' . lightspeed_get_block_id() . '.areoi-lightspeed-block video { display: block; } .' . lightspeed_get_block_id() . '.areoi-lightspeed-block > div.container > .row:not(.block-editor-block-preview__content-iframe .row), .' . lightspeed_get_block_id() . '.areoi-lightspeed-block > div.container-fluid > .row:not(.block-editor-block-preview__content-iframe .row) { min-height: calc( ' . lightspeed_get_attribute( 'size', '100vh' ) . ' - ' . ( $mobile_padding + $mobile_padding_top ) . 'px ); } @media only screen and (min-width: ' . areoi2_get_option( 'areoi-layout-grid-grid-breakpoint-lg', '992px' ) . ') { .' . lightspeed_get_block_id() . '.areoi-lightspeed-block, .' . lightspeed_get_block_id() . ' .areoi-background-pattern-media { padding: ' . $padding . 'px 0; padding-top: ' . $padding_top . 'px; } .' . lightspeed_get_block_id() . '.areoi-lightspeed-block > div.container > .row:not(.block-editor-block-preview__content-iframe .row), .' . lightspeed_get_block_id() . '.areoi-lightspeed-block > div.container-fluid > .row:not(.block-editor-block-preview__content-iframe .row) { min-height: calc( ' . lightspeed_get_attribute( 'size', '100vh' ) . ' - ' . ( $padding + $padding_top ) . 'px ); } } '; $mask = null; if ( lightspeed_get_attribute( 'mask', false ) ) $mask = lightspeed_get_attribute( 'mask', false ); $mask_template = lightspeed_get_masks_directory_uri( $mask ); if ( $mask ) { $styles .= ' .' . lightspeed_get_block_id() . '.areoi-lightspeed-block .areoi-has-mask { mask-image: url(' . $mask_template . '); -webkit-mask-image: url(' . $mask_template . '); } '; } $introduction_color = lightspeed_get_attribute( 'introduction_color', lightspeed_get_default_color( 'text' ) ); $link_color = lightspeed_get_theme_color( $introduction_color ); $styles .= ' .' . lightspeed_get_block_id() . '.areoi-lightspeed-block a:not(.btn) { color: ' . $link_color . '; } .' . lightspeed_get_block_id() . '.areoi-lightspeed-block .bg-dark a:not(.btn) { color: ' . lightspeed_get_theme_color( 'light' ) . '; } .' . lightspeed_get_block_id() . '.areoi-lightspeed-block .bg-light a:not(.btn) { color: ' . lightspeed_get_theme_color( 'dark' ) . '; } '; return $styles; } function lightspeed_get_divider( $block_order ) { $divider = areoi2_get_option( 'areoi-lightspeed-styles-strip-divider', 'none.svg' ); if ( $block_order == 1 ) $divider = 'none.svg'; if ( lightspeed_get_attribute( 'divider', false ) ) $divider = lightspeed_get_attribute( 'divider', false ); return $divider; } function lightspeed_get_divider_styles( $block_order ) { $divider = null; if ( $block_order == 1 ) $divider = 'none.svg'; if ( lightspeed_get_attribute( 'divider', false ) ) $divider = lightspeed_get_attribute( 'divider', false ); $divider_template = lightspeed_get_dividers_directory_uri( $divider ); $divider_styles = ''; if ( $divider ) { $divider_styles .= ' mask-image: url(' . $divider_template . '); -webkit-mask-image: url(' . $divider_template . '); '; } return $divider_styles; } function lightspeed_set_attribute( $key, $value ) { global $lightspeed_attributes; $lightspeed_attributes[$key] = $value; } function lightspeed_get_attribute( $key, $default = null ) { global $lightspeed_attributes; if ( isset( $lightspeed_attributes[$key] ) && ( !empty( $lightspeed_attributes[$key] ) || $lightspeed_attributes[$key] === false ) && $lightspeed_attributes[$key] !== 'Default' ) { return $lightspeed_attributes[$key]; } return $default; } function lightspeed_attribute( $key, $default = null ) { echo lightspeed_get_attribute( $key, $default ); } function lightspeed_get_block_id_append() { global $lightspeed_attributes; if ( !empty( $lightspeed_attributes['block_id'] ) ) { return $lightspeed_attributes['block_id']; } return md5( serialize( $lightspeed_attributes ) . date( 'H:i:s' ) ); } function lightspeed_get_block_id() { return 'block-' . lightspeed_get_block_id_append(); } function lightspeed_block_id() { echo lightspeed_get_block_id(); } function lightspeed_get_block_classes( $block ) { $classes = array(); $classes[] = lightspeed_get_block_id(); $classes[] = 'areoi-lightspeed-block'; $classes[] = 'areoi-lightspeed-' . $block; $classes[] = 'areoi-divider'; if ( lightspeed_get_attribute( 'align', false ) ) { $classes[] = 'align' . lightspeed_get_attribute( 'align', false ); } $divider = areoi2_get_option( 'areoi-lightspeed-styles-strip-divider', false ); if ( $divider && $divider != 'none.svg' ) { $classes[] = 'areoi-divider-styled'; } $pattern = areoi2_get_option( 'areoi-lightspeed-styles-strip-pattern', false ); if ( $pattern && !empty( lightspeed_get_attribute( 'exclude_pattern', false ) ) ) { $classes[] = 'areoi-pattern-none'; } $transition = areoi2_get_option( 'areoi-lightspeed-transition-transition', false ); if ( $transition && !empty( lightspeed_get_attribute( 'exclude_transition', false ) ) ) { $classes[] = 'areoi-transition-none'; } $parallax = areoi2_get_option( 'areoi-lightspeed-parallax-parallax', false ); if ( $parallax && !empty( lightspeed_get_attribute( 'exclude_parallax', false ) ) ) { $classes[] = 'areoi-parallax-none'; } if ( lightspeed_get_attribute( 'utilities_bg', null ) && lightspeed_get_attribute( 'utilities_bg', null ) != 'Default' ) $classes[] = lightspeed_get_attribute( 'utilities_bg', null ); if ( lightspeed_get_attribute( 'utilities_text', null ) && lightspeed_get_attribute( 'utilities_text', null ) != 'Default' ) $classes[] = lightspeed_get_attribute( 'utilities_text', null ); if ( lightspeed_get_attribute( 'utilities_border', null ) && lightspeed_get_attribute( 'utilities_border', null ) != 'Default' ) $classes[] = lightspeed_get_attribute( 'utilities_border', null ); return implode( ' ', $classes ); } function lightspeed_get_media_col_class() { $media_fit = lightspeed_get_attribute( 'media_fit', 'cover' ); $classes = array(); $classes[] = 'areoi-media-col'; $classes[] = 'areoi-media-col-' . $media_fit; return implode( ' ', $classes ); } function lightspeed_media_col_class() { echo lightspeed_get_media_col_class(); } function lightspeed_block_classes( $block ) { echo implode( ' ', lightspeed_get_block_classes( $block ) ); } function lightspeed_get_template_directory( $block, $filename ) { $template = ''; $theme_dir = get_template_directory() . '/all-bootstrap-blocks/lightspeed/' . $block . '/' . $filename; $theme_dir_custom = get_template_directory() . '/all-bootstrap-blocks/lightspeed/custom/' . $block . '/' . $filename; $child_dir = get_stylesheet_directory() . '/all-bootstrap-blocks/lightspeed/' . $block . '/' . $filename; $child_custom_dir = get_stylesheet_directory() . '/all-bootstrap-blocks/lightspeed/custom/' . $block . '/' . $filename; if ( file_exists( $child_dir ) ) { $template = $child_dir; } elseif ( file_exists( $child_custom_dir ) ) { $template = $child_custom_dir; } elseif ( file_exists( $theme_dir ) ) { $template = $theme_dir; } elseif ( file_exists( $theme_dir_custom ) ) { $template = $theme_dir_custom; } else { $template = AREOI__PLUGIN_LIGHTSPEED_DIR . 'blocks/' . $block . '/' . $filename; } return $template; } function lightspeed_get_content_directory( $filename ) { $template = ''; $theme_dir = get_template_directory() . '/all-bootstrap-blocks/lightspeed/content/' . $filename; $child_dir = get_stylesheet_directory() . '/all-bootstrap-blocks/lightspeed/content/' . $filename; if ( file_exists( $child_dir ) ) { $template = $child_dir; } elseif ( file_exists( $theme_dir ) ) { $template = $theme_dir; } else { $template = AREOI__PLUGIN_LIGHTSPEED_DIR . 'content/' . $filename; } return $template; } function lightspeed_get_patterns_directory( $filename ) { $template = ''; $theme_dir = get_template_directory() . '/all-bootstrap-blocks/lightspeed/patterns/' . $filename; $child_dir = get_stylesheet_directory() . '/all-bootstrap-blocks/lightspeed/patterns/' . $filename; if ( file_exists( $child_dir ) ) { $template = $child_dir; } elseif ( file_exists( $theme_dir ) ) { $template = $theme_dir; } else { $template = AREOI__PLUGIN_LIGHTSPEED_DIR . 'patterns/' . $filename; } return $template; } function lightspeed_get_dividers_directory_uri( $filename ) { $template = ''; $theme_dir = get_template_directory() . '/all-bootstrap-blocks/lightspeed/dividers/' . $filename; $theme_uri = get_template_directory_uri() . '/all-bootstrap-blocks/lightspeed/dividers/' . $filename; $child_dir = get_stylesheet_directory() . '/all-bootstrap-blocks/lightspeed/dividers/' . $filename; $child_theme_uri = get_stylesheet_directory_uri() . '/all-bootstrap-blocks/lightspeed/dividers/' . $filename; if ( file_exists( $child_dir ) ) { $template = $child_theme_uri; } elseif ( file_exists( $theme_dir ) ) { $template = $theme_uri; } else { $template = AREOI__PLUGIN_LIGHTSPEED_URI . 'dividers/' . $filename; } return $template; } function lightspeed_get_masks_directory_uri( $filename ) { $template = ''; $theme_dir = get_template_directory() . '/all-bootstrap-blocks/lightspeed/masks/' . $filename; $theme_uri = get_template_directory_uri() . '/all-bootstrap-blocks/lightspeed/masks/' . $filename; $child_dir = get_stylesheet_directory() . '/all-bootstrap-blocks/lightspeed/masks/' . $filename; $child_theme_uri = get_stylesheet_directory_uri() . '/all-bootstrap-blocks/lightspeed/masks/' . $filename; if ( file_exists( $child_dir ) ) { $template = $child_theme_uri; } elseif ( file_exists( $theme_dir ) ) { $template = $theme_uri; } else { $template = AREOI__PLUGIN_LIGHTSPEED_URI . 'masks/' . $filename; } return $template; } function lightspeed_get_theme_color( $col ) { global $areoi_theme_colors; $theme_colors = $areoi_theme_colors; if ( !is_array( $col ) ) { $clean_col = str_replace( 'bg-', '', $col ); $clean_col = str_replace( 'text-', '', $clean_col ); $clean_col = str_replace( 'border-', '', $clean_col ); $clean_col = str_replace( 'hex-', '', $clean_col ); if ( isset( $theme_colors[$clean_col] ) ) { $col = $theme_colors[$clean_col]; } } return $col; } function lightspeed_hex_to_rgb( $hex ) { $R1 = hexdec(substr($hex, 1, 2)); $G1 = hexdec(substr($hex, 3, 2)); $B1 = hexdec(substr($hex, 5, 2)); return [ 'r' => $R1, 'g' => $G1, 'b' => $B1, ]; } function lightspeed_get_contrast_color( $col ) { if ( !is_array( $col ) ) { $col = lightspeed_get_theme_color( $col ); } // hex_color RGB if ( !is_array( $col ) && str_starts_with( $col, '#' ) ) { $rgb = lightspeed_hex_to_rgb( $col ); $R1 = $rgb['r']; $G1 = $rgb['g']; $B1 = $rgb['b']; } else { $R1 = $col['r']; $G1 = $col['g']; $B1 = $col['b']; } // Black RGB $blackColor = "#000000"; $R2BlackColor = hexdec(substr($blackColor, 1, 2)); $G2BlackColor = hexdec(substr($blackColor, 3, 2)); $B2BlackColor = hexdec(substr($blackColor, 5, 2)); // Calc contrast ratio $L1 = 0.2126 * pow($R1 / 255, 2.2) + 0.7152 * pow($G1 / 255, 2.2) + 0.0722 * pow($B1 / 255, 2.2); $L2 = 0.2126 * pow($R2BlackColor / 255, 2.2) + 0.7152 * pow($G2BlackColor / 255, 2.2) + 0.0722 * pow($B2BlackColor / 255, 2.2); $contrastRatio = 0; if ($L1 > $L2) { $contrastRatio = (int)(($L1 + 0.05) / ($L2 + 0.05)); } else { $contrastRatio = (int)(($L2 + 0.05) / ($L1 + 0.05)); } // If contrast is more than 5, return black color if ($contrastRatio > 5) { return '#000000'; } else { // if not, return white color. return '#FFFFFF'; } } function lightspeed_get_default_color( $type, $override_color = null ) { $color = $type == 'btn' ? 'btn-primary' : null; $contrast = null; if ( lightspeed_get_attribute( 'background_display', null ) ) { if ( lightspeed_get_attribute( 'background_display_overlay', null ) && lightspeed_get_attribute( 'background_overlay', null ) ) { $contrast = lightspeed_get_contrast_color( lightspeed_get_attribute( 'background_overlay', null )['rgb'] ); } elseif ( lightspeed_get_attribute( 'background_utility', null ) ) { $contrast = lightspeed_get_contrast_color( lightspeed_get_attribute( 'background_utility', null ) ); } elseif ( lightspeed_get_attribute( 'background_color', null ) ) { $contrast = lightspeed_get_contrast_color( lightspeed_get_attribute( 'background_color', null )['rgb'] ); } elseif ( lightspeed_get_attribute( 'main_background_color', null ) ) { $contrast = lightspeed_get_contrast_color( lightspeed_get_attribute( 'main_background_color', null )['rgb'] ); } } if ( $override_color ) { if ( $override_color == 'bg-transparent' && lightspeed_get_attribute( 'block_type', null ) == 'header' ) { $contrast = lightspeed_get_contrast_color( 'bg-primary' ); } else { $contrast = lightspeed_get_contrast_color( $override_color ); } } if ( $contrast == '#FFFFFF' ) { $color = $type != 'logo' ? $type . '-light' : 'light'; } elseif ( $contrast == '#000000' ) { $color = $type != 'logo' ? $type . '-dark' : 'dark'; } if ( $type == 'hex' ) $color = lightspeed_get_theme_color( $color ); return $color; } function lightspeed_get_logo( $type, $color = null ) { $logos = array( 'dark' => areoi2_get_option( 'areoi-lightspeed-company-logo-dark', null ), 'light' => areoi2_get_option( 'areoi-lightspeed-company-logo-light', null ), ); $icons = array( 'dark' => areoi2_get_option( 'areoi-lightspeed-company-icon-dark', null ), 'light' => areoi2_get_option( 'areoi-lightspeed-company-icon-light', null ), ); if ( !$color ) { $color = lightspeed_get_default_color( 'logo' ); } $content = ''; switch ( $type ) { case 'icon': if ( !empty( $icons[$color] ) ) { $content .= ' Go back to Homepage '; } break; default: if ( !empty( $logos[$color] ) ) { $content .= ' Go back to Homepage '; } break; } return $content; } function lightspeed_logo( $color = 'dark' ) { if ( !empty( lightspeed_get_logo( lightspeed_get_attribute( 'logo', null ), lightspeed_get_attribute( 'logo_color', $color ) ) ) ) : ?> ' . lightspeed_get_logo( 'icon' ) . ' '; } if ( $sub_heading && $original_level < 3 ) { $content .= '

' . $sub_heading . '

'; } if ( trim( $heading ) || trim( $sub_heading ) ) { switch ( $heading_template ) { case 'basic': case 'dotted': case 'wide': $content .= ' ' . $heading . '
'; break; case 'basic-top': case 'dotted-top': case 'wide-top': $content .= '
' . $heading . ' '; break; default: $content .= ' ' . $heading . ' '; break; } } } return $content; } function lightspeed_heading( $level, $item = null, $level_class = '' ) { echo lightspeed_get_heading( $level, $item, $level_class ); } function lightspeed_get_introduction( $item = null ) { $content = ''; $limit = 400; $has_cta = lightspeed_get_attribute( 'cta', null ); $introduction = lightspeed_get_attribute( 'introduction', null ); if ( lightspeed_get_attribute( 'is_post_excerpt', null ) ) { if ( is_single() || is_page() ) $introduction = '

' . get_the_excerpt() . '

'; if ( is_archive() ) $introduction = get_the_archive_description(); } $introduction_color = lightspeed_get_attribute( 'introduction_color', lightspeed_get_default_color( 'text' ) ); $introduction_class = ''; $modal_id = 'modal-' . lightspeed_get_block_id(); $heading = lightspeed_get_attribute( 'heading', 'Continue Reading' ); if ( $item ) { $has_cta = $item['cta']; $introduction = $item['introduction']; if ( !empty( $item['background_color'] ) ) $introduction_color = lightspeed_get_default_color( 'text', $item['background_color'] ); if ( !empty( $item['introduction_color'] ) ) $introduction_color = $item['introduction_color']; $introduction_class = ''; $modal_id .= '-item-' . $item['id']; $heading = !empty( $item['heading'] ) ? $item['heading'] : 'Continue Reading'; $limit = 220; } $introduction_strlen = strlen( wp_strip_all_tags( $introduction ) ); $introduction_short = $introduction; if ( ( lightspeed_get_attribute( 'include_read_more', null ) || ( isset( $item['include_read_more'] ) && $item['include_read_more'] ) ) && $introduction_strlen > ($limit*2) ) { $introduction_short = substr( strip_tags( str_replace( '

', "



", $introduction ), array( '
' ) ), 0, $limit ); $introduction_short .= '... Continue reading.'; } if ( $introduction != $introduction_short ) { $introduction_short = '

' . $introduction_short . '

'; global $areoi_introduction_modals; $areoi_introduction_modals[$modal_id] = ' '; } if ( strip_tags( $introduction ) ) { $content .= '
' . $introduction_short . ' ' . ( $has_cta ? '' : '' ) . '
'; } return $content; } function lightspeed_introduction( $item = null ) { echo lightspeed_get_introduction( $item ); } function lightspeed_get_cta( $item = null, $is_simple = false ) { $content = ''; $btn_class = 'btn'; $include = lightspeed_get_attribute( 'include_cta', true ); $href = lightspeed_get_href( $item ); $size = lightspeed_get_attribute( 'cta_size', 'btn-lg' ); $color = lightspeed_get_attribute( 'cta_color', lightspeed_get_default_color( 'btn' ) ); $cta = lightspeed_get_attribute( 'cta', null ); if ( $item ) { $include = !empty( $item['include_cta'] ) ? $item['include_cta'] : ''; $size = !empty( $item['cta_size'] ) ? $item['cta_size'] : ''; $cta = !empty( $item['cta'] ) ? $item['cta'] : ''; if ( !empty( $item['background_color'] ) ) $color = lightspeed_get_default_color( 'btn', $item['background_color'] ); if ( !empty( $item['cta_color'] ) ) $color = $item['cta_color']; } if ( $is_simple ) { $btn_class = 'btn-simple'; $color = str_replace( 'btn', 'text', $color ); } if ( $include && $cta ) { $content .= ' ' . lightspeed_get_btn_content( $cta ) . ' '; } return $content; } function lightspeed_cta( $item = null, $is_simple = false ) { echo lightspeed_get_cta( $item, $is_simple ); } function lightspeed_get_search() { $color = lightspeed_get_attribute( 'cta_color', lightspeed_get_default_color( 'btn' ) ); ?> post_author; $author = get_the_author_meta( 'display_name', $author_id ); $author_url = get_author_posts_url( $author_id ); return '' . ( $author ? $author : __( 'Author Display Name' ) ) . ''; } function lightspeed_author_url( $color = null ) { echo lightspeed_get_author_url( $color ); } function lightspeed_get_media( $item = null ) { $content = ''; $featured_image_id = get_post_thumbnail_id(); $featured_image = wp_get_attachment_image_src( $featured_image_id, 'full' ); $video = lightspeed_get_attribute( 'video', null ); $image = lightspeed_get_attribute( 'image', null ); if ( lightspeed_get_attribute( 'is_post_image', null ) && $featured_image ) { list( $src, $width, $height ) = $featured_image; $image = [ 'url' => $src, 'width' => $width, 'height' => $height, 'alt' => '' ]; $video = null; } if ( $item ) { $video = !empty( $item['video'] ) ? $item['video'] : null; $image = !empty( $item['image'] ) ? $item['image'] : null; } if ( $video ) { $content .= ''; } elseif ( $image ) { $content .= '' . $image['alt'] . ''; } return $content; } function lightspeed_media( $item = null ) { echo lightspeed_get_media( $item ); } function lightspeed_get_btn_content( $content ) { $selected_icon = areoi2_get_option( 'areoi-lightspeed-styles-btn-icon', null ); $icon = ''; if ( $selected_icon ) { $icon = ' '; } return $content . ' ' . $icon; } function lightspeed_get_href( $item = null ) { $link = ''; $url = lightspeed_get_attribute( 'url', null ); $include_cta = lightspeed_get_attribute( 'include_cta', null ); $open_in_new_tab = lightspeed_get_attribute( 'opensInNewTab', null ); if ( $item ) { $url = $item['url']; $include_cta = $item['include_cta']; $open_in_new_tab = $item['opensInNewTab']; } if ( $url && $include_cta ) { $link = ' href="' . $url . '"'; if ( $open_in_new_tab ) $link .= ' target="_blank"'; } return $link; } function lightspeed_href( $item = null ) { echo lightspeed_get_href( $item ); } function lightspeed_get_stretched_link( $item = null ) { $link = ''; $href = lightspeed_get_href( $item ); if ( $href ) $link .= ''; return $link; } function lightspeed_stretched_link( $item = null ) { echo lightspeed_get_stretched_link( $item ); } function lightspeed_btn_content() { echo lightspeed_get_btn_content(); } function lightspeed_spacer( $default ) { if ( lightspeed_get_attribute( 'media_shape' ) == 'square' ) { lightspeed_square_spacer(); } elseif ( lightspeed_get_attribute( 'media_shape' ) == 'rectangle' ) { lightspeed_rectangle_spacer(); } elseif ( lightspeed_get_attribute( 'media_shape' ) == 'tall-rectangle' ) { lightspeed_tall_rectangle_spacer(); } else { if ( $default == 'square' ) { lightspeed_square_spacer(); } else { lightspeed_rectangle_spacer(); } } } function lightspeed_get_square_spacer() { return ' '; } function lightspeed_square_spacer() { echo lightspeed_get_square_spacer(); } function lightspeed_rectangle_spacer() { echo ' '; } function lightspeed_tall_rectangle_spacer() { echo ' '; } function lightspeed_get_posts() { $post_type = lightspeed_get_attribute( 'post_type', 'post' ); $display_posts = lightspeed_get_attribute( 'display_posts', 'selected' ); $posts_per_page = lightspeed_get_attribute( 'posts_per_page', '8' ); $orderby = lightspeed_get_attribute( 'orderby', 'title' ); $order = lightspeed_get_attribute( 'order', 'asc' ); $post_ids = lightspeed_get_attribute( 'post_ids', array() ); $show_all = in_array( 'all', $post_ids ); $post__in = $post_ids; $post_parent__in = array(); $post_parent__not_in = array(); if ( $post_type == 'child-pages' || $display_posts == 'children' ) { $post_parent__in = $post_ids; $post__in = array(); } if ( $show_all ) { $post__in = array(); $post_parent__in = array('0'); } if ( $show_all && $display_posts == 'children' ) { $post__in = array(); $post_parent__in = array(); $post_parent__not_in = array('0'); } $paged = 1; if ( !empty( $_GET['paginate'] ) && lightspeed_get_attribute( 'include_pagination', false ) ) { $paged = esc_attr( $_GET['paginate'] ); } $args = array( 'posts_per_page' => $posts_per_page, 'post_type' => $post_type, 'post_parent__in' => $post_parent__in, 'post_parent__not_in'=> $post_parent__not_in, 'post__in' => $post__in, 'orderby' => $orderby, 'order' => $order, 'paged' => $paged, 'ignore_sticky_posts' => 1 ); if ( lightspeed_get_attribute( 'is_post_query', false ) ) { global $wp_query; return $wp_query; } else { return new WP_Query( $args ); } } function lightspeed_post_pagination( $the_query ) { if ( lightspeed_get_attribute( 'include_pagination', false ) ) : if ( lightspeed_get_attribute( 'is_post_query', false ) ) { $paged = !empty( $_GET['paged'] ) ? esc_attr( $_GET['paged'] ) : 1; $pages = paginate_links( array( 'format' => '?paged=%#%', 'current' => max( 1, $paged ), 'total' => $the_query->max_num_pages, ) ); } else { $paged = !empty( $_GET['paginate'] ) ? esc_attr( $_GET['paginate'] ) : 1; $pages = paginate_links( array( 'format' => '?paginate=%#%', 'current' => max( 1, $paged ), 'total' => $the_query->max_num_pages, ) ); } $pages = str_replace( 'page-numbers', 'page-numbers btn ' . lightspeed_get_attribute( 'pagination_color', lightspeed_get_default_color( 'btn' ) ), $pages ); $pages = str_replace( 'current', 'current active', $pages ); ?>
' . get_the_title() . ''; } return $content; } function lightspeed_get_post_introduction( $background_color = null ) { $content = ''; $color = lightspeed_get_attribute( 'heading_color', lightspeed_get_default_color( 'text' ) ); if ( !empty( $background_color ) ) $color = lightspeed_get_default_color( 'text', $background_color ); if ( !empty( lightspeed_get_attribute( 'post_excerpt_color', null ) ) ) $color = lightspeed_get_attribute( 'post_excerpt_color', null ); if ( lightspeed_get_attribute( 'include_excerpt', true ) ) { $content .= '

' . get_the_excerpt() . '

'; } return $content; } function lightspeed_get_post_permalink() { $content = ''; if ( lightspeed_get_attribute( 'include_permalink', true ) ) { $content .= ''; } return $content; } function lightspeed_item_icon( $item ) { $icon = ''; if ( !empty( $item['include_icon'] ) ) { $icon = '
' . lightspeed_get_square_spacer() . '
'; } return $icon; } function lightspeed_item( $item, $is_post = false, $is_column = false, $is_background = false ) { if ( $is_post ) { global $post; $background_color = !empty( lightspeed_get_attribute( 'post_background_color', null ) ) ? lightspeed_get_attribute( 'post_background_color', null ) : ''; if ( $is_background && !$background_color ) $background_color = lightspeed_get_default_color( 'bg', lightspeed_get_attribute( 'background_utility' ) ); $item['background_color'] = $background_color; $media = get_the_post_thumbnail() && lightspeed_get_attribute( 'include_media', true ) ? get_the_post_thumbnail() : ''; $heading = lightspeed_get_post_heading( $background_color ); $introduction = lightspeed_get_post_introduction( $background_color ); $stretched_link = lightspeed_get_post_permalink(); $item['include_cta'] = true; $item['cta'] = __( 'Read more', AREOI__TEXT_DOMAIN ); $item['opensInNewTab'] = false; $item['url'] = get_the_permalink(); $cta = lightspeed_get_cta( $item, true ); } else { $background_color = !empty( $item['background_color'] ) ? $item['background_color'] : ''; if ( $is_background && !$background_color ) $background_color = lightspeed_get_default_color( 'bg', lightspeed_get_attribute( 'background_utility' ) ); $item['background_color'] = $background_color; $media = lightspeed_get_media( $item ); $heading = lightspeed_get_heading( 3, $item ); $introduction = lightspeed_get_introduction( $item ); $cta = lightspeed_get_cta( $item, true ); $stretched_link = lightspeed_stretched_link( $item ); } if ( !$media && !$is_column && areoi2_get_option( 'areoi-lightspeed-company-include-lightspeed', false ) && !lightspeed_item_icon( $item ) ) { $media = lightspeed_get_media( array( 'image' => lightspeed_get_placeholder_images( 'rand' ) ) ); } $media_fit = lightspeed_get_attribute( 'media_fit', 'cover' ); $rounded = ''; if ( !$is_column ) $rounded = 'rounded overflow-hidden'; ?>

', $company_address ) : $company_address ?>

$item ) : ?>
$item ) : $heading_color = lightspeed_get_attribute( 'heading_color', lightspeed_get_default_color( 'text' ) ); if ( !empty( $item['heading_color'] ) ) $heading_color = $item['heading_color']; $border_color = str_replace( 'text', 'border', lightspeed_get_attribute( 'heading_color', lightspeed_get_default_color( 'border' ) ) ); ?>

$item ) : ?>
$item ) : ?>
<?php echo $media['alt'] ?>