balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

class-template-overrides.php (3988B)


      1 <?php // phpcs:ignore WordPress.Files.FileName
      2 
      3 /**
      4  * CSS overrides for block plugins.
      5  *
      6  * @since   4.0.0
      7  * @package Redux Framework
      8  */
      9 
     10 namespace ReduxTemplates;
     11 
     12 if ( ! defined( 'ABSPATH' ) ) {
     13 	exit; // Exit if accessed directly.
     14 }
     15 
     16 /**
     17  * Redux Templates Templates Class
     18  *
     19  * @since 4.0.0
     20  */
     21 class Template_Overrides {
     22 
     23 	/**
     24 	 * ReduxTemplates Template_Overrides.
     25 	 *
     26 	 * @since 4.0.0
     27 	 */
     28 	public function __construct() {
     29 	}
     30 
     31 	/**
     32 	 * Detects if the current page has blocks or not.
     33 	 *
     34 	 * @return bool
     35 	 * @since 4.0.0
     36 	 */
     37 	public static function is_gutenberg() {
     38 		global $post;
     39 		if ( function_exists( 'has_blocks' ) && has_blocks( $post->ID ) ) {
     40 			return true;
     41 		}
     42 
     43 		return false;
     44 	}
     45 
     46 	/**
     47 	 * Detects the current theme and provides overrides.
     48 	 *
     49 	 * @return string
     50 	 * @since 4.0.0
     51 	 */
     52 	public static function get_overrides() {
     53 
     54 		if ( ! self::is_gutenberg() ) {
     55 			return;
     56 		}
     57 
     58 		$template = mb_strtolower( get_template() );
     59 
     60 		$css = '';
     61 		if ( method_exists( __CLASS__, $template ) ) {
     62 			$css = call_user_func( array( __CLASS__, $template ) );
     63 			$css = preg_replace( '/\s+/S', ' ', $css );
     64 		}
     65 
     66 		$css .= <<<'EOD'
     67 			#main {
     68 				padding: unset !important;
     69 			}
     70 			#content {
     71 				padding: unset !important;
     72 			}
     73 			#wrapper {
     74 				min-height: unset !important;
     75 			}
     76 			.alignfull, .alignwide {
     77 				margin: unset !important;
     78 				max-width: unset !important;
     79 				width: unset !important;
     80 			}
     81 }
     82 EOD;
     83 		// Remove comments.
     84 		$css = preg_replace( '!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css );
     85 		// Remove space after colons.
     86 		$css = str_replace( ': ', ':', $css );
     87 		// Remove space after commas.
     88 		$css = str_replace( ', ', ',', $css );
     89 		// Remove space after opening bracket.
     90 		$css = str_replace( ' {', '{', $css );
     91 		// Remove whitespace.
     92 		$css = str_replace( array( "\r\n", "\r", "\n", "\t", '  ', '    ', '    ' ), '', $css );
     93 
     94 		return $css;
     95 	}
     96 
     97 	/**
     98 	 * Consulting theme overrides.
     99 	 *
    100 	 * @return string
    101 	 * @since 4.0.0
    102 	 */
    103 	public static function consulting() {
    104 		return <<<'EOD'
    105 			#content-core {
    106 				max-width: 100%;
    107 			}
    108 EOD;
    109 	}
    110 
    111 	/**
    112 	 * Avada theme overrides.
    113 	 *
    114 	 * @return string
    115 	 * @since 4.0.0
    116 	 */
    117 	public static function avada() {
    118 		return <<<'EOD'
    119 			#main .fusion-row {
    120 				max-width: unset;
    121 			}
    122 EOD;
    123 	}
    124 
    125 	/**
    126 	 * GeneratePress theme overrides.
    127 	 *
    128 	 * @return string
    129 	 * @since 4.1.24
    130 	 */
    131 	public static function generatepress() {
    132 		return <<<'EOD'
    133 			.site-content {
    134                             display: block!important;
    135                         }
    136 EOD;
    137 	}
    138 
    139 	/**
    140 	 * TwentyTwenty theme overrides.
    141 	 *
    142 	 * @return string
    143 	 * @since 4.0.0
    144 	 */
    145 	public static function twentytwenty() {
    146 		return <<<'EOD'
    147 			[class*="__inner-container"] > *:not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright):not(.is-style-wide) {
    148 				max-width: unset !important;
    149 			}
    150 			.wp-block-archives:not(.alignwide):not(.alignfull), .wp-block-categories:not(.alignwide):not(.alignfull), .wp-block-code, .wp-block-columns:not(.alignwide):not(.alignfull), .wp-block-cover:not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright):not(.aligncenter), .wp-block-embed:not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright):not(.aligncenter), .wp-block-gallery:not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright):not(.aligncenter), .wp-block-group:not(.has-background):not(.alignwide):not(.alignfull), .wp-block-image:not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright):not(.aligncenter), .wp-block-latest-comments:not(.aligncenter):not(.alignleft):not(.alignright), .wp-block-latest-posts:not(.aligncenter):not(.alignleft):not(.alignright), .wp-block-media-text:not(.alignwide):not(.alignfull), .wp-block-preformatted, .wp-block-pullquote:not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright), .wp-block-quote, .wp-block-quote.is-large, .wp-block-quote.is-style-large, .wp-block-verse, .wp-block-video:not(.alignwide):not(.alignfull) {
    151 				margin-top: unset;
    152 				margin-bottom: unset;
    153 			}
    154 EOD;
    155 	}
    156 
    157 }