GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — modified/modified.php at main · bradp/modified

Expand file tree

/

modified.php

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
129 lines (111 loc) · 3.23 KB
/

modified.php

Copy path

File metadata and controls

129 lines (111 loc) · 3.23 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/**
* Plugin Name: Modified
* Description: Quickly and easily view the last modified posts.
* Version: 1.1.1
* Requires at least: 6.0
* Requires PHP: 7.4
* Author: Brad Parbs
* Author URI: https://bradparbs.com/
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: modified
*
* @package modified
*/
namespace Modified;
use WP_Query;
defined( 'ABSPATH' ) || exit;
add_action( 'wp_dashboard_setup', __NAMESPACE__ . '\\add_dashboard_widget' );
/**
* Add new dashboard widget with list of recently modified posts.
*/
function add_dashboard_widget() {
$name = sprintf(
'<span><span class="dashicons %s" style="padding-right: 10px"></span>%s</span>',
esc_attr( apply_filters( 'modified_widget_icon', 'dashicons-welcome-write-blog' ) ),
apply_filters( 'modified_widget_title', esc_html__( 'Recently Modified', 'modified' ) )
);
wp_add_dashboard_widget( 'modified', $name, __NAMESPACE__ . '\\dashboard_widget' );
}
/**
* Get the post types to show in the widget.
*
* @return string|string[] Post type(s).
*/
function get_widget_post_types() {
return apply_filters(
'modified_post_types_to_show',
array_values( array_diff( get_post_types( [ 'public' => true ] ), [ 'attachment' ] ) )
);
}
/**
* Add dashboard widget for recently modified posts.
*/
function dashboard_widget() {
$query_args = apply_filters(
'modified_widget_query_args',
[
'post_type' => get_widget_post_types(),
'orderby' => 'modified',
'order' => 'DESC',
'posts_per_page' => 25,
'no_found_rows' => true,
]
);
$items = get_widget_items( new WP_Query( $query_args ) );
printf(
'<div id="modified-posts-widget-wrapper">
<div id="modified-posts-widget" class="activity-block" style="padding-top: 0;">
<ul>%s</ul>
</div>
</div>',
display_items_in_widget( $items ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in display_items_in_widget().
);
}
/**
* Get the recently modified posts to display in the dashboard widget.
*
* @param WP_Query $query WP_Query object.
*
* @return array Array of recently modified posts.
*/
function get_widget_items( $query ) {
$items = [];
foreach ( $query->posts as $post ) {
$title = get_the_title( $post );
$item = apply_filters(
'modified_show_in_widget',
[
'ID' => $post->ID,
'title' => '' !== $title ? $title : __( '(no title)', 'modified' ),
'date' => wp_date( 'F j, g:ia', get_post_timestamp( $post, 'modified' ) ),
'preview' => get_preview_post_link( $post ),
]
);
if ( ! empty( $item ) && is_array( $item ) ) {
$items[] = $item;
}
}
return $items;
}
/**
* Display recently modified posts in widget.
*
* @param array $items Post data.
*
* @return string Escaped output of post data.
*/
function display_items_in_widget( $items ) {
$output = '';
foreach ( $items as $item ) {
$output .= sprintf(
'<li><em style="%4$s">%1$s</em> <a href="%2$s">%3$s</a></li>',
esc_html( $item['date'] ?? '' ),
esc_url( $item['preview'] ?? '' ),
esc_html( $item['title'] ?? '' ),
'display: inline-block; margin-right: 5px; min-width: 125px; color: #646970;'
);
}
return $output;
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.