PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.10
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.10
1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 0.8.8 0.8.7 All 34 releases
← All changes | includes/widgets/widget-post-stats.php +27 -27 0.9.81.1.10 View file →
@@ -1,15 +1,15 @@
1 1 <?php
2 2 /**
3 - * Desktop Mode — Post Stats Widget.
3 + * OpenStation — Post Stats Widget.
4 4 *
5 5 * Bar chart of posts published per month for the last 6 months,
6 6 * broken down by published / draft / pending status.
7 7 *
8 8 * Refresh: every 5 minutes.
9 - * Requires: Desktop Mode 0.18.0+ (desktop_mode_register_widget).
9 + * Requires: OpenStation 0.18.0+ (openstation_register_widget).
10 10 *
11 - * @package WPDesktopMode
11 + * @package OpenStation
12 12 */
13 13
14 14 defined( 'ABSPATH' ) || exit;
15 15
@@ -21,15 +21,15 @@
21 21 *
22 22 * Route: GET /desktop-mode/v1/post-stats
23 23 * Permission: edit_posts.
24 24 */
25 -function desktop_mode_register_post_stats_rest_route() {
25 +function openstation_register_post_stats_rest_route() {
26 26 register_rest_route(
27 27 'desktop-mode/v1',
28 28 '/post-stats',
29 29 array(
30 30 'methods' => WP_REST_Server::READABLE,
31 - 'callback' => 'desktop_mode_post_stats_callback',
31 + 'callback' => 'openstation_post_stats_callback',
32 32 'permission_callback' => static function () {
33 33 return current_user_can( 'edit_posts' );
34 34 },
35 35 )
@@ -34,9 +34,9 @@
34 34 },
35 35 )
36 36 );
37 37 }
38 -add_action( 'rest_api_init', 'desktop_mode_register_post_stats_rest_route' );
38 +add_action( 'rest_api_init', 'openstation_register_post_stats_rest_route' );
39 39
40 40 /**
41 41 * Aggregate post counts per month × status for the last 6 months.
42 42 *
@@ -51,9 +51,9 @@
51 51 * in the same capability scope can share one computation.
52 52 *
53 53 * @return array{months:array<int,array{ym:string,publish:int,draft:int,pending:int}>}
54 54 */
55 -function desktop_mode_post_stats_callback() {
55 +function openstation_post_stats_callback() {
56 56 global $wpdb;
57 57
58 58 $see_others = current_user_can( 'edit_others_posts' );
59 59 $cache_key = $see_others
@@ -140,60 +140,60 @@
140 140
141 141 /**
142 142 * Register the JS + CSS assets.
143 143 */
144 -function desktop_mode_register_post_stats_widget_assets() {
145 - $suffix = desktop_mode_asset_suffix();
146 - $version = defined( 'DESKTOP_MODE_VERSION' ) ? DESKTOP_MODE_VERSION : '0';
144 +function openstation_register_post_stats_widget_assets() {
145 + $suffix = openstation_asset_suffix();
146 + $version = defined( 'OPENSTATION_VERSION' ) ? OPENSTATION_VERSION : '0';
147 147
148 - $js_path = DESKTOP_MODE_DIR . 'assets/js/widget-post-stats' . $suffix . '.js';
149 - $css_path = DESKTOP_MODE_DIR . 'assets/js/widget-post-stats' . $suffix . '.css';
148 + $js_path = OPENSTATION_DIR . 'assets/js/widget-post-stats' . $suffix . '.js';
149 + $css_path = OPENSTATION_DIR . 'assets/js/widget-post-stats' . $suffix . '.css';
150 150
151 151 wp_register_style(
152 - 'desktop-mode-post-stats-widget',
153 - DESKTOP_MODE_URL . 'assets/js/widget-post-stats' . $suffix . '.css',
152 + 'os-post-stats-widget',
153 + OPENSTATION_URL . 'assets/js/widget-post-stats' . $suffix . '.css',
154 154 array(),
155 155 file_exists( $css_path ) ? (string) filemtime( $css_path ) : $version
156 156 );
157 157
158 158 wp_register_script(
159 - 'desktop-mode-post-stats-widget',
160 - DESKTOP_MODE_URL . 'assets/js/widget-post-stats' . $suffix . '.js',
159 + 'os-post-stats-widget',
160 + OPENSTATION_URL . 'assets/js/widget-post-stats' . $suffix . '.js',
161 161 array( 'wp-api-fetch' ),
162 162 file_exists( $js_path ) ? (string) filemtime( $js_path ) : $version,
163 163 true
164 164 );
165 165 }
166 -add_action( 'init', 'desktop_mode_register_post_stats_widget_assets', 5 );
166 +add_action( 'init', 'openstation_register_post_stats_widget_assets', 5 );
167 167
168 168 /**
169 169 * Eagerly enqueue the CSS on shell pages.
170 170 */
171 -function desktop_mode_enqueue_post_stats_widget_styles() {
172 - if ( function_exists( 'desktop_mode_is_enabled' ) && ! desktop_mode_is_enabled() ) {
171 +function openstation_enqueue_post_stats_widget_styles() {
172 + if ( function_exists( 'openstation_is_enabled' ) && ! openstation_is_enabled() ) {
173 173 return;
174 174 }
175 - if ( function_exists( 'desktop_mode_is_chromeless_request' ) && desktop_mode_is_chromeless_request() ) {
175 + if ( function_exists( 'openstation_is_chromeless_request' ) && openstation_is_chromeless_request() ) {
176 176 return;
177 177 }
178 - wp_enqueue_style( 'desktop-mode-post-stats-widget' );
178 + wp_enqueue_style( 'os-post-stats-widget' );
179 179 }
180 -add_action( 'admin_enqueue_scripts', 'desktop_mode_enqueue_post_stats_widget_styles', 20 );
180 +add_action( 'admin_enqueue_scripts', 'openstation_enqueue_post_stats_widget_styles', 20 );
181 181
182 182 /**
183 183 * Register the widget definition.
184 184 */
185 -function desktop_mode_register_post_stats_widget() {
186 - if ( ! function_exists( 'desktop_mode_register_widget' ) ) {
185 +function openstation_register_post_stats_widget() {
186 + if ( ! function_exists( 'openstation_register_widget' ) ) {
187 187 return;
188 188 }
189 - desktop_mode_register_widget(
189 + openstation_register_widget(
190 190 'desktop-mode/post-stats',
191 191 array(
192 192 'label' => __( 'Post Stats', 'desktop-mode' ),
193 193 'description' => __( 'Bar chart of posts per month over the last 6 months.', 'desktop-mode' ),
194 194 'icon' => 'dashicons-chart-bar',
195 - 'script' => 'desktop-mode-post-stats-widget',
195 + 'script' => 'os-post-stats-widget',
196 196 'movable' => true,
197 197 'resizable' => true,
198 198 'min_width' => 260,
199 199 'min_height' => 200,
@@ -201,5 +201,5 @@
201 201 'default_height' => 260,
202 202 )
203 203 );
204 204 }
205 -add_action( 'init', 'desktop_mode_register_post_stats_widget', 6 );
205 +add_action( 'init', 'openstation_register_post_stats_widget', 6 );