Changeset 3277147
- Timestamp:
- 04/19/2025 10:53:43 AM (10 months ago)
- Location:
- administrator-z/trunk
- Files:
-
- 1 added
- 8 edited
-
administrator-z.php (modified) (2 diffs)
-
assets/js/adminz.js (modified) (1 diff)
-
includes/shortcodes/flatsome-slider.php (modified) (1 diff)
-
src/Controller/AdministratorZ.php (modified) (2 diffs)
-
src/Controller/Flatsome.php (modified) (1 diff)
-
src/Controller/Wordpress.php (modified) (5 diffs)
-
src/Helper/Page.php (added)
-
src/Helper/WoocommerceOrderItem.php (modified) (4 diffs)
-
vendor/quyle91/wp-database-helper/src/WpDatabase.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
administrator-z/trunk/administrator-z.php
r3273833 r3277147 7 7 * Author: quyle91 8 8 * Author URI: http://quyle91.github.io 9 * Version: 2025.04.1 69 * Version: 2025.04.19 10 10 * License: GPL2 11 11 * Text Domain: administrator-z … … 41 41 42 42 define('ADMINZ', true); 43 define('ADMINZ_VERSION', '2025.04.1 6');43 define('ADMINZ_VERSION', '2025.04.19'); 44 44 define('ADMINZ_DATA_VERSION', 1); 45 45 define('ADMINZ_FILE', __FILE__); -
administrator-z/trunk/assets/js/adminz.js
r3267405 r3277147 672 672 toggle_setup = (element) => { 673 673 element.onclick = () => { 674 console.log(element); 674 675 // single structure 675 676 const target = element.getAttribute('data-target'); -
administrator-z/trunk/includes/shortcodes/flatsome-slider.php
r3251526 r3277147 464 464 465 465 #<?php echo esc_attr( $_id ); ?> .slider img{ 466 width: unset;466 width: 100%; 467 467 } 468 468 -
administrator-z/trunk/src/Controller/AdministratorZ.php
r3271332 r3277147 61 61 function () { 62 62 $list = [ 63 'Page - Preload images', 63 64 'Flatsome - Active on anchor link', 64 65 'Woocommerce - Checkout field validate', … … 71 72 'Wordpress menu toggle button', 72 73 'Flatsome element: ACF', 73 'Tools/ Request logs',74 'Tools/ Email logs - move from mailer',75 'Wpcf7/ Thankyou',76 'Tools/ Server tools',77 'Wordpress/ Login footer text',78 'Flatsome/ Slider auto free scroll',79 'Wordpress/ Quiz login',80 74 ]; 81 75 -
administrator-z/trunk/src/Controller/Flatsome.php
r3273833 r3277147 493 493 'is-smaller', 494 494 'is-xsmall', 495 'is-xxsmall' 495 'is-xxsmall', 496 'heading-font' 496 497 ]; 497 498 -
administrator-z/trunk/src/Controller/Wordpress.php
r3271332 r3277147 174 174 if ($this->settings['add_toggle_button'] ?? "") { 175 175 adminz_add_admin_body_class('adminz_menus_toggle_button'); 176 } 177 178 // 179 if (($this->settings['enable_preload_images'] ?? "") == 'on') { 180 $a = new \Adminz\Helper\Page(); 181 $a->setup_preload_img(); 176 182 } 177 183 … … 677 683 ); 678 684 685 // add section 686 add_settings_section( 687 'adminz_pages', 688 'Pages', 689 function () { 690 // 691 }, 692 $this->id 693 ); 694 695 // field 696 add_settings_field( 697 wp_rand(), 698 'Preload images', 699 function () { 700 // field 701 echo adminz_field([ 702 'field' => 'input', 703 'attribute' => [ 704 'type' => 'checkbox', 705 'name' => $this->option_name . '[enable_preload_images]', 706 ], 707 'value' => $this->settings['enable_preload_images'] ?? "", 708 ]); 709 }, 710 $this->id, 711 'adminz_pages' 712 ); 713 679 714 680 715 // add section … … 765 800 ); 766 801 767 768 769 802 // add section 770 803 add_settings_section( 771 804 'adminz_posttype', 772 'Post types admin ',805 'Post types admin column', 773 806 function () { 774 807 }, … … 862 895 add_settings_section( 863 896 'adminz_term_taxonomy', 864 'Term Taxonomies ',897 'Term Taxonomies admin column', 865 898 function () { 866 899 }, … … 981 1014 add_settings_section( 982 1015 'adminz_wordpress_content', 983 'Content ',1016 'Content Replace', 984 1017 function () { 985 1018 }, -
administrator-z/trunk/src/Helper/WoocommerceOrderItem.php
r3267405 r3277147 1 1 <?php 2 // Chỉ nên copy file này vì chưa finish 2 3 // hỗ trợ cho việc truyền từ $_POST vào cart item data, order item meta, và email 3 4 // chỉ áp dụng cho 1 key/ 1 label, với số nhiều thì gọi nhiều lần. 4 5 // Meta data sẽ được giữ nguyên khi recalculate order 6 // js mẫu và function custom item price ko hỗ trợ, tham khảo code ở ví dụ 5 7 6 8 namespace Adminz\Helper; 7 9 8 10 class WoocommerceOrderItem { 11 12 const VERSION = '16.04.2025'; 9 13 10 14 public $item_label; … … 75 79 function raw_woocommerce_checkout_create_order_line_item() { 76 80 add_action('woocommerce_checkout_create_order_line_item', function ($item, $cart_item_key, $values, $order) { 77 if ($this->item_label) { 78 $value = $values[$this->item_key]; 79 // $value bắt buộc phải có giá trị thì mới dc đưa vào order 80 // và phải xử lý từ bước cart 81 $item->add_meta_data( 82 $this->item_key, 83 $value 84 ); 85 } 81 $value = $values[$this->item_key]; 82 // $value bắt buộc phải có giá trị thì mới dc đưa vào order 83 // và phải xử lý từ bước cart 84 $item->add_meta_data( 85 $this->item_key, 86 $value 87 ); 86 88 }, 10, 4); 89 } 90 91 function is_edit_order_admin() { 92 // Kiểm tra nếu đang ở màn hình edit order (HPOS hoặc classic) thì bỏ qua 93 if (is_admin() && function_exists('get_current_screen')) { 94 $screen = get_current_screen(); 95 if ($screen && ($screen->id === 'shop_order' || $screen->id === 'woocommerce_page_wc-orders')) { 96 return true; 97 } 98 } 99 } 100 101 // display: Hiển thị data trong trang admin (mục chi tiết order), định dạng key và value để dễ đọc. 102 function is_send_order_admin() { 103 if (is_admin() and ($_POST['wc_order_action'] ?? '')) { 104 return true; 105 } 87 106 } 88 107 … … 90 109 function display_woocommerce_order_item_display_meta_key() { 91 110 92 add_filter('woocommerce_order_item_display_meta_value', function ($value, $meta, $item) { 111 // ẩn đi những item ko có label 112 add_filter('woocommerce_order_item_get_formatted_meta_data', function ($formatted_meta, $order_item) { 113 114 // 115 if ($this->is_edit_order_admin() and !$this->is_send_order_admin()) { 116 return $formatted_meta; 117 } 118 119 foreach ((array)$formatted_meta as $key => $item) { 120 if ($this->item_key === $item->key and $this->item_label === '') { 121 unset($formatted_meta[$key]); 122 } 123 } 124 return $formatted_meta; 125 }, 10, 2); 126 127 // cột trái 128 add_filter('woocommerce_order_item_display_meta_key', function ($return, $meta, $item) { 93 129 if ($meta->key === $this->item_key) { 94 return apply_filters( 95 'WoocommerceOrderItem_display', 96 $value, 97 $this->item_key, 98 $item 99 ); 100 } 101 return $value; 130 $return = $this->item_label; 131 132 // 133 if ($this->is_edit_order_admin()) { 134 if (!$return) { 135 $return = $this->item_key; 136 return $return; 137 } 138 } 139 } 140 return $return; 102 141 }, 10, 3); 103 142 104 add_filter('woocommerce_order_item_display_meta_key', function ($display_key, $meta, $item) { 143 // cột phải 144 add_filter('woocommerce_order_item_display_meta_value', function ($return, $meta, $item) { 105 145 if ($meta->key === $this->item_key) { 106 $display_key = $this->item_label; 107 } 108 return $display_key; 146 if ($this->item_label) { 147 return apply_filters( 148 'WoocommerceOrderItem_display', 149 $return, 150 $this->item_key, 151 $item 152 ); 153 } else { 154 // keep default 155 } 156 } 157 return $return; 109 158 }, 10, 3); 110 159 } … … 170 219 } 171 220 172 173 // $a = new \Adminz\Helper\WoocommerceOrderItem; 174 // $a->item_label = $label; 175 // $a->item_key = $key; 176 // $a->init(); 221 /** ------- Khai báo ------------ */ 222 // add_action('init', function () { 223 224 // $list = [ 225 // // key => label 226 // 'property' => 'Property', 227 // 'property_1' => 'Property 1', 228 // 'property_2' => 'Property 2', 229 // ]; 230 231 // foreach ((array)$list as $key => $value) { 232 // $a = new \WCP\Helper\WoocommerceOrderItem; 233 // $a->item_label = $value; 234 // $a->item_key = $key; 235 // $a->init(); 236 // } 237 238 // add_filter('WoocommerceOrderItem_raw', function ($value, $key, $item) use ($list) { 239 // if (in_array($key, array_keys($list)) and $key == 'property') { 240 // return $value . ' Custom raw'; 241 // } 242 // return $value; 243 // }, 10, 3); 244 245 // add_filter('WoocommerceOrderItem_display', function ($value, $key, $item) use ($list) { 246 // if (in_array($key, array_keys($list)) and $key == 'property') { 247 // return $value . ' Custom diplay'; 248 // } 249 // return $value; 250 // }, 10, 3); 251 // }); 252 253 /** ------- hook để custom item price trong cart ------------ */ 254 // add_action('woocommerce_before_calculate_totals', function ($cart) { 255 // if (is_admin() && !defined('DOING_AJAX')) { 256 // return; 257 // } 258 // foreach ($cart->get_cart() as $cart_item_key => $cart_item) { 259 // $product = $cart_item['data']; 260 // $price = 100; // custom item price 261 // if ($price) { 262 // $product->set_price($price); 263 // } 264 // } 265 // }); 266 267 /** ------- hook để custom item price trong reculcale order ------------ */ 268 // add_action('woocommerce_order_before_calculate_totals', function ($and_taxes, $order) { 269 // foreach ($order->get_items() as $item) { 270 // // Chỉ xử lý với line item 271 // if (!$item->is_type('line_item')) { 272 // continue; 273 // } 274 275 // $original_subtotal = $item->get_subtotal(); 276 // $original_total = $item->get_total(); 277 // $discount = $original_subtotal - $original_total; 278 279 // $_check_price = 100; 280 // $new_subtotal = $_check_price; 281 282 // // Tính toán total mới 283 // $new_total = $new_subtotal - $discount; 284 285 // // Đảm bảo total không âm 286 // if ($new_total < 0) { 287 // $new_total = 0; 288 // // Có thể điều chỉnh discount ở đây nếu cần 289 // $discount = $new_subtotal; // Discount tối đa = subtotal 290 // } 291 292 // // Cập nhật giá trị 293 // $item->set_subtotal($new_subtotal); 294 // $item->set_total($new_total); 295 // } 296 297 // // Tính lại thuế nếu cần 298 // if ($and_taxes) { 299 // $order->calculate_taxes(); 300 // } 301 // }, 10, 2); 302 303 /** ------- Script chuẩn để add item vào cart với formData ------------ */ 304 // <script type="text/javascript"> 305 // document.addEventListener('DOMContentLoaded', () => { 306 // const button = e.currentTarget; 307 // if ('undefined' === typeof wc_add_to_cart_params) { 308 // return false; 309 // } 310 // jQuery(button).addClass('processing'); 311 // const formData = this.getFormData(); // form.serialize() 312 // jQuery.post( 313 // wc_add_to_cart_params.wc_ajax_url.toString().replace('%%endpoint%%', 'add_to_cart'), formData, 314 // function(response) { 315 // jQuery(button).removeClass('processing'); 316 // if (!response) { 317 // return; 318 // } 319 // if (response.error && response.product_url) { 320 // window.location = response.product_url; 321 // return; 322 // } 323 // if ('yes' === wc_add_to_cart_params.cart_redirect_after_add) { 324 // window.location = wc_add_to_cart_params.cart_url; 325 // return; 326 // } 327 // jQuery(document.body).trigger('added_to_cart', [response.fragments, response.cart_hash]); 328 // } 329 // ); 330 // }); 331 // </script> -
administrator-z/trunk/vendor/quyle91/wp-database-helper/src/WpDatabase.php
r3271332 r3277147 195 195 // add new 196 196 if (isset($_POST['add_record_' . $this->table_name])) { 197 if (wp_verify_nonce($_POST['nonce'], $this->table_name)) {197 if (wp_verify_nonce($_POST['nonce'], $this->table_name)) { 198 198 $_post = array_filter($_POST); 199 199 $this->insert($_post); … … 204 204 205 205 // search 206 if (isset($_GET['search_' . $this->table_name])) {207 $this->query_args['where_conditions'] = 'like';208 }206 // if (isset($_GET['search_' . $this->table_name])) { 207 // $this->query_args['where_conditions'] = 'like'; 208 // } 209 209 210 210 // delete … … 231 231 'posts_per_page' => (int) ($_GET['posts_per_page'] ?? 100), 232 232 'paged' => (int) ($_GET['paged'] ?? 1), 233 'where_conditions' => $_GET['where_conditions'] ?? '=' 233 234 ]; 234 235 … … 251 252 // parse with $args 252 253 $this->query_args = wp_parse_args($args, $defaults); 254 // echo "<pre>"; print_r($this->query_args); echo "</pre>"; 255 // die; 253 256 return $this->query_args; 254 257 } … … 315 318 break; 316 319 320 case '=': 321 $tmp = "$field = '$value'"; 322 break; 323 317 324 default: 318 325 $tmp = "$field = '$value'"; 319 326 break; 320 327 } 328 // echo "<pre>"; print_r($tmp); echo "</pre>"; die; 321 329 $where[] = $tmp; 322 330 } … … 702 710 $id = wp_rand(); 703 711 $field_name = esc_attr($value['name']); 704 $field_value = esc_textarea( $_GET[$field_name] ?? "");712 $field_value = esc_textarea(stripslashes($_GET[$field_name] ?? "")); 705 713 $fields_html .= <<<HTML 706 714 <div class="per_page item"> … … 731 739 <input type="hidden" name="page" value="{$menu_slug}"> 732 740 <input type="hidden" name="{$search_key}"> 741 <input type="hidden" name="where_conditions" value="like"> 733 742 <div class="form_wrap"> 734 743 {$fields_html}
Note: See TracChangeset
for help on using the changeset viewer.