调用Colorbox/Lightbox以通过插件打开外部内容



我有一个插件,它成功地调用thickbox来打开外部内容的iframe。它使用以下代码:

function user_avatar_admin_print_styles() {
global $hook_suffix;
wp_enqueue_script("thickbox");
wp_enqueue_style("thickbox");
wp_enqueue_style('user-avatar', plugins_url('/user-avatar/css/user-avatar.css'),
'css');
}

<a id="user-avatar-link" class="button-primary thickbox" href="<?php echo 
admin_url('admin-ajax.php'); ?>?action=user_avatar_add_photo&step=1&uid=<?php echo 
$profile->ID; ?>&TB_iframe=true&width=720&height=450" title="<?php _e('Upload and 
Crop an Image to be Displayed','user-avatar'); ?>" ><?php _e('Update Picture',
'user-avatar'); ?></a> 

因此,重要的三个代码是wp_enque_scriptwp_enque_stylea类,它们都引用了thickbox。现在,Thickbox完全搅乱了我的网站,也没有很好地与我的其他插件交互。所以我决定选择colorbox。。。我只是简单地更改了引用"thickbox"的三个代码,并将它们更改为"colorbox"。这听起来很简单,但插件中没有其他引用thickbox的代码接受我列出的三个代码。将代码更改为"colorbox"无效。我还试着安装lightbox和lightboxplus,然后更改代码。。什么也没用。

这是一个类"按钮主thickbox"只适用于thickbox吗?它还有更多吗?我可以更改代码以使用colorbox、lightbox或其他类似的插件吗?任何帮助都将不胜感激。:)

快速更新:

我在thickbox中发现了这段与类有关的代码。我的插件调用thickbox使用代码

这是代码:函数add_thickbox_class_to_attachment_link($link){如果(thickbox_get_option(option_thickbox_ADD_CLASS)==false)return$link;

$use_smoothbox = thickbox_get_option(OPTION_THICKBOX_USE_SMOOTHBOX);
# Since SmoothBox doesn't come with WordPress we don't add the class here
if (use_wordpress_default_script_and_style() and $use_smoothbox == true)
return $link;
$class = $use_smoothbox == true ? 'smoothbox' : 'thickbox';
return str_replace('<a', '<a class="'.$class.'"', $link);
}
if (function_exists('add_filter'))
add_filter('wp_get_attachment_link', 'add_thickbox_class_to_attachment_link');

我还发现使用了一个带颜色框的类,但它不起作用。

我最终使用了插件"PrettyPhoto",并简单地添加了代码

rel="PrettyPhoto" 

而不是一个类来调用插件。

最新更新