/** * Print stylesheet for reading source on front end, if is requested. * * @since 2015-08-26 */ function get_stylesheet() { // Print the stylesheet only on right url parameters from stylesheet url request. if (!isset($_GET['inpsyde_custom_css']) || 1 !== (int) $_GET['inpsyde_custom_css']) { return; } ob_start(); header('Content-type: text/css'); $settings = get_option('inpsyde_custom_css_settings'); $source = Core\filter_source($settings['source']); $source = str_replace('>', '>', $source); $source = '/* Request timestamp: ' . date('Y-m-d H:i:s') . ' */' . "\n" . $source; echo $source; exit; }
/** * Render admin page to edit style. * * @since 2015-08-25 */ function get_admin_page() { // Get custom settings from database. $settings = get_option('inpsyde_custom_css_settings'); isset($settings['source']) && ($source = Core\filter_source($settings['source'])); // Delete the settings field in the database, if empty. if (isset($source) && '' === $source) { delete_option('inpsyde_custom_css_settings'); } // No custom source set a default string. !isset($source) && ($source = esc_html__('No custom rules currently.', 'inpsyde_custom_css')); ?> <h1><?php esc_html_e('Custom Stylesheet', 'inpsyde_custom_css'); ?> </h1> <p><?php esc_html_e('Add your custom stylesheet rules in the textarea below to add or overwrite css rules in the front end of your site.', 'inpsyde_custom_css'); ?> </p> <div class="wrap"> <form name="inpsyde_custom_css-form" action="options.php" method="post" enctype="multipart/form-data"> <?php settings_fields('inpsyde_custom_css_settings_group'); ?> <label for="inpsyde_custom_css_settings[source]"><?php esc_attr_e('CSS Rules', 'inpsyde_custom_css'); ?> </label><br> <textarea id="inpsyde_custom_css_settings[source]" name="inpsyde_custom_css_settings[source]"><?php echo esc_html($source); ?> </textarea> <?php submit_button(esc_html__('Save Changes'), 'primary', 'submit', TRUE); ?> </form> </div> <?php }