I have determined that my plugin code works perfectly fine in other themes, but in the theme: Magazinly, the sidebar plugin I wrote, causes the sidebar not to display. Through debugging, I've determined that the sidebars register, and two sidebar arrays are created, but one is not populated.
Here is the plugin code:
register_sidebar(array(
'name'=>'Bottom Widget Area',
'id'=> 'bottom-widget',
'before_widget' => '<aside class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<div class="block-title"><span>',
'after_title' => '</span></div>'
));
include 'add_bottom_bar.php';
This is add_bottom_bar.php:
// Register Bottom_Bar
function add_bottom_widget(){
echo '<div class=\'bottombar\'>';
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('bottom-widget')) :
endif;
echo '</div>';
}
add_action ('get_footer', 'add_bottom_widget');
// Register style sheet.
add_action( 'wp_enqueue_scripts', 'register_plugin_styles' );
// Register style sheet.
function register_plugin_styles() {
wp_register_style( 'custom_widget_final', plugins_url( 'custom_widget_final/css/bottom_bar.css' ) );
wp_enqueue_style( 'custom_widget_final' );
}
And here is the code for the sidebar in Magazinly:
There's also this code that appears to use whatever this thing the theme creator called 'dinamic sidebar' to... well... I would imagine... render dynamic sidebars :
But, my guess is that this is the culprit: The Magazinly theme uses this sidebar loader, but it seems like serious overkill. I am guessing that the sidebar widget I'm registering, is disrupting this sidebar loader.
With all code presented, my next question is: what are my options? I need to add widget positions to three sites, all using the same theme, but preserve the sidebar. Presently, if I activate my plugin, the sidebar won't load, but the plugin works. If I deactivate the plugin, the sidebar returns. Both are important, but I cannot modify the theme, and creating a child theme seems excessive. I'd prefer to debug this theme, and use widgets.
Here's what I have tried/tested:
Tested this plugin on four other WP sites. No issues. Sidebars render fine. Plugin works like a charm.
On problem site: wp_debug, set to true... throws no errors, but gives a warning for each of the theme's native sidebars (no id set, which is a pre 4.1 thing). To my knowledge, it does not affect anything.
I removed the include at the bottom, just to narrow down where the problem could be in my code. I determined that even when the css enqueue is disabled, or even if add_bottom_bar.php is not included, the theme's native sidebars still break. This makes it abundantly, totally clear to me that there is a register_sidebar conflict.
I've looked at the source when the plugin is activated, and when it is deactivated. I find after diffing the source, when the plugin is activated, the sidebars do not show in the source, so it is not a css/js thing, as far as I can tell.
What, if any workaround might there be for this? A widget would greatly improve workflow, but I'm beginning to consider that letting go of the sidebar/widget situation might be smarter.
Any hints, tips, or insight? I know my question is a bit general, but I've hit a brick wall, here, in trying to stay hands-off with this theme code.
Any help would be much appreciated! Thanks!