options = get_option( 'wpscss_options' ); ?>

WP-SCSS Settings

Version
By: Connect Think
Help & Issues: Github

'Uploads Directory', 'WP-SCSS Plugin' => 'WP-SCSS Plugin' ); if(get_stylesheet_directory() === get_template_directory()){ $base_folder_options['Current Theme'] = 'Current Theme'; }else{ $base_folder_options['Parent Theme'] = 'Parent Theme'; $base_folder_options['Child Theme'] = 'Child Theme'; } add_settings_field( 'wpscss_base_folder', // ID 'Base Location', // Title array( $this, 'input_select_callback' ), // Callback 'wpscss_options', // Page 'wpscss_paths_section', // Section array( // args 'name' => 'base_compiling_folder', 'type' => apply_filters( 'wp_scss_base_compiling_modes', $base_folder_options ) ) ); // #TODO see if this is ever warrented // add_settings_field( // 'Use Absolute Path', // ID // 'Use Absolute Path', // Title // array( $this, 'input_checkbox_callback' ), // Callback // 'wpscss_options', // Page // 'wpscss_paths_section', // Section // array( // args // 'name' => 'use_absolute_paths' // ) // ); add_settings_field( 'wpscss_scss_dir', // ID 'SCSS Location', // Title array( $this, 'input_text_callback' ), // Callback 'wpscss_options', // Page 'wpscss_paths_section', // Section array( // args 'name' => 'scss_dir', ) ); add_settings_field( 'wpscss_css_dir', // ID 'CSS Location', // Title array( $this, 'input_text_callback' ), // Callback 'wpscss_options', // Page 'wpscss_paths_section', // Section array( // args 'name' => 'css_dir', ) ); // Compiling Options add_settings_section( 'wpscss_compile_section', // ID 'Compiling Options', // Title array( $this, 'print_compile_info' ), // Callback 'wpscss_options' // Page ); add_settings_field( 'Compiling Mode', // ID 'Compiling Mode', // Title array( $this, 'input_select_callback' ), // Callback 'wpscss_options', // Page 'wpscss_compile_section', // Section array( // args 'name' => 'compiling_options', 'type' => apply_filters( 'wp_scss_compiling_modes', array( OutputStyle::COMPRESSED => ucfirst(OutputStyle::COMPRESSED), OutputStyle::EXPANDED => ucfirst(OutputStyle::EXPANDED), ) ) ) ); add_settings_field( 'Source Map Mode', // ID 'Source Map Mode', // Title array( $this, 'input_select_callback' ), // Callback 'wpscss_options', // Page 'wpscss_compile_section', // Section array( // args 'name' => 'sourcemap_options', 'type' => apply_filters( 'wp_scss_sourcemap_modes', array( 'SOURCE_MAP_NONE' => 'None', 'SOURCE_MAP_INLINE' => 'Inline', 'SOURCE_MAP_FILE' => 'File' ) ) ) ); add_settings_field( 'Error Display', // ID 'Error Display', // Title array( $this, 'input_select_callback' ), // Callback 'wpscss_options', // Page 'wpscss_compile_section', // Section array( // args 'name' => 'errors', 'type' => apply_filters( 'wp_scss_error_diplay', array( 'show' => 'Show in Header', 'show-logged-in' => 'Show to Logged In Users', 'hide' => 'Print to Log', ) ) ) ); // Enqueuing Options add_settings_section( 'wpscss_enqueue_section', // ID 'Enqueuing Options', // Title array( $this, 'print_enqueue_info' ), // Callback 'wpscss_options' // Page ); add_settings_field( 'Enqueue Stylesheets', // ID 'Enqueue Stylesheets', // Title array( $this, 'input_checkbox_callback' ), // Callback 'wpscss_options', // Page 'wpscss_enqueue_section', // Section array( // args 'name' => 'enqueue' ) ); // Development options add_settings_section( 'wpscss_development_section', // ID 'Development Settings', // Title '', // Callback 'wpscss_options' // Page ); add_settings_field( 'wpscss_scss_always_recompile', // ID 'Always Recompile', // Title array( $this, 'input_checkbox_callback' ), // Callback 'wpscss_options', // Page 'wpscss_development_section', // Section array( // args 'name' => 'always_recompile', ) ); } /** * Sanitize each setting field as needed * * @param array $input Contains all settings fields as array keys */ public function sanitize( $input ) { foreach( ['scss_dir', 'css_dir'] as $dir ){ if( !empty( $input[$dir] ) ) { $input[$dir] = sanitize_text_field( $input[$dir] ); // Add a trailing slash if not already present if(substr($input[$dir], -1) != '/'){ $input[$dir] .= '/'; } } } return $input; } /** * Print the Section text */ public function print_paths_info() { print 'Location of your SCSS/CSS folders. Folders must be nested under your Base Location and start with /.' . '
Examples: /custom-scss/ and /custom-css/' . '
Caution updating some themes or plugins will delete the custom WP-SCSS Base Location when nested.'; } public function print_compile_info() { print 'Choose how you would like SCSS and source maps to be compiled and how you would like the plugin to handle errors'; } public function print_enqueue_info() { print 'WP-SCSS can enqueue your css stylesheets in the header automatically.'; } /** * Text Fields' Callback */ public function input_text_callback( $args ) { printf( '', esc_attr( $args['name'] ), esc_attr( $args['name'] ), esc_attr( isset($this->options[$args['name']]) ? $this->options[$args['name']] : '' ) ); } /** * Select Boxes' Callbacks */ public function input_select_callback( $args ) { $this->options = get_option( 'wpscss_options' ); $html = sprintf( ''; echo wp_kses($html, array( 'select' => array('id' => array(), 'name' => array()), 'option' => array('value' => array(), 'selected' => array()))); } /** * Checkboxes' Callbacks */ public function input_checkbox_callback( $args ) { $this->options = get_option( 'wpscss_options' ); $html = ""; $option_name = esc_attr( $args['name']); if($option_name == 'always_recompile' && defined('WP_SCSS_ALWAYS_RECOMPILE') && WP_SCSS_ALWAYS_RECOMPILE){ $html .= 'options[$option_name] ) ? $this->options[$option_name] : 1, false ) . ' disabled=disabled/>'; $html .= ''; }else{ $html .= 'options[$option_name] ) ? $this->options[$option_name] : 0, false ) . '/>'; $html .= ''; } echo wp_kses($html, array('input' => array('type' => array(), 'id' => array(), 'name' => array(), 'value' => array(), 'checked' => array(), 'disabled' => array()), 'label' => array('for' => array()) )); } }