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