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