PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
← All changes | pages/page-mainwp-user.php +79 -61 6.1 → 6.2.2 View file →
@@ -714,9 +714,9 @@
714 714 <div id="mainwp-edit-users-modal" class="ui modal">
715 715 <i class="close icon"></i>
716 716 <div class="header"><?php esc_html_e( 'Edit User', 'mainwp' ); ?></div>
717 717 <div class="scrolling content">
718 - <div class="ui info message"><?php esc_html_e( 'Empty fields will not be passed to child sites.', 'mainwp' ); ?></div>
718 + <div class="ui info message"><?php esc_html_e( 'Blank fields will not be changed.', 'mainwp' ); ?></div>
719 719 <form id="update_user_profile" class="ui form">
720 720 <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
721 721
722 722 <h3 class="ui header"><?php esc_html_e( 'Name', 'mainwp' ); ?></h3>
@@ -2039,15 +2039,14 @@
2039 2039 MainWP_DB::free_result( $websites );
2040 2040 }
2041 2041 }
2042 2042 }
2043 -
2043 + $output = new \stdClass();
2044 2044 if ( ! empty( $dbwebsites ) ) {
2045 2045 $post_data = array(
2046 2046 'new_user' => base64_encode( wp_json_encode( $user_to_add ) ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible.
2047 2047 'send_password' => ( isset( $_POST['send_password'] ) ? intval( $_POST['send_password'] ) : '' ),
2048 2048 );
2049 - $output = new \stdClass();
2050 2049 $output->ok = array();
2051 2050 $output->errors = array();
2052 2051
2053 2052 /**
@@ -2151,22 +2150,39 @@
2151 2150 static::render_header( 'Import' );
2152 2151 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
2153 2152 $errors = array();
2154 2153 if ( isset( $_FILES['import_user_file_bulkupload']['error'] ) && UPLOAD_ERR_OK === $_FILES['import_user_file_bulkupload']['error'] ) {
2155 - if ( isset( $_FILES['import_user_file_bulkupload']['tmp_name'] ) && is_uploaded_file( $_FILES['import_user_file_bulkupload']['tmp_name'] ) ) {
2156 - $tmp_path = isset( $_FILES['import_user_file_bulkupload']['tmp_name'] ) ? sanitize_text_field( wp_unslash( $_FILES['import_user_file_bulkupload']['tmp_name'] ) ) : '';
2157 - MainWP_System_Utility::get_wp_file_system();
2158 - // phpcs:enable
2159 - /**
2160 - * WordPress files system object.
2161 - *
2162 - * @global object
2163 - */
2164 - global $wp_filesystem;
2154 + $upld_success = false;
2155 + if ( isset( $_FILES['import_user_file_bulkupload']['tmp_name'] ) ) {
2156 + $tmp_path = $_FILES['import_user_file_bulkupload']['tmp_name'];
2157 + if ( is_uploaded_file( $tmp_path ) ) {
2158 + $upld_success = true;
2159 + }
2160 + }
2165 2161
2166 - $content = $wp_filesystem->get_contents( $tmp_path );
2167 - $lines = explode( "\r\n", $content );
2162 + if ( ! $upld_success ) {
2163 + $errors[] = esc_html__( 'File could not be uploaded. Temporary file cold not be created. Please make sure that the tmpfile() PHP function is enabled on your server.', 'mainwp' );
2164 + } else {
2165 + $lines = array();
2168 2166
2167 + $hasWPFileSystem = MainWP_System_Utility::get_wp_file_system();
2168 +
2169 + // phpcs:enable
2170 + /**
2171 + * WordPress files system object.
2172 + *
2173 + * @global object
2174 + */
2175 + global $wp_filesystem;
2176 +
2177 + if ( $hasWPFileSystem && ! empty( $wp_filesystem ) ) {
2178 + $content = $wp_filesystem->get_contents( $tmp_path );
2179 + if ( is_string( $content ) ) {
2180 + $lines = explode( "\r\n", $content );
2181 + }
2182 + }
2183 + $header_line = '';
2184 + $valid_rows_count = 0;
2169 2185 if ( is_array( $lines ) && ! empty( $lines ) ) {
2170 2186 $i = 0;
2171 2187 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
2172 2188 if ( ! empty( $_POST['import_user_chk_header_first'] ) ) {
@@ -2184,9 +2200,9 @@
2184 2200 }
2185 2201
2186 2202 $items = str_getcsv( $line, ',' );
2187 2203
2188 - if ( 3 > count( $items ) ) {
2204 + if ( 10 > count( $items ) ) {
2189 2205 continue;
2190 2206 }
2191 2207
2192 2208 $import_data = array(
@@ -2203,17 +2219,19 @@
2203 2219 );
2204 2220 $encoded = wp_json_encode( $import_data );
2205 2221 ?>
2206 2222 <input type="hidden" id="user_import_csv_line_<?php echo intval( $i + 1 ); ?>" original-line="<?php echo esc_attr( sanitize_text_field( $line ) ); ?>" encoded-data="<?php echo esc_html( $encoded ); ?>" />
2207 - <?php
2208 - ++$i;
2223 + <?php
2224 + ++$i;
2225 + ++$valid_rows_count;
2209 2226 }
2210 2227 $header_line = trim( $header_line );
2211 - ?>
2212 - <div class="ui modal" id="mainwp-import-users-modal">
2213 - <i class="close icon"></i>
2214 - <div class="header"><?php esc_html_e( 'Importing new users and add them to your sites.', 'mainwp' ); ?></div>
2215 - <div class="scrolling content">
2228 + if ( $valid_rows_count ) {
2229 + ?>
2230 + <div class="ui modal" id="mainwp-import-users-modal">
2231 + <i class="close icon"></i>
2232 + <div class="header"><?php esc_html_e( 'Importing new users and add them to your sites.', 'mainwp' ); ?></div>
2233 + <div class="scrolling content">
2216 2234 <?php
2217 2235 /**
2218 2236 * Action: mainwp_import_users_modal_top
2219 2237 *
@@ -2222,53 +2240,53 @@
2222 2240 * @since 4.1
2223 2241 */
2224 2242 do_action( 'mainwp_import_users_modal_top' );
2225 2243 ?>
2226 - <div id="MainWPBulkUploadUserLoading" style="display: none;"><i class="ui active inline loader tiny"></i> <?php esc_html_e( 'Importing Users', 'mainwp' ); ?></div>
2227 - <input type="hidden" id="import_user_do_import" value="1"/>
2228 - <input type="hidden" id="import_user_total_import" value="<?php echo esc_attr( $i ); ?>"/>
2229 - <p>
2230 - <div class="import_user_import_listing" id="import_user_import_logging">
2231 - <pre class="log"><?php echo esc_html( $header_line ) . "\n"; ?></pre>
2244 + <div id="MainWPBulkUploadUserLoading" style="display: none;"><i class="ui active inline loader tiny"></i> <?php esc_html_e( 'Importing Users', 'mainwp' ); ?></div>
2245 + <input type="hidden" id="import_user_do_import" value="1"/>
2246 + <input type="hidden" id="import_user_total_import" value="<?php echo esc_attr( $i ); ?>"/>
2247 + <p>
2248 + <div class="import_user_import_listing" id="import_user_import_logging">
2249 + <pre class="log"><?php echo esc_html( $header_line ) . "\n"; ?></pre>
2250 + </div>
2251 + </p>
2252 + <div id="import_user_import_failed_rows" style="display: none;">
2253 + <span><?php echo esc_html( $header_line ); ?></span>
2232 2254 </div>
2233 - </p>
2234 - <div id="import_user_import_failed_rows" style="display: none;">
2235 - <span><?php echo esc_html( $header_line ); ?></span>
2255 + <?php
2256 + /**
2257 + * Action: mainwp_import_users_modal_bottom
2258 + *
2259 + * Fires on the bottom of the Import Users modal.
2260 + *
2261 + * @since 4.1
2262 + */
2263 + do_action( 'mainwp_import_users_modal_bottom' );
2264 + ?>
2236 2265 </div>
2237 - <?php
2238 - /**
2239 - * Action: mainwp_import_users_modal_bottom
2240 - *
2241 - * Fires on the bottom of the Import Users modal.
2242 - *
2243 - * @since 4.1
2244 - */
2245 - do_action( 'mainwp_import_users_modal_bottom' );
2246 - ?>
2266 + <div class="actions">
2267 + <input type="button" name="import_user_btn_import" id="import_user_btn_import" class="ui basic button" value="<?php esc_attr_e( 'Pause', 'mainwp' ); ?>"/>
2268 + <input type="button" name="import_user_btn_save_csv" id="import_user_btn_save_csv" style="display:none;" class="ui basic green button" value="<?php esc_attr_e( 'Save failed', 'mainwp' ); ?>"/>
2269 + </div>
2247 2270 </div>
2248 - <div class="actions">
2249 - <input type="button" name="import_user_btn_import" id="import_user_btn_import" class="ui basic button" value="<?php esc_attr_e( 'Pause', 'mainwp' ); ?>"/>
2250 - <input type="button" name="import_user_btn_save_csv" id="import_user_btn_save_csv" style="display:none;" class="ui basic green button" value="<?php esc_attr_e( 'Save failed', 'mainwp' ); ?>"/>
2251 - </div>
2252 - </div>
2253 - <script type="text/javascript">
2254 - jQuery( document ).ready( function () {
2255 - jQuery( "#mainwp-import-users-modal" ).modal( {
2256 - closable: false,
2257 - onHide: function() {
2258 - mainwp_forceReload('admin.php?page=BulkImportUsers');
2259 - }
2260 - } ).modal( 'show' );
2261 - } );
2262 - </script>
2271 + <script type="text/javascript">
2272 + jQuery( document ).ready( function () {
2273 + jQuery( "#mainwp-import-users-modal" ).modal( {
2274 + closable: false,
2275 + onHide: function() {
2276 + mainwp_forceReload('admin.php?page=BulkImportUsers');
2277 + }
2278 + } ).modal( 'show' );
2279 + } );
2280 + </script>
2263 2281
2264 - <?php
2265 -
2282 + <?php
2283 + } else {
2284 + $errors[] = esc_html__( 'No valid data rows found. Please make sure the import file is formatted correctly.', 'mainwp' );
2285 + }
2266 2286 } else {
2267 2287 $errors[] = esc_html__( 'Invalid data. Please make sure that the Import file has been formated properly.', 'mainwp' );
2268 2288 }
2269 - } else {
2270 - $errors[] = esc_html__( 'File could not be uploaded. Temporary file cold not be created. Please make sure that the tmpfile() PHP function is enabled on your server.', 'mainwp' );
2271 2289 }
2272 2290 } else {
2273 2291 $errors[] = esc_html__( 'File could not be uploaded. Please try again. If process keeps failing, please review MainWP Knowledgebase, and if you still have issues, please let us know in the MainWP Community.', 'mainwp' );
2274 2292 }