Robin Cox
Robin Cox

Reputation: 1490

Edit the default colorscheme in twentyfifteen

I would like to edit the default colorscheme in the wordpress theme twentyfifteen from my childscheme. I know how to add a new colorsheme like this in functions.php:

add_filter('twentyfifteen_color_schemes', 'my_custom_color_schemes');
function my_custom_color_schemes( $schemes ) {
    $schemes['pinkscheme'] = array(
        'label'  => __( 'Pinkscheme', 'twentyfifteen' ),
        'colors' => array(
            '#f1f1f1',
            '#C32148',
            '#ffffff',
            '#333333',
            '#333333',
            '#f7f7f7',
        ),
    );
    return $schemes;
}

But how can I change the default scheme? if I do this:

add_filter('twentyfifteen_color_schemes', 'my_custom_color_schemes');
function my_custom_color_schemes( $schemes ) {
    $schemes['default'] = array(
        'label'  => __( 'Default', 'twentyfifteen' ),
        'colors' => array(
            '#f1f1f1',
            '#C32148',
            '#ffffff',
            '#333333',
            '#333333',
            '#f7f7f7',
        ),
    );
    return $schemes;
}

I think I will get an error because I'm trying to declare a function twice? Or maybe not give the error but change back when the parents function is loaded?

Upvotes: 1

Views: 56

Answers (1)

user488187
user488187

Reputation:

Yes, you can change the default color scheme with:

add_filter('twentyfifteen_color_schemes', 'my_custom_color_schemes');
function my_custom_color_schemes( $schemes ) {
  $schemes['default'] = array(
    'label'  => __( 'Default', 'twentyfifteen' ),
    'colors' => array(
        '#f1f1f1',
        '#C32148',
        '#ffffff',
        '#333333',
        '#333333',
        '#f7f7f7',
    ),
  );
  return $schemes;
}

When the TwentyFifteen theme applies the 'twentyfifteen_color_schemes' filter, it passes an array $schemes of the color schemes it has by default.

In this case, you are not redefining a function, but setting a member of an array to a different value.

Upvotes: 1

Related Questions