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.

我已经确定我的插件代码在其他主题中运行得非常好,但在主题中:Magazinly,我编写的侧边栏插件会导致侧边栏无法显示。通过调试,我已确定侧边栏注册,并创建了两个侧边栏阵列,但未填充一个侧边栏阵列。

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:

这是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:

以下是Magazinly侧边栏的代码:

http://pastebin.com/eJu7Wk3C

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 :

还有这个代码似乎使用了主题创建者称之为“dinamic sidebar”的东西......好吧......我会想象......渲染动态侧边栏:

http://pastebin.com/T0LW3QTS

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.

但是,我的猜测是,这是罪魁祸首:Magazinly主题使用这个侧边栏加载器,但它似乎严重矫枉过正。我猜我正在注册的侧边栏小部件正在扰乱这个侧边栏加载器。

http://pastebin.com/jCtvjVqC

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:

这是我尝试/测试的内容:

  1. Tested this plugin on four other WP sites. No issues. Sidebars render fine. Plugin works like a charm.

    在其他四个WP站点上测试了这个插件。没有问题。侧边栏渲染得很好。插件就像一个魅力。

  2. 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.

    在问题站点:wp_debug,设置为true ...不会抛出任何错误,但会为每个主题的本机侧边栏发出警告(没有id设置,这是4.1之前的事情)。据我所知,它不会影响任何事情。

  3. 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.

    我删除了底部的include,只是为了缩小问题在我的代码中的位置。我确定即使禁用了css enqueue,或者即使没有包含add_bottom_bar.php,主题的原生侧边栏仍然会中断。这使得我充分清楚地知道存在register_sidebar冲突。

  4. 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.

    我在插件激活时以及停用时查看了源代码。我找到差异源后,当插件被激活时,侧边栏没有显示在源代码中,所以它不是css / js的东西,据我所知。

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!

任何帮助将非常感激!谢谢!

1 个解决方案

#1


Ok. Figured it out.

好。弄清楚了。

add_action( 'widgets_init', 'bottom-widget' );

Needed to initialize the widget right after registering the sidebar.

注册边栏后需要立即初始化窗口小部件。

更多相关文章

  1. Ajax上传插件。handleError未找到
  2. 使用AJAX与拖放jQuery插件
  3. weiphp插件开发注意
  4. 如何将Composer中的CakePHP插件安装到app / Plugin中
  5. jQuery通过igorescobar jQuery掩码插件验证电话号码输入。
  6. 记12306货运系统“抢订空车”插件的编写--订车流程梳理
  7. 超全超实用的Javascript类库和jQuery插件大全之一:图片,地图和图形
  8. 高性能JavaScript代码高亮插件
  9. javascript-cropper插件翻译笔记

随机推荐

  1. golang sleep为什么没有返回值
  2. golang map判断key是否存在
  3. golang不能隐式转换吗
  4. golang select不阻塞吗
  5. golang main如何返回值
  6. golang不可重入函数实现
  7. golang rune几个字节
  8. golang grpc无法安装原因
  9. Golang中哪些值是不可以寻址的
  10. golang判断tcp是否断开的方法