Adding site background to the PressWork toolbox
  • While most colours can be modified from the PressWork toolbox the site background is still only available via the wp dashboard.

    This can be easily fixed. You can do all this in a child theme or custom actions file.

    First we need to add an extra footer script to move the PressWork preview styles to the bottom of the head so that these styles override all others declared in the document head including the site background:
    if(current_user_can('edit_theme_options) && pw_theme_option(toolbox)=='on' ){
    add_action('wp_footer', 'extra_pw_foorter_scripts');
    }
    function extra_pw_footer_scripts(){
    ?>
    <script type='text\javascript'>;
    (function($){
    $('#pw_style_preview).appendTo($('head'));
    })(jQuery);
    </script>;
    <?php
    }


    Next we need to add the default to the $pw_default_options. Simply redefine all values in the array. This is also a good way to set your own defaults:
    $pw_default_options = array(
    ..... //all existing defaults options
    'site_background_color' => ';#FFFFFF'; // your addition and chosen colour
    );


    Next we need to set the default wp background colour:
    set_theme_mod('background_color', substr(pw_theme_option('site_background_color'),1));


    And finally, declare the colour option in the toolbox.php. Add the file and modify the function 'pw_add_all_color_options. Add the line:
    <?php  pw_color_option('page_background', 'site_background_color', __('Site BG Color, "presswork"'), 'body|background-color');  ?>


    That's it!

    I hope the presswork guys will add this to the options by default.

    I'll post some code for adding a background image option to the toolbox soon.
    Post edited by Mike at 2012-01-13 16:33:40