Chuyên mục
Tài liệu WordPres
6 bài viết
Một số tính năng hay trong quản trị WordPress mọi người nên biết
Trong bài viết này mình sẽ chia sẻ một số tính năng hay trong quản trị WordPress mà một số bạn mới sử dụng WordPress chưa biết. Bật tắt nhanh thanh công cụ (admin bar) Thanh admin bar là gì? Khi bạn đăng nhập vào quản trị website WordPress sẽ xuất hiện một thanh công […]
Hướng dẫn dịch và tạo biến dịch trong theme WordPress
https://developer.wordpress.org/themes/functionality/internationalization/
Một số hàm định dạng chuỗi thông dụng
addslashes: – Hàm này sẽ thêm dấu gách chéo trước những ký tự (‘, “, \) trong chuỗi – Thường được sử dụng tránh việc gây lỗi cấu trúc của chuỗi $string = 'Tôi đang sử dụng nhiều dấu "nháy kép" trong chuỗi '; echo addslashes($string); // Output: Tôi đang sử dụng nhiều dấu \"nháy […]
Kiểm tra và So sánh phiên bản WordPress
version_compare(get_bloginfo('version'),'4.5', '>=') Ví dụ: Kiểm tra phiên bản wp của bạn để thực hiện hàm lấy tất cả các term theo taxonomy trong WordPress function tm_get_all_cats_post( $taxonomy ){ $list_terms = array(); if(version_compare(get_bloginfo('version'),'4.5', '>=') ){ $list_terms = get_terms( array( 'taxonomy' => $taxonomy, 'orderby' => 'parent', 'hide_empty' => false, ) ); }else{ $list_terms = get_terms( $taxonomy, array( […]
Hướng dẫn lấy tỉ giá từ api ngân hàng Vietcombank
API tỉ giá của Vietcombank: https://portal.vietcombank.com.vn/Usercontrols/TVPortal.TyGia/pXML.aspx?b=10 => đây là file api xuất ra dữ liệu xml Hàm đọc api_xml function getSslPage($url) { $ch = curl_init(); $headr = array(); curl_setopt($ch, CURLOPT_HTTPHEADER, $headr); curl_setopt($ch, CURLOPT_URL, $url ); // get the url contents curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch,CURLOPT_USERAGENT,'spider'); $data = curl_exec($ch); // execute […]
Xác định đường dẫn trong plugin, theme trong WordPress
Trong WordPress có rất nhiều hàm để lấy đường dẫn tới: Plugin, Theme, WordPress. Plugin __FILE__ // /home/huynhtan/public_html/wp-content/plugins/wp-payroll/wp-payroll.php __DIR__ // /home/huynhtan/public_html/wp-content/plugins/wp-payroll plugins_url(); // https: //huynhtanmao.com/wp-content/plugin plugins_url($path, $file); ex: plugins_url(‘css/style.css’,__FILE__) ; // huynhtanmao.com/wp-content/plugin/your-plugin/css/style.css plugin_dir_url($file); ex: plugins_dir_url(__FILE__) ; // huynhtanmao.com/wp-content/plugin/your-plugin/ plugin_dir_path($file); ex: plugins_dir_path(__FILE__) ; // /home/huynhtan/public_html/wp-content/plugins/wp-payroll/ plugin_basename($file); // /your-plugin/your-plugin.php $file: thường là __FILE__