芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/optimyar/wp-content/plugins/jet-elements/includes/class-jet-elements-tools.php
1, 'tab' => 1, 'mob' => 1, ) ); $classes = array(); foreach ( $columns as $device => $cols ) { if ( ! empty( $cols ) ) { $classes[] = sprintf( 'col-%1$s-%2$s', $device, $cols ); } } return implode( ' ' , $classes ); } /** * Returns disable columns gap nad rows gap classes string * * @param string $use_cols_gap [description] * @param string $use_rows_gap [description] * @return string */ public function gap_classes( $use_cols_gap = 'yes', $use_rows_gap = 'yes' ) { $result = array(); foreach ( array( 'cols' => $use_cols_gap, 'rows' => $use_rows_gap ) as $element => $value ) { if ( 'yes' !== $value ) { $result[] = sprintf( 'disable-%s-gap', $element ); } } return implode( ' ', $result ); } /** * Returns image size array in slug => name format * * @return array */ public function get_image_sizes() { global $_wp_additional_image_sizes; $sizes = get_intermediate_image_sizes(); $result = array(); foreach ( $sizes as $size ) { if ( in_array( $size, array( 'thumbnail', 'medium', 'medium_large', 'large' ) ) ) { $result[ $size ] = ucwords( trim( str_replace( array( '-', '_' ), array( ' ', ' ' ), $size ) ) ); } else { $result[ $size ] = sprintf( '%1$s (%2$sx%3$s)', ucwords( trim( str_replace( array( '-', '_' ), array( ' ', ' ' ), $size ) ) ), $_wp_additional_image_sizes[ $size ]['width'], $_wp_additional_image_sizes[ $size ]['height'] ); } } return array_merge( array( 'full' => esc_html__( 'Full', 'jet-elements' ), ), $result ); } /** * Get categories list. * * @return array */ public function get_categories() { $categories = get_categories(); if ( empty( $categories ) || ! is_array( $categories ) ) { return array(); } return wp_list_pluck( $categories, 'name', 'term_id' ); } /** * Returns icons data list. * * @return array */ public function get_theme_icons_data() { $default = array( 'icons' => false, 'format' => 'fa %s', 'file' => false, ); /** * Filter default icon data before useing * * @var array */ $icon_data = apply_filters( 'jet-elements/controls/icon/data', $default ); $icon_data = array_merge( $default, $icon_data ); return $icon_data; } /** * Returns allowed order by fields for options * * @return array */ public function orderby_arr() { return array( 'none' => esc_html__( 'None', 'jet-elements' ), 'ID' => esc_html__( 'ID', 'jet-elements' ), 'author' => esc_html__( 'Author', 'jet-elements' ), 'title' => esc_html__( 'Title', 'jet-elements' ), 'name' => esc_html__( 'Name (slug)', 'jet-elements' ), 'date' => esc_html__( 'Date', 'jet-elements' ), 'modified' => esc_html__( 'Modified', 'jet-elements' ), 'rand' => esc_html__( 'Rand', 'jet-elements' ), 'comment_count' => esc_html__( 'Comment Count', 'jet-elements' ), 'menu_order' => esc_html__( 'Menu Order', 'jet-elements' ), ); } /** * Returns allowed order fields for options * * @return array */ public function order_arr() { return array( 'desc' => esc_html__( 'Descending', 'jet-elements' ), 'asc' => esc_html__( 'Ascending', 'jet-elements' ), ); } /** * Returns allowed order by fields for options * * @return array */ public function verrtical_align_attr() { return array( 'baseline' => esc_html__( 'Baseline', 'jet-elements' ), 'top' => esc_html__( 'Top', 'jet-elements' ), 'middle' => esc_html__( 'Middle', 'jet-elements' ), 'bottom' => esc_html__( 'Bottom', 'jet-elements' ), 'sub' => esc_html__( 'Sub', 'jet-elements' ), 'super' => esc_html__( 'Super', 'jet-elements' ), 'text-top' => esc_html__( 'Text Top', 'jet-elements' ), 'text-bottom' => esc_html__( 'Text Bottom', 'jet-elements' ), ); } /** * Returns array with numbers in $index => $name format for numeric selects * * @param integer $to Max numbers * @return array */ public function get_select_range( $to = 10 ) { $range = range( 1, $to ); return array_combine( $range, $range ); } /** * Returns badge placeholder URL * * @return void */ public function get_badge_placeholder() { return jet_elements()->plugin_url( 'assets/images/placeholder-badge.svg' ); } /** * Rturns image tag or raw SVG * * @param string $url image URL. * @param array $attr [description] * @return string */ public function get_image_by_url( $url = null, $attr = array(), $tag = 'div' ) { $url = esc_url( $url ); if ( empty( $url ) ) { return; } $ext = pathinfo( $url, PATHINFO_EXTENSION ); $attr = array_merge( array( 'alt' => '' ), $attr ); if ( 'svg' !== $ext ) { return sprintf( '
', $url, $this->get_attr_string( $attr ) ); } $base_url = site_url( '/' ); $svg_path = str_replace( $base_url, ABSPATH, $url ); $key = md5( $svg_path ); $svg = get_transient( $key ); if ( ! $svg ) { $svg = file_get_contents( $svg_path ); } if ( ! $svg ) { return sprintf( '
', $url, $this->get_attr_string( $attr ) ); } set_transient( $key, $svg, DAY_IN_SECONDS ); unset( $attr['alt'] ); return sprintf( '<' . $tag . '%2$s>%1$s' . $tag . '>', $svg, $this->get_attr_string( $attr ) ); } /** * Return attributes string from attributes array. * * @param array $attr Attributes string. * @return string */ public function get_attr_string( $attr = array() ) { if ( empty( $attr ) || ! is_array( $attr ) ) { return; } $result = ''; foreach ( $attr as $key => $value ) { $result .= sprintf( ' %s="%s"', esc_attr( $key ), esc_attr( $value ) ); } return $result; } /** * Returns carousel arrow * * @param array $classes Arrow additional classes list. * @return string */ // public function get_carousel_arrow( $classes ) { // $format = apply_filters( 'jet_elements/carousel/arrows_format', '
', $classes ); // return sprintf( $format, implode( ' ', $classes ) ); // } public function get_carousel_arrow( $icon = '', $direction = 'next', $classes = '', $get_only_svg = false ) { if ( '' === $icon ) { return; } $arrows = $this->get_svg_arrows( $icon ); if ( false === $get_only_svg ) { $format = apply_filters( 'jet_elements/carousel/arrows_format', '
%1$s
' ); return sprintf( $format, $arrows[$direction], $classes ); } else { return $arrows[$direction]; } } /** * Get post types options list * * @return array */ public function get_post_types() { $post_types = get_post_types( array( 'public' => true ), 'objects' ); $deprecated = apply_filters( 'jet-elements/post-types-list/deprecated', array( 'attachment', 'elementor_library' ) ); $result = array(); if ( empty( $post_types ) ) { return $result; } foreach ( $post_types as $slug => $post_type ) { if ( in_array( $slug, $deprecated ) ) { continue; } $result[ $slug ] = $post_type->label; } return $result; } /** * Return available arrows list * @return array */ public function get_available_prev_arrows_list() { return apply_filters( 'jet_elements/carousel/available_arrows/prev', array( 'fa fa-angle-left' => __( 'Angle', 'jet-elements' ), 'fa fa-chevron-left' => __( 'Chevron', 'jet-elements' ), 'fa fa-angle-double-left' => __( 'Angle Double', 'jet-elements' ), 'fa fa-arrow-left' => __( 'Arrow', 'jet-elements' ), 'fa fa-caret-left' => __( 'Caret', 'jet-elements' ), 'fa fa-long-arrow-alt-left' => __( 'Long Arrow', 'jet-elements' ), 'fa fa-arrow-circle-left' => __( 'Arrow Circle', 'jet-elements' ), 'fa fa-chevron-circle-left' => __( 'Chevron Circle', 'jet-elements' ), 'fa fa-caret-square-left' => __( 'Caret Square', 'jet-elements' ), ) ); } /** * Return svg next/prev arrows * @return array */ public static function get_svg_arrows( $arrow_type ) { $arrow = []; switch( $arrow_type ) { case 'fa fa-angle-right': case 'fa fa-angle-left': $arrow['prev'] = '
'; $arrow['next'] = '
'; break; case 'fa fa-chevron-right': case 'fa fa-chevron-left': $arrow['prev'] = '
'; $arrow['next'] = '
'; break; case 'fa fa-angle-double-right': case 'fa fa-angle-double-left': $arrow['prev'] = '
'; $arrow['next'] = '
'; break; case 'fa fa-arrow-right': case 'fa fa-arrow-left': $arrow['prev'] = '
'; $arrow['next'] = '
'; break; case 'fa fa-caret-right': case 'fa fa-caret-left': $arrow['prev'] = '
'; $arrow['next'] = '
'; break; case 'fa fa-long-arrow-alt-right': case 'fa fa-long-arrow-alt-left': $arrow['prev'] = '
'; $arrow['next'] = '
'; break; case 'fa fa-arrow-circle-right': case 'fa fa-arrow-circle-left': $arrow['prev'] = '
'; $arrow['next'] = '
'; break; case 'fa fa-chevron-circle-right': case 'fa fa-chevron-circle-left': $arrow['prev'] = '
'; $arrow['next'] = '
'; break; case 'fa fa-caret-square-right': case 'fa fa-caret-square-left': $arrow['prev'] = '
'; $arrow['next'] = '
'; break; } $arrow = apply_filters( 'jet_elements/carousel/nav-arrow', $arrow, $arrow_type ); return $arrow; } /** * Return available arrows list * @return array */ public function get_available_next_arrows_list() { return apply_filters( 'jet_elements/carousel/available_arrows/next', array( 'fa fa-angle-right' => __( 'Angle', 'jet-elements' ), 'fa fa-chevron-right' => __( 'Chevron', 'jet-elements' ), 'fa fa-angle-double-right' => __( 'Angle Double', 'jet-elements' ), 'fa fa-arrow-right' => __( 'Arrow', 'jet-elements' ), 'fa fa-caret-right' => __( 'Caret', 'jet-elements' ), 'fa fa-long-arrow-alt-right' => __( 'Long Arrow', 'jet-elements' ), 'fa fa-arrow-circle-right' => __( 'Arrow Circle', 'jet-elements' ), 'fa fa-chevron-circle-right' => __( 'Chevron Circle', 'jet-elements' ), 'fa fa-caret-square-right' => __( 'Caret Square', 'jet-elements' ), ) ); } /** * Return available arrows list * @return array */ public function get_available_title_html_tags() { return array( 'h1' => esc_html__( 'H1', 'jet-elements' ), 'h2' => esc_html__( 'H2', 'jet-elements' ), 'h3' => esc_html__( 'H3', 'jet-elements' ), 'h4' => esc_html__( 'H4', 'jet-elements' ), 'h5' => esc_html__( 'H5', 'jet-elements' ), 'h6' => esc_html__( 'H6', 'jet-elements' ), 'div' => esc_html__( 'div', 'jet-elements' ), 'span' => esc_html__( 'span', 'jet-elements' ), 'p' => esc_html__( 'p', 'jet-elements' ), ); } /** * Get post taxonomies for options. * * @return array */ public function get_taxonomies_for_options() { $args = array( 'public' => true, ); $taxonomies = get_taxonomies( $args, 'objects', 'and' ); return wp_list_pluck( $taxonomies, 'label', 'name' ); } /** * Get elementor templates list for options. * * @return array */ public function get_elementor_templates_options() { $templates = jet_elements()->elementor()->templates_manager->get_source( 'local' )->get_items(); $options = array( '0' => '— ' . esc_html__( 'Select', 'jet-elements' ) . ' —', ); foreach ( $templates as $template ) { $options[ $template['template_id'] ] = $template['title'] . ' (' . $template['type'] . ')'; } return $options; } /** * Is script debug. * * @return bool */ public function is_script_debug() { return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG; } /** * Is FA5 migration. * * @return bool */ public function is_fa5_migration() { if ( defined( 'ELEMENTOR_VERSION' ) && version_compare( ELEMENTOR_VERSION, '2.6.0', '>=' ) && Elementor\Icons_Manager::is_migration_allowed() ) { return true; } return false; } /** * Check if is valid timestamp * * @param int|string $timestamp * @return boolean */ public function is_valid_timestamp( $timestamp ) { return ( ( string ) ( int ) $timestamp === $timestamp ) && ( $timestamp <= PHP_INT_MAX ) && ( $timestamp >= ~PHP_INT_MAX ); } /** * @param $tag * @return mixed|string */ public function validate_html_tag( $tag ) { $allowed_tags = array( 'article', 'aside', 'div', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'main', 'nav', 'p', 'section', 'span', ); return in_array( strtolower( $tag ), $allowed_tags ) ? $tag : 'div'; } public function allowed_meta_callbacks() { $callbacks = apply_filters( 'jet-elements/posts/meta_callbacks', array( '' => esc_html__( 'Clean', 'jet-elements' ), 'get_permalink' => 'get_permalink', 'get_the_title' => 'get_the_title', 'wp_get_attachment_url' => 'wp_get_attachment_url', 'wp_get_attachment_image' => 'wp_get_attachment_image', 'date' => esc_html__( 'Format date', 'jet-elements' ), 'date_i18n' => esc_html__( 'Format date (localized)', 'jet-elements' ), ) ); return $callbacks; } /** * @return false|int|string */ public function get_plugin_license() { if ( ! class_exists( '\Jet_Dashboard\Utils' ) ) { \Jet_Dashboard\Dashboard::get_instance(); } return \Jet_Dashboard\Utils::get_plugin_license_key( 'jet-elements/jet-elements.php' ); } /** * Returns the instance. * * @since 1.0.0 * @return Jet_Elements_Tools */ public static function get_instance( $shortcodes = array() ) { // If the single instance hasn't been set, set it now. if ( null == self::$instance ) { self::$instance = new self( $shortcodes ); } return self::$instance; } } } /** * Returns instance of Jet_Elements_Tools * * @return Jet_Elements_Tools */ function jet_elements_tools() { return Jet_Elements_Tools::get_instance(); }