How to manually add Shadowbox.setup() to the foote

2019-08-18 01:52发布

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.

4条回答
贼婆χ
2楼-- · 2019-08-18 02:12

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.

查看更多
smile是对你的礼貌
3楼-- · 2019-08-18 02:22

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(); 
}
查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-08-18 02:31

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!

查看更多
Deceive 欺骗
5楼-- · 2019-08-18 02:35

@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?

查看更多
登录 后发表回答