Skip to content

Instantly share code, notes, and snippets.

@sassinack
Created December 27, 2012 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sassinack/4388983 to your computer and use it in GitHub Desktop.
Save sassinack/4388983 to your computer and use it in GitHub Desktop.
Genesis: PHP: create widget areas
//add php functionality in text widget
add_filter('widget_text', 'php_text', 99);
function php_text($text) {
if (strpos($text, '<' . '?') !== false) {
ob_start();
eval('?' . '>' . $text);
$text = ob_get_contents();
ob_end_clean();
}
return $text;
}
//add widget areas
register_sidebar( array(
'id' => 'slider',
'name' => 'Slider',
'description' => 'Displays responsive slider after header',
'after_widget' => '<div class="shadow-left"></div>'
) );
register_sidebar( array(
'id' => 'fixed-chat-tab',
'name' => 'Fixed Chat Tab',
'description' => 'Place Live Person chat button code here.',
'before_widget' => '<div id="fixed-chat" class="">',
'after_widget' => '</div>',
) );
//display widget area
add_action( 'genesis_before_header', 'Fixed' );
/** Loads a new sidebar after the header */
function fixed() {
echo '<div class="fixed-chat-tab">';
dynamic_sidebar( 'fixed-chat-tab' );
echo '</div>';
}
//display widget area
add_action( 'genesis_after_header', 'Slider' );
/** Loads a new sidebar after the header */
function slider() {
echo '<div class="slider">';
dynamic_sidebar( 'slider' );
echo '</div>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment