function tinybuddha_get_custom_css_file_path() { return get_stylesheet_directory() . '/css/custom-theme-options.css'; } function tinybuddha_sync_custom_css_file() { $css = (string) get_option( 'dm_custom_css', '' ); $css = trim( $css ); $file_path = tinybuddha_get_custom_css_file_path(); $dir_path = dirname( $file_path ); if ( ! is_dir( $dir_path ) ) { $created = wp_mkdir_p( $dir_path ); if ( ! $created ) { update_option( 'tinybuddha_custom_css_file_error', 1, false ); return false; } } $written = file_put_contents( $file_path, "/* Tiny Buddha custom theme options CSS */ " . $css . " " ); if ( false === $written ) { update_option( 'tinybuddha_custom_css_file_error', 1, false ); return false; } delete_option( 'tinybuddha_custom_css_file_error' ); return true; } function tinybuddha_maybe_sync_custom_css_file() { if ( is_admin() ) { tinybuddha_sync_custom_css_file(); } } add_action( 'init', 'tinybuddha_maybe_sync_custom_css_file', 20 ); function tinybuddha_custom_css_file_admin_notice() { if ( ! current_user_can( 'manage_options' ) ) { return; } if ( ! isset( $_GET['page'] ) || 'theme-options.php' !== $_GET['page'] ) { return; } $file_path = tinybuddha_get_custom_css_file_path(); if ( ! get_option( 'tinybuddha_custom_css_file_error' ) && file_exists( $file_path ) && is_writable( $file_path ) ) { return; } echo '

'; echo esc_html__( 'Tiny Buddha could not write custom CSS to wp-content/themes/tinybuddha/css/custom-theme-options.css. Styles will be loaded inline as a fallback.', 'tinybuddha' ); echo '

'; } add_action( 'admin_notices', 'tinybuddha_custom_css_file_admin_notice' ); Life Becomes Easier When You Learn to Accept an Apology You Never Got - Tiny Buddha
Menu

Life Becomes Easier When You Learn to Accept an Apology You Never Got

About Lori Deschene

Lori Deschene is the founder of Tiny Buddha. She started the site after struggling with depression, bulimia, c-PTSD, and toxic shame so she could recycle her former pain into something useful and inspire others to do the same. You can find her books, including Tiny Buddha’s Gratitude Journal and Tiny Buddha’s Worry Journal, here and learn more about her eCourse, Recreate Your Life Story, if you’re ready to transform your life and become the person you want to be.

Comments are closed.