Skip to content

Commit

Permalink
feat(impexp): improved code readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Mte90 committed May 19, 2023
1 parent 0274d53 commit b897c7a
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions plugin-name/backend/ImpExp.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ public function initialize() {
return;
}

// Add the export settings method
\add_action( 'admin_init', array( $this, 'settings_export' ) );
// Add the import settings method
\add_action( 'admin_init', array( $this, 'settings_import' ) );
if ( \current_user_can( 'manage_options' ) ) {
// Add the export settings method
\add_action( 'admin_init', array( $this, 'settings_export' ) );
// Add the import settings method
\add_action( 'admin_init', array( $this, 'settings_import' ) );
}
}

/**
Expand All @@ -53,10 +55,6 @@ public function settings_export() {
return;
}

if ( !\current_user_can( 'manage_options' ) ) {
return;
}

$settings = array();
$settings[ 0 ] = \get_option( PN_TEXTDOMAIN . '-settings' );
$settings[ 1 ] = \get_option( PN_TEXTDOMAIN . '-settings-second' );
Expand Down Expand Up @@ -91,10 +89,10 @@ public function settings_import() {
return;
}

if ( !\current_user_can( 'manage_options' ) ) {
if ( !isset( $_FILES[ 'pn_import_file' ][ 'name' ] ) ) {
return;
}

$file_name_parts = \explode( '.', $_FILES[ 'pn_import_file' ][ 'name' ] ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput
$extension = \end( $file_name_parts );

Expand Down

0 comments on commit b897c7a

Please sign in to comment.