PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.0.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.0.1
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
mainwp / pages / page-mainwp-bulk-add.php

page-mainwp-bulk-add.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 5.0.1, at pages/page-mainwp-bulk-add.php

99 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Bulk Add Handler
4 *
5 * Handles Bulk addition of Pages, Posts, User Import, User Addition & Admin Users Password.
6 *
7 * @package MainWP/Dashboard
8 */
9
10 namespace MainWP\Dashboard;
11
12 /**
13 * Class MainWP_Bulk_Add
14 *
15 * @used-by MainWP_Page::BulkAddPage
16 * @used-by MainWP_Post::BulkAddPost
17 * @used-by MainWP_User::do_bulk_add
18 * @used-by MainWP_User::do_import
19 * @used-by MainWP_Bulk_Update_Admin_Passwords::BulkAddUser
20 */
21 class MainWP_Bulk_Add {
22
23 /**
24 * Method get_class_name()
25 *
26 * Get Class Name.
27 *
28 * @return object __CLASS__
29 */
30 public static function get_class_name() {
31 return __CLASS__;
32 }
33
34 /**
35 * Method posting_bulk_handler()
36 *
37 * @param mixed $data Data to process.
38 * @param object $website The website object.
39 * @param object $output Function output object.
40 *
41 * @return mixed $output
42 *
43 * @uses \MainWP\Dashboard\MainWP_Error_Helper::get_error_message()
44 * @uses \MainWP\Dashboard\MainWP_Exception
45 * @uses \MainWP\Dashboard\MainWP_Logger::warning_for_website()
46 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_child_response()
47 */
48 public static function posting_bulk_handler( $data, $website, &$output ) {
49 if ( MainWP_Demo_Handle::get_instance()->is_demo_website( $website ) ) {
50 return;
51 }
52 if ( preg_match( '/<mainwp>(.*)<\/mainwp>/', $data, $results ) > 0 ) {
53 $result = $results[1];
54 $information = MainWP_System_Utility::get_child_response( base64_decode( $result ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible.
55
56 if ( is_array( $information ) && isset( $information['other_data']['new_post_data'] ) ) { // created/updated post/page.
57 do_action( 'mainwp_post_created', $website, 'newpost', $information['other_data']['new_post_data'] );
58 }
59
60 if ( is_array( $information ) && isset( $information['other_data']['new_user_data'] ) ) { // created user.
61 $data = $information['other_data']['new_user_data'];
62 /**
63 * Fires immediately after new user action.
64 *
65 * @since 4.5.1.1
66 */
67 do_action( 'mainwp_user_action', $website, 'created', $data );
68 }
69
70 if ( is_array( $information ) && isset( $information['other_data']['update_admin_password'] ) ) { // created user.
71 $data = $information['other_data']['update_admin_password'];
72 /**
73 * Fires immediately after update admin password action.
74 *
75 * @since 4.5.1.1
76 */
77 do_action( 'mainwp_user_action', $website, 'newadminpassword', $data );
78 }
79
80 if ( isset( $information['added'] ) ) {
81 $output->ok[ $website->id ] = '1';
82 if ( isset( $information['link'] ) ) {
83 $output->link[ $website->id ] = esc_html( $information['link'] );
84 }
85 if ( isset( $information['added_id'] ) ) {
86 $output->added_id[ $website->id ] = esc_html( $information['added_id'] );
87 }
88 } elseif ( isset( $information['error'] ) ) {
89 $output->errors[ $website->id ] = esc_html__( 'ERROR: ', 'mainwp' ) . esc_html( $information['error'] );
90 } else {
91 $output->errors[ $website->id ] = esc_html__( 'Undefined error! Please reinstall the MainWP Child plugin on the child site', 'mainwp' );
92 }
93 } else {
94 MainWP_Logger::instance()->debug_for_website( $website, 'posting_bulk_handler', '[' . $website->url . '] Result was: [data-start]' . $data . '[data-end]' );
95 $output->errors[ $website->id ] = MainWP_Error_Helper::get_error_message( new MainWP_Exception( 'NOMAINWP', $website->url ) ); //phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
96 }
97 }
98 }
99