get_contents( $file ); } return false; } /** * Loading Core File and Script Loader. */ require THEMEOO_THEME_DIR . 'inc/themeoo-include.php'; /** * Content width based on the theme's design and stylesheet. */ if ( ! isset( $content_width ) ) { $content_width = 870; /* pixels */ } if ( ! function_exists('themeoo_setup') ) { /** * Sets up theme defaults and registers support for various WordPress features. * * Note that this function is hooked into the after_setup_theme hook, which * runs before the init hook. The init hook is too late for some features, such * as indicating support for post thumbnails. * * @return void */ function themeoo_setup() { /* * Make theme available for translation. * Translations can be filed in the /languages/ directory. * If you're building a theme based on Pxlr-theme, use a find and replace * to change 'ayyash' to the name of your theme in all the template files */ if ( ! load_theme_textdomain('ayyash', get_stylesheet_directory() . '/languages') ) { load_theme_textdomain('ayyash', get_template_directory() . '/languages'); } if ( get_theme_mod('woocommerce_general_enable_product_zoom') ) { add_theme_support( 'wc-product-gallery-zoom' ); } if ( get_theme_mod('woocommerce_general_enable_product_lightbox') ) { add_theme_support( 'wc-product-gallery-lightbox' ); } if ( get_theme_mod('woocommerce_general_enable_product_gallery_slider') ) { add_theme_support( 'wc-product-gallery-slider' ); } // Add default posts and comments RSS feed links to head. add_theme_support('automatic-feed-links'); /* * Let WordPress manage the document title. * By adding theme support, we declare that this theme does not use a * hard-coded tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support('title-tag'); /* * Enable support for Post Thumbnails on posts and pages. * * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails */ add_theme_support( 'post-thumbnails' ); add_theme_support( 'post-formats', array( 'aside', 'audio', 'gallery', 'image', 'link', 'quote', 'video' ) ); add_image_size( 'themeoo-blog-grid', 540, 420, true ); add_image_size( 'themeoo-gallery', 420, 420, true ); add_image_size( 'themeoo-vertical', 300, 580, true ); add_image_size( 'themeoo-woocom-thumb', 300, 375, true ); $blog_normal = themeoo_get_mod( 'layout_blog_normal_image' ); $blog_medium = themeoo_get_mod( 'layout_blog_medium_image' ); $blog_grid = themeoo_get_mod( 'layout_blog_grid_image' ); if ( $blog_normal ) { $blog_normalo = explode( ',', $blog_normal ); $blog_normalo = array_map( 'absint', $blog_normalo ); add_image_size( 'blog-normal', $blog_normalo[0], $blog_normalo[1], true ); } if ( $blog_medium ) { $blog_mediumo = explode( ',', $blog_medium ); $blog_mediumo = array_map( 'absint', $blog_mediumo ); add_image_size( 'blog-medium', $blog_mediumo[0], $blog_mediumo[1], true ); } if ( $blog_grid ) { $blog_grido = explode( ',', $blog_grid ); $blog_grido = array_map( 'absint', $blog_grido ); add_image_size( 'blog-grid', $blog_grido[0], $blog_grido[1], true ); } // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'primary' => __( 'Primary Menu', 'ayyash' ) ) ); // Mobile Menu. register_nav_menus( array( 'mobile' => __( 'Mobile Menu ( Select when mobile menu is different )', 'ayyash' ) ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) ); // Set up the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( 'themeoo_custom_background_args', array( 'default-color' => 'ffffff', 'default-image' => '', ) ) ); // Set up the WordPress core custom header feature. $themeoo_custom_header_args = array( 'wp-head-callback' => '', 'admin-head-callback' => '', 'admin-preview-callback' => '', ); add_theme_support( 'custom-header', $themeoo_custom_header_args ); } } if ( ! function_exists( 'wp_body_open' ) ) { /** * Fire the wp_body_open action. * Back compact. for 5.0.0 * * @return void */ function wp_body_open() { do_action( 'wp_body_open' ); } } add_action( 'after_setup_theme', 'themeoo_setup' ); if ( ! function_exists( 'themeoo_extensions_flying_cart' ) ) { /** * /** * Enable Flying cart from theme. * * @param bool $status enable flying cart. * * @return bool */ function themeoo_extensions_flying_cart( $status ) { if ( themeoo_get_mod('woocommerce_general_enable_product_flying_cart') == 1 ) { return $status; } return false; } } add_filter( 'themeoo_extensions_flying_cart', 'themeoo_extensions_flying_cart' ); if ( ! function_exists( 'themeoo_add_editor_styles' ) ) { /** * Registers an editor stylesheet for the theme. * * @return void */ function themeoo_add_editor_styles() { add_editor_style( 'themeoo-editor-style.css' ); } } add_action( 'admin_init', 'themeoo_add_editor_styles' ); if ( ! function_exists( 'themeoo_enqueue_comments_reply' ) ) { /** * Enqueue Comments Reply into footer (comment-reply.js) * * @return void */ function themeoo_enqueue_comments_reply() { if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply', 'wp-includes/js/comment-reply', array(), '1.0.0', true ); } } } add_action( 'comment_form_before', 'themeoo_enqueue_comments_reply' ); if ( ! function_exists('themeoo_variation_radio_buttons') ) { /** * Product Attribute Radio buttons * * @param string $html data. * @param array $args Arguments. * @return string */ function themeoo_variation_radio_buttons( $html, $args ) { $args = wp_parse_args( apply_filters( 'woocommerce_dropdown_variation_attribute_options_args', $args ), array( 'options' => false, 'attribute' => false, 'product' => false, 'selected' => false, 'name' => '', 'id' => '', 'class' => '', 'show_option_none' => __( 'Choose an option', 'ayyash' ), ) ); if ( false === $args['selected'] && $args['attribute'] && $args['product'] instanceof WC_Product ) { $selected_key = 'attribute_' . sanitize_title( $args['attribute'] ); $selected = isset( $_REQUEST[ $selected_key ] ) ? wc_clean( wp_unslash( $_REQUEST[ $selected_key ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $args['selected'] = $selected ? $selected : $args['product']->get_variation_default_attribute( $args['attribute'] ); // @phpstan-ignore-line } $options = $args['options']; $product = $args['product']; $attribute = $args['attribute']; $name = $args['name'] ? $args['name'] : 'attribute_' . sanitize_title($attribute); $id = $args['id'] ? $args['id'] : sanitize_title($attribute); $class = $args['class']; $show_option_none = (bool) $args['show_option_none']; $show_option_none_text = $args['show_option_none'] ? $args['show_option_none'] : __('Choose an option', 'ayyash'); if ( empty($options) && ! empty($product) && ! empty($attribute) ) { $attributes = $product->get_variation_attributes(); $options = $attributes[ $attribute ]; } $radios = '<div class="variation-radios themeoo-attributes">'; if ( ! empty( $options ) ) { if ( $product && taxonomy_exists( $attribute ) ) { $terms = wc_get_product_terms( $product->get_id(), $attribute, [ 'fields' => 'all' ] ); foreach ( $terms as $term ) { if ( in_array( $term->slug, $options, true ) ) { $id = $name . '-' . $term->slug; if ( 'attribute_pa_color' == $name ) { $themeoo_select_color = get_term_meta( $term->term_id, 'color', true ); // Swatch. $output = '<span title="' . esc_attr( $term->name ) . '" style="background-color: ' . esc_attr( $themeoo_select_color ) . '"><img alt="swatch" src="data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0A%3Csvg%20width%3D%2218px%22%20height%3D%2213px%22%20viewBox%3D%220%200%2018%2013%22%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%3E%0A%20%20%20%20%3C%21--%20Generator%3A%20Sketch%2041.2%20%2835397%29%20-%20http%3A%2F%2Fwww.bohemiancoding.com%2Fsketch%20--%3E%0A%20%20%20%20%3Ctitle%3EIcon%3C%2Ftitle%3E%0A%20%20%20%20%3Cdesc%3ECreated%20with%20Sketch.%3C%2Fdesc%3E%0A%20%20%20%20%3Cdefs%3E%3C%2Fdefs%3E%0A%20%20%20%20%3Cg%20id%3D%22Page-1%22%20stroke%3D%22none%22%20stroke-width%3D%221%22%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%0A%20%20%20%20%20%20%20%20%3Cg%20id%3D%22Ecommerce%22%20transform%3D%22translate%28-844.000000%2C%20-3389.000000%29%22%20fill%3D%22%23FFFFFF%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3Cg%20id%3D%22Product-Card-%231%22%20transform%3D%22translate%28150.000000%2C%202942.000000%29%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Cg%20id%3D%22Color%22%20transform%3D%22translate%28683.000000%2C%20399.000000%29%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Cpath%20d%3D%22M28.8443688%2C48.9224987%20L28.095269%2C48.1585481%20C27.8879809%2C47.9471506%2027.5523969%2C47.9471506%2027.3451088%2C48.1585481%20L17.6752%2C58.0207009%20C17.4673818%2C58.2320984%2017.1317978%2C58.2320984%2016.9255701%2C58.0207009%20L12.6546937%2C53.6656962%20C12.4474056%2C53.4542987%2012.1118216%2C53.4542987%2011.9055938%2C53.6656962%20L11.1554337%2C54.4301874%20C10.9481456%2C54.6415849%2010.9481456%2C54.9838218%2011.1554337%2C55.1946786%20L16.5369712%2C60.6834443%20C16.950487%2C61.105158%2017.6211249%2C61.1056986%2018.0351709%2C60.6839849%20L28.8438387%2C49.6875305%20C29.0516569%2C49.4766737%2029.052187%2C49.1338962%2028.8443688%2C48.9224987%22%20id%3D%22Icon%22%3E%3C%2Fpath%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3C%2Fg%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3C%2Fg%3E%0A%20%20%20%20%20%20%20%20%3C%2Fg%3E%0A%20%20%20%20%3C%2Fg%3E%0A%3C%2Fsvg%3E" ></span>'; } elseif ( 'attribute_pa_size' == $name ) { $output = '<span class="size-check"><p>' . esc_html( apply_filters( 'woocommerce_variation_option_name', $term->name ) ) . '</p></span>'; } else { $output = esc_html( apply_filters( 'woocommerce_variation_option_name', $term->name ) ); } $radios .= '<input type="radio" id="' . esc_attr( $id ) . '" name="' . esc_attr( $name ) . '" value="' . esc_attr( $term->slug ) . '" ' . checked( sanitize_title( $args['selected'] ), $term->slug, false ) . '><label for="' . esc_attr( $id ) . '">' . $output . '</label>'; } } } else { foreach ( $options as $option ) { $id = $name . '-' . $option; $term = get_term_by( 'slug', $option, 'pa_color' ); if ( $term && 'attribute_pa_color' == $name ) { $themeoo_select_color = get_term_meta( $term->term_id, 'color', true ); // @phpstan-ignore-line // Swatch. $output = '<span style="background-color: ' . esc_attr( $themeoo_select_color ) . '"><img alt="swatch" src="data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0A%3Csvg%20width%3D%2218px%22%20height%3D%2213px%22%20viewBox%3D%220%200%2018%2013%22%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%3E%0A%20%20%20%20%3C%21--%20Generator%3A%20Sketch%2041.2%20%2835397%29%20-%20http%3A%2F%2Fwww.bohemiancoding.com%2Fsketch%20--%3E%0A%20%20%20%20%3Ctitle%3EIcon%3C%2Ftitle%3E%0A%20%20%20%20%3Cdesc%3ECreated%20with%20Sketch.%3C%2Fdesc%3E%0A%20%20%20%20%3Cdefs%3E%3C%2Fdefs%3E%0A%20%20%20%20%3Cg%20id%3D%22Page-1%22%20stroke%3D%22none%22%20stroke-width%3D%221%22%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%0A%20%20%20%20%20%20%20%20%3Cg%20id%3D%22Ecommerce%22%20transform%3D%22translate%28-844.000000%2C%20-3389.000000%29%22%20fill%3D%22%23FFFFFF%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3Cg%20id%3D%22Product-Card-%231%22%20transform%3D%22translate%28150.000000%2C%202942.000000%29%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Cg%20id%3D%22Color%22%20transform%3D%22translate%28683.000000%2C%20399.000000%29%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Cpath%20d%3D%22M28.8443688%2C48.9224987%20L28.095269%2C48.1585481%20C27.8879809%2C47.9471506%2027.5523969%2C47.9471506%2027.3451088%2C48.1585481%20L17.6752%2C58.0207009%20C17.4673818%2C58.2320984%2017.1317978%2C58.2320984%2016.9255701%2C58.0207009%20L12.6546937%2C53.6656962%20C12.4474056%2C53.4542987%2012.1118216%2C53.4542987%2011.9055938%2C53.6656962%20L11.1554337%2C54.4301874%20C10.9481456%2C54.6415849%2010.9481456%2C54.9838218%2011.1554337%2C55.1946786%20L16.5369712%2C60.6834443%20C16.950487%2C61.105158%2017.6211249%2C61.1056986%2018.0351709%2C60.6839849%20L28.8438387%2C49.6875305%20C29.0516569%2C49.4766737%2029.052187%2C49.1338962%2028.8443688%2C48.9224987%22%20id%3D%22Icon%22%3E%3C%2Fpath%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3C%2Fg%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3C%2Fg%3E%0A%20%20%20%20%20%20%20%20%3C%2Fg%3E%0A%20%20%20%20%3C%2Fg%3E%0A%3C%2Fsvg%3E" ></span>'; } elseif ( $term && 'attribute_pa_size' == $name ) { $output = '<span class="size-check"><p>' . esc_html( apply_filters( 'woocommerce_variation_option_name', $term->name ) ) . '</p></span>'; // @phpstan-ignore-line $checked = sanitize_title( $args['selected'] ) === $args['selected'] ? checked( $args['selected'], sanitize_title( $option ), false ) : checked( $args['selected'], $option, false ); $radios .= '<input type="radio" id="' . esc_attr( $id ) . '" name="' . esc_attr( $name ) . '" value="' . esc_attr( $option ) . '" id="' . sanitize_title( $option ) . '" ' . $checked . '><label for="' . esc_attr( $id ) . '">' . $output . '</label>'; } } } } $radios .= '</div>'; return $html . $radios; } add_filter('woocommerce_dropdown_variation_attribute_options_html', 'themeoo_variation_radio_buttons', 20, 2); /** * Check Product Variation. * * @param bool $active activate. * @param WC_Product_Variation $variation variation. * * @return bool */ function themeoo_variation_check( $active, $variation ) { if ( ! $variation->is_in_stock() && ! $variation->backorders_allowed() ) { return false; } return $active; } add_filter('woocommerce_variation_is_active', 'themeoo_variation_check', 10, 2); } /* ---------------------------------------------------------------------- * Advice for theme developer read carefully * If you are developing theme using ayyash Starter theme make sure Not to write any new theme function (The theme you are going to release using our starter framework) Anywhere , Just use inc/themeoo-theme-extras.php which we created for developer who is using ayyash for theme development . By maintaining this advice , you can able to update base framework easily. Because we will not write anything in the file. ---------------------------------------------------------------------- */