我在WP后端使用厚箱进行预览或其他内容。在后端中的页面上,我的脚本非常好,可以使用自定义宽度和厚箱的高度。在我的代码下方:

            <script type="text/javascript">
            <!--
                var viewportwidth;
                var viewportheight;

                if (typeof window.innerWidth != 'undefined') {
                    viewportwidth = window.innerWidth-80,
                    viewportheight = window.innerHeight-100
                } else if (typeof document.documentElement != 'undefined'
                    && typeof document.documentElement.clientWidth !=
                    'undefined' && document.documentElement.clientWidth != 0)
                {
                    viewportwidth = document.documentElement.clientWidth,
                    viewportheight = document.documentElement.clientHeight
                } else { // older versions of IE
                    viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
                    viewportheight = document.getElementsByTagName('body')[0].clientHeight
                }
                //document.write('<p class="textright">Your viewport width is '+viewportwidth+'x'+viewportheight+'</p>');
                document.write('<a onclick="return false;" href="<?php echo WP_PLUGIN_URL . '/' . FB_ADM_BASEDIR; ?>/inc/index.php?username=<?php echo DB_USER; ?>&?KeepThis=true&amp;TB_iframe=true&amp;height='+viewportheight+'&width='+viewportwidth+'" class="thickbox button"><?php _e( 'Start Adminer', FB_ADM_TEXTDOMAIN ); ?></a>');
                //-->
            </script>

现在解决我的问题和问题。我将在页面wp-admin/plugins.php的页面上使用一个厚的盒子,在这里不使用脚本。 WP始终将高度和宽度设置为核心价值,这对于我的要求很小。

也许其他读者有一个想法或解决方案。

非常感谢!

有帮助吗?

解决方案

plugins.php 页电话 add_thickbox() 引起WP本机厚箱脚本和样式的功能。它在文档中具有:

如果需要更改任何设置,则可以使用类似于Media-upload.js和theme-preview.js的另一个JS文件来完成此操作。该文件应需要数组(“厚框”)以确保其后加载。

因此,有不同的方法可以解决此问题:

  1. 如WP所建议的创建和队列.js文件,将添加您需要默认的设置。
  2. 完全注册或完全禁用本机厚箱,然后用自己的代码替换。

其他提示

前端或后端您可以通过设置设置厚箱的宽度和高度 GET 源URL的值。

厚箱JS代码将是这样的:

tb_show('Demo', '?action=show_demo&type=extended&width=900&height=800');

注意 widthheight 范围。当然,您将不得不加入 thickbox 脚本和样式之前。

笔记: 代码经过测试并在前端为我工作。它也应该在后端工作。如果它在后端不起作用,请告诉我。我将尝试修复代码

我在互联网上无处可读的解决方案:

tb_position是厚框函数,可对窗口大小进行奇怪的事情。您可以轻松,简单地将其过度过度,然后将其调用。

old_tb_position = tb_position;  
tb_position = function(){
    $("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px', height: TB_HEIGHT + 'px', marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});    
};

// Set-up inner size
tb_show("Window title,"<?= $the_url; ?>&width=600&height=350",      
tb_position = old_tb_position;
许可以下: CC-BY-SA归因
scroll top