Changeset 2586106
- Timestamp:
- 08/20/2021 05:06:30 PM (5 years ago)
- Location:
- modified
- Files:
-
- 4 edited
- 1 copied
-
tags/1.1.0 (copied) (copied from modified/trunk)
-
tags/1.1.0/modified.php (modified) (3 diffs)
-
tags/1.1.0/readme.txt (modified) (2 diffs)
-
trunk/modified.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
modified/tags/1.1.0/modified.php
r2582304 r2586106 3 3 * Plugin Name: Modified 4 4 * Description: Quickly and easily view the last modified posts. 5 * Version: 1. 0.05 * Version: 1.1.0 6 6 * Author: Brad Parbs 7 7 * Author URI: https://bradparbs.com/ … … 17 17 use WP_Query; 18 18 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 ); 19 add_action( 'wp_dashboard_setup', __NAMESPACE__ . '\\add_dashboard_widget' ); 33 20 34 21 /** 35 * Add dashboard widget for modified posts. 22 * Add new dashboard widget with list of recently modified posts. 23 */ 24 function 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. 36 36 */ 37 37 function 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 ] ); 47 46 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 ); 62 49 63 50 printf( … … 70 57 ); 71 58 } 59 72 60 /** 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 */ 67 function 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. 74 92 * 75 93 * @param array $posts Post data. -
modified/tags/1.1.0/readme.txt
r2582304 r2586106 1 1 === Modified === 2 Contributors: bradparbs 2 Contributors: bradparbs, surfboards 3 3 Tags: posts, widget, dashboard, content, calendar 4 4 Requires at least: 5.2 5 5 Tested up to: 5.8 6 Stable tag: 1. 0.06 Stable tag: 1.1.0 7 7 License: GPLv2 or later 8 8 Requires PHP: 5.6 … … 13 13 14 14 Quickly 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 3 3 * Plugin Name: Modified 4 4 * Description: Quickly and easily view the last modified posts. 5 * Version: 1. 0.05 * Version: 1.1.0 6 6 * Author: Brad Parbs 7 7 * Author URI: https://bradparbs.com/ … … 17 17 use WP_Query; 18 18 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 ); 19 add_action( 'wp_dashboard_setup', __NAMESPACE__ . '\\add_dashboard_widget' ); 33 20 34 21 /** 35 * Add dashboard widget for modified posts. 22 * Add new dashboard widget with list of recently modified posts. 23 */ 24 function 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. 36 36 */ 37 37 function 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 ] ); 47 46 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 ); 62 49 63 50 printf( … … 70 57 ); 71 58 } 59 72 60 /** 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 */ 67 function 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. 74 92 * 75 93 * @param array $posts Post data. -
modified/trunk/readme.txt
r2582304 r2586106 1 1 === Modified === 2 Contributors: bradparbs 2 Contributors: bradparbs, surfboards 3 3 Tags: posts, widget, dashboard, content, calendar 4 4 Requires at least: 5.2 5 5 Tested up to: 5.8 6 Stable tag: 1. 0.06 Stable tag: 1.1.0 7 7 License: GPLv2 or later 8 8 Requires PHP: 5.6 … … 13 13 14 14 Quickly 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.