ID, 'aytias_page_layout', true ); } // Fetch from customizer if everything else fails if( empty($page_layout) ){ $page_layout = aytias_get_option('global_sidebar_layout'); } return $page_layout; } endif; if ( ! function_exists( 'aytias_get_sidebar' ) ) : /** * Get Proper sidebar based on settings * * @since 1.0.0 * * @return string Sidebar */ function aytias_get_sidebar() { if(is_front_page()): $front_page_sidebar_enabled = aytias_get_option('front_page_enable_sidebar'); $hide_sidebar_mobile = aytias_get_option('hide_front_page_sidebar_mobile'); if($front_page_sidebar_enabled == true && is_active_sidebar( 'home-page-sidebar' )): ?> $width, 'height' => $height, 'crop' => $_wp_additional_image_sizes[ $_size ]['crop'], ); } } } if( true == $for_choice ){ $sizes['full'] = __( 'Full Image', 'aytias' ); } return $sizes; } endif; if ( ! function_exists( 'aytias_get_header_layouts' ) ) : /** * Returns header layout options. * * @since 1.0.0 * * @return array Options array. */ function aytias_get_header_layouts() { $options = apply_filters( 'aytias_header_layouts', array( 'header_style_1' => array( 'url' => get_template_directory_uri().'/assets/images/header1.png', 'label' => esc_html__( 'Header Style 1', 'aytias' ), ), 'header_style_3' => array( 'url' => get_template_directory_uri().'/assets/images/header3.png', 'label' => esc_html__( 'Header Style 3', 'aytias' ), ), ) ); return $options; } endif; if ( ! function_exists( 'aytias_get_footer_layouts' ) ) : /** * Returns footer layout options. * * @since 1.0.0 * * @return array Options array. */ function aytias_get_footer_layouts() { $options = apply_filters( 'aytias_footer_layouts', array( 'footer_layout_1' => array( 'url' => get_template_directory_uri().'/assets/images/footer-col-4.png', 'label' => esc_html__( 'Four Columns', 'aytias' ), ), 'footer_layout_2' => array( 'url' => get_template_directory_uri().'/assets/images/footer-col-3.png', 'label' => esc_html__( 'Three Columns', 'aytias' ), ), 'footer_layout_3' => array( 'url' => get_template_directory_uri().'/assets/images/footer-col-2.png', 'label' => esc_html__( 'Two Columns', 'aytias' ), ) ) ); return $options; } endif; if ( ! function_exists( 'aytias_get_general_layouts' ) ) : /** * Returns general layout options. * * @since 1.0.0 * * @return array Options array. */ function aytias_get_general_layouts() { $options = apply_filters( 'aytias_general_layouts', array( 'left-sidebar' => array( 'url' => get_template_directory_uri().'/assets/images/left_sidebar.png', 'label' => esc_html__( 'Left Sidebar', 'aytias' ), ), 'right-sidebar' => array( 'url' => get_template_directory_uri().'/assets/images/right_sidebar.png', 'label' => esc_html__( 'Right Sidebar', 'aytias' ), ), 'no-sidebar' => array( 'url' => get_template_directory_uri().'/assets/images/no_sidebar.png', 'label' => esc_html__( 'No Sidebar', 'aytias' ), ), ) ); return $options; } endif; if ( ! function_exists( 'aytias_get_archive_layouts' ) ) : /** * Returns archive layout options. * * @since 1.0.0 * * @return array Options array. */ function aytias_get_archive_layouts() { $options = apply_filters( 'aytias_archive_layouts', array( 'archive_style_1' => array( 'url' => get_template_directory_uri().'/assets/images/full_column.png', 'label' => esc_html__( 'Full Column', 'aytias' ), ), 'archive_style_4' => array( 'url' => get_template_directory_uri().'/assets/images/archive4.png', 'label' => esc_html__( 'Misc Column', 'aytias' ), ), ) ); return $options; } endif; if ( ! function_exists( 'aytias_in_multi_array' ) ) : /** * Returns true/false if the key exists in array * * @since 1.0.0 * * @param string $needle * @param array $haystack * * @return boolean Key exists/not */ function aytias_in_multi_array($needle,$haystack) { if (array_key_exists($needle,$haystack ) or in_array($needle,$haystack)) { return true; } else { $return = false; foreach (array_values($haystack) as $value) { if (is_array($value) and !$return) { $return = aytias_in_multi_array($needle,$value); } } return $return; } } endif; if ( ! function_exists( 'aytias_hex2rbga' ) ) : /**Convert hex to rbga * * @since 1.0.0 * * @param $color string Hex color * @param $opacity int Opacity * */ function aytias_hex2rbga( $color, $opacity = false ){ $default = 'rgb(0,0,0)'; //Return default if no color provided if(empty($color)) return $default; //Sanitize $color if "#" is provided if ($color[0] == '#' ) { $color = substr( $color, 1 ); } //Check if color has 6 or 3 characters and get values if (strlen($color) == 6) { $hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] ); } elseif ( strlen( $color ) == 3 ) { $hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] ); } else { return $default; } //Convert hexadec to rgb $rgb = array_map('hexdec', $hex); //Check if opacity is set(rgba or rgb) if($opacity){ if(abs($opacity) > 1) $opacity = 1.0; $output = 'rgba('.implode(",",$rgb).','.$opacity.')'; } else { $output = 'rgb('.implode(",",$rgb).')'; } //Return rgb(a) color string return $output; } endif; if( ! function_exists( 'aytias_estimated_read_time' ) ) : /** * Estimated reading time in minutes * * @param $content * @param $words_per_minute * @param $with_gutenberg * * @return int estimated time in minutes */ function aytias_estimated_read_time ( $content = '', $words_per_minute = 200, $with_gutenberg = false ) { // In case if content is build with gutenberg parse blocks if ( $with_gutenberg ) { $blocks = parse_blocks( $content ); $contentHtml = ''; foreach ( $blocks as $block ) { $contentHtml .= render_block( $block ); } $content = $contentHtml; } // Remove HTML tags from string $content = wp_strip_all_tags( $content ); // When content is empty return 0 if ( !$content ) { return 0; } // Count words containing string $words_count = str_word_count( $content ); // Calculate time for read all words and round $minutes = ceil( $words_count / $words_per_minute ); return $minutes; } endif; if( ! function_exists('aytias_print_first_instance_of_block') ): /** Print the first instance of a block in the content, and then break away. * @param string $block_name The full block type name, or a partial match. * Example: `core/image`, `core-embed/*`. * @param string|null $content The content to search in. Use null for get_the_content(). * @param int $instances How many instances of the block will be printed (max). Default 1. * @return bool Returns true if a block was located & printed, otherwise false. */ function aytias_print_first_instance_of_block( $block_name, $content = null, $instances = 1 ) { $instances_count = 0; $blocks_content = ''; if ( ! $content ) { $content = get_the_content(); } // Parse blocks in the content. $blocks = parse_blocks( $content ); // Loop blocks. foreach ( $blocks as $block ) { // Sanity check. if ( ! isset( $block['blockName'] ) ) { continue; } // Check if this the block matches the $block_name. $is_matching_block = false; // If the block ends with *, try to match the first portion. if ( '*' === $block_name[-1] ) { $is_matching_block = 0 === strpos( $block['blockName'], rtrim( $block_name, '*' ) ); } else { $is_matching_block = $block_name === $block['blockName']; } if ( $is_matching_block ) { // Increment count. $instances_count++; // Add the block HTML. $blocks_content .= render_block( $block ); // Break the loop if the $instances count was reached. if ( $instances_count >= $instances ) { break; } } } if ( $blocks_content ) { /** This filter is documented in wp-includes/post-template.php */ echo apply_filters( 'the_content', $blocks_content ); // phpcs:ignore WordPress.Security.EscapeOutput return true; } return false; } endif; if ( ! function_exists( 'aytias_excerpt_length' ) ): /** * Change Excerpt Length * * @param string $length of the excerpt. */ function aytias_excerpt_length( $length ) { return 18; } endif; //add_filter( 'excerpt_length', 'aytias_excerpt_length' ); if ( ! function_exists( 'aytias_more' ) ) : /** * Change Excerpt Suffix * * @param string $more suffix for the excerpt. */ function aytias_excerpt_more( $more ) { return '…'; } endif; add_filter( 'excerpt_more', 'aytias_excerpt_more' ); if ( ! function_exists( 'aytias_archive_title_prefix_wrapper' ) ) : /** * Wrap prefix * * @return string Prefix */ function aytias_archive_title_prefix_wrapper($prefix){ return ''.$prefix.''; } endif; add_filter( 'get_the_archive_title_prefix', 'aytias_archive_title_prefix_wrapper' ); if ( ! function_exists( 'aytias_get_localized_variables' ) ) { /** * Get array of localized variables * * @return array Array of localized vairables */ function aytias_get_localized_variables() { $args = array(); /*For Ajax Load Posts*/ $args['nonce'] = wp_create_nonce( 'aytias-load-more-nonce' ); $args['ajaxurl'] = admin_url( 'admin-ajax.php' ); if( is_front_page() ){ $args['post_type'] = 'post'; } /*Support for custom post types*/ if( is_post_type_archive() ){ $args['post_type'] = get_queried_object()->name; } /**/ /*Support for categories and taxonomies*/ if( is_category() || is_tag() || is_tax() ){ $args['cat'] = get_queried_object()->slug; $args['taxonomy'] = get_queried_object()->taxonomy; /*Get the associated post type for custom taxonomy*/ if( is_tax() ){ global $wp_taxonomies; $tax_object = isset( $wp_taxonomies[$args['taxonomy']] ) ? $wp_taxonomies[$args['taxonomy']]->object_type : array(); $args['post_type'] = array_pop($tax_object); } /**/ } /**/ /*Support for search*/ if( is_search() ){ $args['search'] = get_search_query(); } /**/ /*Support for author*/ if( is_author() ){ $args['author'] = get_the_author_meta( 'user_nicename' ) ; } /**/ /*Support for date archive*/ if( is_date() ){ $args['year'] = get_query_var('year'); $args['month'] = get_query_var('monthnum'); $args['day'] = get_query_var('day'); } /**/ global $wp_query; $arggs['nonce'] = wp_create_nonce( 'aytias-load-more-nonce' ); $arggs['ajaxurl'] = admin_url( 'admin-ajax.php' ); $arggs['posts'] = json_encode( $wp_query->query_vars ); $arggs['current_page'] = get_query_var( 'paged' ) ? get_query_var('paged') : 1; $arggs['max_page'] = $wp_query->max_num_pages; return $arggs; } }