如何手动将 Shadowbox.setup() 添加到主题的页脚?

发布于 2024-10-01 17:50:06 字数 489 浏览 7 评论 0原文

我有一个 Wordpress 网站,有两个版本,一种是全尺寸版本,另一种适用于移动浏览器。 我想关闭移动主题的 Shadowbox.JS 插件。 (我希望直接打开图像)

我在插件的高级设置中找到了一些东西。

跳过设置:true/false。
设置此 true 以在 Shadowbox.init() 期间跳过 Shadowbox.setup()。为了使用此插件,您必须手动将 Shadowbox.setup() 添加到主题的页脚。默认为 false。

如何手动将 Shadowbox.setup() 添加到主题的页脚?

这个想法是我将其添加到完整主题,Shadowbox 可以工作,但我不会将其添加到移动主题,链接将直接打开图像。

I have a Wordpress website with two versions, one full-sized and one for mobile browsers.
I want to shut down the Shadowbox.JS plugin for the mobile theme. (I want images to be opened directly)

I've found something in the Advanced settings of the plugin.

Skip setup: true/false.
Set this true to skip Shadowbox.setup() during Shadowbox.init(). For purposes of this plugin you will have to manually add Shadowbox.setup() to the footer of your theme. Defaults to false.

How do I manually add Shadowbox.setup() to the footer of my theme?

The idea is I will add it to the full theme, and Shadowbox will work, but I won't add it to the mobile theme, and links will open the images directly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

老娘不死你永远是小三 2024-10-08 17:50:06

听起来 Shadowbox.setup() 是由 Shadowbox-js 创建的自定义操作钩子。如果放置在页脚中,就像任何其他 WordPress 模板标签一样,它会触发插件来获取您在高级配置屏幕中设置的选项。

我建议将高级选项设置为 true (如“跳过设置”),并将模板标签放置在移动主题的页脚中。当移动主题页脚加载时,插件应该停用。不要将其放在完整主题中,插件将忽略高级设置,保持插件处于活动状态。

Sounds like Shadowbox.setup() is a custom action hook created by Shadowbox-js. If placed in your footer, like any other WordPress template tag, it triggers the plugin to get the option you set in the advanced configuration screen.

I recommend setting the advanced option to true (as in "skip the setup") , and placing the template tag in the footer of your mobile theme. When the mobile theme footer loads, the plugin should deactivate. Do not place it in your full theme, and the plugin will ignore the advanced setting, keeping the plugin active.

与之呼应 2024-10-08 17:50:06

您可以使用正则表达式来测试域名及其路径。

if( /mobile.example.com/.test(window.location) == false ) {
  Shadowbox.init(); 
}

// Or check the path for (example.com/mobile)
if( /example.com\/mobile/.test(window.location) == false ) {
  Shadowbox.init(); 
}

You can use regular expressions to test the domain name and its path.

if( /mobile.example.com/.test(window.location) == false ) {
  Shadowbox.init(); 
}

// Or check the path for (example.com/mobile)
if( /example.com\/mobile/.test(window.location) == false ) {
  Shadowbox.init(); 
}
心欲静而疯不止 2024-10-08 17:50:06

@kevtrout:Skip setup = true 意味着该插件不起作用。 False(默认)意味着它有效。

根据我收集的信息,它说我需要在页脚中放入 Shadowbox.setup() 模板标签才能使其再次工作,因为它丢失了。所以我必须将其包含在完整主题中,而不是移动主题中。

无论如何,我已经尝试了两种变体!问题是当我将“跳过设置”设置为 true 时,Shadowbox 不适用于这两个主题。我可能没有在页脚中插入代码!
我对此表示歉意,您能写出我应该使用的确切语法吗?

@kevtrout: Skip setup = true means the plugin doesn't work. False (default) means it works.

From what I gather, it says I need to put in that Shadowbox.setup() template tag in the footer in order to make it work again, because it's missing it. So I have to include it in the full theme, not the mobile theme.

I've tried both variants, anyway! The problem is when I set "Skip setup" to true Shadowbox doesn't work for either theme. I'm probably not inserting the code right in the footer!
I apoligise for that, could you please write the exact syntax I should be using?

似最初 2024-10-08 17:50:06

哦。抱歉打扰您,这可能是某种缓存问题,我不是很彻底。是的,确实:

高级设置>跳过设置 = true
完整主题的 footer.php

保持 Mobile 主题的 footer.php 不变。

它有效!

Oh. Sorry to bother you, it was probably some sort of cache issue, I wasn't very thorough. Yes, indeed:

Advanced settings > Skip setup = true
footer.php of Full theme

<script type="text/javascript">
Shadowbox.init();
Shadowbox.setup();
</script>

leave footer.php of Mobile theme unaltered.

And it works!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文