false, 'user-agent' => $user_agent, ) ); if ( is_wp_error( $request ) ) { return ''; } $result = wp_remote_retrieve_body( $request ); return $result; } } /** * Get Local WebFonts data */ if ( ! function_exists( 'oceanwp_get_local_webfonts_data_dir' ) ) { function oceanwp_get_local_webfonts_data_dir( $file_name ) { $upload = wp_upload_dir(); $uploads_dir = 'oceanwp-webfonts'; // Create directory if ( ! is_dir( trailingslashit( $upload['basedir'] ) . $uploads_dir ) ) { wp_mkdir_p( trailingslashit( $upload['basedir'] ) . $uploads_dir ); } return array( 'upload_dir' => trailingslashit( $upload['basedir'] ) . $uploads_dir, 'upload_url' => trailingslashit( $upload['baseurl'] ) . $uploads_dir, ); } } /** * Get Local WebFonts CSS data */ if ( ! function_exists( 'oceanwp_get_local_webfonts_css_data_dir' ) ) { function oceanwp_get_local_webfonts_css_data_dir( $file_name ) { $upload = wp_upload_dir(); $uploads_dir = 'oceanwp-webfonts-css'; // Create directory if ( ! is_dir( trailingslashit( $upload['basedir'] ) . $uploads_dir ) ) { wp_mkdir_p( trailingslashit( $upload['basedir'] ) . $uploads_dir ); } return array( 'upload_dir' => trailingslashit( $upload['basedir'] ) . $uploads_dir, 'upload_url' => trailingslashit( $upload['baseurl'] ) . $uploads_dir, ); } } add_filter( 'oceanwp_local_font_url', 'oceanwp_webfonts_local_font_url' ); if ( ! function_exists( 'oceanwp_webfonts_local_font_url' ) ) { function oceanwp_webfonts_local_font_url( $url ) { if ( strpos( $url, 'https://' ) === 0 ) { $url = str_replace( 'https://', '//', $url ); } if ( strpos( $url, 'http://' ) === 0 ) { $url = str_replace( 'http://', '//', $url ); } return $url; } } // Setup theme => Generate the custom CSS file. add_action( 'admin_bar_init', 'ocean_save_customizer_css_in_file', 9999 ); if ( ! function_exists( 'ocean_save_customizer_css_in_file' ) ) { function ocean_save_customizer_css_in_file( $output = null ) { // If Custom File is not selected. if ( 'file' !== get_theme_mod( 'ocean_customzer_styling', 'head' ) ) { return; } // Get all the customier css. $output = apply_filters( 'ocean_head_css', $output ); // Get Custom Panel CSS. $output_custom_css = wp_get_custom_css(); // Minified the Custom CSS. $output .= oceanwp_minify_css( $output_custom_css ); $upload_dir = wp_upload_dir(); // Grab uploads folder array. $dir = trailingslashit( $upload_dir['basedir'] ) . 'oceanwp' . DIRECTORY_SEPARATOR; // Set storage directory path. $untraling_dir = untrailingslashit( $dir ); if ( ! file_exists( $untraling_dir ) ) { mkdir( $untraling_dir, FS_CHMOD_DIR ); } if( file_exists( $untraling_dir ) ) { $filename = $dir . 'custom-style.css'; if ( file_put_contents( $filename, $output ) ) { chmod( $filename, 0644 ); } } } }