<?php
class fppopupcontent {
function __construct() {
require_once('inc/init.php');
if(isset($_POST['reset'])) {
add_action('admin_init',array($this,'fppopupcontentreset'));
}
}
function fppopupcontentadmin() {
add_submenu_page('options-general.php','Fantastic Popup Content', 'Fantastic Popup Content', 'manage_options','fppopupcontentadmin', 'fppopupcontentadmin_menu');
}
function fppopupcontentupdate() {
register_setting('fppopup','fppopupcontent');
register_setting('fppopup','fppopuptitle');
register_setting('fppopup','fppopupdays');
}
function fppopupcontentregister() {
add_option('fppopupdays',0);
}
function fppopupcontentreset() {
delete_option('fppopuptitle');
delete_option('fppopupcontent');
delete_option('fppopupdays');
add_option('fppopupdays','0');
fppopupcontent::fppopupcontentmail();
}
function fppopupcontentprocess() {
$plugin_dir = plugin_dir_url(__FILE__);
wp_enqueue_script('jquery');
wp_register_style('fp_style', $plugin_dir . 'css/home.css');
wp_enqueue_style('fp_style');
wp_register_script('fpquery_cookie', $plugin_dir . 'js/cookies.js');
wp_enqueue_script('fpquery_cookie');
}
function fppopupcntnt() {
if(is_home()) {
?>
<div id="fppop">
<div id="fp-close"></div>
<div id="fppopcnt">
<div id="fpclose" style="position:fixed;margin-left:-7px;"></div>
<div style="margin-left:50px">
<h1 style="font-size:24px"><?php echo get_option('fppopuptitle');?></h1>
<hr />
<?php $options=get_option('fppopupcontent'); ?>
<?php echo $options['textarea'] ; ?>
</div>
</div>
</div>
<?php
}
}
function fppopupprcss() {
?>
<script type="text/javascript">
jQuery(document)
.ready(function($){
if($.cookie('popup_user_login')!='yes'){
$('#fppop')
.delay(100)
.fadeIn('medium');
$('#fpclose, #fp-close')
.click(function(){
$('#fppop')
.stop()
.fadeOut('medium')
})
}
$.cookie(
'popup_user_login',
'yes',
{
path:'/',
expires:<?php echo (get_option('fppopupdays')); ?>
}
)
});
</script>
<?php
}
}
add_filter('wp_footer',array('fppopupcontent','fppopupcntnt'));
add_filter('wp_head', array('fppopupcontent','fppopupprcss'));
add_action('wp_enqueue_scripts',array('fppopupcontent','fppopupcontentprocess'));
//add_action('wp_print_styles',array('fppopupcontent','fppopupcontentprocess'));
add_action('admin_menu',array('fppopupcontent','fppopupcontentadmin'));
add_action('admin_init',array('fppopupcontent','fppopupcontentupdate'));
register_activation_hook(__FILE__,array('fppopupcontent','fppopupcontentregister'));
$new = new fppopupcontent();
?>
我创建了一个示例弹出插件。
在上面的代码中,它在 localhost 中运行良好。但是当我在实时站点中使用它时,它不起作用。
如果我使用 FireBug 查看,代码就会出现,但 CSS 设置为display:none
.
我尝试将 CSS 更改为display:block
,然后它会显示,但是当我单击关闭按钮时它不会关闭。
我不知道我做错了什么。如果有人可以就如何做到这一点给我建议,那就太好了。
以下是我用于弹出窗口的 css:
#fppop {
display: block;
background:color: #666;
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
z-index: 99999;
}
#fp-close {
width: 100%;
height: 100%
}
#fppopcnt {
background: white;
width: 600px;
height: 400px;
position: absolute;
top: 220px;
left: 630px;
-webkit-box-shadow: inset 0 0 50px 0 #939393;
-moz-box-shadow: inset 0 0 50px 0 #CCC;
box-shadow: inset 0 0 50px 0 #CCC;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
margin: -135px 0 0 -210px;
overflow: scroll;
}
#fpclose {
float: left;
cursor: pointer;
background: url(../images/fanclose.png) repeat;
height: 15px;
padding: 20px;
position: relative;
padding-right: 40px;
margin-top: -20px;
margin-right: -22px;
}