' . esc_html__( 'Read more', 'krea' ) . ''; } }// end function_exists add_filter( 'the_content_more_link', 'krea_new_content_more' ); /** * Meta Slider configurations */ function krea_metaslider_default_slideshow_properties( $params ) { $params['width'] = 1450; $params['height'] = 700; return $params; } add_filter( 'metaslider_default_parameters', 'krea_metaslider_default_slideshow_properties', 10, 1 ); /** * Meta Slider referall ID */ function krea_metaslider_hoplink( $link ) { return "https://getdpd.com/cart/hoplink/15318?referrer=24l934xmnt6sc8gs"; } add_filter( 'metaslider_hoplink', 'krea_metaslider_hoplink', 10, 1 ); /** * Retrieve sliders from Meta Slider plugin */ function krea_all_meta_sliders( $sort_key = 'date' ) { $sliders = array(); // list the tabs $args = array( 'post_type' => 'ml-slider', 'post_status' => 'publish', 'orderby' => $sort_key, 'suppress_filters' => 1, // wpml, ignore language filter 'order' => 'ASC', 'posts_per_page' => -1 ); $args = apply_filters( 'metaslider_all_meta_sliders_args', $args ); // WP_Query causes issues with other plugins using admin_footer to insert scripts // use get_posts instead $all_sliders = get_posts( $args ); foreach( $all_sliders as $slideshow ) { $sliders[] = array( 'title' => $slideshow->post_title, 'id' => $slideshow->ID ); } return $sliders; } /** * Convert HEX colors to RGB */ function krea_hex2rgb( $colour ) { $colour = str_replace("#", "", $colour); if ( strlen( $colour ) == 6 ) { list( $r, $g, $b ) = array( $colour[0] . $colour[1], $colour[2] . $colour[3], $colour[4] . $colour[5] ); } elseif ( strlen( $colour ) == 3 ) { list( $r, $g, $b ) = array( $colour[0] . $colour[0], $colour[1] . $colour[1], $colour[2] . $colour[2] ); } else { return false; } $r = hexdec( $r ); $g = hexdec( $g ); $b = hexdec( $b ); return array( 'red' => $r, 'green' => $g, 'blue' => $b ); } /** * Return only slug from all portfolios CPT * * @return array */ function krea_get_portfolios_slug(){ if ( class_exists( 'Multiple_Portfolios' ) ) { $krea_portfolio_types = Multiple_Portfolios::get_post_types(); $krea_portfolio_types_slugs = array(); foreach ( $krea_portfolio_types as $portfolio ) { $krea_portfolio_types_slugs[] = $portfolio['slug']; } return $krea_portfolio_types_slugs; }else{ return new WP_Error( 'plugin_missing', esc_html__( 'Multiple Portfolios plugin not installed', 'krea' ) ); } } /** * Return portfolios as option for Meta Box * * @return array */ function krea_get_portfolios_options(){ if ( class_exists( 'Multiple_Portfolios' ) ) { $krea_portfolio_types = Multiple_Portfolios::get_post_types(); $krea_portfolio_types_option = array(); foreach ( $krea_portfolio_types as $portfolio ) { $krea_portfolio_types_option[$portfolio['slug']] = $portfolio['name']; } return $krea_portfolio_types_option; }else{ return new WP_Error( 'plugin_missing', esc_html__( 'Multiple Portfolios plugin not installed', 'krea' ) ); } } /** * Return only slug from all portfolios CPT * * @return array */ function krea_is_portfolio_category( $category ){ if ( class_exists( 'Multiple_Portfolios' ) ) { $krea_portfolio_types = Multiple_Portfolios::get_post_types(); $taxonomy_objects = get_object_taxonomies( 'portfolio' ); foreach ( $krea_portfolio_types as $portfolio ) { $taxonomy_objects = get_object_taxonomies( $portfolio ); $portfolio_tax_category = $taxonomy_objects[0]; //portfolio_category if ( $category == $portfolio_tax_category ) { return true; } } return false; }else{ return new WP_Error( 'plugin_missing', esc_html__( 'Multiple Portfolios plugin not installed', 'krea' ) ); } } /** * Avoid undefined functions if Meta Box is not activated * * @return bool */ if ( ! function_exists( 'rwmb_meta' ) ) { function rwmb_meta( $key, $args = '', $post_id = null ) { return false; } } /** * Check if the post type is a Portfolio post type * * @return bool */ if ( ! function_exists( 'krea_is_portfolio_type' ) ) { function krea_is_portfolio_type( $post_type ) { $krea_portfolios_post_types = krea_get_portfolios_slug(); if ( ! is_wp_error( $krea_portfolios_post_types ) ) { if ( in_array( $post_type, $krea_portfolios_post_types ) ) : return true; else: return false; endif; }else{ return false; } } } /** * Display Portfolio or Post navigation * * @return html */ if ( ! function_exists( 'krea_post_navigation' ) ) { function krea_post_navigation() { $post_nav_bck = ''; $post_nav_bck_next = ''; $prev_post = get_previous_post(); if ( ! empty( $prev_post ) ): $portfolio_image = wp_get_attachment_image_src( get_post_thumbnail_id( $prev_post->ID ), 'krea_portfolio' ); if ( ! empty( $portfolio_image ) ) { $post_nav_bck = ' style="background-image: url(' . esc_url( $portfolio_image[0] ) . ');"'; } endif; $next_post = get_next_post(); if ( ! empty( $next_post ) ): $portfolio_image = wp_get_attachment_image_src( get_post_thumbnail_id( $next_post->ID ), 'krea_portfolio' ); if ( ! empty( $portfolio_image ) ) { $post_nav_bck_next = ' style="background-image: url(' . esc_url( $portfolio_image[0] ) . ');"'; } endif; if ( ! empty( $prev_post ) || ! empty( $next_post ) ): ?> 1) ? $darker : 1; list($R16,$G16,$B16) = str_split($rgb,2); $R = sprintf("%02X", floor(hexdec($R16)/$darker)); $G = sprintf("%02X", floor(hexdec($G16)/$darker)); $B = sprintf("%02X", floor(hexdec($B16)/$darker)); return $hash.$R.$G.$B; } /** * Enqueues front-end CSS for retina images of portfolio. * * @see wp_add_inline_style() */ function krea_portfolio_retina_images() { $custom_css = krea_get_portfolio_retina_css(); wp_add_inline_style( 'krea_style', $custom_css ); } add_action( 'wp_enqueue_scripts', 'krea_portfolio_retina_images' ); /** * Returns CSS for the color schemes. * * @param array $colors colors. * @return string CSS. */ function krea_get_portfolio_retina_css() { $krea_portfolio_display = rwmb_meta( 'krea_portfolio_display' ); $krea_retina_css = ''; $args = array( 'post_type' => $krea_portfolio_display, 'posts_per_page' => -1, ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); if ( has_post_thumbnail() ) { $portfolio_image_2x = wp_get_attachment_image_src( get_post_thumbnail_id(), 'krea_portfolio_2x' ); $krea_retina_css .= "@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {"; $krea_retina_css .= "#portfolio-item-" . esc_attr( get_the_ID() ) . "{ background-image: url(" . esc_url( $portfolio_image_2x[0] ) . "); }"; $krea_retina_css .= "}\n"; } }//while }// if have posts wp_reset_postdata(); $css = << '', 'title' => '', 'desc' => '', 'fallback' => false, ); // Parse args. $args = wp_parse_args( $args, $defaults ); // Set aria hidden. $aria_hidden = ' aria-hidden="true"'; // Set ARIA. $aria_labelledby = ''; /* * Twenty Seventeen doesn't use the SVG title or description attributes; non-decorative icons are described with .screen-reader-text. * * However, child themes can use the title and description to add information to non-decorative SVG icons to improve accessibility. * * Example 1 with title: 'arrow-right', 'title' => __( 'This is the title', 'textdomain' ) ) ); ?> * * Example 2 with title and description: 'arrow-right', 'title' => __( 'This is the title', 'textdomain' ), 'desc' => __( 'This is the description', 'textdomain' ) ) ); ?> * * See https://www.paciellogroup.com/blog/2013/12/using-aria-enhance-svg-accessibility/. */ if ( $args['title'] ) { $aria_hidden = ''; $unique_id = uniqid(); $aria_labelledby = ' aria-labelledby="title-' . $unique_id . '"'; if ( $args['desc'] ) { $aria_labelledby = ' aria-labelledby="title-' . $unique_id . ' desc-' . $unique_id . '"'; } } // Begin SVG markup. $svg = ''; // Display the title. if ( $args['title'] ) { $svg .= '' . esc_html( $args['title'] ) . ''; // Display the desc only if the title is already set. if ( $args['desc'] ) { $svg .= '' . esc_html( $args['desc'] ) . ''; } } /* * Display the icon. * * The whitespace around `` is intentional - it is a work around to a keyboard navigation bug in Safari 10. * * See https://core.trac.wordpress.org/ticket/38387. */ $svg .= ' '; // Add some markup to use as a fallback for browsers that do not support SVGs. if ( $args['fallback'] ) { $svg .= ''; } $svg .= ''; return $svg; } /** * Add dropdown icon if menu item has children. * * @param string $title The menu item's title. * @param object $item The current menu item. * @param array $args An array of wp_nav_menu() arguments. * @param int $depth Depth of menu item. Used for padding. * @return string $title The menu item's title with dropdown icon. */ function krea_dropdown_icon_to_menu_link( $title, $item, $args, $depth ) { if ( 'primary' === $args->theme_location ) { foreach ( $item->classes as $value ) { if ( 'menu-item-has-children' === $value || 'page_item_has_children' === $value ) { $title = $title . ''; } } } return $title; } add_filter( 'nav_menu_item_title', 'krea_dropdown_icon_to_menu_link', 10, 4 ); /** * Add a pingback url auto-discovery header for single posts, pages, or attachments. */ function krea_pingback_header() { if ( is_singular() && pings_open() ) { echo ''; } } add_action( 'wp_head', 'krea_pingback_header' );