TAILIEUCHUNG - Hướng dẫn tạo themes cho wordpress part 20

Điều này có chứa một xử lý (tên của kịch bản, một chuỗi chữ thường) và URL (cũng là một chuỗi ký tự) mà kịch bản có thể được tìm thấy. Khi bạn gọi wp_enqueue_script, bạn phải vượt qua trong một chuỗi giá trị với giá xử lý như tham số đầu tiên, và URL ($ src) mà tại đó các tập lệnh có thể được tìm thấy như là các tham số thứ hai. | Chapter 10 How it works. When you call wp_enqueue_script you re taking advantage of one of several JavaScriptspecific functions included with WordPress. Some of the others include wp_register_ script wp_is_script and wp_print_scripts. The wp_enqueue_script function accepts the following parameters handle src deps ver and in_footer. Let s talk about which ones are required and which ones are optional. Earlier in our example we used the following function to call a simple JavaScript file wp_enqueue_script my-theme get_bloginfo stylesheet_ directory . js This contained a handle the name of the script a lowercase string and the URL also a string where the script could be found. When you call wp_enqueue_script you must pass in a string value for handle as the first parameter and the URL src at which the script can be found as the second parameter. These are the required parameters. Optionally you can pass in an array of script handles as a third parameter the dep parameter a version string as the fourth parameter the ver parameter and a flag in_footer a Boolean value indicating that the script should be printed in the footer as the fifth and final parameter. After a script has been enqueued WordPress knows that a link to it should be printed whenever wp_print_scripts is called. Normally this is called within the wp_head function inside of the head tag. When you are creating a theme using multiple JavaScript functions aL or feature-rich libraries such as JQuery it is a best practice to place the wp_enqueue_script function in and use 3 the in_footer parameter to automatically call the script in the footer. We will cover that in the next section. If you go back and check the source for your blog homepage after adding the code specified previously you ll see something like the following script type text javascript src http wp-content themes my-theme js my-theme. js ver script You can see that WordPress parsed the relative path .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.