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 [type] [description]
*/
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', 'jetwoo-widgets-for-elementor' ), ), $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', 'slug' );
}
/**
* Return post terms.
*
* @since 1.0.0
* @param [type] $tax - category, post_tag, post_format.
* @param [type] $return_key - slug, term_id.
* @return array
*/
public function get_terms_array( $tax = array( 'category' ), $return_key = 'slug' ) {
$terms = array();
$tax = is_array( $tax ) ? $tax : array( $tax ) ;
foreach ( $tax as $key => $value ) {
if ( ! taxonomy_exists( $value ) ) {
unset( $tax[ $key ] );
}
}
$all_terms = (array) get_terms( $tax, array(
'hide_empty' => 0,
'hierarchical' => 0,
) );
if ( empty( $all_terms ) || is_wp_error( $all_terms ) ) {
return '';
}
foreach ( $all_terms as $term ) {
$terms[ $term->$return_key ] = $term->name;
}
return $terms;
}
/**
* 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-woo-widgets/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', 'jetwoo-widgets-for-elementor' ),
'ID' => esc_html__( 'ID', 'jetwoo-widgets-for-elementor' ),
'author' => esc_html__( 'Author', 'jetwoo-widgets-for-elementor' ),
'title' => esc_html__( 'Title', 'jetwoo-widgets-for-elementor' ),
'name' => esc_html__( 'Name (slug)', 'jetwoo-widgets-for-elementor' ),
'date' => esc_html__( 'Date', 'jetwoo-widgets-for-elementor' ),
'modified' => esc_html__( 'Modified', 'jetwoo-widgets-for-elementor' ),
'rand' => esc_html__( 'Rand', 'jetwoo-widgets-for-elementor' ),
'comment_count' => esc_html__( 'Comment Count', 'jetwoo-widgets-for-elementor' ),
'menu_order' => esc_html__( 'Menu Order', 'jetwoo-widgets-for-elementor' ),
);
}
/**
* Returns allowed order fields for options
*
* @return array
*/
public function order_arr() {
return array(
'desc' => esc_html__( 'Descending', 'jetwoo-widgets-for-elementor' ),
'asc' => esc_html__( 'Ascending', 'jetwoo-widgets-for-elementor' ),
);
}
/**
* Returns allowed order by fields for options
*
* @return array
*/
public function verrtical_align_attr() {
return array(
'baseline' => esc_html__( 'Baseline', 'jetwoo-widgets-for-elementor' ),
'top' => esc_html__( 'Top', 'jetwoo-widgets-for-elementor' ),
'middle' => esc_html__( 'Middle', 'jetwoo-widgets-for-elementor' ),
'bottom' => esc_html__( 'Bottom', 'jetwoo-widgets-for-elementor' ),
'sub' => esc_html__( 'Sub', 'jetwoo-widgets-for-elementor' ),
'super' => esc_html__( 'Super', 'jetwoo-widgets-for-elementor' ),
'text-top' => esc_html__( 'Text Top', 'jetwoo-widgets-for-elementor' ),
'text-bottom' => esc_html__( 'Text Bottom', 'jetwoo-widgets-for-elementor' ),
);
}
/**
* 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 );
}
/**
* 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() ) {
$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 = network_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( '