$value ) { $widgets[ $key ] = $value['name']; } } return array_reverse( $widgets ); } } /** * Check Google Fonts */ if ( ! function_exists( 'amy_xmas_is_google_font' ) ) { function amy_xmas_is_google_font( $font_family ) { static $google_fonts; if ( empty( $google_fonts ) ) { $google_json = amy_get_google_fonts(); if ( is_object( $google_json ) ) { $google_fonts = array(); foreach ( $google_json->items as $key => $font ) { $google_fonts[ $font->family ] = $font->variants; } } } return is_array( $google_fonts ) && array_key_exists( $font_family, $google_fonts ); } } /** * Enqueue Google Fonts. */ if ( ! function_exists( 'amy_xmas_enqueue_google_fonts' ) ) { function amy_xmas_enqueue_google_fonts() { $embed_fonts = array(); $query_args = array(); $subsets = amy_get_option( 'subsets' ); $subsets = ! empty( $subsets ) ? '&subset=' . implode( ',', $subsets ) : ''; $typography = amy_get_option( 'typography' ); $google_json = amy_get_google_fonts(); if ( empty( $typography ) ) { return; } foreach ( $typography as $font ) { if ( ! empty( $font['selector'] ) ) { if ( amy_xmas_is_google_font( $font['font']['family'] ) ) { $family = $font['font']['family']; $variant = $font['font']['variant'] != 'regular' ? $font['font']['variant'] : 400; $embed_fonts[ $family ]['variant'][ $variant ] = $variant; } } } if ( ! empty( $embed_fonts ) ) { foreach ( $embed_fonts as $name => $font ) { $variants = $font['variant']; $embed_variants = ! empty( $font['variant'] ) ? ':' . implode( ',', $font['variant'] ) : ''; $query_args[] = $name . $embed_variants; } wp_enqueue_style( 'amy-xmas-google-fonts', esc_url( add_query_arg( 'family', urlencode( implode( '|', $query_args ) ) . $subsets, '//fonts.googleapis.com/css' ) ) ); } } } /* * Get all custom sizes of image */ if ( ! function_exists( 'amy_xmas_get_image_sizes' ) ) { function amy_xmas_get_image_sizes( $force = false, $flip = true ) { $current_image_sizes = get_intermediate_image_sizes(); foreach ( $current_image_sizes as $image_size ) { $dimenssion = (in_array( $image_size, array( 'thumbnail', 'medium', 'large' ) )) ? ' - (' . get_option( $image_size . '_size_w' ) . 'x' . get_option( $image_size . '_size_h' ) . ')' : ''; $image_sizes[ $image_size ] = $image_size . $dimenssion; } if ( $force ) { $get_custom_image_sizes = amy_get_option( 'custom_image_sizes' ); if ( ! empty( $get_custom_image_sizes ) ) { foreach ( $get_custom_image_sizes as $custom_size ) { $name = sanitize_title( $custom_size['img_size_name'] ); $custom_image_sizes[ $name ] = $name . ' - (' . $custom_size['img_size_width'] . 'x' . $custom_size['img_size_height'] . ')'; } $image_sizes = array_filter( array_merge( $image_sizes, $custom_image_sizes ) ); } } $image_sizes['full'] = 'full (orginal size)'; $image_sizes = ($flip) ? array_flip( $image_sizes ) : $image_sizes; return apply_filters( 'amy_xmas_custom_image_sizes', $image_sizes ); } } /** * encapsulates post-classes to use them on different tags */ if ( ! function_exists( 'amy_xmas_get_post_classes' ) ) { function amy_xmas_get_post_classes( $classes = array() ) { // Adds a class for microformats v2 $classes[] = 'h-entry'; // add hentry to the same tag as h-entry $classes[] = 'hentry'; // adds microformats 2 activity-stream support // for pages and articles if ( get_post_type() === 'page' ) { $classes[] = 'h-as-page'; } if ( ! get_post_format() && 'post' === get_post_type() ) { $classes[] = 'h-as-article'; } // adds some more microformats 2 classes based on the // posts "format" switch ( get_post_format() ) { case 'aside': case 'status': $classes[] = 'h-as-note'; break; case 'audio': $classes[] = 'h-as-audio'; break; case 'video': $classes[] = 'h-as-video'; break; case 'gallery': case 'image': $classes[] = 'h-as-image'; break; case 'link': $classes[] = 'h-as-bookmark'; break; } return array_unique( $classes ); } } /** * add semantics * * @param string $id the class identifier * @return array */ if ( ! function_exists( 'amy_xmas_get_semantics' ) ) { function amy_xmas_get_semantics( $id = null ) { $classes = array(); // add default values switch ( $id ) { case 'body': if ( ! is_singular() ) { $classes['itemscope'] = array( '' ); $classes['itemtype'] = array( 'http://schema.org/Blog' ); } elseif ( is_single() ) { $classes['itemscope'] = array( '' ); $classes['itemtype'] = array( 'http://schema.org/BlogPosting' ); } elseif ( is_page() ) { $classes['itemscope'] = array( '' ); $classes['itemtype'] = array( 'http://schema.org/WebPage' ); } break; case 'site-title': if ( ! is_singular() ) { $classes['itemprop'] = array( 'name' ); $classes['class'] = array( 'p-name' ); } break; case 'site-description': if ( ! is_singular() ) { $classes['itemprop'] = array( 'description' ); $classes['class'] = array( 'p-summary', 'e-content' ); } break; case 'site-url': if ( ! is_singular() ) { $classes['itemprop'] = array( 'url' ); $classes['class'] = array( 'u-url', 'url' ); } break; case 'post': if ( ! is_singular() ) { $classes['itemprop'] = array( 'blogPost' ); $classes['itemscope'] = array( '' ); $classes['itemtype'] = array( 'http://schema.org/BlogPosting' ); } break; } $classes = apply_filters( 'amy_xmas_semantics', $classes, $id ); $classes = apply_filters( "amy_xmas_semantics_{$id}", $classes, $id ); return $classes; } } /** * echos the semantic classes added via * * @param string $id the class identifier */ if ( ! function_exists( 'amy_xmas_semantics' ) ) { function amy_xmas_semantics( $id ) { $classes = amy_xmas_get_semantics( $id ); if ( ! $classes ) { return; } foreach ( $classes as $key => $value ) { echo ' ' . esc_attr( $key ) . '="' . esc_attr( join( ' ', $value ) ) . '"'; } } } /* * Custom JS */ if ( ! function_exists( 'amy_xmas_custom_js' ) ) { function amy_xmas_custom_js() { $custom_js = amy_get_option( 'custom_js' ); if ( $custom_js ) { return ''; } } }