Plugin Directory

Changeset 2586106


Ignore:
Timestamp:
08/20/2021 05:06:30 PM (5 years ago)
Author:
bradparbs
Message:

Update to version 1.1.0 from GitHub

Location:
modified
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • modified/tags/1.1.0/modified.php

    r2582304 r2586106  
    33 * Plugin Name: Modified
    44 * Description: Quickly and easily view the last modified posts.
    5  * Version:     1.0.0
     5 * Version:     1.1.0
    66 * Author:      Brad Parbs
    77 * Author URI:  https://bradparbs.com/
     
    1717use WP_Query;
    1818
    19 // Add new dashboard widget with list of modified posts.
    20 add_action(
    21     'wp_dashboard_setup',
    22     function () {
    23         wp_add_dashboard_widget(
    24             'modified',
    25             sprintf(
    26                 '<span><span class="dashicons dashicons-welcome-write-blog" style="padding-right: 10px"></span>%s</span>',
    27                 esc_attr__( 'Recently Modified', 'modified' )
    28             ),
    29             __NAMESPACE__ . '\\dashboard_widget'
    30         );
    31     }
    32 );
     19add_action( 'wp_dashboard_setup', __NAMESPACE__ . '\\add_dashboard_widget' );
    3320
    3421/**
    35  * Add dashboard widget for modified posts.
     22 * Add new dashboard widget with list of recently modified posts.
     23 */
     24function add_dashboard_widget() {
     25    $name = sprintf(
     26        '<span><span class="dashicons %s" style="padding-right: 10px"></span>%s</span>',
     27        apply_filters( 'modified_widget_icon', 'dashicons-welcome-write-blog' ),
     28        apply_filters( 'modified_widget_title', esc_attr__( 'Recently Modified', 'modified' ) )
     29    );
     30
     31    wp_add_dashboard_widget( 'modified', $name, __NAMESPACE__ . '\\dashboard_widget' );
     32}
     33
     34/**
     35 * Add dashboard widget for recently modified posts.
    3636 */
    3737function dashboard_widget() {
    38     $posts = new WP_Query(
    39         [
    40             'post_type'      => get_post_types(),
    41             'orderby'        => 'modified',
    42             'order'          => 'DESC',
    43             'posts_per_page' => 25,
    44             'no_found_rows'  => true,
    45         ]
    46     );
     38    $post_types = apply_filters( 'modified_post_types_to_show', get_post_types() );
     39    $query_args = apply_filters( 'modified_widget_query_args', [
     40        'post_type'      => $post_types,
     41        'orderby'        => 'modified',
     42        'order'          => 'DESC',
     43        'posts_per_page' => 25,
     44        'no_found_rows'  => true,
     45    ] );
    4746
    48     $modified = [];
    49 
    50     if ( $posts->have_posts() ) {
    51         while ( $posts->have_posts() ) {
    52             $posts->the_post();
    53 
    54             $modified[] = [
    55                 'ID'      => get_the_ID(),
    56                 'title'   => get_the_title(),
    57                 'date'    => gmdate( 'F j, g:ia', get_the_time( 'U' ) ),
    58                 'preview' => get_preview_post_link(),
    59             ];
    60         }
    61     }
     47    $posts     = new WP_Query( $query_args );
     48    $modified = get_modified_posts( $posts );
    6249
    6350    printf(
     
    7057    );
    7158}
     59
    7260/**
    73  * Display modified posts in widget.
     61 * Get the recently modified posts to display in the dashboard widget.
     62 *
     63 * @param WP_Query $posts WP_Query object.
     64 *
     65 * @return array Array of recently modified posts.
     66 */
     67function get_modified_posts( $posts ) {
     68    $modified = [];
     69
     70    if ( $posts->have_posts() ) {
     71        while ( $posts->have_posts() ) {
     72            $posts->the_post();
     73
     74            $add_to_modified = apply_filters( 'schedules_show_in_widget', [
     75                'ID'      => get_the_ID(),
     76                'title'   => get_the_title(),
     77                'date'    => gmdate( 'F j, g:ia', get_the_time( 'U' ) ),
     78                'preview' => get_preview_post_link(),
     79            ] );
     80
     81            if ( isset( $add_to_modified ) ) {
     82                $modified[] = $add_to_modified;
     83            }
     84        }
     85    }
     86
     87    return $modified;
     88}
     89
     90/**
     91 * Display recently modified posts in widget.
    7492 *
    7593 * @param array $posts Post data.
  • modified/tags/1.1.0/readme.txt

    r2582304 r2586106  
    11=== Modified ===
    2 Contributors: bradparbs
     2Contributors: bradparbs, surfboards
    33Tags: posts, widget, dashboard, content, calendar
    44Requires at least: 5.2
    55Tested up to: 5.8
    6 Stable tag: 1.0.0
     6Stable tag: 1.1.0
    77License: GPLv2 or later
    88Requires PHP: 5.6
     
    1313
    1414Quickly and easily view all your recently edited posts.
     15
     16== Availiable filters ==
     17
     18`modified_widget_icon` - The dashicon to use for the dashboard widget.
     19`modified_widget_title` - The title to use for the dashboard widget.
     20`modified_post_types_to_show` - An arry of post types to show in the widget. Defaults to all post types.
     21`modified_widget_query_args` - An array of arguments to pass to the WP_Query.
     22`modified_show_in_widget` - Will pass ID of each post, returning `false` will not add it to the dashboard widget.
     23
     24== Changelog ==
     25
     26= 1.1.0 =
     27
     28* Added more filters
     29
     30= 1.0.0 =
     31
     32* Initial release
  • modified/trunk/modified.php

    r2582304 r2586106  
    33 * Plugin Name: Modified
    44 * Description: Quickly and easily view the last modified posts.
    5  * Version:     1.0.0
     5 * Version:     1.1.0
    66 * Author:      Brad Parbs
    77 * Author URI:  https://bradparbs.com/
     
    1717use WP_Query;
    1818
    19 // Add new dashboard widget with list of modified posts.
    20 add_action(
    21     'wp_dashboard_setup',
    22     function () {
    23         wp_add_dashboard_widget(
    24             'modified',
    25             sprintf(
    26                 '<span><span class="dashicons dashicons-welcome-write-blog" style="padding-right: 10px"></span>%s</span>',
    27                 esc_attr__( 'Recently Modified', 'modified' )
    28             ),
    29             __NAMESPACE__ . '\\dashboard_widget'
    30         );
    31     }
    32 );
     19add_action( 'wp_dashboard_setup', __NAMESPACE__ . '\\add_dashboard_widget' );
    3320
    3421/**
    35  * Add dashboard widget for modified posts.
     22 * Add new dashboard widget with list of recently modified posts.
     23 */
     24function add_dashboard_widget() {
     25    $name = sprintf(
     26        '<span><span class="dashicons %s" style="padding-right: 10px"></span>%s</span>',
     27        apply_filters( 'modified_widget_icon', 'dashicons-welcome-write-blog' ),
     28        apply_filters( 'modified_widget_title', esc_attr__( 'Recently Modified', 'modified' ) )
     29    );
     30
     31    wp_add_dashboard_widget( 'modified', $name, __NAMESPACE__ . '\\dashboard_widget' );
     32}
     33
     34/**
     35 * Add dashboard widget for recently modified posts.
    3636 */
    3737function dashboard_widget() {
    38     $posts = new WP_Query(
    39         [
    40             'post_type'      => get_post_types(),
    41             'orderby'        => 'modified',
    42             'order'          => 'DESC',
    43             'posts_per_page' => 25,
    44             'no_found_rows'  => true,
    45         ]
    46     );
     38    $post_types = apply_filters( 'modified_post_types_to_show', get_post_types() );
     39    $query_args = apply_filters( 'modified_widget_query_args', [
     40        'post_type'      => $post_types,
     41        'orderby'        => 'modified',
     42        'order'          => 'DESC',
     43        'posts_per_page' => 25,
     44        'no_found_rows'  => true,
     45    ] );
    4746
    48     $modified = [];
    49 
    50     if ( $posts->have_posts() ) {
    51         while ( $posts->have_posts() ) {
    52             $posts->the_post();
    53 
    54             $modified[] = [
    55                 'ID'      => get_the_ID(),
    56                 'title'   => get_the_title(),
    57                 'date'    => gmdate( 'F j, g:ia', get_the_time( 'U' ) ),
    58                 'preview' => get_preview_post_link(),
    59             ];
    60         }
    61     }
     47    $posts     = new WP_Query( $query_args );
     48    $modified = get_modified_posts( $posts );
    6249
    6350    printf(
     
    7057    );
    7158}
     59
    7260/**
    73  * Display modified posts in widget.
     61 * Get the recently modified posts to display in the dashboard widget.
     62 *
     63 * @param WP_Query $posts WP_Query object.
     64 *
     65 * @return array Array of recently modified posts.
     66 */
     67function get_modified_posts( $posts ) {
     68    $modified = [];
     69
     70    if ( $posts->have_posts() ) {
     71        while ( $posts->have_posts() ) {
     72            $posts->the_post();
     73
     74            $add_to_modified = apply_filters( 'schedules_show_in_widget', [
     75                'ID'      => get_the_ID(),
     76                'title'   => get_the_title(),
     77                'date'    => gmdate( 'F j, g:ia', get_the_time( 'U' ) ),
     78                'preview' => get_preview_post_link(),
     79            ] );
     80
     81            if ( isset( $add_to_modified ) ) {
     82                $modified[] = $add_to_modified;
     83            }
     84        }
     85    }
     86
     87    return $modified;
     88}
     89
     90/**
     91 * Display recently modified posts in widget.
    7492 *
    7593 * @param array $posts Post data.
  • modified/trunk/readme.txt

    r2582304 r2586106  
    11=== Modified ===
    2 Contributors: bradparbs
     2Contributors: bradparbs, surfboards
    33Tags: posts, widget, dashboard, content, calendar
    44Requires at least: 5.2
    55Tested up to: 5.8
    6 Stable tag: 1.0.0
     6Stable tag: 1.1.0
    77License: GPLv2 or later
    88Requires PHP: 5.6
     
    1313
    1414Quickly and easily view all your recently edited posts.
     15
     16== Availiable filters ==
     17
     18`modified_widget_icon` - The dashicon to use for the dashboard widget.
     19`modified_widget_title` - The title to use for the dashboard widget.
     20`modified_post_types_to_show` - An arry of post types to show in the widget. Defaults to all post types.
     21`modified_widget_query_args` - An array of arguments to pass to the WP_Query.
     22`modified_show_in_widget` - Will pass ID of each post, returning `false` will not add it to the dashboard widget.
     23
     24== Changelog ==
     25
     26= 1.1.0 =
     27
     28* Added more filters
     29
     30= 1.0.0 =
     31
     32* Initial release
Note: See TracChangeset for help on using the changeset viewer.