' . esc_html( $filter_by_text ) . '';
}
// If enabled, this overwrites the filters mode in mobile view
if ( wp_is_mobile() && (isset( $settings['enableMobileDropdownFilters'] ) && '1' == $settings['enableMobileDropdownFilters'] || isset( $settings['dropdownFilters'] ) && '1' == $settings['dropdownFilters'] )){
echo "';
return;
}
if ( !wp_is_mobile() && isset( $settings['dropdownFilters'] ) && '1' == $settings['dropdownFilters'] ){
echo "';
return;
}
echo "";
}
// Add filters to items
function modula_pro_add_filters( $item_data, $item, $settings ) {
if ( isset( $item['filters'] ) ) {
$filters = explode( ',', $item['filters'] );
$item_data['item_classes'][] = 'jtg-filter-all';
foreach ( $filters as $filter ) {
$item_data['item_classes'][] = 'jtg-filter-' . esc_attr(urldecode(sanitize_title( $filter )));
}
}
return $item_data;
}
/**
* @param $template_data
*
* @return string
*
* Adds extra class to modula-gallery that is used to position the filters
*/
function modula_pro_extra_modula_section_classes($template_data){
if ( ! isset( $template_data['settings']['filters'] ) || empty( Modula_Pro_Helper::remove_empty_items( $template_data['settings']['filters'] ) ) ) {
return $template_data;
}
$filter_position = isset( $template_data['settings']['filterPositioning'] ) ? $template_data['settings']['filterPositioning'] : '';
$horizontal = array( 'top', 'bottom', 'top_bottom' );
$extra_classes = in_array( $filter_position, $horizontal ) ? ' horizontal-filters' : ' vertical-filters' ;
$template_data['gallery_container']['class'][] = $extra_classes;
return $template_data;
}
/**
* @return array
*
* Return default active filter
*/
function modula_pro_current_active_filter() {
$id = get_the_ID();
$settings = get_post_meta($id,'modula-settings',true);
$filters = isset($settings['filters']) ? $settings['filters'] : false;
$return = array(
'All' => esc_html__( 'All','modula-pro' )
);
if( $filters ) {
foreach ( $filters as $filter ) {
$return[ $filter ] = esc_html( $filter );
}
}
return $return;
}
function modula_pro_sanitize_color( $color ){
if ( method_exists( 'Modula_Helper', 'sanitize_rgba_colour' ) ) {
return Modula_Helper::sanitize_rgba_colour( $color );
}
if ( empty( $color ) || 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 ) . ')';
}