';
$after_widget = "\n
\n";
$before_title = '';
$after_title = " \n";
register_sidebar(array(
'name' => 'Default Sidebar',
'id' => SIDEBAR_DEFAULT,
'before_widget' => $before_widget,
'after_widget' => $after_widget,
'before_title' => $before_title,
'after_title' => $after_title,
'description' => 'This is the default sidebar shown if no sidebar is associated to the page for some reason.'
));
for ($i=1; $i<=23; $i++) {
register_sidebar(array(
'name' => "Sidebar $i",
'id' => "sidebar-$i",
'before_widget' => $before_widget,
'after_widget' => $after_widget,
'before_title' => $before_title,
'after_title' => $after_title
));
}
register_sidebar(array(
'name' => 'Homepage Sidebar',
'id' => SIDEBAR_HOMEPAGE,
'before_widget' => $before_widget,
'after_widget' => $after_widget,
'before_title' => $before_title,
'after_title' => $after_title,
'description' => 'This is the sidebar that shows on the homepage.'
));
}
// allow calling a sidebar by id instead of name to make it easier if a sidebar name changes in the future
function portico_dynamic_sidebar($id) {
global $wp_registered_sidebars;
if (function_exists('dynamic_sidebar')) {
foreach ( (array) $wp_registered_sidebars as $key => $value ) {
if ($key == $id) {
dynamic_sidebar($value['name']);
return true;
}
}
}
return false;
}
// get the sidebar id associated with the current page or section
function portico_get_sidebar_id() {
$sidebar_id = false;
// check for page specific sidebar id
if (is_page() || is_single()) {
$sidebar_info = portico_custom_info('sidebar');
if ($sidebar_info && !empty($sidebar_info['id'])) {
return $sidebar_info['id'];
}
global $post;
// individual case study pages
if ($post->post_parent == CASE_STUDIES_PAGE_ID) {
return 'sidebar-9';
} elseif (portico_is_news_section()) {
return 'sidebar-19';
}
}
if (portico_is_events() || portico_is_events_section()) {
return 'sidebar-20';
} elseif (portico_is_past_news()) {
return 'sidebar-19';
} elseif (is_category(NEWS_EVENTS_CATEGORY_ID) || portico_is_news_section()) {
return 'sidebar-18';
} elseif (is_front_page()) {
return SIDEBAR_HOMEPAGE;
}
// sidebar-18
// p45 - News & Events
// p46 - Announcements & Press Releases
// sidebar-19
// p47 - Individual Article Pages
// p48 - Past News
// check for news & events specific pages
// if (portico_is_news() || portico_is_news_and_events()) {
//
// }
// else
return SIDEBAR_DEFAULT;
}
// print out the right sidebar
function portico_get_right_sidebar() {
$sidebar_id = portico_get_sidebar_id();
// make sure to show a sidebar if the sidebar wasn't found
if (!portico_dynamic_sidebar($sidebar_id))
portico_dynamic_sidebar(SIDEBAR_DEFAULT);
}
// print out the left sidebar
function portico_get_left_sidebar() {
portico_dynamic_sidebar(SIDEBAR_LEFT);
}
class Portico_Widget_E_News_Signup extends WP_Widget {
function Portico_Widget_E_News_Signup() {
$widget_ops = array('classname' => 'e_news_signup', 'description' => __( "E-News Sign-up form") );
$this->WP_Widget('portico_e_news_signup', __('E-News Sign-up (static)'), $widget_ops);
}
function widget( $args, $instance ) {
extract($args);
echo $before_widget;
echo 'E-News Sign-up ';
echo 'Sign up for our email alerts.
';
echo do_shortcode( '[gravityform id="1" title="false" description="false"]' );
// echo '';
// echo '';
echo $after_widget;
}
function form( $instance ) {
echo $this->widget_options['description'];
}
function update( $new_instance, $old_instance ) {
return $new_instance;
}
}
class Portico_Widget_Search_News extends WP_Widget {
function Portico_Widget_Search_News() {
$widget_ops = array('classname' => 'search_news', 'description' => __( "Search News form") );
$this->WP_Widget('portico_search_news', __('Search News (static)'), $widget_ops);
}
function widget( $args, $instance ) {
extract($args);
$search_url = get_bloginfo('home') . '/';
echo $before_widget;
echo '';
echo '';
echo $after_widget;
}
function form( $instance ) {
echo $this->widget_options['description'];
}
function update( $new_instance, $old_instance ) {
return $new_instance;
}
}
class Portico_Widget_Question extends WP_Widget {
function Portico_Widget_Question() {
$widget_ops = array('classname' => 'question', 'description' => __('Question background with arbitrary text or HTML'));
$control_ops = array('width' => 400, 'height' => 350);
$this->WP_Widget('portico_question', __('Question'), $widget_ops, $control_ops);
}
function widget( $args, $instance ) {
extract($args);
$title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance );
$text = apply_filters( 'widget_text', $instance['text'], $instance );
echo $before_widget;
echo !empty( $title ) ? "$title " : '';
echo $instance['filter'] ? wpautop($text) : $text;
echo $after_widget;
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
if ( current_user_can('unfiltered_html') )
$instance['text'] = $new_instance['text'];
else
$instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed
$instance['filter'] = isset($new_instance['filter']);
return $instance;
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) );
$title = strip_tags($instance['title']);
$text = format_to_edit($instance['text']);
?>
/>
'latest_news', 'description' => __( "Display 2 of the most recent news articles") );
$this->WP_Widget('portico_latest_news', __('Latest News (static)'), $widget_ops);
}
function widget( $args, $instance ) {
extract($args);
$posts = get_posts('numberposts=2&category=' . NEWS_CATEGORY_ID);
if ($posts) {
echo $before_widget;
echo 'Latest News ';
echo '';
echo 'Read more News & Events
';
echo $after_widget;
}
}
function form( $instance ) {
echo $this->widget_options['description'];
}
function update( $new_instance, $old_instance ) {
return $new_instance;
}
}
class Portico_Widget_Latest_News_Homepage extends WP_Widget {
function Portico_Widget_Latest_News_Homepage() {
$widget_ops = array('classname' => 'latest_news_homepage', 'description' => __( "Display the most recent news article") );
$this->WP_Widget('portico_latest_news_homepage', __('Latest News Homepage (static)'), $widget_ops);
}
function widget( $args, $instance ) {
extract($args);
function limit_words($string, $word_limit)
{
$words = explode(" ",$string);
return implode(" ",array_splice($words,0,$word_limit));
}
$posts = get_posts('numberposts=2&category=' . NEWS_CATEGORY_ID);
if ($posts) {
echo $before_widget;
echo '';
echo 'More »
';
echo $after_widget;
}
}
function form( $instance ) {
echo $this->widget_options['description'];
}
function update( $new_instance, $old_instance ) {
return $new_instance;
}
}
class Portico_Widget_Testimonial extends WP_Widget {
function Portico_Widget_Testimonial() {
$widget_ops = array('classname' => 'testimonial', 'description' => __( "A page specific testimonial will be displayed or a random testimonial if no specific testimonial is assigned") );
$this->WP_Widget('portico_testimonial', __('Testimonial (global)'), $widget_ops);
}
function widget( $args, $instance ) {
extract($args);
$testimonial = false;
// check for page specific testimonial
if (is_single() || is_page()) {
global $id;
$sidebar_info = portico_custom_info('sidebar', $id);
$testimonial_id = (int)$sidebar_info['testimonial_id'];
if ($testimonial_id > 0) {
if ($post = get_post($testimonial_id)) {
$testimonial = $post;
}
}
}
// if we didn't get a testimonial or are on a page with randomly displayed testimonials
if ($testimonial === false) {
$parent_id = TESTIMONIALS_PAGE_ID;
$posts = get_posts("post_parent=$parent_id&orderby=rand&showposts=1&post_type=any");
if ($posts) {
$testimonial = $posts[0];
}
}
// $posts = get_posts('numberposts=2&category=' . NEWS_CATEGORY_ID);
if ($testimonial) {
echo $before_widget;
echo 'What Participants Say ';
echo $testimonial->post_content;
echo $after_widget;
}
}
function form( $instance ) {
echo $this->widget_options['description'];
}
function update( $new_instance, $old_instance ) {
return $new_instance;
}
}
class Portico_Widget_Facts_Figures extends WP_Widget {
function Portico_Widget_Facts_Figures() {
$widget_ops = array('classname' => 'facts_figures', 'description' => __( "Display a random Facts & Figure") );
$this->WP_Widget('portico_facts_figures', __('Facts & Figures (global)'), $widget_ops);
}
function widget( $args, $instance ) {
extract($args);
$portico_widgets = get_option('portico_widgets');
$facts_figures = explode("\r\n", trim($portico_widgets['fandf_right']));
if (count($facts_figures) > 0) {
$value = $facts_figures[array_rand($facts_figures)];
echo $before_widget;
echo 'Facts & Figures ';
echo '';
echo do_shortcode($value);
echo '
';
echo 'See more Facts & Figures
';
echo $after_widget;
}
}
function form( $instance ) {
echo $this->widget_options['description'];
}
function update( $new_instance, $old_instance ) {
return $new_instance;
}
}
class Portico_Widget_Recent_Titles extends WP_Widget {
function Portico_Widget_Recent_Titles() {
$widget_ops = array('classname' => 'recent_titles', 'description' => __( "Display the 3 most recently added titles") );
$this->WP_Widget('portico_recent_titles', __('Recent Titles Added (static)'), $widget_ops);
}
function widget( $args, $instance ) {
extract($args);
echo $before_widget;
echo 'Recent Titles Added ';
echo 'Placeholder content
';
echo $after_widget;
}
function form( $instance ) {
echo $this->widget_options['description'];
}
function update( $new_instance, $old_instance ) {
return $new_instance;
}
}
class Portico_Widget_Trigger_Events extends WP_Widget {
function Portico_Widget_Trigger_Events() {
$widget_ops = array('classname' => 'trigger_events', 'description' => __( "Display trigger event information") );
$control_ops = array('width' => 400, 'height' => 350);
$this->WP_Widget('portico_trigger_events', __('Trigger Events'), $widget_ops, $control_ops);
}
function widget( $args, $instance ) {
extract($args);
if (is_single() || is_page()) {
$sidebar_info = portico_custom_info('sidebar');
if ($sidebar_info['show_trigger_events'] == 1) {
$text = apply_filters( 'widget_text', $instance['text'], $instance );
echo $before_widget;
echo 'Trigger Events ';
echo $instance['filter'] ? wpautop($text) : $text;
echo $after_widget;
}
}
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
if ( current_user_can('unfiltered_html') )
$instance['text'] = $new_instance['text'];
else
$instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed
$instance['filter'] = isset($new_instance['filter']);
return $instance;
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'text' => '' ) );
$text = format_to_edit($instance['text']);
?>
/>
widgets = array();
unregister_sidebar_widget(sanitize_title('Breadcrumb NavXT'));
$widgets = array(
'WP_Widget_Text',
'Portico_Widget_E_News_Signup',
'Portico_Widget_Search_News',
'Portico_Widget_Question',
'Portico_Widget_Latest_News',
'Portico_Widget_Latest_News_Homepage',
'Portico_Widget_Testimonial',
'Portico_Widget_Facts_Figures',
'Portico_Widget_Recent_Titles',
'Portico_Widget_Trigger_Events'
);
foreach ($widgets as $widget) {
register_widget($widget);
}
}
add_action('widgets_init', 'portico_widgets_init', 10);
function portico_sidebar_admin_page() {
echo '';
}
function portico_facts_figures_left() {
$portico_widgets = get_option('portico_widgets');
$facts_figures = explode("\r\n", trim($portico_widgets['fandf_left']));
if (count($facts_figures) > 0) {
// print_r($facts_figures);
// print array_rand($facts_figures);
list($key, $title) = explode(',', $facts_figures[array_rand($facts_figures)]);
$title = esc_html(trim($title));
$url = get_permalink(FACTS_FIGURES_PAGE_ID);
$value = do_shortcode("[stat key=\"$key\"]");
$size = strlen(str_replace(',', '', $value));
// determine class name based on how many digits are in the value
if ($size <= 4)
$class_name = 'size_1';
elseif ($size <= 6)
$class_name = 'size_2';
elseif ($size <= 8)
$class_name = 'size_3';
else
$class_name = 'size_4';
echo '";
}
}
if (is_admin()) {
add_action('sidebar_admin_page', 'portico_sidebar_admin_page');
}
add_action( 'excerpt_length', 'portico_excerpt_length' );
function portico_excerpt_length()
{
return 25;
}