| @@ -6,9 +6,8 @@ | ||
| 6 | 6 | use Elementor\Plugin; |
| 7 | 7 | use Elementor\TemplateLibrary\Source_Base; |
| 8 | 8 | use RadiusTheme\SB\Helpers\BuilderFns; |
| 9 | 9 | use RadiusTheme\SB\Helpers\Fns; |
| 10 | -use RadiusTheme\SB\Models\TemplateSettings; | |
| 11 | 10 | use RadiusTheme\SB\Traits\SingletonTrait; |
| 12 | 11 | |
| 13 | 12 | // Do not allow directly accessing this file. |
| 14 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -86,15 +85,8 @@ | ||
| 86 | 85 | ]; |
| 87 | 86 | wp_send_json( $return ); |
| 88 | 87 | |
| 89 | 88 | } |
| 90 | - if ( ! current_user_can( 'manage_options' ) ) { | |
| 91 | - $return = [ | |
| 92 | - 'success' => false, | |
| 93 | - 'post_id' => $page_id, | |
| 94 | - ]; | |
| 95 | - wp_send_json( $return ); | |
| 96 | - } | |
| 97 | 89 | |
| 98 | 90 | add_filter( 'pre_option_elementor_unfiltered_files_upload', function () { |
| 99 | 91 | return '1'; |
| 100 | 92 | }, 99 ); |
| @@ -110,13 +102,12 @@ | ||
| 110 | 102 | 'has_pro' => $hasPro |
| 111 | 103 | ]; |
| 112 | 104 | $layoutRequest = wp_remote_post( rtsb()->BASE_API, $post_args ); |
| 113 | 105 | |
| 114 | - $layoutJson = []; | |
| 115 | - if ( ! is_wp_error( $layoutRequest ) && ! empty( $layoutRequest['body'] ) ) { | |
| 116 | - $layoutJson = json_decode( $layoutRequest['body'], true ); | |
| 106 | + if ( is_wp_error( $layoutRequest ) ) { | |
| 107 | + wp_send_json_error( [ 'messages' => $layoutRequest->get_error_messages() ] ); | |
| 117 | 108 | } |
| 118 | - | |
| 109 | + $layoutJson = json_decode( $layoutRequest['body'], true ); | |
| 119 | 110 | $option_name = BuilderFns::option_name( $page_type ); |
| 120 | 111 | |
| 121 | 112 | $post_data = [ |
| 122 | 113 | 'ID' => $page_id, |
| @@ -155,16 +146,13 @@ | ||
| 155 | 146 | $category_archive = array_unique( isset( $_POST['category_archive'] ) && is_array( $_POST['category_archive'] ) ? array_map( 'sanitize_text_field', $_POST['category_archive'] ) : [] ); |
| 156 | 147 | $the_products = array_unique( isset( $_POST['the_products'] ) && is_array( $_POST['the_products'] ) ? array_map( 'absint', $_POST['the_products'] ) : [] ); |
| 157 | 148 | if ( ! count( $the_products ) && ! count( $category_archive ) ) { |
| 158 | 149 | if ( 'default_template' === $default_template ) { |
| 159 | - // update_option( $option_name, $page_id ); | |
| 160 | - TemplateSettings::instance()->set_option( $option_name, $page_id ); | |
| 150 | + update_option( $option_name, $page_id ); | |
| 161 | 151 | } else { |
| 162 | - // $has_default = get_option( $option_name ); | |
| 163 | - $has_default = TemplateSettings::instance()->get_option( $option_name ); | |
| 152 | + $has_default = get_option( $option_name ); | |
| 164 | 153 | if ( ! $has_default ) { |
| 165 | - // update_option( $option_name, '' ); | |
| 166 | - TemplateSettings::instance()->set_option( $option_name, '' ); | |
| 154 | + update_option( $option_name, '' ); | |
| 167 | 155 | } |
| 168 | 156 | } |
| 169 | 157 | } |
| 170 | 158 | |