'Export and import settings', 'version' => '1.1.0', 'option_id' => array( 'export_settings' ), 'card' => 'card_famne_export_settings', ) ); /** * Card_famne_export_settings * * @return void */ function card_famne_export_settings() { global $pagenow; if ( ! FAMNESettingsPage::is_famne_settings_page() && ! FAMNESettingsPage::is_famne_network_settings_page() ) { return; } $downloadlink = $pagenow . '?page=' . sanitize_text_field( $_GET['page'] ) . '&export-settings=famne'; ?>
100000 ) { wp_die( __( 'File size exceeds maximum upload limit.', 'manage-notification-emails' ) ); } // Read JSON. try { $json = null; if ( function_exists( 'file_get_contents' ) ) : $json = file_get_contents( $file['tmp_name'] ); $json = json_decode( $json, true ); endif; // Check if empty. if ( ! $json || ! is_array( $json ) ) { wp_die( __( 'Import file empty.', 'manage-notification-emails' ) ); } } catch ( RuntimeException $e ) { wp_die( 'Invalid parameters or file is corrupted.' ); } // Check file size. if ( empty( $json['version'] ) || FA_MNE_VERSION !== $json['version'] ) { wp_die( __( 'The import file has a different plugin version.', 'manage-notification-emails' ) ); } // Get all available options. $available_options = array(); foreach ( FAMNE::default_options() as $key => $o ) : $available_options[] = $key; endforeach; foreach ( FAMNE::getModules() as $mod ) : if ( ! empty( $mod->option_id ) && is_array( $mod->option_id ) ) : foreach ( $mod->option_id as $m ) : $available_options[] = $m; endforeach; endif; endforeach; $input = array(); foreach ( $json as $key => $val ) : if ( in_array( $key, $available_options, true ) ) { $input[ $key ] = sanitize_text_field( $val ); } endforeach; endif; return $input; } } add_action( 'fa_mne_modules', 'load_mod_famne_export_settings' );