← All changes
|
app/src/Support/Scripts/AdminModelEditController.php
+17
-26
4.3.1
→
3.11.0
View file →
| @@ -1,8 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace SureCart\Support\Scripts; |
| 4 | 4 | |
| 5 | +use SureCart\Models\Account; | |
| 5 | 6 | use SureCart\Support\Currency; |
| 6 | 7 | |
| 7 | 8 | /** |
| 8 | 9 | * Class for model edit pages to extend. |
| @@ -104,9 +105,9 @@ | ||
| 104 | 105 | |
| 105 | 106 | // enqueue dependencies. |
| 106 | 107 | $this->enqueueScriptDependencies(); |
| 107 | 108 | |
| 108 | - // Fix Jetpack script key hijacking issues. | |
| 109 | + // fix shitty jetpack issues key hijacking issues. | |
| 109 | 110 | add_filter( |
| 110 | 111 | 'admin_head', |
| 111 | 112 | function () { |
| 112 | 113 | wp_dequeue_script( 'wpcom-notes-common' ); |
| @@ -129,31 +130,24 @@ | ||
| 129 | 130 | true |
| 130 | 131 | ); |
| 131 | 132 | |
| 132 | 133 | // pass app url. |
| 133 | - $this->data['upgrade_url'] = \SureCart::config()->links->purchase; | |
| 134 | - $this->data['surecart_app_url'] = defined( 'SURECART_APP_URL' ) ? SURECART_APP_URL : ''; | |
| 135 | - $this->data['account_id'] = \SureCart::account()->id ?? ''; | |
| 136 | - $this->data['account_slug'] = \SureCart::account()->slug ?? ''; | |
| 137 | - $this->data['api_url'] = \SureCart::requests()->getBaseUrl(); | |
| 138 | - $this->data['plugin_url'] = \SureCart::core()->assets()->getUrl(); | |
| 139 | - $this->data['locale'] = str_replace( '_', '-', get_locale() ); | |
| 140 | - $this->data['root_url'] = esc_url_raw( get_rest_url() ); | |
| 141 | - $this->data['home_url'] = untrailingslashit( get_home_url() ); | |
| 142 | - $this->data['buy_page_slug'] = untrailingslashit( \SureCart::settings()->permalinks()->getBase( 'buy_page' ) ); | |
| 143 | - $this->data['product_page_slug'] = untrailingslashit( \SureCart::settings()->permalinks()->getBase( 'product_page' ) ); | |
| 144 | - $this->data['collection_page_slug'] = untrailingslashit( \SureCart::settings()->permalinks()->getBase( 'collection_page' ) ); | |
| 145 | - $this->data['is_block_theme'] = \SureCart::utility()->blockTemplates()->isFSETheme(); | |
| 146 | - $this->data['claim_url'] = ! \SureCart::account()->claimed ? \SureCart::routeUrl( 'account.claim' ) : ''; | |
| 147 | - $this->data['claim_expired'] = \SureCart::account()->claim_expired ?? false; | |
| 148 | - $this->data['is_woocommerce_active'] = class_exists( 'WooCommerce' ); | |
| 134 | + $this->data['upgrade_url'] = \SureCart::config()->links->purchase; | |
| 135 | + $this->data['surecart_app_url'] = defined( 'SURECART_APP_URL' ) ? SURECART_APP_URL : ''; | |
| 136 | + $this->data['account_id'] = \SureCart::account()->id ?? ''; | |
| 137 | + $this->data['account_slug'] = \SureCart::account()->slug ?? ''; | |
| 138 | + $this->data['api_url'] = \SureCart::requests()->getBaseUrl(); | |
| 139 | + $this->data['plugin_url'] = \SureCart::core()->assets()->getUrl(); | |
| 140 | + $this->data['home_url'] = untrailingslashit( get_home_url() ); | |
| 141 | + $this->data['buy_page_slug'] = untrailingslashit( \SureCart::settings()->permalinks()->getBase( 'buy_page' ) ); | |
| 142 | + $this->data['product_page_slug'] = untrailingslashit( \SureCart::settings()->permalinks()->getBase( 'product_page' ) ); | |
| 143 | + $this->data['collection_page_slug'] = untrailingslashit( \SureCart::settings()->permalinks()->getBase( 'collection_page' ) ); | |
| 144 | + $this->data['is_block_theme'] = \SureCart::utility()->blockTemplates()->isFSETheme(); | |
| 145 | + $this->data['claim_url'] = ! \SureCart::account()->claimed ? \SureCart::routeUrl( 'account.claim' ) : ''; | |
| 149 | 146 | |
| 150 | 147 | if ( in_array( 'currency', $this->with_data ) ) { |
| 151 | 148 | $this->data['currency_code'] = \SureCart::account()->currency; |
| 152 | 149 | } |
| 153 | - if ( in_array( 'review_protocol', $this->with_data ) ) { | |
| 154 | - $this->data['review_protocol'] = \SureCart::account()->review_protocol; | |
| 155 | - } | |
| 156 | 150 | if ( in_array( 'tax_protocol', $this->with_data ) ) { |
| 157 | 151 | $this->data['tax_protocol'] = \SureCart::account()->tax_protocol; |
| 158 | 152 | } |
| 159 | 153 | if ( in_array( 'shipping_protocol', $this->with_data ) ) { |
| @@ -170,18 +164,15 @@ | ||
| 170 | 164 | foreach ( array_keys( \SureCart::getAdminPageNames() ) as $name ) { |
| 171 | 165 | $this->data['links'][ $name ] = esc_url_raw( add_query_arg( [ 'action' => 'edit' ], \SureCart::getUrl()->index( $name ) ) ); |
| 172 | 166 | } |
| 173 | 167 | } |
| 174 | - if ( in_array( 'google_map_api_key', $this->with_data ) ) { | |
| 175 | - $this->data['google_map_api_key'] = \SureCart::googleMaps()->getApiKey(); | |
| 168 | + if ( in_array( 'i18n', $this->with_data ) ) { | |
| 169 | + $this->data['i18n'] = \SureCart::state()->i18n()->get(); | |
| 176 | 170 | } |
| 177 | 171 | |
| 178 | 172 | // pass entitlements to page. |
| 179 | 173 | $this->data['entitlements'] = \SureCart::account()->entitlements; |
| 180 | - $this->data['get_locale'] = str_replace( '_', '-', determine_locale() ); | |
| 181 | - | |
| 182 | - // pass wp user roles to page. | |
| 183 | - $this->data['wp_user_roles'] = get_editable_roles(); | |
| 174 | + $this->data['get_locale'] = str_replace( '_', '-', get_locale() ); | |
| 184 | 175 | |
| 185 | 176 | wp_set_script_translations( $this->handle, 'surecart' ); |
| 186 | 177 | |
| 187 | 178 | // common localizations. |