LLMS_Twenty_Twenty_Two::generate_inline_styles( string|null $context = null )

Generate inline CSS for a given context.


Parameters Parameters

$context

(string|null) (Optional) Inline CSS context. Accepts "editor" to define styles loaded within the block editor or null for frontend styles.

Default value: null


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/theme-support/class-llms-twenty-twenty-two.php

	protected static function generate_inline_styles( $context = null ) {

		$selector_prefix = ( 'editor' === $context ) ? '.editor-styles-wrapper' : '';

		$styles = array();

		// Frontend only.
		if ( is_null( $context ) ) {

			// Fix alignment of content in an access plan, and navigation.
			$styles[] = '.llms-access-plan-description ul, .llms-pagination ul { padding-left: 0; }';

			// Fix form input padding.
			$styles[] = '.llms-form-field input, .llms-form-field textarea, .llms-form-field select { padding: 6px 10px }';

			// Question layout.
			$styles[] = '.llms-question-wrapper ol.llms-question-choices li.llms-choice .llms-choice-text { margin-top: 0; }';

			// Payment gateway stylized radio buttons.
			$styles[] = LLMS_Theme_Support::get_css(
				array( '.llms-form-field.type-radio:not(.is-group) input[type=radio]:checked+label:before' ),
				array(
					'background-image' => '-webkit-radial-gradient(center,ellipse,var(--wp--preset--color--primary) 0,var(--wp--preset--color--primary) 40%,#fafafa 45%)',
					'background-image' => 'radial-gradient(ellipse at center,var(--wp--preset--color--primary) 0,var(--wp--preset--color--primary) 40%,#fafafa 45%)',
				)
			);
			// Completed lesson check.
			$styles[] = LLMS_Theme_Support::get_css(
				array(
					'.llms-lesson-preview.is-free .llms-lesson-complete',
					'.llms-lesson-preview.is-complete .llms-lesson-complete',
				),
				array(
					'color' => 'var(--wp--preset--color--primary)',
				)
			);
		}

		// Editor only.
		if ( 'editor' === $context ) {

			// Elements with a light background that become unreadable in darkmode in the block editor.
			$styles[] = LLMS_Theme_Support::get_css(
				array(
					'.wp-block-llms-course-progress .progress-bar .progress--fill',
					'.wp-block[data-type="llms/course-continue-button"] button',
					'.wp-block[data-type="llms/lesson-progression"] button',
				),
				array(
					'background-color' => 'var(--wp--preset--color--primary)',
					'color'            => 'var(--wp--preset--color--background)',
				),
				$selector_prefix
			);

		}

		// Fix lesson preview titles.
		$styles[] = '.llms-lesson-preview h6 { margin: 0 0 10px; }';

		// Primary background color.
		$styles[] = LLMS_Theme_Support::get_css(
			LLMS_Theme_Support::get_selectors_primary_color_background(),
			array(
				'background-color' => 'var(--wp--preset--color--primary)',
				'color'            => 'var(--wp--preset--color--background)',
			)
		);

		// Add border color to qualifying elements.
		$styles[] = LLMS_Theme_Support::get_css(
			LLMS_Theme_Support::get_selectors_primary_color_border(),
			array(
				'border-color' => 'var(--wp--preset--color--primary)',
			)
		);

		// Quiz.
		$styles[] = '.llms-quiz-ui { background: transparent; }';
		// Fix questions with pictures, and images in quiz/questions description.
		$styles[] = '.llms-quiz-wrapper img, .llms-quiz-question-wrapper img { max-width: 100%; height: auto; }';

		// Fix anchor buttons.
		$styles[] = 'a.llms-button-action, a.llms-button-danger, a.llms-button-primary, a.llms-button-secondary { display: inline-block; }';

		return implode( "\r", $styles );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
6.8.0 Fixed label/text alignment by removing text’s margin top. Also, removed now outdated width rule.
5.9.0 Fixed stretched images in questions with pictures, and images in quiz/questions description.
5.8.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.