PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 4.6.0.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v4.6.0.1
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
mainwp / widgets / widget-mainwp-recent-pages.php

widget-mainwp-recent-pages.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 4.6.0.1, at widgets/widget-mainwp-recent-pages.php

725 lines 33.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Recent Pages Widget
4 *
5 * Displays the Child Sites most recent published draft, pending, trash & future Pages.
6 *
7 * @package MainWP/Widget_Mainwp_Recent_Pages
8 */
9
10 namespace MainWP\Dashboard;
11
12 /**
13 * Class MainWP_Recent_Pages
14 *
15 * Displays the Child Sites most recent published draft, pending, trash & future Pages.
16 */
17 class MainWP_Recent_Pages {
18
19 /**
20 * Method get_class_name()
21 *
22 * @return string __CLASS__ Class Name
23 */
24 public static function get_class_name() {
25 return __CLASS__;
26 }
27
28 /**
29 * Method render()
30 *
31 * Fire off Method render_sites().
32 */
33 public static function render() {
34 self::render_sites();
35 }
36
37 /**
38 * Method render_sites()
39 *
40 * Build the resent pages list.
41 *
42 * @uses \MainWP\Dashboard\MainWP_DB::query()
43 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
44 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
45 * @uses \MainWP\Dashboard\MainWP_DB::free_result()
46 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid()
47 */
48 public static function render_sites() {
49
50 /** This filter is documented in /widgets/widget-mainwp-recent-posts.php */
51 $recent_number = apply_filters( 'mainwp_recent_posts_pages_number', 5 );
52
53 $allPages = array();
54
55 $current_wpid = MainWP_System_Utility::get_current_wpid();
56
57 if ( isset( $_GET['client_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
58 $data_fields = MainWP_System_Utility::get_default_map_site_fields();
59 $data_fields[] = 'recent_pages';
60 $individual = false;
61 $client_id = isset( $_GET['client_id'] ) ? intval( $_GET['client_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
62 $websites = MainWP_DB_Client::instance()->get_websites_by_client_ids( $client_id, array( 'select_data' => $data_fields ) );
63
64 if ( $websites ) {
65 foreach ( $websites as $website ) {
66 if ( empty( $website->recent_pages ) ) {
67 continue;
68 }
69
70 $pages = json_decode( $website->recent_pages, 1 );
71 if ( 0 === count( $pages ) ) {
72 continue;
73 }
74 foreach ( $pages as $page ) {
75 $page['website'] = (object) array(
76 'id' => $website->id,
77 'url' => $website->url,
78 'name' => $website->name,
79 );
80 $allPages[] = $page;
81 }
82 }
83 }
84 } else {
85 if ( $current_wpid ) {
86 $sql = MainWP_DB::instance()->get_sql_website_by_id( $current_wpid );
87 $individual = true;
88 } else {
89 $sql = MainWP_DB::instance()->get_sql_websites_for_current_user();
90 $individual = false;
91 }
92 $websites = MainWP_DB::instance()->query( $sql );
93
94 if ( $websites ) {
95 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
96 if ( empty( $website->recent_pages ) ) {
97 continue;
98 }
99
100 $pages = json_decode( $website->recent_pages, 1 );
101 if ( 0 === count( $pages ) ) {
102 continue;
103 }
104 foreach ( $pages as $page ) {
105 $page['website'] = (object) array(
106 'id' => $website->id,
107 'url' => $website->url,
108 'name' => $website->name,
109 );
110 $allPages[] = $page;
111 }
112 }
113 MainWP_DB::free_result( $websites );
114 }
115 }
116
117 self::render_top_grid();
118
119 /**
120 * Action: mainwp_recent_pages_widget_top
121 *
122 * Fires at the top of the Recent Pages widget.
123 *
124 * @since 4.1
125 */
126 do_action( 'mainwp_recent_pages_widget_top' );
127
128 ?>
129 <div class="mainwp-scrolly-overflow">
130 <?php
131 self::render_published_posts( $allPages, $recent_number, $individual );
132 self::render_draft_posts( $allPages, $recent_number, $individual );
133 self::render_pending_posts( $allPages, $recent_number, $individual );
134 self::render_future_posts( $allPages, $recent_number, $individual );
135 self::render_trash_posts( $allPages, $recent_number, $individual );
136 ?>
137 </div>
138 <?php
139 /**
140 * Action: mainwp_recent_pages_after_lists
141 *
142 * Fires after the recent pages lists, before the bottom actions section.
143 *
144 * @since 4.1
145 */
146 do_action( 'mainwp_recent_pages_after_lists' );
147
148 ?>
149
150 <div class="ui stackable grid mainwp-widget-footer">
151 <div class="eight wide column">
152 <a href="<?php echo esc_url( admin_url( 'admin.php?page=PageBulkManage' ) ); ?>" title="" class="ui button fluid mini green basic"><?php esc_html_e( 'Manage Pages', 'mainwp' ); ?></a>
153 </div>
154 <div class="eight wide column right aligned">
155 <a href="<?php echo esc_url( admin_url( 'admin.php?page=PageBulkAdd' ) ); ?>" title="" class="ui button fluid mini green"><?php esc_html_e( 'New Page', 'mainwp' ); ?></a>
156 </div>
157 </div>
158 <?php
159 /**
160 * Action: mainwp_recent_pages_widget_bottom
161 *
162 * Fires at the bottom of the Recent Pages widget.
163 *
164 * @since 4.1
165 */
166 do_action( 'mainwp_recent_pages_widget_bottom' );
167 }
168
169 /**
170 * Render MainWP Recent Paged Widget Header
171 */
172 public static function render_top_grid() {
173 ?>
174 <div class="ui grid mainwp-widget-header">
175 <div class="twelve wide column">
176 <h3 class="ui header handle-drag">
177 <?php
178 /**
179 * Filter: mainwp_recent_pages_widget_title
180 *
181 * Filters the recent pages widget title text.
182 *
183 * @since 4.1
184 */
185 echo esc_html( apply_filters( 'mainwp_recent_pages_widget_title', esc_html__( 'Recent Pages', 'mainwp' ) ) );
186 ?>
187 <?php if ( isset( $_GET['client_id'] ) ) : // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized ?>
188 <div class="sub header"><?php esc_html_e( 'The most recent pages from the Client websites', 'mainwp' ); ?></div>
189 <?php else : ?>
190 <div class="sub header"><?php esc_html_e( 'The most recent pages from your websites', 'mainwp' ); ?></div>
191 <?php endif; ?>
192 </h3>
193 </div>
194 <div class="four wide column right aligned">
195 <div class="ui dropdown right pointing mainwp-dropdown-tab">
196 <div class="text"><?php esc_html_e( 'Published', 'mainwp' ); ?></div>
197 <i class="dropdown icon"></i>
198 <div class="menu">
199 <a class="item recent_posts_published_lnk" data-tab="page-published" data-value="published" title="<?php esc_attr_e( 'Published', 'mainwp' ); ?>" href="#"><?php esc_html_e( 'Published', 'mainwp' ); ?></a>
200 <a class="item recent_posts_draft_lnk" data-tab="page-draft" data-value="draft" title="<?php esc_attr_e( 'Draft', 'mainwp' ); ?>" href="#"><?php esc_html_e( 'Draft', 'mainwp' ); ?></a>
201 <a class="item recent_posts_pending_lnk" data-tab="page-pending" data-value="pending" title="<?php esc_attr_e( 'Pending', 'mainwp' ); ?>" href="#"><?php esc_html_e( 'Pending', 'mainwp' ); ?></a>
202 <a class="item recent_posts_future_lnk" data-tab="page-future" data-value="future" title="<?php esc_attr_e( 'Scheduled', 'mainwp' ); ?>" href="#"><?php esc_html_e( 'Scheduled', 'mainwp' ); ?></a>
203 <a class="item recent_posts_trash_lnk" data-tab="page-trash" data-value="trash" title="<?php esc_attr_e( 'Trash', 'mainwp' ); ?>" href="#"><?php esc_html_e( 'Trash', 'mainwp' ); ?></a>
204 </div>
205 </div>
206 </div>
207 </div>
208 <?php
209 }
210
211 /**
212 * Render Published Pages.
213 *
214 * @param array $allPages All pages data.
215 * @param int $recent_number Number of posts.
216 * @param bool $individual Determins if it's individual site dashbaord.
217 *
218 * @uses \MainWP\Dashboard\MainWP_Utility::get_sub_array_having()
219 * @uses \MainWP\Dashboard\MainWP_Utility::sortmulti()
220 * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
221 * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp()
222 */
223 public static function render_published_posts( $allPages, $recent_number, $individual ) {
224 $recent_pages_published = MainWP_Utility::get_sub_array_having( $allPages, 'status', 'publish' );
225 $recent_pages_published = MainWP_Utility::sortmulti( $recent_pages_published, 'dts', 'desc' );
226 $is_demo = MainWP_Demo_Handle::is_demo_mode();
227 ?>
228 <div class="recent_posts_published ui tab active" data-tab="page-published">
229 <?php
230 /**
231 * Action: mainwp_recent_pages_before_publised_list
232 *
233 * Fires before the list of recent published Pages.
234 *
235 * @param array $allPages All pages data.
236 * @param int $recent_number Number of posts.
237 *
238 * @since 4.1
239 */
240 do_action( 'mainwp_recent_pages_before_publised_list', $allPages, $recent_number );
241 if ( 0 === count( $recent_pages_published ) ) :
242 ?>
243 <h2 class="ui icon header">
244 <i class="folder open outline icon"></i>
245 <div class="content">
246 <?php esc_html_e( 'No pages found!', 'mainwp' ); ?>
247 </div>
248 </h2>
249 <?php endif; ?>
250 <div class="ui middle aligned divided selection list">
251 <?php
252 $_count = count( $recent_pages_published );
253 for ( $i = 0; $i < $_count && $i < $recent_number; $i++ ) {
254 if ( ! isset( $recent_pages_published[ $i ]['title'] ) || empty( $recent_pages_published[ $i ]['title'] ) ) {
255 $recent_pages_published[ $i ]['title'] = '(No Title)';
256 }
257 if ( isset( $recent_pages_published[ $i ]['dts'] ) ) {
258 if ( ! stristr( $recent_pages_published[ $i ]['dts'], '-' ) ) {
259 $recent_pages_published[ $i ]['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $recent_pages_published[ $i ]['dts'] ) );
260 }
261 }
262
263 $name = wp_strip_all_tags( $recent_pages_published[ $i ]['website']->name );
264
265 ?>
266 <div class="item">
267 <div class="ui stackable grid">
268 <input class="postId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_published[ $i ]['id'] ); ?>"/>
269 <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_published[ $i ]['website']->id ); ?>"/>
270 <div class="<?php echo $individual ? 'fourteen' : 'ten'; ?> wide column middle aligned">
271 <div><a href="<?php echo esc_url( $recent_pages_published[ $i ]['website']->url ); ?>?p=<?php echo esc_attr( $recent_pages_published[ $i ]['id'] ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo esc_html( htmlentities( $recent_pages_published[ $i ]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8' ) ); ?></a></div>
272 <span class="ui small text"><?php echo esc_html( $recent_pages_published[ $i ]['dts'] ); ?></span>
273 </div>
274 <?php if ( ! $individual ) : ?>
275 <div class="four wide column middle aligned">
276 <a href="<?php echo esc_url( $recent_pages_published[ $i ]['website']->url ); ?>" target="_blank"><?php echo $name; // phpcs:ignore WordPress.Security.EscapeOutput ?></a>
277 </div>
278 <?php endif; ?>
279 <div class="two wide column right aligned">
280 <div class="ui right pointing dropdown icon mini basic green button mainwp-768-hide" style="z-index:999">
281 <i class="ellipsis horizontal icon"></i>
282 <div class="menu">
283 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-unpublish" href="#"><?php esc_html_e( 'Unpublish', 'mainwp' ); ?></a>
284 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo esc_attr( $recent_pages_published[ $i ]['website']->id ); ?>&location=<?php echo esc_html( base64_encode( 'post.php?action=editpost&post=' . esc_attr( $recent_pages_published[ $i ]['id'] ) . '&action=edit' ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" title="Edit this post" target="_blank"><?php esc_html_e( 'Edit', 'mainwp' ); ?></a>
285 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-trash" href="#" ><?php esc_html_e( 'Trash', 'mainwp' ); ?></a>
286 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item" href="<?php echo esc_url( $recent_pages_published[ $i ]['website']->url ) . ( substr( $recent_pages_published[ $i ]['website']->url, - 1 ) !== '/' ? '/' : '' ) . '?p=' . esc_attr( $recent_pages_published[ $i ]['id'] ); ?>" target="_blank" class="mainwp-may-hide-referrer" title="View '<?php echo esc_attr( $recent_pages_published[ $i ]['title'] ); ?>'" rel="permalink"><?php esc_html_e( 'View', 'mainwp' ); ?></a>
287 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-viewall" href="admin.php?page=PageBulkManage" ><?php esc_html_e( 'View all', 'mainwp' ); ?></a>
288 </div>
289 </div>
290 </div>
291 </div>
292 <div class="mainwp-row-actions-working"><i class="notched circle loading icon"></i><?php esc_html_e( 'Please wait...', 'mainwp' ); ?></div>
293 </div>
294 <?php } ?>
295 </div>
296 <?php
297 /**
298 * Action: mainwp_recent_pages_after_publised_list
299 *
300 * Fires after the list of recent published Pages.
301 *
302 * @param array $allPages All pages data.
303 * @param int $recent_number Number of pages.
304 *
305 * @since 4.1
306 */
307 do_action( 'mainwp_recent_pages_after_publised_list', $allPages, $recent_number );
308 ?>
309 </div>
310 <?php
311 }
312
313 /**
314 * Render all draft pages.
315 *
316 * @param array $allPages All pages data.
317 * @param int $recent_number Number of pages.
318 * @param bool $individual Determins if it's individual site dashbaord.
319 *
320 * @uses \MainWP\Dashboard\MainWP_Utility::get_sub_array_having()
321 * @uses \MainWP\Dashboard\MainWP_Utility::sortmulti()
322 * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
323 * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp()
324 */
325 public static function render_draft_posts( $allPages, $recent_number, $individual ) {
326 $recent_pages_draft = MainWP_Utility::get_sub_array_having( $allPages, 'status', 'draft' );
327 $recent_pages_draft = MainWP_Utility::sortmulti( $recent_pages_draft, 'dts', 'desc' );
328 $is_demo = MainWP_Demo_Handle::is_demo_mode();
329 ?>
330 <div class="recent_posts_draft ui tab" data-tab="page-draft">
331 <?php
332 /**
333 * Action: mainwp_recent_pages_before_draft_list
334 *
335 * Fires before the list of recent draft Pages.
336 *
337 * @param array $allPages All pages data.
338 * @param int $recent_number Number of pages.
339 *
340 * @since 4.1
341 */
342 do_action( 'mainwp_recent_pages_before_draft_list', $allPages, $recent_number );
343 if ( 0 === count( $recent_pages_draft ) ) {
344 ?>
345 <h2 class="ui icon header">
346 <i class="folder open outline icon"></i>
347 <div class="content">
348 <?php esc_html_e( 'No draft pages found!', 'mainwp' ); ?>
349 </div>
350 </h2>
351 <?php
352 }
353 ?>
354 <div class="ui middle aligned divided selection list">
355 <?php
356 $_count = count( $recent_pages_draft );
357 for ( $i = 0; $i < $_count && $i < $recent_number; $i++ ) {
358 if ( ! isset( $recent_pages_draft[ $i ]['title'] ) || empty( $recent_pages_draft[ $i ]['title'] ) ) {
359 $recent_pages_draft[ $i ]['title'] = '(No Title)';
360 }
361 if ( isset( $recent_pages_draft[ $i ]['dts'] ) ) {
362 if ( ! stristr( $recent_pages_draft[ $i ]['dts'], '-' ) ) {
363 $recent_pages_draft[ $i ]['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $recent_pages_draft[ $i ]['dts'] ) );
364 }
365 }
366 $name = wp_strip_all_tags( $recent_pages_draft[ $i ]['website']->name );
367 ?>
368 <div class="item">
369 <div class="ui stackable grid">
370 <input class="postId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_draft[ $i ]['id'] ); ?>"/>
371 <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_draft[ $i ]['website']->id ); ?>"/>
372 <div class="six wide column middle aligned">
373 <a href="<?php echo esc_url( $recent_pages_draft[ $i ]['website']->url ); ?>?p=<?php echo esc_attr( $recent_pages_draft[ $i ]['id'] ); ?>" target="_blank" class="mainwp-may-hide-referrer" ><?php echo esc_html( htmlentities( $recent_pages_draft[ $i ]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8' ) ); ?></a>
374 </div>
375 <div class="<?php echo $individual ? 'eight' : 'four'; ?> wide column middle aligned">
376 <?php echo esc_html( $recent_pages_draft[ $i ]['dts'] ); ?>
377 </div>
378 <?php if ( ! $individual ) : ?>
379 <div class="four wide column middle aligned">
380 <a href="<?php echo esc_url( $recent_pages_draft[ $i ]['website']->url ); ?>" target="_blank" class="mainwp-may-hide-referrer" ><?php echo $name; // phpcs:ignore WordPress.Security.EscapeOutput ?></a>
381 </div>
382 <?php endif; ?>
383 <div class="two wide column right aligned">
384 <div class="ui right pointing dropdown icon mini basic green button mainwp-768-hide" style="z-index:999">
385 <i class="ellipsis horizontal icon"></i>
386 <div class="menu">
387 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-publish" href="#"><?php esc_html_e( 'Publish', 'mainwp' ); ?></a>
388 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo intval( $recent_pages_draft[ $i ]['website']->id ); ?>&location=<?php echo esc_html( base64_encode( 'post.php?action=editpost&post=' . $recent_pages_draft[ $i ]['id'] . '&action=edit' ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" title="Edit this post" target="_blank"><?php esc_html_e( 'Edit', 'mainwp' ); ?></a>
389 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-trash" href="#"><?php esc_html_e( 'Trash', 'mainwp' ); ?></a>
390 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-viewall" href="admin.php?page=PostBulkManage"><?php esc_html_e( 'View all', 'mainwp' ); ?></a>
391 </div>
392 </div>
393 </div>
394 </div>
395 <div class="mainwp-row-actions-working"><i class="notched circle loading icon"></i><?php esc_html_e( 'Please wait...', 'mainwp' ); ?></div>
396 </div>
397 <?php } ?>
398 </div>
399 <?php
400 /**
401 * Action: mainwp_recent_pages_after_draft_list
402 *
403 * Fires after the list of recent draft Pages.
404 *
405 * @param array $allPages All pages data.
406 * @param int $recent_number Number of pages.
407 *
408 * @since 4.1
409 */
410 do_action( 'mainwp_recent_pages_after_draft_list', $allPages, $recent_number );
411 ?>
412 </div>
413 <?php
414 }
415
416 /**
417 * Render all pending pages.
418 *
419 * @param array $allPages All pages data.
420 * @param int $recent_number Number of pages.
421 * @param bool $individual Determins if it's individual site dashbaord.
422 *
423 * @uses \MainWP\Dashboard\MainWP_Utility::get_sub_array_having()
424 * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
425 * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp()
426 */
427 public static function render_pending_posts( $allPages, $recent_number, $individual ) {
428 $recent_pages_pending = MainWP_Utility::get_sub_array_having( $allPages, 'status', 'pending' );
429 $recent_pages_pending = MainWP_Utility::sortmulti( $recent_pages_pending, 'dts', 'desc' );
430 $is_demo = MainWP_Demo_Handle::is_demo_mode();
431 ?>
432 <div class="recent_posts_pending ui bottom attached tab" data-tab="page-pending">
433 <?php
434 /**
435 * Action: mainwp_recent_pages_before_pending_list
436 *
437 * Fires before the list of recent pending pages.
438 *
439 * @param array $allPages All pages data.
440 * @param int $recent_number Number of pages.
441 *
442 * @since 4.1
443 */
444 do_action( 'mainwp_recent_pages_before_pending_list', $allPages, $recent_number );
445 if ( 0 === count( $recent_pages_pending ) ) {
446 ?>
447 <h2 class="ui icon header">
448 <i class="folder open outline icon"></i>
449 <div class="content">
450 <?php esc_html_e( 'No pending pages found!', 'mainwp' ); ?>
451 </div>
452 </h2>
453 <?php
454 }
455 ?>
456 <div class="ui middle aligned divided selection list">
457 <?php
458 $_count = count( $recent_pages_pending );
459 for ( $i = 0; $i < $_count && $i < $recent_number; $i++ ) {
460 if ( ! isset( $recent_pages_pending[ $i ]['title'] ) || empty( $recent_pages_pending[ $i ]['title'] ) ) {
461 $recent_pages_pending[ $i ]['title'] = '(No Title)';
462 }
463 if ( isset( $recent_pages_pending[ $i ]['dts'] ) ) {
464 if ( ! stristr( $recent_pages_pending[ $i ]['dts'], '-' ) ) {
465 $recent_pages_pending[ $i ]['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $recent_pages_pending[ $i ]['dts'] ) );
466 }
467 }
468 $name = wp_strip_all_tags( $recent_pages_pending[ $i ]['website']->name );
469 ?>
470 <div class="item">
471 <div class="ui stackable grid">
472 <input class="postId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_pending[ $i ]['id'] ); ?>"/>
473 <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_pending[ $i ]['website']->id ); ?>"/>
474 <div class="six wide column middle aligned">
475 <a href="<?php echo esc_url( $recent_pages_pending[ $i ]['website']->url ); ?>?p=<?php echo esc_attr( $recent_pages_pending[ $i ]['id'] ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo esc_html( htmlentities( $recent_pages_pending[ $i ]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8' ) ); ?></a>
476 </div>
477 <div class="<?php echo $individual ? 'eight' : 'four'; ?> wide column middle aligned">
478 <?php echo esc_html( $recent_pages_pending[ $i ]['dts'] ); ?>
479 </div>
480 <?php if ( ! $individual ) : ?>
481 <div class="four wide column middle aligned">
482 <a href="<?php echo esc_url( $recent_pages_pending[ $i ]['website']->url ); ?>" class="mainwp-may-hide-referrer" target="_blank" ><?php echo $name; // phpcs:ignore WordPress.Security.EscapeOutput ?></a>
483 </div>
484 <?php endif; ?>
485 <div class="two wide column right aligned">
486 <div class="ui right pointing dropdown icon mini basic green button mainwp-768-hide" style="z-index:999">
487 <i class="ellipsis horizontal icon"></i>
488 <div class="menu">
489 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-publish" href="#"><?php esc_html_e( 'Publish', 'mainwp' ); ?></a>
490 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo intval( $recent_pages_pending[ $i ]['website']->id ); ?>&location=<?php echo esc_html( base64_encode( 'post.php?action=editpost&post=' . $recent_pages_pending[ $i ]['id'] . '&action=edit' ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" title="Edit this post" target="_blank"><?php esc_html_e( 'Edit', 'mainwp' ); ?></a>
491 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-trash" href="#"><?php esc_html_e( 'Trash', 'mainwp' ); ?></a>
492 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-viewall" href="admin.php?page=PostBulkManage"><?php esc_html_e( 'View all', 'mainwp' ); ?></a>
493 </div>
494 </div>
495 </div>
496 </div>
497 <div class="mainwp-row-actions-working"><i class="notched circle loading icon"></i><?php esc_html_e( 'Please wait...', 'mainwp' ); ?></div>
498 </div>
499 <?php } ?>
500 </div>
501 <?php
502 /**
503 * Action: mainwp_recent_pages_after_pending_list
504 *
505 * Fires after the list of recent pending pages.
506 *
507 * @param array $allPages All pages data.
508 * @param int $recent_number Number of pages.
509 *
510 * @since 4.1
511 */
512 do_action( 'mainwp_recent_pages_after_pending_list', $allPages, $recent_number );
513 ?>
514 </div>
515 <?php
516 }
517
518 /**
519 * Render all future pages.
520 *
521 * @param array $allPages All pages data.
522 * @param int $recent_number Number of pages.
523 * @param bool $individual Determins if it's individual site dashbaord .
524 *
525 * @uses \MainWP\Dashboard\MainWP_Utility::get_sub_array_having()
526 * @uses \MainWP\Dashboard\MainWP_Utility::sortmulti()
527 * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
528 * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp()
529 */
530 public static function render_future_posts( $allPages, $recent_number, $individual ) {
531 $recent_pages_future = MainWP_Utility::get_sub_array_having( $allPages, 'status', 'future' );
532 $recent_pages_future = MainWP_Utility::sortmulti( $recent_pages_future, 'dts', 'desc' );
533 $is_demo = MainWP_Demo_Handle::is_demo_mode();
534 ?>
535 <div class="recent_posts_future ui tab" data-tab="page-future">
536 <?php
537 /**
538 * Action: mainwp_recent_pages_before_future_list
539 *
540 * Fires before the list of recent future Pages.
541 *
542 * @param array $allPages All pages data.
543 * @param int $recent_number Number of pages.
544 *
545 * @since 4.1
546 */
547 do_action( 'mainwp_recent_pages_before_future_list', $allPages, $recent_number );
548 if ( 0 === count( $recent_pages_future ) ) {
549 ?>
550 <h2 class="ui icon header">
551 <i class="folder open outline icon"></i>
552 <div class="content">
553 <?php esc_html_e( 'No future pages found!', 'mainwp' ); ?>
554 </div>
555 </h2>
556 <?php
557 }
558 ?>
559 <div class="ui middle aligned divided selection list">
560 <?php
561 $_count = count( $recent_pages_future );
562 for ( $i = 0; $i < $_count && $i < $recent_number; $i++ ) {
563 if ( ! isset( $recent_pages_future[ $i ]['title'] ) || empty( $recent_pages_future[ $i ]['title'] ) ) {
564 $recent_pages_future[ $i ]['title'] = '(No Title)';
565 }
566 if ( isset( $recent_pages_future[ $i ]['dts'] ) ) {
567 if ( ! stristr( $recent_pages_future[ $i ]['dts'], '-' ) ) {
568 $recent_pages_future[ $i ]['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $recent_pages_future[ $i ]['dts'] ) );
569 }
570 }
571 $name = wp_strip_all_tags( $recent_pages_future[ $i ]['website']->name );
572 ?>
573 <div class="item">
574 <div class="ui stackable grid">
575 <input class="postId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_future[ $i ]['id'] ); ?>"/>
576 <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_future[ $i ]['website']->id ); ?>"/>
577 <div class="six wide column middle aligned">
578 <a href="<?php echo esc_url( $recent_pages_future[ $i ]['website']->url ); ?>?p=<?php echo esc_attr( $recent_pages_future[ $i ]['id'] ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo esc_html( htmlentities( $recent_pages_future[ $i ]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8' ) ); ?></a>
579 </div>
580 <div class="<?php echo $individual ? 'eight' : 'four'; ?> wide column middle aligned">
581 <?php echo esc_html( $recent_pages_future[ $i ]['dts'] ); ?>
582 </div>
583 <?php if ( ! $individual ) : ?>
584 <div class="four wide column middle aligned">
585 <a href="<?php echo esc_url( $recent_pages_future[ $i ]['website']->url ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo $name; // phpcs:ignore WordPress.Security.EscapeOutput ?></a>
586 </div>
587 <?php endif; ?>
588 <div class="two wide column right aligned">
589 <div class="ui right pointing dropdown icon mini basic green button mainwp-768-hide" style="z-index:999">
590 <i class="ellipsis horizontal icon"></i>
591 <div class="menu">
592 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-publish" href="#"><?php esc_html_e( 'Publish', 'mainwp' ); ?></a>
593 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo esc_attr( $recent_pages_future[ $i ]['website']->id ); ?>&location=<?php echo esc_html( base64_encode( 'post.php?action=editpost&post=' . $recent_pages_future[ $i ]['id'] . '&action=edit' ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" title="Edit this post" target="_blank"><?php esc_html_e( 'Edit', 'mainwp' ); ?></a>
594 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-trash" href="#"><?php esc_html_e( 'Trash', 'mainwp' ); ?></a>
595 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo esc_attr( $recent_pages_future[ $i ]['website']->id ); ?>&newWindow=yes&openUrl=yes&location=<?php echo esc_html( base64_encode( '?p=' . $recent_pages_future[ $i ]['id'] . '&preview=true' ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" target="_blank" title="Preview '< ? php echo esc_attr( $recent_pages_future[ $i ]['title'] ); ?>'" rel="permalink"><?php esc_html_e( 'Preview', 'mainwp' ); ?></a>
596 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-viewall" href="admin.php?page=PostBulkManage"><?php esc_html_e( 'View all', 'mainwp' ); ?></a>
597 </div>
598 </div>
599 </div>
600 </div>
601 <div class="mainwp-row-actions-working"><i class="notched circle loading icon"></i><?php esc_html_e( 'Please wait...', 'mainwp' ); ?></div>
602 </div>
603 <?php } ?>
604 </div>
605 <?php
606 /**
607 * Action: mainwp_recent_pages_after_future_list
608 *
609 * Fires after the list of recent future Pages.
610 *
611 * @param array $allPages All pages data.
612 * @param int $recent_number Number of pages.
613 *
614 * @since 4.1
615 */
616 do_action( 'mainwp_recent_pages_after_future_list', $allPages, $recent_number );
617 ?>
618 </div>
619 <?php
620 }
621
622 /**
623 * Render all trashed pages.
624 *
625 * @param array $allPages All pages data.
626 * @param int $recent_number Number of pages.
627 * @param bool $individual Determins if it's individual site dashbaord.
628 *
629 * @uses \MainWP\Dashboard\MainWP_Utility::get_sub_array_having()
630 * @uses \MainWP\Dashboard\MainWP_Utility::sortmulti()
631 * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
632 * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp()
633 */
634 public static function render_trash_posts( $allPages, $recent_number, $individual ) {
635 $recent_pages_trash = MainWP_Utility::get_sub_array_having( $allPages, 'status', 'trash' );
636 $recent_pages_trash = MainWP_Utility::sortmulti( $recent_pages_trash, 'dts', 'desc' );
637 $is_demo = MainWP_Demo_Handle::is_demo_mode();
638 ?>
639 <div class="recent_posts_trash ui tab" data-tab="page-trash">
640 <?php
641 /**
642 * Action: mainwp_recent_pages_before_trash_list
643 *
644 * Fires before the list of recent trash Pages.
645 *
646 * @param array $allPages All pages data.
647 * @param int $recent_number Number of pages.
648 *
649 * @since 4.1
650 */
651 do_action( 'mainwp_recent_pages_before_trash_list', $allPages, $recent_number );
652 if ( 0 === count( $recent_pages_trash ) ) {
653 ?>
654 <h2 class="ui icon header">
655 <i class="folder open outline icon"></i>
656 <div class="content">
657 <?php esc_html_e( 'No trashed pages found!', 'mainwp' ); ?>
658 </div>
659 </h2>
660 <?php
661 }
662 ?>
663 <div class="ui middle aligned divided selection list">
664 <?php
665 $_count = count( $recent_pages_trash );
666 for ( $i = 0; $i < $_count && $i < $recent_number; $i++ ) {
667 if ( ! isset( $recent_pages_trash[ $i ]['title'] ) || empty( $recent_pages_trash[ $i ]['title'] ) ) {
668 $recent_pages_trash[ $i ]['title'] = '(No Title)';
669 }
670 if ( isset( $recent_pages_trash[ $i ]['dts'] ) ) {
671 if ( ! stristr( $recent_pages_trash[ $i ]['dts'], '-' ) ) {
672 $recent_pages_trash[ $i ]['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $recent_pages_trash[ $i ]['dts'] ) );
673 }
674 }
675 $name = wp_strip_all_tags( $recent_pages_trash[ $i ]['website']->name );
676 ?>
677 <div class="item">
678 <div class="ui stackable grid">
679 <input class="postId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_trash[ $i ]['id'] ); ?>"/>
680 <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_trash[ $i ]['website']->id ); ?>"/>
681 <div class="six wide column middle aligned">
682 <?php echo esc_html( $recent_pages_trash[ $i ]['title'] ); ?>
683 </div>
684 <div class="<?php echo $individual ? 'eight' : 'four'; ?> wide column middle aligned">
685 <?php echo esc_html( $recent_pages_trash[ $i ]['dts'] ); ?>
686 </div>
687 <?php
688 if ( ! $individual ) :
689 ?>
690 <div class="four wide column middle aligned">
691 <?php echo $name; // phpcs:ignore WordPress.Security.EscapeOutput ?>
692 </div>
693 <?php endif; ?>
694 <div class="two wide column right aligned">
695 <div class="ui right pointing dropdown icon mini basic green button mainwp-768-hide" style="z-index:999">
696 <i class="ellipsis horizontal icon"></i>
697 <div class="menu">
698 <a href="#" class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-restore"><?php esc_html_e( 'Restore', 'mainwp' ); ?></a>
699 <a href="#" class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-delete"><?php esc_html_e( 'Delete permanently', 'mainwp' ); ?></a>
700 </div>
701 </div>
702 </div>
703 </div>
704 <div class="mainwp-row-actions-working"><i class="notched circle loading icon"></i><?php esc_html_e( 'Please wait...', 'mainwp' ); ?></div>
705 </div>
706 <?php } ?>
707 </div>
708 <?php
709 /**
710 * Action: mainwp_recent_pages_after_trash_list
711 *
712 * Fires after the list of recent trash Pages.
713 *
714 * @param array $allPages All pages data.
715 * @param int $recent_number Number of pages.
716 *
717 * @since 4.1
718 */
719 do_action( 'mainwp_recent_pages_after_trash_list', $allPages, $recent_number );
720 ?>
721 </div>
722 <?php
723 }
724 }
725