| @@ -2,8 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace RadiusTheme\SB\Modules\Compare; |
| 4 | 4 | |
| 5 | 5 | use RadiusTheme\SB\Helpers\Fns; |
| 6 | +use RadiusTheme\SB\Models\DataModel; | |
| 6 | 7 | |
| 7 | 8 | // Do not allow directly accessing this file. |
| 8 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | 10 | exit( 'This script cannot be accessed directly.' ); |
| @@ -31,18 +32,14 @@ | ||
| 31 | 32 | $page_id = Fns::get_option( 'modules', 'compare', 'page', 0, 'number' ); |
| 32 | 33 | if ( $page_id > 0 ) { |
| 33 | 34 | $page_object = get_post( $page_id ); |
| 34 | 35 | |
| 35 | - if ( $page_object && 'page' === $page_object->post_type && ! in_array( | |
| 36 | - $page_object->post_status, | |
| 37 | - [ | |
| 36 | + if ( $page_object && 'page' === $page_object->post_type && ! in_array( $page_object->post_status, [ | |
| 38 | 37 | 'pending', |
| 39 | 38 | 'trash', |
| 40 | 39 | 'future', |
| 41 | - 'auto-draft', | |
| 42 | - ], | |
| 43 | - true | |
| 44 | - ) ) { | |
| 40 | + 'auto-draft' | |
| 41 | + ], true ) ) { | |
| 45 | 42 | // Valid page is already in place. |
| 46 | 43 | return; |
| 47 | 44 | } |
| 48 | 45 | } |
| @@ -56,12 +53,11 @@ | ||
| 56 | 53 | esc_html__( 'Compare', 'shopbuilder' ), |
| 57 | 54 | '<!-- wp:shortcode -->[rtsb_compare_list]<!-- /wp:shortcode -->' |
| 58 | 55 | ); |
| 59 | 56 | if ( $create_page_id ) { |
| 60 | - $section_items = []; | |
| 61 | - $section_items['page'] = strval( $create_page_id ); | |
| 62 | - Fns::set_options( 'modules', 'compare', $section_items ); | |
| 63 | - | |
| 57 | + $section_items = DataModel::source()->get_option( 'modules', [] ); | |
| 58 | + $section_items['compare']['page'] = strval( $create_page_id ); | |
| 59 | + DataModel::source()->set_option( 'modules', $section_items ); | |
| 64 | 60 | } |
| 65 | 61 | } |
| 66 | 62 | } |
| 67 | -} | |
| 63 | +} | |