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