详情页

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>
相关文章
猜你需要