areoi_get_option_color( AREOI__PREPEND . '-customize-theme-colors-primary', '#0d6efd' ), 'secondary' => areoi_get_option_color( AREOI__PREPEND . '-customize-theme-colors-secondary', '#6c757d' ), 'success' => areoi_get_option_color( AREOI__PREPEND . '-customize-theme-colors-success', '#198754' ), 'info' => areoi_get_option_color( AREOI__PREPEND . '-customize-theme-colors-info', '#0dcaf0' ), 'warning' => areoi_get_option_color( AREOI__PREPEND . '-customize-theme-colors-warning', '#ffc107' ), 'danger' => areoi_get_option_color( AREOI__PREPEND . '-customize-theme-colors-danger', '#dc3545' ), 'light' => areoi_get_option_color( AREOI__PREPEND . '-customize-theme-colors-light', '#f8f9fa' ), 'dark' => areoi_get_option_color( AREOI__PREPEND . '-customize-theme-colors-dark', '#212529' ), 'body' => areoi_get_option_color( AREOI__PREPEND . '-customize-body-body-bg', '#ffffff' ), 'transparent' => '#ffffff', ); function areoi_get_class_name_str( $classes ) { $class_string = ''; if ( is_array( $classes) ) { foreach ( $classes as $class_key => $class ) { if ( !$class || $class == 'Default' ) { continue; } $class_string .= $class . ' '; } } return esc_attr( trim( $class_string ) ); } function areoi_get_display_class_str( $attributes, $display ) { $devices = array( 'xs', 'sm', 'md', 'lg', 'xl', 'xxl' ); $class_string = ''; $prev_display = false; foreach ( $devices as $device ) { if ( empty( $attributes['hide_' . $device] ) ) { // continue; } $attr = !empty( $attributes['hide_' . $device] ) ? $attributes['hide_' . $device] : null; if ( !empty( $attr ) ) { $class_string .= ' d-' . ( $device == 'xs' ? '' : $device . '-' ) . 'none'; $prev_display = true; } elseif ( $prev_display ) { $class_string .= ' d-' . ( $device == 'xs' ? '' : $device . '-' ) . $display; $prev_display = false; } } return esc_attr( trim( $class_string ) ); } function areoi_get_background_display_class_str( $attributes, $display ) { $devices = array( 'xs', 'sm', 'md', 'lg', 'xl', 'xxl' ); $class_string = ''; $prev_display = false; foreach ( $devices as $device ) { if ( empty( $attributes['background_hide_' . $device] ) ) { // continue; } $attr = !empty( $attributes['background_hide_' . $device] ) ? $attributes['background_hide_' . $device] : null; if ( !empty( $attr ) ) { $class_string .= ' d-' . ( $device == 'xs' ? '' : $device . '-' ) . 'none'; $prev_display = true; } elseif ( $prev_display ) { $class_string .= ' d-' . ( $device == 'xs' ? '' : $device . '-' ) . $display; $prev_display = false; } } return esc_attr( trim( $class_string ) ); } function areoi_return_id( $attributes ) { return ( ( !empty( $attributes['anchor'] ) ) ? 'id="' . esc_attr( $attributes['anchor'] ) . '"' : '' ); } function areoi_get_display_block_class_str( $attributes, $display ) { $devices = array( 'xs', 'sm', 'md', 'lg', 'xl', 'xxl' ); $class_string = ''; $prev_display = false; foreach ( $devices as $device ) { $attr = $attributes['block_' . $device]; if ( !empty( $attr ) ) { $class_string .= ' d-' . ( $device == 'xs' ? '' : $device . '-' ) . 'block'; $prev_display = true; } elseif ( $prev_display ) { $class_string .= ' d-' . ( $device == 'xs' ? '' : $device . '-' ) . $display; $prev_display = false; } } return esc_attr( trim( $class_string ) ); } function areoi_get_utilities_classes( $attributes ) { $string = ' '; if ( !empty( $attributes['utilities_bg'] ) && $attributes['utilities_bg'] != 'Default' ) $string .= ' ' . $attributes['utilities_bg']; if ( !empty( $attributes['utilities_text'] ) && $attributes['utilities_text'] != 'Default' ) $string .= ' ' . $attributes['utilities_text']; if ( !empty( $attributes['utilities_border'] ) && $attributes['utilities_border'] != 'Default' ) $string .= ' ' . $attributes['utilities_border']; return esc_attr( $string ); } function areoi_format_block_id( $block_id ) { return esc_attr( 'block-' . $block_id ); } function areoi_get_rgba_str( $rgba ) { return esc_attr( trim( 'rgba(' . $rgba['r'] . ', ' . $rgba['g'] . ', ' . $rgba['b'] . ',' . $rgba['a'] . ')' ) ); } function areoi_generate_breadcrumbs( $attributes = array() ) { global $post,$wp_query; $breadcrumbs = array(); if ( $post->post_parent ) { $breadcrumbs = areoi_generate_breadcrumbs_parent( $breadcrumbs, $post->post_parent ); $title = __( 'Home', AREOI__TEXT_DOMAIN ); $front_page_id = (int) get_option( 'page_on_front' ); if ( $front_page_id > 0 && !empty( $attributes['is_front_page'] ) ) { $title = get_the_title( $front_page_id ); } $breadcrumbs[] = array( 'permalink' => home_url(), 'label' => $title, 'active' => false ); } $breadcrumbs = array_reverse( $breadcrumbs ); if ( get_permalink( $post->ID ) != home_url() ) { $breadcrumbs[] = array( 'permalink' => get_the_permalink( $post->ID ), 'label' => get_the_title( $post->ID ), 'active' => true ); } else { $breadcrumbs[0]['active'] = true; } return $breadcrumbs; } function areoi_generate_breadcrumbs_parent( $breadcrumbs, $parent_id ) { $parent = get_post( $parent_id ); if ( get_permalink( $parent->ID ) != home_url() ) { $breadcrumbs[] = array( 'permalink' => get_the_permalink( $parent->ID ), 'label' => get_the_title( $parent->ID ), 'active' => false ); } if ( $parent->post_parent ) { return areoi_generate_breadcrumbs_parent( $breadcrumbs, $parent->post_parent ); } return $breadcrumbs; } function areoi_enqueue_css( $enqueues ) { foreach ( $enqueues as $enqueue_key => $enqueue ) { wp_enqueue_style( $enqueue_key, AREOI__PLUGIN_URI . $enqueue, array(), filemtime( AREOI__PLUGIN_DIR . $enqueue ) ); } } function areoi_enqueue_js( $enqueues ) { foreach ( $enqueues as $enqueue_key => $enqueue ) { wp_enqueue_script( $enqueue_key, AREOI__PLUGIN_URI . $enqueue['path'], $enqueue['includes'], filemtime( AREOI__PLUGIN_DIR . $enqueue['path'] ), true ); } } function areoi_get_original_theme_json() { $has_theme_json = null; $theme_json_path = get_stylesheet_directory() . '/theme.json'; if ( file_exists( $theme_json_path ) ) $has_theme_json = json_decode( file_get_contents( $theme_json_path ), true ); return $has_theme_json; } function areoi_get_theme_json() { $has_theme_json = null; $theme_json_path = get_stylesheet_directory() . '/theme.json'; if ( file_exists( $theme_json_path ) ) { $has_theme_json = json_decode( file_get_contents( $theme_json_path ), true ); $settings = !empty( $has_theme_json['settings'] ) ? areoi_preset_properties_theme_json( $has_theme_json['settings'], array(), array( 'settings' ) ) : array(); $styles = array( 'text' => 'Styles', 'children' => array() ); $styles['children'] = !empty( $has_theme_json['styles'] ) ? areoi_flatten_theme_json( $has_theme_json['styles'], array(), array( 'styles' ) ) : array(); $has_theme_json = array_merge( $settings, array( $styles ) ); } return $has_theme_json; } function areoi_get_theme_json_last_update() { $theme_json_path = get_stylesheet_directory() . '/theme.json'; return filemtime( $theme_json_path ); } function areoi_preset_properties_theme_json( $rows ) { $array = array(); if ( !empty( $rows ) ) { if ( !empty( $rows['color']['gradients'] ) ) { $group = array( 'text' => 'Gradient', 'children' => array() ); foreach ( $rows['color']['gradients'] as $row_key => $row ) { $var = 'settings!!color!!gradients!!' . $row_key . '!!gradient'; $group['children'][] = [ 'id' => $var, 'text' => ( !empty( $row['name'] ) ? $row['name'] : $row['slug'] ) ]; } $array[] = $group; } if ( !empty( $rows['color']['palette'] ) ) { $group = array( 'text' => 'Palette', 'children' => array() ); foreach ( $rows['color']['palette'] as $row_key => $row ) { $var = 'settings!!color!!palette!!' . $row_key . '!!color'; $group['children'][] = [ 'id' => $var, 'text' => ( !empty( $row['name'] ) ? $row['name'] : $row['slug'] ) ]; } $array[] = $group; } if ( !empty( $rows['typography']['fontFamilies'] ) ) { $group = array( 'text' => 'Font Families', 'children' => array() ); foreach ( $rows['typography']['fontFamilies'] as $row_key => $row ) { $var = 'settings!!typography!!fontFamilies!!' . $row_key . '!!fontFamily'; $group['children'][] = [ 'id' => $var, 'text' => ( !empty( $row['name'] ) ? $row['name'] : $row['slug'] ) ]; } $array[] = $group; } if ( !empty( $rows['typography']['fontSizes'] ) ) { $group = array( 'text' => 'Font Size', 'children' => array() ); foreach ( $rows['typography']['fontSizes'] as $row_key => $row ) { $var = 'settings!!typography!!fontSizes!!' . $row_key . '!!size'; $group['children'][] = [ 'id' => $var, 'text' => ( !empty( $row['name'] ) ? $row['name'] : $row['slug'] ) ]; } $array[] = $group; } if ( !empty( $rows['layout'] ) ) { $group = array( 'text' => 'Layout', 'children' => array() ); foreach ( $rows['layout'] as $row_key => $row ) { $var = 'settings!!layout!!' . $row_key; $group['children'][] = [ 'id' => $var, 'text' => $row_key . ': ' . $row ]; } $array[] = $group; } } return $array; } function areoi_flatten_theme_json( $rows, $array, $append ) { if ( !empty( $rows ) ) { foreach ( $rows as $child_rows_key => $child_rows ) { $new_append = $append; $new_append[] = $child_rows_key; $append_id = implode( '!!', $new_append ); $append_label = implode( ' > ', $new_append ); if ( in_array( $child_rows_key, array( 'slug', 'name' ) ) ) continue; if ( !is_array( $child_rows ) ) { $array[] = [ 'id' => $append_id, 'text' => $append_label ]; } else { $array = areoi_flatten_theme_json( $child_rows, $array, $new_append ); } } } return $array; } function areoi_get_theme_json_value( $value ) { $theme_json = areoi_get_original_theme_json(); $value = str_replace( 'theme-json-', '', $value ); $array = explode( '!!', $value ); $value = ''; if ( !empty( $array ) ) { foreach ( $array as $arr_key => $arr ) { if ( !empty( $theme_json[$arr] ) ) { $theme_json = $theme_json[$arr]; } if ( !empty( $theme_json['value'] ) ) { $value = $theme_json['value']; } } } return $theme_json; } function areoi_get_parent_block( $id ) { global $post; $all_blocks = parse_blocks( $post->post_content ); foreach ( $all_blocks as $block_key => $block ) { if ( !empty( $block['attrs']['block_id'] ) && $block['attrs']['block_id'] == $id ) return $block; } return null; } function areoi_get_prepend_content( $attributes ) { $prepend = ''; $prepend_row_class = trim( areoi_get_class_name_str( array( 'row', 'position-relative', ( empty( $attributes['hide_xs'] ) && !empty( $attributes['prepend_horizontal_align_xs'] ) ? $attributes['prepend_horizontal_align_xs'] : '' ), ( empty( $attributes['hide_sm'] ) && !empty( $attributes['prepend_horizontal_align_sm'] ) ? $attributes['prepend_horizontal_align_sm'] : '' ), ( empty( $attributes['hide_md'] ) && !empty( $attributes['prepend_horizontal_align_md'] ) ? $attributes['prepend_horizontal_align_md'] : '' ), ( empty( $attributes['hide_lg'] ) && !empty( $attributes['prepend_horizontal_align_lg'] ) ? $attributes['prepend_horizontal_align_lg'] : '' ), ( empty( $attributes['hide_xl'] ) && !empty( $attributes['prepend_horizontal_align_xl'] ) ? $attributes['prepend_horizontal_align_xl'] : '' ), ( empty( $attributes['hide_xxl'] ) && !empty( $attributes['prepend_horizontal_align_xxl'] ) ? $attributes['prepend_horizontal_align_xxl'] : '' ), )) ); $prepend_col_class = trim( areoi_get_class_name_str( array( 'col', ( empty( $attributes['hide_xs'] ) && !empty( $attributes['prepend_col_xs'] ) ? $attributes['prepend_col_xs'] : '' ), ( empty( $attributes['hide_sm'] ) && !empty( $attributes['prepend_col_sm'] ) ? $attributes['prepend_col_sm'] : '' ), ( empty( $attributes['hide_md'] ) && !empty( $attributes['prepend_col_md'] ) ? $attributes['prepend_col_md'] : '' ), ( empty( $attributes['hide_lg'] ) && !empty( $attributes['prepend_col_lg'] ) ? $attributes['prepend_col_lg'] : '' ), ( empty( $attributes['hide_xl'] ) && !empty( $attributes['prepend_col_xl'] ) ? $attributes['prepend_col_xl'] : '' ), ( empty( $attributes['hide_xxl'] ) && !empty( $attributes['prepend_col_xxl'] ) ? $attributes['prepend_col_xxl'] : '' ), ( empty( $attributes['hide_xs'] ) && !empty( $attributes['prepend_text_align_xs'] ) ? $attributes['prepend_text_align_xs'] : '' ), ( empty( $attributes['hide_sm'] ) && !empty( $attributes['prepend_text_align_sm'] ) ? $attributes['prepend_text_align_sm'] : '' ), ( empty( $attributes['hide_md'] ) && !empty( $attributes['prepend_text_align_md'] ) ? $attributes['prepend_text_align_md'] : '' ), ( empty( $attributes['hide_lg'] ) && !empty( $attributes['prepend_text_align_lg'] ) ? $attributes['prepend_text_align_lg'] : '' ), ( empty( $attributes['hide_xl'] ) && !empty( $attributes['prepend_text_align_xl'] ) ? $attributes['prepend_text_align_xl'] : '' ), ( empty( $attributes['hide_xxl'] ) && !empty( $attributes['prepend_text_align_xxl'] ) ? $attributes['prepend_text_align_xxl'] : '' ), ) ) ); $heading_color = !empty( $attributes['prepend_heading_color'] ) ? $attributes['prepend_heading_color'] : ''; $intro_color = !empty( $attributes['prepend_intro_color'] ) ? $attributes['prepend_intro_color'] : ''; if ( !empty( $attributes['prepend_display_heading'] ) || !empty( $attributes['prepend_display_intro'] ) ) { $heading_level = $attributes['prepend_heading_level']; if ( !in_array( $heading_level, ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] ) ) { $heading_level = 'h2'; } $prepend_heading = !empty( $attributes['prepend_display_heading'] ) && !empty( $attributes['prepend_heading'] ) ? '<' . $heading_level . ' class="' . $heading_color . '">' . wp_kses_post( $attributes['prepend_heading'] ) . '' . $heading_level . '>' : ''; $prepend_intro = !empty( $attributes['prepend_intro'] ) && !empty( $attributes['prepend_intro'] ) ? '
' . wp_kses_post( $attributes['prepend_intro'] ) . '
' : ''; $prepend .= '