Plugin Directory

Changeset 155757


Ignore:
Timestamp:
09/17/2009 05:03:53 PM (16 years ago)
Author:
ehsan4php
Message:

Version 1.0.1:
Added feature to display list of recently updated blog Posts along with the pages

Location:
recently-updated-pages
Files:
6 added
2 edited

Legend:

Unmodified
Added
Removed
  • recently-updated-pages/trunk/readme.txt

    r155443 r155757  
    44Donate link: http://resource.bdwebwork.com/WordpressPlugins/RecentlyUpdatedPages/
    55Author URI: http://ehsan.bdwebwork.com/
    6 Tags: updated, recent, page
     6Tags: updated, recent, page, post
    77Requires at least: 2.8
    88Tested up to: 2.8
    9 Stable tag: 1.0.0
     9Stable tag: 1.0.1
    1010
    11 Purpose of this plugin is to display the list of pages on Wordpress blog those have been recently updated.
     11Purpose of this plugin is to display the list of pages (and optionally posts) on Wordpress blog those have been recently updated.
    1212
    1313== Description ==
    1414
    1515Sometimes when you update one of your pages on the Wordpress blog you would want visitors to know about those. This widget will create a sidebar
    16 box with a list of pages you've recently updated. It also shows the date of the update beside the page title.
     16box with a list of pages you've recently updated. It also shows the date of the update beside the page title.
     17
     18You've an option to display the Posts in the list as well. If checked (through admin panel) the list will include the Posts along with the list of Pages.
    1719
    1820== Installation ==
     
    3840You can define it through the widget editor in the Wordpress admin panel. Specify the number and save.
    3941
     42= Will I be able to show my blog POST titles in the list? =
     43
     44Yes, now you can. Check the option to include the blog Posts in the list and it will show them along with the Page list.
     45
    4046== Screenshots ==
    4147
    42 1. widget-on-admin.jpg
    43 2. widget-on-blog.jpg
     481. Widget as shown in Admin panel
     492. Widget on the blog, only showing the Pages
     503. Widget on the blog showing both Pages and Posts
    4451
    4552== Changelog ==
  • recently-updated-pages/trunk/recently_updated_pages.php

    r155451 r155757  
    44     *
    55     * Plugin name:     Recently Updated Pages
    6      * Description:     Purpose of this plugin is to display the list of pages on
     6     * Description:     Purpose of this plugin is to display the list of pages (and optionally posts) on
    77     *                  Wordpress blog those have been recently updated.
    8      * Version:         1.0.0
     8     * Version:         1.0.1
    99     * Plugin URI:      http://resource.bdwebwork.com/WordpressPlugins/RecentlyUpdatedPages/
    1010     * Author:          Ehsanul Haque
     
    4141            $title              = apply_filters('widget_title', $instance['title']);
    4242            $totalPagesToShow   = (int) $instance['totalPagesToShow'];
     43            $showListWithPosts  = (int) $instance['showListWithPosts'];
    4344
    4445            $defaults           = array (
    4546                                        'title'             => 'Recently Updated Pages',
    46                                         'totalPagesToShow'  => 3
     47                                        'totalPagesToShow'  => 3,
     48                                        'showListWithPosts' => 0
    4749                                        );
    4850                                   
     
    5658
    5759            if ($totalPagesToShow != 0) {
    58                 $pageList       = $this->getListOfPages($totalPagesToShow);
     60                $pageList       = $this->getListOfPages($totalPagesToShow, $showListWithPosts);
    5961            } else {
    60                 $pageList       = $this->getListOfPages($defaults['totalPagesToShow']);
     62                $pageList       = $this->getListOfPages($defaults['totalPagesToShow'], $defaults['showListWithPosts']);
    6163            }
    6264
    63             echo "<ul>";
    64                 echo str_replace("</a>", "</a> on ", $pageList);
    65             echo "</ul>";
    66 
     65            if (!empty($pageList)) {
     66                echo "<ul>";
     67                    foreach ($pageList as $obj) {
     68                        echo "<li class='page_item page-item-{$obj->ID}'><a href='{$obj->uri}' title='{$obj->post_title}'>{$obj->post_title}</a> on {$obj->post_modified}</li>";
     69                    }
     70                echo "</ul>";
     71            }
    6772            echo $after_widget;
    6873        }       
     
    7378            $instance['title']              = strip_tags($new_instance['title']);
    7479            $instance['totalPagesToShow']   = strip_tags($new_instance['totalPagesToShow']);
     80            $instance['showListWithPosts']  = strip_tags($new_instance['showListWithPosts']);
    7581
    7682            return $instance;
     
    8288            $defaults       = array (
    8389                                    'title'             => 'Recently Updated Pages',
    84                                     'totalPagesToShow'  => 3
     90                                    'totalPagesToShow'  => 3,
     91                                    'showListWithPosts' => 0
    8592                                    );
    8693                                   
     
    96103            <input id="<?php echo $this->get_field_id('totalPagesToShow'); ?>" name="<?php echo $this->get_field_name('totalPagesToShow'); ?>" value="<?php echo $instance['totalPagesToShow']; ?>" style="width:100%;" />
    97104        </p>
     105
     106        <p>
     107            <label for="<?php echo $this->get_field_id('showListWithPosts'); ?>">Include blog Posts in the list:</label>
     108            <input id="<?php echo $this->get_field_id('showListWithPosts'); ?>" name="<?php echo $this->get_field_name('showListWithPosts'); ?>" value="1" type="checkbox"
     109                   <?php
     110                   if ($instance['showListWithPosts'] == 1) {
     111                       echo " Checked";
     112                   }
     113                   ?>
     114                   />
     115        </p>
    98116<?php
    99117        }
    100118
    101         // Getting the list of pages based on the option set by the user
    102         function getListOfPages($totalPagesToShow) {
    103             $args       = array (
    104                                 'depth'         => 0,
    105                                 'child_of'      => 0,
    106                                 'depth'         => -1,
    107                                 'show_date'     => 'modified',
    108                                 'date_format'   => 'F j, Y',
    109                                 'sort_column'   => 'post_modified',
    110                                 'sort_order'    => 'desc',
    111                                 'title_li'      => '',
    112                                 'number'        => $totalPagesToShow,
    113                                 'echo'          => 0
    114                                 );
    115                                
    116             return wp_list_pages($args);
     119        // Getting the list of pages ( and posts) based on the option set by the user
     120        function getListOfPages($totalPagesToShow, $showListWithPosts) {
     121            GLOBAL $wpdb;
     122
     123            if ($showListWithPosts == 1) {
     124                $postTypeWhere      = "post_type IN ('page', 'post')";
     125            } else {
     126                $postTypeWhere      = "post_type = 'page'";
     127            }
     128            $sql            = "SELECT ID, post_title, post_modified FROM
     129                                {$wpdb->posts} WHERE
     130                                post_status = 'publish' AND
     131                                {$postTypeWhere}
     132                                ORDER BY post_modified DESC
     133                                LIMIT {$totalPagesToShow}";
     134
     135            $list           = (array) $wpdb->get_results($sql);
     136
     137            if (!empty($list)) {
     138                foreach ($list as $key => $val) {
     139                    $val->uri = get_permalink($val->ID);
     140                }
     141            }
     142
     143            return $list;
    117144        }
    118145    }
Note: See TracChangeset for help on using the changeset viewer.