2

我正在为朋友的业务做一些编辑工作,而 wordpress 模板是以非常古老的方式编写的。我已经弄清楚了大部分代码是如何工作的,但是让我感到困惑的一件事是文件引用了 css 信息的地方,它没有以任何通常的方式导入它,也没有使用主要的 wordpress主题 css 文件。我也无法在萤火虫中找到资源。谁能帮我理解这段代码是如何工作的?我特别想访问 singleStyle div 的 css 信息

网址: http ://wp.rafelshearling.com/?page_id=319

代码:

<?php
/**
 * The template used for displaying page content in page.php
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 * @since Twenty Eleven 1.0
<?php the_ID(); ?> 
post_class();

 */
?>
    <h1 class="entry-title"><?php the_title(); ?></h1>

    <div class="entry-content">
        <?php if(is_page( array( 319, 321 ) ) ) { ?>


            <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

            <?php if(is_page( 319 ) ) { // Mens ?>

                <script>
                var pageNum = 1;
                var catIndex = 0;
                var pageMax, catSlugList = ["jackets"];
                var originalCat = catSlugList[catIndex];
                var originalCatID = 9;


                $(function() {
                    $.ajax({
                        url: '/?json=get_category_posts&slug='+originalCat+'&count=12&page='+pageNum+'&exclude=categories,type,url,title_plain,status,excerpt,comments,comment_count,comment_status,tags,attachments,modified,date,author',
                        success: function(data) {
                            pageMax = data.pages;
                            var $collectionDiv = $("#styleCollectionDiv").children("div:eq(1)");
                            var $showLargerDiv = $("#viewLargerDiv");
                            for(var i in data.posts){
                                $collectionDiv.append("<div class='singleStyle'>"+data.posts[i].content+"<p>"+data.posts[i].title+"</p></div>");
                            }
                            $showLargerDiv.append($collectionDiv.children("div:eq(0)").clone());

                            $("#stylesDiv .singleStyle").mouseenter( function(e){
                                $("#viewLargerDiv").empty().append($(this).clone());
                            });


                            $(".childrenUls a").removeClass("active");
                            $(".childrenUls a:eq("+catIndex+")").addClass("active");
                        }
                    });


                    $(".childrenUls a").click( function(e){
                        return false;
                    });

                    $("#collectionNav p a").click( function(e){
                        if(this.getAttribute("href") === "#Back"){
                            if(pageNum === 1){

                                return false;
                            } else {
                                pageNum--;

                                $.ajax({
                                    url: '/?json=get_category_posts&slug='+originalCat+'&count=12&page='+pageNum+'&exclude=categories,type,url,title_plain,status,excerpt,comments,comment_count,comment_status,tags,attachments,modified,date,author',
                                    success: function(data) {
                                        $("#stylesDiv, #viewLargerDiv").empty();
                                        pageMax = data.pages;
                                        var $collectionDiv = $("#styleCollectionDiv").children("div:eq(1)");
                                        var $showLargerDiv = $("#viewLargerDiv");
                                        for(var i in data.posts){
                                            $collectionDiv.append("<div class='singleStyle'>"+data.posts[i].content+"<p>"+data.posts[i].title+"</p></div>");
                                        }
                                        $showLargerDiv.append($collectionDiv.children("div:eq(0)").clone());

                                        $("#stylesDiv .singleStyle").mouseenter( function(e){
                                            $("#viewLargerDiv").empty().append($(this).clone());
                                        });

                                        $(".childrenUls a").removeClass("active");
                                        $(".childrenUls a:eq("+catIndex+")").addClass("active");
                                    }
                                });

                            }
                        } else if(this.getAttribute("href") === "#More"){
                            if(pageNum < pageMax){
                                pageNum++;
                                $.ajax({
                                    url: '/?json=get_category_posts&slug='+originalCat+'&count=12&page='+pageNum+'&exclude=categories,type,url,title_plain,status,excerpt,comments,comment_count,comment_status,tags,attachments,modified,date,author',
                                    success: function(data) {
                                        $("#stylesDiv, #viewLargerDiv").empty();
                                        pageMax = data.pages;
                                        var $collectionDiv = $("#styleCollectionDiv").children("div:eq(1)");
                                        var $showLargerDiv = $("#viewLargerDiv");
                                        for(var i in data.posts){
                                            $collectionDiv.append("<div class='singleStyle'>"+data.posts[i].content+"<p>"+data.posts[i].title+"</p></div>");
                                        }
                                        $showLargerDiv.append($collectionDiv.children("div:eq(0)").clone());

                                        $("#stylesDiv .singleStyle").mouseenter( function(e){
                                            $("#viewLargerDiv").empty().append($(this).clone());
                                        });

                                        $(".childrenUls a").removeClass("active");
                                        $(".childrenUls a:eq("+catIndex+")").addClass("active");
                                    }
                                });
                            } else {
                                return false
                            }
                        }
                        return false;
                    });
                });
                </script>

                <ul class="childrenUls cMe">
                    <?php wp_list_categories('child_of=5&orderby=id&order=DESC&title_li='); ?>
                </ul>

            <?php } else if(is_page( 321 ) ) { // Womens ?>

                <script>
                var pageNum = 1;
                var catIndex = 0;
                var pageMax, catSlugList = ["jackets-vests-assessories","hip-34-length","full-length"];
                var originalCat = catSlugList[catIndex];
                var originalCatID = 8;
                $(function() {
                    $.ajax({
                        url: '/?json=get_category_posts&slug='+originalCat+'&count=12&page='+pageNum+'&exclude=categories,type,url,title_plain,status,excerpt,comments,comment_count,comment_status,tags,attachments,modified,date,author',
                        success: function(data) {
                            pageMax = data.pages;
                            var $collectionDiv = $("#styleCollectionDiv").children("div:eq(1)");
                            var $showLargerDiv = $("#viewLargerDiv");
                            for(var i in data.posts){
                                $collectionDiv.append("<div class='singleStyle'>"+data.posts[i].content+"<p>"+data.posts[i].title+"</p></div>");
                            }
                            $showLargerDiv.append($collectionDiv.children("div:eq(0)").clone());

                            $("#stylesDiv .singleStyle").mouseenter( function(e){
                                $("#viewLargerDiv").empty().append($(this).clone());
                            });

                            $(".childrenUls a").removeClass("active");
                            $(".childrenUls a:eq("+catIndex+")").addClass("active");

                        }
                    });

                    $(".childrenUls a").click( function(e){
                        catIndex = $(".childrenUls a").index(this);
                        pageNum = 1;
                        $.ajax({
                            url: '/?json=get_category_posts&slug='+catSlugList[catIndex]+'&count=12&page='+pageNum+'&exclude=categories,type,url,title_plain,status,excerpt,comments,comment_count,comment_status,tags,attachments,modified,date,author',
                            success: function(data) {
                                $("#stylesDiv, #viewLargerDiv").empty();
                                pageMax = data.pages;
                                var $collectionDiv = $("#styleCollectionDiv").children("div:eq(1)");
                                var $showLargerDiv = $("#viewLargerDiv");
                                for(var i in data.posts){
                                    $collectionDiv.append("<div class='singleStyle'>"+data.posts[i].content+"<p>"+data.posts[i].title+"</p></div>");
                                }
                                $showLargerDiv.append($collectionDiv.children("div:eq(0)").clone());

                                $("#stylesDiv .singleStyle").mouseenter( function(e){
                                    $("#viewLargerDiv").empty().append($(this).clone());
                                });

                                $(".childrenUls a").removeClass("active");
                                $(".childrenUls a:eq("+catIndex+")").addClass("active");

                            }
                        });

                        return false;
                    });

                    $("#collectionNav p a").click( function(e){
                        if(this.getAttribute("href") === "#Back"){
                            if(pageNum===1){
                                if(catIndex === 0){
                                    return
                                } else {
                                    pageNum = 1;
                                    catIndex--;
                                    originalCat = catSlugList[catIndex];

                                    $.ajax({
                                        url: '/?json=get_category_posts&slug='+originalCat+'&count=12&page='+pageNum+'&exclude=categories,type,url,title_plain,status,excerpt,comments,comment_count,comment_status,tags,attachments,modified,date,author',
                                        success: function(data) {
                                            $("#stylesDiv, #viewLargerDiv").empty();
                                            pageMax = data.pages;
                                            var $collectionDiv = $("#styleCollectionDiv").children("div:eq(1)");
                                            var $showLargerDiv = $("#viewLargerDiv");
                                            for(var i in data.posts){
                                                $collectionDiv.append("<div class='singleStyle'>"+data.posts[i].content+"<p>"+data.posts[i].title+"</p></div>");
                                            }
                                            $showLargerDiv.append($collectionDiv.children("div:eq(0)").clone());

                                            $("#stylesDiv .singleStyle").mouseenter( function(e){
                                                $("#viewLargerDiv").empty().append($(this).clone());
                                            });

                                            $(".childrenUls a").removeClass("active");
                                            $(".childrenUls a:eq("+catIndex+")").addClass("active");

                                        }
                                    });

                                }
                            } else {
                                pageNum--;

                                $.ajax({
                                    url: '/?json=get_category_posts&slug='+originalCat+'&count=12&page='+pageNum+'&exclude=categories,type,url,title_plain,status,excerpt,comments,comment_count,comment_status,tags,attachments,modified,date,author',
                                    success: function(data) {
                                        $("#stylesDiv, #viewLargerDiv").empty();
                                        pageMax = data.pages;
                                        var $collectionDiv = $("#styleCollectionDiv").children("div:eq(1)");
                                        var $showLargerDiv = $("#viewLargerDiv");
                                        for(var i in data.posts){
                                            $collectionDiv.append("<div class='singleStyle'>"+data.posts[i].content+"<p>"+data.posts[i].title+"</p></div>");
                                        }
                                        $showLargerDiv.append($collectionDiv.children("div:eq(0)").clone());

                                        $("#stylesDiv .singleStyle").mouseenter( function(e){
                                            $("#viewLargerDiv").empty().append($(this).clone());
                                        });

                                        $(".childrenUls a").removeClass("active");
                                        $(".childrenUls a:eq("+catIndex+")").addClass("active");
                                    }
                                });

                            }
                        } else if(this.getAttribute("href") === "#More"){
                            if(pageNum===pageMax){
                                if(catSlugList.length-1 === catIndex){
                                    return
                                } else {
                                    pageNum = 1;
                                    catIndex++;
                                    originalCat = catSlugList[catIndex];

                                    $.ajax({
                                        url: '/?json=get_category_posts&slug='+originalCat+'&count=12&page='+pageNum+'&exclude=categories,type,url,title_plain,status,excerpt,comments,comment_count,comment_status,tags,attachments,modified,date,author',
                                        success: function(data) {
                                            $("#stylesDiv, #viewLargerDiv").empty();
                                            pageMax = data.pages;
                                            var $collectionDiv = $("#styleCollectionDiv").children("div:eq(1)");
                                            var $showLargerDiv = $("#viewLargerDiv");
                                            for(var i in data.posts){
                                                $collectionDiv.append("<div class='singleStyle'>"+data.posts[i].content+"<p>"+data.posts[i].title+"</p></div>");
                                            }
                                            $showLargerDiv.append($collectionDiv.children("div:eq(0)").clone());

                                            $("#stylesDiv .singleStyle").mouseenter( function(e){
                                                $("#viewLargerDiv").empty().append($(this).clone());
                                            });

                                            $(".childrenUls a").removeClass("active");
                                            $(".childrenUls a:eq("+catIndex+")").addClass("active");
                                        }
                                    });

                                }
                            } else if(pageNum < pageMax){
                                pageNum++;
                                $.ajax({
                                    url: '/?json=get_category_posts&slug='+originalCat+'&count=12&page='+pageNum+'&exclude=categories,type,url,title_plain,status,excerpt,comments,comment_count,comment_status,tags,attachments,modified,date,author',
                                    success: function(data) {
                                        $("#stylesDiv, #viewLargerDiv").empty();
                                        pageMax = data.pages;
                                        var $collectionDiv = $("#styleCollectionDiv").children("div:eq(1)");
                                        var $showLargerDiv = $("#viewLargerDiv");
                                        for(var i in data.posts){
                                            $collectionDiv.append("<div class='singleStyle'>"+data.posts[i].content+"<p>"+data.posts[i].title+"</p></div>");
                                        }
                                        $showLargerDiv.append($collectionDiv.children("div:eq(0)").clone());

                                        $("#stylesDiv .singleStyle").mouseenter( function(e){
                                            $("#viewLargerDiv").empty().append($(this).clone());
                                        });

                                        $(".childrenUls a").removeClass("active");
                                        $(".childrenUls a:eq("+catIndex+")").addClass("active");
                                    }
                                });
                            } else {
                                return false
                            }
                        }
                        return false;
                    });
                });
                </script>

                <ul class="childrenUls">
                    <?php wp_list_categories('child_of=4&orderby=id&order=DESC&title_li='); ?>
                </ul>
            <?php } ?>

            <br style="clear:both;" />

            <div id="largeViewDiv">
                <div><p>Place mouse over thumbnails to view larger.</p></div>
                <div id="viewLargerDiv"></div>
            </div>
            <div id="styleCollectionDiv">
                <div id="collectionNav"><p class="cMe"><a class="backButton" href="#Back">< Back</a><a class="moreButton" href="#More">More ></a></p></div>
                <div id="stylesDiv"></div>
            </div>
            <br style="clear:both;" />

        <?php } else { ?>
            <?php the_content(); ?>
            <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentyeleven' ) . '</span>', 'after' => '</div>' ) ); ?>
        <?php } ?>
    </div><!-- .entry-content -->

    <?php edit_post_link( __( 'Edit', 'twentyeleven' ), '<br><br><br><span class="edit-link">', '</span>' ); ?>
4

1 回答 1

1

大多数 Wordpress 模板的 CSS 位于 wp-content>themes>theme_name 文件夹中,它几乎总是被称为 style.css

如果我没记错的话,CSS 也在主题主文件夹的 header.php 中被引用。

于 2012-11-15T02:08:48.303 回答