-
AuthorPosts
-
September 26, 2014 at 10:52 am #113239
The following two resources are the only ones I have left that are not able to be cached. Please advise.
http://www.meoptometry.com/wp-content/themes/x/framework/fonts/font_awesome/font-awesome.woff?v=4.0.3
http://www.meoptometry.com/wp-content/themes/x/framework/fonts/foundation_social/foundation-social.woff?v=1.0Thank you,
meo
http://www.meoptometry.comSeptember 26, 2014 at 12:49 pm #113305Hi Meo,
I think the best way would be using a plugin: https://wordpress.org/plugins/remove-query-strings-from-static-resources/ for removing query strings. And if you need live performance report in your site then you can consider to use this: https://wordpress.org/plugins/gtmetrix-for-wordpress/
Hope these helps, Cheers!
September 26, 2014 at 2:12 pm #113352Thanks for the reply. There was some code i found to enter into the child themes functions.php, but that did not fix the issue. I am hesitant to use a plugin as the bulk the plugin would add to the site may slow the site more than necessary. Can i just find the files and remove the part of the name that includes the ? such as ?v=4.0.3 for font awesome? Are there any drawbacks to doing that?
meo
September 26, 2014 at 3:25 pm #113401Hi Meo,
If you remove the font-awesome, all icons of the site won’t show. They’ll show as square dot.
September 26, 2014 at 3:40 pm #113416I don’t think Meo intends to remove the font file. Just the query string.
September 26, 2014 at 4:04 pm #113449HI There,
If you don’t want to use a plugin, try adding the following codes into funtions.php of your child theme:
function _remove_script_version( $src ){ $parts = explode( '?', $src ); return $parts[0]; } add_filter( 'script_loader_src', '_remove_script_version', 15, 1 ); add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
September 27, 2014 at 1:21 am #113615Unfortunately the above options (code in function.php and the mentioned plugins) did not work. The code in the last post actually removed the query string from google fonts…but that ended up breaking those. It doesn’t seem to touch font_awesome or foundation_social.
When i tried to find the files in the theme folder.. they did not have the query strings in the file name so I could not remove them there either.Anyone have any other tips/solutions on removing them from these two items?
Thanks,
meoSeptember 27, 2014 at 8:27 am #113710Hello,
the font awesome and foundation social is declared on a each CSS based on the stack used that includes query strings. You could easily remove those query string directly from those CSS files but the thing is you must not edit anything inside X core file.
Can you try adding this Instead on your child theme style.css and see how it goes,
@font-face { font-family: 'fontawesome'; src: url("../x/framework/fonts/font_awesome/font-awesome.eot"); src: url("../x/framework/fonts/font_awesome/font-awesome.eot") format("embedded-opentype"), url("../x/framework/fonts/font_awesome/font-awesome.woff") format("woff"), url("../x/framework/fonts/font_awesome/font-awesome.ttf") format("truetype"), url("../x/framework/fonts/font_awesome/font-awesome.svg") format("svg"); font-weight: normal; font-style: normal; } @font-face { font-family:'foundationsocial'; src:url("../x/framework/fonts/foundation_social/foundation-social.eot"); src:url("../x/framework/fonts/foundation_social/foundation-social.eot") format("embedded-opentype"), url("../x/framework/fonts/foundation_social/foundation-social.woff") format("woff"), url("../x/framework/fonts/foundation_social/foundation-social.ttf") format("truetype"), url("../x/framework/fonts/foundation_social/foundation-social.svg") format("svg"); font-weight:normal;font-style:normal; }
Let me know how it works.
Cheers
September 27, 2014 at 2:56 pm #113843Thank you. The latest solution seems to affect it…but now it seems to load them twice….once still with the query string and once without.
See the following report for more info.
http://tools.pingdom.com/fpt/#!/dBWM66/http://www.meoptometry.com
September 27, 2014 at 8:55 pm #113943Hi there,
How about this,
Remove the css given above, then go to /wp-content/themes/x/framework/css/site/stacks/ using your filemanager or ftp.
Duplicate all css file that you can find in there and renamed your new copies of css file into alternative-{STACK}.css (eg. alternative-ethos.css, alternative-integrity-light.css, etc. ).
Edit all alternative-{STACK}.css css files and remove all occurrences of these strings.
1. ?#fontawesome&v=4.0.3
2. ?#iefix&v=1.0
3. ?v=4.0.3
4. ?v=1.0Save your new css files and upload them where your original stacks css files are.
Now add this code at your child theme’s functions.php
if ( ! function_exists( 'x_enqueue_site_styles' ) ) : function x_enqueue_site_styles() { // // Stack data. // $stack = x_get_stack(); $design = x_get_option( 'x_integrity_design', 'light' ); if ( $stack == 'integrity' && $design == 'light' ) { $ext = '-light'; } elseif ( $stack == 'integrity' && $design == 'dark' ) { $ext = '-dark'; } else { $ext = ''; } // // Font data. // $body_font_family_query = x_get_font_family_query( x_get_option( 'x_body_font_family', 'Lato' ) ); $body_font_weight_and_style = x_get_option( 'x_body_font_weight', '400' ); $body_font_weight = x_get_font_weight( $body_font_weight_and_style ); $headings_font_family_query = x_get_font_family_query( x_get_option( 'x_headings_font_family', 'Lato' ) ); $headings_font_weight_and_style = x_get_option( 'x_headings_font_weight', '400' ); $headings_font_weight = x_get_font_weight( $headings_font_weight_and_style ); $logo_font_family_query = x_get_font_family_query( x_get_option( 'x_logo_font_family', 'Lato' ) ); $logo_font_weight_and_style = x_get_option( 'x_logo_font_weight', '400' ); $logo_font_weight = x_get_font_weight( $logo_font_weight_and_style ); $navbar_font_family_query = x_get_font_family_query( x_get_option( 'x_navbar_font_family', 'Lato' ) ); $navbar_font_weight_and_style = x_get_option( 'x_navbar_font_weight', '400' ); $navbar_font_weight = x_get_font_weight( $navbar_font_weight_and_style ); $subsets = 'latin,latin-ext'; if ( x_get_option( 'x_custom_font_subsets', 0 ) == 1 ) { if ( x_get_option( 'x_custom_font_subset_cyrillic', 0 ) == 1 ) { $subsets .= ',cyrillic,cyrillic-ext'; } if ( x_get_option( 'x_custom_font_subset_greek', 0 ) == 1 ) { $subsets .= ',greek,greek-ext'; } if ( x_get_option( 'x_custom_font_subset_vietnamese', 0 ) == 1 ) { $subsets .= ',vietnamese'; } } $custom_font_args = array( 'family' => $body_font_family_query . ':' . $body_font_weight . ',' . $body_font_weight . 'italic,700,700italic|' . $navbar_font_family_query . ':' . $navbar_font_weight_and_style . '|' . $headings_font_family_query . ':' . $headings_font_weight_and_style . '|' . $logo_font_family_query . ':' . $logo_font_weight_and_style, 'subset' => $subsets ); $standard_font_args = array( 'family' => 'Lato:' . $body_font_weight . ',' . $body_font_weight . 'italic,' . $navbar_font_weight_and_style . ',' . $headings_font_weight_and_style . ',' . $logo_font_weight_and_style . ',700,700italic', 'subset' => $subsets ); $get_custom_font_family = add_query_arg( $custom_font_args, '//fonts.googleapis.com/css' ); $get_standard_font_family = add_query_arg( $standard_font_args, '//fonts.googleapis.com/css' ); // // Enqueue styles. // if ( is_child_theme() ) { wp_enqueue_style( 'x-stack', get_stylesheet_directory_uri() . '/style.css', NULL, NULL, 'all' ); } else { wp_enqueue_style( 'x-stack', get_stylesheet_directory_uri() . '/framework/css/site/stacks/alternative-' . $stack . $ext . '.css', NULL, NULL, 'all' ); } if ( is_rtl() ) { wp_enqueue_style( 'x-rtl', X_TEMPLATE_URL . '/framework/css/site/rtl/' . $stack . '.css', NULL, NULL, 'all' ); } if ( X_BBPRESS_IS_ACTIVE ) { if ( x_is_bbpress() ) { wp_deregister_style( 'buttons' ); } wp_deregister_style( 'bbp-default' ); wp_enqueue_style( 'x-bbpress', X_TEMPLATE_URL . '/framework/css/site/bbpress/' . $stack . $ext . '.css', NULL, NULL, 'all' ); } if ( X_BUDDYPRESS_IS_ACTIVE ) { wp_deregister_style( 'bp-legacy-css' ); wp_deregister_style( 'bp-admin-bar' ); wp_enqueue_style( 'x-buddypress', X_TEMPLATE_URL . '/framework/css/site/buddypress/' . $stack . $ext . '.css', NULL, NULL, 'all' ); } if ( X_WOOCOMMERCE_IS_ACTIVE ) { wp_deregister_style( 'woocommerce-layout' ); wp_deregister_style( 'woocommerce-general' ); wp_deregister_style( 'woocommerce-smallscreen' ); wp_enqueue_style( 'x-woocommerce', X_TEMPLATE_URL . '/framework/css/site/woocommerce/' . $stack . $ext . '.css', NULL, NULL, 'all' ); } if ( X_GRAVITY_FORMS_IS_ACTIVE ) { wp_enqueue_style( 'x-gravity-forms', X_TEMPLATE_URL . '/framework/css/site/gravity_forms/' . $stack . $ext . '.css', NULL, NULL, 'all' ); } if ( X_CONTACT_FORM_7_IS_ACTIVE ) { wp_deregister_style( 'contact-form-7' ); } if ( x_get_option( 'x_custom_fonts', 0 ) == 1 ) { wp_enqueue_style( 'x-font-custom', $get_custom_font_family, NULL, NULL, 'all' ); } else { wp_enqueue_style( 'x-font-standard', $get_standard_font_family, NULL, NULL, 'all' ); } } endif; add_action( 'wp_enqueue_scripts', 'x_enqueue_site_styles' );
Last, edit your child theme’s style.css and find the line similar to this.
@import url( '../x/framework/css/site/stacks/{STACK}.css' );
And change its name into :
@import url( '../x/framework/css/site/stacks/alternative-{STACK}.css' );
Eg.
@import url( '../x/framework/css/site/stacks/alternative-ethos.css' );
These will be permanent since the new css files have new name and won’t be ovewritten by X theme update. Unless child theme is deleted. ( Same instruction can be applied to different child theme ).
Cheers!
September 28, 2014 at 2:41 am #114067It worked!!! Thank you SO much! Highly recommended!
One follow-up question…is there anything to look out for in the future as far as updates causing conflict or things not updating? Any precautions to take/observe when doing this?
Again, thank you SO much!
meo
September 28, 2014 at 6:32 am #114103Hi Meo,
As you will add your stuff into Child Theme it is future proof and you will have no problem.
Thanks.
September 28, 2014 at 11:21 am #114194Excellent. Will the alternative CSS files get deleted on theme update/will I have to create them after an update to X or font awesome/foundation social?
meo
September 28, 2014 at 6:28 pm #114315Hi there,
Alternative css files will not be replaced by update. But, it will be deleted if you will do clean install that requires deletion on entire core files.
Cheers!
January 1, 2015 at 7:40 pm #174785UPDATE: This still works, but be sure to remember to manually update the CSS files after a theme update.
I ran into an issue after updating to 3.1.1 (due to a change in navigation structure). See the following link for more info:
https://theme.co/x/member/forums/topic/help-site-navigation-broke-after-update/
-
AuthorPosts