electreffects | it's electric and effects

Replacing primary sidebar with the secondary sidebar

On my pages, viagra usa pharmacy I have selected a two column format from my theme’s options. The primary sidebar is displayed to the right of the main content. I want to replace that with the secondary sidebar.( I don’t want to effect Featured Items, individual posts, or category pages. More on that later.)
Starting with my theme’s page.php, I find a call to php get_sidebar()on line 19. From the wordpress codex:

Includes the sidebar.php template file from your current theme’s directory.

If a name ($name) is specified then a specialized sidebar sidebar-{name}.php will be included. If sidebar-{name}.php does not exist, then it will fallback to loading sidebar.php.

If the theme contains no sidebar.php file then the sidebar from the default theme wp-includes/theme-compat/sidebar.php will be included.

That brings us to sidebar.php.

First I made a copy of my theme’s sidebar.php, and placed it in in my child theme’s folder. We’ll make any edits to this new file.

Lets take a look at what’s in the theme’s sidebar.php. In line 2, we have a reference to a global variable:
global $sds_theme_options;
This gives us access to the global variable $sds_theme_options from within our function. Line 5 has the first reference to this global variable.
if ( ! isset( $sds_theme_options['body_class'] ) || ( ! empty( $sds_theme_options['body_class'] ) && $sds_theme_options['body_class'] !== 'cols-1' ) ) :
a or (b and c). If body class is not set in the theme options, or the body class is not empty, and the body class is not set as ‘cols-1′, meaning the page has more than one column, then show the primary sidebar.

The next if statement is similar. It controls whether the secondary sidebar is shown or not.
if ( isset( $sds_theme_options['body_class'] ) && ! empty( $sds_theme_options['body_class'] ) && strpos( $sds_theme_options['body_class'], 'cols-3' ) !== false ) :
If body class is set in theme options, and the body class is not empty, and the string ‘cols-3′ exists in the $sds_theme_options variable, then we know we have a layout that calls for the secondary sidebar.

With this setup, as long as the body class is not ‘cols-1′, then the primary sidebar is shown to the right(as is set in the theme options for pages). As long as ‘cols-3′ is part of the body class, the primary sidebar is moves to the left, and the secondary sidebar is shown to the right. The only time the secondary sidebar is shown is if the primary sidebar is also there. What we want is to have the secondary sidebar show in the primary sidebar’s position if there are two columns, and have the primary and secondary sidebars show in their normal positions if there are three columns.

I decided to add an additional if and else to the top of my child theme’s sidebar.php. If body class is set, and body class is not empty, and body class contains the text ‘cols-2′, then put the secondary sidebar in the primary sidebar’s position. else, do what the function used to do. this way I’m only affecting the two column pages. Remember, sidebar.php gets used in every type of page, post, category, etc.

Here is my final sidebar.php:



Using Font Awesome in Modern Business Pro theme

Font Awesome is enqueued in the file includes/ModernBusiness.php, tadalafil discount line 214.

wp_enqueue_style( 'font-awesome-css-min', cialis usa get_template_directory_uri() . '/includes/css/font-awesome.min.css' );

I had included it myself in my child theme’s functions.php with this code:

//* Load Font Awesome
add_action( 'wp_enqueue_scripts', 'enqueue_font_awesome' );
function enqueue_font_awesome() {
wp_enqueue_style( 'font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css' );
}

It turns out, my function wasn’t needed. I commented it out, and Font Awesome still works.

How does this file get included? It starts with line 15 of functions.php:

include_once get_template_directory() . '/includes/theme-functions.php'; // SDS Theme Options Functions

This includes the file theme-functions.php, which is located in the folder /includes.

I searched for ‘awesome’ in the file theme-functions.php. line 915:

wp_enqueue_style( 'font-awesome-css-min', get_template_directory_uri() . '/includes/css/font-awesome.min.css' );

There it is. but why didn’t my first attempts at using Font Awesome fonts work? if we look at the code surrounding the wp_enqueue_style (method? what’s the correct name?):

// Theme Option Fonts (Social Media)
if ( ! empty( $sds_theme_options['social_media'] ) ) {
$social_networks_active = false;

foreach( $sds_theme_options['social_media'] as $network => $url )
if ( ! empty( $url ) ) {
$social_networks_active = true;
break;
}

if ( $social_networks_active )
wp_enqueue_style( 'font-awesome-css-min', get_template_directory_uri() . '/includes/css/font-awesome.min.css' );
}

This means if no social network links have been added to the theme options, the wp_enqueue_style (thing?) is never called. When I fist tried using Font Awesome, i didn’t have ant social media links added to my theme options. If I remove the links, Font Awesome should go back to not working.

That didn’t work. I removed the link, yet the phone icon was still there. When is functions.php called? Is it every time the page is loaded? Yes, it should be. Did I read the above code incorrectly?
the if ( ! empty( and the foreach( are used to set the $social_networks_active variable. The final if statement would only carry out the wp_enqueue_style function(?) if the $social_networks_active = true.

Did I include font awesome somewhere else?