.wp-block-group, .wp-site-blocks > .alignfull { max-width: none; } body > .is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)) { max-width: {$c_max}px; } CSS; return sprintf( $css, gmdate( 'Y-m-d H:i:s' ) ); } /** * Write the generated CSS file to disk. * * @return bool|WP_Error True on success, WP_Error on failure. */ function oribi_write_generated_css() { $css = oribi_build_css(); $path = oribi_generated_css_path(); // Ensure directory exists. $dir = dirname( $path ); if ( ! file_exists( $dir ) ) { wp_mkdir_p( $dir ); } // Use WP_Filesystem for safe file writing. require_once ABSPATH . 'wp-admin/includes/file.php'; global $wp_filesystem; if ( ! WP_Filesystem() ) { return new WP_Error( 'fs', __( 'Could not initialise filesystem.', 'ots-theme' ) ); } $result = $wp_filesystem->put_contents( $path, $css, FS_CHMOD_FILE ); if ( ! $result ) { return new WP_Error( 'write', __( 'Could not write generated CSS file.', 'ots-theme' ) ); } // Bump version number so browsers cache-bust. $version = intval( get_theme_mod( 'oribi_css_version', 0 ) ) + 1; set_theme_mod( 'oribi_css_version', $version ); return true; } /** * Regenerate the CSS file when it is missing or the theme version has changed. * * Hooked early so the file is ready before wp_enqueue_scripts fires. * Also re-seeds defaults if the palette has changed, so the generated * CSS always reflects the current default values. */ add_action( 'init', function () { // Re-seed defaults if the defaults array has changed (e.g. new palette). if ( function_exists( 'oribi_maybe_seed_defaults' ) ) { oribi_maybe_seed_defaults(); } $needs_regen = ! file_exists( oribi_generated_css_path() ); if ( ! $needs_regen && defined( 'ORIBI_VERSION' ) ) { $stored = get_theme_mod( 'oribi_css_theme_version', '' ); if ( $stored !== ORIBI_VERSION ) { $needs_regen = true; } } if ( $needs_regen ) { oribi_write_generated_css(); if ( defined( 'ORIBI_VERSION' ) ) { set_theme_mod( 'oribi_css_theme_version', ORIBI_VERSION ); } } } );