Example #1
0
function wpss_gen()
{
    ob_start();
    // start output caching (so that existing content in the [simple-sitemap] post doesn't get shoved to the bottom of the post
    global $post;
    //wordpress post global object
    $permalink_structure = get_option('permalink_structure');
    if ($permalink_structure == null) {
        $link_url = get_permalink($post->ID);
        $query_symbol = '&';
        // add a '&' character prefix onto the query string
    } else {
        if (substr($permalink_structure, -1) != '/') {
            $link_url = get_permalink($post->ID) . '/';
            $query_symbol = '?';
            // add a '?' character prefix onto the query string
        } else {
            $link_url = get_permalink($post->ID);
            $query_symbol = '?';
            // add a '?' character prefix onto the query string
        }
    }
    // sort by value in drop down box (make sure drop down default is title which is the default used by wp_list_pages)
    $page_params = page_params();
    $post_params = post_params();
    $opt = get_option('wpss_options');
    //echo '$opt[\'drp_pages_default\'] = '.$opt['drp_pages_default'].'<br />';
    //echo '$opt[\'drp_posts_default\'] = '.$opt['drp_posts_default'].'<br />';
    if ($page_params == null) {
        if ($opt['drp_pages_default'] == "post_title") {
            $page_params = 'menu_order, post_title';
        } else {
            if ($opt['drp_pages_default'] == "post_date") {
                $page_params = 'post_date';
            } else {
                $page_params = 'post_author';
            }
        }
    }
    $page_args = array('sort_column' => $page_params, 'title_li' => '');
    if ($post_params == null) {
        if ($opt['drp_posts_default'] == "title") {
            $post_params = 'title';
        } else {
            if ($opt['drp_posts_default'] == "date") {
                $post_params = 'date';
            } else {
                if ($opt['drp_posts_default'] == "author") {
                    $post_params = 'author';
                } else {
                    if ($opt['drp_posts_default'] == "category") {
                        $post_params = 'category';
                    } else {
                        $post_params = 'tags';
                    }
                }
            }
        }
    }
    $post_args = array('orderby' => $post_params, 'posts_per_page' => -1, 'order' => 'asc');
    //echo "<br />Page Args: <br />";
    //print_r($page_args);
    //echo "<br /><br />Posts Args: <br />";
    //print_r($post_args);
    //echo "<br /><br />Page Params: $page_params";
    //echo "<br />Post Params: $post_params";
    // Initialise to "" to prevent undefined variable error
    $pt1 = $pd1 = $pa1 = $pt2 = $pd2 = $pa2 = $pc2 = $ptg2 = "";
    // page drop down box
    if ($page_params == 'menu_order, post_title') {
        $pt1 = "selected='selected'";
    } else {
        if ($page_params == 'post_date') {
            $pd1 = "selected='selected'";
        } else {
            if ($page_params == 'post_author') {
                $pa1 = "selected='selected'";
            }
        }
    }
    // post drop down box
    if ($post_params == 'title') {
        $pt2 = "selected='selected'";
    } else {
        if ($post_params == 'date') {
            $pd2 = "selected='selected'";
        } else {
            if ($post_params == 'author') {
                $pa2 = "selected='selected'";
            } else {
                if ($post_params == 'category') {
                    $pc2 = "selected='selected'";
                } else {
                    if ($post_params == 'tags') {
                        $ptg2 = "selected='selected'";
                    }
                }
            }
        }
    }
    ?>
<div class="ss_wrapper">
		<?php 
    $opt = get_option('wpss_options');
    if ($opt['rdo_display_order'] == "pages_left") {
        $pages_float = "float:left;";
    } else {
        $pages_float = "float:right;";
    }
    ?>
		<?php 
    $opt = get_option('wpss_options');
    if ($opt['rdo_display_order'] == "pages_left") {
        $posts_float = "float:left;";
    } else {
        $posts_float = "float:left;";
    }
    ?>
		<div id="ss_posts" style="<?php 
    echo $posts_float;
    ?>
">
			<h2 class='post_heading'>Posts</h2>
			<div id="post_drop_down">
				<form name="post_drop_form" id="post_drop_form">
					<span id="post_dd_label">Show posts by:</span>
					<select name="post_drop_select" OnChange="location.href=post_drop_form.post_drop_select.options[selectedIndex].value">
						<option value="<?php 
    echo $link_url . $query_symbol . 'postsort=title';
    ?>
" <?php 
    echo $pt2;
    ?>
>Title</option>
						<option value="<?php 
    echo $link_url . $query_symbol . 'postsort=date';
    ?>
" <?php 
    echo $pd2;
    ?>
>Date</option>
						<option value="<?php 
    echo $link_url . $query_symbol . 'postsort=author';
    ?>
" <?php 
    echo $pa2;
    ?>
>Author</option>
						<option value="<?php 
    echo $link_url . $query_symbol . 'postsort=category';
    ?>
" <?php 
    echo $pc2;
    ?>
>Category</option>
						<option value="<?php 
    echo $link_url . $query_symbol . 'postsort=tags';
    ?>
" <?php 
    echo $ptg2;
    ?>
>Tags</option>	
					</select>
				</form>
			</div>
			<?php 
    if (strpos($post_params, 'category') !== false) {
        $categories = get_categories();
        foreach ($categories as $category) {
            $category_link = get_category_link($category->term_id);
            $cat_count = $category->category_count;
            echo '<div class="ss_cat_header"><a href="' . $category_link . '">' . ucwords($category->cat_name) . '</a> ';
            query_posts('post_status=publish&cat=' . $category->term_id);
            // show the sorted posts
            ?>
					<?php 
            global $wp_query;
            echo '(' . $wp_query->post_count . ')</div>';
            ?>
					<?php 
            if (have_posts()) {
                echo '<div class="post_item_list"><ul class="post_item_list">';
                while (have_posts()) {
                    the_post();
                    ?>
							<li class="post_item">
								<a href="<?php 
                    the_permalink();
                    ?>
" rel="bookmark" title="Permanent Link to <?php 
                    the_title_attribute();
                    ?>
"><?php 
                    the_title();
                    ?>
</a>
							</li>
						<?php 
                }
                echo '</ul></div>';
            }
            wp_reset_query();
        }
    } else {
        if (strpos($post_params, 'author') !== false) {
            $authors = get_users();
            //gets registered users
            foreach ($authors as $author) {
                echo '<a href="' . get_author_posts_url($author->ID) . '">' . $author->display_name . '</a> ';
                query_posts('post_status=publish&author=' . $author->ID);
                // show the sorted posts
                ?>
					<?php 
                global $wp_query;
                echo '(' . $wp_query->post_count . ')';
                ?>
					<?php 
                if (have_posts()) {
                    echo '<div class="post_item_list"><ul class="post_item_list">';
                    while (have_posts()) {
                        the_post();
                        ?>
							<li class="post_item">
								<a href="<?php 
                        the_permalink();
                        ?>
" rel="bookmark" title="Permanent Link to <?php 
                        the_title_attribute();
                        ?>
"><?php 
                        the_title();
                        ?>
</a>
							</li>
						<?php 
                    }
                    echo '</ul></div>';
                }
                wp_reset_query();
            }
        } else {
            if (strpos($post_params, 'tags') !== false) {
                $post_tags = get_tags();
                echo '<div class="ss_tag_header">';
                foreach ($post_tags as $tag) {
                    $tag_link = get_tag_link($tag->term_id);
                    echo "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
                    echo "{$tag->name}</a> ({$tag->count})";
                    query_posts('post_status=publish&tag=' . $tag->slug);
                    // show posts
                    ?>
					<?php 
                    if (have_posts()) {
                        echo '<div class="post_item_list"><ul class="post_item_list">';
                        while (have_posts()) {
                            the_post();
                            ?>
							<li class="post_item">
								<a href="<?php 
                            the_permalink();
                            ?>
" rel="bookmark" title="Permanent Link to <?php 
                            the_title_attribute();
                            ?>
"><?php 
                            the_title();
                            ?>
</a>
							</li>
						<?php 
                        }
                        echo '</ul></div>';
                    }
                    wp_reset_query();
                }
                echo '</div>';
            } else {
                if (strpos($post_params, 'date') !== false) {
                    ?>
<div class="ss_date_header">
				<?php 
                    global $wpdb;
                    $months = $wpdb->get_results("SELECT DISTINCT MONTH(post_date) AS month , YEAR(post_date) AS year FROM {$wpdb->posts} WHERE post_status = 'publish' and post_date <= now( ) and post_type = 'post' GROUP BY month, year ORDER BY post_date DESC");
                    foreach ($months as $curr_month) {
                        query_posts('post_status=publish&monthnum=' . $curr_month->month . '&year=' . $curr_month->year);
                        // show posts
                        ?>
					<?php 
                        global $wp_query;
                        echo "<a href=\"";
                        echo get_month_link($curr_month->year, $curr_month->month);
                        echo '">' . date('F', mktime(0, 0, 0, $curr_month->month)) . ' ' . $curr_month->year . '</a> (' . $wp_query->post_count . ')';
                        ?>
					<?php 
                        if (have_posts()) {
                            echo '<div class="post_item_list"><ul class="post_item_list">';
                            while (have_posts()) {
                                the_post();
                                ?>
							<li class="post_item">
								<a href="<?php 
                                the_permalink();
                                ?>
" rel="bookmark" title="Permanent Link to <?php 
                                the_title_attribute();
                                ?>
"><?php 
                                the_title();
                                ?>
</a>
							</li>
						<?php 
                            }
                            echo '</ul></div>';
                        }
                        wp_reset_query();
                    }
                    ?>
				</div>
			<?php 
                } else {
                    // default = title
                    ?>
				<?php 
                    query_posts($post_args);
                    // show the sorted posts
                    if (have_posts()) {
                        echo '<ul class="post_item_list">';
                        while (have_posts()) {
                            the_post();
                            $sticky = "";
                            if (is_sticky(get_the_ID())) {
                                $sticky = " (sticky post)";
                            }
                            ?>
							<li class="post_item">
								<a href="<?php 
                            the_permalink();
                            ?>
" rel="bookmark" title="Permanent Link to <?php 
                            the_title_attribute();
                            ?>
"><?php 
                            the_title();
                            ?>
</a>
								<?php 
                            if ($sticky == ' (sticky post)') {
                                ?>
									<span class="ss_sticky"><?php 
                                echo $sticky;
                                ?>
</span>
								<?php 
                            }
                            ?>
							</li>
						<?php 
                        }
                        echo '</ul>';
                    }
                    wp_reset_query();
                }
            }
        }
    }
    ?>
		</div><!--ss_posts-->
</div>
<?php 
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Example #2
0
function wpss_gen()
{
    ob_start();
    // start output caching (so that existing content in the [simple-sitemap] post doesn't get shoved to the bottom of the post
    global $post;
    //wordpress post global object
    $permalink_structure = get_option('permalink_structure');
    if ($permalink_structure == null) {
        $link_url = get_permalink($post->ID);
        $query_symbol = '&';
        // add a '&' character prefix onto the query string
    } else {
        if (substr($permalink_structure, -1) != '/') {
            $link_url = get_permalink($post->ID) . '/';
            $query_symbol = '?';
            // add a '?' character prefix onto the query string
        } else {
            $link_url = get_permalink($post->ID);
            $query_symbol = '?';
            // add a '?' character prefix onto the query string
        }
    }
    /* Sort by value in drop down box (make sure drop down default is title which is the default used by wp_list_pages). */
    $page_params = page_params();
    $post_params = post_params();
    $opt = get_option('wpss_options');
    //echo '$opt[\'drp_pages_default\'] = '.$opt['drp_pages_default'].'<br />';
    //echo '$opt[\'drp_posts_default\'] = '.$opt['drp_posts_default'].'<br />';
    if ($page_params == null) {
        if ($opt['drp_pages_default'] == "post_title") {
            $page_params = 'menu_order, post_title';
        } else {
            if ($opt['drp_pages_default'] == "post_date") {
                $page_params = 'post_date';
            } else {
                $page_params = 'post_author';
            }
        }
    }
    $page_args = array('sort_column' => $page_params, 'title_li' => '');
    if (!empty($opt['txt_page_ids'])) {
        $page_args['exclude'] = $opt['txt_page_ids'];
    }
    if ($post_params == null) {
        if ($opt['drp_posts_default'] == "title") {
            $post_params = 'title';
        } else {
            if ($opt['drp_posts_default'] == "date") {
                $post_params = 'date';
            } else {
                if ($opt['drp_posts_default'] == "author") {
                    $post_params = 'author';
                } else {
                    if ($opt['drp_posts_default'] == "category") {
                        $post_params = 'category';
                    } else {
                        $post_params = 'tags';
                    }
                }
            }
        }
    }
    $post_args = array('orderby' => $post_params, 'posts_per_page' => -1, 'order' => 'asc');
    //echo "<br />Page Args: <br />";
    //print_r($page_args);
    //echo "<br /><br />Posts Args: <br />";
    //print_r($post_args);
    //echo "<br /><br />Page Params: $page_params";
    //echo "<br />Post Params: $post_params";
    /* Initialise to "" to prevent undefined variable error. */
    $pt1 = $pd1 = $pa1 = $pt2 = $pd2 = $pa2 = $pc2 = $ptg2 = "";
    /* Page drop down box. */
    if ($page_params == 'menu_order, post_title') {
        $pt1 = "selected='selected'";
    } else {
        if ($page_params == 'post_date') {
            $pd1 = "selected='selected'";
        } else {
            if ($page_params == 'post_author') {
                $pa1 = "selected='selected'";
            }
        }
    }
    /* Post drop down box. */
    if ($post_params == 'title') {
        $pt2 = "selected='selected'";
    } else {
        if ($post_params == 'date') {
            $pd2 = "selected='selected'";
        } else {
            if ($post_params == 'author') {
                $pa2 = "selected='selected'";
            } else {
                if ($post_params == 'category') {
                    $pc2 = "selected='selected'";
                } else {
                    if ($post_params == 'tags') {
                        $ptg2 = "selected='selected'";
                    }
                }
            }
        }
    }
    ?>
<div class="ss_wrapper">
		<?php 
    $opt = get_option('wpss_options');
    if ($opt['rdo_display_order'] == "pages_left") {
        $pages_float = "float:left;";
    } else {
        $pages_float = "float:right;";
    }
    ?>
		<div id="ss_pages" style="<?php 
    echo $pages_float;
    ?>
">
			<h2 class='page_heading'>Pages</h2>
			
			<div id="page_drop_down">
				<form name="page_drop_form" id="page_drop_form">
					<span id="page_dd_label">Show pages by:</span>
					<select name="page_drop_select" OnChange="location.href=page_drop_form.page_drop_select.options[selectedIndex].value">
						<option value="<?php 
    echo $link_url . $query_symbol . 'pagesort=post_title';
    ?>
" <?php 
    echo $pt1;
    ?>
>Title</option>
						<option value="<?php 
    echo $link_url . $query_symbol . 'pagesort=post_date';
    ?>
" <?php 
    echo $pd1;
    ?>
>Date</option>
						<option value="<?php 
    echo $link_url . $query_symbol . 'pagesort=post_author';
    ?>
" <?php 
    echo $pa1;
    ?>
>Author</option>
					</select>
				</form>
			</div>
			<?php 
    if (strpos($page_params, 'post_date') !== false) {
        echo '<ul class="page_item_list">';
        $page_args = array('sort_order' => 'desc', 'sort_column' => 'post_date', 'date_format' => ' (m.d.y)', 'show_date' => 'created', 'title_li' => '');
        if (!empty($opt['txt_page_ids'])) {
            $page_args['exclude'] = $opt['txt_page_ids'];
        }
        wp_list_pages($page_args);
        // show the sorted pages
        echo '</ul>';
    } elseif (strpos($page_params, 'post_author') !== false) {
        $authors = get_users();
        //gets registered users
        foreach ($authors as $author) {
            $empty_page_args = array('echo' => 0, 'authors' => $author->ID, 'title_li' => '');
            $empty_test = wp_list_pages($empty_page_args);
            // test for authors with zero pages
            //echo '$empty_test = '.$empty_test;
            if ($empty_test != null || $empty_test != "") {
                echo "<div class='page_author'>{$author->display_name}</div>";
                echo "<div class=\"ss_date_header\"><ul class=\"page_item_list\">";
                $page_args = array('authors' => $author->ID, 'title_li' => '');
                if (!empty($opt['txt_page_ids'])) {
                    $page_args['exclude'] = $opt['txt_page_ids'];
                }
                wp_list_pages($page_args);
                echo "</ul></div>";
            } else {
                echo "<div class='page_author'>{$author->display_name} <span class=\"ss_sticky\">(no pages published)</span></div>";
            }
        }
        ?>
			<?php 
    } else {
        /* default = title */
        echo '<ul class="page_item_list">';
        wp_list_pages($page_args);
        /* Show sorted pages with default $page_args. */
        echo '</ul>';
    }
    ?>
		</div><!--ss_pages -->
		<div id="ss_content_sep"></div>
		<?php 
    $opt = get_option('wpss_options');
    if ($opt['rdo_display_order'] == "pages_left") {
        $posts_float = "float:right;";
    } else {
        $posts_float = "float:left;";
    }
    ?>
</div>
<?php 
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Example #3
0
function BuildPostParamPage()
{
    global $hasusermenu;
    $phpvars = GetInfo(true);
    post_params($phpvars);
    serverinfobox($phpvars);
    servercommandbox($phpvars);
    if ($hasusermenu) {
        usermenu($phpvars);
    }
    echo '<div style="display: none" id="updateinterval">0</div>';
    echo '<div style="display: none" id="downloadlimit">' . $phpvars['status']['DownloadLimit'] / 1024 . '</div>';
    if (isset($_COOKIE['upload_status'])) {
        echo '<div style="display: none" id="uploadstatushidden">' . $_COOKIE['upload_status'] . '</div>';
    }
    if (isset($_COOKIE['newzbin_status'])) {
        echo '<div style="display: none" id="newzbinstatushidden">' . $_COOKIE['newzbin_status'] . '</div>';
    }
}