从 WP 管理栏打开厚盒式灯箱

发布于 2025-01-06 18:47:49 字数 1877 浏览 0 评论 0原文

各位,

我目前正在设置 WP 安装。为了让客户端访问自定义帮助文档,我通过以下 php 文件在管理栏中添加了一个额外的下拉菜单作为 WP 插件:

<?php

function pub_admin_bar_init() {
    if (!is_super_admin() || !is_admin_bar_showing() )
        return;

    add_action('admin_bar_menu', 'pub_admin_bar_links', 500);
}

add_action('admin_bar_init', 'pub_admin_bar_init');

function pub_admin_bar_links() {
    global $wp_admin_bar;

    $links = array(
        'Chapter 1' => 'http://manual.domain.com/index1.html',
        'Chapter 2' => 'http://manual.domain.com/index2.html',
        'Chapter 3' => 'http://manual.domain.com/index3.html',
        'Chapter 4' => 'http://manual.domain.com/index4.html',
        'Chapter ...' => 'http://manual.domain.com/index5.html',
    );

    $wp_admin_bar->add_menu( array(
        'title' => 'Help-Document',
        'href' => false,
        'id' => 'pub_links',
        'href' => false
    ));

    foreach ($links as $label => $url) {
        $wp_admin_bar->add_menu( array(
            'title' => $label,
            'href' => $url,
            'parent' => 'pub_links',
            'meta' => array('target' => '_blank')
        ));
    }
}

?>

下拉菜单工作正常,引用的 html 文件位于子域中在新选项卡中调用相同的域。

然而,为了让 WP 管理中的所有内容整齐排列,我想通过 iframe Lightbox 调用新管理栏下拉菜单中的菜单项。

我设法使用内置的thickbox在仪表板简介部分中进行了设置,语法如下:

<a style="text-decoration:none;" 
href="http://codex.wordpress.org/First_Steps_With_WordPress?
keepThis=true&TB_iframe=true&height=800&width=1200" class="thickbox" 
title="sometitle">First Steps with WordPress</a>

这让我可以将html帮助文件(或与此相关的任何其他url)作为厚盒样式覆盖中的iframe进行调用。

现在我的实际问题

有人可以告诉我如何在管理栏下拉列表中创建链接(“第 1 章”=>“http://manual.domain.com/index1.html”)吗? html', ...) 作为厚盒样式覆盖而不是 target=_blank?

非常感谢帮助。多谢!

Folks,

I'm currently setting up a WP install. In order for the client to access a custom help-document, I added an additional dropdown menu in the admin-bar as a WP plugin via the following php-file:

<?php

function pub_admin_bar_init() {
    if (!is_super_admin() || !is_admin_bar_showing() )
        return;

    add_action('admin_bar_menu', 'pub_admin_bar_links', 500);
}

add_action('admin_bar_init', 'pub_admin_bar_init');

function pub_admin_bar_links() {
    global $wp_admin_bar;

    $links = array(
        'Chapter 1' => 'http://manual.domain.com/index1.html',
        'Chapter 2' => 'http://manual.domain.com/index2.html',
        'Chapter 3' => 'http://manual.domain.com/index3.html',
        'Chapter 4' => 'http://manual.domain.com/index4.html',
        'Chapter ...' => 'http://manual.domain.com/index5.html',
    );

    $wp_admin_bar->add_menu( array(
        'title' => 'Help-Document',
        'href' => false,
        'id' => 'pub_links',
        'href' => false
    ));

    foreach ($links as $label => $url) {
        $wp_admin_bar->add_menu( array(
            'title' => $label,
            'href' => $url,
            'parent' => 'pub_links',
            'meta' => array('target' => '_blank')
        ));
    }
}

?>

The dropdown works fine and the referenced html-files located in the subdomain of the same domain get called in a new tab.

However, in order to have everything neatly arranged within the WP admin, I'd like to call the menu items in the new admin-bar dropdown via an iframe Lightbox.

I managed to set this up in the Dashboard intro section using the built-in thickbox with the following syntax:

<a style="text-decoration:none;" 
href="http://codex.wordpress.org/First_Steps_With_WordPress?
keepThis=true&TB_iframe=true&height=800&width=1200" class="thickbox" 
title="sometitle">First Steps with WordPress</a>

This lets me call the html help-files (or any other url for that matter) as an iframe in a thickbox-style overlay.

Now my actual question:

Could someone point me to how I could make the links in the admin-bar dropdown ('Chapter 1' => 'http://manual.domain.com/index1.html', ...) as thickbox-style overlays instead of target=_blank?

Help very much appreciated. Thanks a lot!

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

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

发布评论

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

评论(1

香橙ぽ 2025-01-13 18:47:50

'元' => array('target' => '_blank'),

你忘记了“,

'meta' => array('target' => '_blank'),

You forget of ","

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