| @@ -37,14 +37,8 @@ | ||
| 37 | 37 | /** |
| 38 | 38 | * Method render_sites() |
| 39 | 39 | * |
| 40 | 40 | * Build the recent posts 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 | 41 | */ |
| 48 | 42 | public static function render_sites() { |
| 49 | 43 | |
| 50 | 44 | /** |
| @@ -55,70 +49,39 @@ | ||
| 55 | 49 | * @since 4.0 |
| 56 | 50 | */ |
| 57 | 51 | $recent_number = apply_filters( 'mainwp_recent_posts_pages_number', 5 ); |
| 58 | 52 | |
| 59 | - $allPosts = array(); | |
| 60 | - | |
| 61 | 53 | $current_wpid = MainWP_System_Utility::get_current_wpid(); |
| 62 | 54 | |
| 63 | - if ( isset( $_GET['client_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.NonceVerification.Missing | |
| 64 | - $data_fields = MainWP_System_Utility::get_default_map_site_fields(); | |
| 65 | - $data_fields[] = 'recent_posts'; | |
| 66 | - $individual = false; | |
| 67 | - $client_id = isset( $_GET['client_id'] ) ? intval( $_GET['client_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.NonceVerification.Missing | |
| 68 | - $websites = MainWP_DB_Client::instance()->get_websites_by_client_ids( $client_id, array( 'select_data' => $data_fields ) ); | |
| 55 | + if ( $current_wpid ) { | |
| 56 | + $sql = MainWP_DB::instance()->get_sql_website_by_id( $current_wpid ); | |
| 57 | + } else { | |
| 58 | + $sql = MainWP_DB::instance()->get_sql_websites_for_current_user(); | |
| 59 | + } | |
| 69 | 60 | |
| 70 | - if ( $websites ) { | |
| 71 | - foreach ( $websites as $website ) { | |
| 72 | - if ( empty( $website->recent_posts ) ) { | |
| 73 | - continue; | |
| 74 | - } | |
| 61 | + $websites = MainWP_DB::instance()->query( $sql ); | |
| 75 | 62 | |
| 76 | - $posts = json_decode( $website->recent_posts, 1 ); | |
| 77 | - if ( 0 === count( $posts ) ) { | |
| 78 | - continue; | |
| 79 | - } | |
| 80 | - foreach ( $posts as $post ) { | |
| 81 | - $post['website'] = (object) array( | |
| 82 | - 'id' => $website->id, | |
| 83 | - 'url' => $website->url, | |
| 84 | - 'name' => $website->name, | |
| 85 | - ); | |
| 86 | - $allPosts[] = $post; | |
| 87 | - } | |
| 63 | + $allPosts = array(); | |
| 64 | + if ( $websites ) { | |
| 65 | + while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { | |
| 66 | + if ( '' == $website->recent_posts ) { | |
| 67 | + continue; | |
| 88 | 68 | } |
| 89 | - } | |
| 90 | - } else { | |
| 91 | - if ( $current_wpid ) { | |
| 92 | - $sql = MainWP_DB::instance()->get_sql_website_by_id( $current_wpid ); | |
| 93 | - $individual = true; | |
| 94 | - } else { | |
| 95 | - $sql = MainWP_DB::instance()->get_sql_websites_for_current_user(); | |
| 96 | - $individual = false; | |
| 97 | - } | |
| 98 | - $websites = MainWP_DB::instance()->query( $sql ); | |
| 99 | 69 | |
| 100 | - if ( $websites ) { | |
| 101 | - while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { | |
| 102 | - if ( empty( $website->recent_posts ) ) { | |
| 103 | - continue; | |
| 104 | - } | |
| 105 | - | |
| 106 | - $posts = json_decode( $website->recent_posts, 1 ); | |
| 107 | - if ( 0 === count( $posts ) ) { | |
| 108 | - continue; | |
| 109 | - } | |
| 110 | - foreach ( $posts as $post ) { | |
| 111 | - $post['website'] = (object) array( | |
| 112 | - 'id' => $website->id, | |
| 113 | - 'url' => $website->url, | |
| 114 | - 'name' => $website->name, | |
| 115 | - ); | |
| 116 | - $allPosts[] = $post; | |
| 117 | - } | |
| 70 | + $posts = json_decode( $website->recent_posts, 1 ); | |
| 71 | + if ( 0 == count( $posts ) ) { | |
| 72 | + continue; | |
| 118 | 73 | } |
| 119 | - MainWP_DB::free_result( $websites ); | |
| 74 | + foreach ( $posts as $post ) { | |
| 75 | + $post['website'] = (object) array( | |
| 76 | + 'id' => $website->id, | |
| 77 | + 'url' => $website->url, | |
| 78 | + 'name' => $website->name, | |
| 79 | + ); | |
| 80 | + $allPosts[] = $post; | |
| 81 | + } | |
| 120 | 82 | } |
| 83 | + MainWP_DB::free_result( $websites ); | |
| 121 | 84 | } |
| 122 | 85 | |
| 123 | 86 | self::render_top_grid(); |
| 124 | 87 | |
| @@ -129,19 +92,15 @@ | ||
| 129 | 92 | * |
| 130 | 93 | * @since 4.1 |
| 131 | 94 | */ |
| 132 | 95 | do_action( 'mainwp_recent_posts_widget_top' ); |
| 133 | - ?> | |
| 134 | - <div class="mainwp-scrolly-overflow"> | |
| 135 | - <?php | |
| 136 | - self::render_published_posts( $allPosts, $recent_number, $individual ); | |
| 137 | - self::render_draft_posts( $allPosts, $recent_number, $individual ); | |
| 138 | - self::render_pending_posts( $allPosts, $recent_number, $individual ); | |
| 139 | - self::render_future_posts( $allPosts, $recent_number, $individual ); | |
| 140 | - self::render_trash_posts( $allPosts, $recent_number, $individual ); | |
| 141 | - ?> | |
| 142 | - </div> | |
| 143 | - <?php | |
| 96 | + | |
| 97 | + self::render_published_posts( $allPosts, $recent_number ); | |
| 98 | + self::render_draft_posts( $allPosts, $recent_number ); | |
| 99 | + self::render_pending_posts( $allPosts, $recent_number ); | |
| 100 | + self::render_future_posts( $allPosts, $recent_number ); | |
| 101 | + self::render_trash_posts( $allPosts, $recent_number ); | |
| 102 | + | |
| 144 | 103 | /** |
| 145 | 104 | * Action: mainwp_recent_posts_after_lists |
| 146 | 105 | * |
| 147 | 106 | * Fires after the recent posts lists, before the bottom actions section. |
| @@ -150,14 +109,17 @@ | ||
| 150 | 109 | */ |
| 151 | 110 | do_action( 'mainwp_recent_posts_after_lists' ); |
| 152 | 111 | ?> |
| 153 | 112 | |
| 154 | - <div class="ui stackable grid mainwp-widget-footer"> | |
| 155 | - <div class="eight wide column"> | |
| 156 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=PostBulkManage' ) ); ?>" title="" class="ui button fluid mini green basic"><?php esc_html_e( 'Manage Posts', 'mainwp' ); ?></a> | |
| 113 | + | |
| 114 | + <div class="ui hidden divider"></div> | |
| 115 | + | |
| 116 | + <div class="ui two column grid"> | |
| 117 | + <div class="column"> | |
| 118 | + <a href="<?php echo admin_url( 'admin.php?page=PostBulkManage' ); ?>" title="" class="ui button green basic"><?php esc_html_e( 'Manage Posts', 'mainwp' ); ?></a> | |
| 157 | 119 | </div> |
| 158 | - <div class="eight wide column right aligned"> | |
| 159 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=PostBulkAdd' ) ); ?>" title="" class="ui button fluid mini green"><?php esc_html_e( 'New Post', 'mainwp' ); ?></a> | |
| 120 | + <div class="column right aligned"> | |
| 121 | + <a href="<?php echo admin_url( 'admin.php?page=PostBulkAdd' ); ?>" title="" class="ui button green"><?php esc_html_e( 'Create New Post', 'mainwp' ); ?></a> | |
| 160 | 122 | </div> |
| 161 | 123 | </div> |
| 162 | 124 | <?php |
| 163 | 125 | /** |
| @@ -174,9 +136,9 @@ | ||
| 174 | 136 | * Render MainWP Recent Posts Widget Header |
| 175 | 137 | */ |
| 176 | 138 | public static function render_top_grid() { |
| 177 | 139 | ?> |
| 178 | - <div class="ui grid mainwp-widget-header"> | |
| 140 | + <div class="ui grid"> | |
| 179 | 141 | <div class="twelve wide column"> |
| 180 | 142 | <h3 class="ui header handle-drag"> |
| 181 | 143 | <?php |
| 182 | 144 | /** |
| @@ -185,19 +147,15 @@ | ||
| 185 | 147 | * Filters the recent posts widget title text. |
| 186 | 148 | * |
| 187 | 149 | * @since 4.1 |
| 188 | 150 | */ |
| 189 | - echo esc_html( apply_filters( 'mainwp_recent_posts_widget_title', esc_html__( 'Recent Posts', 'mainwp' ) ) ); | |
| 151 | + echo esc_html( apply_filters( 'mainwp_recent_posts_widget_title', __( 'Recent Posts', 'mainwp' ) ) ); | |
| 190 | 152 | ?> |
| 191 | - <?php if ( isset( $_GET['client_id'] ) ) : // phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.NonceVerification.Missing ?> | |
| 192 | - <div class="sub header"><?php esc_html_e( 'The most recent posts from the Client websites', 'mainwp' ); ?></div> | |
| 193 | - <?php else : ?> | |
| 194 | 153 | <div class="sub header"><?php esc_html_e( 'The most recent posts from your websites', 'mainwp' ); ?></div> |
| 195 | - <?php endif; ?> | |
| 196 | 154 | </h3> |
| 197 | 155 | </div> |
| 198 | 156 | <div class="four wide column right aligned"> |
| 199 | - <div class="ui dropdown right pointing mainwp-dropdown-tab"> | |
| 157 | + <div class="ui dropdown right mainwp-dropdown-tab"> | |
| 200 | 158 | <div class="text"><?php esc_html_e( 'Published', 'mainwp' ); ?></div> |
| 201 | 159 | <i class="dropdown icon"></i> |
| 202 | 160 | <div class="menu"> |
| 203 | 161 | <a class="item recent_posts_published_lnk" data-tab="published" data-value="published" title="<?php esc_attr_e( 'Published', 'mainwp' ); ?>" href="#"><?php esc_html_e( 'Published', 'mainwp' ); ?></a> |
| @@ -208,8 +166,9 @@ | ||
| 208 | 166 | </div> |
| 209 | 167 | </div> |
| 210 | 168 | </div> |
| 211 | 169 | </div> |
| 170 | + <div class="ui section hidden divider"></div> | |
| 212 | 171 | <?php |
| 213 | 172 | } |
| 214 | 173 | |
| 215 | 174 | /** |
| @@ -216,19 +175,12 @@ | ||
| 216 | 175 | * Render Published Posts. |
| 217 | 176 | * |
| 218 | 177 | * @param array $allPosts All posts data. |
| 219 | 178 | * @param int $recent_number Number of posts. |
| 220 | - * @param bool $individual Determins if it's individual site dashbaord. | |
| 221 | - * | |
| 222 | - * @uses \MainWP\Dashboard\MainWP_Utility::get_sub_array_having() | |
| 223 | - * @uses \MainWP\Dashboard\MainWP_Utility::sortmulti() | |
| 224 | - * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp() | |
| 225 | - * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp() | |
| 226 | 179 | */ |
| 227 | - public static function render_published_posts( $allPosts, $recent_number, $individual ) { | |
| 180 | + public static function render_published_posts( $allPosts, $recent_number ) { | |
| 228 | 181 | $recent_posts_published = MainWP_Utility::get_sub_array_having( $allPosts, 'status', 'publish' ); |
| 229 | 182 | $recent_posts_published = MainWP_Utility::sortmulti( $recent_posts_published, 'dts', 'desc' ); |
| 230 | - $is_demo = MainWP_Demo_Handle::is_demo_mode(); | |
| 231 | 183 | ?> |
| 232 | 184 | <div class="recent_posts_published ui tab active" data-tab="published"> |
| 233 | 185 | <?php |
| 234 | 186 | /** |
| @@ -241,17 +193,24 @@ | ||
| 241 | 193 | * |
| 242 | 194 | * @since 4.1 |
| 243 | 195 | */ |
| 244 | 196 | do_action( 'mainwp_recent_posts_before_publised_list', $allPosts, $recent_number ); |
| 245 | - if ( 0 === count( $recent_posts_published ) ) { | |
| 246 | - MainWP_UI::render_empty_element_placeholder(); | |
| 197 | + if ( 0 == count( $recent_posts_published ) ) { | |
| 198 | + ?> | |
| 199 | + <h2 class="ui icon header"> | |
| 200 | + <i class="folder open outline icon"></i> | |
| 201 | + <div class="content"> | |
| 202 | + <?php esc_html_e( 'No published posts found!', 'mainwp' ); ?> | |
| 203 | + </div> | |
| 204 | + </h2> | |
| 205 | + <?php | |
| 247 | 206 | } |
| 248 | 207 | ?> |
| 249 | 208 | <div class="ui middle aligned divided selection list"> |
| 250 | 209 | <?php |
| 251 | 210 | $_count = count( $recent_posts_published ); |
| 252 | - for ( $i = 0; $i < $_count && $i < $recent_number; $i++ ) { | |
| 253 | - if ( ! isset( $recent_posts_published[ $i ]['title'] ) || empty( $recent_posts_published[ $i ]['title'] ) ) { | |
| 211 | + for ( $i = 0; $i < $_count && $i < $recent_number; $i ++ ) { | |
| 212 | + if ( ! isset( $recent_posts_published[ $i ]['title'] ) || ( '' == $recent_posts_published[ $i ]['title'] ) ) { | |
| 254 | 213 | $recent_posts_published[ $i ]['title'] = '(No Title)'; |
| 255 | 214 | } |
| 256 | 215 | if ( isset( $recent_posts_published[ $i ]['dts'] ) ) { |
| 257 | 216 | if ( ! stristr( $recent_posts_published[ $i ]['dts'], '-' ) ) { |
| @@ -262,29 +221,29 @@ | ||
| 262 | 221 | $name = wp_strip_all_tags( $recent_posts_published[ $i ]['website']->name ); |
| 263 | 222 | |
| 264 | 223 | ?> |
| 265 | 224 | <div class="item"> |
| 266 | - <div class="ui stackable grid"> | |
| 225 | + <div class="ui grid"> | |
| 267 | 226 | <input class="postId" type="hidden" name="id" value="<?php echo esc_attr( $recent_posts_published[ $i ]['id'] ); ?>"/> |
| 268 | 227 | <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $recent_posts_published[ $i ]['website']->id ); ?>"/> |
| 269 | - <div class="fourteen wide column middle aligned"> | |
| 270 | - <div> | |
| 271 | - <a href="<?php echo esc_url( $recent_posts_published[ $i ]['website']->url ); ?>?p=<?php echo esc_attr( $recent_posts_published[ $i ]['id'] ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo esc_html( htmlentities( $recent_posts_published[ $i ]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8' ) ); ?></a> | |
| 272 | - <?php if ( ! $individual ) : ?> | |
| 273 | - <?php esc_html_e( 'on', 'mainwp' ); ?> <a href="<?php echo esc_url( $recent_posts_published[ $i ]['website']->url ); ?>" target="_blank"><?php echo $name; // phpcs:ignore WordPress.Security.EscapeOutput ?></a> | |
| 274 | - <?php endif; ?> | |
| 275 | - </div> | |
| 276 | - <span class="ui small text"><?php echo esc_html( $recent_posts_published[ $i ]['dts'] ); ?></span> | |
| 228 | + <div class="six wide column middle aligned"> | |
| 229 | + <a href="<?php echo esc_url( $recent_posts_published[ $i ]['website']->url ); ?>?p=<?php echo esc_attr( $recent_posts_published[ $i ]['id'] ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo htmlentities( $recent_posts_published[ $i ]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8' ); ?></a> | |
| 277 | 230 | </div> |
| 231 | + <div class="four wide column middle aligned"> | |
| 232 | + <?php echo esc_html( $recent_posts_published[ $i ]['dts'] ); ?> | |
| 233 | + </div> | |
| 234 | + <div class="four wide column middle aligned"> | |
| 235 | + <a href="<?php echo esc_url( $recent_posts_published[ $i ]['website']->url ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo $name; ?></a> | |
| 236 | + </div> | |
| 278 | 237 | <div class="two wide column right aligned"> |
| 279 | - <div class="ui right pointing dropdown icon mini basic green button" style="z-index:999"> | |
| 238 | + <div class="ui left pointing dropdown icon mini basic green button" style="z-index:999"> | |
| 280 | 239 | <i class="ellipsis horizontal icon"></i> |
| 281 | - <div class="menu"> | |
| 282 | - <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-unpublish" href="#"><?php esc_html_e( 'Unpublish', 'mainwp' ); ?></a> | |
| 283 | - <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo intval( $recent_posts_published[ $i ]['website']->id ); ?>&location=<?php echo esc_attr( base64_encode( 'post.php?action=editpost&post=' . $recent_posts_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' ) ); ?>" target="_blank"><?php esc_html_e( 'Edit', 'mainwp' ); ?></a> | |
| 284 | - <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-trash" href="#"><?php esc_html_e( 'Trash', 'mainwp' ); ?></a> | |
| 285 | - <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item" href="<?php echo esc_url( $recent_posts_published[ $i ]['website']->url ) . ( '/' !== substr( $recent_posts_published[ $i ]['website']->url, - 1 ) ? '/' : '' ) . '?p=' . esc_attr( $recent_posts_published[ $i ]['id'] ); ?>" target="_blank"><?php esc_html_e( 'View', 'mainwp' ); ?></a> | |
| 286 | - </div> | |
| 240 | + <div class="menu"> | |
| 241 | + <a class="item mainwp-post-unpublish" href="#"><?php esc_html_e( 'Unpublish', 'mainwp' ); ?></a> | |
| 242 | + <a class="item" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo $recent_posts_published[ $i ]['website']->id; ?>&location=<?php echo base64_encode( 'post.php?action=editpost&post=' . $recent_posts_published[ $i ]['id'] . '&action=edit' ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. ?>" target="_blank"><?php esc_html_e( 'Edit', 'mainwp' ); ?></a> | |
| 243 | + <a class="item mainwp-post-trash" href="#"><?php esc_html_e( 'Trash', 'mainwp' ); ?></a> | |
| 244 | + <a class="item" href="<?php echo esc_url( $recent_posts_published[ $i ]['website']->url ) . ( '/' != substr( $recent_posts_published[ $i ]['website']->url, - 1 ) ? '/' : '' ) . '?p=' . esc_attr( $recent_posts_published[ $i ]['id'] ); ?>" target="_blank"><?php esc_html_e( 'View', 'mainwp' ); ?></a> | |
| 245 | + </div> | |
| 287 | 246 | </div> |
| 288 | 247 | </div> |
| 289 | 248 | </div> |
| 290 | 249 | <div class="mainwp-row-actions-working"><i class="notched circle loading icon"></i><?php esc_html_e( 'Please wait...', 'mainwp' ); ?></div> |
| @@ -312,19 +271,13 @@ | ||
| 312 | 271 | * Render all draft posts. |
| 313 | 272 | * |
| 314 | 273 | * @param array $allPosts All posts data. |
| 315 | 274 | * @param int $recent_number Number of posts. |
| 316 | - * @param bool $individual Determins if it's individual site dashbaord. | |
| 317 | - * | |
| 318 | - * @uses \MainWP\Dashboard\MainWP_Utility::get_sub_array_having() | |
| 319 | - * @uses \MainWP\Dashboard\MainWP_Utility::sortmulti() | |
| 320 | - * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp() | |
| 321 | - * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp() | |
| 322 | 275 | */ |
| 323 | - public static function render_draft_posts( $allPosts, $recent_number, $individual ) { | |
| 276 | + public static function render_draft_posts( $allPosts, $recent_number ) { | |
| 277 | + | |
| 324 | 278 | $recent_posts_draft = MainWP_Utility::get_sub_array_having( $allPosts, 'status', 'draft' ); |
| 325 | 279 | $recent_posts_draft = MainWP_Utility::sortmulti( $recent_posts_draft, 'dts', 'desc' ); |
| 326 | - $is_demo = MainWP_Demo_Handle::is_demo_mode(); | |
| 327 | 280 | ?> |
| 328 | 281 | <div class="recent_posts_draft ui tab" data-tab="draft"> |
| 329 | 282 | <?php |
| 330 | 283 | /** |
| @@ -337,17 +290,24 @@ | ||
| 337 | 290 | * |
| 338 | 291 | * @since 4.1 |
| 339 | 292 | */ |
| 340 | 293 | do_action( 'mainwp_recent_posts_before_draft_list', $allPosts, $recent_number ); |
| 341 | - if ( 0 === count( $recent_posts_draft ) ) { | |
| 342 | - MainWP_UI::render_empty_element_placeholder(); | |
| 294 | + if ( 0 == count( $recent_posts_draft ) ) { | |
| 295 | + ?> | |
| 296 | + <h2 class="ui icon header"> | |
| 297 | + <i class="folder open outline icon"></i> | |
| 298 | + <div class="content"> | |
| 299 | + <?php esc_html_e( 'No draft posts found!', 'mainwp' ); ?> | |
| 300 | + </div> | |
| 301 | + </h2> | |
| 302 | + <?php | |
| 343 | 303 | } |
| 344 | 304 | ?> |
| 345 | 305 | <div class="ui middle aligned divided selection list"> |
| 346 | 306 | <?php |
| 347 | 307 | $_count = count( $recent_posts_draft ); |
| 348 | - for ( $i = 0; $i < $_count && $i < $recent_number; $i++ ) { | |
| 349 | - if ( ! isset( $recent_posts_draft[ $i ]['title'] ) || empty( $recent_posts_draft[ $i ]['title'] ) ) { | |
| 308 | + for ( $i = 0; $i < $_count && $i < $recent_number; $i ++ ) { | |
| 309 | + if ( ! isset( $recent_posts_draft[ $i ]['title'] ) || ( '' == $recent_posts_draft[ $i ]['title'] ) ) { | |
| 350 | 310 | $recent_posts_draft[ $i ]['title'] = '(No Title)'; |
| 351 | 311 | } |
| 352 | 312 | if ( isset( $recent_posts_draft[ $i ]['dts'] ) ) { |
| 353 | 313 | if ( ! stristr( $recent_posts_draft[ $i ]['dts'], '-' ) ) { |
| @@ -356,27 +316,27 @@ | ||
| 356 | 316 | } |
| 357 | 317 | $name = wp_strip_all_tags( $recent_posts_draft[ $i ]['website']->name ); |
| 358 | 318 | ?> |
| 359 | 319 | <div class="item"> |
| 360 | - <div class="ui stackable grid"> | |
| 320 | + <div class="ui grid"> | |
| 361 | 321 | <input class="postId" type="hidden" name="id" value="<?php echo esc_attr( $recent_posts_draft[ $i ]['id'] ); ?>"/> |
| 362 | 322 | <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $recent_posts_draft[ $i ]['website']->id ); ?>"/> |
| 363 | - <div class="fourteen wide column middle aligned"> | |
| 364 | - <div> | |
| 365 | - <a href="<?php echo esc_url( $recent_posts_draft[ $i ]['website']->url ); ?>?p=<?php echo esc_attr( $recent_posts_draft[ $i ]['id'] ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo esc_html( htmlentities( $recent_posts_draft[ $i ]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8' ) ); ?></a> | |
| 366 | - <?php if ( ! $individual ) : ?> | |
| 367 | - <?php esc_html_e( 'on', 'mainwp' ); ?> <a href="<?php echo esc_url( $recent_posts_draft[ $i ]['website']->url ); ?>" target="_blank"><?php echo $name; // phpcs:ignore WordPress.Security.EscapeOutput ?></a> | |
| 368 | - <?php endif; ?> | |
| 369 | - </div> | |
| 370 | - <span class="ui small text"><?php echo esc_html( $recent_posts_draft[ $i ]['dts'] ); ?></span> | |
| 323 | + <div class="six wide column middle aligned"> | |
| 324 | + <a href="<?php echo esc_url( $recent_posts_draft[ $i ]['website']->url ); ?>?p=<?php echo esc_attr( $recent_posts_draft[ $i ]['id'] ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo htmlentities( $recent_posts_draft[ $i ]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8' ); ?></a> | |
| 371 | 325 | </div> |
| 326 | + <div class="four wide column middle aligned"> | |
| 327 | + <?php echo esc_html( $recent_posts_draft[ $i ]['dts'] ); ?> | |
| 328 | + </div> | |
| 329 | + <div class="four wide column middle aligned"> | |
| 330 | + <a href="<?php echo esc_url( $recent_posts_draft[ $i ]['website']->url ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo $name; ?></a> | |
| 331 | + </div> | |
| 372 | 332 | <div class="two wide column right aligned"> |
| 373 | - <div class="ui right pointing dropdown icon mini basic green button" style="z-index:999"> | |
| 333 | + <div class="ui left pointing dropdown icon mini basic green button" style="z-index:999"> | |
| 374 | 334 | <i class="ellipsis horizontal icon"></i> |
| 375 | 335 | <div class="menu"> |
| 376 | - <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-publish" href="#"><?php esc_html_e( 'Publish', 'mainwp' ); ?></a> | |
| 377 | - <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo esc_attr( $recent_posts_draft[ $i ]['website']->id ); ?>&location=<?php echo esc_attr( base64_encode( 'post.php?action=editpost&post=' . $recent_posts_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' ) ); ?>" target="_blank"><?php esc_html_e( 'Edit', 'mainwp' ); ?></a> | |
| 378 | - <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-trash" href="#"><?php esc_html_e( 'Trash', 'mainwp' ); ?></a> | |
| 336 | + <a class="item mainwp-post-publish" href="#"><?php esc_html_e( 'Publish', 'mainwp' ); ?></a> | |
| 337 | + <a class="item" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo esc_attr( $recent_posts_draft[ $i ]['website']->id ); ?>&location=<?php echo base64_encode( 'post.php?action=editpost&post=' . $recent_posts_draft[ $i ]['id'] . '&action=edit' ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. ?>" target="_blank"><?php esc_html_e( 'Edit', 'mainwp' ); ?></a> | |
| 338 | + <a class="item mainwp-post-trash" href="#"><?php esc_html_e( 'Trash', 'mainwp' ); ?></a> | |
| 379 | 339 | </div> |
| 380 | 340 | </div> |
| 381 | 341 | </div> |
| 382 | 342 | </div> |
| @@ -405,19 +365,13 @@ | ||
| 405 | 365 | * Render all pending posts. |
| 406 | 366 | * |
| 407 | 367 | * @param array $allPosts All posts data. |
| 408 | 368 | * @param int $recent_number Number of posts. |
| 409 | - * @param bool $individual Determins if it's individual site dashbaord. | |
| 410 | - * | |
| 411 | - * @uses \MainWP\Dashboard\MainWP_Utility::get_sub_array_having() | |
| 412 | - * @uses \MainWP\Dashboard\MainWP_Utility::sortmulti() | |
| 413 | - * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp() | |
| 414 | - * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp() | |
| 415 | 369 | */ |
| 416 | - public static function render_pending_posts( $allPosts, $recent_number, $individual ) { | |
| 370 | + public static function render_pending_posts( $allPosts, $recent_number ) { | |
| 417 | 371 | $recent_posts_pending = MainWP_Utility::get_sub_array_having( $allPosts, 'status', 'pending' ); |
| 418 | 372 | $recent_posts_pending = MainWP_Utility::sortmulti( $recent_posts_pending, 'dts', 'desc' ); |
| 419 | - $is_demo = MainWP_Demo_Handle::is_demo_mode(); | |
| 373 | + | |
| 420 | 374 | ?> |
| 421 | 375 | <div class="recent_posts_pending ui bottom attached tab" data-tab="pending"> |
| 422 | 376 | <?php |
| 423 | 377 | /** |
| @@ -430,17 +384,24 @@ | ||
| 430 | 384 | * |
| 431 | 385 | * @since 4.1 |
| 432 | 386 | */ |
| 433 | 387 | do_action( 'mainwp_recent_posts_before_pending_list', $allPosts, $recent_number ); |
| 434 | - if ( 0 === count( $recent_posts_pending ) ) { | |
| 435 | - MainWP_UI::render_empty_element_placeholder(); | |
| 388 | + if ( 0 == count( $recent_posts_pending ) ) { | |
| 389 | + ?> | |
| 390 | + <h2 class="ui icon header"> | |
| 391 | + <i class="folder open outline icon"></i> | |
| 392 | + <div class="content"> | |
| 393 | + <?php esc_html_e( 'No pending posts found!', 'mainwp' ); ?> | |
| 394 | + </div> | |
| 395 | + </h2> | |
| 396 | + <?php | |
| 436 | 397 | } |
| 437 | 398 | ?> |
| 438 | 399 | <div class="ui middle aligned divided selection list"> |
| 439 | 400 | <?php |
| 440 | 401 | $_count = count( $recent_posts_pending ); |
| 441 | - for ( $i = 0; $i < $_count && $i < $recent_number; $i++ ) { | |
| 442 | - if ( ! isset( $recent_posts_pending[ $i ]['title'] ) || empty( $recent_posts_pending[ $i ]['title'] ) ) { | |
| 402 | + for ( $i = 0; $i < $_count && $i < $recent_number; $i ++ ) { | |
| 403 | + if ( ! isset( $recent_posts_pending[ $i ]['title'] ) || ( '' == $recent_posts_pending[ $i ]['title'] ) ) { | |
| 443 | 404 | $recent_posts_pending[ $i ]['title'] = '(No Title)'; |
| 444 | 405 | } |
| 445 | 406 | if ( isset( $recent_posts_pending[ $i ]['dts'] ) ) { |
| 446 | 407 | if ( ! stristr( $recent_posts_pending[ $i ]['dts'], '-' ) ) { |
| @@ -449,27 +410,27 @@ | ||
| 449 | 410 | } |
| 450 | 411 | $name = wp_strip_all_tags( $recent_posts_pending[ $i ]['website']->name ); |
| 451 | 412 | ?> |
| 452 | 413 | <div class="item"> |
| 453 | - <div class="ui stackable grid"> | |
| 414 | + <div class="ui grid"> | |
| 454 | 415 | <input class="postId" type="hidden" name="id" value="<?php echo esc_attr( $recent_posts_pending[ $i ]['id'] ); ?>"/> |
| 455 | 416 | <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $recent_posts_pending[ $i ]['website']->id ); ?>"/> |
| 456 | - <div class="fourteen wide column middle aligned"> | |
| 457 | - <div> | |
| 458 | - <a href="<?php echo esc_url( $recent_posts_pending[ $i ]['website']->url ); ?>?p=<?php echo esc_attr( $recent_posts_pending[ $i ]['id'] ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo esc_html( htmlentities( $recent_posts_pending[ $i ]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8' ) ); ?></a> | |
| 459 | - <?php if ( ! $individual ) : ?> | |
| 460 | - <?php esc_html_e( 'on', 'mainwp' ); ?> <a href="<?php echo esc_url( $recent_posts_pending[ $i ]['website']->url ); ?>" target="_blank"><?php echo $name; // phpcs:ignore WordPress.Security.EscapeOutput ?></a> | |
| 461 | - <?php endif; ?> | |
| 462 | - </div> | |
| 463 | - <span class="ui small text"><?php echo esc_html( $recent_posts_pending[ $i ]['dts'] ); ?></span> | |
| 417 | + <div class="six wide column middle aligned"> | |
| 418 | + <a href="<?php echo esc_url( $recent_posts_pending[ $i ]['website']->url ); ?>?p=<?php echo esc_attr( $recent_posts_pending[ $i ]['id'] ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo htmlentities( $recent_posts_pending[ $i ]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8' ); ?></a> | |
| 464 | 419 | </div> |
| 420 | + <div class="four wide column middle aligned"> | |
| 421 | + <?php echo esc_html( $recent_posts_pending[ $i ]['dts'] ); ?> | |
| 422 | + </div> | |
| 423 | + <div class="four wide column middle aligned"> | |
| 424 | + <a href="<?php echo esc_url( $recent_posts_pending[ $i ]['website']->url ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo $name; ?></a> | |
| 425 | + </div> | |
| 465 | 426 | <div class="two wide column right aligned"> |
| 466 | - <div class="ui right pointing dropdown icon mini basic green button" style="z-index:999"> | |
| 427 | + <div class="ui left pointing dropdown icon mini basic green button" style="z-index:999"> | |
| 467 | 428 | <i class="ellipsis horizontal icon"></i> |
| 468 | 429 | <div class="menu"> |
| 469 | - <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-publish" href="#"><?php esc_html_e( 'Publish', 'mainwp' ); ?></a> | |
| 470 | - <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo esc_attr( $recent_posts_pending[ $i ]['website']->id ); ?>&location=<?php echo esc_attr( base64_encode( 'post.php?action=editpost&post=' . $recent_posts_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' ) ); ?>" target="_blank"><?php esc_html_e( 'Edit', 'mainwp' ); ?></a> | |
| 471 | - <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-trash" href="#"><?php esc_html_e( 'Trash', 'mainwp' ); ?></a> | |
| 430 | + <a class="item mainwp-post-publish" href="#"><?php esc_html_e( 'Publish', 'mainwp' ); ?></a> | |
| 431 | + <a class="item" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo esc_attr( $recent_posts_pending[ $i ]['website']->id ); ?>&location=<?php echo base64_encode( 'post.php?action=editpost&post=' . $recent_posts_pending[ $i ]['id'] . '&action=edit' ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. ?>" target="_blank"><?php esc_html_e( 'Edit', 'mainwp' ); ?></a> | |
| 432 | + <a class="item mainwp-post-trash" href="#"><?php esc_html_e( 'Trash', 'mainwp' ); ?></a> | |
| 472 | 433 | </div> |
| 473 | 434 | </div> |
| 474 | 435 | </div> |
| 475 | 436 | </div> |
| @@ -498,72 +459,72 @@ | ||
| 498 | 459 | * Render all future posts. |
| 499 | 460 | * |
| 500 | 461 | * @param array $allPosts All posts data. |
| 501 | 462 | * @param int $recent_number Number of posts. |
| 502 | - * @param bool $individual Determins if it's individual site dashbaord . | |
| 503 | - * | |
| 504 | - * @uses \MainWP\Dashboard\MainWP_Utility::get_sub_array_having() | |
| 505 | - * @uses \MainWP\Dashboard\MainWP_Utility::sortmulti() | |
| 506 | - * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp() | |
| 507 | - * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp() | |
| 508 | 463 | */ |
| 509 | - public static function render_future_posts( $allPosts, $recent_number, $individual ) { | |
| 464 | + public static function render_future_posts( $allPosts, $recent_number ) { | |
| 510 | 465 | $recent_posts_future = MainWP_Utility::get_sub_array_having( $allPosts, 'status', 'future' ); |
| 511 | 466 | $recent_posts_future = MainWP_Utility::sortmulti( $recent_posts_future, 'dts', 'desc' ); |
| 512 | - $is_demo = MainWP_Demo_Handle::is_demo_mode(); | |
| 513 | 467 | ?> |
| 514 | 468 | <div class="recent_posts_future ui tab" data-tab="future"> |
| 515 | - <?php | |
| 516 | - /** | |
| 517 | - * Action: mainwp_recent_posts_before_future_list | |
| 518 | - * | |
| 519 | - * Fires before the list of recent future Posts. | |
| 520 | - * | |
| 521 | - * @param array $allPosts All posts data. | |
| 522 | - * @param int $recent_number Number of posts. | |
| 523 | - * | |
| 524 | - * @since 4.1 | |
| 525 | - */ | |
| 526 | - do_action( 'mainwp_recent_posts_before_future_list', $allPosts, $recent_number ); | |
| 527 | - if ( 0 === count( $recent_posts_future ) ) { | |
| 528 | - MainWP_UI::render_empty_element_placeholder(); | |
| 529 | - } | |
| 530 | - ?> | |
| 531 | - <div class="ui middle aligned divided selection list"> | |
| 532 | - <?php | |
| 533 | - $_count = count( $recent_posts_future ); | |
| 534 | - for ( $i = 0; $i < $_count && $i < $recent_number; $i++ ) { | |
| 535 | - if ( ! isset( $recent_posts_future[ $i ]['title'] ) || empty( $recent_posts_future[ $i ]['title'] ) ) { | |
| 536 | - $recent_posts_future[ $i ]['title'] = '(No Title)'; | |
| 537 | - } | |
| 538 | - if ( isset( $recent_posts_future[ $i ]['dts'] ) ) { | |
| 539 | - if ( ! stristr( $recent_posts_future[ $i ]['dts'], '-' ) ) { | |
| 540 | - $recent_posts_future[ $i ]['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $recent_posts_future[ $i ]['dts'] ) ); | |
| 469 | + <?php | |
| 470 | + /** | |
| 471 | + * Action: mainwp_recent_posts_before_future_list | |
| 472 | + * | |
| 473 | + * Fires before the list of recent future Posts. | |
| 474 | + * | |
| 475 | + * @param array $allPosts All posts data. | |
| 476 | + * @param int $recent_number Number of posts. | |
| 477 | + * | |
| 478 | + * @since 4.1 | |
| 479 | + */ | |
| 480 | + do_action( 'mainwp_recent_posts_before_future_list', $allPosts, $recent_number ); | |
| 481 | + if ( 0 == count( $recent_posts_future ) ) { | |
| 482 | + ?> | |
| 483 | + <h2 class="ui icon header"> | |
| 484 | + <i class="folder open outline icon"></i> | |
| 485 | + <div class="content"> | |
| 486 | + <?php esc_html_e( 'No future posts found!', 'mainwp' ); ?> | |
| 487 | + </div> | |
| 488 | + </h2> | |
| 489 | + <?php | |
| 541 | 490 | } |
| 542 | - } | |
| 543 | - $name = wp_strip_all_tags( $recent_posts_future[ $i ]['website']->name ); | |
| 544 | - ?> | |
| 491 | + ?> | |
| 492 | + <div class="ui middle aligned divided selection list"> | |
| 493 | + <?php | |
| 494 | + $_count = count( $recent_posts_future ); | |
| 495 | + for ( $i = 0; $i < $_count && $i < $recent_number; $i ++ ) { | |
| 496 | + if ( ! isset( $recent_posts_future[ $i ]['title'] ) || ( '' == $recent_posts_future[ $i ]['title'] ) ) { | |
| 497 | + $recent_posts_future[ $i ]['title'] = '(No Title)'; | |
| 498 | + } | |
| 499 | + if ( isset( $recent_posts_future[ $i ]['dts'] ) ) { | |
| 500 | + if ( ! stristr( $recent_posts_future[ $i ]['dts'], '-' ) ) { | |
| 501 | + $recent_posts_future[ $i ]['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $recent_posts_future[ $i ]['dts'] ) ); | |
| 502 | + } | |
| 503 | + } | |
| 504 | + $name = wp_strip_all_tags( $recent_posts_future[ $i ]['website']->name ); | |
| 505 | + ?> | |
| 545 | 506 | <div class="item"> |
| 546 | - <div class="ui stackable grid"> | |
| 507 | + <div class="ui grid"> | |
| 547 | 508 | <input class="postId" type="hidden" name="id" value="<?php echo esc_attr( $recent_posts_future[ $i ]['id'] ); ?>"/> |
| 548 | 509 | <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $recent_posts_future[ $i ]['website']->id ); ?>"/> |
| 549 | - <div class="fourteen wide column middle aligned"> | |
| 550 | - <div> | |
| 551 | - <a href="<?php echo esc_url( $recent_posts_future[ $i ]['website']->url ); ?>?p=<?php echo esc_attr( $recent_posts_future[ $i ]['id'] ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo esc_html( htmlentities( $recent_posts_future[ $i ]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8' ) ); ?></a> | |
| 552 | - <?php if ( ! $individual ) : ?> | |
| 553 | - <?php esc_html_e( 'on', 'mainwp' ); ?> <a href="<?php echo esc_url( $recent_posts_future[ $i ]['website']->url ); ?>" target="_blank"><?php echo $name; // phpcs:ignore WordPress.Security.EscapeOutput ?></a> | |
| 554 | - <?php endif; ?> | |
| 555 | - </div> | |
| 556 | - <span class="ui small text"><?php echo esc_html( $recent_posts_future[ $i ]['dts'] ); ?></span> | |
| 510 | + <div class="six wide column middle aligned"> | |
| 511 | + <a href="<?php echo esc_url( $recent_posts_future[ $i ]['website']->url ); ?>?p=<?php echo esc_attr( $recent_posts_future[ $i ]['id'] ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo htmlentities( $recent_posts_future[ $i ]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8' ); ?></a> | |
| 557 | 512 | </div> |
| 513 | + <div class="four wide column middle aligned"> | |
| 514 | + <?php echo esc_html( $recent_posts_future[ $i ]['dts'] ); ?> | |
| 515 | + </div> | |
| 516 | + <div class="four wide column middle aligned"> | |
| 517 | + <a href="<?php echo esc_url( $recent_posts_future[ $i ]['website']->url ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo $name; ?></a> | |
| 518 | + </div> | |
| 558 | 519 | <div class="two wide column right aligned"> |
| 559 | - <div class="ui right pointing dropdown icon mini basic green button" style="z-index:999"> | |
| 520 | + <div class="ui left pointing dropdown icon mini basic green button" style="z-index:999"> | |
| 560 | 521 | <i class="ellipsis horizontal icon"></i> |
| 561 | 522 | <div class="menu"> |
| 562 | - <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-publish" href="#"><?php esc_html_e( 'Publish', 'mainwp' ); ?></a> | |
| 563 | - <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo esc_attr( $recent_posts_future[ $i ]['website']->id ); ?>&location=<?php echo esc_attr( base64_encode( 'post.php?action=editpost&post=' . $recent_posts_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' ) ); ?>" target="_blank"><?php esc_html_e( 'Edit', 'mainwp' ); ?></a> | |
| 564 | - <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-trash" href="#"><?php esc_html_e( 'Trash', 'mainwp' ); ?></a> | |
| 565 | - <a class="<?php echo $is_demo ? 'disabled' : ''; ?> item" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo esc_attr( $recent_posts_future[ $i ]['website']->id ); ?>&openUrl=yes&location=<?php echo esc_attr( base64_encode( '?p=' . $recent_posts_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"><?php esc_html_e( 'Preview', 'mainwp' ); ?></a> | |
| 523 | + <a class="item mainwp-post-publish" href="#"><?php esc_html_e( 'Publish', 'mainwp' ); ?></a> | |
| 524 | + <a class="item" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo esc_attr( $recent_posts_future[ $i ]['website']->id ); ?>&location=<?php echo base64_encode( 'post.php?action=editpost&post=' . $recent_posts_future[ $i ]['id'] . '&action=edit' ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. ?>" target="_blank"><?php esc_html_e( 'Edit', 'mainwp' ); ?></a> | |
| 525 | + <a class="item mainwp-post-trash" href="#"><?php esc_html_e( 'Trash', 'mainwp' ); ?></a> | |
| 526 | + <a class="item" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo esc_attr( $recent_posts_future[ $i ]['website']->id ); ?>&newWindow=yes&openUrl=yes&location=<?php echo base64_encode( '?p=' . $recent_posts_future[ $i ]['id'] . '&preview=true' ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. ?>" target="_blank"><?php esc_html_e( 'Preview', 'mainwp' ); ?></a> | |
| 566 | 527 | </div> |
| 567 | 528 | </div> |
| 568 | 529 | </div> |
| 569 | 530 | </div> |
| @@ -592,91 +553,92 @@ | ||
| 592 | 553 | * Render all trashed posts. |
| 593 | 554 | * |
| 594 | 555 | * @param array $allPosts All posts data. |
| 595 | 556 | * @param int $recent_number Number of posts. |
| 596 | - * @param bool $individual Determins if it's individual site dashbaord . | |
| 597 | - * | |
| 598 | - * @uses \MainWP\Dashboard\MainWP_Utility::get_sub_array_having() | |
| 599 | - * @uses \MainWP\Dashboard\MainWP_Utility::sortmulti() | |
| 600 | - * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp() | |
| 601 | - * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp() | |
| 602 | 557 | */ |
| 603 | - public static function render_trash_posts( $allPosts, $recent_number, $individual ) { | |
| 558 | + public static function render_trash_posts( $allPosts, $recent_number ) { | |
| 604 | 559 | $recent_posts_trash = MainWP_Utility::get_sub_array_having( $allPosts, 'status', 'trash' ); |
| 605 | 560 | $recent_posts_trash = MainWP_Utility::sortmulti( $recent_posts_trash, 'dts', 'desc' ); |
| 606 | - $is_demo = MainWP_Demo_Handle::is_demo_mode(); | |
| 561 | + | |
| 607 | 562 | ?> |
| 608 | 563 | <div class="recent_posts_trash ui tab" data-tab="trash"> |
| 609 | - <?php | |
| 610 | - /** | |
| 611 | - * Action: mainwp_recent_posts_before_trash_list | |
| 612 | - * | |
| 613 | - * Fires before the list of recent trash Posts. | |
| 614 | - * | |
| 615 | - * @param array $allPosts All posts data. | |
| 616 | - * @param int $recent_number Number of posts. | |
| 617 | - * | |
| 618 | - * @since 4.1 | |
| 619 | - */ | |
| 620 | - do_action( 'mainwp_recent_posts_before_trash_list', $allPosts, $recent_number ); | |
| 621 | - if ( 0 === count( $recent_posts_trash ) ) { | |
| 622 | - MainWP_UI::render_empty_element_placeholder(); | |
| 623 | - } | |
| 624 | - ?> | |
| 625 | - <div class="ui middle aligned divided selection list"> | |
| 626 | - <?php | |
| 627 | - $_count = count( $recent_posts_trash ); | |
| 628 | - for ( $i = 0; $i < $_count && $i < $recent_number; $i++ ) { | |
| 629 | - if ( ! isset( $recent_posts_trash[ $i ]['title'] ) || empty( $recent_posts_trash[ $i ]['title'] ) ) { | |
| 630 | - $recent_posts_trash[ $i ]['title'] = '(No Title)'; | |
| 631 | - } | |
| 632 | - if ( isset( $recent_posts_trash[ $i ]['dts'] ) ) { | |
| 633 | - if ( ! stristr( $recent_posts_trash[ $i ]['dts'], '-' ) ) { | |
| 634 | - $recent_posts_trash[ $i ]['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $recent_posts_trash[ $i ]['dts'] ) ); | |
| 564 | + <?php | |
| 565 | + /** | |
| 566 | + * Action: mainwp_recent_posts_before_trash_list | |
| 567 | + * | |
| 568 | + * Fires before the list of recent trash Posts. | |
| 569 | + * | |
| 570 | + * @param array $allPosts All posts data. | |
| 571 | + * @param int $recent_number Number of posts. | |
| 572 | + * | |
| 573 | + * @since 4.1 | |
| 574 | + */ | |
| 575 | + do_action( 'mainwp_recent_posts_before_trash_list', $allPosts, $recent_number ); | |
| 576 | + if ( 0 == count( $recent_posts_trash ) ) { | |
| 577 | + ?> | |
| 578 | + <h2 class="ui icon header"> | |
| 579 | + <i class="folder open outline icon"></i> | |
| 580 | + <div class="content"> | |
| 581 | + <?php esc_html_e( 'No trashed posts found!', 'mainwp' ); ?> | |
| 582 | + </div> | |
| 583 | + </h2> | |
| 584 | + <?php | |
| 635 | 585 | } |
| 636 | - } | |
| 637 | - $name = wp_strip_all_tags( $recent_posts_trash[ $i ]['website']->name ); | |
| 638 | - ?> | |
| 639 | - <div class="item"> | |
| 640 | - <div class="ui stackable grid"> | |
| 641 | - <input class="postId" type="hidden" name="id" value="<?php echo esc_attr( $recent_posts_trash[ $i ]['id'] ); ?>"/> | |
| 642 | - <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $recent_posts_trash[ $i ]['website']->id ); ?>"/> | |
| 643 | - <div class="fourteen wide column middle aligned"> | |
| 644 | - <div> | |
| 645 | - <a href="<?php echo esc_url( $recent_posts_trash[ $i ]['website']->url ); ?>?p=<?php echo esc_attr( $recent_posts_trash[ $i ]['id'] ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo esc_html( htmlentities( $recent_posts_trash[ $i ]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8' ) ); ?></a> | |
| 646 | - <?php if ( ! $individual ) : ?> | |
| 647 | - <?php esc_html_e( 'on', 'mainwp' ); ?> <a href="<?php echo esc_url( $recent_posts_trash[ $i ]['website']->url ); ?>" target="_blank"><?php echo $name; // phpcs:ignore WordPress.Security.EscapeOutput ?></a> | |
| 648 | - <?php endif; ?> | |
| 586 | + ?> | |
| 587 | + <div class="ui middle aligned divided selection list"> | |
| 588 | + <?php | |
| 589 | + $_count = count( $recent_posts_trash ); | |
| 590 | + for ( $i = 0; $i < $_count && $i < $recent_number; $i ++ ) { | |
| 591 | + if ( ! isset( $recent_posts_trash[ $i ]['title'] ) || ( '' == $recent_posts_trash[ $i ]['title'] ) ) { | |
| 592 | + $recent_posts_trash[ $i ]['title'] = '(No Title)'; | |
| 593 | + } | |
| 594 | + if ( isset( $recent_posts_trash[ $i ]['dts'] ) ) { | |
| 595 | + if ( ! stristr( $recent_posts_trash[ $i ]['dts'], '-' ) ) { | |
| 596 | + $recent_posts_trash[ $i ]['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $recent_posts_trash[ $i ]['dts'] ) ); | |
| 597 | + } | |
| 598 | + } | |
| 599 | + $name = wp_strip_all_tags( $recent_posts_trash[ $i ]['website']->name ); | |
| 600 | + ?> | |
| 601 | + <div class="item"> | |
| 602 | + <div class="ui grid"> | |
| 603 | + <input class="postId" type="hidden" name="id" value="<?php echo esc_attr( $recent_posts_trash[ $i ]['id'] ); ?>"/> | |
| 604 | + <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $recent_posts_trash[ $i ]['website']->id ); ?>"/> | |
| 605 | + <div class="six wide column middle aligned"> | |
| 606 | + <?php echo htmlentities( $recent_posts_trash[ $i ]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8' ); ?> | |
| 649 | 607 | </div> |
| 650 | - <span class="ui small text"><?php echo esc_html( $recent_posts_trash[ $i ]['dts'] ); ?></span> | |
| 608 | + <div class="four wide column middle aligned"> | |
| 609 | + <?php echo esc_html( $recent_posts_trash[ $i ]['dts'] ); ?> | |
| 610 | + </div> | |
| 611 | + <div class="four wide column middle aligned"> | |
| 612 | + <a href="<?php echo esc_url( $recent_posts_trash[ $i ]['website']->url ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo $name; ?></a> | |
| 613 | + </div> | |
| 614 | + <div class="two wide column right aligned"> | |
| 615 | + <div class="ui left pointing dropdown icon mini basic green button" style="z-index:999"> | |
| 616 | + <i class="ellipsis horizontal icon"></i> | |
| 617 | + <div class="menu"> | |
| 618 | + <a href="#" class="item mainwp-post-restore"><?php esc_html_e( 'Restore', 'mainwp' ); ?></a> | |
| 619 | + <a href="#" class="item mainwp-post-delete"><?php esc_html_e( 'Delete permanently', 'mainwp' ); ?></a> | |
| 620 | + </div> | |
| 621 | + </div> | |
| 622 | + </div> | |
| 651 | 623 | </div> |
| 652 | - <div class="two wide column right aligned"> | |
| 653 | - <div class="ui right pointing dropdown icon mini basic green button" style="z-index:999"> | |
| 654 | - <i class="ellipsis horizontal icon"></i> | |
| 655 | - <div class="menu"> | |
| 656 | - <a href="#" class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-restore" ><?php esc_html_e( 'Restore', 'mainwp' ); ?></a> | |
| 657 | - <a href="#" class="<?php echo $is_demo ? 'disabled' : ''; ?> item mainwp-post-delete"><?php esc_html_e( 'Delete permanently', 'mainwp' ); ?></a> | |
| 658 | - </div> | |
| 659 | - </div> | |
| 624 | + <div class="mainwp-row-actions-working"><i class="notched circle loading icon"></i><?php esc_html_e( 'Please wait...', 'mainwp' ); ?></div> | |
| 660 | 625 | </div> |
| 661 | - </div> | |
| 662 | - <div class="mainwp-row-actions-working"><i class="notched circle loading icon"></i><?php esc_html_e( 'Please wait...', 'mainwp' ); ?></div> | |
| 663 | - </div> | |
| 664 | - <?php } ?> | |
| 626 | + <?php } ?> | |
| 665 | 627 | </div> |
| 666 | - <?php | |
| 667 | - /** | |
| 668 | - * Action: mainwp_recent_posts_after_trash_list | |
| 669 | - * | |
| 670 | - * Fires after the list of recent trash Posts. | |
| 671 | - * | |
| 672 | - * @param array $allPosts All posts data. | |
| 673 | - * @param int $recent_number Number of posts. | |
| 674 | - * | |
| 675 | - * @since 4.1 | |
| 676 | - */ | |
| 677 | - do_action( 'mainwp_recent_posts_after_trash_list', $allPosts, $recent_number ); | |
| 678 | - ?> | |
| 628 | + <?php | |
| 629 | + /** | |
| 630 | + * Action: mainwp_recent_posts_after_trash_list | |
| 631 | + * | |
| 632 | + * Fires after the list of recent trash Posts. | |
| 633 | + * | |
| 634 | + * @param array $allPosts All posts data. | |
| 635 | + * @param int $recent_number Number of posts. | |
| 636 | + * | |
| 637 | + * @since 4.1 | |
| 638 | + */ | |
| 639 | + do_action( 'mainwp_recent_posts_after_trash_list', $allPosts, $recent_number ); | |
| 640 | + ?> | |
| 679 | 641 | </div> |
| 680 | 642 | <?php |
| 681 | 643 | } |
| 682 | 644 | |
| @@ -686,9 +648,9 @@ | ||
| 686 | 648 | * Publish Post. |
| 687 | 649 | */ |
| 688 | 650 | public static function publish() { |
| 689 | 651 | self::action( 'publish' ); |
| 690 | - die( wp_json_encode( array( 'result' => esc_html__( 'The post has been published.', 'mainwp' ) ) ) ); | |
| 652 | + die( wp_json_encode( array( 'result' => __( 'Post has been published!', 'mainwp' ) ) ) ); | |
| 691 | 653 | } |
| 692 | 654 | |
| 693 | 655 | /** |
| 694 | 656 | * Method approve() |
| @@ -696,9 +658,9 @@ | ||
| 696 | 658 | * Approve Post. |
| 697 | 659 | */ |
| 698 | 660 | public static function approve() { |
| 699 | 661 | self::action( 'publish' ); |
| 700 | - die( wp_json_encode( array( 'result' => esc_html__( 'The post has been approved.', 'mainwp' ) ) ) ); | |
| 662 | + die( wp_json_encode( array( 'result' => __( 'Post has been approved!', 'mainwp' ) ) ) ); | |
| 701 | 663 | } |
| 702 | 664 | |
| 703 | 665 | /** |
| 704 | 666 | * Method unpublish() |
| @@ -706,9 +668,9 @@ | ||
| 706 | 668 | * Unpublish Post. |
| 707 | 669 | */ |
| 708 | 670 | public static function unpublish() { |
| 709 | 671 | self::action( 'unpublish' ); |
| 710 | - die( wp_json_encode( array( 'result' => esc_html__( 'The post has been unpublished.', 'mainwp' ) ) ) ); | |
| 672 | + die( wp_json_encode( array( 'result' => __( 'Post has been unpublished!', 'mainwp' ) ) ) ); | |
| 711 | 673 | } |
| 712 | 674 | |
| 713 | 675 | /** |
| 714 | 676 | * Method trash() |
| @@ -716,9 +678,9 @@ | ||
| 716 | 678 | * Trash Post. |
| 717 | 679 | */ |
| 718 | 680 | public static function trash() { |
| 719 | 681 | self::action( 'trash' ); |
| 720 | - die( wp_json_encode( array( 'result' => esc_html__( 'The post has been moved to the trash.', 'mainwp' ) ) ) ); | |
| 682 | + die( wp_json_encode( array( 'result' => __( 'Post has been moved to trash!', 'mainwp' ) ) ) ); | |
| 721 | 683 | } |
| 722 | 684 | |
| 723 | 685 | /** |
| 724 | 686 | * Method delete() |
| @@ -726,9 +688,9 @@ | ||
| 726 | 688 | * Delete Post. |
| 727 | 689 | */ |
| 728 | 690 | public static function delete() { |
| 729 | 691 | self::action( 'delete' ); |
| 730 | - die( wp_json_encode( array( 'result' => esc_html__( 'The post has been permanently deleted.', 'mainwp' ) ) ) ); | |
| 692 | + die( wp_json_encode( array( 'result' => __( 'Post has been permanently deleted!', 'mainwp' ) ) ) ); | |
| 731 | 693 | } |
| 732 | 694 | |
| 733 | 695 | /** |
| 734 | 696 | * Method restore() |
| @@ -736,9 +698,9 @@ | ||
| 736 | 698 | * Restore Post. |
| 737 | 699 | */ |
| 738 | 700 | public static function restore() { |
| 739 | 701 | self::action( 'restore' ); |
| 740 | - die( wp_json_encode( array( 'result' => esc_html__( 'The post has been restored.', 'mainwp' ) ) ) ); | |
| 702 | + die( wp_json_encode( array( 'result' => __( 'Post has been restored!', 'mainwp' ) ) ) ); | |
| 741 | 703 | } |
| 742 | 704 | |
| 743 | 705 | /** |
| 744 | 706 | * Method action() |
| @@ -745,24 +707,16 @@ | ||
| 745 | 707 | * |
| 746 | 708 | * Initiate try catch for chosen Action |
| 747 | 709 | * |
| 748 | 710 | * @param string $pAction Post Action. |
| 749 | - * @param string $type Post type. | |
| 750 | - * | |
| 751 | - * @throws \Exception Error message. | |
| 752 | - * | |
| 753 | - * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() | |
| 754 | - * @uses \MainWP\Dashboard\MainWP_Error_Helper::get_error_message() | |
| 755 | - * @uses \MainWP\Dashboard\MainWP_Exception | |
| 756 | - * @uses \MainWP\Dashboard\MainWP_Connect::fetch_url_authed() | |
| 757 | - * @uses \MainWP\Dashboard\MainWP_System_Utility::can_edit_website() | |
| 711 | + * @param string $type Post type. | |
| 758 | 712 | */ |
| 759 | 713 | public static function action( $pAction, $type = 'post' ) { |
| 760 | - $postId = isset( $_POST['postId'] ) ? intval( $_POST['postId'] ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.NonceVerification.Missing | |
| 761 | - $websiteId = isset( $_POST['websiteId'] ) ? intval( $_POST['websiteId'] ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.NonceVerification.Missing | |
| 714 | + $postId = isset( $_POST['postId'] ) ? intval( $_POST['postId'] ) : false; | |
| 715 | + $websiteId = isset( $_POST['websiteId'] ) ? intval( $_POST['websiteId'] ) : false; | |
| 762 | 716 | |
| 763 | 717 | if ( empty( $postId ) || empty( $websiteId ) ) { |
| 764 | - die( wp_json_encode( array( 'error' => 'Post ID or site ID not found. Please, reload the page and try again.' ) ) ); | |
| 718 | + die( wp_json_encode( array( 'error' => 'Invalid request!' ) ) ); | |
| 765 | 719 | } |
| 766 | 720 | |
| 767 | 721 | $website = MainWP_DB::instance()->get_website_by_id( $websiteId ); |
| 768 | 722 | if ( ! MainWP_System_Utility::can_edit_website( $website ) ) { |
| @@ -768,19 +722,8 @@ | ||
| 768 | 722 | if ( ! MainWP_System_Utility::can_edit_website( $website ) ) { |
| 769 | 723 | die( wp_json_encode( array( 'error' => 'You can not edit this website!' ) ) ); |
| 770 | 724 | } |
| 771 | 725 | |
| 772 | - if ( MainWP_System_Utility::is_suspended_site( $website ) ) { | |
| 773 | - die( | |
| 774 | - wp_json_encode( | |
| 775 | - array( | |
| 776 | - 'error' => esc_html__( 'Suspended site.', 'mainwp' ), | |
| 777 | - 'errorCode' => 'SUSPENDED_SITE', | |
| 778 | - ) | |
| 779 | - ) | |
| 780 | - ); | |
| 781 | - } | |
| 782 | - | |
| 783 | 726 | /** |
| 784 | 727 | * Action: mainwp_before_post_action |
| 785 | 728 | * |
| 786 | 729 | * Fires before post/page publish/unpublish/trash/delete/restore actions. |
| @@ -787,8 +730,9 @@ | ||
| 787 | 730 | * |
| 788 | 731 | * @since 4.1 |
| 789 | 732 | */ |
| 790 | 733 | do_action( 'mainwp_before_post_action', $type, $pAction, $postId, $website ); |
| 734 | + | |
| 791 | 735 | try { |
| 792 | 736 | $information = MainWP_Connect::fetch_url_authed( |
| 793 | 737 | $website, |
| 794 | 738 | 'post_action', |
| @@ -796,16 +740,15 @@ | ||
| 796 | 740 | 'action' => $pAction, |
| 797 | 741 | 'id' => $postId, |
| 798 | 742 | ) |
| 799 | 743 | ); |
| 800 | - | |
| 801 | 744 | } catch ( MainWP_Exception $e ) { |
| 802 | - $information = array( 'error' => MainWP_Error_Helper::get_error_message( $e ) ); | |
| 803 | - | |
| 745 | + die( wp_json_encode( array( 'error' => MainWP_Error_Helper::get_error_message( $e ) ) ) ); | |
| 804 | 746 | } |
| 805 | 747 | |
| 806 | 748 | /** |
| 807 | 749 | * Action: mainwp_after_post_action |
| 750 | + * | |
| 808 | 751 | * Fires after post/page publish/unpublish/trash/delete/restore actions. |
| 809 | 752 | * |
| 810 | 753 | * @since 4.1 |
| 811 | 754 | */ |
| @@ -810,13 +753,49 @@ | ||
| 810 | 753 | * @since 4.1 |
| 811 | 754 | */ |
| 812 | 755 | do_action( 'mainwp_after_post_action', $information, $type, $pAction, $postId, $website ); |
| 813 | 756 | |
| 814 | - mainwp_get_actions_handler_instance()->do_action_mainwp_post_action( $website, $pAction, $information, $postId, $type ); | |
| 757 | + if ( ! isset( $information['status'] ) || ( 'SUCCESS' != $information['status'] ) ) { | |
| 758 | + die( wp_json_encode( array( 'error' => 'Unexpected error!' ) ) ); | |
| 759 | + } | |
| 760 | + } | |
| 815 | 761 | |
| 816 | - if ( is_array( $information ) && isset( $information['error'] ) ) { | |
| 817 | - die( wp_json_encode( $information ) ); | |
| 818 | - } elseif ( ! isset( $information['status'] ) || ( 'SUCCESS' !== $information['status'] ) ) { | |
| 819 | - die( wp_json_encode( array( 'error' => 'Unexpected error!' ) ) ); | |
| 762 | + /** | |
| 763 | + * Method action_update() | |
| 764 | + * | |
| 765 | + * Update Post Action. | |
| 766 | + * | |
| 767 | + * @param mixed $pAction Post Action. | |
| 768 | + */ | |
| 769 | + public static function action_update( $pAction ) { | |
| 770 | + $postId = isset( $_POST['postId'] ) ? intval( $_POST['postId'] ) : false; | |
| 771 | + $websiteId = isset( $_POST['websiteId'] ) ? intval( $_POST['websiteId'] ) : false; | |
| 772 | + $post_data = isset( $_POST['post_data'] ) ? wp_unslash( $_POST['post_data'] ) : array(); | |
| 773 | + | |
| 774 | + if ( empty( $postId ) || empty( $websiteId ) ) { | |
| 775 | + die( 'FAIL' ); | |
| 820 | 776 | } |
| 777 | + | |
| 778 | + $website = MainWP_DB::instance()->get_website_by_id( $websiteId ); | |
| 779 | + if ( ! MainWP_System_Utility::can_edit_website( $website ) ) { | |
| 780 | + die( 'FAIL' ); | |
| 781 | + } | |
| 782 | + | |
| 783 | + try { | |
| 784 | + $information = MainWP_Connect::fetch_url_authed( | |
| 785 | + $website, | |
| 786 | + 'post_action', | |
| 787 | + array( | |
| 788 | + 'action' => $pAction, | |
| 789 | + 'id' => $postId, | |
| 790 | + 'post_data' => $post_data, | |
| 791 | + ) | |
| 792 | + ); | |
| 793 | + } catch ( MainWP_Exception $e ) { | |
| 794 | + die( 'FAIL' ); | |
| 795 | + } | |
| 796 | + if ( ! isset( $information['status'] ) || ( 'SUCCESS' != $information['status'] ) ) { | |
| 797 | + die( 'FAIL' ); | |
| 798 | + } | |
| 821 | 799 | } |
| 800 | + | |
| 822 | 801 | } |