| 1 |
<?php |
| 2 |
|
| 3 |
class MainWP_Recent_Posts { |
| 4 |
|
| 5 |
public static function getClassName() { |
| 6 |
return __CLASS__; |
| 7 |
} |
| 8 |
|
| 9 |
public static function render() { |
| 10 |
MainWP_Recent_Posts::renderSites( false, false ); |
| 11 |
} |
| 12 |
|
| 13 |
public static function renderSites( $renew, $pExit = true ) { |
| 14 |
|
| 15 |
$recent_number = apply_filters( 'mainwp_recent_posts_pages_number', 5 ); // $recent_number: support >=0 and <= 30 |
| 16 |
|
| 17 |
$current_wpid = MainWP_Utility::get_current_wpid(); |
| 18 |
|
| 19 |
if ( $current_wpid ) { |
| 20 |
$sql = MainWP_DB::Instance()->getSQLWebsiteById( $current_wpid ); |
| 21 |
} else { |
| 22 |
$sql = MainWP_DB::Instance()->getSQLWebsitesForCurrentUser(); |
| 23 |
} |
| 24 |
|
| 25 |
$websites = MainWP_DB::Instance()->query( $sql ); |
| 26 |
|
| 27 |
$allPosts = array(); |
| 28 |
if ( $websites ) { |
| 29 |
while ( $websites && ( $website = @MainWP_DB::fetch_object( $websites ) ) ) { |
| 30 |
if ( $website->recent_posts == '' ) { |
| 31 |
continue; |
| 32 |
} |
| 33 |
|
| 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 |
} |
| 45 |
|
| 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' ); |
| 56 |
|
| 57 |
?> |
| 58 |
|
| 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> |
| 81 |
|
| 82 |
<!-- Published List --> |
| 83 |
|
| 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 |
} |
| 108 |
|
| 109 |
$name = strip_tags( $recent_posts_published[ $i ][ 'website' ]->name ); |
| 110 |
|
| 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> |
| 142 |
|
| 143 |
<!-- END Published List --> |
| 144 |
|
| 145 |
<!-- Draft List --> |
| 146 |
|
| 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> |
| 202 |
|
| 203 |
<!-- END Draft List --> |
| 204 |
|
| 205 |
<!-- Pending List --> |
| 206 |
|
| 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> |
| 262 |
|
| 263 |
<!-- END Pending List --> |
| 264 |
|
| 265 |
<!-- Future List --> |
| 266 |
|
| 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> |
| 323 |
|
| 324 |
<!-- END Future List --> |
| 325 |
|
| 326 |
<!-- Trash List --> |
| 327 |
|
| 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 --> |
| 383 |
|
| 384 |
<div class="ui hidden divider"></div> |
| 385 |
|
| 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 |
} |
| 399 |
|
| 400 |
public static function publish() { |
| 401 |
MainWP_Recent_Posts::action( 'publish' ); |
| 402 |
die( json_encode( array( 'result' => __( 'Post has been published!', 'mainwp' ) ) ) ); |
| 403 |
} |
| 404 |
|
| 405 |
public static function approve() { |
| 406 |
MainWP_Recent_Posts::action( 'publish' ); |
| 407 |
die( json_encode( array( 'result' => __( 'Post has been approved!', 'mainwp' ) ) ) ); |
| 408 |
} |
| 409 |
|
| 410 |
public static function unpublish() { |
| 411 |
MainWP_Recent_Posts::action( 'unpublish' ); |
| 412 |
die( json_encode( array( 'result' => __( 'Post has been unpublished!', 'mainwp' ) ) ) ); |
| 413 |
} |
| 414 |
|
| 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 |
} |
| 419 |
|
| 420 |
public static function delete() { |
| 421 |
MainWP_Recent_Posts::action( 'delete' ); |
| 422 |
die( json_encode( array( 'result' => __( 'Post has been permanently deleted!', 'mainwp' ) ) ) ); |
| 423 |
} |
| 424 |
|
| 425 |
public static function restore() { |
| 426 |
MainWP_Recent_Posts::action( 'restore' ); |
| 427 |
die( json_encode( array( 'result' => __( 'Post has been restored!', 'mainwp' ) ) ) ); |
| 428 |
} |
| 429 |
|
| 430 |
public static function action( $pAction ) { |
| 431 |
$postId = $_POST[ 'postId' ]; |
| 432 |
$websiteIdEnc = $_POST[ 'websiteId' ]; |
| 433 |
|
| 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 |
} |
| 441 |
|
| 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 |
} |
| 446 |
|
| 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 |
|
| 494 |
} |
| 495 |
|