Changeset 2586110
- Timestamp:
- 08/20/2021 05:07:22 PM (5 years ago)
- Location:
- published
- Files:
-
- 4 edited
- 1 copied
-
tags/1.1.1 (copied) (copied from published/trunk)
-
tags/1.1.1/published.php (modified) (3 diffs)
-
tags/1.1.1/readme.txt (modified) (2 diffs)
-
trunk/published.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
published/tags/1.1.1/published.php
r2584858 r2586110 3 3 * Plugin Name: Published 4 4 * Description: Quickly and easily view the last published posts. 5 * Version: 1.1. 05 * Version: 1.1.1 6 6 * Author: Brad Parbs 7 7 * Author URI: https://bradparbs.com/ … … 17 17 use WP_Query; 18 18 19 20 // Add new dashboard widget with list of published posts. 21 add_action( 22 'wp_dashboard_setup', 23 function () { 24 wp_add_dashboard_widget( 25 'published', 26 sprintf( 27 '<span><span class="dashicons dashicons-clock" style="padding-right: 10px"></span>%s</span>', 28 esc_attr__( 'Recently Published', 'published' ) 29 ), 30 __NAMESPACE__ . '\\dashboard_widget' 31 ); 32 } 33 ); 19 add_action( 'wp_dashboard_setup', __NAMESPACE__ . '\\add_dashboard_widget' ); 34 20 35 21 /** 36 * Add dashboard widget for published posts. 22 * Add new dashboard widget with list of recently published 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( 'published_widget_icon', 'dashicons-clock' ), 28 apply_filters( 'published_widget_title', esc_attr__( 'Recently Published', 'published' ) ) 29 ); 30 31 wp_add_dashboard_widget( 'published', $name, __NAMESPACE__ . '\\dashboard_widget' ); 32 } 33 34 /** 35 * Add dashboard widget for recently published posts. 37 36 */ 38 37 function dashboard_widget() { 39 $posts = new \WP_Query( 40 [ 41 'post_type' => get_post_types(), 42 'orderby' => 'date', 43 'order' => 'DESC', 44 'posts_per_page' => 25, 45 'no_found_rows' => true, 46 ] 47 ); 38 $post_types = apply_filters( 'published_post_types_to_show', get_post_types() ); 39 $query_args = apply_filters( 'published_widget_query_args', [ 40 'post_type' => $post_types, 41 'orderby' => 'date', 42 'order' => 'DESC', 43 'posts_per_page' => 25, 44 'no_found_rows' => true, 45 ] ); 48 46 49 $published = []; 50 51 if ( $posts->have_posts() ) { 52 while ( $posts->have_posts() ) { 53 $posts->the_post(); 54 55 $published[] = [ 56 'ID' => get_the_ID(), 57 'title' => get_the_title(), 58 'date' => gmdate( 'F j, g:ia', get_the_time( 'U' ) ), 59 'preview' => get_preview_post_link(), 60 ]; 61 } 62 } 47 $posts = new WP_Query( $query_args ); 48 $published = get_published_posts( $posts ); 63 49 64 50 printf( … … 71 57 ); 72 58 } 59 73 60 /** 74 * Display published posts in widget. 61 * Get the recently published posts to display in the dashboard widget. 62 * 63 * @param WP_Query $posts WP_Query object. 64 * 65 * @return array Array of recently published posts. 66 */ 67 function get_published_posts( $posts ) { 68 $published = []; 69 70 if ( $posts->have_posts() ) { 71 while ( $posts->have_posts() ) { 72 $posts->the_post(); 73 74 $add_to_published = 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_published ) ) { 82 $published[] = $add_to_published; 83 } 84 } 85 } 86 87 return $published; 88 } 89 90 /** 91 * Display recently published posts in widget. 75 92 * 76 93 * @param array $posts Post data. -
published/tags/1.1.1/readme.txt
r2584858 r2586110 1 1 === Published === 2 Contributors: bradparbs 2 Contributors: bradparbs, surfboards 3 3 Tags: posts, published, widget, dashboard, content, calendar 4 4 Requires at least: 5.2 5 5 Tested up to: 5.8 6 Stable tag: 1.1. 06 Stable tag: 1.1.1 7 7 License: GPLv2 or later 8 8 Requires PHP: 5.6 … … 13 13 14 14 Quickly and easily view all your published posts. 15 16 == Availiable filters == 17 18 `published_widget_icon` - The dashicon to use for the dashboard widget. 19 `published_widget_title` - The title to use for the dashboard widget. 20 `published_post_types_to_show` - An arry of post types to show in the widget. Defaults to all post types. 21 `published_widget_query_args` - An array of arguments to pass to the WP_Query. 22 `published_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.1 = 27 28 * Added more filters 29 30 = 1.1.0 = 31 32 * Fix namespace 33 34 = 1.0.0 = 35 36 * Initial release -
published/trunk/published.php
r2584858 r2586110 3 3 * Plugin Name: Published 4 4 * Description: Quickly and easily view the last published posts. 5 * Version: 1.1. 05 * Version: 1.1.1 6 6 * Author: Brad Parbs 7 7 * Author URI: https://bradparbs.com/ … … 17 17 use WP_Query; 18 18 19 20 // Add new dashboard widget with list of published posts. 21 add_action( 22 'wp_dashboard_setup', 23 function () { 24 wp_add_dashboard_widget( 25 'published', 26 sprintf( 27 '<span><span class="dashicons dashicons-clock" style="padding-right: 10px"></span>%s</span>', 28 esc_attr__( 'Recently Published', 'published' ) 29 ), 30 __NAMESPACE__ . '\\dashboard_widget' 31 ); 32 } 33 ); 19 add_action( 'wp_dashboard_setup', __NAMESPACE__ . '\\add_dashboard_widget' ); 34 20 35 21 /** 36 * Add dashboard widget for published posts. 22 * Add new dashboard widget with list of recently published 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( 'published_widget_icon', 'dashicons-clock' ), 28 apply_filters( 'published_widget_title', esc_attr__( 'Recently Published', 'published' ) ) 29 ); 30 31 wp_add_dashboard_widget( 'published', $name, __NAMESPACE__ . '\\dashboard_widget' ); 32 } 33 34 /** 35 * Add dashboard widget for recently published posts. 37 36 */ 38 37 function dashboard_widget() { 39 $posts = new \WP_Query( 40 [ 41 'post_type' => get_post_types(), 42 'orderby' => 'date', 43 'order' => 'DESC', 44 'posts_per_page' => 25, 45 'no_found_rows' => true, 46 ] 47 ); 38 $post_types = apply_filters( 'published_post_types_to_show', get_post_types() ); 39 $query_args = apply_filters( 'published_widget_query_args', [ 40 'post_type' => $post_types, 41 'orderby' => 'date', 42 'order' => 'DESC', 43 'posts_per_page' => 25, 44 'no_found_rows' => true, 45 ] ); 48 46 49 $published = []; 50 51 if ( $posts->have_posts() ) { 52 while ( $posts->have_posts() ) { 53 $posts->the_post(); 54 55 $published[] = [ 56 'ID' => get_the_ID(), 57 'title' => get_the_title(), 58 'date' => gmdate( 'F j, g:ia', get_the_time( 'U' ) ), 59 'preview' => get_preview_post_link(), 60 ]; 61 } 62 } 47 $posts = new WP_Query( $query_args ); 48 $published = get_published_posts( $posts ); 63 49 64 50 printf( … … 71 57 ); 72 58 } 59 73 60 /** 74 * Display published posts in widget. 61 * Get the recently published posts to display in the dashboard widget. 62 * 63 * @param WP_Query $posts WP_Query object. 64 * 65 * @return array Array of recently published posts. 66 */ 67 function get_published_posts( $posts ) { 68 $published = []; 69 70 if ( $posts->have_posts() ) { 71 while ( $posts->have_posts() ) { 72 $posts->the_post(); 73 74 $add_to_published = 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_published ) ) { 82 $published[] = $add_to_published; 83 } 84 } 85 } 86 87 return $published; 88 } 89 90 /** 91 * Display recently published posts in widget. 75 92 * 76 93 * @param array $posts Post data. -
published/trunk/readme.txt
r2584858 r2586110 1 1 === Published === 2 Contributors: bradparbs 2 Contributors: bradparbs, surfboards 3 3 Tags: posts, published, widget, dashboard, content, calendar 4 4 Requires at least: 5.2 5 5 Tested up to: 5.8 6 Stable tag: 1.1. 06 Stable tag: 1.1.1 7 7 License: GPLv2 or later 8 8 Requires PHP: 5.6 … … 13 13 14 14 Quickly and easily view all your published posts. 15 16 == Availiable filters == 17 18 `published_widget_icon` - The dashicon to use for the dashboard widget. 19 `published_widget_title` - The title to use for the dashboard widget. 20 `published_post_types_to_show` - An arry of post types to show in the widget. Defaults to all post types. 21 `published_widget_query_args` - An array of arguments to pass to the WP_Query. 22 `published_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.1 = 27 28 * Added more filters 29 30 = 1.1.0 = 31 32 * Fix namespace 33 34 = 1.0.0 = 35 36 * Initial release
Note: See TracChangeset
for help on using the changeset viewer.