HEX
Server: LiteSpeed
System: Linux premium221.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User: madepabj (2566)
PHP: 8.3.26
Disabled: NONE
Upload Files
File: //home/madepabj/hc-cosmetics.com/wp-content/plugins/dbea-shortcodes/functions.php
<?php 
function dbea_shortcode_template( $name = false ) {
    if (!$name)
        return false;
    if ( $overridden_template = locate_template( 'vc_templates/' . $name . '.php' ) ) {
        return $overridden_template;
    } else {
        return DBEA_SHORTCODES_PATH . '/shortcodes/templates/' . $name . '.php';
    }
}
function dbea_shortcode_woo_template( $name = false ) {
    if (!$name)
        return false;
    if ( $overridden_template = locate_template( 'vc_templates/' . $name . '.php' ) ) {
        return $overridden_template;
    } else {
        return DBEA_SHORTCODES_PATH . '/shortcodes-woo/templates/' . $name . '.php';
    }
}
function dbea_extra_class(){
    return array(
            "type" => "textfield",
            "heading" => esc_html__("Extra class name", 'dbea-shortcodes'),
            "param_name" => "extra_class"
        );
}
function dbea_getCSSAnimation( $css_animation ) {
    $output = '';
    if ( '' !== $css_animation && 'none' !== $css_animation ) {
        wp_enqueue_script( 'waypoints' );
        wp_enqueue_style( 'animate-css' );
        $output = ' wpb_animate_when_almost_visible wpb_' . $css_animation . ' ' . $css_animation;
    }

    return $output;
}
function dbea_css_animation(){
    return array(
        'type' => 'dropdown',
        'heading' => esc_html__( 'CSS Animation', 'dbea-shortcodes' ),
        'param_name' => 'css_animation',
        'admin_label' => true,
        'value' => array(
            esc_html__( 'No', 'dbea-shortcodes' ) => '',
            esc_html__( 'Top to bottom', 'dbea-shortcodes' ) => 'top-to-bottom',
            esc_html__( 'Bottom to top', 'dbea-shortcodes' ) => 'bottom-to-top',
            esc_html__( 'Left to right', 'dbea-shortcodes' ) => 'left-to-right',
            esc_html__( 'Right to left', 'dbea-shortcodes' ) => 'right-to-left',
            esc_html__( 'Appear from center', 'dbea-shortcodes' ) => 'appear'
        ),
        'description' => esc_html__( 'Select type of animation for element to be animated when it "enters" the browsers viewport (Note: works only in modern browsers).', 'dbea-shortcodes' )
    );
}
function dbea_woo_cat_level( $parent_id, $pos, $array, $level, &$dropdown ) {
    for ( $i = $pos; $i < count( $array ); $i ++ ) {
        if ( $array[ $i ]->category_parent == $parent_id ) {
            $name = str_repeat( '- ', $level ) . $array[ $i ]->name;
            $value = $array[ $i ]->slug;
            $dropdown[] = array(
                'label' => $name,
                'value' => $value,
            );
            dbea_woo_cat_level( $array[ $i ]->term_id, $i, $array, $level + 1, $dropdown );
        }
    }
}
function dbea_woo_cat($bool =1) {
    $args = array(
            'type' => 'post',
            'child_of' => 0,
            'parent' => '',
            //'orderby' => 'parent_id',
            'order' => 'ASC',
            'hide_empty' => false,
            'hierarchical' => 1,
            'exclude' => '',
            'include' => '',
            'number' => '',
            'taxonomy' => 'product_cat',
            'pad_counts' => false,

        );
    $categories = get_categories( $args );
    if ($bool==0) return $categories;
    $dropdown = array(); $woocat_value = array(); 
    dbea_sort_level_catid(0, $categories, 0 , $dropdown);
    foreach ($dropdown as $cat) {
        $woocat_value[$cat['label']] = $cat['value'];
    }
    return $woocat_value;
}
function dbea_sort_level_catid( $parent_id, $array, $level, &$dropdown){
    $keys = array_keys( $array );
    $i = 0;
    while ( $i < count( $array ) ) {
        $key = $keys[ $i ];
        $item = $array[ $key ];
        $i ++;
        if ( $item->category_parent == $parent_id ) {
            $name = str_repeat( '- ', $level ) . $item->name;
            $value = $item->slug;
            $dropdown[] = array(
                'label' => $name . '(id:' . $item->term_id . ')',
                'value' => $value,
            );
            //$dropdown[$name] = $value;
            unset( $array[ $key ] );
            $array = dbea_sort_level_catid( $item->term_id, $array, $level + 1, $dropdown );
            $keys = array_keys( $array );
            $i = 0;
        }
    }

    return $array;
}
function dbea_cat(){
    global $wpdb;
    $sql = $wpdb->prepare( "
        SELECT a.name,a.slug,a.term_id 
        FROM {$wpdb->terms} a JOIN  {$wpdb->term_taxonomy} b ON (a.term_id= b.term_id ) 
        WHERE b.count> %d and b.taxonomy = %s",
        0,'category' );
    $results = $wpdb->get_results($sql);
    $cat_value = array();
    foreach ($results as $cat) {
        $cat_value[$cat->name] = $cat->slug;
    }
    return $cat_value;
}
function dbea_woo_tags_array(){
    $args = array(
        'taxonomy' => 'product_tag',
        'number' => 10000,
        'format' => 'array',
    );
    $tags = get_terms( $args['taxonomy'], $args ); // Always query top tags
    $tags_arr = array();
    foreach ($tags as $key => $value) {
        $tags_arr[$value->name]  = $value->term_id;
    }
    return $tags_arr;
}
function dbea_ajaxtab_order_title($tab){
    switch ($tab) {
        case 'recent':
            return array('name'=>$tab,'title'=>esc_html__('New products','dbea-shortcodes'),'short_title'=>esc_html__('New arrival', 'dbea-shortcodes'));
        case 'featured_product':
            return array('name'=>$tab,'title'=>esc_html__('Featured Products','dbea-shortcodes'),'short_title'=>esc_html__('Featured','dbea-shortcodes'));
        case 'top_rate':
            return array('name'=>$tab,'title'=> esc_html__('Top Rated','dbea-shortcodes'),'short_title'=>esc_html__('Top Rated', 'dbea-shortcodes'));
        case 'best_selling':
            return array('name'=>$tab,'title'=>esc_html__('Best Seller','dbea-shortcodes'),'short_title'=>esc_html__('Best Seller','dbea-shortcodes'));
        case 'on_sale':
            return array('name'=>$tab,'title'=>esc_html__('Sale Off','dbea-shortcodes'),'short_title'=>esc_html__('Sale off','dbea-shortcodes'));
    }
}

add_filter( 'vc_iconpicker-type-ionicons', 'vc_iconpicker_type_ionicons' );
function vc_iconpicker_type_ionicons( $icons ) {
    $icon_ion = array(); $ioniocns_icons = array();
    $content_ion = '';
    if( file_exists( get_template_directory().'/assets/fonts/ionicons/css/ionicons.css' ) ) {
        $content_ion = file_get_contents(get_template_directory().'/assets/fonts/ionicons/css/ionicons.css');
    }
    preg_match_all('/\.(ion-(?:\w+(?:-)?)+):before/', $content_ion , $matches_ion, PREG_SET_ORDER);
    $icon_ion['ion-none'] = ' ';
    foreach($matches_ion as $k => $v){
       $icon_ion[$k] = $v[1];
    }
    if( is_array($icon_ion ) && !empty($icon_ion)) {
        foreach( $icon_ion as $k => $v) { 
            $ioniocns_icons[] = array( $v => $v );
        }
    }
    return array_merge( $icons, $ioniocns_icons );
}
add_action('admin_enqueue_scripts', 'dbea_admin_ioniocns_scripts');
function dbea_admin_ioniocns_scripts(){
    wp_enqueue_style('font-ionicons', get_template_directory_uri() . '/assets/fonts/ionicons/css/ionicons.min.css');
}

function sns_productIdAutocompleteSuggester( $query ) {
    global $wpdb;
    $product_id = (int) $query;
    $post_meta_infos = $wpdb->get_results( $wpdb->prepare( "SELECT a.ID AS id, a.post_title AS title, b.meta_value AS sku
                FROM {$wpdb->posts} AS a
                LEFT JOIN ( SELECT meta_value, post_id  FROM {$wpdb->postmeta} WHERE `meta_key` = '_sku' ) AS b ON b.post_id = a.ID
                WHERE a.post_type = 'product' AND ( a.ID = '%d' OR b.meta_value LIKE '%%%s%%' OR a.post_title LIKE '%%%s%%' )", $product_id > 0 ? $product_id : - 1, stripslashes( $query ), stripslashes( $query ) ), ARRAY_A );

    $results = array();
    if ( is_array( $post_meta_infos ) && ! empty( $post_meta_infos ) ) {
        foreach ( $post_meta_infos as $value ) {
            $data = array();
            $data['value'] = $value['id'];
            $data['label'] = esc_html__( 'Id', 'js_composer' ) . ': ' . $value['id'] . ( ( strlen( $value['title'] ) > 0 ) ? ' - ' . esc_html__( 'Title', 'js_composer' ) . ': ' . $value['title'] : '' ) . ( ( strlen( $value['sku'] ) > 0 ) ? ' - ' . esc_html__( 'Sku', 'js_composer' ) . ': ' . $value['sku'] : '' );
            $results[] = $data;
        }
    }

    return $results;
}
function sns_productIdAutocompleteRender( $query ) {
    $query = trim( $query['value'] ); // get value from requested
    if ( ! empty( $query ) ) {
        // get product
        $product_object = wc_get_product( (int) $query );
        if ( is_object( $product_object ) ) {
            $product_sku = $product_object->get_sku();
            $product_title = $product_object->get_title();
            $product_id = $product_object->get_id();

            $product_sku_display = '';
            if ( ! empty( $product_sku ) ) {
                $product_sku_display = ' - ' . esc_html__( 'Sku', 'js_composer' ) . ': ' . $product_sku;
            }

            $product_title_display = '';
            if ( ! empty( $product_title ) ) {
                $product_title_display = ' - ' . esc_html__( 'Title', 'js_composer' ) . ': ' . $product_title;
            }

            $product_id_display = esc_html__( 'Id', 'js_composer' ) . ': ' . $product_id;

            $data = array();
            $data['value'] = $product_id;
            $data['label'] = $product_id_display . $product_title_display . $product_sku_display;

            return ! empty( $data ) ? $data : false;
        }

        return false;
    }

    return false;
}