Changeset 3004043
- Timestamp:
- 12/01/2023 04:37:35 AM (2 years ago)
- Location:
- product-code-for-woocommerce
- Files:
-
- 54 added
- 13 edited
-
tags/1.4.4 (added)
-
tags/1.4.4/assets (added)
-
tags/1.4.4/assets/css (added)
-
tags/1.4.4/assets/css/dashboard.css (added)
-
tags/1.4.4/assets/css/single-product.css (added)
-
tags/1.4.4/assets/js (added)
-
tags/1.4.4/assets/js/editor.js (added)
-
tags/1.4.4/assets/js/generic_admin.js (added)
-
tags/1.4.4/assets/js/stl_admin_custom.js (added)
-
tags/1.4.4/assets/js/stl_custom.js (added)
-
tags/1.4.4/classes (added)
-
tags/1.4.4/classes/class-pcfw-admin-settings.php (added)
-
tags/1.4.4/classes/class-pcfw-services.php (added)
-
tags/1.4.4/languages (added)
-
tags/1.4.4/languages/product-code-for-woocommerce-de_DE.mo (added)
-
tags/1.4.4/languages/product-code-for-woocommerce-de_DE.po (added)
-
tags/1.4.4/languages/product-code-for-woocommerce-en_US.mo (added)
-
tags/1.4.4/languages/product-code-for-woocommerce-en_US.po (added)
-
tags/1.4.4/languages/product-code-for-woocommerce-es_ES.mo (added)
-
tags/1.4.4/languages/product-code-for-woocommerce-es_ES.po (added)
-
tags/1.4.4/languages/product-code-for-woocommerce-fr_FR.mo (added)
-
tags/1.4.4/languages/product-code-for-woocommerce-fr_FR.po (added)
-
tags/1.4.4/languages/product-code-for-woocommerce-ru_RU.mo (added)
-
tags/1.4.4/languages/product-code-for-woocommerce-ru_RU.po (added)
-
tags/1.4.4/languages/product-code-for-woocommerce.pot (added)
-
tags/1.4.4/modules (added)
-
tags/1.4.4/modules/export (added)
-
tags/1.4.4/modules/export/pcfw-export-support.php (added)
-
tags/1.4.4/modules/search (added)
-
tags/1.4.4/modules/search/pcfw-filter-search.php (added)
-
tags/1.4.4/modules/search/pcfw-product-code-search.php (added)
-
tags/1.4.4/modules/search/pcfw-relevanssi-product-code-search.php (added)
-
tags/1.4.4/modules/search/pcfw-searchwp-product-code-search.php (added)
-
tags/1.4.4/product-code-for-woocommerce.php (added)
-
tags/1.4.4/readme.txt (added)
-
tags/1.4.4/templates (added)
-
tags/1.4.4/templates/hidden-product-list-column.php (added)
-
tags/1.4.4/templates/link.php (added)
-
tags/1.4.4/templates/product-meta-row.php (added)
-
tags/1.4.4/templates/quick-edit-text-field.php (added)
-
tags/1.4.4/templates/variation-field.php (added)
-
tags/1.4.4/templates/wc-text-input.php (added)
-
tags/1.4.4/vendor (added)
-
tags/1.4.4/vendor/autoload.php (added)
-
tags/1.4.4/vendor/bin (added)
-
tags/1.4.4/vendor/composer (added)
-
tags/1.4.4/vendor/composer/ClassLoader.php (added)
-
tags/1.4.4/vendor/composer/LICENSE (added)
-
tags/1.4.4/vendor/composer/autoload_classmap.php (added)
-
tags/1.4.4/vendor/composer/autoload_namespaces.php (added)
-
tags/1.4.4/vendor/composer/autoload_psr4.php (added)
-
tags/1.4.4/vendor/composer/autoload_real.php (added)
-
tags/1.4.4/vendor/composer/autoload_static.php (added)
-
tags/1.4.4/vendor/composer/installed.json (added)
-
trunk/classes/class-pcfw-admin-settings.php (modified) (30 diffs)
-
trunk/classes/class-pcfw-services.php (modified) (27 diffs)
-
trunk/modules/export/pcfw-export-support.php (modified) (3 diffs)
-
trunk/modules/search/pcfw-filter-search.php (modified) (2 diffs)
-
trunk/modules/search/pcfw-product-code-search.php (modified) (2 diffs)
-
trunk/modules/search/pcfw-relevanssi-product-code-search.php (modified) (1 diff)
-
trunk/modules/search/pcfw-searchwp-product-code-search.php (modified) (6 diffs)
-
trunk/product-code-for-woocommerce.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/templates/product-meta-row.php (modified) (1 diff)
-
trunk/templates/quick-edit-text-field.php (modified) (1 diff)
-
trunk/templates/variation-field.php (modified) (1 diff)
-
trunk/templates/wc-text-input.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
product-code-for-woocommerce/trunk/classes/class-pcfw-admin-settings.php
r3000925 r3004043 3 3 namespace Artiosmedia\WC_Product_Code; 4 4 5 class PCFW_Admin_ settings {5 class PCFW_Admin_Settings { 6 6 7 7 public function actions() { … … 26 26 27 27 // add_action( 'woocommerce_product_quick_edit_end', [ $this, 'add_quick_edit_field' ] ); 28 add_action( "admin_notices", array($this, "admin_notice"));29 add_action( "wp_ajax_product_code_dismiss_notice", array($this, "dismiss_notice"));28 add_action('admin_notices', array($this, 'admin_notice')); 29 add_action('wp_ajax_product_code_dismiss_notice', array($this, 'dismiss_notice')); 30 30 31 31 // Will be removed in next update 32 add_action( "wp_ajax_product_code_update_database", array($this, "update_database"));32 add_action('wp_ajax_product_code_update_database', array($this, 'update_database')); 33 33 34 34 //add product code to admin column 35 add_action( "manage_edit-product_columns", array($this, 'product_column'));36 add_action( "manage_posts_custom_column", array($this, 'product_column_value'));35 add_action('manage_edit-product_columns', array($this, 'product_column')); 36 add_action('manage_posts_custom_column', array($this, 'product_column_value')); 37 37 38 38 //add product code to quick edit 39 add_action('woocommerce_product_quick_edit_start', array($this, 'pcfw_woocommerce_product_quick_edit_start'));40 add_action('woocommerce_product_quick_edit_save', array($this, 'pcfw_woocommerce_product_quick_edit_save'));39 add_action('woocommerce_product_quick_edit_start', array($this, 'pcfw_woocommerce_product_quick_edit_start')); 40 add_action('woocommerce_product_quick_edit_save', array($this, 'pcfw_woocommerce_product_quick_edit_save')); 41 41 42 42 … … 50 50 public function enqueue() { 51 51 $screen = get_current_screen(); 52 wp_enqueue_script( "product-code-admin-generic", sprintf(53 "%s/assets/js/generic_admin.js",52 wp_enqueue_script('product-code-admin-generic', sprintf( 53 '%s/assets/js/generic_admin.js', 54 54 PRODUCT_CODE_URL 55 ), array("jquery"), PRODUCT_CODE_VERSION); 56 57 wp_localize_script("product-code-admin-generic", "PRODUCT_CODE_ADMIN", array("ajax" => 58 admin_url("admin-ajax.php"))); 55 ), array('jquery'), PRODUCT_CODE_VERSION); 56 57 wp_localize_script('product-code-admin-generic', 'PRODUCT_CODE_ADMIN', array('ajax' => admin_url('admin-ajax.php'))); 59 58 60 59 if ($screen && 'product' === $screen->post_type) { … … 62 61 wp_enqueue_script('wc_product_code_admin', PRODUCT_CODE_URL . '/assets/js/' . 63 62 'stl_admin_custom.js', ['jquery'], PRODUCT_CODE_VERSION); 64 wp_localize_script( "wc_product_code_admin", "i18n", array("product_code_title"=> __('Product code', 'product-code-for-woocommerce')));63 wp_localize_script('wc_product_code_admin', 'i18n', array('product_code_title' => __('Product code', 'product-code-for-woocommerce'))); 65 64 66 65 add_action('admin_footer', array($this, 'inline_javascript')); … … 69 68 70 69 public function update_database() { 71 if (current_user_can( "manage_options")) {70 if (current_user_can('manage_options')) { 72 71 global $wpdb; 73 $query = "UPDATE " . $wpdb->prefix . "postmeta 74 SET meta_key = '_product_code' 75 WHERE meta_key = '_product_code_variant'"; 76 $results = $wpdb->get_results($query, ARRAY_A); 77 $query = "UPDATE " . $wpdb->prefix . "postmeta 78 SET meta_key = '_product_code_second' 79 WHERE meta_key = '_product_code_variant_second'"; 80 $results2 = $wpdb->get_results($query, ARRAY_A); 72 73 $results = $wpdb->get_results("UPDATE {$wpdb->prefix}postmeta SET meta_key = '_product_code' WHERE meta_key = '_product_code_variant'", ARRAY_A); 74 $results2 = $wpdb->get_results("UPDATE {$wpdb->prefix}postmeta SET meta_key = '_product_code_second' WHERE meta_key = '_product_code_variant_second'", ARRAY_A); 75 81 76 if (is_array($results) && is_array($results2)) { 82 _e("Successfully Updated Redirecting back....", 'product-code-for-woocommerce'); 83 $query = "DELETE FROM " . $wpdb->prefix . "postmeta 84 WHERE meta_key = '_product_code_variant'"; 85 $results2 = $wpdb->get_results($query, ARRAY_A); 77 esc_html_e('Successfully Updated Redirecting back....', 'product-code-for-woocommerce'); 78 $results2 = $wpdb->get_results("DELETE FROM {$wpdb->prefix}postmeta WHERE meta_key = '_product_code_variant'", ARRAY_A); 86 79 update_option('product_code_db_updated', true); 87 80 } else { 88 _e(89 "Failed to update please retry later, Redirecting back... ",81 esc_html_e( 82 'Failed to update please retry later, Redirecting back... ', 90 83 'product-code-for-woocommerce' 91 84 ); … … 94 87 echo "<script> 95 88 window.setTimeout(function() { 96 window.location.replace('" . admin_url('admin.php?page=wc-settings&tab=products§ion=product_code_settings') .89 window.location.replace('" . esc_url_raw(admin_url('admin.php?page=wc-settings&tab=products§ion=product_code_settings')) . 97 90 "'); 98 91 }, 3000); … … 104 97 105 98 public function dismiss_notice() { 106 if (current_user_can("manage_options")) { 107 if (!empty($_POST["dismissed_final"])) { 108 update_option("product_code_notice_dismiss", null); 109 } else { 110 update_option("product_code_notice_dismiss", date('Y-m-d', strtotime('+30 days'))); 111 } 112 wp_send_json(array("status" => true)); 99 $post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS); 100 101 if (current_user_can('manage_options')) { 102 if (!empty(sanitize_text_field($post_data['dismissed_final']))) { 103 update_option('product_code_notice_dismiss', null); 104 } else { 105 update_option('product_code_notice_dismiss', gmdate('Y-m-d', strtotime('+30 days'))); 106 } 107 wp_send_json(array('status' => true)); 113 108 } 114 109 } 115 110 public function admin_notice() { 116 $last_dismissed = get_option( "product_code_notice_dismiss");111 $last_dismissed = get_option('product_code_notice_dismiss'); 117 112 118 113 if ($last_dismissed && current_time('timestamp') >= strtotime($last_dismissed)) { … … 137 132 'label' => $label, 138 133 'desc_tip' => true, 139 'description' => sprintf(__('%s refers to a company’s unique internal product identifier, needed for online product fulfillment.', 'product-code-for-woocommerce'), $label), 134 'description' => sprintf( 135 /* translators: 1 for label */ 136 __('%s refers to a company’s unique internal product identifier, needed for online product fulfillment.', 'product-code-for-woocommerce'), 137 $label 138 ), 140 139 'value' => get_post_meta($post->ID, PRODUCT_CODE_FIELD_NAME, true) 141 140 ]); 142 141 143 if ( $displaySecond == 'yes') {142 if ('yes' == $displaySecond) { 144 143 145 144 $html .= woocommerce_wp_text_input([ … … 147 146 'label' => $label_second, 148 147 'desc_tip' => true, 149 'description' => sprintf(__('%s refers to a company’s unique internal product identifier, needed for online product fulfillment.', 'product-code-for-woocommerce'), $label_second), 148 'description' => sprintf( 149 /* translators: 1 for label */ 150 __('%s refers to a company’s unique internal product identifier, needed for online product fulfillment.', 'product-code-for-woocommerce'), 151 $label_second 152 ), 150 153 'value' => get_post_meta($post->ID, PRODUCT_CODE_FIELD_NAME_SECOND, true) 151 154 ]); … … 156 159 157 160 public function save_product_code_meta() { 161 $post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS); 158 162 global $post; 159 163 160 164 if ( 161 $post->post_type == 'product' && !empty($_POST['woocommerce_meta_nonce']) &&162 wp_verify_nonce($ _POST['woocommerce_meta_nonce'], 'woocommerce_save_data')165 'product' == $post->post_type && !empty($post_data['woocommerce_meta_nonce']) && 166 wp_verify_nonce($post_data['woocommerce_meta_nonce'], 'woocommerce_save_data') 163 167 ) { 164 168 $field_name = PRODUCT_CODE_FIELD_NAME; 165 169 166 if (!empty($_POST[$field_name])) { 167 $code = sanitize_text_field($_POST[$field_name]); 168 if (!add_post_meta($post->ID, $field_name, $code, true)) 170 if (!empty($post_data[$field_name])) { 171 $code = sanitize_text_field($post_data[$field_name]); 172 173 $add_meta_result = add_post_meta($post->ID, $field_name, $code, true); 174 if (!$add_meta_result) { 169 175 update_post_meta($post->ID, $field_name, $code); 176 } 170 177 } else { 171 178 delete_post_meta($post->ID, $field_name); … … 175 182 $field_name = PRODUCT_CODE_FIELD_NAME_SECOND; 176 183 if (!empty($_POST[$field_name])) { 177 $code = sanitize_text_field($ _POST[$field_name]);178 if (!add_post_meta($post->ID, $field_name, $code, true)) 184 $code = sanitize_text_field($post_data[$field_name]); 185 if (!add_post_meta($post->ID, $field_name, $code, true)) { 179 186 update_post_meta($post->ID, $field_name, $code); 187 } 180 188 } else { 181 189 delete_post_meta($post->ID, $field_name); … … 196 204 197 205 public function save_variation_field($variation_id, $i) { 206 $post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS); 198 207 199 208 $field_name = PRODUCT_CODE_FIELD_NAME; 200 209 $form_field_name = sprintf('%s_%d', PRODUCT_CODE_FIELD_NAME, $i); 201 210 202 if (!empty($ _POST[$form_field_name])) {203 $code = sanitize_text_field($ _POST[$form_field_name]);204 if (!add_post_meta($variation_id, $field_name, $code, true)) 211 if (!empty($post_data[$form_field_name])) { 212 $code = sanitize_text_field($post_data[$form_field_name]); 213 if (!add_post_meta($variation_id, $field_name, $code, true)) { 205 214 update_post_meta($variation_id, $field_name, $code); 215 } 206 216 } else { 207 217 delete_post_meta($variation_id, $field_name); … … 212 222 $form_field_name = sprintf('%s_%d', PRODUCT_CODE_FIELD_NAME_SECOND, $i); 213 223 214 if (!empty($ _POST[$form_field_name])) {215 $code = sanitize_text_field($ _POST[$form_field_name]);216 if (!add_post_meta($variation_id, $field_name, $code, true)) 224 if (!empty($post_data[$form_field_name])) { 225 $code = sanitize_text_field($post_data[$form_field_name]); 226 if (!add_post_meta($variation_id, $field_name, $code, true)) { 217 227 update_post_meta($variation_id, $field_name, $code); 228 } 218 229 } else { 219 230 delete_post_meta($variation_id, $field_name); … … 224 235 225 236 public function add_quick_edit_field() { 226 227 /* $field_name = PRODUCT_CODE_FIELD_NAME;228 $code = get_post_meta( $post->ID, $field_name, true ); */229 237 require_once(PRODUCT_CODE_TEMPLATE_PATH . '/quick-edit-text-field.php'); 230 return;231 238 } 232 239 … … 236 243 237 244 public function get_field_title_text() { 238 $field_title = get_option( "product_code_text");245 $field_title = get_option('product_code_text'); 239 246 if ($field_title) { 240 247 return $field_title; 241 } else {242 return __('Product code', 'product-code-for-woocommerce'); 243 }248 } 249 250 return __('Product code', 'product-code-for-woocommerce'); 244 251 } 245 252 246 253 public function get_second_field_title_text() { 247 $field_title = get_option( "product_code_text_second");254 $field_title = get_option('product_code_text_second'); 248 255 if ($field_title) { 249 256 return $field_title; 250 } else {251 return __('Product code 2', 'product-code-for-woocommerce'); 252 }257 } 258 259 return __('Product code 2', 'product-code-for-woocommerce'); 253 260 } 254 261 255 262 public function get_edit_field_title_text() { 256 $field_title = get_option( "product_code_quik_edit_text");263 $field_title = get_option('product_code_quik_edit_text'); 257 264 if ($field_title) { 258 265 return $field_title; 259 } else {260 return __('Code', 'product-code-for-woocommerce'); 261 }266 } 267 268 return __('Code', 'product-code-for-woocommerce'); 262 269 } 263 270 264 271 public function get_second_edit_field_title_text() { 265 $field_title = get_option( "product_code_quik_edit_text_second");272 $field_title = get_option('product_code_quik_edit_text_second'); 266 273 if ($field_title) { 267 274 return $field_title; 268 } else {269 return __('Code 2', 'product-code-for-woocommerce'); 270 }275 } 276 277 return __('Code 2', 'product-code-for-woocommerce'); 271 278 } 272 279 … … 282 289 $new_columns[$key] = $value; 283 290 284 if ( $key === 'sku') {291 if ('sku' === $key) { 285 292 286 293 $label = $this->get_edit_field_title_text(); … … 288 295 289 296 $new_columns['pcw_product_code'] = $label; 290 if ( get_option('product_code_second_show') == 'yes') {297 if ('yes' == get_option('product_code_second_show')) { 291 298 $new_columns['pcw_product_code_2'] = $label_second; 292 299 } … … 300 307 global $post; 301 308 302 if (is_object($post) && isset($post->post_type) && $post->post_type === 'product' && $column_name === 'pcw_product_code') {309 if (is_object($post) && isset($post->post_type) && 'product' === $post->post_type && 'pcw_product_code' === $column_name) { 303 310 304 311 $product = wc_get_product($post->ID); 305 312 $type = $product->get_type(); 306 if ( $type === 'variable') {313 if ('variable' === $type) { 307 314 $product_code = ''; 308 315 } else { … … 313 320 echo '-'; 314 321 } else { 315 echo $product_code;316 } 317 ?>318 <div style="display:none;" class="hidden" id="pcfw_woocommerce_inline_<?php echo $post->ID; ?>">319 <div class="product_code_val"><?php echo get_post_meta($post->ID, PRODUCT_CODE_FIELD_NAME, true); ?></div>320 <div class="product_code_2_val"><?php echo get_post_meta($post->ID, PRODUCT_CODE_FIELD_NAME_SECOND, true); ?></div>322 echo esc_html($product_code); 323 } 324 ?> 325 <div style="display:none;" class="hidden" id="pcfw_woocommerce_inline_<?php echo absint($post->ID); ?>"> 326 <div class="product_code_val"><?php echo esc_html(get_post_meta($post->ID, PRODUCT_CODE_FIELD_NAME, true)); ?></div> 327 <div class="product_code_2_val"><?php echo esc_html(get_post_meta($post->ID, PRODUCT_CODE_FIELD_NAME_SECOND, true)); ?></div> 321 328 <?php 322 329 } 323 330 324 if (is_object($post) && isset($post->post_type) && $post->post_type === 'product' && $column_name === 'pcw_product_code_2') {331 if (is_object($post) && isset($post->post_type) && 'product' === $post->post_type && 'pcw_product_code_2' === $column_name) { 325 332 326 333 $product = wc_get_product($post->ID); 327 334 $type = $product->get_type(); 328 if ( $type === 'variable') {335 if ('variable' === $type) { 329 336 $product_code = ''; 330 337 } else { … … 335 342 echo '-'; 336 343 } else { 337 echo $product_code;344 echo esc_html($product_code); 338 345 } 339 346 } … … 341 348 342 349 public function inline_javascript() { 343 ?>350 ?> 344 351 <script> 345 352 jQuery(function() { … … 350 357 if (jQuery('body').hasClass('post-type-product')) { 351 358 if (jQuery('input#pcw_product_code-hide').length > 0) { 352 document.getElementById('pcw_product_code-hide').parentNode.childNodes[1].textContent = '<?php e cho __('Product code', 'product-code-for-woocommerce'); ?>';359 document.getElementById('pcw_product_code-hide').parentNode.childNodes[1].textContent = '<?php esc_html_e('Product code', 'product-code-for-woocommerce'); ?>'; 353 360 } 354 361 } … … 356 363 if (jQuery('body').hasClass('post-type-product')) { 357 364 if (jQuery('input#pcw_product_code_2-hide').length > 0) { 358 document.getElementById('pcw_product_code_2-hide').parentNode.childNodes[1].textContent = '<?php e cho __('Product code 2', 'product-code-for-woocommerce'); ?>';365 document.getElementById('pcw_product_code_2-hide').parentNode.childNodes[1].textContent = '<?php esc_html_e('Product code 2', 'product-code-for-woocommerce'); ?>'; 359 366 } 360 367 } … … 378 385 ?> 379 386 <label class="product_code_1_label"> 380 <span class="title product_code_title"><?php echo $label; ?></span>387 <span class="title product_code_title"><?php echo esc_html($label); ?></span> 381 388 <span class="input-text-wrap"> 382 <input style="<?php echo $product_one_input_style; ?>" type="text" name="<?php echo PRODUCT_CODE_FIELD_NAME; ?>" class="text product_code_field" value="">389 <input style="<?php echo esc_attr($product_one_input_style); ?>" type="text" name="<?php echo esc_html(PRODUCT_CODE_FIELD_NAME); ?>" class="text product_code_field" value=""> 383 390 </span> 384 391 </label> 385 392 <?php if ($show_product_code_2) { ?> 386 393 <label class="product_code_2_label"> 387 <span class="title product_code_title_2"> <?php echo $label_second; ?> </span>394 <span class="title product_code_title_2"> <?php echo esc_html($label_second); ?> </span> 388 395 <span class="input-text-wrap"> 389 <input type="text" name="<?php echo PRODUCT_CODE_FIELD_NAME_SECOND; ?>" class="text product_code_field" value="">396 <input type="text" name="<?php echo esc_attr(PRODUCT_CODE_FIELD_NAME_SECOND); ?>" class="text product_code_field" value=""> 390 397 </span> 391 398 </label> … … 396 403 397 404 public function pcfw_woocommerce_product_quick_edit_save($product) { 405 $post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS); 398 406 399 407 $product_id = $product->get_id(); 400 408 401 409 $field_name = PRODUCT_CODE_FIELD_NAME; 402 if (!empty($ _POST[$field_name])) {403 $code = sanitize_text_field($ _POST[$field_name]);404 if (!add_post_meta($product_id, $field_name, $code, true)) 410 if (!empty($post_data[$field_name])) { 411 $code = sanitize_text_field($post_data[$field_name]); 412 if (!add_post_meta($product_id, $field_name, $code, true)) { 405 413 update_post_meta($product_id, $field_name, $code); 414 } 406 415 } else { 407 416 delete_post_meta($product_id, $field_name); … … 410 419 // Saving Second Field Product Meta 411 420 $field_name = PRODUCT_CODE_FIELD_NAME_SECOND; 412 if (!empty($ _POST[$field_name])) {413 $code = sanitize_text_field($ _POST[$field_name]);414 if (!add_post_meta($product_id, $field_name, $code, true)) 421 if (!empty($post_data[$field_name])) { 422 $code = sanitize_text_field($post_data[$field_name]); 423 if (!add_post_meta($product_id, $field_name, $code, true)) { 415 424 update_post_meta($product_id, $field_name, $code); 425 } 416 426 } else { 417 427 delete_post_meta($product_id, $field_name); … … 420 430 421 431 public function admin_enqueue_scripts() { 422 if ( get_current_screen()->id != 'woocommerce_page_wc-settings' || !isset($_GET['section']) || $_GET['section'] !== 'product_code_settings') {432 if ('woocommerce_page_wc-settings' != get_current_screen()->id || !isset($_GET['section']) || 'product_code_settings' !== $_GET['section']) { 423 433 return; 424 434 } … … 429 439 /** 430 440 * Make product code column sortable 441 * 431 442 * @since 1.4.3 432 443 * @return array … … 440 451 /** 441 452 * Sortable product table 453 * 442 454 * @since 1.4.3 443 455 * @return void … … 452 464 } 453 465 454 if (isset($_GET['orderby']) && ( $_GET['orderby'] == 'product_code' || $_GET['orderby'] == 'product_code_2')) {455 $meta_key = $_GET['orderby'] == 'product_code_2'? '_product_code_second' : '_product_code';466 if (isset($_GET['orderby']) && ( 'product_code' == $_GET['orderby'] || 'product_code_2' == $_GET['orderby'] )) { 467 $meta_key = 'product_code_2' == $_GET['orderby'] ? '_product_code_second' : '_product_code'; 456 468 457 469 $meta_query = array( -
product-code-for-woocommerce/trunk/classes/class-pcfw-services.php
r2967261 r3004043 7 7 private $admin_settings; 8 8 public function __construct() { 9 $this->admin_settings = new PCFW_Admin_ settings();9 $this->admin_settings = new PCFW_Admin_Settings(); 10 10 $this->actions(); 11 11 } … … 30 30 add_action('woocommerce_admin_field_file', [$this, 'add_admin_field_file']); 31 31 add_action('woocommerce_admin_field_button', [$this, 'add_admin_field_button']); 32 add_action( "admin_menu", array($this, "add_to_wc_submenu"), 90);32 add_action('admin_menu', array($this, 'add_to_wc_submenu'), 90); 33 33 add_filter('plugin_row_meta', [$this, 'plugin_row_filter'], 10, 3); 34 34 add_action('wp_ajax_product_code', [$this, 'ajax_get_product_code']); … … 43 43 44 44 public function PCFW_add_body_class($classes) { 45 if ( get_option('product_code_hide_empty_field') == "yes")45 if ('yes' == get_option('product_code_hide_empty_field')) { 46 46 $classes[] = 'hide_pcode'; 47 } 48 47 49 return $classes; 48 50 } … … 63 65 public function enqueue() { 64 66 global $post; 65 if (( !empty($post) && $post->post_type == 'product') || is_wc_endpoint_url('order-pay') || is_wc_endpoint_url('order-received') || is_wc_endpoint_url('view-order')) :67 if (( !empty($post) && 'product' == $post->post_type ) || is_wc_endpoint_url('order-pay') || is_wc_endpoint_url('order-received') || is_wc_endpoint_url('view-order')) : 66 68 67 69 //wp_enqueue_script( 'product-code-frontend', PRODUCT_CODE_URL . '/assets/js/stl_custom.js', [ 'wc-add-to-cart-variation', 'jquery' ]); … … 129 131 public function retrieve_product_code_in_cart($cart_item_data, $cart_item) { 130 132 $simple_field_name = PRODUCT_CODE_FIELD_NAME; 131 $txt = get_option( "product_code_text", '');133 $txt = get_option('product_code_text', ''); 132 134 $cart_data = []; 133 if ( get_option('product_code') == 'yes') :135 if ('yes' == get_option('product_code')) : 134 136 if (isset($cart_item[$simple_field_name])) { 135 137 $cart_data[] = array( … … 141 143 142 144 // Second product 143 if ( get_option('product_code_second') == 'yes' && get_option('product_code_second_show') == 'yes') :145 if ('yes' == get_option('product_code_second') && 'yes' == get_option('product_code_second_show')) : 144 146 $simple_field_name = PRODUCT_CODE_FIELD_NAME_SECOND; 145 $txt = get_option( "product_code_text_second", '');147 $txt = get_option('product_code_text_second', ''); 146 148 147 149 // $cart_data = []; … … 159 161 public function process_order_item($item, $cart_item_key, $values, $order) { 160 162 $simple_field_name = PRODUCT_CODE_FIELD_NAME; 161 $txt = get_option( "product_code_text", '');163 $txt = get_option('product_code_text', ''); 162 164 if (isset($values[$simple_field_name])) { 163 $item->add_meta_data(( $txt ? $txt : __('Product Code', 'product-code-for-woocommerce')), $values[$simple_field_name], false);165 $item->add_meta_data(( $txt ? $txt : __('Product Code', 'product-code-for-woocommerce') ), $values[$simple_field_name], false); 164 166 } 165 167 $simple_field_name = PRODUCT_CODE_FIELD_NAME_SECOND; 166 $txt = get_option( "product_code_text_second", '');168 $txt = get_option('product_code_text_second', ''); 167 169 if (isset($values[$simple_field_name])) { 168 $item->add_meta_data(( $txt ? $txt : __('Product Code', 'product-code-for-woocommerce')), $values[$simple_field_name], false);170 $item->add_meta_data(( $txt ? $txt : __('Product Code', 'product-code-for-woocommerce') ), $values[$simple_field_name], false); 169 171 } 170 172 } … … 173 175 $field_name = PRODUCT_CODE_FIELD_NAME; 174 176 175 $txt = get_option( "product_code_text", '');177 $txt = get_option('product_code_text', ''); 176 178 177 179 foreach ($formatted_meta as $idx => $meta) { … … 196 198 // Second Product Item Meta 197 199 $field_name = PRODUCT_CODE_FIELD_NAME_SECOND; 198 $txt = get_option( "product_code_text_second", '');200 $txt = get_option('product_code_text_second', ''); 199 201 foreach ($formatted_meta as $idx => $meta) { 200 202 if ($meta->key === $field_name) { … … 218 220 219 221 public function get_order_item_meta_display_key($display_key, $meta, $item) { 220 if ( $meta->key === PRODUCT_CODE_FIELD_NAME) {221 $txt = get_option( "product_code_text", '');222 if (PRODUCT_CODE_FIELD_NAME === $meta->key) { 223 $txt = get_option('product_code_text', ''); 222 224 return $txt ? $txt : __('Product Code', 'product-code-for-woocommerce'); 223 225 } 224 226 225 if ( $meta->key === PRODUCT_CODE_FIELD_NAME_SECOND) {226 $txt = get_option( "product_code_text_second", '');227 if (PRODUCT_CODE_FIELD_NAME_SECOND === $meta->key) { 228 $txt = get_option('product_code_text_second', ''); 227 229 return $txt ? $txt : __('Product Code', 'product-code-for-woocommerce'); 228 230 } … … 230 232 } 231 233 public function display_product_code() { 232 if ( get_option('product_code') == 'yes') {234 if ('yes' == get_option('product_code')) { 233 235 $post = get_post(); 234 236 $value = get_post_meta($post->ID, PRODUCT_CODE_FIELD_NAME, true); 235 $text = get_option( "product_code_text", "");237 $text = get_option('product_code_text', ''); 236 238 $value_second = get_post_meta($post->ID, PRODUCT_CODE_FIELD_NAME_SECOND, true); 237 239 238 $text_second = get_option( "product_code_text_second", "");240 $text_second = get_option('product_code_text_second', ''); 239 241 include_once(PRODUCT_CODE_TEMPLATE_PATH . '/product-meta-row.php'); 240 return;241 242 } 242 243 } … … 248 249 249 250 public function add_to_wc_submenu() { 250 add_submenu_page( "woocommerce", __("Product Code", "product-code-for-woocommerce"), __("Product Code", "product-code-for-woocommerce"), "manage_options", "wc_product_code", function () {251 printf("<script>window.location='%s'</script>", admin_url("admin.php?page=wc-settings&tab=products§ion=product_code_settings"));251 add_submenu_page('woocommerce', __('Product Code', 'product-code-for-woocommerce'), __('Product Code', 'product-code-for-woocommerce'), 'manage_options', 'wc_product_code', function () { 252 printf("<script>window.location='%s'</script>", esc_url_raw(admin_url('admin.php?page=wc-settings&tab=products§ion=product_code_settings'))); 252 253 }); 253 254 255 256 254 } 257 255 258 256 public function add_product_code_settings($settings, $current_section) { 259 if ( $current_section == 'product_code_settings') {257 if ('product_code_settings' == $current_section) { 260 258 $settings_slider = array(); 261 259 … … 289 287 'id' => 'product_code_text', 290 288 'type' => 'text', 291 'default' => "Product Code",289 'default' => 'Product Code', 292 290 'desc' => __('Field title can be edited to read anything, no longer than 12 characters including spaces.', 'product-code-for-woocommerce'), 293 291 ); … … 298 296 'id' => 'product_code_quik_edit_text', 299 297 'type' => 'text', 300 'default' => "Code",298 'default' => 'Code', 301 299 'desc' => __('Admin products column title can be edited to read anything, no longer than 12 characters including spaces.', 'product-code-for-woocommerce'), 302 300 ); … … 331 329 'id' => 'product_code_text_second', 332 330 'type' => 'text', 333 'default' => "Product Code 2",331 'default' => 'Product Code 2', 334 332 'desc' => __('Field title can be edited to read anything, no longer than 14 characters including spaces.', 'product-code-for-woocommerce'), 335 333 ); … … 340 338 'id' => 'product_code_quik_edit_text_second', 341 339 'type' => 'text', 342 'default' => "Code 2",340 'default' => 'Code 2', 343 341 'desc' => __('Admin second products column title can be edited to read anything, no longer than 14 characters including spaces.', 'product-code-for-woocommerce'), 344 342 ); … … 386 384 387 385 public function add_admin_field_file($value) { 388 ?>386 ?> 389 387 390 388 <tr valign="top"> … … 392 390 <label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label> 393 391 </th> 394 <td class="forminp forminp-<?php echo sanitize_title($value['type'])?>">392 <td class="forminp forminp-<?php echo esc_attr($value['type']); ?>"> 395 393 <input name="<?php echo esc_attr($value['name']); ?>" id="<?php echo esc_attr($value['id']); ?>" type="file" style="<?php echo esc_attr($value['css']); ?>" value="<?php echo esc_attr($value['name']); ?>" class="<?php echo esc_attr($value['class']); ?>" /> 396 394 </td> … … 400 398 } 401 399 public function add_admin_field_button($value) { 402 ?>400 ?> 403 401 404 402 <tr valign="top"> … … 406 404 <label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label> 407 405 </th> 408 <td class="forminp forminp-<?php echo sanitize_title($value['type'])?>">406 <td class="forminp forminp-<?php echo esc_attr($value['type']); ?>"> 409 407 <a target="_blank" href="<?php echo esc_attr($value['href']); ?>" name="<?php echo esc_attr($value['name']); ?>" id="<?php echo esc_attr($value['id']); ?>" style="<?php echo esc_attr($value['css']); ?>" value="<?php echo esc_attr($value['name']); ?>" class="<?php echo esc_attr($value['class']); ?>"><?php echo esc_attr($value['name']); ?></a> 410 408 </td> … … 415 413 416 414 public function ajax_get_product_code() { 415 $post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS); 417 416 $simple_field_name = PRODUCT_CODE_FIELD_NAME; 418 if ( $_POST['code_num'] == 'second')417 if ('second' == $post_data['code_num']) { 419 418 $simple_field_name = PRODUCT_CODE_FIELD_NAME_SECOND; 420 421 $value = get_post_meta((int) $_POST['product_code_id'], $simple_field_name, true); 419 } 420 421 $value = get_post_meta((int) $post_data['product_code_id'], $simple_field_name, true); 422 422 423 423 echo json_encode([ … … 432 432 public function show_woocommerce_missing_notice() { 433 433 echo '<div class="notice notice-error is-dismissible"> 434 <p>' . __('Product Code for WooCommerce Add-on requires Woocommerce plugin to be installed and activated.', 'product-code-for-woocommerce') . '</p>435 </div>';434 <p>' . esc_html__('Product Code for WooCommerce Add-on requires Woocommerce plugin to be installed and activated.', 'product-code-for-woocommerce') . '</p> 435 </div>'; 436 436 } 437 437 438 438 /** 439 439 * Add the product code to structured data. 440 * 440 441 * @param $data 441 *442 442 * @return mixed 443 443 */ … … 445 445 446 446 // Applies only when enable 447 if ( get_option('pcfw_structure_data') == 'yes') {447 if ('yes' == get_option('pcfw_structure_data')) { 448 448 $property = apply_filters('pcfw_structured_data_property', get_option('pcfw_structured_data_field', 'gtin'), $product); 449 449 $product_code = get_post_meta($product->get_id(), '_product_code'); … … 451 451 //$product_code_second = get_post_meta( $product->get_id(), '_product_code_second' ); 452 452 453 $data[$property] = !empty($product_code) ? $product_code : "N/A";453 $data[$property] = !empty($product_code) ? $product_code : 'N/A'; 454 454 455 455 //$data[ $property ][] = ! empty( $product_code_second )? $product_code_second : "N/A"; … … 458 458 return $data; 459 459 } 460 461 462 /**463 * @param $atts array464 * @return string465 */466 460 467 461 public function product_code_shortcode($atts) { … … 470 464 $atts = shortcode_atts(array( 471 465 'id' => '', 472 'pc_label' => get_option('product_code_text', __( "Product Code:", 'product-code-for-woocommerce')),473 'pcs_label' => get_option('product_code_text_second', __( "Product Code Second:", 'product-code-for-woocommerce')),466 'pc_label' => get_option('product_code_text', __('Product Code:', 'product-code-for-woocommerce')), 467 'pcs_label' => get_option('product_code_text_second', __('Product Code Second:', 'product-code-for-woocommerce')), 474 468 'wrapper' => is_shop() ? 'div' : 'span', 475 469 'wrapper_code' => 'span', … … 498 492 $is_product_code = $product->get_meta('_product_code'); 499 493 $is_product_code_second = $product->get_meta('_product_code_second'); 500 $product_code = (!empty($is_product_code)) ? $is_product_code : "N/A";501 $product_code_second = (!empty($is_product_code_second)) ? $is_product_code_second : "N/A";494 $product_code = !empty($is_product_code) ? $is_product_code : 'N/A'; 495 $product_code_second = !empty($is_product_code_second) ? $is_product_code_second : 'N/A'; 502 496 503 497 ob_start(); 504 498 505 if ($product_code || ( get_option('product_code_hide_empty_field') != 'yes' && !$product_code) || (is_single() && $product->is_type('variable'))) :506 //echo sprintf('<%1$s class="%3$s">%2$s: <%4$s class="%5$s" data-product-id="%7$s">%6$s</%4$s></%1$s>', $atts['wrapper'], $atts['pc_label'], esc_attr($atts['class_wrapper']), $atts['wrapper_code'], esc_attr($atts['class']), $product_code, $product->get_id());499 if ($product_code || ( 'yes' != get_option('product_code_hide_empty_field') && !$product_code ) || ( is_single() && $product->is_type('variable') )) : 500 echo wp_kses_post(sprintf('<%1$s class="%3$s">%2$s: <%4$s class="%5$s" data-product-id="%7$s">%6$s</%4$s></%1$s>', esc_html($atts['wrapper']), esc_html($atts['pc_label']), esc_attr($atts['class_wrapper']), esc_html($atts['wrapper_code']), esc_attr($atts['class']), esc_html($product_code), $product->get_id())); 507 501 endif; 508 502 509 var_dump($product_code_second); 510 511 if (get_option('product_code_second') == 'yes') { 512 if ($product_code_second || (get_option('product_code_hide_empty_field') != 'yes' && !$product_code_second) || (is_single() && $product->is_type('variable'))) : 513 echo sprintf('<%1$s class="%3$s">%2$s: <%4$s class="%5$s" data-product-id="%7$s">%6$s</%4$s></%1$s>', $atts['wrapper'], $atts['pcs_label'], esc_attr($atts['class_wrapper']), $atts['wrapper_code'], esc_attr($atts['class']), $product_code_second, $product->get_id()); 503 if ('yes' == get_option('product_code_second')) { 504 if ($product_code_second || ( 'yes' != get_option('product_code_hide_empty_field') && !$product_code_second ) || ( is_single() && $product->is_type('variable') )) : 505 echo wp_kses_post(sprintf('<br><%1$s class="%3$s">%2$s: <%4$s class="%5$s" data-product-id="%7$s">%6$s</%4$s></%1$s>', esc_html($atts['wrapper']), esc_html($atts['pcs_label']), esc_attr($atts['class_wrapper']), esc_html($atts['wrapper_code']), esc_attr($atts['class']), esc_html($product_code_second), $product->get_id())); 514 506 endif; 515 507 } -
product-code-for-woocommerce/trunk/modules/export/pcfw-export-support.php
r2933587 r3004043 1 1 <?php 2 2 3 /**4 5 *6 7 */8 3 9 4 if (!defined('ABSPATH')) { … … 12 7 } 13 8 14 class PCFW_ wc_export_filter {9 class PCFW_Wc_Export_Filter { 15 10 16 11 … … 82 77 } 83 78 84 return new PCFW_ wc_export_filter();79 return new PCFW_Wc_Export_Filter(); -
product-code-for-woocommerce/trunk/modules/search/pcfw-filter-search.php
r2588140 r3004043 1 1 <?php 2 2 3 /** 3 4 * Remove method for an hook when, it's a class method used and class don't have global for instanciation ! 4 5 */ 5 function pcfw_remove_filters_with_method_name( $hook_name = '', $method_name = '', $priority = 0) {6 function pcfw_remove_filters_with_method_name($hook_name = '', $method_name = '', $priority = 0) { 6 7 global $wp_filter; 7 8 8 9 // Take only filters on right hook name and priority 9 if ( !isset($wp_filter[$hook_name][$priority]) || !is_array($wp_filter[$hook_name][$priority]) )10 if (!isset($wp_filter[$hook_name][$priority]) || !is_array($wp_filter[$hook_name][$priority])) { 10 11 return false; 11 12 } 13 12 14 // Loop on filters registered 13 foreach ( (array) $wp_filter[$hook_name][$priority] as $unique_id => $filter_array) {14 if ( isset($filter_array['function']) && is_array($filter_array['function'])) {15 if ( is_object($filter_array['function'][0]) && get_class($filter_array['function'][0]) && $filter_array['function'][1] == $method_name) {15 foreach ( (array) $wp_filter[$hook_name][$priority] as $unique_id => $filter_array) { 16 if (isset($filter_array['function']) && is_array($filter_array['function'])) { 17 if (is_object($filter_array['function'][0]) && get_class($filter_array['function'][0]) && $filter_array['function'][1] == $method_name) { 16 18 unset($wp_filter[$hook_name][$priority][$unique_id]); 17 19 } 18 } 19 } 20 } 21 } 20 22 return false; 21 23 } … … 24 26 * Allow to remove method for an hook when, it's a class method used and class don't have variable, but you know the class name :) 25 27 */ 26 function pcfw_remove_filters_for_anonymous_class( $hook_name = '', $class_name ='', $method_name = '', $priority = 0) {28 function pcfw_remove_filters_for_anonymous_class($hook_name = '', $class_name = '', $method_name = '', $priority = 0) { 27 29 global $wp_filter; 28 30 // Take only filters on right hook name and priority 29 if ( !isset($wp_filter[$hook_name][$priority]) || !is_array($wp_filter[$hook_name][$priority]) )31 if (!isset($wp_filter[$hook_name][$priority]) || !is_array($wp_filter[$hook_name][$priority])) { 30 32 return false; 31 33 } 34 32 35 // Loop on filters registered 33 foreach ( (array) $wp_filter[$hook_name][$priority] as $unique_id => $filter_array) {34 if ( isset($filter_array['function']) && is_array($filter_array['function'])) {35 if ( is_object($filter_array['function'][0]) && get_class($filter_array['function'][0]) && get_class($filter_array['function'][0]) == $class_name && $filter_array['function'][1] == $method_name) {36 foreach ((array) $wp_filter[$hook_name][$priority] as $unique_id => $filter_array) { 37 if (isset($filter_array['function']) && is_array($filter_array['function'])) { 38 if (is_object($filter_array['function'][0]) && get_class($filter_array['function'][0]) && get_class($filter_array['function'][0]) == $class_name && $filter_array['function'][1] == $method_name) { 36 39 unset($wp_filter[$hook_name][$priority][$unique_id]); 37 40 } 38 } 39 } 41 } 42 } 40 43 return false; 41 44 } -
product-code-for-woocommerce/trunk/modules/search/pcfw-product-code-search.php
r2588140 r3004043 4 4 * Replacement of WC_Admin_Post_Types::product_search() 5 5 */ 6 add_filter('posts_search', 'pcfw_product_code_search', 9);6 add_filter('posts_search', 'pcfw_product_code_search', 9); 7 7 function pcfw_product_code_search($where) { 8 global $pagenow, $wpdb, $wp;9 $type = array('product', 'product_variation');10 if ((is_admin() && 'edit.php' != $pagenow) 11 || !is_search() 12 || !isset($wp->query_vars['s']) 13 //post_types can also be arrays..14 || (isset($wp->query_vars['post_type']) && 'product' != $wp->query_vars['post_type'])15 || (isset($wp->query_vars['post_type']) && is_array($wp->query_vars['post_type']) && !in_array('product', $wp->query_vars['post_type']) ) 16 ) {17 return $where;18 }19 $search_ids = array();20 $terms = explode(',', $wp->query_vars['s']);8 global $pagenow, $wpdb, $wp; 9 $type = array('product', 'product_variation'); 10 if (( is_admin() && 'edit.php' != $pagenow ) 11 || !is_search() 12 || !isset($wp->query_vars['s']) 13 //post_types can also be arrays.. 14 || ( isset($wp->query_vars['post_type']) && 'product' != $wp->query_vars['post_type'] ) 15 || ( isset($wp->query_vars['post_type']) && is_array($wp->query_vars['post_type']) && !in_array('product', $wp->query_vars['post_type']) ) 16 ) { 17 return $where; 18 } 19 $search_ids = array(); 20 $terms = explode(',', $wp->query_vars['s']); 21 21 22 foreach ($terms as $term) { 23 //Include search by id if admin area. 24 if (is_admin() && is_numeric($term)) { 25 $search_ids[] = $term; 26 } 27 // search variations with a matching product code and return the parent. 22 foreach ($terms as $term) { 23 //Include search by id if admin area. 24 if (is_admin() && is_numeric($term)) { 25 $search_ids[] = $term; 26 } 27 // search variations with a matching product code and return the parent. 28 $term_like = '%' . $wpdb->esc_like($term) . '%'; 29 $product_code_to_parent_id = $wpdb->get_col($wpdb->prepare("SELECT p.post_parent as post_id FROM {$wpdb->posts} as p join {$wpdb->postmeta} pm on p.ID = pm.post_id and pm.meta_key IN('_product_code', '_product_code_second' ) and pm.meta_value LIKE %s where p.post_parent <> 0 group by p.post_parent", $term_like)); 28 30 29 $product_code_to_parent_id = $wpdb->get_col($wpdb->prepare("SELECT p.post_parent as post_id FROM {$wpdb->posts} as p join {$wpdb->postmeta} pm on p.ID = pm.post_id and pm.meta_key IN('_product_code', '_product_code_second' ) and pm.meta_value LIKE '%%%s%%' where p.post_parent <> 0 group by p.post_parent", wc_clean($term))); 31 //Search a regular product that matches the product code. 32 $product_code_to_id = $wpdb->get_col($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key IN ('_product_code', '_product_code_second' ) AND meta_value LIKE %s;", $term_like)); 30 33 31 //Search a regular product that matches the product code. 32 $product_code_to_id = $wpdb->get_col($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key IN ('_product_code', '_product_code_second' ) AND meta_value LIKE '%%%s%%';", wc_clean($term))); 34 $search_ids = array_merge($search_ids, $product_code_to_id, $product_code_to_parent_id); 35 } 33 36 34 $search_ids = array_merge($search_ids, $product_code_to_id, $product_code_to_parent_id); 35 } 37 $search_ids = array_filter(array_map('absint', $search_ids)); 36 38 37 $search_ids = array_filter(array_map('absint', $search_ids)); 39 if (count($search_ids) > 0) { 40 $where = str_replace(')))', ") OR ({$wpdb->posts}.ID IN (" . implode(',', $search_ids) . '))))', $where); 41 } 38 42 39 if (sizeof($search_ids) > 0) { 40 $where = str_replace(')))', ") OR ({$wpdb->posts}.ID IN (" . implode(',', $search_ids) . "))))", $where); 41 } 42 43 pcfw_remove_filters_for_anonymous_class('posts_search', 'WC_Admin_Post_Types', 'product_search', 10); 44 return $where; 43 pcfw_remove_filters_for_anonymous_class('posts_search', 'WC_Admin_Post_Types', 'product_search', 10); 44 return $where; 45 45 } 46 46 … … 48 48 * Search products by product code via administartor product list page 49 49 */ 50 add_filter( 'request', 'pcfw_product_code_admin_search', 20);51 function pcfw_product_code_admin_search( $query_vars) {50 add_filter('request', 'pcfw_product_code_admin_search', 20); 51 function pcfw_product_code_admin_search($query_vars) { 52 52 global $typenow; 53 53 global $wpdb; 54 54 global $pagenow; 55 55 56 if ( is_admin() && 'product' === $typenow && isset( $_GET['s'] ) && 'edit.php' === $pagenow ) { 57 $search_term = esc_sql( sanitize_text_field( $_GET['s'] ) ); 58 $post_types = array( 'product', 'product_variation' ); 56 if (is_admin() && 'product' === $typenow && isset($_GET['s']) && 'edit.php' === $pagenow) { 57 $search_term = esc_sql(sanitize_text_field($_GET['s'])); 59 58 $search_results = $wpdb->get_results( 60 59 $wpdb->prepare( 61 "SELECT DISTINCT posts.ID as product_id, posts.post_parent as parent_id FROM {$wpdb->posts} posts LEFT JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id WHERE postmeta.meta_key IN('_product_code_second', '_product_code' ) AND postmeta.meta_value LIKE %s AND posts.post_type IN (' " . implode( "','", $post_types ) . "') ORDER BY posts.post_parent ASC, posts.post_title ASC",62 '%' . $wpdb->esc_like( $search_term) . '%'60 "SELECT DISTINCT posts.ID as product_id, posts.post_parent as parent_id FROM {$wpdb->posts} posts LEFT JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id WHERE postmeta.meta_key IN('_product_code_second', '_product_code' ) AND postmeta.meta_value LIKE %s AND posts.post_type IN ('product', 'product_variation') ORDER BY posts.post_parent ASC, posts.post_title ASC", 61 '%' . $wpdb->esc_like($search_term) . '%' 63 62 ) 64 63 ); 65 $product_ids = wp_parse_id_list( array_merge( wp_list_pluck( $search_results, 'product_id' ), wp_list_pluck( $search_results, 'parent_id' ) ));66 if( isset( $query_vars['post__in'] )) {67 $query_vars['post__in'] = array_merge( $product_ids, $query_vars['post__in']);68 }64 $product_ids = wp_parse_id_list(array_merge(wp_list_pluck($search_results, 'product_id'), wp_list_pluck($search_results, 'parent_id'))); 65 if (isset($query_vars['post__in'])) { 66 $query_vars['post__in'] = array_merge($product_ids, $query_vars['post__in']); 67 } 69 68 } 70 69 -
product-code-for-woocommerce/trunk/modules/search/pcfw-relevanssi-product-code-search.php
r2588140 r3004043 1 1 <?php 2 2 // Indexing variation product code 3 add_filter( 'relevanssi_content_to_index', 'rlv_index_variation_product_code', 10, 2);3 add_filter('relevanssi_content_to_index', 'rlv_index_variation_product_code', 10, 2); 4 4 5 function rlv_index_variation_product_code( $content, $post) {6 if ( 'product' === $post->post_type) {7 $args = array(8 'post_parent' => $post->ID,9 'post_type' => 'product_variation',10 'posts_per_page' => -111 );12 $variations = get_posts( $args);13 if ( !empty( $variations )) {14 foreach ( $variations as $variation) {15 $sku = get_post_meta( $variation->ID, '_product_code', true);16 $content .= " $sku";17 }18 }19 }20 return $content;5 function rlv_index_variation_product_code($content, $post) { 6 if ('product' === $post->post_type) { 7 $args = array( 8 'post_parent' => $post->ID, 9 'post_type' => 'product_variation', 10 'posts_per_page' => -1 11 ); 12 $variations = get_posts($args); 13 if (!empty($variations)) { 14 foreach ($variations as $variation) { 15 $sku = get_post_meta($variation->ID, '_product_code', true); 16 $content .= " $sku"; 17 } 18 } 19 } 20 return $content; 21 21 } -
product-code-for-woocommerce/trunk/modules/search/pcfw-searchwp-product-code-search.php
r2588140 r3004043 3 3 4 4 5 add_filter( 'searchwp_extra_metadata', 'my_searchwp_index_woocommerce_variation_product_code', 10, 2);5 add_filter('searchwp_extra_metadata', 'my_searchwp_index_woocommerce_variation_product_code', 10, 2); 6 6 7 7 … … 9 9 // index WooCommerce product_variation product code with the parent post 10 10 11 function my_searchwp_index_woocommerce_variation_product_code( $extra_meta, $post_being_indexed) {11 function my_searchwp_index_woocommerce_variation_product_code($extra_meta, $post_being_indexed) { 12 12 13 13 … … 15 15 // we only care about WooCommerce Products 16 16 17 if ( 'product' !== get_post_type( $post_being_indexed )) {17 if ('product' !== get_post_type($post_being_indexed)) { 18 18 19 19 return $extra_meta; 20 21 20 } 22 21 … … 37 36 ); 38 37 39 $product_variations = get_posts( $args);38 $product_variations = get_posts($args); 40 39 41 40 42 41 43 if ( ! empty( $product_variations )) {42 if (!empty($product_variations)) { 44 43 45 44 … … 49 48 $extra_meta['_product_code_second'] = array(); 50 49 51 50 52 51 53 52 … … 55 54 // loop through all product variations, grab and store the SKU 56 55 57 foreach ( $product_variations as $product_variation) {56 foreach ($product_variations as $product_variation) { 58 57 59 $extra_meta['_product_code'][] = get_post_meta( absint( $product_variation ), '_product_code', true);58 $extra_meta['_product_code'][] = get_post_meta(absint($product_variation), '_product_code', true); 60 59 61 $extra_meta['_product_code_second'][] = get_post_meta( absint( $product_variation ), '_product_code_second', true ); 62 60 $extra_meta['_product_code_second'][] = get_post_meta(absint($product_variation), '_product_code_second', true); 63 61 } 64 65 62 } 66 63 67 64 68 65 69 66 return $extra_meta; 70 71 67 } 72 68 73 69 74 70 75 add_filter( 'searchwp_custom_field_keys', 'my_searchwp_custom_field_keys_product_code_variant', 10, 1);71 add_filter('searchwp_custom_field_keys', 'my_searchwp_custom_field_keys_product_code_variant', 10, 1); 76 72 77 73 78 74 79 function my_searchwp_custom_field_keys_product_code_variant( $keys) {75 function my_searchwp_custom_field_keys_product_code_variant($keys) { 80 76 81 $keys[] = '_product_code'; 77 $keys[] = '_product_code'; 82 78 83 $keys[] = '_product_code_second';79 $keys[] = '_product_code_second'; 84 80 85 return $keys; 86 81 return $keys; 87 82 } -
product-code-for-woocommerce/trunk/product-code-for-woocommerce.php
r3000925 r3004043 2 2 3 3 /** 4 * @package PCFW5 * @wordpress-plugin6 *7 4 * Plugin Name: Product Code for WooCommerce 8 5 * Plugin URI: http://wordpress.org/plugins/product-code-for-woocommerce 9 6 * Description: Plugin provides a unique internal product identifier in addition to the GTIN, EAN, SKU and UPC throughout the order process. A secondary product code field can be activated from setup. 10 * Version: 1.4. 47 * Version: 1.4.5 11 8 * Author: Artios Media 12 9 * Author URI: http://www.artiosmedia.com … … 17 14 * Text Domain: product-code-for-woocommerce 18 15 * Domain Path: /languages 19 * Tested up to: 6. 4.116 * Tested up to: 6.3.2 20 17 * WC requires at least: 4.6.0 21 * WC tested up to: 8. 3.122 * PHP tested up to: 8.2.1 218 * WC tested up to: 8.2.0 19 * PHP tested up to: 8.2.11 23 20 */ 24 21 25 22 namespace Artiosmedia\WC_Product_Code; 26 23 27 define( 'PRODUCT_CODE_URL', plugins_url( '', __FILE__ ));28 define( 'PRODUCT_CODE_PATH', plugin_dir_path( __FILE__ ));29 define( 'PRODUCT_CODE_FIELD_NAME', '_product_code');30 define( 'PRODUCT_CODE_FIELD_NAME_SECOND', '_product_code_second');24 define('PRODUCT_CODE_URL', plugins_url('', __FILE__)); 25 define('PRODUCT_CODE_PATH', plugin_dir_path(__FILE__)); 26 define('PRODUCT_CODE_FIELD_NAME', '_product_code'); 27 define('PRODUCT_CODE_FIELD_NAME_SECOND', '_product_code_second'); 31 28 32 define( 'PRODUCT_CODE_TEMPLATE_PATH', __DIR__ . '/templates');33 define( 'PRODUCT_CODE_PAYPAL_ID', 'E7LS2JGFPLTH2');29 define('PRODUCT_CODE_TEMPLATE_PATH', __DIR__ . '/templates'); 30 define('PRODUCT_CODE_PAYPAL_ID', 'E7LS2JGFPLTH2'); 34 31 35 define( 'PRODUCT_CODE_VERSION', '1.4.4');36 define( 'PRODUCT_CODE_DB_VERSION', '1.4.4');32 define('PRODUCT_CODE_VERSION', '1.4.5'); 33 define('PRODUCT_CODE_DB_VERSION', '1.4.5'); 37 34 38 load_plugin_textdomain( 'product-code-for-woocommerce', false, basename( dirname( __FILE__ ) ) . '/languages');35 load_plugin_textdomain('product-code-for-woocommerce', false, basename(dirname(__FILE__)) . '/languages'); 39 36 40 require_once( __DIR__ . '/vendor/autoload.php');37 require_once(__DIR__ . '/vendor/autoload.php'); 41 38 42 if ( ! class_exists( 'PCFW_Services' )) {43 include( PRODUCT_CODE_PATH . 'classes/class-pcfw-services.php');39 if (!class_exists('PCFW_Services')) { 40 include(PRODUCT_CODE_PATH . 'classes/class-pcfw-services.php'); 44 41 } 45 42 46 if ( ! class_exists( 'PCFW_Admin_settings' )) {47 include( PRODUCT_CODE_PATH . 'classes/class-pcfw-admin-settings.php');43 if (!class_exists('PCFW_Admin_Settings')) { 44 include(PRODUCT_CODE_PATH . 'classes/class-pcfw-admin-settings.php'); 48 45 } 49 if ( ! class_exists( 'PCFW_wc_export_filter' )) {50 include( PRODUCT_CODE_PATH . 'modules/export/pcfw-export-support.php');46 if (!class_exists('PCFW_Wc_Export_Filter')) { 47 include(PRODUCT_CODE_PATH . 'modules/export/pcfw-export-support.php'); 51 48 } 52 49 53 50 new PCFW_Services(); 54 51 55 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), function( $links) {56 $settings = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=wc-settings&tab=products§ion=product_code_settings' ), __( 'Settings', 'product-code-for-woocommerce' ));52 add_filter('plugin_action_links_' . plugin_basename(__FILE__), function ($links) { 53 $settings = sprintf('<a href="%s">%s</a>', admin_url('admin.php?page=wc-settings&tab=products§ion=product_code_settings'), __('Settings', 'product-code-for-woocommerce')); 57 54 58 array_unshift( $links, $settings);59 return $links;60 } );55 array_unshift($links, $settings); 56 return $links; 57 }); 61 58 62 register_activation_hook( __FILE__, function() {63 // Must Be deleted on other update ,64 delete_option( 'product_code_update');59 register_activation_hook(__FILE__, function () { 60 // Must Be deleted on other update , 61 delete_option('product_code_update'); 65 62 66 $show_product = get_option( 'product_code');67 if ( ! $show_product ) 68 add_option( 'product_code', 'yes');69 add_option( 'product_code_text', 'Product Code' ); 63 $show_product = get_option('product_code'); 64 if (!$show_product) { 65 add_option('product_code', 'yes'); 66 } 70 67 71 update_option( "product_code_notice_dismiss", date( 'Y-m-d', strtotime( '+30 days' ) ) ); 72 } ); 68 add_option('product_code_text', 'Product Code'); 73 69 74 register_deactivation_hook( __FILE__, function() { 75 delete_option( 'product_code' ); 76 } ); 70 update_option('product_code_notice_dismiss', gmdate('Y-m-d', strtotime('+30 days'))); 71 }); 72 73 register_deactivation_hook(__FILE__, function () { 74 delete_option('product_code'); 75 }); 77 76 78 77 add_action('before_woocommerce_init', function () { 79 // Check if the FeaturesUtil class exists in the \Automattic\WooCommerce\Utilities namespace.80 if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) {81 // Declare compatibility with custom order tables using the FeaturesUtil class.82 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true);83 }84 });85 78 // Check if the FeaturesUtil class exists in the \Automattic\WooCommerce\Utilities namespace. 79 if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) { 80 // Declare compatibility with custom order tables using the FeaturesUtil class. 81 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true); 82 } 83 }); 84 86 85 // run on upgrade 87 add_action( 'admin_init', function() {86 add_action('admin_init', function () { 88 87 89 88 90 if ( PRODUCT_CODE_VERSION === "1.0.6" && ( ! $upgrade_db )) {91 update_option( "product_code_notice_dismiss", date( 'Y-m-d', strtotime( '+30 days' ) ));92 update_option( "product_code_update", true);93 }89 if (PRODUCT_CODE_VERSION === '1.0.6' && !$upgrade_db) { 90 update_option('product_code_notice_dismiss', gmdate('Y-m-d', strtotime('+30 days'))); 91 update_option('product_code_update', true); 92 } 94 93 95 if ( PRODUCT_CODE_VERSION === "1.0.7" ) { 96 $product_text = get_option( 'product_code_text' ); 97 if ( ! $product_text ) { 98 update_option( 'product_code_text', 'Product Code' ); 94 if (PRODUCT_CODE_VERSION === '1.0.7') { 95 $product_text = get_option('product_code_text'); 96 if (!$product_text) { 97 update_option('product_code_text', 'Product Code'); 98 } 99 99 } 100 } 101 /* Change the order of code and resolved offset error */ 102 // update the version value 103 $product_code_info = array( 104 'version' => PRODUCT_CODE_VERSION, 105 'db_version' => PRODUCT_CODE_DB_VERSION 106 ); 107 update_site_option( 'product_code_info', $product_code_info ); 108 /* Change the order of code and resolved offset error */ 100 /* Change the order of code and resolved offset error */ 101 // update the version value 102 $product_code_info = array( 103 'version' => PRODUCT_CODE_VERSION, 104 'db_version' => PRODUCT_CODE_DB_VERSION 105 ); 106 update_site_option('product_code_info', $product_code_info); 107 /* Change the order of code and resolved offset error */ 109 108 110 $plugin_options = get_site_option( 'product_code_info' ); 111 $upgrade_db = get_option( "product_code_db_updated" ); 112 113 // Check if postmeta data is changed to the new name. 114 Global $wpdb; 115 $query = "SELECT * from " . $wpdb->prefix . "postmeta WHERE meta_key='_product_code_variant' "; 116 $results = $wpdb->get_results( $query ); 109 $plugin_options = get_site_option('product_code_info'); 110 $upgrade_db = get_option('product_code_db_updated'); 117 111 118 // If plugin version is less then 1.2.0 then upgrade and if not update database after version upgrade still display the notice. 119 if ( ( $plugin_options[ 'version' ] < "1.2.2" && ( ! $upgrade_db ) ) || ( ! empty( $results ) ) ) { 120 add_action( "admin_notices", function() { 121 $url = admin_url( 'admin-ajax.php' ); 122 ?> 123 <div class="warning notice"> 124 <p><?php _e( '<strong>NOTICE! Product Code For WooCommerce</strong> must update your database to modify meta fields. Consider backing up database first.', 'product-code-for-woocommerce' ); ?> <a class="button button-primary" href="<?php echo $url; ?>?action=product_code_update_database" target="_blank"><?php _e( 'Update Now', 'product-code-for-woocommerce' ); ?></a></p> 125 </div> 126 <?php 127 } ); 128 } 129 } ); 112 // Check if postmeta data is changed to the new name. 113 global $wpdb; 114 $results = $wpdb->get_results("SELECT * from {$wpdb->prefix}postmeta WHERE meta_key='_product_code_variant'"); 115 116 // If plugin version is less then 1.2.0 then upgrade and if not update database after version upgrade still display the notice. 117 if (( $plugin_options['version'] < '1.2.2' && !$upgrade_db ) || !empty($results)) { 118 add_action('admin_notices', function () { 119 $url = admin_url('admin-ajax.php'); 120 $notice_text = __('<strong>NOTICE! Product Code For WooCommerce</strong> must update your database to modify meta fields. Consider backing up database first.', 'product-code-for-woocommerce'); 121 ?> 122 <div class="warning notice"> 123 <p><?php echo wp_kses_post($notice_text); ?> <a class="button button-primary" href="<?php echo esc_url($url); ?>?action=product_code_update_database" target="_blank"><?php esc_html_e('Update Now', 'product-code-for-woocommerce'); ?></a></p> 124 </div> 125 <?php 126 }); 127 } 128 }); 130 129 131 130 // Include files for search 132 add_filter( 'init', function() { 133 include_once PRODUCT_CODE_PATH . 'modules/search/pcfw-filter-search.php'; 134 include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 135 if ( ! is_admin() && is_plugin_active( 'relevanssi/relevanssi.php' ) || ! function_exists( 'wc_clean' ) ) { 136 include_once PRODUCT_CODE_PATH . 'modules/search/pcfw-relevanssi-product-code-search.php'; 137 } else 138 if ( ! is_admin() && is_plugin_active( 'searchwp/searchwp.php' ) && is_plugin_active( 'searchwp-woocommerce/searchwp-woocommerce.php' ) ) { 139 include_once PRODUCT_CODE_PATH . 'modules/search/pcfw-searchwp-product-code-search.php'; 140 } else { 141 include_once PRODUCT_CODE_PATH . 'modules/search/pcfw-product-code-search.php'; 142 } 143 }, 11 ); 131 add_filter('init', function () { 132 include_once PRODUCT_CODE_PATH . 'modules/search/pcfw-filter-search.php'; 133 include_once(ABSPATH . 'wp-admin/includes/plugin.php'); 134 if (!is_admin() && is_plugin_active('relevanssi/relevanssi.php') || !function_exists('wc_clean')) { 135 include_once PRODUCT_CODE_PATH . 'modules/search/pcfw-relevanssi-product-code-search.php'; 136 } else if (!is_admin() && is_plugin_active('searchwp/searchwp.php') && is_plugin_active('searchwp-woocommerce/searchwp-woocommerce.php')) { 137 include_once PRODUCT_CODE_PATH . 'modules/search/pcfw-searchwp-product-code-search.php'; 138 } else { 139 include_once PRODUCT_CODE_PATH . 'modules/search/pcfw-product-code-search.php'; 140 } 141 }, 11); 144 142 145 143 146 add_action('save_post', function($post_id, $post){147 if ($post->post_type != 'product'){148 return;149 }150 $product = wc_get_product($post_id);151 $type = $product->get_type();152 global $post;153 if($type == "variable"){154 $variations = $product->get_available_variations();155 $variations_id = wp_list_pluck( $variations, 'variation_id');156 delete_post_meta($post_id,'_product_code');157 foreach($variations_id as $var){158 $ProductCode = get_post_meta($var,"_product_code",true);159 add_post_meta($post_id, '_product_code', $ProductCode);160 }161 }144 add_action('save_post', function ($post_id, $post) { 145 if ('product' != $post->post_type) { 146 return; 147 } 148 $product = wc_get_product($post_id); 149 $type = $product->get_type(); 150 global $post; 151 if ('variable' == $type) { 152 $variations = $product->get_available_variations(); 153 $variations_id = wp_list_pluck($variations, 'variation_id'); 154 delete_post_meta($post_id, '_product_code'); 155 foreach ($variations_id as $var) { 156 $ProductCode = get_post_meta($var, '_product_code', true); 157 add_post_meta($post_id, '_product_code', $ProductCode); 158 } 159 } 162 160 }, 10, 2); 163 164 -
product-code-for-woocommerce/trunk/readme.txt
r3000925 r3004043 6 6 Requires at least: 4.6 7 7 Tested up to: 6.4.1 8 Version: 1.4. 49 Stable tag: 1.4. 48 Version: 1.4.5 9 Stable tag: 1.4.5 10 10 Requires PHP: 7.4.33 11 11 License: GPLv3 or later license and included … … 32 32 As of <strong>version 1.4.1</strong>, an administrator can choose to hide the default and secondary product code from the user-side product posts while the other display injections still work (checkout, cart, and receipts). 33 33 34 As of <strong>version 1.4.5</strong>, shortcodes have changed to solve a vulnerability found by PatchStack, where the new shortcodes are...". 35 34 36 == Installation == 35 37 … … 38 40 3. Enter the Product Code under the SKU from either Variable or Simple products. 39 41 40 == Technical Details for Release 1.4. 4==42 == Technical Details for Release 1.4.5 == 41 43 42 44 Load time: 0.279 s; Memory usage: 3.61 MiB … … 135 137 136 138 == Changelog == 139 140 1.4.5 11/30/23 141 - Fixed Cross Site Scripting (XSS) vulnerability 142 - Add whitelist check for the wrapper tag 137 143 138 144 1.4.4 11/23/23 -
product-code-for-woocommerce/trunk/templates/product-meta-row.php
r2967261 r3004043 15 15 ?> 16 16 17 <?php if ( $hide_product_code == 'no' && ($value || (get_option('product_code_hide_empty_field') != 'yes' && !$value) || $product_type == "variable")) : ?>18 <span class="wo_productcode">19 <input type="hidden" value="<?php echo $post->ID?>" id="product_id" />20 <span><?php echo ($text ? $text : __('Product Code', 'product-code-for-woocommerce'))?>:</span>21 <span class="stl_codenum"><?php echo !$value ? __('N/A', 'product-code-for-woocommerce') : $value?></span>22 </span>17 <?php if ('no' == $hide_product_code && ( $value || ( 'yes' != get_option('product_code_hide_empty_field') && !$value ) || 'variable' == $product_type )) : ?> 18 <span class="wo_productcode"> 19 <input type="hidden" value="<?php echo absint($post->ID); ?>" id="product_id" /> 20 <span><?php echo esc_html($text ? $text : __('Product Code', 'product-code-for-woocommerce')); ?>:</span> 21 <span class="stl_codenum"><?php echo esc_html(!$value ? __('N/A', 'product-code-for-woocommerce') : $value); ?></span> 22 </span> 23 23 <?php endif; ?> 24 24 25 25 <?php 26 if ($hide_second_product_code == 'no' && get_option('product_code_second') == 'yes') { 27 if ($value_second || (get_option('product_code_hide_empty_field') != 'yes' && !$value_second) || $product_type == "variable") : ?> 28 <span class="wo_productcode_second"> 29 <input type="hidden" value="<?php echo $post->ID ?>" id="product_id_second" /> 30 <span><?php echo ($text_second ? $text_second : __('Product Code', 'product-code-for-woocommerce')) ?>:</span> 31 <span class="stl_codenum_second"><?php echo !$value_second ? __('N/A', 'product-code-for-woocommerce') : $value_second ?></span> 32 </span> 33 <?php endif; ?> 26 if ('no' == $hide_second_product_code && 'yes' == get_option('product_code_second')) { 27 if ($value_second || ( 'yes' != get_option('product_code_hide_empty_field') && !$value_second ) || 'variable' == $product_type) : 28 ?> 29 <span class="wo_productcode_second"> 30 <input type="hidden" value="<?php echo absint($post->ID); ?>" id="product_id_second" /> 31 <span><?php echo esc_html($text_second ? $text_second : __('Product Code', 'product-code-for-woocommerce')); ?>:</span> 32 <span class="stl_codenum_second"><?php echo esc_html(!$value_second ? __('N/A', 'product-code-for-woocommerce') : $value_second); ?></span> 33 </span> 34 <?php endif; ?> 34 35 <?php } ?> -
product-code-for-woocommerce/trunk/templates/quick-edit-text-field.php
r2588140 r3004043 12 12 <div style="clear:both;"></div> 13 13 <label class="product_code"> 14 <span class="title"><?php 15 _e('Product Code','product-code-for-woocommerce') 16 17 ?></span> 14 <span class="title"><?php esc_html_e('Product Code', 'product-code-for-woocommerce'); ?></span> 18 15 <span class="input-text-wrap"> 19 <input type="text" name="<?php 20 echo $field_name 21 22 ?>" class="text" placeholder="<?php 23 _e('Product Code','product-code-for-woocommerce') 24 25 ?>" value="<?php 26 echo $code 27 28 ?>" /> 16 <input type="text" 17 name="<?php echo esc_attr($field_name); ?>" class="text" 18 placeholder="<?php esc_attr_e('Product Code', 'product-code-for-woocommerce'); ?>" 19 value="<?php echo esc_attr($code); ?>" 20 /> 29 21 </span> 30 22 </label> -
product-code-for-woocommerce/trunk/templates/variation-field.php
r2967261 r3004043 12 12 <div class="form-row form-row-first"> 13 13 14 <?php14 <?php 15 15 16 $label = $this->get_field_title_text();17 $label_second = $this->get_second_field_title_text();16 $label = $this->get_field_title_text(); 17 $label_second = $this->get_second_field_title_text(); 18 18 19 woocommerce_wp_text_input([ 20 'id' => sprintf('%s_%d', $field_name, $i), 21 'label' => $label, 22 'desc_tip' => true, 23 'description' => sprintf(__('%s refers to a company’s unique internal product identifier, needed for online product fulfillment.', 'product-code-for-woocommerce'), $label), 24 'value' => $code, 25 ]); 19 woocommerce_wp_text_input([ 20 'id' => sprintf('%s_%d', $field_name, $i), 21 'label' => $label, 22 'desc_tip' => true, 23 'description' => sprintf( 24 /* translators: 1 for label */ 25 __('%s refers to a company’s unique internal product identifier, needed for online product fulfillment.', 'product-code-for-woocommerce'), 26 $label 27 ), 28 'value' => $code, 29 ]); 26 30 27 if ($displaySecond == 'yes') { 28 woocommerce_wp_text_input([ 29 'id' => sprintf('%s_%d', $field_name_second, $i), 30 'label' => $label_second, 31 'desc_tip' => true, 32 'description' => sprintf(__('%s refers to a company’s unique internal product identifier, needed for online product fulfillment.', 'product-code-for-woocommerce'), $label_second), 33 'value' => $code_second, 34 ]); 35 } 31 if ('yes' == $displaySecond) { 32 woocommerce_wp_text_input([ 33 'id' => sprintf('%s_%d', $field_name_second, $i), 34 'label' => $label_second, 35 'desc_tip' => true, 36 'description' => sprintf( 37 /* translators: 1 for label */ 38 __('%s refers to a company’s unique internal product identifier, needed for online product fulfillment.', 'product-code-for-woocommerce'), 39 $label_second 40 ), 41 'value' => $code_second, 42 ]); 43 } 36 44 37 ?> 38 <!-- <label for="product_code_<?php 39 echo $variation->ID 40 41 ?>"> 42 <strong> 43 <?php 44 echo $label; 45 46 ?> 47 </strong> 48 </label> 49 <input type="text" value="<?php 50 echo $code 51 52 ?>" name="<?php 53 echo $field_name 54 55 ?>" id="product_code_<?php 56 echo $variation->ID 57 58 ?>" /> --> 45 ?> 59 46 </div> 60 47 <div style="clear:both;"></div> -
product-code-for-woocommerce/trunk/templates/wc-text-input.php
r2588140 r3004043 9 9 */ 10 10 11 woocommerce_wp_text_input(['id' => $c('id'),'label' => $c('label'),'desc_tip' => 12 $c('desc_tip'),'description' => $c('description'),'value' => $c('value'),]); 11 woocommerce_wp_text_input(['id' => $c('id'),'label' => $c('label'),'desc_tip' => $c('desc_tip'),'description' => $c('description'),'value' => $c('value'),]);
Note: See TracChangeset
for help on using the changeset viewer.