<?php

function lwegatech_customize_register( $wp_customize ) {


   $wp_customize->add_setting( 'logo' ); // Add setting for logo uploader

   // Add control for logo uploader (actual uploader)
   $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'logo', array(
       'label'    => __( 'your can change the site logo here .This will replace site title and tagline.', 'm1' ),
       'section'  => 'title_tagline',
       'settings' => 'logo',
   ) ) );

   //Addding options for the color scheme both primary and background.
   $wp_customize->add_section( 'textcolors' , array(
    'title' =>  'Basic color settings',
) );

// main color ( site title, h1, h2, h4. h6, widget headings, nav links, footer headings )
$txtcolors[] = array(
    'slug'=>'color_scheme_1',
    'default' => '#000',
    'label' => 'Main Color'
);

// secondary color ( site description, sidebar headings, h3, h5, nav links on hover )
$txtcolors[] = array(
    'slug'=>'color_scheme_2',
    'default' => '#666',
    'label' => 'Secondary Color'
);

// link color
$txtcolors[] = array(
    'slug'=>'link_color',
    'default' => '#008AB7',
    'label' => 'Link Color'
);

// link color ( hover, active )
$txtcolors[] = array(
    'slug'=>'hover_link_color',
    'default' => '#9e4059',
    'label' => 'Link Color (on hover)'
);

// add the settings and controls for each color
foreach( $txtcolors as $txtcolor ) {

    // SETTINGS
    $wp_customize->add_setting(
        $txtcolor['slug'], array(
            'default' => $txtcolor['default'],
            'type' => 'option',
            'capability' =>
            'edit_theme_options'
        )
    );
    // CONTROLS
    $wp_customize->add_control(
        new WP_Customize_Color_Control(
            $wp_customize,
            $txtcolor['slug'],
            array('label' => $txtcolor['label'],
            'section' => 'textcolors',
            'settings' => $txtcolor['slug'])
        )
    );
}





}
add_action( 'customize_register', 'lwegatech_customize_register' );





//here we will do the styling of color schemes
function wptutsplus_customize_colors() {
  /**********************
 text colors
 **********************/
 // main color
 $color_scheme_1 = get_option( 'color_scheme_1' );

 // secondary color
 $color_scheme_2 = get_option( 'color_scheme_2' );

 // link color
 $link_color = get_option( 'link_color' );

 // hover or active link color
 $hover_link_color = get_option( 'hover_link_color' );

 /****************************************
styling
****************************************/
?>
<style>


/* color scheme */

/* main color */
#site-title a, h1, h2, h2.page-title, h2.post-title, h2 a:link, h2 a:visited, .menu.main a:link, .menu.main a:visited, footer h3 {
    color:  <?php echo $color_scheme_1; ?>;
}

/* secondary color */
#site-description, .sidebar h3, h3, h5, .menu.main a:active, .menu.main a:hover {
    color:  <?php echo $color_scheme_2; ?>;
}
.menu.main,
.fatfooter {
    border-top: 1px solid <?php echo $color_scheme_2; ?>;
}
.menu.main {
    border-bottom: 1px solid <?php echo $color_scheme_2; ?>;
}
.fatfooter {
    border-bottom: 1px solid <?php echo $color_scheme_2; ?>;
}

/* links color */
a:link, a:visited {
    color:  <?php echo $link_color; ?>;
}

/* hover links color */
a:hover, a:active {
    color:  <?php echo $hover_link_color; ?>;

}


/* background colors */

/* header */
.header-background-on .header-wrapper {
    background-color: <?php echo $color_scheme_1; ?>;
}
.header-background-on #site-title a, .header-background-on h1, .header-background-on #site-description, .header-background-on address, .header-background-on header a:link, .header-background-on header a:visited, .header-background-on header a:active, .header-background-on header a:hover {
    color: #fff;
}
.header-background-on header a:link, .header-background-on header a:visited {
    text-decoration: underline;
}
.header-background-on header a:active, .header-background-on header a:hover {
    text-decoration: none;
}
.header-background-on .menu.main {
    border: none;
}

/* footer */
.footer-background-on footer {
    background-color: <?php echo $color_scheme_1; ?>;
}
.footer-background-on footer, .footer-background-on footer h3, .footer-background-on footer a:link, .footer-background-on footer a:visited, .footer-background-on footer a:active, .footer-background-on footer a:hover {
    color: #fff;
}
.footer-background-on footer a:link, .footer-background-on footer a:visited {
    text-decoration: underline;
}
.footer-background-on footer a:active, .footer-background-on footer a:hover {
    text-decoration: none;
}
.footer-background-on .fatfooter {
    border: none;
}

</style>

<?php
}
add_action( 'wp_head', 'wptutsplus_customize_colors' );


/*******************************************************************************
 add class to body if backgrounds turned on using the body_class filter
 ********************************************************************************/
function wptutsplus_add_background_color_style( $classes ) {

    // set the header background
    $header_background = get_theme_mod( 'header-background' );
    $classes[] = $header_background;

    // set the footer background
    $footer_background = get_theme_mod( 'footer-background' );
    $classes[] = $footer_background;

    return $classes;

}
add_filter('body_class', 'wptutsplus_add_background_color_style');



//addding the customization for the theme $footer_background
add_action('customize_register', 'theme_footer_customizer');
function theme_footer_customizer($wp_customize){
 //adding section in wordpress customizer
$wp_customize->add_section('footer_settings_section', array(
  'title'          => 'Footer Text Settings'
 ));
//adding setting for footer text area
$wp_customize->add_setting('text_setting', array(
 'default'        => 'Default Text For Footer Section',
 ));
$wp_customize->add_control('text_setting', array(
 'label'   => 'Footer Text Here',
  'section' => 'footer_settings_section',
 'type'    => 'textarea',
));

//adding setting for background
$wp_customize->add_setting('background_color', array(
 'default'        => '#ffffff',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'background_color', array(
'label'   => 'Footer Color Setting',
'section' => 'footer_settings_section',

        'settings'   => 'background_color',

    )));

    //adding setting for footer logo
$wp_customize->add_setting('footer_logo');
$wp_customize->add_control(new WP_Customize_Upload_Control($wp_customize,'footer_logo',array(
 'label'      => __('Footer Logo', 'mytheme'),
 'section'    => 'footer_settings_section',
 'settings'   => 'footer_logo',
 )));


}













?>
