diff --git a/functions.php b/functions.php
index 1e04495..42d1f2b 100644
--- a/functions.php
+++ b/functions.php
@@ -89,8 +89,10 @@ function arras_setup() {
remove_action( 'wp_head', 'pagenavi_css' );
add_action( 'arras_head', 'arras_override_styles' );
+
add_action( 'arras_custom_styles', 'arras_add_custom_logo' );
add_action( 'arras_custom_styles', 'arras_constrain_footer_sidebars' );
+ add_action( 'arras_custom_styles', 'arras_add_custom_background' );
add_action( 'arras_beside_nav', 'arras_social_nav' );
diff --git a/library/admin/background.php b/library/admin/background.php
index 07a9934..d0009e1 100644
--- a/library/admin/background.php
+++ b/library/admin/background.php
@@ -21,8 +21,24 @@ function arras_custom_background_scripts() {
}
function arras_custom_background_styles() {
- ?> false,
+ 'id' => 0,
+ 'attachment' => 'scroll',
+ 'pos-x' => 'center',
+ 'pos-y' => 'center',
+ 'repeat' => 'no-repeat',
+ 'color' => '#F0F0F0',
+ 'foreground' => false,
+ 'wrap' => false
+ );
+
+ return $_defaults;
}
function arras_custom_background() {
@@ -32,23 +48,16 @@ function arras_custom_background() {
if ( isset($_REQUEST['reset']) ) {
check_admin_referer('arras-custom-background');
- $arras_custom_bg_options = array(
- 'enable' => false,
- 'id' => 0,
- 'attachment' => 'scroll',
- 'pos-x' => 'center',
- 'pos-y' => 'center',
- 'repeat' => 'no-repeat',
- 'color' => '#F0F0F0',
- 'foreground' => false,
- 'wrap' => false
- );
- update_option('arras_custom_bg_options', maybe_serialize($arras_custom_bg_options));
+ $arras_custom_bg_options = arras_get_custom_background_defaults();
+ update_option( 'arras_custom_bg_options', maybe_serialize($arras_custom_bg_options) );
$notices = '
' . __('Your settings have been reverted to the defaults.', 'arras') . '
';
}
if ( isset($_REQUEST['save']) ) {
+ var_dump( $_REQUEST );
+
check_admin_referer('arras-custom-background');
+ $defaults = arras_get_custom_background_defaults();
if ($_FILES['import']['error'] != 4) {
$overrides = array('test_form' => false);
@@ -73,18 +82,19 @@ function arras_custom_background() {
$arras_custom_bg_options['id'] = wp_insert_attachment($object, $file);
}
- $arras_custom_bg_options['enable'] = (boolean)(isset($_POST['bg-enable']));
- $arras_custom_bg_options['attachment'] = stripslashes($_POST['bg-attachment']);
- $arras_custom_bg_options['pos-x'] = stripslashes($_POST['bg-pos-x']);
- $arras_custom_bg_options['pos-y'] = stripslashes($_POST['bg-pos-y']);
- $arras_custom_bg_options['repeat'] = stripslashes($_POST['bg-repeat']);
- $arras_custom_bg_options['color'] = stripslashes($_POST['bg-color']);
- $arras_custom_bg_options['foreground'] = (boolean)(isset($_POST['foreground']));
- $arras_custom_bg_options['wrap'] = (boolean)(isset($_POST['wrap']));
+ $arras_custom_bg_options['enable'] = ( isset( $_POST['bg-enable'] ) );
- update_option('arras_custom_bg_options', maybe_serialize($arras_custom_bg_options));
+ $arras_custom_bg_options['attachment'] = isset( $_POST['bg-attachment'] ) ? $_POST['bg-attachment'] : $defaults['attachment'];
+ $arras_custom_bg_options['pos-x'] = isset( $_POST['bg-pos-x'] ) ? $_POST['bg-pos-x'] : $defaults['pos-x'];
+ $arras_custom_bg_options['pos-y'] = isset( $_POST['bg-pos-y'] ) ? $_POST['bg-pos-y'] : $defaults['pos-y'];
+ $arras_custom_bg_options['repeat'] = isset( $_POST['bg-repeat'] ) ? $_POST['bg-repeat'] : $defaults['repeat'];
+ $arras_custom_bg_options['color'] = ( isset( $_POST['bg-color'] ) && preg_match( '/^#?(([a-fA-F0-9]){3}){1,2}$/', $_POST['bg-color'] ) )? $_POST['bg-color'] : $defaults['color'];
+ $arras_custom_bg_options['foreground'] = isset( $_POST['foreground'] );
+ $arras_custom_bg_options['wrap'] = isset( $_POST['wrap'] ) ? $_POST['wrap'] : $defaults['wrap'];
+
+ update_option( 'arras_custom_bg_options', maybe_serialize( $arras_custom_bg_options ) );
- $notices = '' . __('Your settings have been saved to the database.', 'arras') . '
';
+ $notices = '' . __( 'Your settings have been saved to the database.', 'arras' ) . '
';
}
if ( isset($_GET['page']) && $_GET['page'] == 'arras-custom-background' ) : ?>
@@ -150,7 +160,7 @@ function arras_custom_background() {
-
+
@@ -161,24 +171,4 @@ function arras_custom_background() {
- { background: !important; }
-
-#main { background: url(/images/foreground.png) !important; }
-
\ No newline at end of file
diff --git a/library/styles.php b/library/styles.php
index aaa8d73..3157525 100644
--- a/library/styles.php
+++ b/library/styles.php
@@ -18,7 +18,6 @@ function is_valid_arras_style($file) {
function arras_override_styles() {
?>
-