PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.0.3.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.0.3.2
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 5.2.2 5.3 All 153 releases
mainwp / widgets / widget-mainwp-recent-pages.php

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

682 lines 32.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 MainWP_UI::render_empty_element_placeholder();
243 endif;
244 ?>
245 <div class="ui middle aligned divided selection list">
246 <?php
247 $_count = count( $recent_pages_published );
248 for ( $i = 0; $i < $_count && $i < $recent_number; $i++ ) {
249 if ( ! isset( $recent_pages_published[ $i ]['title'] ) || empty( $recent_pages_published[ $i ]['title'] ) ) {
250 $recent_pages_published[ $i ]['title'] = '(No Title)';
251 }
252 if ( isset( $recent_pages_published[ $i ]['dts'] ) ) {
253 if ( ! stristr( $recent_pages_published[ $i ]['dts'], '-' ) ) {
254 $recent_pages_published[ $i ]['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $recent_pages_published[ $i ]['dts'] ) );
255 }
256 }
257
258 $name = wp_strip_all_tags( $recent_pages_published[ $i ]['website']->name );
259
260 ?>
261 <div class="item">
262 <div class="ui stackable grid">
263 <input class="postId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_published[ $i ]['id'] ); ?>"/>
264 <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_published[ $i ]['website']->id ); ?>"/>
265 <div class="fourteen wide column middle aligned">
266 <div>
267 <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>
268 <?php if ( ! $individual ) : ?>
269 <?php esc_html_e( 'on', 'mainwp' ); ?> <a href="<?php echo esc_url( $recent_pages_published[ $i ]['website']->url ); ?>" target="_blank"><?php echo $name; // phpcs:ignore WordPress.Security.EscapeOutput ?></a>
270 <?php endif; ?>
271 </div>
272 <span class="ui small text"><?php echo esc_html( $recent_pages_published[ $i ]['dts'] ); ?></span>
273 </div>
274 <div class="two wide column right aligned">
275 <div class="ui right pointing dropdown icon mini basic green button" style="z-index:999">
276 <i class="ellipsis horizontal icon"></i>
277 <div class="menu">
278 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-unpublish" href="#"><?php esc_html_e( 'Unpublish', 'mainwp' ); ?></a>
279 <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>
280 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-trash" href="#" ><?php esc_html_e( 'Trash', 'mainwp' ); ?></a>
281 <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>
282 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-viewall" href="admin.php?page=PageBulkManage" ><?php esc_html_e( 'View all', 'mainwp' ); ?></a>
283 </div>
284 </div>
285 </div>
286 </div>
287 <div class="mainwp-row-actions-working"><i class="notched circle loading icon"></i><?php esc_html_e( 'Please wait...', 'mainwp' ); ?></div>
288 </div>
289 <?php } ?>
290 </div>
291 <?php
292 /**
293 * Action: mainwp_recent_pages_after_publised_list
294 *
295 * Fires after the list of recent published Pages.
296 *
297 * @param array $allPages All pages data.
298 * @param int $recent_number Number of pages.
299 *
300 * @since 4.1
301 */
302 do_action( 'mainwp_recent_pages_after_publised_list', $allPages, $recent_number );
303 ?>
304 </div>
305 <?php
306 }
307
308 /**
309 * Render all draft pages.
310 *
311 * @param array $allPages All pages data.
312 * @param int $recent_number Number of pages.
313 * @param bool $individual Determins if it's individual site dashbaord.
314 *
315 * @uses \MainWP\Dashboard\MainWP_Utility::get_sub_array_having()
316 * @uses \MainWP\Dashboard\MainWP_Utility::sortmulti()
317 * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
318 * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp()
319 */
320 public static function render_draft_posts( $allPages, $recent_number, $individual ) {
321 $recent_pages_draft = MainWP_Utility::get_sub_array_having( $allPages, 'status', 'draft' );
322 $recent_pages_draft = MainWP_Utility::sortmulti( $recent_pages_draft, 'dts', 'desc' );
323 $is_demo = MainWP_Demo_Handle::is_demo_mode();
324 ?>
325 <div class="recent_posts_draft ui tab" data-tab="page-draft">
326 <?php
327 /**
328 * Action: mainwp_recent_pages_before_draft_list
329 *
330 * Fires before the list of recent draft Pages.
331 *
332 * @param array $allPages All pages data.
333 * @param int $recent_number Number of pages.
334 *
335 * @since 4.1
336 */
337 do_action( 'mainwp_recent_pages_before_draft_list', $allPages, $recent_number );
338 if ( 0 === count( $recent_pages_draft ) ) {
339 MainWP_UI::render_empty_element_placeholder();
340 }
341 ?>
342 <div class="ui middle aligned divided selection list">
343 <?php
344 $_count = count( $recent_pages_draft );
345 for ( $i = 0; $i < $_count && $i < $recent_number; $i++ ) {
346 if ( ! isset( $recent_pages_draft[ $i ]['title'] ) || empty( $recent_pages_draft[ $i ]['title'] ) ) {
347 $recent_pages_draft[ $i ]['title'] = '(No Title)';
348 }
349 if ( isset( $recent_pages_draft[ $i ]['dts'] ) ) {
350 if ( ! stristr( $recent_pages_draft[ $i ]['dts'], '-' ) ) {
351 $recent_pages_draft[ $i ]['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $recent_pages_draft[ $i ]['dts'] ) );
352 }
353 }
354 $name = wp_strip_all_tags( $recent_pages_draft[ $i ]['website']->name );
355 ?>
356 <div class="item">
357 <div class="ui stackable grid">
358 <input class="postId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_draft[ $i ]['id'] ); ?>"/>
359 <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_draft[ $i ]['website']->id ); ?>"/>
360 <div class="fourteen wide column middle aligned">
361 <div>
362 <a href="<?php echo esc_url( $recent_pages_draft[ $i ]['website']->url ); ?>?p=<?php echo esc_attr( $recent_pages_draft[ $i ]['id'] ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo esc_html( htmlentities( $recent_pages_draft[ $i ]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8' ) ); ?></a>
363 <?php if ( ! $individual ) : ?>
364 <?php esc_html_e( 'on', 'mainwp' ); ?> <a href="<?php echo esc_url( $recent_pages_draft[ $i ]['website']->url ); ?>" target="_blank"><?php echo $name; // phpcs:ignore WordPress.Security.EscapeOutput ?></a>
365 <?php endif; ?>
366 </div>
367 <span class="ui small text"><?php echo esc_html( $recent_pages_draft[ $i ]['dts'] ); ?></span>
368 </div>
369 <div class="two wide column right aligned">
370 <div class="ui right pointing dropdown icon mini basic green button" style="z-index:999">
371 <i class="ellipsis horizontal icon"></i>
372 <div class="menu">
373 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-publish" href="#"><?php esc_html_e( 'Publish', 'mainwp' ); ?></a>
374 <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>
375 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-trash" href="#"><?php esc_html_e( 'Trash', 'mainwp' ); ?></a>
376 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-viewall" href="admin.php?page=PostBulkManage"><?php esc_html_e( 'View all', 'mainwp' ); ?></a>
377 </div>
378 </div>
379 </div>
380 </div>
381 <div class="mainwp-row-actions-working"><i class="notched circle loading icon"></i><?php esc_html_e( 'Please wait...', 'mainwp' ); ?></div>
382 </div>
383 <?php } ?>
384 </div>
385 <?php
386 /**
387 * Action: mainwp_recent_pages_after_draft_list
388 *
389 * Fires after the list of recent draft Pages.
390 *
391 * @param array $allPages All pages data.
392 * @param int $recent_number Number of pages.
393 *
394 * @since 4.1
395 */
396 do_action( 'mainwp_recent_pages_after_draft_list', $allPages, $recent_number );
397 ?>
398 </div>
399 <?php
400 }
401
402 /**
403 * Render all pending pages.
404 *
405 * @param array $allPages All pages data.
406 * @param int $recent_number Number of pages.
407 * @param bool $individual Determins if it's individual site dashbaord.
408 *
409 * @uses \MainWP\Dashboard\MainWP_Utility::get_sub_array_having()
410 * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
411 * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp()
412 */
413 public static function render_pending_posts( $allPages, $recent_number, $individual ) {
414 $recent_pages_pending = MainWP_Utility::get_sub_array_having( $allPages, 'status', 'pending' );
415 $recent_pages_pending = MainWP_Utility::sortmulti( $recent_pages_pending, 'dts', 'desc' );
416 $is_demo = MainWP_Demo_Handle::is_demo_mode();
417 ?>
418 <div class="recent_posts_pending ui bottom attached tab" data-tab="page-pending">
419 <?php
420 /**
421 * Action: mainwp_recent_pages_before_pending_list
422 *
423 * Fires before the list of recent pending pages.
424 *
425 * @param array $allPages All pages data.
426 * @param int $recent_number Number of pages.
427 *
428 * @since 4.1
429 */
430 do_action( 'mainwp_recent_pages_before_pending_list', $allPages, $recent_number );
431 if ( 0 === count( $recent_pages_pending ) ) {
432 MainWP_UI::render_empty_element_placeholder();
433 }
434 ?>
435 <div class="ui middle aligned divided selection list">
436 <?php
437 $_count = count( $recent_pages_pending );
438 for ( $i = 0; $i < $_count && $i < $recent_number; $i++ ) {
439 if ( ! isset( $recent_pages_pending[ $i ]['title'] ) || empty( $recent_pages_pending[ $i ]['title'] ) ) {
440 $recent_pages_pending[ $i ]['title'] = '(No Title)';
441 }
442 if ( isset( $recent_pages_pending[ $i ]['dts'] ) ) {
443 if ( ! stristr( $recent_pages_pending[ $i ]['dts'], '-' ) ) {
444 $recent_pages_pending[ $i ]['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $recent_pages_pending[ $i ]['dts'] ) );
445 }
446 }
447 $name = wp_strip_all_tags( $recent_pages_pending[ $i ]['website']->name );
448 ?>
449 <div class="item">
450 <div class="ui stackable grid">
451 <input class="postId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_pending[ $i ]['id'] ); ?>"/>
452 <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_pending[ $i ]['website']->id ); ?>"/>
453 <div class="fourteen wide column middle aligned">
454 <div>
455 <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>
456 <?php if ( ! $individual ) : ?>
457 <?php esc_html_e( 'on', 'mainwp' ); ?> <a href="<?php echo esc_url( $recent_pages_pending[ $i ]['website']->url ); ?>" target="_blank"><?php echo $name; // phpcs:ignore WordPress.Security.EscapeOutput ?></a>
458 <?php endif; ?>
459 </div>
460 <span class="ui small text"><?php echo esc_html( $recent_pages_pending[ $i ]['dts'] ); ?></span>
461 </div>
462 <div class="two wide column right aligned">
463 <div class="ui right pointing dropdown icon mini basic green button" style="z-index:999">
464 <i class="ellipsis horizontal icon"></i>
465 <div class="menu">
466 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-publish" href="#"><?php esc_html_e( 'Publish', 'mainwp' ); ?></a>
467 <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>
468 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-trash" href="#"><?php esc_html_e( 'Trash', 'mainwp' ); ?></a>
469 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-viewall" href="admin.php?page=PostBulkManage"><?php esc_html_e( 'View all', 'mainwp' ); ?></a>
470 </div>
471 </div>
472 </div>
473 </div>
474 <div class="mainwp-row-actions-working"><i class="notched circle loading icon"></i><?php esc_html_e( 'Please wait...', 'mainwp' ); ?></div>
475 </div>
476 <?php } ?>
477 </div>
478 <?php
479 /**
480 * Action: mainwp_recent_pages_after_pending_list
481 *
482 * Fires after the list of recent pending pages.
483 *
484 * @param array $allPages All pages data.
485 * @param int $recent_number Number of pages.
486 *
487 * @since 4.1
488 */
489 do_action( 'mainwp_recent_pages_after_pending_list', $allPages, $recent_number );
490 ?>
491 </div>
492 <?php
493 }
494
495 /**
496 * Render all future pages.
497 *
498 * @param array $allPages All pages data.
499 * @param int $recent_number Number of pages.
500 * @param bool $individual Determins if it's individual site dashbaord .
501 *
502 * @uses \MainWP\Dashboard\MainWP_Utility::get_sub_array_having()
503 * @uses \MainWP\Dashboard\MainWP_Utility::sortmulti()
504 * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
505 * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp()
506 */
507 public static function render_future_posts( $allPages, $recent_number, $individual ) {
508 $recent_pages_future = MainWP_Utility::get_sub_array_having( $allPages, 'status', 'future' );
509 $recent_pages_future = MainWP_Utility::sortmulti( $recent_pages_future, 'dts', 'desc' );
510 $is_demo = MainWP_Demo_Handle::is_demo_mode();
511 ?>
512 <div class="recent_posts_future ui tab" data-tab="page-future">
513 <?php
514 /**
515 * Action: mainwp_recent_pages_before_future_list
516 *
517 * Fires before the list of recent future Pages.
518 *
519 * @param array $allPages All pages data.
520 * @param int $recent_number Number of pages.
521 *
522 * @since 4.1
523 */
524 do_action( 'mainwp_recent_pages_before_future_list', $allPages, $recent_number );
525 if ( 0 === count( $recent_pages_future ) ) {
526 MainWP_UI::render_empty_element_placeholder();
527 }
528 ?>
529 <div class="ui middle aligned divided selection list">
530 <?php
531 $_count = count( $recent_pages_future );
532 for ( $i = 0; $i < $_count && $i < $recent_number; $i++ ) {
533 if ( ! isset( $recent_pages_future[ $i ]['title'] ) || empty( $recent_pages_future[ $i ]['title'] ) ) {
534 $recent_pages_future[ $i ]['title'] = '(No Title)';
535 }
536 if ( isset( $recent_pages_future[ $i ]['dts'] ) ) {
537 if ( ! stristr( $recent_pages_future[ $i ]['dts'], '-' ) ) {
538 $recent_pages_future[ $i ]['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $recent_pages_future[ $i ]['dts'] ) );
539 }
540 }
541 $name = wp_strip_all_tags( $recent_pages_future[ $i ]['website']->name );
542 ?>
543 <div class="item">
544 <div class="ui stackable grid">
545 <input class="postId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_future[ $i ]['id'] ); ?>"/>
546 <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_future[ $i ]['website']->id ); ?>"/>
547 <div class="fourteen wide column middle aligned">
548 <div>
549 <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>
550 <?php if ( ! $individual ) : ?>
551 <?php esc_html_e( 'on', 'mainwp' ); ?> <a href="<?php echo esc_url( $recent_pages_future[ $i ]['website']->url ); ?>" target="_blank"><?php echo $name; // phpcs:ignore WordPress.Security.EscapeOutput ?></a>
552 <?php endif; ?>
553 </div>
554 <span class="ui small text"><?php echo esc_html( $recent_pages_future[ $i ]['dts'] ); ?></span>
555 </div>
556 <div class="two wide column right aligned">
557 <div class="ui right pointing dropdown icon mini basic green button" style="z-index:999">
558 <i class="ellipsis horizontal icon"></i>
559 <div class="menu">
560 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-publish" href="#"><?php esc_html_e( 'Publish', 'mainwp' ); ?></a>
561 <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>
562 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-trash" href="#"><?php esc_html_e( 'Trash', 'mainwp' ); ?></a>
563 <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>
564 <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-viewall" href="admin.php?page=PostBulkManage"><?php esc_html_e( 'View all', 'mainwp' ); ?></a>
565 </div>
566 </div>
567 </div>
568 </div>
569 <div class="mainwp-row-actions-working"><i class="notched circle loading icon"></i><?php esc_html_e( 'Please wait...', 'mainwp' ); ?></div>
570 </div>
571 <?php } ?>
572 </div>
573 <?php
574 /**
575 * Action: mainwp_recent_pages_after_future_list
576 *
577 * Fires after the list of recent future Pages.
578 *
579 * @param array $allPages All pages data.
580 * @param int $recent_number Number of pages.
581 *
582 * @since 4.1
583 */
584 do_action( 'mainwp_recent_pages_after_future_list', $allPages, $recent_number );
585 ?>
586 </div>
587 <?php
588 }
589
590 /**
591 * Render all trashed pages.
592 *
593 * @param array $allPages All pages data.
594 * @param int $recent_number Number of pages.
595 * @param bool $individual Determins if it's individual site dashbaord.
596 *
597 * @uses \MainWP\Dashboard\MainWP_Utility::get_sub_array_having()
598 * @uses \MainWP\Dashboard\MainWP_Utility::sortmulti()
599 * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
600 * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp()
601 */
602 public static function render_trash_posts( $allPages, $recent_number, $individual ) {
603 $recent_pages_trash = MainWP_Utility::get_sub_array_having( $allPages, 'status', 'trash' );
604 $recent_pages_trash = MainWP_Utility::sortmulti( $recent_pages_trash, 'dts', 'desc' );
605 $is_demo = MainWP_Demo_Handle::is_demo_mode();
606 ?>
607 <div class="recent_posts_trash ui tab" data-tab="page-trash">
608 <?php
609 /**
610 * Action: mainwp_recent_pages_before_trash_list
611 *
612 * Fires before the list of recent trash Pages.
613 *
614 * @param array $allPages All pages data.
615 * @param int $recent_number Number of pages.
616 *
617 * @since 4.1
618 */
619 do_action( 'mainwp_recent_pages_before_trash_list', $allPages, $recent_number );
620 if ( 0 === count( $recent_pages_trash ) ) {
621 MainWP_UI::render_empty_element_placeholder();
622 }
623 ?>
624 <div class="ui middle aligned divided selection list">
625 <?php
626 $_count = count( $recent_pages_trash );
627 for ( $i = 0; $i < $_count && $i < $recent_number; $i++ ) {
628 if ( ! isset( $recent_pages_trash[ $i ]['title'] ) || empty( $recent_pages_trash[ $i ]['title'] ) ) {
629 $recent_pages_trash[ $i ]['title'] = '(No Title)';
630 }
631 if ( isset( $recent_pages_trash[ $i ]['dts'] ) ) {
632 if ( ! stristr( $recent_pages_trash[ $i ]['dts'], '-' ) ) {
633 $recent_pages_trash[ $i ]['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $recent_pages_trash[ $i ]['dts'] ) );
634 }
635 }
636 $name = wp_strip_all_tags( $recent_pages_trash[ $i ]['website']->name );
637 ?>
638 <div class="item">
639 <div class="ui stackable grid">
640 <input class="postId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_trash[ $i ]['id'] ); ?>"/>
641 <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $recent_pages_trash[ $i ]['website']->id ); ?>"/>
642 <div class="fourteen wide column middle aligned">
643 <div>
644 <a href="<?php echo esc_url( $recent_pages_trash[ $i ]['website']->url ); ?>?p=<?php echo esc_attr( $recent_pages_trash[ $i ]['id'] ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo esc_html( htmlentities( $recent_pages_trash[ $i ]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8' ) ); ?></a>
645 <?php if ( ! $individual ) : ?>
646 <?php esc_html_e( 'on', 'mainwp' ); ?> <a href="<?php echo esc_url( $recent_pages_trash[ $i ]['website']->url ); ?>" target="_blank"><?php echo $name; // phpcs:ignore WordPress.Security.EscapeOutput ?></a>
647 <?php endif; ?>
648 </div>
649 <span class="ui small text"><?php echo esc_html( $recent_pages_trash[ $i ]['dts'] ); ?></span>
650 </div>
651 <div class="two wide column right aligned">
652 <div class="ui right pointing dropdown icon mini basic green button" style="z-index:999">
653 <i class="ellipsis horizontal icon"></i>
654 <div class="menu">
655 <a href="#" class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-restore"><?php esc_html_e( 'Restore', 'mainwp' ); ?></a>
656 <a href="#" class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-delete"><?php esc_html_e( 'Delete permanently', 'mainwp' ); ?></a>
657 </div>
658 </div>
659 </div>
660 </div>
661 <div class="mainwp-row-actions-working"><i class="notched circle loading icon"></i><?php esc_html_e( 'Please wait...', 'mainwp' ); ?></div>
662 </div>
663 <?php } ?>
664 </div>
665 <?php
666 /**
667 * Action: mainwp_recent_pages_after_trash_list
668 *
669 * Fires after the list of recent trash Pages.
670 *
671 * @param array $allPages All pages data.
672 * @param int $recent_number Number of pages.
673 *
674 * @since 4.1
675 */
676 do_action( 'mainwp_recent_pages_after_trash_list', $allPages, $recent_number );
677 ?>
678 </div>
679 <?php
680 }
681 }
682