Blog cá nhân
Bài viết mới nhất
Chia sẻ kinh nghiệm thực tế về WordPress, lập trình và phát triển web.
Trang 3 / 12 — 105 bài viết
Reset 1 câu lệnh trong git
### Reset 1 câu lệnh trong git ### git reset –hard commit-id git push –force origin <branch_name>
Query only seach by title
Hook only seach by title in page seach function wpse_11826_search_by_title( $search, $wp_query ) { if ( ! empty( $search ) && ! empty( $wp_query->query_vars[‘search_terms’] ) ) { global $wpdb; $q = $wp_query->query_vars; $n = ! empty( $q[‘exact’] ) ? ” : ‘%’; $search = array(); foreach ( ( array ) $q[‘search_terms’] as $term ) $search[] […]
Hướng dẫn tạo form có validate, upload file nhiều bước và xử lý ajax
B1: Đăng ký thư viện trong admin WordPress function tmdev_add_style_scripts() { $js_list_an_item_ver = date(“ymd-Gis”, filemtime( get_template_directory(). ‘/assets/js/list-an-item.js’ )); $assets_path = get_template_directory_uri(); wp_enqueue_script(‘jquery-validation’, $assets_path.’/assets/js/jquery.validate.min.js’, array(‘jquery’)); wp_enqueue_script(‘product-submit’, $assets_path.’/assets/js/list-an-item.js’, array(‘jquery’, ‘custom-script’), $js_list_an_item_ver ); wp_enqueue_style( ‘product-submit’, $assets_path.’/assets/css/product-submit.css’, ”, 123 ); } add_action( ‘wp_enqueue_scripts’, ‘tmdev_add_style_scripts’ ); B2: Tạo form và xử lý validate ở ngoài Frontend <div id=”product-submission-form”> <div class=”step-buttons”> […]
Các lỗ hổng phổ biến của WordPress và cách phòng ngừa thông qua các biện pháp thực hành tốt nhất về mã hóa an toàn
Một số lỗ hổng bảo mật liên quan đến việc hook tới các hook của admin hay lỗ hổng ko kiểm tra quyền khi upload… Common-WordPress-Vulnerabilities-and-Prevention-Through-Secure-Coding-Best-Practices Nguồn: https://www.wordfence.com/blog/2021/07/common-wordpress-vulnerabilities-and-prevention-through-secure-coding-best-practices/
Trang tổng hợp một số thư viện Javascript, Awesome JavaScript libraries
Một bộ sưu tập các thư viện, tài nguyên và so sánh giữa các thư viện JavaScript: https://js.libhunt.com/ để từ đó bạn quyết định nên chọn thư viện nào Vd: So sánh các thư viện slider:
Làm mượt Animate On Scroll Library AOS
Để custom effect animation của AOS, bạn cần điều chỉnh thẻ css sau: [data-aos][data-aos][data-aos-duration=”1000″], body[data-aos-duration=”1000″] [data-aos]{ animation-timing-function: linear(0, 0.0027, 0.0106 7.29%, 0.0425, 0.0957, 0.1701 29.16%, 0.2477, 0.3401 41.23%, 0.5982 55.18%, 0.7044 61.56%, 0.7987, 0.875 75%, 0.9297, 0.9687, 0.9922, 1) animation-duration: 1.25s; } trong đó có phần animation-timing-function bạn có thể thay thế bằng các hiệu […]
WooCommerce: Lấy thông tin sản phẩm (ID, SKU…) từ $product Object
Bạn cần lấy tất cả các thông liên quan đến sản phẩm: ID, sku, hình ảnh, product meta… Nếu bạn đang ở trang chi tiết sản phẩm thì bạn chỉ cần sử dụng trực tiếp các hàm của object $product bên dưới. Tuy nhiên nếu bạn không ở trong trang chi tiết và bạn đã […]
Cách lấy Page ID một số trang mặc định trong WooCommerce: shop, cart, checkout…
Cách lấy page id một số trang mặc định trong WooCommerce như: trang cửa hàng (shop), giỏ hàng (cart), thanh toán (checkout), đặt hàng thành công (thank you)… // Get The Page ID You Need get_option( ‘woocommerce_shop_page_id’ ); get_option( ‘woocommerce_cart_page_id’ ); get_option( ‘woocommerce_checkout_page_id’ ); get_option( ‘woocommerce_pay_page_id’ ); get_option( ‘woocommerce_thanks_page_id’ ); get_option( ‘woocommerce_myaccount_page_id’ ); get_option( ‘woocommerce_edit_address_page_id’ […]
Sắp xếp bài viết theo ID cho sẵn trong WooCommerce
Để hiển thị và sắp xếp bài viết theo danh sách $id cho sẵn: <?php $args = array( ‘post_type’ => ‘product’, ‘post__in’ => $id, ‘orderby’ => ‘post__in’ ); $loop = new WP_Query( $args ); ?> Khi đó câu SQL sẽ như sau: SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.ID IN (1236,1165,1187,1260,1247,1181,1219,1249) AND (wp_posts.post_type […]