Changeset 3341206
- Timestamp:
- 08/07/2025 06:28:28 PM (6 months ago)
- Location:
- upc-ean-barcode-generator/trunk
- Files:
-
- 4 added
- 2 deleted
- 11 edited
-
assets/css/index-2.0.2-basic-1736239113724.css (deleted)
-
assets/css/index-2.0.3-basic-1754503987086.css (added)
-
assets/js/index-2.0.2-basic-1736239113724.js (deleted)
-
assets/js/index-2.0.3-basic-1754503987086.js (added)
-
src/Core.php (modified) (2 diffs)
-
src/Helpers (added)
-
src/Helpers/Request.php (added)
-
src/features/DataSources/SpreadSheet.php (modified) (5 diffs)
-
src/features/Integrations/AtumBarcode.php (modified) (4 diffs)
-
src/features/Integrations/AtumSupplierSku.php (modified) (4 diffs)
-
src/features/Integrations/CodeStoreField.php (modified) (5 diffs)
-
src/features/Integrations/CustomField.php (modified) (4 diffs)
-
src/features/Integrations/DefaultField.php (modified) (3 diffs)
-
src/features/Integrations/HwpGtin.php (modified) (4 diffs)
-
src/features/codes/Codes.php (modified) (2 diffs)
-
src/features/products/Products.php (modified) (6 diffs)
-
src/features/settings/Settings.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
upc-ean-barcode-generator/trunk/src/Core.php
r3218304 r3341206 90 90 global $wp_version; 91 91 92 wp_enqueue_script("uegenerator_loader", plugin_dir_url(__FILE__)."../assets/js/index-2.0. 2-basic-1736239113724.js", array("jquery"), 1736239113724, true);92 wp_enqueue_script("uegenerator_loader", plugin_dir_url(__FILE__)."../assets/js/index-2.0.3-basic-1754503987086.js", array("jquery"), 1754503987086, true); 93 93 94 wp_enqueue_style('uegenerator_style', plugin_dir_url(__FILE__)."../assets/css/index-2.0. 2-basic-1736239113724.css", false, 1736239113724);94 wp_enqueue_style('uegenerator_style', plugin_dir_url(__FILE__)."../assets/css/index-2.0.3-basic-1754503987086.css", false, 1754503987086); 95 95 96 96 $appJsPath = ""; … … 108 108 'pluginUrl' => plugin_dir_url(__DIR__ ), 109 109 'ajaxUrl' => get_admin_url() . 'admin-ajax.php', 110 'pluginVersion' => '2.0. 2',110 'pluginVersion' => '2.0.3', 111 111 'nonce' => wp_create_nonce('wp_rest'), 112 'ajaxNonce' => wp_create_nonce('uegen-ajax-nonce'), 112 113 'settings' => $this->settings->get(), 113 114 'codeStoreFieldOptions' => $this->settings->getCodeStoreFieldOptions(), -
upc-ean-barcode-generator/trunk/src/features/DataSources/SpreadSheet.php
r3218304 r3341206 6 6 use UkrSolution\UpcEanGenerator\Exceptions\GeneratorException; 7 7 use UkrSolution\UpcEanGenerator\features\DataSources\Filters\PhpExcelChunkReadFilter; 8 use UkrSolution\UpcEanGenerator\Helpers\Request; 8 9 9 10 class SpreadSheet … … 30 31 public function uploadDataFile() 31 32 { 33 Request::checkNonce('uegen-ajax-nonce'); 34 32 35 if (!current_user_can('manage_options')) { 33 36 wp_die(); … … 84 87 public function importFromFile() 85 88 { 89 Request::checkNonce('uegen-ajax-nonce'); 90 86 91 if (!current_user_can('manage_options')) { 87 92 wp_die(); … … 305 310 } 306 311 307 public function getImportedFilesInfo($getResult = true) 308 { 312 public function getImportedFilesInfo($getResult = false) 313 { 314 if (!$getResult) { 315 Request::checkNonce('uegen-ajax-nonce'); 316 } 317 309 318 if (!current_user_can('manage_options')) { 310 319 wp_die(); … … 377 386 public function deleteImportedFileData() 378 387 { 388 Request::checkNonce('uegen-ajax-nonce'); 389 379 390 if (!current_user_can('manage_options')) { 380 391 wp_die(); -
upc-ean-barcode-generator/trunk/src/features/Integrations/AtumBarcode.php
r3148766 r3341206 116 116 ); 117 117 118 if (is_plugin_active('polylang/polylang.php')) { 119 unset($args['lang']); 120 } 121 118 122 $simpleProductsIds = (new \WP_Query($args))->posts; 119 123 … … 124 128 $productsVariationsParentsIds = wp_list_pluck($productsVariations, 'post_parent'); 125 129 126 $actualProducts Ids = (new \WP_Query(array(130 $actualProductsArgs = array( 127 131 'post_type' => 'product', 128 132 'post_status' => static::POST_STATUSES, … … 132 136 'suppress_filters' => true, 133 137 'lang' => 'all', 134 )))->posts; 138 ); 139 140 if (is_plugin_active('polylang/polylang.php')) { 141 unset($actualProductsArgs['lang']); 142 } 143 144 $actualProductsIds = (new \WP_Query($actualProductsArgs))->posts; 135 145 136 146 $args['post_parent__in'] = empty($actualProductsIds) ? array(0) : array_values($actualProductsIds); … … 149 159 ); 150 160 161 if (is_plugin_active('polylang/polylang.php')) { 162 unset($args['lang']); 163 } 164 151 165 $result = new \WP_Query($args); 152 166 return $result; 153 154 167 } 155 168 -
upc-ean-barcode-generator/trunk/src/features/Integrations/AtumSupplierSku.php
r3148766 r3341206 113 113 ); 114 114 115 if (is_plugin_active('polylang/polylang.php')) { 116 unset($args['lang']); 117 } 118 115 119 $simpleProductsIds = (new \WP_Query($args))->posts; 116 120 … … 121 125 $productsVariationsParentsIds = wp_list_pluck($productsVariations, 'post_parent'); 122 126 123 $actualProducts Ids = (new \WP_Query(array(127 $actualProductsArgs = array( 124 128 'post_type' => 'product', 125 129 'post_status' => static::POST_STATUSES, … … 129 133 'suppress_filters' => true, 130 134 'lang' => 'all', 131 )))->posts; 135 ); 136 if (is_plugin_active('polylang/polylang.php')) { 137 unset($actualProductsArgs['lang']); 138 } 139 $actualProductsIds = (new \WP_Query($actualProductsArgs))->posts; 132 140 133 141 $args['post_parent__in'] = empty($actualProductsIds) ? array(0) : array_values($actualProductsIds); … … 146 154 ); 147 155 156 if (is_plugin_active('polylang/polylang.php')) { 157 unset($args['lang']); 158 } 159 148 160 $result = new \WP_Query($args); 149 161 return $result; 150 151 162 } 152 163 -
upc-ean-barcode-generator/trunk/src/features/Integrations/CodeStoreField.php
r3148766 r3341206 168 168 ); 169 169 170 if (is_plugin_active('polylang/polylang.php')) { 171 unset($args['lang']); 172 } 173 170 174 $simpleProductsIds = (new \WP_Query($args))->posts; 171 175 … … 176 180 $productsVariationsParentsIds = wp_list_pluck($productsVariations, 'post_parent'); 177 181 178 $actualProducts Ids = (new \WP_Query(array(182 $actualProductsArgs = array( 179 183 'post_type' => 'product', 180 184 'post_status' => static::POST_STATUSES, … … 184 188 'suppress_filters' => true, 185 189 'lang' => 'all', 186 )))->posts; 190 ); 191 192 if (is_plugin_active('polylang/polylang.php')) { 193 unset($actualProductsArgs['lang']); 194 } 195 196 $actualProductsIds = (new \WP_Query($actualProductsArgs))->posts; 187 197 188 198 $args['post_parent__in'] = empty($actualProductsIds) ? array(0) : array_values($actualProductsIds); … … 191 201 192 202 $postsIds = array_merge($simpleProductsIds, $variationsIds); 203 193 204 $args = array( 194 205 'post_type' => static::POST_TYPES, … … 201 212 ); 202 213 214 if (is_plugin_active('polylang/polylang.php')) { 215 unset($args['lang']); 216 } 217 203 218 $result = new \WP_Query($args); 219 204 220 return $result; 205 206 221 } 207 222 -
upc-ean-barcode-generator/trunk/src/features/Integrations/CustomField.php
r3148766 r3341206 126 126 ); 127 127 128 if (is_plugin_active('polylang/polylang.php')) { 129 unset($args['lang']); 130 } 131 128 132 $simpleProductsIds = (new \WP_Query($args))->posts; 129 133 … … 134 138 $productsVariationsParentsIds = wp_list_pluck($productsVariations, 'post_parent'); 135 139 136 $actualProducts Ids = (new \WP_Query(array(140 $actualProductsArgs = array( 137 141 'post_type' => 'product', 138 142 'post_status' => static::POST_STATUSES, … … 142 146 'suppress_filters' => true, 143 147 'lang' => 'all', 144 )))->posts; 148 ); 149 if (is_plugin_active('polylang/polylang.php')) { 150 unset($actualProductsArgs['lang']); 151 } 152 $actualProductsIds = (new \WP_Query($actualProductsArgs))->posts; 145 153 146 154 $args['post_parent__in'] = empty($actualProductsIds) ? array(0) : array_values($actualProductsIds); … … 158 166 'lang' => 'all', 159 167 ); 168 169 if (is_plugin_active('polylang/polylang.php')) { 170 unset($args['lang']); 171 } 160 172 161 173 $result = new \WP_Query($args); -
upc-ean-barcode-generator/trunk/src/features/Integrations/DefaultField.php
r3148766 r3341206 120 120 ); 121 121 122 if (is_plugin_active('polylang/polylang.php')) { 123 unset($args['lang']); 124 } 125 122 126 $simpleProductsIds = (new \WP_Query($args))->posts; 123 127 … … 128 132 $productsVariationsParentsIds = wp_list_pluck($productsVariations, 'post_parent'); 129 133 130 $actualProductsIds = (new \WP_Query(array( 131 'post_type' => 'product', 132 'post_status' => static::POST_STATUSES, 133 'post__in' => empty($productsVariationsParentsIds) ? array(0) : array_values($productsVariationsParentsIds), 134 'posts_per_page' => -1, 135 'fields' => 'ids', 136 'suppress_filters' => true, 137 'lang' => 'all', 138 )))->posts; 134 $actualProductsArgs = array( 135 'post_type' => 'product', 136 'post_status' => static::POST_STATUSES, 137 'post__in' => empty($productsVariationsParentsIds) ? array(0) : array_values($productsVariationsParentsIds), 138 'posts_per_page' => -1, 139 'fields' => 'ids', 140 'suppress_filters' => true, 141 'lang' => 'all', 142 ); 143 if (is_plugin_active('polylang/polylang.php')) { 144 unset($actualProductsArgs['lang']); 145 } 146 $actualProductsIds = (new \WP_Query($actualProductsArgs))->posts; 139 147 140 148 $args['post_parent__in'] = empty($actualProductsIds) ? array(0) : array_values($actualProductsIds); … … 152 160 'lang' => 'all', 153 161 ); 162 163 if (is_plugin_active('polylang/polylang.php')) { 164 unset($args['lang']); 165 } 154 166 155 167 $result = new \WP_Query($args); -
upc-ean-barcode-generator/trunk/src/features/Integrations/HwpGtin.php
r3148766 r3341206 143 143 ); 144 144 145 if (is_plugin_active('polylang/polylang.php')) { 146 unset($args['lang']); 147 } 148 145 149 $simpleProductsIds = (new \WP_Query($args))->posts; 146 150 … … 163 167 $productsVariationsParentsIds = wp_list_pluck($productsVariations, 'post_parent'); 164 168 165 $actualProducts Ids = (new \WP_Query(array(169 $actualProductsArgs = array( 166 170 'post_type' => 'product', 167 171 'post_status' => static::POST_STATUSES, … … 171 175 'suppress_filters' => true, 172 176 'lang' => 'all', 173 )))->posts; 177 ); 178 if (is_plugin_active('polylang/polylang.php')) { 179 unset($actualProductsArgs['lang']); 180 } 181 $actualProductsIds = (new \WP_Query($actualProductsArgs))->posts; 174 182 175 183 $args['post_parent__in'] = empty($actualProductsIds) ? array(0) : array_values($actualProductsIds); … … 187 195 'lang' => 'all', 188 196 ); 197 198 if (is_plugin_active('polylang/polylang.php')) { 199 unset($args['lang']); 200 } 189 201 190 202 $result = new \WP_Query($args); -
upc-ean-barcode-generator/trunk/src/features/codes/Codes.php
r3218304 r3341206 5 5 use UkrSolution\UpcEanGenerator\features\products\Products; 6 6 use UkrSolution\UpcEanGenerator\features\settings\Settings; 7 use UkrSolution\UpcEanGenerator\Helpers\Request; 7 8 use UkrSolution\UpcEanGenerator\Hooks; 8 9 9 10 class Codes 10 11 { 11 12 12 public function regenerateCode() 13 13 { 14 Request::checkNonce('uegen-ajax-nonce'); 15 14 16 if (!current_user_can('manage_options')) { 15 17 wp_die(); … … 24 26 public function generate($fieldName) 25 27 { 26 27 28 $settings = new Settings(); 28 29 if ($settings->getField("general", "code-type", "upc") === "upc") { -
upc-ean-barcode-generator/trunk/src/features/products/Products.php
r3218304 r3341206 6 6 use UkrSolution\UpcEanGenerator\features\DataSources\SpreadSheet; 7 7 use UkrSolution\UpcEanGenerator\features\settings\Settings; 8 use UkrSolution\UpcEanGenerator\Helpers\Request; 8 9 use UkrSolution\UpcEanGenerator\Hooks; 9 10 use function EasyWPSMTP\Vendor\GuzzleHttp\Psr7\str; … … 52 53 add_action('woocommerce_save_product_variation', array($this, 'woocommerce_save_product_variation'), 10, 2); 53 54 54 add_action(' save_post', array($this, 'addCodeValueForNewProduct'), 99999, 3);55 add_action('woocommerce_after_product_object_save', array($this, 'addCodeValueForNewProductWcAfterProductSave'), 10, 2); 55 56 56 57 add_action('edit_form_top', array($this, 'noFreeCodeFoundInDatabaseNotice')); … … 185 186 } 186 187 188 189 public function addCodeValueForNewProductWcAfterProductSave($product, $store) 190 { 191 $postId = $product->get_id(); 192 $post = get_post($product->get_id()); 193 194 if ( (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { 195 return; 196 } 197 198 $productIds = $product->is_type('variable') ? $product->get_children() : array($postId); 199 200 foreach ($productIds as $productId) { 201 $value = $this->getProductCodeValue($productId); 202 203 if ('' !== $value && null !== $value) { 204 continue; 205 } 206 207 if (self::DATA_DATABASE === $this->newProductsCodeSource) { 208 $codeRow = $this->spreadSheet->getFreeCode($this->settings->getField("general", "code-type", "upc")); 209 if (!empty($codeRow)) { 210 $usedMetaKey = ''; 211 if ($this->setProductCodeValue($productId, esc_attr($codeRow->code), $usedMetaKey)) { 212 $this->spreadSheet->setCodeIsUsedFlag($codeRow->id); 213 $this->spreadSheet->updateCodeRow($codeRow->id, array( 214 'integration' => $this->settings->getField("general", "code-store-field", 'default'), 215 'product_id' => $productId, 216 'meta_key' => $usedMetaKey, 217 )); 218 } 219 } 220 } elseif(self::DATA_GENERATE === $this->newProductsCodeSource) { 221 for ($i = 0; $i < 100; $i++) { 222 $value = (new Codes())->generate($this->fieldName); 223 224 if ($this->codeValueNotUsed($productId, $value)) { 225 break; 226 } else { 227 $value = ''; 228 } 229 } 230 231 $this->setProductCodeValue($productId, esc_attr($value)); 232 } 233 } 234 } 235 187 236 public function woocommerce_product_options_sku() 188 237 { … … 246 295 public function generateProductsCodes() 247 296 { 297 Request::checkNonce('uegen-ajax-nonce'); 298 248 299 if (!current_user_can('manage_options')) { 249 300 wp_die(); … … 374 425 public function getProductsInfo() 375 426 { 427 Request::checkNonce('uegen-ajax-nonce'); 428 376 429 if (!current_user_can('manage_options')) { 377 430 wp_die(); … … 401 454 public function unassignFromFile() 402 455 { 456 Request::checkNonce('uegen-ajax-nonce'); 457 403 458 if (!current_user_can('manage_options')) { 404 459 wp_die(); -
upc-ean-barcode-generator/trunk/src/features/settings/Settings.php
r3218304 r3341206 2 2 3 3 namespace UkrSolution\UpcEanGenerator\features\settings; 4 5 use UkrSolution\UpcEanGenerator\Helpers\Request; 4 6 5 7 class Settings … … 81 83 public function save() 82 84 { 85 Request::checkNonce('uegen-ajax-nonce'); 86 83 87 if (!current_user_can('manage_options')) { 84 88 wp_die(); … … 104 108 public function checkCustomField() 105 109 { 110 Request::checkNonce('uegen-ajax-nonce'); 111 106 112 if (!current_user_can('manage_options')) { 107 113 wp_die();
Note: See TracChangeset
for help on using the changeset viewer.