$value ) { if ( is_array( $value ) && 'class' == $name ) { $value = implode( ' ', $value ); }elseif ( is_array( $value ) ) { $value = json_encode( $value ); } if ( in_array( $name, array( 'alt', 'rel', 'title' ) ) ) { $value = str_replace( ']*?>.*?@si', '', $value ); } $return .= ' ' . esc_attr( $name ) . '="' . esc_attr( $value ) . '"'; } return $return; } public static function get_icon( $icon ) { switch ( $icon ) { case 'facebook': return ''; break; case 'twitter': return ''; break; case 'whatsapp': return ''; break; case 'pinterest': return ''; break; case 'linkedin': return ''; break; case 'email': return ''; break; default: $return = apply_filters( 'modula_get_icon', '', $icon ); return $return; break; } } public static function hover_effects_elements( $effect ) { $effects_with_title = apply_filters( 'modula_effects_with_title', array( 'under', 'fluid-up', 'hide', 'quiet', 'reflex', 'curtain', 'lens', 'appear', 'crafty', 'seemo', 'comodo', 'pufrobo', 'lily', 'sadie', 'honey', 'layla', 'zoe', 'oscar', 'marley', 'ruby', 'roxy', 'bubba', 'dexter', 'sarah', 'chico', 'milo', 'julia', 'hera', 'winston', 'selena', 'terry', 'phoebe', 'apollo', 'steve', 'jazz', 'ming', 'lexi', 'duke', 'tilt_1', 'tilt_3', 'tilt_7','greyscale', 'centered-bottom' ) ); $effects_with_description = apply_filters( 'modula_effects_with_description', array( 'under', 'fluid-up', 'hide', 'reflex', 'lens', 'crafty', 'pufrobo', 'lily', 'sadie', 'layla', 'zoe', 'oscar', 'marley', 'ruby', 'roxy', 'bubba', 'dexter', 'sarah', 'chico', 'milo', 'julia', 'selena', 'apollo', 'steve', 'jazz', 'ming', 'lexi', 'duke', 'tilt_1', 'tilt_3', 'tilt_7','greyscale', 'centered-bottom' ) ); $effects_with_social = apply_filters( 'modula_effects_with_social', array( 'under', 'comodo', 'seemo', 'appear', 'lens', 'curtain', 'reflex', 'catinelle', 'quiet', 'hide', 'pufrobo', 'lily', 'sadie', 'zoe', 'ruby', 'roxy', 'bubba', 'dexter', 'sarah', 'chico', 'julia', 'hera', 'winston', 'selena', 'terry', 'phoebe', 'ming','greyscale', 'centered-bottom' ) ); $effects_with_extra_scripts = apply_filters( 'modula_effects_with_scripts', array( 'tilt_1', 'tilt_3', 'tilt_7' ) ); return array( 'title' => in_array( $effect, $effects_with_title ), 'description' => in_array( $effect, $effects_with_description ), 'social' => in_array( $effect, $effects_with_social ), 'scripts' => in_array( $effect, $effects_with_extra_scripts ) ); } /** * Callback to sort tabs/fields on priority. * * @since 2.0.0 * * @return bool */ public static function sort_data_by_priority( $a, $b ) { if ( !isset( $a['priority'], $b['priority'] ) ) { return -1; } if ( $a['priority'] == $b['priority'] ) { return 0; } return $a['priority'] < $b['priority'] ? -1 : 1; } public static function get_image_info( $att_id, $what ) { $caption = ''; switch ( $what ) { case 'title': $caption = get_the_title( $att_id ); break; case 'caption': $caption = wp_get_attachment_caption( $att_id ); break; case 'description': $caption = get_the_content( $att_id ); break; } return $caption; } public static function get_title( $item, $default_source ) { $title = isset( $item['title'] ) ? $item['title'] : ''; if ( '' == $title && 'none' != $default_source ) { $title = self::get_image_info( $item['id'], $default_source ); } return $title; } public static function get_description( $item, $default_source ) { $description = isset( $item['description'] ) ? $item['description'] : ''; if ( '' == $description && 'none' != $default_source ) { $description = self::get_image_info( $item['id'], $default_source ); } return $description; } public static function get_galleries() { $galleries = get_posts( array( 'post_type' => 'modula-gallery', 'posts_per_page' => -1 ) ); $gallery_array = array( 'none' => esc_html__( 'None', 'modula-best-grid-gallery' ) ); foreach ( $galleries as $gallery ) { $gallery_array[$gallery->ID] = esc_html( $gallery->post_title ); } return $gallery_array; } public static function sanitize_rgba_colour( $color ) { if ( empty( $color ) ) { return ''; } if ( is_array( $color ) ){ return 'rgba(0,0,0,0)'; } if ( false === strpos( $color, 'rgba' ) ) { return sanitize_hex_color( $color ); } $color = str_replace( ' ', '', $color ); sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha ); return 'rgba(' . absint( $red ) . ',' . absint( $green ) . ',' . absint( $blue ) . ',' . floatval( $alpha ) . ')'; } public static function lightbox_default_options() { $fancybox_options = array( 'loop' => false, 'arrows' => false, 'toolbar' => true, 'keyboard' => false, 'wheel' => false, 'buttons' => array( 'close', ), 'hash' => false, 'lang' => 'en', 'touch' => false, 'protect' => false, 'i18n' => array( 'en' => array( 'CLOSE' => esc_html__( 'Close', 'modula-best-grid-gallery' ), 'NEXT' => esc_html__( 'Next', 'modula-best-grid-gallery' ), 'PREV' => esc_html__( 'Previous', 'modula-best-grid-gallery' ), 'Error' => esc_html__( 'The requested content cannot be loaded. Please try again later.', 'modula-best-grid-gallery' ), 'PLAY_START' => esc_html__( 'Start slideshow', 'modula-best-grid-gallery' ), 'PLAY_STOP' => esc_html__( 'Pause slideshow', 'modula-best-grid-gallery' ), 'FULL_SCREEN' => esc_html__( 'Full screen', 'modula-best-grid-gallery' ), 'THUMBS' => esc_html__( 'Thumbnails', 'modula-best-grid-gallery' ), 'DOWNLOAD' => esc_html__( 'Download', 'modula-best-grid-gallery' ), 'SHARE' => esc_html__( 'Share', 'modula-best-grid-gallery' ), 'ZOOM' => esc_html__( 'Zoom', 'modula-best-grid-gallery' ), ) ), 'clickSlide' => false, 'clickOutside' => false, 'dblclickContent' => false, 'dblclickSlide' => false, 'dblclickOutside' => false, 'clickContent' => false, ); return $fancybox_options; } /** * Get image sizes * * @param $size_type * @param string $size * * @return array|bool|mixed * * @since 2.3.0 */ public static function get_image_sizes( $size_type = false, $size = '' ) { global $_wp_additional_image_sizes; $sizes = array(); $get_intermediate_image_sizes = get_intermediate_image_sizes(); // Create the full array with sizes foreach ( $get_intermediate_image_sizes as $_size ) { // only default if ( in_array( $_size, array( 'thumbnail', 'medium', 'large' ) ) ) { $image_size_txt = ucfirst( strtolower( str_replace( '_', ' ', $_size ) ) ); $image_sizes_array[$_size] = $image_size_txt; $sizes[$_size]['width'] = get_option( $_size . '_size_w' ); $sizes[$_size]['height'] = get_option( $_size . '_size_h' ); $sizes[$_size]['crop'] = (bool) get_option( $_size . '_crop' ); } elseif ( isset( $_wp_additional_image_sizes[$_size] ) ) { if ( 'post-thumbnail' != $_size ) { $image_size_txt = ucfirst( strtolower( str_replace( '_', ' ', $_size ) ) ); $image_sizes_array[$_size] = $image_size_txt; } $sizes[$_size] = array( 'width' => $_wp_additional_image_sizes[$_size]['width'], 'height' => $_wp_additional_image_sizes[$_size]['height'], 'crop' => (bool) get_option( $_size . '_crop' ) ); } } // Get only 1 size if found if ( $size ) { if ( isset( $sizes[$size] ) ) { return $sizes[$size]; } else { return false; } } $image_sizes_array['full'] = esc_html__( 'Full', 'modula-best-grid-gallery' ); $image_sizes_array['custom'] = esc_html__( 'Custom', 'modula-best-grid-gallery' ); if ( $size_type ) { return $image_sizes_array; } return $sizes; } /** * Modula Placeholders * * @return mixed|void * @since 2.3.3 */ public static function modula_gallery_placeholders() { return apply_filters( 'modula_gallery_placeholders', array()); } /** * Placeholders real/front value * * @param $value * @param $object * * @return string|string[] * @since 2.3.3 */ public static function modula_placeholders_value($value,$object) { $values = apply_filters('modula_placeholder_values',array('setting'=>array(),'front'=>array()),$object); return str_replace( $values['setting'], $values['front'], $value); } }