← Back
Editing: helper.php
<?php if ( ! function_exists( 'zoya_is_installed' ) ) { /** * Function that checks if forward plugin installed * * @param string $plugin - plugin name * * @return bool */ function zoya_is_installed( $plugin ) { switch ( $plugin ) { case 'framework': return class_exists( 'QodeFramework' ); break; case 'core': return class_exists( 'ZoyaCore' ); break; case 'woocommerce': return class_exists( 'WooCommerce' ); break; case 'gutenberg-page': $current_screen = function_exists( 'get_current_screen' ) ? get_current_screen() : array(); return method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor(); break; case 'gutenberg-editor': return class_exists( 'WP_Block_Type' ); break; default: return false; } } } if ( ! function_exists( 'zoya_include_theme_is_installed' ) ) { /** * Function that set case is installed element for framework functionality * * @param bool $installed * @param string $plugin - plugin name * * @return bool */ function zoya_include_theme_is_installed( $installed, $plugin ) { if ( 'theme' === $plugin ) { return class_exists( 'Zoya_Handler' ); } return $installed; } add_filter( 'qode_framework_filter_is_plugin_installed', 'zoya_include_theme_is_installed', 10, 2 ); } if ( ! function_exists( 'zoya_template_part' ) ) { /** * Function that echo module template part. * * @param string $module name of the module from inc folder * @param string $template full path of the template to load * @param string $slug * @param array $params array of parameters to pass to template */ function zoya_template_part( $module, $template, $slug = '', $params = array() ) { echo zoya_get_template_part( $module, $template, $slug, $params ); } } if ( ! function_exists( 'zoya_get_template_part' ) ) { /** * Function that load module template part. * * @param string $module name of the module from inc folder * @param string $template full path of the template to load * @param string $slug * @param array $params array of parameters to pass to template * * @return string - string containing html of template */ function zoya_get_template_part( $module, $template, $slug = '', $params = array() ) { // HTML Content from template $html = ''; $template_path = ZOYA_INC_ROOT_DIR . '/' . $module; $temp = $template_path . '/' . $template; if ( is_array( $params ) && count( $params ) ) { extract( $params, EXTR_SKIP ); // @codingStandardsIgnoreLine } $template = ''; if ( ! empty( $temp ) ) { if ( ! empty( $slug ) ) { $template = "{$temp}-{$slug}.php"; if ( ! file_exists( $template ) ) { $template = $temp . '.php'; } } else { $template = $temp . '.php'; } } if ( $template ) { ob_start(); include( $template ); $html = ob_get_clean(); } return $html; } } if ( ! function_exists( 'zoya_get_page_id' ) ) { /** * Function that returns current page id * Additional conditional is to check if current page is any wp archive page (archive, category, tag, date etc.) and returns -1 * * @return int */ function zoya_get_page_id() { $page_id = get_queried_object_id(); if ( zoya_is_wp_template() ) { $page_id = - 1; } return apply_filters( 'zoya_filter_page_id', $page_id ); } } if ( ! function_exists( 'zoya_is_wp_template' ) ) { /** * Function that checks if current page default wp page * * @return bool */ function zoya_is_wp_template() { return is_archive() || is_search() || is_404() || ( is_front_page() && is_home() ); } } if ( ! function_exists( 'zoya_get_ajax_status' ) ) { /** * Function that return status from ajax functions * * @param string $status - success or error * @param string $message - ajax message value * @param string|array $data - returned value * @param string $redirect - url address */ function zoya_get_ajax_status( $status, $message, $data = null, $redirect = '' ) { $response = array( 'status' => esc_attr( $status ), 'message' => esc_html( $message ), 'data' => $data, 'redirect' => ! empty( $redirect ) ? esc_url( $redirect ) : '', ); $output = json_encode( $response ); exit( $output ); } } if ( ! function_exists( 'zoya_get_button_element' ) ) { /** * Function that returns button with provided params * * @param array $params - array of parameters * * @return string - string representing button html */ function zoya_get_button_element( $params ) { if ( class_exists( 'ZoyaCore_Button_Shortcode' ) ) { return ZoyaCore_Button_Shortcode::call_shortcode( $params ); } else { $link = isset( $params['link'] ) ? $params['link'] : '#'; $target = isset( $params['target'] ) ? $params['target'] : '_self'; $text = isset( $params['text'] ) ? $params['text'] : ''; return '<a itemprop="url" class="qodef-theme-button" href="' . esc_url( $link ) . '" target="' . esc_attr( $target ) . '">' . esc_html( $text ) . '</a>'; } } } if ( ! function_exists( 'zoya_render_button_element' ) ) { /** * Function that render button with provided params * * @param array $params - array of parameters */ function zoya_render_button_element( $params ) { echo zoya_get_button_element( $params ); } } if ( ! function_exists( 'zoya_class_attribute' ) ) { /** * Function that render class attribute * * @param string|array $class */ function zoya_class_attribute( $class ) { echo zoya_get_class_attribute( $class ); } } if ( ! function_exists( 'zoya_get_class_attribute' ) ) { /** * Function that return class attribute * * @param string|array $class * * @return string|mixed */ function zoya_get_class_attribute( $class ) { $value = zoya_is_installed( 'framework' ) ? qode_framework_get_class_attribute( $class ) : ''; return $value; } } if ( ! function_exists( 'zoya_get_post_value_through_levels' ) ) { /** * Function that returns meta value if exists * * @param string $name name of option * @param int $post_id id of * * @return string value of option */ function zoya_get_post_value_through_levels( $name, $post_id = null ) { return zoya_is_installed( 'framework' ) && zoya_is_installed( 'core' ) ? zoya_core_get_post_value_through_levels( $name, $post_id ) : ''; } } if ( ! function_exists( 'zoya_get_space_value' ) ) { /** * Function that returns spacing value based on selected option * * @param string $text_value - textual value of spacing * * @return int */ function zoya_get_space_value( $text_value ) { return zoya_is_installed( 'core' ) ? zoya_core_get_space_value( $text_value ) : 0; } } if ( ! function_exists( 'zoya_wp_kses_html' ) ) { /** * Function that does escaping of specific html. * It uses wp_kses function with predefined attributes array. * * @param string $type - type of html element * @param string $content - string to escape * * @return string escaped output * @see wp_kses() * */ function zoya_wp_kses_html( $type, $content ) { return zoya_is_installed( 'framework' ) ? qode_framework_wp_kses_html( $type, $content ) : $content; } } if ( ! function_exists( 'zoya_render_svg_icon' ) ) { /** * Function that print svg html icon * * @param string $name - icon name * @param string $class_name - custom html tag class name */ function zoya_render_svg_icon( $name, $class_name = '' ) { echo zoya_get_svg_icon( $name, $class_name ); } } if ( ! function_exists( 'zoya_get_svg_icon' ) ) { /** * Returns svg html * * @param string $name - icon name * @param string $class_name - custom html tag class name * * @return string|html */ function zoya_get_svg_icon( $name, $class_name = '' ) { $html = ''; $class = isset( $class_name ) && ! empty( $class_name ) ? 'class="' . esc_attr( $class_name ) . '"' : ''; switch ( $name ) { case 'menu': $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="64px" height="64px" viewBox="0 0 64 64" enable-background="new 0 0 64 64" xml:space="preserve"><line x1="12" y1="21" x2="52" y2="21"/><line x1="12" y1="33" x2="52" y2="33"/><line x1="12" y1="45" x2="52" y2="45"/></svg>'; break; case 'search': $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="17.17px" height="17.21px" viewBox="3.42 3.38 17.17 17.21" enable-background="new 3.42 3.38 17.17 17.21" xml:space="preserve"><g><circle fill="none" stroke="#1B1B1B" stroke-linecap="round" stroke-linejoin="round" cx="11.11" cy="11.11" r="7.11"/><line fill="none" stroke="#1B1B1B" stroke-linecap="round" stroke-linejoin="round" x1="20" y1="20" x2="16.13" y2="16.13"/></g></svg>'; break; case 'star': $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="9.47px" height="9.02px" viewBox="0 0 9.47 9.02" enable-background="new 0 0 9.47 9.02" xml:space="preserve"><g><path stroke-width="0.1" stroke-miterlimit="10" d="M6.48,5.55l1.08,3.3L4.74,6.81L1.93,8.84L3,5.55 L0.19,3.5h3.48l1.07-3.31L5.82,3.5H9.3L6.48,5.55z"/></g></svg>'; break; case 'menu-arrow-right': $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="13.81px" height="26.19px" viewBox="0 0 13.81 26.19" enable-background="new 0 0 13.81 26.19" xml:space="preserve"><g><line fill="none" stroke="#616161" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="0.69" y1="0.63" x2="13.19" y2="13.13"/><line fill="none" stroke="#616161" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="0.69" y1="25.63" x2="13.19" y2="13.13"/></g></svg>'; break; case 'slider-arrow-left': $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 26 50.9" xml:space="preserve"><polyline points="25.6,0.4 0.7,25.5 25.6,50.6 "/></svg>'; break; case 'slider-arrow-right': $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 26 50.9" xml:space="preserve"><polyline points="0.4,50.6 25.3,25.5 0.4,0.4 "/></svg>'; break; case 'pagination-arrow-left': $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 20 20"><path d="M14 20c0.128 0 0.256-0.049 0.354-0.146 0.195-0.195 0.195-0.512 0-0.707l-8.646-8.646 8.646-8.646c0.195-0.195 0.195-0.512 0-0.707s-0.512-0.195-0.707 0l-9 9c-0.195 0.195-0.195 0.512 0 0.707l9 9c0.098 0.098 0.226 0.146 0.354 0.146z"/></svg>'; break; case 'pagination-arrow-right': $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 20 20"><path d="M5 20c-0.128 0-0.256-0.049-0.354-0.146-0.195-0.195-0.195-0.512 0-0.707l8.646-8.646-8.646-8.646c-0.195-0.195-0.195-0.512 0-0.707s0.512-0.195 0.707 0l9 9c0.195 0.195 0.195 0.512 0 0.707l-9 9c-0.098 0.098-0.226 0.146-0.354 0.146z"/></svg>'; break; case 'close': $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="10.83px" height="10.81px" viewBox="32.59 32.58 10.83 10.81" enable-background="new 32.59 32.58 10.83 10.81" xml:space="preserve"><line fill="none" stroke="#1B1B1B" stroke-width="0.75" stroke-linecap="round" stroke-linejoin="round" x1="43" y1="33" x2="33" y2="43"/><line fill="none" stroke="#1B1B1B" stroke-width="0.75" stroke-linecap="round" stroke-linejoin="round" x1="33" y1="33" x2="43" y2="43"/></svg>'; break; case 'spinner': $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512"><path d="M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z"></path></svg>'; break; case 'link': $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="190px" height="190px" viewBox="0 0 32.06999969482422 33.58000183105469" fill="#FFFFFF"><g><path d="M 7.54,15.77c 1.278,1.278, 3.158,1.726, 4.868,1.216L 2.96,7.54C 2.652,7.232, 2.49,6.786, 2.49,6.254 c0-0.88, 0.46-2.004, 1.070-2.614c 0.8-0.8, 2.97-1.686, 3.98-0.682l 9.446,9.448c 0.138-0.462, 0.208-0.942, 0.208-1.422 c0-1.304-0.506-2.526-1.424-3.446L 9.364,1.134C 7.44-0.79, 3.616-0.068, 1.734,1.814C 0.642,2.906-0.036,4.598-0.036,6.23 c0,1.268, 0.416,2.382, 1.17,3.136L 7.54,15.77zM 24.46,16.23c-1.278-1.278-3.158-1.726-4.868-1.216l 9.448,9.448c 0.308,0.308, 0.47,0.752, 0.47,1.286 c0,0.88-0.46,2.004-1.070,2.614c-0.8,0.8-2.97,1.686-3.98,0.682L 15.014,19.594c-0.138,0.462-0.208,0.942-0.208,1.422 c0,1.304, 0.506,2.526, 1.424,3.446l 6.404,6.404c 1.924,1.924, 5.748,1.202, 7.63-0.68c 1.092-1.092, 1.77-2.784, 1.77-4.416 c0-1.268-0.416-2.382-1.17-3.136L 24.46,16.23zM 9.164,9.162C 8.908,9.416, 8.768,9.756, 8.768,10.116s 0.14,0.698, 0.394,0.952l 11.768,11.77 c 0.526,0.524, 1.38,0.524, 1.906,0c 0.256-0.254, 0.394-0.594, 0.394-0.954s-0.14-0.698-0.394-0.952L 11.068,9.162 C 10.544,8.638, 9.688,8.638, 9.164,9.162z"/></g></svg>'; break; case 'quote': $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="180.51px" height="126.1px" viewBox="0 0 180.51 126.1" enable-background="new 0 0 180.51 126.1" xml:space="preserve"><g><path fill="#FFFFFF" d="M60.08,5.59c-22.4,17.2-28.4,44.4-21.6,45.2c8.8,0.8,18,3.6,25.2,10.4c14.8,14.4,14.8,38.4,0.4,53.2 c-14.4,14.4-38.4,14.4-52.8,0c-22.4-22.8-3.6-62.4,9.6-82c5.6-8.4,16.8-21.2,35.6-31.6L60.08,5.59z M165.28,5.59 c-22,17.2-28.4,44.4-21.6,45.2c9.2,0.8,18,3.6,25.2,10.4c14.8,14.4,15.2,38.4,0.4,53.2c-14.4,14.4-38,14.4-52.4,0 c-22.8-22.8-3.6-62.4,9.2-82c6-8.4,17.2-21.2,35.6-31.6L165.28,5.59z"/></g></svg>'; break; case 'share': $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="13.06px" height="18.05px" viewBox="5.45 3.97 13.06 18.05" enable-background="new 5.45 3.97 13.06 18.05" xml:space="preserve"><path fill="none" stroke="#1B1B1B" stroke-linecap="round" stroke-linejoin="round" d="M6,16.25V20c0,0.83,0.67,1.5,1.5,1.5h9 c0.83,0,1.5-0.67,1.5-1.5v-3.75"/><polyline fill="none" stroke="#1B1B1B" stroke-linecap="round" stroke-linejoin="round" points="15,7.5 12,4.5 9,7.5 "/><line fill="none" stroke="#1B1B1B" stroke-linecap="round" stroke-linejoin="round" x1="12" y1="4.5" x2="12" y2="14.25"/></svg>'; break; case 'cart': $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="15.06px" height="19.13px" viewBox="4.47 1 15.06 19.13" enable-background="new 4.47 1 15.06 19.13" xml:space="preserve"><path fill="none" stroke-linecap="round" stroke-linejoin="round" d="M5.06,4.52v13.53c0,0.85,0.42,1.54,1.27,1.54 h11.35c0.85,0,1.27-0.69,1.27-1.54V4.52"/><line fill="none" stroke-linecap="round" stroke-linejoin="round" x1="5.06" y1="4.52" x2="18.94" y2="4.52"/><path fill="none" stroke-linecap="round" stroke-linejoin="round" d="M8.69,6.45V2.81c0,0,2.95-2.69,6.63-0.11 v3.63"/></svg>'; break; case 'popup-close': $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="20.91px" height="20.84px" viewBox="27.53 27.56 20.91 20.84" enable-background="new 27.53 27.56 20.91 20.84" xml:space="preserve"><line fill="none" stroke="#1B1B1B" stroke-width="0.75" stroke-linecap="round" stroke-linejoin="round" x1="48" y1="28" x2="28" y2="48"/><line fill="none" stroke="#1B1B1B" stroke-width="0.75" stroke-linecap="round" stroke-linejoin="round" x1="28" y1="28" x2="48" y2="48"/></svg>'; break; } return $html; } }
Save File
Cancel