wordpress游戏主题GameStudio幻灯片设置不起作用修复
时间:2023年07月30日
/来源:网络
/编辑:佚名
wordpress游戏主题GameStudio第一次启用主题的时候幻灯片正常,修改保存后设置不生效,一直为空;
调试代码
第一处:
if(file_exists(THEMATER_INCLUDES_DIR . '/featuredposts/template.php') ) {
$featuredposts_source = $this->theme->get_option('featuredposts_source');
var_dump($featuredposts_source);
打印的$featuredposts_source值一直为空,其实也就是获取的featuredposts_source为空。
第二处:
function featuredposts_source()
{
$get_featuredposts_source = $this->theme->get_option('featuredposts_source') ;
// $get_featuredposts_source = 'category' ;
// var_dump($get_featuredposts_source);
这里的$get_featuredposts_source也是为空,获取不了主题featuredposts_source参数的值。
完整原来的代码
function featuredposts_source()
{
$get_featuredposts_source = $this->theme->get_option('featuredposts_source');
$featuredposts_sources = array('custom'=> 'Custom Slides', 'category'=> 'Category Posts', 'posts' => 'Selected Posts', 'pages' => 'Selected Pages');
foreach($featuredposts_sources as $key=>$val) {
$featuredposts_sources_selected = $get_featuredposts_source == $key ? 'checked="checked"' : '';
?>
<div id="select_slide_source_<?php echo $key; ?>" class="tt_radio_button_container">
<input type="radio" name="featuredposts_source" value="<?php echo $key; ?>" <?php echo $featuredposts_sources_selected; ?> id="featuredposts_source_id_<?php echo $key; ?>" /> <a href="javascript:themater_featuredposts_source('<?php echo $key; ?>');" class="tt_radio_button"><?php echo $val; ?></a>
</div>
<?php
}
?>
<script type="text/javascript">
function themater_featuredposts_source(source)
{
$thematerjQ("#themater_featuredposts_custom").hide();
$thematerjQ("#select_slide_source_custom a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_custom").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_category").hide();
$thematerjQ("#select_slide_source_category a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_category").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_posts").hide();
$thematerjQ("#select_slide_source_posts a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_posts").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_pages").hide();
$thematerjQ("#select_slide_source_pages a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_pages").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_"+source+"").fadeIn();
$thematerjQ("#select_slide_source_"+source+" a").addClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_"+source+"").find(":radio").attr("checked","checked");
}
jQuery(document).ready(function(){
themater_featuredposts_source('<?php echo $get_featuredposts_source; ?>');
});
</script>
<?php
}
定位原因:主要原因就是js代码function themater_featuredposts_source(source)有问题,循环覆盖导致变量为空,获取不了表单name为featuredposts_source的值。
修改方法:
function featuredposts_source()
{
$get_featuredposts_source = $this->theme->get_option('featuredposts_source') ;
// $get_featuredposts_source = 'category' ;
// var_dump($get_featuredposts_source);
//dyz修改bug
?>
<div class="tt-form-element" >已选择:<div class="tt_radio_button tt_radio_button_current" ><?php echo $get_featuredposts_source; ?></div></div>
<?php
//dyz修改bug
$featuredposts_sources = array('custom'=> 'Custom Slides', 'category'=> 'Category Posts', 'posts' => 'Selected Posts', 'pages' => 'Selected Pages');
foreach($featuredposts_sources as $key=>$val) {
$featuredposts_sources_selected = $get_featuredposts_source == $key ? 'checked="checked"' : '';
?>
<div id="select_slide_source_<?php echo $key; ?>" class="tt_radio_button_container">
<input type="radio" name="featuredposts_source" value="<?php echo $key; ?>" <?php echo $featuredposts_sources_selected; ?> id="featuredposts_source_id_<?php echo $key; ?>" /> <a href="javascript:themater_featuredposts_source('<?php echo $key; ?>');" class="tt_radio_button"><?php echo $val; ?></a>
</div>
<?php
}
?>
<script type="text/javascript">
function themater_featuredposts_source(source)
{
if(source=='custom'){
$thematerjQ("#themater_featuredposts_category").hide();
$thematerjQ("#select_slide_source_category a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_category").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_posts").hide();
$thematerjQ("#select_slide_source_posts a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_posts").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_pages").hide();
$thematerjQ("#select_slide_source_pages a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_pages").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_"+source+"").fadeIn();
$thematerjQ("#select_slide_source_"+source+" a").addClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_"+source+"").find(":radio").attr("checked","checked");
}
if(source=='category'){
$thematerjQ("#themater_featuredposts_custom").hide();
$thematerjQ("#select_slide_source_custom a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_custom").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_posts").hide();
$thematerjQ("#select_slide_source_posts a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_posts").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_pages").hide();
$thematerjQ("#select_slide_source_pages a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_pages").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_"+source+"").fadeIn();
$thematerjQ("#select_slide_source_"+source+" a").addClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_"+source+"").find(":radio").attr("checked","checked");
}
if(source=='posts'){
$thematerjQ("#themater_featuredposts_custom").hide();
$thematerjQ("#select_slide_source_custom a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_custom").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_category").hide();
$thematerjQ("#select_slide_source_category a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_category").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_pages").hide();
$thematerjQ("#select_slide_source_pages a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_pages").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_"+source+"").fadeIn();
$thematerjQ("#select_slide_source_"+source+" a").addClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_"+source+"").find(":radio").attr("checked","checked");
}
if(source=='pages'){
$thematerjQ("#themater_featuredposts_custom").hide();
$thematerjQ("#select_slide_source_custom a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_custom").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_category").hide();
$thematerjQ("#select_slide_source_category a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_category").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_posts").hide();
$thematerjQ("#select_slide_source_posts a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_posts").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_"+source+"").fadeIn();
$thematerjQ("#select_slide_source_"+source+" a").addClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_"+source+"").find(":radio").attr("checked","checked");
}
}
function themater_featuredposts_source1(source)
{
$thematerjQ("#themater_featuredposts_"+source+"").fadeIn();
$thematerjQ("#select_slide_source_"+source+" a").addClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_"+source+"").find(":radio").attr("checked","checked");
}
jQuery(document).ready(function(){
themater_featuredposts_source1('<?php echo $get_featuredposts_source; ?>');
// themater_featuredposts_source('<?php echo $get_featuredposts_source; ?>');
});
</script>
调试代码
第一处:
if(file_exists(THEMATER_INCLUDES_DIR . '/featuredposts/template.php') ) {
$featuredposts_source = $this->theme->get_option('featuredposts_source');
var_dump($featuredposts_source);
打印的$featuredposts_source值一直为空,其实也就是获取的featuredposts_source为空。
第二处:
function featuredposts_source()
{
$get_featuredposts_source = $this->theme->get_option('featuredposts_source') ;
// $get_featuredposts_source = 'category' ;
// var_dump($get_featuredposts_source);
这里的$get_featuredposts_source也是为空,获取不了主题featuredposts_source参数的值。
完整原来的代码
function featuredposts_source()
{
$get_featuredposts_source = $this->theme->get_option('featuredposts_source');
$featuredposts_sources = array('custom'=> 'Custom Slides', 'category'=> 'Category Posts', 'posts' => 'Selected Posts', 'pages' => 'Selected Pages');
foreach($featuredposts_sources as $key=>$val) {
$featuredposts_sources_selected = $get_featuredposts_source == $key ? 'checked="checked"' : '';
?>
<div id="select_slide_source_<?php echo $key; ?>" class="tt_radio_button_container">
<input type="radio" name="featuredposts_source" value="<?php echo $key; ?>" <?php echo $featuredposts_sources_selected; ?> id="featuredposts_source_id_<?php echo $key; ?>" /> <a href="javascript:themater_featuredposts_source('<?php echo $key; ?>');" class="tt_radio_button"><?php echo $val; ?></a>
</div>
<?php
}
?>
<script type="text/javascript">
function themater_featuredposts_source(source)
{
$thematerjQ("#themater_featuredposts_custom").hide();
$thematerjQ("#select_slide_source_custom a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_custom").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_category").hide();
$thematerjQ("#select_slide_source_category a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_category").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_posts").hide();
$thematerjQ("#select_slide_source_posts a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_posts").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_pages").hide();
$thematerjQ("#select_slide_source_pages a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_pages").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_"+source+"").fadeIn();
$thematerjQ("#select_slide_source_"+source+" a").addClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_"+source+"").find(":radio").attr("checked","checked");
}
jQuery(document).ready(function(){
themater_featuredposts_source('<?php echo $get_featuredposts_source; ?>');
});
</script>
<?php
}
定位原因:主要原因就是js代码function themater_featuredposts_source(source)有问题,循环覆盖导致变量为空,获取不了表单name为featuredposts_source的值。
修改方法:
function featuredposts_source()
{
$get_featuredposts_source = $this->theme->get_option('featuredposts_source') ;
// $get_featuredposts_source = 'category' ;
// var_dump($get_featuredposts_source);
//dyz修改bug
?>
<div class="tt-form-element" >已选择:<div class="tt_radio_button tt_radio_button_current" ><?php echo $get_featuredposts_source; ?></div></div>
<?php
//dyz修改bug
$featuredposts_sources = array('custom'=> 'Custom Slides', 'category'=> 'Category Posts', 'posts' => 'Selected Posts', 'pages' => 'Selected Pages');
foreach($featuredposts_sources as $key=>$val) {
$featuredposts_sources_selected = $get_featuredposts_source == $key ? 'checked="checked"' : '';
?>
<div id="select_slide_source_<?php echo $key; ?>" class="tt_radio_button_container">
<input type="radio" name="featuredposts_source" value="<?php echo $key; ?>" <?php echo $featuredposts_sources_selected; ?> id="featuredposts_source_id_<?php echo $key; ?>" /> <a href="javascript:themater_featuredposts_source('<?php echo $key; ?>');" class="tt_radio_button"><?php echo $val; ?></a>
</div>
<?php
}
?>
<script type="text/javascript">
function themater_featuredposts_source(source)
{
if(source=='custom'){
$thematerjQ("#themater_featuredposts_category").hide();
$thematerjQ("#select_slide_source_category a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_category").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_posts").hide();
$thematerjQ("#select_slide_source_posts a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_posts").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_pages").hide();
$thematerjQ("#select_slide_source_pages a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_pages").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_"+source+"").fadeIn();
$thematerjQ("#select_slide_source_"+source+" a").addClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_"+source+"").find(":radio").attr("checked","checked");
}
if(source=='category'){
$thematerjQ("#themater_featuredposts_custom").hide();
$thematerjQ("#select_slide_source_custom a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_custom").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_posts").hide();
$thematerjQ("#select_slide_source_posts a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_posts").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_pages").hide();
$thematerjQ("#select_slide_source_pages a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_pages").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_"+source+"").fadeIn();
$thematerjQ("#select_slide_source_"+source+" a").addClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_"+source+"").find(":radio").attr("checked","checked");
}
if(source=='posts'){
$thematerjQ("#themater_featuredposts_custom").hide();
$thematerjQ("#select_slide_source_custom a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_custom").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_category").hide();
$thematerjQ("#select_slide_source_category a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_category").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_pages").hide();
$thematerjQ("#select_slide_source_pages a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_pages").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_"+source+"").fadeIn();
$thematerjQ("#select_slide_source_"+source+" a").addClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_"+source+"").find(":radio").attr("checked","checked");
}
if(source=='pages'){
$thematerjQ("#themater_featuredposts_custom").hide();
$thematerjQ("#select_slide_source_custom a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_custom").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_category").hide();
$thematerjQ("#select_slide_source_category a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_category").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_posts").hide();
$thematerjQ("#select_slide_source_posts a").removeClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_posts").find(":radio").removeAttr("checked");
$thematerjQ("#themater_featuredposts_"+source+"").fadeIn();
$thematerjQ("#select_slide_source_"+source+" a").addClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_"+source+"").find(":radio").attr("checked","checked");
}
}
function themater_featuredposts_source1(source)
{
$thematerjQ("#themater_featuredposts_"+source+"").fadeIn();
$thematerjQ("#select_slide_source_"+source+" a").addClass('tt_radio_button_current');
$thematerjQ("#select_slide_source_"+source+"").find(":radio").attr("checked","checked");
}
jQuery(document).ready(function(){
themater_featuredposts_source1('<?php echo $get_featuredposts_source; ?>');
// themater_featuredposts_source('<?php echo $get_featuredposts_source; ?>');
});
</script>
新闻资讯 更多
- 【wordpress教程】WordPress跟踪记录访客在网站的搜索词 优化网站内容和搜索体验03-31
- 【wordpress教程】Zibll子比主题的用户中心修改头像增加支持上传PNG图片文件03-31
- 【wordpress教程】wordpress报错429怎么办03-28
- 【wordpress教程】wordpress如何批量删除指定分类目录下的所有文章03-23
- 【wordpress教程】Wordpress 在文章内容的第二段后面插入广告03-03
- 【wordpress教程】WordPress纯代码禁止发表重复标题的文章03-03
- 【wordpress教程】给wordpress博客-VIEU主题评论框添加打字特效(其他主题类似)03-03
- 【wordpress教程】wordpress自动批量定时发布插件 DX-auto-publish02-08
热门文章
- 178Moban源码谈谈免费源码与收费源码的区别
- 2帝国CMS忘记后台登陆用户名、密码、认证码的解决方法
- 3帝国CMS(EmpireCMS) v7.5后台任意代码执行漏洞及具体修复方法
- 4帝国CMS和WordPress 哪个好?哪个适合建站?
- 5如何解决Discuz的密码错误次数过多请15分钟后登陆的问题
- 6帝国cms灵动标签取得内容和栏目链接地址
- 7emlog pro 注册码“开心”教程(如果有一天,emlog官方版 或者 emlog免费版 跑路了,那用户怎么办?)
- 8织梦CMS在nginx下设置伪静态方法(附nginx伪静态规则)
- 9帝国cms后台登录出现”您还未登录”怎么解决?
- 10帝国cms7.5忘记登录密码 和忘记登录认证码以及多次登录 失败被锁定解决办法