| @@ -8,674 +8,677 @@ | ||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | namespace MainWP\Dashboard; |
| 11 | 11 | |
| 12 | +// Exit if accessed directly. | |
| 13 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 14 | + exit; | |
| 15 | +} | |
| 16 | + | |
| 12 | 17 | /** |
| 13 | 18 | * Class MainWP_Recent_Pages |
| 14 | 19 | * |
| 15 | 20 | * Displays the Child Sites most recent published draft, pending, trash & future Pages. |
| 16 | 21 | */ |
| 17 | -class MainWP_Recent_Pages { | |
| 22 | +class MainWP_Recent_Pages { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR. | |
| 18 | 23 | |
| 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 | - } | |
| 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 | + } | |
| 27 | 32 | |
| 28 | - /** | |
| 29 | - * Method render() | |
| 30 | - * | |
| 31 | - * Fire off Method render_sites(). | |
| 32 | - */ | |
| 33 | - public static function render() { | |
| 34 | - self::render_sites(); | |
| 35 | - } | |
| 33 | + /** | |
| 34 | + * Method render() | |
| 35 | + * | |
| 36 | + * Fire off Method render_sites(). | |
| 37 | + */ | |
| 38 | + public static function render() { | |
| 39 | + static::render_sites(); | |
| 40 | + } | |
| 36 | 41 | |
| 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() { | |
| 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. | |
| 49 | 54 | |
| 50 | - /** This filter is documented in /widgets/widget-mainwp-recent-posts.php */ | |
| 51 | - $recent_number = apply_filters( 'mainwp_recent_posts_pages_number', 5 ); | |
| 55 | + /** This filter is documented in /widgets/widget-mainwp-recent-posts.php */ | |
| 56 | + $recent_number = apply_filters( 'mainwp_recent_posts_pages_number', 5 ); | |
| 52 | 57 | |
| 53 | - $allPages = array(); | |
| 58 | + $allPages = array(); | |
| 54 | 59 | |
| 55 | - $current_wpid = MainWP_System_Utility::get_current_wpid(); | |
| 60 | + $current_wpid = MainWP_System_Utility::get_current_wpid(); | |
| 56 | 61 | |
| 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 ) ); | |
| 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 ) ); | |
| 63 | 68 | |
| 64 | - if ( $websites ) { | |
| 65 | - foreach ( $websites as $website ) { | |
| 66 | - if ( empty( $website->recent_pages ) ) { | |
| 67 | - continue; | |
| 68 | - } | |
| 69 | + if ( $websites ) { | |
| 70 | + foreach ( $websites as $website ) { | |
| 71 | + if ( empty( $website->recent_pages ) ) { | |
| 72 | + continue; | |
| 73 | + } | |
| 69 | 74 | |
| 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 ); | |
| 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 | + } | |
| 93 | 107 | |
| 94 | - if ( $websites ) { | |
| 95 | - while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { | |
| 96 | - if ( empty( $website->recent_pages ) ) { | |
| 97 | - continue; | |
| 98 | - } | |
| 108 | + if ( $websites ) { | |
| 109 | + while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { | |
| 110 | + if ( empty( $website->recent_pages ) ) { | |
| 111 | + continue; | |
| 112 | + } | |
| 99 | 113 | |
| 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 | - } | |
| 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 | + } | |
| 116 | 130 | |
| 117 | - self::render_top_grid(); | |
| 131 | + static::render_top_grid(); | |
| 118 | 132 | |
| 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' ); | |
| 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' ); | |
| 127 | 141 | |
| 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' ); | |
| 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' ); | |
| 147 | 161 | |
| 148 | - ?> | |
| 162 | + ?> | |
| 149 | 163 | |
| 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 | - } | |
| 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 | + } | |
| 168 | 182 | |
| 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 | - } | |
| 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 | + } | |
| 210 | 223 | |
| 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 | - } | |
| 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 | + } | |
| 257 | 268 | |
| 258 | - $name = wp_strip_all_tags( $recent_pages_published[ $i ]['website']->name ); | |
| 269 | + $name = wp_strip_all_tags( $recent_pages_published[ $i ]['website']->name ); | |
| 259 | 270 | |
| 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="fifteen 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="one wide column right aligned"> | |
| 275 | - <div class="ui right pointing dropdown icon mini basic green button mainwp-768-hide" 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 | - } | |
| 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 | + } | |
| 307 | 318 | |
| 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="fifteen 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="one wide column right aligned"> | |
| 370 | - <div class="ui right pointing dropdown icon mini basic green button mainwp-768-hide" 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 | - } | |
| 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 | + } | |
| 401 | 410 | |
| 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="fifteen 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="one wide column right aligned"> | |
| 463 | - <div class="ui right pointing dropdown icon mini basic green button mainwp-768-hide" 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 | - } | |
| 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 | + } | |
| 494 | 501 | |
| 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="fifteen 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="one wide column right aligned"> | |
| 557 | - <div class="ui right pointing dropdown icon mini basic green button mainwp-768-hide" 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 | - } | |
| 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 | + } | |
| 589 | 594 | |
| 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="fifteen 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="one wide column right aligned"> | |
| 652 | - <div class="ui right pointing dropdown icon mini basic green button mainwp-768-hide" 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 | - } | |
| 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 | + } | |
| 681 | 684 | } |