← All changes
|
app/src/Support/Scripts/AdminModelEditController.php
+10
-49
4.4.1
→
1.2.5
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. |
| @@ -57,27 +58,13 @@ | ||
| 57 | 58 | */ |
| 58 | 59 | public function enqueueScriptDependencies() { |
| 59 | 60 | wp_enqueue_media(); |
| 60 | 61 | wp_enqueue_style( 'wp-components' ); |
| 61 | - wp_enqueue_style( 'wp-editor' ); | |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - /** | |
| 65 | - * Enqueue components | |
| 66 | - * | |
| 67 | - * @return void | |
| 68 | - */ | |
| 69 | 64 | public function enqueueComponents() { |
| 70 | 65 | wp_enqueue_script( 'surecart-components' ); |
| 71 | 66 | wp_enqueue_style( 'surecart-themes-default' ); |
| 72 | - wp_add_inline_style( | |
| 73 | - 'surecart-themes-default', | |
| 74 | - ':root { --sc-color-primary-text: #fff; }' // this is important in case the user has a dark primary text. | |
| 75 | - ); | |
| 76 | - wp_add_inline_style( | |
| 77 | - 'surecart-themes-default', | |
| 78 | - '.sc-dragging { z-index: 1 }' // this is required for dragging. | |
| 79 | - ); | |
| 80 | 67 | } |
| 81 | 68 | |
| 82 | 69 | /** |
| 83 | 70 | * Enqueue scripts |
| @@ -104,12 +91,12 @@ | ||
| 104 | 91 | |
| 105 | 92 | // enqueue dependencies. |
| 106 | 93 | $this->enqueueScriptDependencies(); |
| 107 | 94 | |
| 108 | - // Fix Jetpack script key hijacking issues. | |
| 95 | + // fix shitty jetpack issues key hijacking issues. | |
| 109 | 96 | add_filter( |
| 110 | 97 | 'admin_head', |
| 111 | - function () { | |
| 98 | + function() { | |
| 112 | 99 | wp_dequeue_script( 'wpcom-notes-common' ); |
| 113 | 100 | wp_dequeue_script( 'wpcom-notes-admin-bar' ); |
| 114 | 101 | wp_dequeue_style( 'wpcom-notes-admin-bar' ); |
| 115 | 102 | wp_dequeue_style( 'noticons' ); |
| @@ -120,51 +107,31 @@ | ||
| 120 | 107 | // automatically load dependencies and version. |
| 121 | 108 | $asset_file = include plugin_dir_path( SURECART_PLUGIN_FILE ) . "dist/$this->path.asset.php"; |
| 122 | 109 | |
| 123 | 110 | // Enqueue scripts. |
| 124 | - wp_enqueue_script( | |
| 111 | + \SureCart::core()->assets()->enqueueScript( | |
| 125 | 112 | $this->handle, |
| 126 | 113 | trailingslashit( \SureCart::core()->assets()->getUrl() ) . "dist/$this->path.js", |
| 127 | 114 | array_merge( $asset_file['dependencies'], $this->dependencies ), |
| 128 | - $asset_file['version'], | |
| 129 | - true | |
| 115 | + $asset_file['version'] . '-' . \SureCart::plugin()->version() | |
| 130 | 116 | ); |
| 131 | 117 | |
| 132 | 118 | // 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' ); | |
| 119 | + $this->data['surecart_app_url'] = defined( 'SURECART_APP_URL' ) ? SURECART_APP_URL : ''; | |
| 120 | + $this->data['api_url'] = defined( 'SURECART_API_URL' ) ? untrailingslashit( SURECART_API_URL ) : \SureCart::requests()->getBaseUrl(); | |
| 121 | + $this->data['plugin_url'] = \SureCart::core()->assets()->getUrl(); | |
| 149 | 122 | |
| 150 | 123 | if ( in_array( 'currency', $this->with_data ) ) { |
| 151 | 124 | $this->data['currency_code'] = \SureCart::account()->currency; |
| 152 | 125 | } |
| 153 | - if ( in_array( 'review_protocol', $this->with_data ) ) { | |
| 154 | - $this->data['review_protocol'] = \SureCart::account()->review_protocol; | |
| 155 | - } | |
| 156 | 126 | if ( in_array( 'tax_protocol', $this->with_data ) ) { |
| 157 | 127 | $this->data['tax_protocol'] = \SureCart::account()->tax_protocol; |
| 158 | 128 | } |
| 159 | - if ( in_array( 'shipping_protocol', $this->with_data ) ) { | |
| 160 | - $this->data['shipping_protocol'] = \SureCart::account()->shipping_protocol; | |
| 161 | - } | |
| 162 | 129 | if ( in_array( 'checkout_page_url', $this->with_data ) ) { |
| 163 | 130 | $this->data['checkout_page_url'] = \SureCart::getUrl()->checkout(); |
| 164 | 131 | } |
| 165 | 132 | if ( in_array( 'supported_currencies', $this->with_data ) ) { |
| 166 | - $this->data['supported_currencies'] = Currency::list(); | |
| 133 | + $this->data['supported_currencies'] = Currency::getSupportedCurrencies(); | |
| 167 | 134 | } |
| 168 | 135 | if ( in_array( 'links', $this->with_data ) ) { |
| 169 | 136 | $this->data['links'] = []; |
| 170 | 137 | foreach ( array_keys( \SureCart::getAdminPageNames() ) as $name ) { |
| @@ -170,18 +137,12 @@ | ||
| 170 | 137 | foreach ( array_keys( \SureCart::getAdminPageNames() ) as $name ) { |
| 171 | 138 | $this->data['links'][ $name ] = esc_url_raw( add_query_arg( [ 'action' => 'edit' ], \SureCart::getUrl()->index( $name ) ) ); |
| 172 | 139 | } |
| 173 | 140 | } |
| 174 | - if ( in_array( 'google_map_api_key', $this->with_data ) ) { | |
| 175 | - $this->data['google_map_api_key'] = \SureCart::googleMaps()->getApiKey(); | |
| 176 | - } | |
| 177 | 141 | |
| 178 | 142 | // pass entitlements to page. |
| 179 | 143 | $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(); | |
| 144 | + $this->data['get_locale'] = str_replace( '_', '-', get_locale() ); | |
| 184 | 145 | |
| 185 | 146 | wp_set_script_translations( $this->handle, 'surecart' ); |
| 186 | 147 | |
| 187 | 148 | // common localizations. |