Skip Navigation

[Resolved] admin-ajax-php css Loading and theme.css vs. bootstrap.min.css

This support ticket is created 7 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 4 replies, has 2 voices.

Last updated by christianS-8 7 years, 8 months ago.

Assisted by: Nigel.

Author
Posts
#495814

Hello,
https://toolset.com/forums/topic/call-to-admin-ajax-phpactionref_dynamic_css-is-very-slow/?bbp_reply_to=362566&_wpnonce=6616e89ae6#new-post

I had the same Problem. I copied this code from Toolset-Start function.php in functions.php of Toolset-Start Child theme. I commented scripts or styles, that which I don't need. Therefore these Scripts & Styles are not loading from Toolset-Start Theme. This is very good for me. I unchecked also all boxes in Appearance-> Customizer->Advanced Settings, while I don't have, Woocomerce and don't need Theme.css Customizer styles. Just works all very good. But please look this code in Toolset-Starter Child Theme and please say, if so is okay and if this is possible, that I become some issue in the Future.

Code, which I don't need, is commented.

// used in different places
define( 'THEME_CSS', get_stylesheet_directory_uri() . '/css/theme.css' );
define( 'THEME_CSS_WOO', get_template_directory_uri() . '/css/woocommerce.css' );
define( 'THEME_CSS_BOOTSTRAP', get_template_directory_uri() . '/bootstrap/css/bootstrap.min.css' );

if ( ! function_exists( 'ref_enqueue_main_stylesheet' ) ) {
	function ref_enqueue_main_stylesheet() {
		if ( ! is_admin() ) {
			//wp_enqueue_style( 'main', get_template_directory_uri() . '/style.css', array(), null );
			wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array(), null );
		}
	}
	add_action( 'wp_enqueue_scripts', 'ref_enqueue_main_stylesheet', 100 );
}

if ( ! function_exists( 'ref_register_scripts' ) ) {

	function ref_register_scripts() {
		if ( ! is_admin() ) {

			// Register  CSS
			wp_register_style( 'bootstrap_css', THEME_CSS_BOOTSTRAP , array(), null );
			//wp_register_style( 'theme', THEME_CSS, array(), null );
			//wp_register_style( 'ref_woocommerce', THEME_CSS_WOO, array(), null );
			wp_register_style( 'font_awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css', array(), null );

			/*if(get_theme_mod( 'ref_theme_styles',1) == 1 ) {
				wp_enqueue_style( 'theme' );
			} else {*/
				wp_enqueue_style( 'bootstrap_css' );
			//}

			/*if(get_theme_mod( 'ref_wc_styles',1) == 1 ) {
				wp_enqueue_style( 'ref_woocommerce' );
			}*/

			wp_enqueue_style( 'font_awesome' );

			// Register  JS
			wp_register_script( 'wpbootstrap_bootstrap_js', get_template_directory_uri() . '/bootstrap/js/bootstrap.min.js', array( 'jquery' ), null, true );
			wp_register_script( 'theme_js', get_template_directory_uri() . '/js/theme.min.js', array( 'jquery' ), null, true );

			// Enqueue JS
			wp_enqueue_script( 'wpbootstrap_bootstrap_js' );
			wp_enqueue_script( 'theme_js' );


			if ( is_single() && comments_open() && get_option( 'thread_comments' ) ) {
				wp_enqueue_script( 'comment-reply' );
			}
		}
	}

	add_action( 'wp_enqueue_scripts', 'ref_register_scripts' );
}

may I remove also "theme_js" and "comment-reply" scripts? for what are they loading? Is some big difference between bootstrap.min.css 3.3.4 and 3.3.7 ? and if I may use bootstrap.min.css 3.3.7 version?

best regards

#496116

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Christian

Let me make a few observations about child themes before turning to some specifics. (The best starting point for reading about child themes is the official Theme Developers Handbook: https://developer.wordpress.org/themes/advanced-topics/child-themes/.)

A theme will have a functions.php file, and you can add one for the child theme, too. Unlike template files, where the files in the child theme if present replace those in the parent theme, both the child and parent functions.php files run (in that order).

You cannot declare the same function twice in PHP, and functions added to the parent functions.php are ideally 'pluggable', meaning that they test to see if the function already exists before declaring it.

That way, the child theme can declare the functions and these will be used instead of the same functions in the parent theme functions.php.

Functions in the child theme don't need to be pluggable, you can just go ahead and declare them. (You have copied the pluggable wrapper when reproducing functions from the parent in the child.)

Your child theme uses the function ref_enqueue_main_stylesheet to enqueue the main stylesheets. You have commented out style.css for the parent theme. That includes a lot of default base styles which are no longer available to your site. That may be intended, just be aware of it.

You then replace ref_register_scripts from the parent in your child theme.

Everything you have done there looks fine to me.

For theme_js, I believe you should be able to remove it (it is used by the example Reference Sites). Try removing it and only add it back in if you discover some expected functionality not working.

The comment-reply script is only needed if you want threaded comments on your posts, if not it is superfluous. (Note, though that it would never be loaded if you do not allow comments, as there is a test for this before the file is enqueued.)

Lastly, there should not be any problems switching out the Bootstrap CSS file for minor version variants.

#496256

Hi Nigel,

Many many Thanks, you are brilliant ! I want only say, that bootstrap.min.css in Toolset Starter has Version 3.3.7. I don't know, why, but it is not the same, as Original bootstrap.min.css from hidden link .

I tested it, and in Toolset bootstrap.min.css is:

 .col-xs-4{width:33.33333%} 

only 5 times "3" after comma.

but in original hidden link :

.col-xs-4{width:33.33333333%}

8 times "3" after comma.

You may think, this is not very important, but if anyone use Masonry, than is this very very important, while Element doesn't become exact width. Therefore are to columns: col-xs-8 and col-col-xs-4 don't let on the same line to order.

I fixed this issue self, with install original bootstrap.min.css. May can this help someone

best regards

#496565

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Christian

Thanks for the update. I'm not sure why the discrepancy between the Toolset version of the bootrstap 3.3.7 CSS file and the official version, but I'm glad you were able to identify it and resolve the issue yourself.

#496572

Thanks Nigel. Resolved