diff --git a/classes/plugin.php b/classes/plugin.php index a08b494..c5263a7 100644 --- a/classes/plugin.php +++ b/classes/plugin.php @@ -9,6 +9,13 @@ class Admin_Color_Schemer_Plugin { private $colors; + /** + * The data needed for the input text form. + * + * @var array + */ + private $scheme_name_input; + protected function __construct() { self::$instance = $this; $this->base = dirname( dirname( __FILE__ ) ); @@ -27,6 +34,12 @@ public function init() { // Initialize translations load_plugin_textdomain( 'admin-color-schemer', false, basename( dirname( dirname( __FILE__ ) ) ) . '/languages' ); + // Set up the label name for the scheme name input form + $this->scheme_name_input = array( + 'label' => __( 'Your Scheme name', 'admin-color-schemer' ), + 'attribute' => 'scheme_name', + ); + // Set up color arrays - need translations $this->colors['basic'] = array( 'base_color' => __( 'Base', 'admin-color-schemer' ), @@ -161,6 +174,15 @@ protected function get_color_scheme( $id = null ) { } } + /** + * Gets the input data necessary for the text input form. + * + * @return mixed|array + */ + public function get_scheme_input() { + return $this->scheme_name_input; + } + public function get_colors( $set = null ) { if ( 'basic' === $set ) { return $this->colors['basic']; @@ -321,6 +343,13 @@ public function save() { die(); } + //add the scheme name to the settings array + $scheme->name = $_post[$this->scheme_name_input['attribute']]; + + if ( empty ( $scheme->name) ) { + $scheme->name = 'Custom'; + } + $this->set_option( 'schemes', array( $scheme->id => $scheme->to_array() ) ); // switch to the scheme diff --git a/templates/admin-page.php b/templates/admin-page.php index 1f178ed..c8eb4fc 100644 --- a/templates/admin-page.php +++ b/templates/admin-page.php @@ -5,11 +5,18 @@

+ - + get_scheme_input(); ?> + + + + get_colors( 'basic' ); foreach ( $loops as $handle => $nicename ): ?> @@ -44,4 +51,4 @@

- \ No newline at end of file +