if (!defined('BDTUSK_CP')) { define('BDTUSK_CP', ''); } //Add prefix for all widgets if (!defined('BDTUSK_NC')) { define('BDTUSK_NC', ''); } // if you have any custom style if (!defined('BDTUSK_SLUG')) { define('BDTUSK_SLUG', 'ultimate-store-kit'); } // set your own alias if (!defined('BDTUSK_VER')) { define('BDTUSK_VER', 'Ultimate Store Kit'); } // Set your own name for plugin if (!defined('BDTUSK_NAME')) { define('BDTUSK_NAME', 'Ultimate Store Kit'); } /** * Show any alert by this function * * @param mixed $message [description] * @param class prefix $type [description] * @param boolean $close [description] * * @return helper [description] */ function ultimate_store_kit_is_edit() { return Plugin::$instance->editor->is_edit_mode(); } function ultimate_store_kit_is_preview() { return Plugin::$instance->preview->is_preview_mode(); } function ultimate_store_kit_alert($message, $type = 'warning', $close = true) { ?>
'; if ($close) : $output .= ''; endif; $output .= wp_kses_post($message); $output .= ''; return $output; } /** * all array css classes will output as proper space * * @param array $classes shortcode css class as array * * @return proper string */ function ultimate_store_kit_get_post_types($args = []) { $post_type_args = [ 'show_in_nav_menus' => true, ]; if (!empty($args['post_type'])) { $post_type_args['name'] = $args['post_type']; } $_post_types = get_post_types($post_type_args, 'objects'); $post_types = ['0' => esc_html__('Select Type', 'ultimate-store-kit')]; foreach ($_post_types as $post_type => $object) { $post_types[$post_type] = $object->label; } return $post_types; } /** * Add REST API support to an already registered post type. */ // function bdt_custom_post_type_rest_support() { // global $wp_post_types; // $post_types = ultimate_store_kit_get_post_types(); // foreach( $post_types as $post_type ) { // $post_type_name = $post_type; // if( isset( $wp_post_types[ $post_type_name ] ) ) { // $wp_post_types[$post_type_name]->show_in_rest = true; // $wp_post_types[$post_type_name]->rest_base = $post_type_name; // $wp_post_types[$post_type_name]->rest_controller_class = 'WP_REST_Posts_Controller'; // } // } // } // add_action( 'init', 'bdt_custom_post_type_rest_support', 25 ); function ultimate_store_kit_allow_tags($tag = null) { $tag_allowed = wp_kses_allowed_html('post'); $tag_allowed['input'] = [ 'class' => [], 'id' => [], 'name' => [], 'value' => [], 'checked' => [], 'type' => [], ]; $tag_allowed['select'] = [ 'class' => [], 'id' => [], 'name' => [], 'value' => [], 'multiple' => [], 'type' => [], ]; $tag_allowed['option'] = [ 'value' => [], 'selected' => [], ]; $tag_allowed['title'] = [ 'a' => [ 'href' => [], 'title' => [], 'class' => [], ], 'br' => [], 'em' => [], 'strong' => [], 'hr' => [], ]; $tag_allowed['text'] = [ 'a' => [ 'href' => [], 'title' => [], 'class' => [], ], 'br' => [], 'em' => [], 'strong' => [], 'hr' => [], 'i' => [ 'class' => [], ], 'span' => [ 'class' => [], ], ]; $tag_allowed['svg'] = [ 'svg' => [ 'version' => [], 'xmlns' => [], 'viewbox' => [], 'xml:space' => [], 'xmlns:xlink' => [], 'x' => [], 'y' => [], 'style' => [], ], 'g' => [], 'path' => [ 'class' => [], 'd' => [], ], 'ellipse' => [ 'class' => [], 'cx' => [], 'cy' => [], 'rx' => [], 'ry' => [], ], 'circle' => [ 'class' => [], 'cx' => [], 'cy' => [], 'r' => [], ], 'rect' => [ 'x' => [], 'y' => [], 'transform' => [], 'height' => [], 'width' => [], 'class' => [], ], 'line' => [ 'class' => [], 'x1' => [], 'x2' => [], 'y1' => [], 'y2' => [], ], 'style' => [], ]; if ($tag == null) { return $tag_allowed; } elseif (is_array($tag)) { $new_tag_allow = []; foreach ($tag as $_tag) { $new_tag_allow[$_tag] = $tag_allowed[$_tag]; } return $new_tag_allow; } else { return isset($tag_allowed[$tag]) ? $tag_allowed[$tag] : []; } } /** * post pagination */ function ultimate_store_kit_post_pagination($wp_query) { /** Stop execution if there's only 1 page */ if ($wp_query->max_num_pages <= 1) { return; } if (is_front_page()) { $paged = (get_query_var('page')) ? get_query_var('page') : 1; } else { $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; } $max = intval($wp_query->max_num_pages); /** Add current page to the array */ if ($paged >= 1) { $links[] = $paged; } /** Add the pages around the current page to the array */ if ($paged >= 3) { $links[] = $paged - 1; $links[] = $paged - 2; } if (($paged + 2) <= $max) { $links[] = $paged + 2; $links[] = $paged + 1; } echo '