editor->is_edit_mode(); } return false; } public static function get_elementor_css_uri($pid) { global $blog_id; $wp_upload_dir = wp_upload_dir(null, false); $base = $wp_upload_dir['baseurl'] . '/elementor/css/'; return set_url_scheme($base . 'post-' . $pid . '.css'); } public static function add_to_url($url, $param) { $info = parse_url( $url ); $query = []; if(isset($info['query'])){ parse_str( $info['query'], $query ); } return (isset($info['scheme']) ? $info['scheme'] . '://' : '') . ($info['host'] ?? '') .( $info['path'] ?? '' ). '?' . http_build_query( $query ? array_merge( $query, $param ) : $param ); } /** * Auto generate classname from path. * * @since 1.0.0 * @access public */ public static function make_classname($dirname) { $dirname = pathinfo($dirname, PATHINFO_FILENAME); $class_name = explode('-', $dirname); $class_name = array_map('ucfirst', $class_name); $class_name = implode('_', $class_name); return $class_name; } public static function get_kses_array() { return [ 'a' => [ 'class' => [], 'href' => [], 'rel' => [], 'title' => [], 'target' => [], 'data-quantity' => [], 'data-product_id' => [], 'data-product_sku' => [], 'data-pid' => [], 'aria-label' => [], ], 'abbr' => [ 'title' => [], ], 'b' => [], 'blockquote' => [ 'cite' => [], ], 'cite' => [ 'title' => [], ], 'code' => [], 'del' => [ 'datetime' => [], 'title' => [], ], 'dd' => [], 'div' => [ 'class' => [], 'title' => [], 'style' => [], 'data-product-id' => [], 'data-attribute_name' => [], 'data-type' => [], 'id' => [], ], 'dl' => [], 'dt' => [], 'em' => [], 'h1' => [ 'class' => [], ], 'h2' => [ 'class' => [], ], 'h3' => [ 'class' => [], ], 'h4' => [ 'class' => [], ], 'h5' => [ 'class' => [], ], 'h6' => [ 'class' => [], ], 'i' => [ 'class' => [], ], 'img' => [ 'alt' => [], 'class' => [], 'height' => [], 'src' => [], 'width' => [], 'decoding' => [], 'loading' => [], 'srcset' => [], 'sizes' => [] ], 'li' => [ 'class' => [], ], 'ol' => [ 'class' => [], ], 'p' => [ 'class' => [], ], 'q' => [ 'cite' => [], 'title' => [], ], 'span' => [ 'class' => [], 'title' => [], 'style' => [], ], 'iframe' => [ 'width' => [], 'height' => [], 'scrolling' => [], 'frameborder' => [], 'allow' => [], 'src' => [], ], 'strike' => [], 'br' => [], 'strong' => [], 'data-wow-duration' => [], 'data-wow-delay' => [], 'data-wallpaper-options' => [], 'data-stellar-background-ratio' => [], 'ul' => [ 'class' => [], ], 'button' => [ 'class' => [], 'title' => [], 'data-share-url' => [], 'data-message' => [] ] ]; } public static function kses($raw) { if(function_exists('wp_kses')) { // WP is here return wp_kses($raw, self::get_kses_array()); } else { return $raw; } } public static function kspan($text) { return str_replace(['{', '}'], ['', ''], self::kses($text)); } public static function category_list_by_taxonomy($taxonomy = '') { $query_args = [ 'orderby' => 'ID', 'order' => 'DESC', 'hide_empty' => 1, 'taxonomy' => $taxonomy, ]; $categories = get_categories($query_args); return $categories; } public static function trim_words($text, $num_words) { return wp_trim_words($text, $num_words, ''); } public static function array_push_assoc($array, $key, $value) { $array[$key] = $value; return $array; } public static function render($content) { $content = $content ?? ''; if(stripos($content, "shopengine-has-lisence") !== false) { return null; } return $content; } public static function render_elementor_content($content_id) { $elementor_instance = \Elementor\Plugin::instance(); return $elementor_instance->frontend->get_builder_content_for_display($content_id); } public static function esc_options($str, $options = [], $default = '') { if(!in_array($str, $options)) { return $default; } return $str; } public static function img_meta($id) { $attachment = get_post($id); if($attachment == null || $attachment->post_type != 'attachment') { return null; } return [ 'alt' => get_post_meta($attachment->ID, '_wp_attachment_image_alt', true), 'caption' => $attachment->post_excerpt, 'description' => $attachment->post_content, 'href' => get_permalink($attachment->ID), 'src' => $attachment->guid, 'title' => $attachment->post_title, ]; } public static function _product_tag_sale_badge($settings = null) { global $product; $terms = get_the_terms(get_the_ID(), 'product_tag'); $badge_position = (isset($settings['badge_position']) && !empty($settings['badge_position'])) ? esc_attr($settings['badge_position']) : 'top-right'; $badge_align = (isset($settings['badge_align']) && !empty($settings['badge_align'])) ? esc_attr($settings['badge_align']) : 'horizontal'; if($product->is_on_sale() || !empty($terms)) : ?>