Export.php
2 years ago
GetFields.php
4 months ago
Import.php
2 years ago
Options.php
1 week ago
Pages.php
2 years ago
Posts.php
4 months ago
Services.php
1 year ago
Import.php
62 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Import services. |
| 4 | * |
| 5 | * @package ShopPress |
| 6 | */ |
| 7 | |
| 8 | namespace ShopPress\Admin\API; |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | |
| 12 | class Import { |
| 13 | /** |
| 14 | * Instance of this class. |
| 15 | * |
| 16 | * @since 1.0.0 |
| 17 | */ |
| 18 | public static $instance; |
| 19 | |
| 20 | /** |
| 21 | * Provides access to a single instance of a module using the singleton pattern. |
| 22 | * |
| 23 | * @since 1.0.0 |
| 24 | * |
| 25 | * @return object |
| 26 | */ |
| 27 | public static function instance() { |
| 28 | if ( self::$instance === null ) { |
| 29 | self::$instance = new self(); |
| 30 | } |
| 31 | return self::$instance; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Import. |
| 36 | * |
| 37 | * @since 1.0.0 |
| 38 | * |
| 39 | * @param object $request |
| 40 | */ |
| 41 | public function import( $request ) { |
| 42 | $action = $request->get_param( 'action' ); |
| 43 | |
| 44 | switch ( $action ) { |
| 45 | case 'importOptions': { |
| 46 | $content = $request->get_param( 'fileContent' ); |
| 47 | |
| 48 | $options = json_decode( $content, true ); |
| 49 | |
| 50 | update_option( 'sp_admin', $options ); |
| 51 | |
| 52 | break; |
| 53 | } |
| 54 | |
| 55 | default: { |
| 56 | |
| 57 | break; |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 |