'; if( isset( $field['title'] ) ) { $field_desc = ( isset( $field['desc'] ) ) ? '

'. $field['desc'] .'

' : ''; $output .= '

' . $field['title'] . '

'. $field_desc .'
'; } $output .= ( isset( $field['title'] ) ) ? '
' : ''; $value = ( !isset( $value ) && isset( $field['default'] ) ) ? $field['default'] : $value; $value = ( isset( $field['value'] ) ) ? $field['value'] : $value; if( class_exists( $class ) ) { ob_start(); $element = new $class( $field, $value, $unique ); $element->output(); $output .= ob_get_clean(); } else { $output .= '

'. __( 'This field class is not available!', 'cs-framework' ) .'

'; } $output .= ( isset( $field['title'] ) ) ? '
' : ''; $output .= '
'; $output .= ''; return $output; } } /** * * Encode string for backup options * * @since 1.0.0 * @version 1.0.0 * */ if ( ! function_exists( 'cs_encode_string' ) ) { function cs_encode_string( $string ) { return rtrim( strtr( call_user_func( 'base'. '64' .'_encode', addslashes( gzcompress( serialize( $string ), 9 ) ) ), '+/', '-_' ), '=' ); } } /** * * Decode string for backup options * * @since 1.0.0 * @version 1.0.0 * */ if ( ! function_exists( 'cs_decode_string' ) ) { function cs_decode_string( $string ) { return unserialize( gzuncompress( stripslashes( call_user_func( 'base'. '64' .'_decode', rtrim( strtr( $string, '-_', '+/' ), '=' ) ) ) ) ); } } /** * * Get google font from json file * * @since 1.0.0 * @version 1.0.0 * */ if ( ! function_exists( 'cs_get_google_fonts' ) ) { function cs_get_google_fonts() { global $cs_google_fonts; if( ! empty( $cs_google_fonts ) ) { return $cs_google_fonts; } else { ob_start(); cs_locate_template( 'fields/typography/google-fonts.json' ); $json = ob_get_clean(); $cs_google_fonts = json_decode( $json ); return $cs_google_fonts; } } } /** * * Get icon fonts from json file * * @since 1.0.0 * @version 1.0.0 * */ if ( ! function_exists( 'cs_get_icon_fonts' ) ) { function cs_get_icon_fonts( $file ) { ob_start(); cs_locate_template( $file ); $json = ob_get_clean(); return json_decode( $json ); } } /** * * Array search key & value * * @since 1.0.0 * @version 1.0.0 * */ if ( ! function_exists( 'cs_array_search' ) ) { function cs_array_search( $array, $key, $value ) { $results = array(); if ( is_array( $array ) ) { if ( isset( $array[$key] ) && $array[$key] == $value ) { $results[] = $array; } foreach ( $array as $sub_array ) { $results = array_merge( $results, cs_array_search( $sub_array, $key, $value ) ); } } return $results; } } /** * * Load options fields * * @since 1.0.0 * @version 1.0.0 * */ if ( ! function_exists( 'cs_load_option_fields' ) ) { function cs_load_option_fields() { $located_fields = array(); foreach ( glob( CS_DIR .'/fields/*/*.php' ) as $cs_field ) { $located_fields[] = basename( $cs_field ); cs_locate_template( str_replace( CS_DIR, '', $cs_field ) ); } $override_name = apply_filters( 'cs_framework_override', 'cs-framework-override' ); $override_dir = get_template_directory() .'/'. $override_name .'/fields'; if( is_dir( $override_dir ) ) { foreach ( glob( $override_dir .'/*/*.php' ) as $override_field ) { if( ! in_array( basename( $override_field ), $located_fields ) ) { cs_locate_template( str_replace( $override_dir, '/fields', $override_field ) ); } } } do_action( 'cs_load_option_fields' ); } }