PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.19
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.19
1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 All 164 releases
woocommerce-pos / includes / Admin / Products / templates / quick-edit-visibility-select.php

quick-edit-visibility-select.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.19, at includes/Admin/Products/templates/quick-edit-visibility-select.php

75 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Admin View: Quick Edit Product.
4 *
5 * @package WCPOS\WooCommercePOS
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 /**
13 * Quick edit visibility select template.
14 *
15 * @var array $options
16 */
17 ?>
18
19 <fieldset class="inline-edit-col-left">
20 <div class="inline-edit-col">
21 <div class="inline-edit-group">
22 <label class="inline-edit-status alignleft">
23 <span class="title"><?php /* translators: Product POS visibility or barcode label in WooCommerce admin. */ esc_html_e( 'POS visibility', 'woocommerce-pos' ); ?></span>
24 <select name="_pos_visibility">
25 <?php
26 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template variables.
27 foreach ( $options as $name => $label ) {
28 echo '<option value="' . esc_attr( $name ) . '">' . esc_html( $label ) . '</option>';
29 }
30 ?>
31 </select>
32 </label>
33 </div>
34 </div>
35 <script>
36 document.addEventListener('DOMContentLoaded', function() {
37 // we create a copy of the WP inline edit post function
38 const wp_inline_edit = window.inlineEditPost.edit;
39
40 // and then we overwrite the function with our own code
41 window.inlineEditPost.edit = function (id) {
42 // "call" the original WP edit function
43 // we don't want to leave WordPress hanging
44 wp_inline_edit.apply(this, arguments);
45
46 // now we take care of our business
47
48 // get the post ID
49 let post_id = 0;
50 if (typeof id === 'object') {
51 post_id = parseInt(this.getId(id), 10);
52 }
53
54 if (post_id > 0) {
55 // define the edit row
56 const edit_row = document.getElementById('edit-' + post_id);
57
58 // get the data
59 let val = '';
60 let elem = document.getElementById('woocommerce_pos_inline_' + post_id);
61 if (elem) {
62 val = elem.dataset.visibility;
63 }
64
65 // populate the data
66 const select = edit_row.querySelector('select[name="_pos_visibility"]');
67 if (select) {
68 select.value = val;
69 }
70 }
71 };
72 });
73 </script>
74 </fieldset>
75