Skip to content

Instantly share code, notes, and snippets.

@neilgee
Last active November 14, 2019 21:55
Show Gist options
  • Save neilgee/2531c67100c1ccfae89d to your computer and use it in GitHub Desktop.
Save neilgee/2531c67100c1ccfae89d to your computer and use it in GitHub Desktop.

Revisions

  1. neilgee revised this gist May 29, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion output-css.php
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ function genesischild_css() {

    $hero_bg_image = get_theme_mod( 'hero_bg' ); // Assigning it to a variable to keep the markup clean.

    $css = ( $hero_bg_image !== '') ? sprintf('
    $css .= ( !empty($hero_bg_image) ) ? sprintf('
    .herocontainer {
    background: url(%s) no-repeat center;
    background-size: cover;
  2. neilgee revised this gist Mar 25, 2016. 1 changed file with 28 additions and 30 deletions.
    58 changes: 28 additions & 30 deletions add-customizer-option.php
    Original file line number Diff line number Diff line change
    @@ -6,35 +6,33 @@
    */
    function genesischild_register_theme_customizer( $wp_customize ) {

    // Create custom panel
    $wp_customize->add_panel( 'featured_images', array(
    'priority' => 70,
    'theme_supports' => '',
    'title' => __( 'Featured Images', 'genesischild' ),
    'description' => __( 'Set background images for certain widgets.', 'genesischild' ),
    ) );
    // Create custom panel.
    $wp_customize->add_panel( 'featured_images', array(
    'priority' => 70,
    'theme_supports' => '',
    'title' => __( 'Featured Images', 'genesischild' ),
    'description' => __( 'Set background images for certain widgets.', 'genesischild' ),
    ) );

    // Add section
    $wp_customize->add_section( 'hero_background' , array(
    'title' => __('Hero Background','genesischild'),
    'panel' => 'featured_images',
    'priority' => 20
    ) );

    // Add setting
    $wp_customize->add_setting( 'hero_bg', array(
    'default' => get_stylesheet_directory_uri() . '/images/hero-bg.jpg',
    )
    );

    // Add control
    $wp_customize->add_control(
    new WP_Customize_Image_Control(
    $wp_customize, 'hero_background_image', array(
    'label' => __( 'Add Hero Background Here, the width should be approx 1400px', 'genesischild' ),
    'section' => 'hero_background',
    'settings' => 'hero_bg',
    )
    )
    );
    // Add Featured Image for Hero Widget
    // Add section.
    $wp_customize->add_section( 'hero_background' , array(
    'title' => __( 'Hero Background','genesischild' ),
    'panel' => 'featured_images',
    'priority' => 20,
    ) );

    // Add setting.
    $wp_customize->add_setting( 'hero_bg', array(
    'default' => get_stylesheet_directory_uri() . '/images/hero-bg.jpg',
    ) );

    // Add control.
    $wp_customize->add_control( new WP_Customize_Image_Control(
    $wp_customize, 'hero_background_image', array(
    'label' => __( 'Add Hero Background Here, the width should be approx 1400px', 'genesischild' ),
    'section' => 'hero_background',
    'settings' => 'hero_bg',
    )
    ) );
    }
  3. neilgee revised this gist Mar 25, 2016. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion add-customizer-option.php
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,6 @@ function genesischild_register_theme_customizer( $wp_customize ) {
    // Add setting
    $wp_customize->add_setting( 'hero_bg', array(
    'default' => get_stylesheet_directory_uri() . '/images/hero-bg.jpg',
    'description' => __('this is the description', 'genesischild'),
    )
    );

  4. neilgee revised this gist Mar 25, 2016. 2 changed files with 3 additions and 3 deletions.
    4 changes: 2 additions & 2 deletions add-customizer-option.php
    Original file line number Diff line number Diff line change
    @@ -35,7 +35,7 @@ function genesischild_register_theme_customizer( $wp_customize ) {
    'label' => __( 'Add Hero Background Here, the width should be approx 1400px', 'genesischild' ),
    'section' => 'hero_background',
    'settings' => 'hero_bg',
    )
    )
    )
    )
    );
    }
    2 changes: 1 addition & 1 deletion output-css.php
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@
    function genesischild_css() {
    wp_enqueue_style( 'genesischild', get_stylesheet_directory_uri() . '/style.css' );

    $handle = 'genesischild';
    $handle = 'genesischild'; // Swap in your CSS Stylesheet ID

    $css = '';

  5. neilgee revised this gist Mar 25, 2016. 1 changed file with 13 additions and 12 deletions.
    25 changes: 13 additions & 12 deletions add-customizer-option.php
    Original file line number Diff line number Diff line change
    @@ -8,32 +8,33 @@ function genesischild_register_theme_customizer( $wp_customize ) {

    // Create custom panel
    $wp_customize->add_panel( 'featured_images', array(
    'priority' => 70,
    'priority' => 70,
    'theme_supports' => '',
    'title' => __( 'Featured Images', 'genesischild' ),
    'description' => __( 'Set background images for certain widgets.', 'genesischild' ),
    'title' => __( 'Featured Images', 'genesischild' ),
    'description' => __( 'Set background images for certain widgets.', 'genesischild' ),
    ) );


    // Add section
    $wp_customize->add_section( 'hero_background' , array(
    'title' => __('Hero Background','genesischild'),
    'panel' => 'featured_images',
    'priority' => 20
    'title' => __('Hero Background','genesischild'),
    'panel' => 'featured_images',
    'priority' => 20
    ) );

    // Add setting
    $wp_customize->add_setting( 'hero_bg', array(
    'default' => get_stylesheet_directory_uri() . '/images/hero-bg.jpg',
    'description' => __('this is the description', 'genesischild'),
    'default' => get_stylesheet_directory_uri() . '/images/hero-bg.jpg',
    'description' => __('this is the description', 'genesischild'),
    )
    );

    // Add control
    $wp_customize->add_control(
    new WP_Customize_Image_Control(
    $wp_customize, 'hero_background_image', array(
    'label' => __( 'Add Hero Background Here, the width should be approx 1400px', 'genesischild' ),
    'section' => 'hero_background',
    'settings' => 'hero_bg',
    'label' => __( 'Add Hero Background Here, the width should be approx 1400px', 'genesischild' ),
    'section' => 'hero_background',
    'settings' => 'hero_bg',
    )
    )
    );
  6. neilgee revised this gist Mar 25, 2016. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion add-customizer-option.php
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,6 @@ function genesischild_register_theme_customizer( $wp_customize ) {
    ) );


    // Add Featured Image for Hero Widget
    // Add section
    $wp_customize->add_section( 'hero_background' , array(
    'title' => __('Hero Background','genesischild'),
  7. neilgee revised this gist Mar 25, 2016. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions widget-register.php
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,8 @@
    <?php
    /**
    * Register and unregister and position all the widgets.
    */

    add_action( 'widgets_init', 'genesischild_extra_widgets' );
    /**
    * Register new Widget areas and position them.
    * Register new Widget area and position it after the header.
    */
    function genesischild_extra_widgets() {

  8. neilgee revised this gist Mar 25, 2016. 3 changed files with 0 additions and 4 deletions.
    1 change: 0 additions & 1 deletion add-customizer-option.php
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,6 @@
    add_action( 'customize_register', 'genesischild_register_theme_customizer' );
    /*
    * Register Our Customizer Stuff Here
    *
    */
    function genesischild_register_theme_customizer( $wp_customize ) {

    1 change: 0 additions & 1 deletion output-css.php
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,6 @@
    add_action( 'wp_enqueue_scripts', 'genesischild_css' );
    /**
    * Output CSS for background image
    *
    */
    function genesischild_css() {
    wp_enqueue_style( 'genesischild', get_stylesheet_directory_uri() . '/style.css' );
    2 changes: 0 additions & 2 deletions widget-register.php
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,6 @@
    <?php
    /**
    * Register and unregister and position all the widgets.
    *
    * @package genesischild
    */
    add_action( 'widgets_init', 'genesischild_extra_widgets' );
    /**
  9. neilgee revised this gist Mar 25, 2016. 2 changed files with 69 additions and 0 deletions.
    42 changes: 42 additions & 0 deletions add-customizer-option.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    <?php

    add_action( 'customize_register', 'genesischild_register_theme_customizer' );
    /*
    * Register Our Customizer Stuff Here
    *
    */
    function genesischild_register_theme_customizer( $wp_customize ) {

    // Create custom panel
    $wp_customize->add_panel( 'featured_images', array(
    'priority' => 70,
    'theme_supports' => '',
    'title' => __( 'Featured Images', 'genesischild' ),
    'description' => __( 'Set background images for certain widgets.', 'genesischild' ),
    ) );


    // Add Featured Image for Hero Widget
    // Add section
    $wp_customize->add_section( 'hero_background' , array(
    'title' => __('Hero Background','genesischild'),
    'panel' => 'featured_images',
    'priority' => 20
    ) );
    // Add setting
    $wp_customize->add_setting( 'hero_bg', array(
    'default' => get_stylesheet_directory_uri() . '/images/hero-bg.jpg',
    'description' => __('this is the description', 'genesischild'),
    )
    );
    // Add control
    $wp_customize->add_control(
    new WP_Customize_Image_Control(
    $wp_customize, 'hero_background_image', array(
    'label' => __( 'Add Hero Background Here, the width should be approx 1400px', 'genesischild' ),
    'section' => 'hero_background',
    'settings' => 'hero_bg',
    )
    )
    );
    }
    27 changes: 27 additions & 0 deletions output-css.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    <?php

    add_action( 'wp_enqueue_scripts', 'genesischild_css' );
    /**
    * Output CSS for background image
    *
    */
    function genesischild_css() {
    wp_enqueue_style( 'genesischild', get_stylesheet_directory_uri() . '/style.css' );

    $handle = 'genesischild';

    $css = '';

    $hero_bg_image = get_theme_mod( 'hero_bg' ); // Assigning it to a variable to keep the markup clean.

    $css = ( $hero_bg_image !== '') ? sprintf('
    .herocontainer {
    background: url(%s) no-repeat center;
    background-size: cover;
    }
    ', $hero_bg_image ) : '';

    if ( $css ) {
    wp_add_inline_style( $handle , $css );
    }
    }
  10. neilgee revised this gist Mar 25, 2016. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion widget-register.php
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,6 @@ function genesischild_extra_widgets() {
    'name' => __( 'Hero Home Page', 'genesischild' ),
    'description' => __( 'This is the Hero Home Page area', 'genesischild' ),
    ) );

    }

    add_action( 'genesis_after_header','genesischild_hero_widget' );
  11. neilgee created this gist Mar 25, 2016.
    30 changes: 30 additions & 0 deletions widget-register.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    <?php
    /**
    * Register and unregister and position all the widgets.
    *
    * @package genesischild
    */
    add_action( 'widgets_init', 'genesischild_extra_widgets' );
    /**
    * Register new Widget areas and position them.
    */
    function genesischild_extra_widgets() {

    genesis_register_sidebar( array(
    'id' => 'hero',
    'name' => __( 'Hero Home Page', 'genesischild' ),
    'description' => __( 'This is the Hero Home Page area', 'genesischild' ),
    ) );

    }

    add_action( 'genesis_after_header','genesischild_hero_widget' );
    /**
    * Position the Hero Area.
    */
    function genesischild_hero_widget() {
    genesis_widget_area( 'hero', array(
    'before' => '<section class="herocontainer"><div class="wrap hero">',
    'after' => '</div></section>',
    ));
    }