diff --git a/wp-admin/custom-background.php b/wp-admin/custom-background.php index bf5f33f11..22ecc7995 100644 --- a/wp-admin/custom-background.php +++ b/wp-admin/custom-background.php @@ -57,7 +57,10 @@ class Custom_Background { $page = add_theme_page(__('Background'), __('Background'), 'switch_themes', 'custom-background', array(&$this, 'admin_page')); - add_action("admin_head-$page", array(&$this, 'take_action'), 50); + add_action("admin_print_scripts-$page", array(&$this, 'js_includes')); + add_action("admin_print_styles-$page", array(&$this, 'css_includes')); + add_action("admin_head-$page", array(&$this, 'js'), 50); + add_action("admin_head-$page", array(&$this, 'take_action'), 49); if ( $this->admin_header_callback ) add_action("admin_head-$page", $this->admin_header_callback, 51); } @@ -80,6 +83,30 @@ class Custom_Background { return $step; } + /** + * Setup the enqueue for the JavaScript files. + * + * @since unknown + */ + function js_includes() { + $step = $this->step(); + + if ( 1 == $step ) + wp_enqueue_script('farbtastic'); + } + + /** + * Setup the enqueue for the CSS files + * + * @since unknown + */ + function css_includes() { + $step = $this->step(); + + if ( 1 == $step ) + wp_enqueue_style('farbtastic'); + } + /** * Execute custom background modification. * @@ -119,6 +146,70 @@ class Custom_Background { } if ( isset($_POST['remove-background']) ) set_theme_mod('background_image', ''); + if ( isset( $_POST['background-color'] ) ) { + $color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['background-color']); + if ( strlen($color) == 6 || strlen($color) == 3 ) + set_theme_mod('background_color', $color); + else + set_theme_mod('background_color', ''); + } + } + + /** + * Execute Javascript depending on step. + * + * @since unknown + */ + function js() { + $step = $this->step(); + if ( 1 == $step ) + $this->js_1(); + } + + /** + * Display Javascript based on Step 1. + * + * @since unknown + */ + function js_1() { ?> + +admin_image_div_callback); } else { ?> -