| 1 |
<?php |
| 2 |
/** |
| 3 |
* Post Handler. |
| 4 |
* |
| 5 |
* @package MainWP/Dashboard |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace MainWP\Dashboard; |
| 9 |
|
| 10 |
/** |
| 11 |
* Class MainWP_Post_Handler |
| 12 |
* |
| 13 |
* @package MainWP\Dashboard |
| 14 |
* |
| 15 |
* @uses \MainWP\Dashboard\MainWP_Post_Base_Handler |
| 16 |
*/ |
| 17 |
class MainWP_Post_Handler extends MainWP_Post_Base_Handler { |
| 18 |
// phpcs:disable Generic.Metrics.CyclomaticComplexity -- This is the only way to achieve desired results, pull request solutions appreciated. |
| 19 |
|
| 20 |
/** |
| 21 |
* Private static variable to hold the single instance of the class. |
| 22 |
* |
| 23 |
* @static |
| 24 |
* |
| 25 |
* @var mixed Default null |
| 26 |
*/ |
| 27 |
private static $instance = null; |
| 28 |
|
| 29 |
/** |
| 30 |
* Method instance() |
| 31 |
* |
| 32 |
* Create a public static instance. |
| 33 |
* |
| 34 |
* @static |
| 35 |
* @return MainWP_Post_Handler |
| 36 |
*/ |
| 37 |
public static function instance() { |
| 38 |
if ( null == self::$instance ) { |
| 39 |
self::$instance = new self(); |
| 40 |
} |
| 41 |
return self::$instance; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Initiate all actions. |
| 46 |
* |
| 47 |
* @uses \MainWP\Dashboard\MainWP_Post_Page_Handler::get_class_name() |
| 48 |
*/ |
| 49 |
public function init() { |
| 50 |
// Page: ManageSites. |
| 51 |
$this->add_action( 'mainwp_notes_save', array( &$this, 'mainwp_notes_save' ) ); |
| 52 |
|
| 53 |
// Page: BulkAddUser. |
| 54 |
$this->add_action( 'mainwp_bulkadduser', array( &$this, 'mainwp_bulkadduser' ) ); |
| 55 |
$this->add_action( 'mainwp_importuser', array( &$this, 'mainwp_importuser' ) ); |
| 56 |
|
| 57 |
// Widget: RightNow. |
| 58 |
$this->add_action( 'mainwp_syncerrors_dismiss', array( &$this, 'mainwp_syncerrors_dismiss' ) ); |
| 59 |
|
| 60 |
if ( mainwp_current_user_have_right( 'dashboard', 'manage_security_issues' ) ) { |
| 61 |
// Page: SecurityIssues. |
| 62 |
$this->add_action( 'mainwp_security_issues_request', array( &$this, 'mainwp_security_issues_request' ) ); |
| 63 |
$this->add_action( 'mainwp_security_issues_fix', array( &$this, 'mainwp_security_issues_fix' ) ); |
| 64 |
$this->add_action( 'mainwp_security_issues_unfix', array( &$this, 'mainwp_security_issues_unfix' ) ); |
| 65 |
} |
| 66 |
|
| 67 |
$this->add_action( 'mainwp_notice_status_update', array( &$this, 'mainwp_notice_status_update' ) ); |
| 68 |
$this->add_action( 'mainwp_dismiss_twit', array( &$this, 'mainwp_dismiss_twit' ) ); |
| 69 |
$this->add_action( 'mainwp_dismiss_activate_notice', array( &$this, 'dismiss_activate_notice' ) ); |
| 70 |
$this->add_action( 'mainwp_status_saving', array( &$this, 'mainwp_status_saving' ) ); |
| 71 |
$this->add_action( 'mainwp_leftmenu_filter_group', array( &$this, 'mainwp_leftmenu_filter_group' ) ); |
| 72 |
$this->add_action( 'mainwp_widgets_order', array( &$this, 'ajax_widgets_order' ) ); |
| 73 |
$this->add_action( 'mainwp_save_settings', array( &$this, 'ajax_mainwp_save_settings' ) ); |
| 74 |
|
| 75 |
$this->add_action( 'mainwp_twitter_dashboard_action', array( &$this, 'mainwp_twitter_dashboard_action' ) ); |
| 76 |
|
| 77 |
// Page: Recent Posts. |
| 78 |
if ( mainwp_current_user_have_right( 'dashboard', 'manage_posts' ) ) { |
| 79 |
$this->add_action( 'mainwp_post_unpublish', array( &$this, 'mainwp_post_unpublish' ) ); |
| 80 |
$this->add_action( 'mainwp_post_publish', array( &$this, 'mainwp_post_publish' ) ); |
| 81 |
$this->add_action( 'mainwp_post_trash', array( &$this, 'mainwp_post_trash' ) ); |
| 82 |
$this->add_action( 'mainwp_post_delete', array( &$this, 'mainwp_post_delete' ) ); |
| 83 |
$this->add_action( 'mainwp_post_restore', array( &$this, 'mainwp_post_restore' ) ); |
| 84 |
$this->add_action( 'mainwp_post_approve', array( &$this, 'mainwp_post_approve' ) ); |
| 85 |
} |
| 86 |
$this->add_action( 'mainwp_post_addmeta', array( MainWP_Post_Page_Handler::get_class_name(), 'ajax_add_meta' ) ); |
| 87 |
// Page: Pages. |
| 88 |
if ( mainwp_current_user_have_right( 'dashboard', 'manage_pages' ) ) { |
| 89 |
$this->add_action( 'mainwp_page_unpublish', array( &$this, 'mainwp_page_unpublish' ) ); |
| 90 |
$this->add_action( 'mainwp_page_publish', array( &$this, 'mainwp_page_publish' ) ); |
| 91 |
$this->add_action( 'mainwp_page_trash', array( &$this, 'mainwp_page_trash' ) ); |
| 92 |
$this->add_action( 'mainwp_page_delete', array( &$this, 'mainwp_page_delete' ) ); |
| 93 |
$this->add_action( 'mainwp_page_restore', array( &$this, 'mainwp_page_restore' ) ); |
| 94 |
} |
| 95 |
// Page: Users. |
| 96 |
$this->add_action( 'mainwp_user_delete', array( &$this, 'mainwp_user_delete' ) ); |
| 97 |
$this->add_action( 'mainwp_user_edit', array( &$this, 'mainwp_user_edit' ) ); |
| 98 |
$this->add_action( 'mainwp_user_update_password', array( &$this, 'mainwp_user_update_password' ) ); |
| 99 |
$this->add_action( 'mainwp_user_update_user', array( &$this, 'mainwp_user_update_user' ) ); |
| 100 |
|
| 101 |
// Page: Posts. |
| 102 |
$this->add_action( 'mainwp_posts_search', array( &$this, 'mainwp_posts_search' ) ); |
| 103 |
$this->add_action( 'mainwp_get_categories', array( &$this, 'mainwp_get_categories' ) ); |
| 104 |
$this->add_action( 'mainwp_post_get_edit', array( &$this, 'mainwp_post_get_edit' ) ); |
| 105 |
$this->add_action( 'mainwp_post_postingbulk', array( MainWP_Post_Page_Handler::get_class_name(), 'ajax_posting_posts' ) ); |
| 106 |
$this->add_action( 'mainwp_get_sites_of_groups', array( MainWP_Post_Page_Handler::get_class_name(), 'ajax_get_sites_of_groups' ) ); |
| 107 |
|
| 108 |
// Page: Pages. |
| 109 |
$this->add_action( 'mainwp_pages_search', array( &$this, 'mainwp_pages_search' ) ); |
| 110 |
// Page: User. |
| 111 |
$this->add_action( 'mainwp_users_search', array( &$this, 'mainwp_users_search' ) ); |
| 112 |
|
| 113 |
$this->add_action( 'mainwp_events_notice_hide', array( &$this, 'mainwp_events_notice_hide' ) ); |
| 114 |
$this->add_action( 'mainwp_showhide_sections', array( &$this, 'mainwp_showhide_sections' ) ); |
| 115 |
$this->add_action( 'mainwp_saving_status', array( &$this, 'mainwp_saving_status' ) ); |
| 116 |
$this->add_action( 'mainwp_autoupdate_and_trust_child', array( &$this, 'mainwp_autoupdate_and_trust_child' ) ); |
| 117 |
$this->add_action( 'mainwp_installation_warning_hide', array( &$this, 'mainwp_installation_warning_hide' ) ); |
| 118 |
$this->add_action( 'mainwp_force_destroy_sessions', array( &$this, 'mainwp_force_destroy_sessions' ) ); |
| 119 |
$this->add_action( 'mainwp_recheck_http', array( &$this, 'ajax_recheck_http' ) ); |
| 120 |
$this->add_action( 'mainwp_ignore_http_response', array( &$this, 'mainwp_ignore_http_response' ) ); |
| 121 |
$this->add_action( 'mainwp_disconnect_site', array( &$this, 'ajax_disconnect_site' ) ); |
| 122 |
$this->add_action( 'mainwp_manage_sites_display_rows', array( &$this, 'ajax_sites_display_rows' ) ); |
| 123 |
$this->add_action( 'mainwp_monitoring_sites_display_rows', array( &$this, 'ajax_monitoring_display_rows' ) ); |
| 124 |
|
| 125 |
$this->add_action_nonce( 'mainwp-common-nonce' ); |
| 126 |
|
| 127 |
// Page: Clients. |
| 128 |
$this->add_action( 'mainwp_clients_add_client', array( &$this, 'mainwp_clients_add_client' ) ); |
| 129 |
$this->add_action( 'mainwp_clients_delete_client', array( &$this, 'mainwp_clients_delete_client' ) ); |
| 130 |
|
| 131 |
$this->add_action( 'mainwp_clients_save_field', array( &$this, 'mainwp_clients_save_field' ) ); |
| 132 |
$this->add_action( 'mainwp_clients_delete_general_field', array( &$this, 'mainwp_clients_delete_general_field' ) ); |
| 133 |
$this->add_action( 'mainwp_clients_delete_field', array( &$this, 'mainwp_clients_delete_field' ) ); |
| 134 |
$this->add_action( 'mainwp_clients_notes_save', array( &$this, 'mainwp_clients_notes_save' ) ); |
| 135 |
$this->add_action( 'mainwp_clients_suspend_client', array( &$this, 'mainwp_clients_suspend_client' ) ); |
| 136 |
$this->add_action( 'mainwp_refresh_icon', array( &$this, 'ajax_refresh_icon' ) ); |
| 137 |
$this->add_action( 'mainwp_upload_custom_icon', array( &$this, 'ajax_upload_custom_icon' ) ); |
| 138 |
$this->add_action( 'mainwp_select_custom_theme', array( &$this, 'ajax_select_custom_theme' ) ); |
| 139 |
$this->add_action( 'mainwp_site_actions_dismiss', array( &$this, 'ajax_site_actions_dismiss' ) ); |
| 140 |
} |
| 141 |
|
| 142 |
/** |
| 143 |
* Method add_post_action() |
| 144 |
* |
| 145 |
* Add ajax action. |
| 146 |
* |
| 147 |
* @param string $action Action to perform. |
| 148 |
* @param string $callback Callback to perform. |
| 149 |
*/ |
| 150 |
public function add_post_action( $action, $callback ) { |
| 151 |
$this->add_action( $action, $callback ); |
| 152 |
} |
| 153 |
|
| 154 |
/** |
| 155 |
* Method mainwp_installation_warning_hide() |
| 156 |
* |
| 157 |
* Hide the installation warning. |
| 158 |
*/ |
| 159 |
public function mainwp_installation_warning_hide() { |
| 160 |
$this->secure_request( 'mainwp_installation_warning_hide' ); |
| 161 |
|
| 162 |
update_option( 'mainwp_installation_warning_hide_the_notice', 'yes' ); |
| 163 |
die( 'ok' ); |
| 164 |
} |
| 165 |
|
| 166 |
/** |
| 167 |
* Method mainwp_users_search() |
| 168 |
* |
| 169 |
* Search Post handler, |
| 170 |
* Page: User. |
| 171 |
* |
| 172 |
* @uses \MainWP\Dashboard\MainWP_Cache::init_session() |
| 173 |
* @uses \MainWP\Dashboard\MainWP_User::render_table() |
| 174 |
*/ |
| 175 |
public function mainwp_users_search() { |
| 176 |
$this->secure_request( 'mainwp_users_search' ); |
| 177 |
MainWP_Cache::init_session(); |
| 178 |
|
| 179 |
$role = isset( $_POST['role'] ) ? sanitize_text_field( wp_unslash( $_POST['role'] ) ) : ''; |
| 180 |
$groups = isset( $_POST['groups'] ) && is_array( $_POST['groups'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['groups'] ) ) : ''; |
| 181 |
$sites = isset( $_POST['sites'] ) && is_array( $_POST['sites'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['sites'] ) ) : ''; |
| 182 |
$clients = isset( $_POST['clients'] ) && is_array( $_POST['clients'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['clients'] ) ) : ''; |
| 183 |
$search = isset( $_POST['search'] ) ? sanitize_text_field( wp_unslash( $_POST['search'] ) ) : ''; |
| 184 |
|
| 185 |
MainWP_User::render_table( false, $role, $groups, $sites, $search, $clients ); |
| 186 |
die(); |
| 187 |
} |
| 188 |
|
| 189 |
/** |
| 190 |
* Method mainwp_posts_search() |
| 191 |
* |
| 192 |
* Search Post handler, |
| 193 |
* Page: Posts. |
| 194 |
* |
| 195 |
* @uses \MainWP\Dashboard\MainWP_Cache::init_session() |
| 196 |
* @uses \MainWP\Dashboard\MainWP_Post::render_table() |
| 197 |
* @uses \MainWP\Dashboard\MainWP_Utility::update_option() |
| 198 |
*/ |
| 199 |
public function mainwp_posts_search() { |
| 200 |
$this->secure_request( 'mainwp_posts_search' ); |
| 201 |
$post_type = ( isset( $_POST['post_type'] ) && 0 < strlen( sanitize_text_field( wp_unslash( $_POST['post_type'] ) ) ) ? sanitize_text_field( wp_unslash( $_POST['post_type'] ) ) : 'post' ); |
| 202 |
if ( isset( $_POST['maximum'] ) ) { |
| 203 |
MainWP_Utility::update_option( 'mainwp_maximumPosts', isset( $_POST['maximum'] ) ? intval( $_POST['maximum'] ) : 50 ); |
| 204 |
} |
| 205 |
|
| 206 |
$keyword = isset( $_POST['keyword'] ) ? sanitize_text_field( wp_unslash( $_POST['keyword'] ) ) : ''; |
| 207 |
$dtsstart = isset( $_POST['dtsstart'] ) ? sanitize_text_field( wp_unslash( trim( $_POST['dtsstart'] ) ) ) : ''; |
| 208 |
$dtsstop = isset( $_POST['dtsstop'] ) ? sanitize_text_field( wp_unslash( trim( $_POST['dtsstop'] ) ) ) : ''; |
| 209 |
$status = isset( $_POST['status'] ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : ''; |
| 210 |
$groups = isset( $_POST['groups'] ) && is_array( $_POST['groups'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['groups'] ) ) : ''; |
| 211 |
$sites = isset( $_POST['sites'] ) && is_array( $_POST['sites'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['sites'] ) ) : ''; |
| 212 |
$clients = isset( $_POST['clients'] ) && is_array( $_POST['clients'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['clients'] ) ) : ''; |
| 213 |
$postId = isset( $_POST['postId'] ) ? sanitize_text_field( wp_unslash( $_POST['postId'] ) ) : ''; |
| 214 |
$userId = isset( $_POST['userId'] ) ? sanitize_text_field( wp_unslash( $_POST['userId'] ) ) : ''; |
| 215 |
$search_on = isset( $_POST['search_on'] ) ? sanitize_text_field( wp_unslash( $_POST['search_on'] ) ) : ''; |
| 216 |
$table_content_only = isset( $_POST['table_content'] ) && $_POST['table_content'] ? true : false; |
| 217 |
|
| 218 |
MainWP_Cache::init_session(); |
| 219 |
if ( $table_content_only ) { |
| 220 |
MainWP_Post::render_table_body( $keyword, $dtsstart, $dtsstop, $status, $groups, $sites, $postId, $userId, $post_type, $search_on, true, $clients ); |
| 221 |
} else { |
| 222 |
MainWP_Post::render_table( false, $keyword, $dtsstart, $dtsstop, $status, $groups, $sites, $postId, $userId, $post_type, $search_on, $clients ); |
| 223 |
} |
| 224 |
die(); |
| 225 |
} |
| 226 |
/** |
| 227 |
* Method mainwp_pages_search() |
| 228 |
* |
| 229 |
* Search Post handler, |
| 230 |
* Page: Pages. |
| 231 |
* |
| 232 |
* @uses \MainWP\Dashboard\MainWP_Cache::init_session() |
| 233 |
* @uses \MainWP\Dashboard\MainWP_Page::render_table() |
| 234 |
* |
| 235 |
* @uses \MainWP\Dashboard\MainWP_Utility::update_option() |
| 236 |
*/ |
| 237 |
public function mainwp_pages_search() { |
| 238 |
$this->secure_request( 'mainwp_pages_search' ); |
| 239 |
if ( isset( $_POST['maximum'] ) ) { |
| 240 |
MainWP_Utility::update_option( 'mainwp_maximumPages', intval( $_POST['maximum'] ) ? intval( $_POST['maximum'] ) : 50 ); |
| 241 |
} |
| 242 |
|
| 243 |
$keyword = isset( $_POST['keyword'] ) ? sanitize_text_field( wp_unslash( $_POST['keyword'] ) ) : ''; |
| 244 |
$dtsstart = isset( $_POST['dtsstart'] ) ? sanitize_text_field( wp_unslash( $_POST['dtsstart'] ) ) : ''; |
| 245 |
$dtsstop = isset( $_POST['dtsstop'] ) ? sanitize_text_field( wp_unslash( $_POST['dtsstop'] ) ) : ''; |
| 246 |
$status = isset( $_POST['status'] ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : ''; |
| 247 |
$groups = isset( $_POST['groups'] ) && is_array( $_POST['groups'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['groups'] ) ) : ''; |
| 248 |
$sites = isset( $_POST['sites'] ) && is_array( $_POST['sites'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['sites'] ) ) : ''; |
| 249 |
$clients = isset( $_POST['clients'] ) && is_array( $_POST['clients'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['clients'] ) ) : ''; |
| 250 |
$search_on = isset( $_POST['search_on'] ) ? sanitize_text_field( wp_unslash( $_POST['search_on'] ) ) : ''; |
| 251 |
|
| 252 |
MainWP_Cache::init_session(); |
| 253 |
MainWP_Page::render_table( false, $keyword, $dtsstart, $dtsstop, $status, $groups, $sites, $search_on, $clients ); |
| 254 |
die(); |
| 255 |
} |
| 256 |
|
| 257 |
/** |
| 258 |
* Method mainwp_get_categories() |
| 259 |
* |
| 260 |
* Get post/page categories. |
| 261 |
* |
| 262 |
* @uses \MainWP\Dashboard\MainWP_Post_Page_Handler::get_categories() |
| 263 |
*/ |
| 264 |
public function mainwp_get_categories() { |
| 265 |
$this->secure_request( 'mainwp_get_categories' ); |
| 266 |
MainWP_Post_Page_Handler::get_categories(); |
| 267 |
die(); |
| 268 |
} |
| 269 |
|
| 270 |
/** |
| 271 |
* Method mainwp_post_get_edit() |
| 272 |
* |
| 273 |
* Get post to edit. |
| 274 |
* |
| 275 |
* @uses \MainWP\Dashboard\MainWP_Post_Page_Handler::get_post() |
| 276 |
*/ |
| 277 |
public function mainwp_post_get_edit() { |
| 278 |
$this->secure_request( 'mainwp_post_get_edit' ); |
| 279 |
MainWP_Post_Page_Handler::get_post(); |
| 280 |
die(); |
| 281 |
} |
| 282 |
|
| 283 |
/** |
| 284 |
* Method mainwp_user_delete() |
| 285 |
* |
| 286 |
* Delete User from Child Site, |
| 287 |
* Page: Users. |
| 288 |
* |
| 289 |
* @uses \MainWP\Dashboard\MainWP_User::delete() |
| 290 |
*/ |
| 291 |
public function mainwp_user_delete() { |
| 292 |
$this->secure_request( 'mainwp_user_delete' ); |
| 293 |
MainWP_User::delete(); |
| 294 |
} |
| 295 |
|
| 296 |
/** |
| 297 |
* Method mainwp_user_edit() |
| 298 |
* |
| 299 |
* Edit User from Child Site, |
| 300 |
* Page: Users. |
| 301 |
* |
| 302 |
* @uses \MainWP\Dashboard\MainWP_User::edit() |
| 303 |
*/ |
| 304 |
public function mainwp_user_edit() { |
| 305 |
$this->secure_request( 'mainwp_user_edit' ); |
| 306 |
MainWP_User::edit(); |
| 307 |
} |
| 308 |
|
| 309 |
/** |
| 310 |
* Method mainwp_user_update_password( |
| 311 |
* |
| 312 |
* Update User password from Child Site, |
| 313 |
* Page: Users. |
| 314 |
* |
| 315 |
* @uses \MainWP\Dashboard\MainWP_User::update_password() |
| 316 |
*/ |
| 317 |
public function mainwp_user_update_password() { |
| 318 |
$this->secure_request( 'mainwp_user_update_password' ); |
| 319 |
MainWP_User::update_password(); |
| 320 |
} |
| 321 |
|
| 322 |
/** |
| 323 |
* Method mainwp_user_update_user() |
| 324 |
* |
| 325 |
* Update User from Child Site, |
| 326 |
* Page: Users. |
| 327 |
* |
| 328 |
* @uses \MainWP\Dashboard\MainWP_User::update_user() |
| 329 |
*/ |
| 330 |
public function mainwp_user_update_user() { |
| 331 |
$this->secure_request( 'mainwp_user_update_user' ); |
| 332 |
MainWP_User::update_user(); |
| 333 |
} |
| 334 |
|
| 335 |
/** |
| 336 |
* Method mainwp_post_unpublish() |
| 337 |
* |
| 338 |
* Unpublish post from Child Site, |
| 339 |
* Page: Recent Posts. |
| 340 |
* |
| 341 |
* @uses \MainWP\Dashboard\MainWP_Recent_Posts::unpublish() |
| 342 |
*/ |
| 343 |
public function mainwp_post_unpublish() { |
| 344 |
$this->secure_request( 'mainwp_post_unpublish' ); |
| 345 |
MainWP_Recent_Posts::unpublish(); |
| 346 |
} |
| 347 |
|
| 348 |
/** |
| 349 |
* Method mainwp_post_publish() |
| 350 |
* |
| 351 |
* Publish post on Child Site, |
| 352 |
* Page: Recent Posts. |
| 353 |
* |
| 354 |
* @uses \MainWP\Dashboard\MainWP_Recent_Posts::publish() |
| 355 |
*/ |
| 356 |
public function mainwp_post_publish() { |
| 357 |
$this->secure_request( 'mainwp_post_publish' ); |
| 358 |
MainWP_Recent_Posts::publish(); |
| 359 |
} |
| 360 |
|
| 361 |
/** |
| 362 |
* Method mainwp_post_approve() |
| 363 |
* |
| 364 |
* Approve post on Child Site, |
| 365 |
* Page: Recent Posts. |
| 366 |
* |
| 367 |
* @uses \MainWP\Dashboard\MainWP_Recent_Posts::approve() |
| 368 |
*/ |
| 369 |
public function mainwp_post_approve() { |
| 370 |
$this->secure_request( 'mainwp_post_approve' ); |
| 371 |
MainWP_Recent_Posts::approve(); |
| 372 |
} |
| 373 |
|
| 374 |
/** |
| 375 |
* Method mainwp_post_trash() |
| 376 |
* |
| 377 |
* Trash post on Child Site, |
| 378 |
* Page: Recent Posts. |
| 379 |
* |
| 380 |
* @uses \MainWP\Dashboard\MainWP_Recent_Posts::trash() |
| 381 |
*/ |
| 382 |
public function mainwp_post_trash() { |
| 383 |
$this->secure_request( 'mainwp_post_trash' ); |
| 384 |
|
| 385 |
MainWP_Recent_Posts::trash(); |
| 386 |
} |
| 387 |
|
| 388 |
/** |
| 389 |
* Method mainwp_post_delete() |
| 390 |
* |
| 391 |
* Delete post on Child Site, |
| 392 |
* Page: Recent Posts. |
| 393 |
* |
| 394 |
* @uses \MainWP\Dashboard\MainWP_Recent_Posts::delete() |
| 395 |
*/ |
| 396 |
public function mainwp_post_delete() { |
| 397 |
$this->secure_request( 'mainwp_post_delete' ); |
| 398 |
|
| 399 |
MainWP_Recent_Posts::delete(); |
| 400 |
} |
| 401 |
|
| 402 |
/** |
| 403 |
* Method mainwp_post_restore() |
| 404 |
* |
| 405 |
* Restore post, |
| 406 |
* Page: Recent Posts. |
| 407 |
* |
| 408 |
* @uses \MainWP\Dashboard\MainWP_Recent_Posts::restore() |
| 409 |
*/ |
| 410 |
public function mainwp_post_restore() { |
| 411 |
$this->secure_request( 'mainwp_post_restore' ); |
| 412 |
|
| 413 |
MainWP_Recent_Posts::restore(); |
| 414 |
} |
| 415 |
|
| 416 |
/** |
| 417 |
* Method mainwp_page_unpublish() |
| 418 |
* |
| 419 |
* Unpublish page, |
| 420 |
* Page: Recent Pages. |
| 421 |
* |
| 422 |
* @uses \MainWP\Dashboard\MainWP_Page::unpublish() |
| 423 |
*/ |
| 424 |
public function mainwp_page_unpublish() { |
| 425 |
$this->secure_request( 'mainwp_page_unpublish' ); |
| 426 |
MainWP_Page::unpublish(); |
| 427 |
} |
| 428 |
|
| 429 |
/** |
| 430 |
* Method mainwp_page_publish() |
| 431 |
* |
| 432 |
* Publish page, |
| 433 |
* Page: Recent Pages. |
| 434 |
* |
| 435 |
* @uses \MainWP\Dashboard\MainWP_Page::publish() |
| 436 |
*/ |
| 437 |
public function mainwp_page_publish() { |
| 438 |
$this->secure_request( 'mainwp_page_publish' ); |
| 439 |
MainWP_Page::publish(); |
| 440 |
} |
| 441 |
|
| 442 |
/** |
| 443 |
* Method mainwp_page_trash() |
| 444 |
* |
| 445 |
* Trash page, |
| 446 |
* Page: Recent Pages. |
| 447 |
* |
| 448 |
* @uses \MainWP\Dashboard\MainWP_Page::trash() |
| 449 |
*/ |
| 450 |
public function mainwp_page_trash() { |
| 451 |
$this->secure_request( 'mainwp_page_trash' ); |
| 452 |
MainWP_Page::trash(); |
| 453 |
} |
| 454 |
|
| 455 |
/** |
| 456 |
* Method mainwp_page_delete() |
| 457 |
* |
| 458 |
* Delete page, |
| 459 |
* Page: Recent Pages. |
| 460 |
* |
| 461 |
* @uses \MainWP\Dashboard\MainWP_Page::delete() |
| 462 |
*/ |
| 463 |
public function mainwp_page_delete() { |
| 464 |
$this->secure_request( 'mainwp_page_delete' ); |
| 465 |
MainWP_Page::delete(); |
| 466 |
} |
| 467 |
|
| 468 |
/** |
| 469 |
* Method mainwp_page_restor() |
| 470 |
* |
| 471 |
* Restore page, |
| 472 |
* Page: Recent Pages. |
| 473 |
* |
| 474 |
* @uses \MainWP\Dashboard\MainWP_Page::restore() |
| 475 |
*/ |
| 476 |
public function mainwp_page_restore() { |
| 477 |
$this->secure_request( 'mainwp_page_restore' ); |
| 478 |
MainWP_Page::restore(); |
| 479 |
} |
| 480 |
|
| 481 |
/** |
| 482 |
* Method mainwp_notice_status_update() |
| 483 |
* |
| 484 |
* Hide after installation notices, |
| 485 |
* (PHP version, Trust MainWP Child, Multisite Warning and OpenSSL warning). |
| 486 |
* |
| 487 |
* @uses \MainWP\Dashboard\MainWP_Utility::update_option() |
| 488 |
*/ |
| 489 |
public function mainwp_notice_status_update() { |
| 490 |
$this->secure_request( 'mainwp_notice_status_update' ); |
| 491 |
|
| 492 |
$no_id = isset( $_POST['notice_id'] ) ? sanitize_text_field( wp_unslash( $_POST['notice_id'] ) ) : false; |
| 493 |
if ( 'mail_failed' === $no_id ) { |
| 494 |
MainWP_Utility::update_option( 'mainwp_notice_wp_mail_failed', 'hide' ); |
| 495 |
die( 'ok' ); |
| 496 |
} |
| 497 |
|
| 498 |
/** |
| 499 |
* Current user global. |
| 500 |
* |
| 501 |
* @global string |
| 502 |
*/ |
| 503 |
global $current_user; |
| 504 |
$user_id = $current_user->ID; |
| 505 |
if ( $user_id ) { |
| 506 |
$status = get_user_option( 'mainwp_notice_saved_status' ); |
| 507 |
if ( ! is_array( $status ) ) { |
| 508 |
$status = array(); |
| 509 |
} |
| 510 |
if ( ! empty( $no_id ) ) { |
| 511 |
$status[ $no_id ] = 1; |
| 512 |
update_user_option( $user_id, 'mainwp_notice_saved_status', $status ); |
| 513 |
} |
| 514 |
} |
| 515 |
die( 1 ); |
| 516 |
} |
| 517 |
|
| 518 |
/** |
| 519 |
* Method mainwp_status_saving() |
| 520 |
* |
| 521 |
* Save last_sync_sites time() or mainwp_status_saved_values. |
| 522 |
*/ |
| 523 |
public function mainwp_status_saving() { |
| 524 |
$this->secure_request( 'mainwp_status_saving' ); |
| 525 |
$values = get_option( 'mainwp_status_saved_values' ); |
| 526 |
|
| 527 |
if ( ! isset( $_POST['status'] ) ) { |
| 528 |
die( -1 ); |
| 529 |
} |
| 530 |
|
| 531 |
if ( 'last_sync_sites' === $_POST['status'] ) { |
| 532 |
if ( isset( $_POST['isGlobalSync'] ) && ! empty( $_POST['isGlobalSync'] ) ) { |
| 533 |
update_option( 'mainwp_last_synced_all_sites', time() ); |
| 534 |
|
| 535 |
/** |
| 536 |
* Action: mainwp_synced_all_sites |
| 537 |
* |
| 538 |
* Fires upon successfull synchronization process. |
| 539 |
* |
| 540 |
* @since 3.5.1 |
| 541 |
*/ |
| 542 |
do_action( 'mainwp_synced_all_sites' ); |
| 543 |
} |
| 544 |
die( 'ok' ); |
| 545 |
} |
| 546 |
|
| 547 |
$status = isset( $_POST['status'] ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : ''; |
| 548 |
$value = isset( $_POST['value'] ) ? sanitize_text_field( wp_unslash( $_POST['value'] ) ) : ''; |
| 549 |
|
| 550 |
if ( ! empty( $status ) ) { |
| 551 |
if ( empty( $value ) ) { |
| 552 |
if ( isset( $values[ $status ] ) ) { |
| 553 |
unset( $values[ $status ] ); |
| 554 |
} |
| 555 |
} else { |
| 556 |
$values[ $status ] = $value; |
| 557 |
} |
| 558 |
update_option( 'mainwp_status_saved_values', $values ); |
| 559 |
} |
| 560 |
|
| 561 |
die( 'ok' ); |
| 562 |
} |
| 563 |
|
| 564 |
/** |
| 565 |
* Method ajax_widget_order() |
| 566 |
* |
| 567 |
* Update saved widget order. |
| 568 |
*/ |
| 569 |
public function ajax_widgets_order() { |
| 570 |
|
| 571 |
$this->secure_request( 'mainwp_widgets_order' ); |
| 572 |
$user = wp_get_current_user(); |
| 573 |
if ( $user && ! empty( $_POST['page'] ) ) { |
| 574 |
$page = isset( $_POST['page'] ) ? sanitize_text_field( wp_unslash( $_POST['page'] ) ) : ''; |
| 575 |
$order = isset( $_POST['order'] ) ? sanitize_text_field( wp_unslash( $_POST['order'] ) ) : ''; |
| 576 |
|
| 577 |
if ( 'mainwp_page_manageclients' == $page ) { |
| 578 |
$item_id = isset( $_POST['item_id'] ) ? intval( $_POST['item_id'] ) : 0; |
| 579 |
$sorted_array = get_user_option( 'mainwp_widgets_sorted_' . strtolower( $page ) ); |
| 580 |
if ( ! is_array( $sorted_array ) ) { |
| 581 |
$sorted_array = array(); |
| 582 |
} |
| 583 |
$sorted_array[ $item_id ] = $order; |
| 584 |
update_user_option( $user->ID, 'mainwp_widgets_sorted_' . $page, $sorted_array, true ); |
| 585 |
} else { |
| 586 |
update_user_option( $user->ID, 'mainwp_widgets_sorted_' . $page, $order, true ); |
| 587 |
} |
| 588 |
die( 'ok' ); |
| 589 |
} |
| 590 |
die( -1 ); |
| 591 |
} |
| 592 |
|
| 593 |
/** |
| 594 |
* Method ajax_mainwp_save_settings() |
| 595 |
* |
| 596 |
* Update saved MainWP Settings. |
| 597 |
* |
| 598 |
* @uses \MainWP\Dashboard\MainWP_Utility::update_option() |
| 599 |
*/ |
| 600 |
public function ajax_mainwp_save_settings() { |
| 601 |
$this->secure_request( 'mainwp_save_settings' ); |
| 602 |
$name = isset( $_POST['name'] ) ? sanitize_text_field( wp_unslash( $_POST['name'] ) ) : ''; |
| 603 |
if ( ! empty( $name ) ) { |
| 604 |
$option_name = 'mainwp_' . $name; |
| 605 |
$val = isset( $_POST['value'] ) ? sanitize_text_field( wp_unslash( $_POST['value'] ) ) : ''; |
| 606 |
MainWP_Utility::update_option( $option_name, $val ); |
| 607 |
} |
| 608 |
die( 'ok' ); |
| 609 |
} |
| 610 |
|
| 611 |
/** |
| 612 |
* Method mainwp_leftmenu_filter_group() |
| 613 |
* |
| 614 |
* MainWP left menu filter by group. |
| 615 |
* |
| 616 |
* @uses \MainWP\Dashboard\MainWP_DB::query() |
| 617 |
* @uses \MainWP\Dashboard\MainWP_DB::get_websites_by_group_id() |
| 618 |
* @uses \MainWP\Dashboard\MainWP_DB::fetch_object() |
| 619 |
* @uses \MainWP\Dashboard\MainWP_DB::free_result() |
| 620 |
*/ |
| 621 |
public function mainwp_leftmenu_filter_group() { |
| 622 |
$this->secure_request( 'mainwp_leftmenu_filter_group' ); |
| 623 |
|
| 624 |
$gid = isset( $_POST['group_id'] ) ? intval( $_POST['group_id'] ) : false; |
| 625 |
|
| 626 |
if ( ! empty( $gid ) ) { |
| 627 |
$ids = ''; |
| 628 |
$websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_by_group_id( $gid, true ) ); |
| 629 |
while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { |
| 630 |
$ids .= $website->id . ','; |
| 631 |
} |
| 632 |
MainWP_DB::free_result( $websites ); |
| 633 |
$ids = rtrim( $ids, ',' ); |
| 634 |
die( $ids ); |
| 635 |
} |
| 636 |
die( '' ); |
| 637 |
} |
| 638 |
|
| 639 |
/** |
| 640 |
* Method mainwp_dismiss_twit() |
| 641 |
* |
| 642 |
* Dismiss the twitter bragger. |
| 643 |
* |
| 644 |
* @uses \MainWP\Dashboard\MainWP_Twitter::clear_twitter_info() |
| 645 |
*/ |
| 646 |
public function mainwp_dismiss_twit() { |
| 647 |
$this->secure_request( 'mainwp_dismiss_twit' ); |
| 648 |
|
| 649 |
/** |
| 650 |
* Current user global. |
| 651 |
* |
| 652 |
* @global string |
| 653 |
*/ |
| 654 |
global $current_user; |
| 655 |
|
| 656 |
$user_id = $current_user->ID; |
| 657 |
if ( $user_id && isset( $_POST['twitId'] ) && ! empty( $_POST['twitId'] ) && isset( $_POST['what'] ) && ! empty( $_POST['what'] ) ) { |
| 658 |
MainWP_Twitter::clear_twitter_info( sanitize_text_field( wp_unslash( $_POST['what'] ) ), sanitize_text_field( wp_unslash( $_POST['twitId'] ) ) ); |
| 659 |
} |
| 660 |
die( 1 ); |
| 661 |
} |
| 662 |
|
| 663 |
/** |
| 664 |
* Method dismiss_activate_notice() |
| 665 |
* |
| 666 |
* Dismiss activate notice. |
| 667 |
*/ |
| 668 |
public function dismiss_activate_notice() { |
| 669 |
$this->secure_request( 'mainwp_dismiss_activate_notice' ); |
| 670 |
|
| 671 |
/** |
| 672 |
* Current user global. |
| 673 |
* |
| 674 |
* @global string |
| 675 |
*/ |
| 676 |
global $current_user; |
| 677 |
|
| 678 |
$user_id = $current_user->ID; |
| 679 |
$slug = isset( $_POST['slug'] ) ? sanitize_text_field( wp_unslash( $_POST['slug'] ) ) : ''; |
| 680 |
if ( $user_id && ! empty( $slug ) ) { |
| 681 |
$activate_notices = get_user_option( 'mainwp_hide_activate_notices' ); |
| 682 |
if ( ! is_array( $activate_notices ) ) { |
| 683 |
$activate_notices = array(); |
| 684 |
} |
| 685 |
|
| 686 |
$activate_notices[ $slug ] = time(); |
| 687 |
update_user_option( $user_id, 'mainwp_hide_activate_notices', $activate_notices ); |
| 688 |
} |
| 689 |
die( 1 ); |
| 690 |
} |
| 691 |
|
| 692 |
/** |
| 693 |
* Method mainwp_twitter_dashboard_action() |
| 694 |
* |
| 695 |
* Post handler for twitter bragger. |
| 696 |
* |
| 697 |
* @return mixed $html|$success |
| 698 |
* |
| 699 |
* @uses \MainWP\Dashboard\MainWP_Twitter |
| 700 |
* @uses \MainWP\Dashboard\MainWP_Twitter::update_twitter_info() |
| 701 |
* @uses \MainWP\Dashboard\MainWP_Twitter::enabled_twitter_messages() |
| 702 |
* @uses \MainWP\Dashboard\MainWP_Twitter::get_twitter_notice() |
| 703 |
* @uses \MainWP\Dashboard\MainWP_Twitter::get_twit_to_send() |
| 704 |
*/ |
| 705 |
public function mainwp_twitter_dashboard_action() { |
| 706 |
$this->secure_request( 'mainwp_twitter_dashboard_action' ); |
| 707 |
|
| 708 |
$success = false; |
| 709 |
$actionName = isset( $_POST['actionName'] ) ? sanitize_text_field( wp_unslash( $_POST['actionName'] ) ) : ''; |
| 710 |
$countSites = isset( $_POST['countSites'] ) ? intval( $_POST['countSites'] ) : 0; |
| 711 |
$countRealItems = isset( $_POST['countRealItems'] ) ? intval( $_POST['countRealItems'] ) : 0; |
| 712 |
$countItems = isset( $_POST['countItems'] ) ? intval( $_POST['countItems'] ) : 0; |
| 713 |
$countSeconds = isset( $_POST['countSeconds'] ) ? intval( $_POST['countSeconds'] ) : 0; |
| 714 |
|
| 715 |
if ( ! empty( $actionName ) && ! empty( $countSites ) ) { |
| 716 |
$success = MainWP_Twitter::update_twitter_info( $actionName, $countSites, $countSeconds, $countRealItems, time(), $countItems ); |
| 717 |
} |
| 718 |
|
| 719 |
if ( ! empty( $_POST['showNotice'] ) ) { |
| 720 |
if ( MainWP_Twitter::enabled_twitter_messages() ) { |
| 721 |
$twitters = MainWP_Twitter::get_twitter_notice( $actionName ); |
| 722 |
$html = ''; |
| 723 |
if ( is_array( $twitters ) ) { |
| 724 |
foreach ( $twitters as $timeid => $twit_mess ) { |
| 725 |
if ( ! empty( $twit_mess ) ) { |
| 726 |
$sendText = MainWP_Twitter::get_twit_to_send( $actionName, $timeid ); |
| 727 |
$html .= '<div class="mainwp-tips mainwp-notice mainwp-notice-blue twitter"><span class="mainwp-tip" twit-what="' . esc_attr( $actionName ) . '" twit-id="' . $timeid . '">' . $twit_mess . '</span> ' . MainWP_Twitter::gen_twitter_button( $sendText, false ) . '<span><a href="#" class="mainwp-dismiss-twit mainwp-right" ><i class="fa fa-times-circle"></i> ' . esc_html__( 'Dismiss', 'mainwp' ) . '</a></span></div>'; |
| 728 |
} |
| 729 |
} |
| 730 |
} |
| 731 |
die( $html ); |
| 732 |
} |
| 733 |
} elseif ( $success ) { |
| 734 |
die( 'ok' ); |
| 735 |
} |
| 736 |
|
| 737 |
die( '' ); |
| 738 |
} |
| 739 |
|
| 740 |
/** |
| 741 |
* Method mainwp_security_issues_request() |
| 742 |
* |
| 743 |
* Post handler for, |
| 744 |
* Page: SecurityIssues. |
| 745 |
* |
| 746 |
* @uses \MainWP\Dashboard\MainWP_Exception |
| 747 |
* @uses \MainWP\Dashboard\MainWP_Security_Issues::fetch_security_issues() |
| 748 |
*/ |
| 749 |
public function mainwp_security_issues_request() { |
| 750 |
$this->secure_request( 'mainwp_security_issues_request' ); |
| 751 |
|
| 752 |
try { |
| 753 |
wp_send_json( array( 'result' => MainWP_Security_Issues::fetch_security_issues() ) ); |
| 754 |
} catch ( MainWP_Exception $e ) { |
| 755 |
die( |
| 756 |
wp_json_encode( |
| 757 |
array( |
| 758 |
'error' => array( |
| 759 |
'message' => $e->getMessage(), |
| 760 |
'extra' => $e->get_message_extra(), |
| 761 |
), |
| 762 |
) |
| 763 |
) |
| 764 |
); |
| 765 |
} |
| 766 |
} |
| 767 |
|
| 768 |
/** |
| 769 |
* Method mainwp_security_issues_fix() |
| 770 |
* |
| 771 |
* Post handler for 'fix issues', |
| 772 |
* Page: SecurityIssues. |
| 773 |
* |
| 774 |
* @uses \MainWP\Dashboard\MainWP_Exception |
| 775 |
* @uses \MainWP\Dashboard\MainWP_Security_Issues::fix_security_issue() |
| 776 |
*/ |
| 777 |
public function mainwp_security_issues_fix() { |
| 778 |
$this->secure_request( 'mainwp_security_issues_fix' ); |
| 779 |
|
| 780 |
try { |
| 781 |
wp_send_json( array( 'result' => MainWP_Security_Issues::fix_security_issue() ) ); |
| 782 |
} catch ( MainWP_Exception $e ) { |
| 783 |
die( |
| 784 |
wp_json_encode( |
| 785 |
array( |
| 786 |
'error' => array( |
| 787 |
'message' => $e->getMessage(), |
| 788 |
'extra' => $e->get_message_extra(), |
| 789 |
), |
| 790 |
) |
| 791 |
) |
| 792 |
); |
| 793 |
} |
| 794 |
} |
| 795 |
|
| 796 |
/** |
| 797 |
* Method mainwp_security_issues_unfix() |
| 798 |
* |
| 799 |
* Post handler for 'unfix issues', |
| 800 |
* Page: SecurityIssues. |
| 801 |
* |
| 802 |
* @uses \MainWP\Dashboard\MainWP_Exception |
| 803 |
* @uses \MainWP\Dashboard\MainWP_Security_Issues::unfix_security_issue() |
| 804 |
*/ |
| 805 |
public function mainwp_security_issues_unfix() { |
| 806 |
$this->secure_request( 'mainwp_security_issues_unfix' ); |
| 807 |
|
| 808 |
try { |
| 809 |
wp_send_json( array( 'result' => MainWP_Security_Issues::unfix_security_issue() ) ); |
| 810 |
} catch ( MainWP_Exception $e ) { |
| 811 |
die( |
| 812 |
wp_json_encode( |
| 813 |
array( |
| 814 |
'error' => array( |
| 815 |
'message' => $e->getMessage(), |
| 816 |
'extra' => $e->get_message_extra(), |
| 817 |
), |
| 818 |
) |
| 819 |
) |
| 820 |
); |
| 821 |
} |
| 822 |
} |
| 823 |
|
| 824 |
/** |
| 825 |
* Method ajax_disconnect_site() |
| 826 |
* |
| 827 |
* Disconnect Child Site. |
| 828 |
* |
| 829 |
* @uses \MainWP\Dashboard\MainWP_Connect::fetch_url_authed() |
| 830 |
* @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() |
| 831 |
*/ |
| 832 |
public function ajax_disconnect_site() { |
| 833 |
$this->secure_request( 'mainwp_disconnect_site' ); |
| 834 |
|
| 835 |
$siteid = isset( $_POST['wp_id'] ) ? intval( $_POST['wp_id'] ) : 0; |
| 836 |
|
| 837 |
if ( empty( $siteid ) ) { |
| 838 |
die( wp_json_encode( array( 'error' => 'Error: site id empty' ) ) ); |
| 839 |
} |
| 840 |
|
| 841 |
$website = MainWP_DB::instance()->get_website_by_id( $siteid ); |
| 842 |
|
| 843 |
if ( ! $website ) { |
| 844 |
die( wp_json_encode( array( 'error' => 'Not found site' ) ) ); |
| 845 |
} |
| 846 |
|
| 847 |
try { |
| 848 |
$information = MainWP_Connect::fetch_url_authed( $website, 'disconnect' ); |
| 849 |
} catch ( \Exception $e ) { |
| 850 |
$information = array( 'error' => esc_html__( 'fetch_url_authed exception', 'mainwp' ) ); |
| 851 |
} |
| 852 |
|
| 853 |
wp_send_json( $information ); |
| 854 |
} |
| 855 |
|
| 856 |
/** |
| 857 |
* Method ajax_sites_display_rows() |
| 858 |
* |
| 859 |
* Display rows via ajax, |
| 860 |
* Page: Manage Sites. |
| 861 |
* |
| 862 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites::ajax_optimize_display_rows() |
| 863 |
*/ |
| 864 |
public function ajax_sites_display_rows() { |
| 865 |
$this->secure_request( 'mainwp_manage_sites_display_rows' ); |
| 866 |
MainWP_Manage_Sites::ajax_optimize_display_rows(); |
| 867 |
} |
| 868 |
|
| 869 |
/** |
| 870 |
* Method ajax_monitoring_display_rows() |
| 871 |
* |
| 872 |
* Display rows via ajax, |
| 873 |
* Page: Monitoring Sites. |
| 874 |
* |
| 875 |
* @uses \MainWP\Dashboard\MainWP_Monitoring::ajax_optimize_display_rows() |
| 876 |
*/ |
| 877 |
public function ajax_monitoring_display_rows() { |
| 878 |
$this->secure_request( 'mainwp_monitoring_sites_display_rows' ); |
| 879 |
MainWP_Monitoring::ajax_optimize_display_rows(); |
| 880 |
} |
| 881 |
|
| 882 |
|
| 883 |
/** |
| 884 |
* Method mainwp_bulkadduser() |
| 885 |
* |
| 886 |
* Bulk Add User for, |
| 887 |
* Page: BulkAddUser. |
| 888 |
* |
| 889 |
* @uses \MainWP\Dashboard\MainWP_User::do_bulk_add() |
| 890 |
*/ |
| 891 |
public function mainwp_bulkadduser() { |
| 892 |
$this->check_security( 'mainwp_bulkadduser' ); |
| 893 |
MainWP_User::do_bulk_add(); |
| 894 |
die(); |
| 895 |
} |
| 896 |
|
| 897 |
/** |
| 898 |
* Method mainwp_importuser() |
| 899 |
* |
| 900 |
* Import user. |
| 901 |
* |
| 902 |
* @uses \MainWP\Dashboard\MainWP_User::do_import() |
| 903 |
*/ |
| 904 |
public function mainwp_importuser() { |
| 905 |
$this->secure_request( 'mainwp_importuser' ); |
| 906 |
MainWP_User::do_import(); |
| 907 |
} |
| 908 |
|
| 909 |
/** |
| 910 |
* Method mainwp_clients_add_client() |
| 911 |
* |
| 912 |
* Add Client for, |
| 913 |
* Page: BulkAddClient. |
| 914 |
*/ |
| 915 |
public function mainwp_clients_add_client() { |
| 916 |
$this->check_security( 'mainwp_clients_add_client' ); |
| 917 |
MainWP_Client::add_client(); |
| 918 |
die(); |
| 919 |
} |
| 920 |
|
| 921 |
/** |
| 922 |
* Method mainwp_clients_delete_client() |
| 923 |
* |
| 924 |
* Add Client for, |
| 925 |
* Page: BulkAddClient. |
| 926 |
*/ |
| 927 |
public function mainwp_clients_delete_client() { |
| 928 |
$this->check_security( 'mainwp_clients_delete_client' ); |
| 929 |
$ret = array( 'success' => false ); |
| 930 |
$client_id = isset( $_POST['clientid'] ) ? intval( $_POST['clientid'] ) : 0; |
| 931 |
|
| 932 |
if ( $client_id ) { |
| 933 |
MainWP_DB_Client::instance()->delete_client( $client_id ); |
| 934 |
$ret['success'] = 'SUCCESS'; |
| 935 |
$ret['result'] = esc_html__( 'Client removed successfully.', 'mainwp' ); |
| 936 |
} else { |
| 937 |
$ret['result'] = esc_html__( 'Client ID empty.', 'mainwp' ); |
| 938 |
} |
| 939 |
|
| 940 |
echo wp_json_encode( $ret ); |
| 941 |
exit; |
| 942 |
} |
| 943 |
|
| 944 |
/** |
| 945 |
* Method mainwp_clients_save_field() |
| 946 |
* |
| 947 |
* Save client custom fields. |
| 948 |
*/ |
| 949 |
public function mainwp_clients_save_field() { |
| 950 |
$this->check_security( 'mainwp_clients_save_field' ); |
| 951 |
MainWP_Client::save_client_field(); |
| 952 |
die(); |
| 953 |
} |
| 954 |
|
| 955 |
|
| 956 |
/** |
| 957 |
* Method mainwp_clients_delete_general_field() |
| 958 |
* |
| 959 |
* Delete client general fields. |
| 960 |
*/ |
| 961 |
public function mainwp_clients_delete_general_field() { |
| 962 |
$this->check_security( 'mainwp_clients_delete_general_field' ); |
| 963 |
$ret = array( 'success' => false ); |
| 964 |
$field_id = intval( $_POST['field_id'] ); |
| 965 |
$client_id = 0; // 0 general fields. |
| 966 |
if ( MainWP_DB_Client::instance()->delete_client_field_by( 'field_id', $field_id, $client_id ) ) { |
| 967 |
$ret['success'] = true; |
| 968 |
} |
| 969 |
echo wp_json_encode( $ret ); |
| 970 |
exit; |
| 971 |
} |
| 972 |
|
| 973 |
|
| 974 |
/** |
| 975 |
* Method mainwp_clients_delete_field() |
| 976 |
* |
| 977 |
* Delete client custom fields. |
| 978 |
*/ |
| 979 |
public function mainwp_clients_delete_field() { |
| 980 |
$this->check_security( 'mainwp_clients_delete_field' ); |
| 981 |
$ret = array( 'success' => false ); |
| 982 |
$field_id = intval( $_POST['field_id'] ); |
| 983 |
$client_id = isset( $_POST['client_id'] ) ? intval( $_POST['client_id'] ) : 0; // $client_id > 0, individual token. |
| 984 |
if ( $client_id ) { |
| 985 |
if ( MainWP_DB_Client::instance()->delete_client_field_by( 'field_id', $field_id, $client_id ) ) { |
| 986 |
$ret['success'] = true; |
| 987 |
} |
| 988 |
} |
| 989 |
echo wp_json_encode( $ret ); |
| 990 |
exit; |
| 991 |
} |
| 992 |
|
| 993 |
/** |
| 994 |
* Method mainwp_notes_save() |
| 995 |
* |
| 996 |
* Post handler for save notes on, |
| 997 |
* Page: Manage Sites. |
| 998 |
* |
| 999 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites_Handler::save_note() |
| 1000 |
*/ |
| 1001 |
public function mainwp_notes_save() { |
| 1002 |
$this->secure_request( 'mainwp_notes_save' ); |
| 1003 |
MainWP_Manage_Sites_Handler::save_note(); |
| 1004 |
} |
| 1005 |
|
| 1006 |
/** |
| 1007 |
* Method mainwp_clients_notes_save() |
| 1008 |
* |
| 1009 |
* Post handler for save notes on, |
| 1010 |
* Page: Manage Sites. |
| 1011 |
* |
| 1012 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites_Handler::save_note() |
| 1013 |
*/ |
| 1014 |
public function mainwp_clients_notes_save() { |
| 1015 |
$this->secure_request( 'mainwp_clients_notes_save' ); |
| 1016 |
MainWP_Client::save_note(); |
| 1017 |
} |
| 1018 |
|
| 1019 |
/** |
| 1020 |
* Method mainwp_clients_suspend_client() |
| 1021 |
* |
| 1022 |
* Post handler for suspend client, |
| 1023 |
* Page: Manage Sites. |
| 1024 |
* |
| 1025 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites_Handler::save_note() |
| 1026 |
*/ |
| 1027 |
public function mainwp_clients_suspend_client() { |
| 1028 |
$this->secure_request( 'mainwp_clients_suspend_client' ); |
| 1029 |
$clientid = isset( $_POST['clientid'] ) ? intval( $_POST['clientid'] ) : 0; |
| 1030 |
$suspended = isset( $_POST['suspend_status'] ) && $_POST['suspend_status'] ? 1 : 0; |
| 1031 |
|
| 1032 |
if ( empty( $clientid ) ) { |
| 1033 |
wp_die( 'Error - empty client id!' ); |
| 1034 |
} |
| 1035 |
|
| 1036 |
$params = array( |
| 1037 |
'client_id' => $clientid, |
| 1038 |
'suspended' => $suspended, |
| 1039 |
); |
| 1040 |
|
| 1041 |
MainWP_DB_Client::instance()->update_client( $params ); |
| 1042 |
|
| 1043 |
MainWP_DB_Client::instance()->suspend_unsuspend_websites_by_client_id( $clientid, $suspended ); |
| 1044 |
|
| 1045 |
wp_die( 'success' ); |
| 1046 |
} |
| 1047 |
|
| 1048 |
/** |
| 1049 |
* Method mainwp_syncerrors_dismiss() |
| 1050 |
* |
| 1051 |
* Dismiss Sync errors for, |
| 1052 |
* Widget: RightNow. |
| 1053 |
* |
| 1054 |
* @uses \MainWP\Dashboard\MainWP_Updates_Overview::dismiss_sync_errors() |
| 1055 |
*/ |
| 1056 |
public function mainwp_syncerrors_dismiss() { |
| 1057 |
|
| 1058 |
$this->secure_request( 'mainwp_syncerrors_dismiss' ); |
| 1059 |
|
| 1060 |
try { |
| 1061 |
die( wp_json_encode( array( 'result' => MainWP_Updates_Overview::dismiss_sync_errors() ) ) ); |
| 1062 |
} catch ( \Exception $e ) { |
| 1063 |
die( wp_json_encode( array( 'error' => $e->getMessage() ) ) ); |
| 1064 |
} |
| 1065 |
} |
| 1066 |
|
| 1067 |
/** |
| 1068 |
* Method mainwp_events_notice_hide() |
| 1069 |
* |
| 1070 |
* Hide events notice. |
| 1071 |
*/ |
| 1072 |
public function mainwp_events_notice_hide() { |
| 1073 |
$this->secure_request( 'mainwp_events_notice_hide' ); |
| 1074 |
|
| 1075 |
if ( isset( $_POST['notice'] ) ) { |
| 1076 |
$current_options = get_option( 'mainwp_showhide_events_notice' ); |
| 1077 |
if ( ! is_array( $current_options ) ) { |
| 1078 |
$current_options = array(); |
| 1079 |
} |
| 1080 |
if ( 'first_site' === $_POST['notice'] ) { |
| 1081 |
update_option( 'mainwp_first_site_events_notice', '' ); |
| 1082 |
} elseif ( 'request_reviews1' === $_POST['notice'] ) { |
| 1083 |
$current_options['request_reviews1'] = 15; |
| 1084 |
$current_options['request_reviews1_starttime'] = time(); |
| 1085 |
} elseif ( 'request_reviews1_forever' === $_POST['notice'] || 'request_reviews2_forever' === $_POST['notice'] ) { |
| 1086 |
$current_options['request_reviews1'] = 'forever'; |
| 1087 |
$current_options['request_reviews2'] = 'forever'; |
| 1088 |
} elseif ( 'request_reviews2' === $_POST['notice'] ) { |
| 1089 |
$current_options['request_reviews2'] = 15; |
| 1090 |
$current_options['request_reviews2_starttime'] = time(); |
| 1091 |
} elseif ( 'trust_child' === $_POST['notice'] ) { |
| 1092 |
$current_options['trust_child'] = 1; |
| 1093 |
} elseif ( 'multi_site' === $_POST['notice'] ) { |
| 1094 |
$current_options['hide_multi_site_notice'] = 1; |
| 1095 |
} |
| 1096 |
update_option( 'mainwp_showhide_events_notice', $current_options ); |
| 1097 |
} |
| 1098 |
die( 'ok' ); |
| 1099 |
} |
| 1100 |
|
| 1101 |
/** |
| 1102 |
* Method mainwp_showhide_sections() |
| 1103 |
* |
| 1104 |
* Show/Hide sections. |
| 1105 |
*/ |
| 1106 |
public function mainwp_showhide_sections() { |
| 1107 |
if ( isset( $_POST['sec'] ) && isset( $_POST['status'] ) ) { |
| 1108 |
$opts = get_option( 'mainwp_opts_showhide_sections' ); |
| 1109 |
if ( ! is_array( $opts ) ) { |
| 1110 |
$opts = array(); |
| 1111 |
} |
| 1112 |
$opts[ sanitize_text_field( wp_unslash( $_POST['sec'] ) ) ] = sanitize_text_field( wp_unslash( $_POST['status'] ) ); |
| 1113 |
update_option( 'mainwp_opts_showhide_sections', $opts ); |
| 1114 |
die( 'ok' ); |
| 1115 |
} |
| 1116 |
die( 'failed' ); |
| 1117 |
} |
| 1118 |
|
| 1119 |
/** |
| 1120 |
* Method mainwp_saving_status() |
| 1121 |
* |
| 1122 |
* MainWP Saving Status. |
| 1123 |
*/ |
| 1124 |
public function mainwp_saving_status() { |
| 1125 |
if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'mainwp_ajax' ) ) { |
| 1126 |
die( esc_html__( 'WP nonce could not be verified. Please reload the page and try again.', 'mainwp' ) ); |
| 1127 |
} |
| 1128 |
$saving_status = isset( $_POST['saving_status'] ) ? sanitize_text_field( wp_unslash( $_POST['saving_status'] ) ) : false; |
| 1129 |
if ( ! empty( $saving_status ) ) { |
| 1130 |
$current_options = get_option( 'mainwp_opts_saving_status' ); |
| 1131 |
if ( ! is_array( $current_options ) ) { |
| 1132 |
$current_options = array(); |
| 1133 |
} |
| 1134 |
if ( isset( $_POST['value'] ) ) { |
| 1135 |
$current_options[ $saving_status ] = sanitize_text_field( wp_unslash( $_POST['value'] ) ); |
| 1136 |
} |
| 1137 |
update_option( 'mainwp_opts_saving_status', $current_options ); |
| 1138 |
} |
| 1139 |
die( 'ok' ); |
| 1140 |
} |
| 1141 |
|
| 1142 |
/** |
| 1143 |
* Method ajax_recheck_http() |
| 1144 |
* |
| 1145 |
* Recheck Child Site http status code & message. |
| 1146 |
* |
| 1147 |
* @uses \MainWP\Dashboard\MainWP_Connect::check_ignored_http_code() |
| 1148 |
* @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() |
| 1149 |
* @uses \MainWP\Dashboard\MainWP_Monitoring_Handler::handle_check_website() |
| 1150 |
*/ |
| 1151 |
public function ajax_recheck_http() { |
| 1152 |
$this->check_security( 'mainwp_recheck_http' ); |
| 1153 |
|
| 1154 |
if ( ! isset( $_POST['websiteid'] ) || empty( $_POST['websiteid'] ) ) { |
| 1155 |
die( -1 ); |
| 1156 |
} |
| 1157 |
|
| 1158 |
$website = MainWP_DB::instance()->get_website_by_id( intval( $_POST['websiteid'] ) ); |
| 1159 |
if ( empty( $website ) ) { |
| 1160 |
die( -1 ); |
| 1161 |
} |
| 1162 |
|
| 1163 |
$result = MainWP_Monitoring_Handler::handle_check_website( $website ); |
| 1164 |
$http_code = ( is_array( $result ) && isset( $result['httpCode'] ) ) ? $result['httpCode'] : 0; |
| 1165 |
$check_result = MainWP_Connect::check_ignored_http_code( $http_code ); |
| 1166 |
die( |
| 1167 |
wp_json_encode( |
| 1168 |
array( |
| 1169 |
'httpcode' => esc_html( $http_code ), |
| 1170 |
'status' => $check_result ? 1 : 0, |
| 1171 |
) |
| 1172 |
) |
| 1173 |
); |
| 1174 |
} |
| 1175 |
|
| 1176 |
/** |
| 1177 |
* Method mainwp_ignore_http_response() |
| 1178 |
* |
| 1179 |
* Ignore Child Site https response. |
| 1180 |
* |
| 1181 |
* @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() |
| 1182 |
* @uses \MainWP\Dashboard\MainWP_DB::update_website_values() |
| 1183 |
*/ |
| 1184 |
public function mainwp_ignore_http_response() { |
| 1185 |
$this->check_security( 'mainwp_ignore_http_response' ); |
| 1186 |
$siteid = isset( $_POST['websiteid'] ) ? intval( $_POST['websiteid'] ) : false; |
| 1187 |
|
| 1188 |
if ( empty( $siteid ) ) { |
| 1189 |
die( -1 ); |
| 1190 |
} |
| 1191 |
|
| 1192 |
$website = MainWP_DB::instance()->get_website_by_id( $siteid ); |
| 1193 |
if ( empty( $website ) ) { |
| 1194 |
die( -1 ); |
| 1195 |
} |
| 1196 |
|
| 1197 |
MainWP_DB::instance()->update_website_values( $website->id, array( 'http_response_code' => '-1' ) ); |
| 1198 |
die( wp_json_encode( array( 'ok' => 1 ) ) ); |
| 1199 |
} |
| 1200 |
|
| 1201 |
/** |
| 1202 |
* Method mainwp_autoupdate_and_trust_child() |
| 1203 |
* |
| 1204 |
* Set MainWP Child Plugin to Trusted & AutoUpdate. |
| 1205 |
* |
| 1206 |
* @uses \MainWP\Dashboard\MainWP_Plugins_Handler::trust_plugin() |
| 1207 |
*/ |
| 1208 |
public function mainwp_autoupdate_and_trust_child() { |
| 1209 |
$this->secure_request( 'mainwp_autoupdate_and_trust_child' ); |
| 1210 |
if ( get_option( 'mainwp_automaticDailyUpdate' ) != 1 ) { |
| 1211 |
update_option( 'mainwp_automaticDailyUpdate', 1 ); |
| 1212 |
} |
| 1213 |
MainWP_Plugins_Handler::trust_plugin( 'mainwp-child/mainwp-child.php' ); |
| 1214 |
die( 'ok' ); |
| 1215 |
} |
| 1216 |
|
| 1217 |
/** |
| 1218 |
* Method mainwp_force_destroy_sessions() |
| 1219 |
* |
| 1220 |
* Force destroy sessions. |
| 1221 |
* |
| 1222 |
* @uses \MainWP\Dashboard\MainWP_Connect::fetch_url_authed() |
| 1223 |
* @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() |
| 1224 |
* |
| 1225 |
* @uses \MainWP\Dashboard\MainWP_System_Utility::can_edit_website() |
| 1226 |
*/ |
| 1227 |
public function mainwp_force_destroy_sessions() { |
| 1228 |
$this->secure_request( 'mainwp_force_destroy_sessions' ); |
| 1229 |
|
| 1230 |
$website_id = ( isset( $_POST['website_id'] ) ? (int) $_POST['website_id'] : 0 ); |
| 1231 |
|
| 1232 |
if ( ! MainWP_DB::instance()->get_website_by_id( $website_id ) ) { |
| 1233 |
die( wp_json_encode( array( 'error' => array( 'message' => esc_html__( 'This website does not exist.', 'mainwp' ) ) ) ) ); |
| 1234 |
} |
| 1235 |
|
| 1236 |
$website = MainWP_DB::instance()->get_website_by_id( $website_id ); |
| 1237 |
if ( ! MainWP_System_Utility::can_edit_website( $website ) ) { |
| 1238 |
die( wp_json_encode( array( 'error' => array( 'message' => esc_html__( 'You cannot edit this website.', 'mainwp' ) ) ) ) ); |
| 1239 |
} |
| 1240 |
|
| 1241 |
try { |
| 1242 |
$information = MainWP_Connect::fetch_url_authed( |
| 1243 |
$website, |
| 1244 |
'settings_tools', |
| 1245 |
array( |
| 1246 |
'action' => 'force_destroy_sessions', |
| 1247 |
) |
| 1248 |
); |
| 1249 |
|
| 1250 |
/** |
| 1251 |
* MainWP information array. |
| 1252 |
* |
| 1253 |
* @global object $mainWP |
| 1254 |
*/ |
| 1255 |
global $mainWP; |
| 1256 |
|
| 1257 |
if ( ( '2.0.22' === $mainWP->get_version() ) || ( '2.0.23' === $mainWP->get_version() ) ) { |
| 1258 |
if ( 1 != get_option( 'mainwp_fixed_security_2022' ) ) { |
| 1259 |
update_option( 'mainwp_fixed_security_2022', 1 ); |
| 1260 |
} |
| 1261 |
} |
| 1262 |
} catch ( \Exception $e ) { |
| 1263 |
$information = array( 'error' => esc_html__( 'fetch_url_authed exception', 'mainwp' ) ); |
| 1264 |
} |
| 1265 |
|
| 1266 |
wp_send_json( $information ); |
| 1267 |
} |
| 1268 |
|
| 1269 |
/** |
| 1270 |
* Method ajax_refresh_icon() |
| 1271 |
*/ |
| 1272 |
public function ajax_refresh_icon() { |
| 1273 |
$this->secure_request( 'mainwp_refresh_icon' ); |
| 1274 |
$slug = isset( $_POST['slug'] ) ? sanitize_text_field( wp_unslash( $_POST['slug'] ) ) : ''; |
| 1275 |
$type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : ''; |
| 1276 |
|
| 1277 |
if ( empty( $slug ) ) { |
| 1278 |
wp_die( 'failed' ); |
| 1279 |
} |
| 1280 |
|
| 1281 |
$fet_icon = MainWP_System_Utility::handle_get_icon( $slug, $type ); |
| 1282 |
|
| 1283 |
if ( ! empty( $fet_icon ) ) { |
| 1284 |
wp_die( 'success' ); |
| 1285 |
} else { |
| 1286 |
wp_die( 'failed' ); |
| 1287 |
} |
| 1288 |
} |
| 1289 |
|
| 1290 |
/** |
| 1291 |
* Method ajax_upload_custom_icon() |
| 1292 |
*/ |
| 1293 |
public function ajax_upload_custom_icon() { |
| 1294 |
$this->secure_request( 'mainwp_upload_custom_icon' ); |
| 1295 |
$slug = isset( $_POST['slug'] ) ? sanitize_text_field( wp_unslash( $_POST['slug'] ) ) : ''; |
| 1296 |
$type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : ''; |
| 1297 |
$delete = isset( $_POST['delete'] ) ? intval( $_POST['delete'] ) : 0; |
| 1298 |
|
| 1299 |
if ( empty( $slug ) || ( 'plugin' !== $type && 'theme' !== $type ) ) { |
| 1300 |
wp_die( 'failed' ); |
| 1301 |
} |
| 1302 |
|
| 1303 |
$sub_folder = ''; |
| 1304 |
|
| 1305 |
if ( 'plugin' === $type ) { |
| 1306 |
$sub_folder = 'plugin-icons'; |
| 1307 |
} elseif ( 'theme' === $type ) { |
| 1308 |
$sub_folder = 'theme-icons'; |
| 1309 |
} else { |
| 1310 |
wp_die( wp_json_encode( array( 'result' => 'invalid' ) ) ); |
| 1311 |
} |
| 1312 |
|
| 1313 |
if ( $delete ) { |
| 1314 |
MainWP_System_Utility::update_cached_icons( '', $slug, $type, true ); |
| 1315 |
wp_die( wp_json_encode( array( 'result' => 'success' ) ) ); |
| 1316 |
} |
| 1317 |
|
| 1318 |
$output = MainWP_System_Utility::handle_upload_image( $sub_folder, $_FILES['mainwp_upload_icon_uploader'], 0 ); |
| 1319 |
|
| 1320 |
$uploaded_icon = 'NOTCHANGE'; |
| 1321 |
if ( is_array( $output ) && isset( $output['filename'] ) && ! empty( $output['filename'] ) ) { |
| 1322 |
$uploaded_icon = $output['filename']; |
| 1323 |
} |
| 1324 |
|
| 1325 |
if ( 'NOTCHANGE' !== $uploaded_icon ) { |
| 1326 |
MainWP_System_Utility::update_cached_icons( $uploaded_icon, $slug, $type, true ); |
| 1327 |
wp_die( wp_json_encode( array( 'result' => 'success' ) ) ); |
| 1328 |
} else { |
| 1329 |
wp_die( wp_json_encode( array( 'result' => 'failed' ) ) ); |
| 1330 |
} |
| 1331 |
} |
| 1332 |
|
| 1333 |
/** |
| 1334 |
* Method ajax_select_custom_theme() |
| 1335 |
*/ |
| 1336 |
public function ajax_select_custom_theme() { |
| 1337 |
$this->secure_request( 'mainwp_select_custom_theme' ); |
| 1338 |
$theme = isset( $_POST['theme'] ) ? sanitize_text_field( wp_unslash( $_POST['theme'] ) ) : ''; |
| 1339 |
if ( empty( $theme ) ) { |
| 1340 |
wp_die( 'failed' ); |
| 1341 |
} |
| 1342 |
|
| 1343 |
$user = wp_get_current_user(); |
| 1344 |
if ( empty( $user ) || empty( $user->ID ) ) { |
| 1345 |
wp_die( 'failed' ); |
| 1346 |
} |
| 1347 |
|
| 1348 |
update_user_option( $user->ID, 'mainwp_selected_theme', $theme ); |
| 1349 |
wp_die( 'success' ); |
| 1350 |
} |
| 1351 |
|
| 1352 |
|
| 1353 |
/** |
| 1354 |
* Method ajax_site_actions_dismiss() |
| 1355 |
*/ |
| 1356 |
public function ajax_site_actions_dismiss() { |
| 1357 |
$this->secure_request( 'mainwp_site_actions_dismiss' ); |
| 1358 |
$action_id = isset( $_POST['action_id'] ) ? intval( $_POST['action_id'] ) : 0; |
| 1359 |
if ( empty( $action_id ) ) { |
| 1360 |
wp_die( 'failed' ); |
| 1361 |
} |
| 1362 |
$update = array( |
| 1363 |
'dismiss' => 1, |
| 1364 |
); |
| 1365 |
MainWP_DB_Site_Actions::instance()->update_action_by_id( $action_id, $update ); |
| 1366 |
wp_die( 'success' ); |
| 1367 |
} |
| 1368 |
|
| 1369 |
|
| 1370 |
} |
| 1371 |
|