Sofian777 Posted June 24, 2015 Share Posted June 24, 2015 I am using a WordPress premium theme that has a 25.000+ lines styles.css. I want to change the font and main color sitewide, and for this I would like to catch ALL classes and IDs that use them for my childtheme. Manually searching through 25.000 lines and then selecting and copying the classes together is a very slow procedure, and I am sure this can be automated with RegEx, but I only know that it exists but not how it works, especially not for such a vast function. But at least I could figure out the logic that a script for such a task would need to follow. So let's say I need a rule that collects ALL classes to which Roboto is assigned. Basically it needs to 1. find Roboto, then 2. go back to the { and 3. collect everything before { until 4. the last } before, so it needs to go backwards searching 5. Then it needs to add a comma to the last entry, so the list can continue. The result will be a very big list of comma-separated classes which I can then easily assign the new font to. Can someone figure out such a RegEx String, or better to say, write such a php script? ......last CSS rule ending here. } .td-page-content blockquote p, .td-post-content blockquote p, .wpb_text_column blockquote p, .td_block_text_with_title blockquote p, .bbpress blockquote p, .woocommerce #tab-description blockquote p, .mce-content-body blockquote p, .comment-content blockquote p { font-family: 'Roboto', sans-serif; font-size: 32px; line-height: 40px; font-weight: 400; font-style: italic; text-align: center; text-transform: uppercase; color: ... ......... Quote Link to comment https://forums.phpfreaks.com/topic/296995-catching-all-classes-and-ids-from-a-css-stylesheet-that-contain-a-certain-search-term/ Share on other sites More sharing options...
Ch0cu3r Posted June 24, 2015 Share Posted June 24, 2015 Looks like you are wanting to change the font for all p tags within blockquote tags, in that case put the following at the end of your style. blockquote p { font-family: 'Roboto', sans-serif; font-size: 32px; line-height: 40px; font-weight: 400; font-style: italic; text-align: center; text-transform: uppercase; color: ... } Quote Link to comment https://forums.phpfreaks.com/topic/296995-catching-all-classes-and-ids-from-a-css-stylesheet-that-contain-a-certain-search-term/#findComment-1514783 Share on other sites More sharing options...
Sofian777 Posted June 25, 2015 Author Share Posted June 25, 2015 Thanks for your answer, but the above code is just an example, I don't want to change only blockquotes. I want to create a list of all classes and ID's to which roboto is assigned. With a script running through a large CSS file, outputting a list of all classes that I can then use in my child-theme to change roboto in all instances where the main theme has set it. Quote Link to comment https://forums.phpfreaks.com/topic/296995-catching-all-classes-and-ids-from-a-css-stylesheet-that-contain-a-certain-search-term/#findComment-1514907 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.