admin管理员组文章数量:1384511
I really new in Wordpress development and have a little bit of knowledge of jquery. I was trying to understand a WordPress plugin and also trying to understand the js code they wrote for the plugin. I don't understand what does the following code mean.
(function( api, wp, $ ) {
'use strict';
})( wp.customize, wp, jQuery );
what is api , wp and $ at the top and wp.customize , wp , jQuery at the bottom mean?
I really new in Wordpress development and have a little bit of knowledge of jquery. I was trying to understand a WordPress plugin and also trying to understand the js code they wrote for the plugin. I don't understand what does the following code mean.
(function( api, wp, $ ) {
'use strict';
})( wp.customize, wp, jQuery );
what is api , wp and $ at the top and wp.customize , wp , jQuery at the bottom mean?
Share Improve this question edited May 9, 2020 at 13:48 Prappo 1531 silver badge4 bronze badges asked May 4, 2020 at 10:16 xs-devxs-dev 153 bronze badges2 Answers
Reset to default 2It's an Immediately Invoked Function Expression (IIFE) - an anonymous function that executes itself after it has been defined. The variables at the bottom are taken from the global scope and are passed as parameters to the anonymous function.
So api
represents wp.customize
,
wp
represents wp
and
$
represents jQuery
inside the function.
As I understand it, this function just tells you that strict mode (https://www.w3schools/js/js_strict.asp) is being used for the execution of jQuery Scripts of your WordPress customizer. api here just refers to the "connection" onto a specific part, which in this case is the wordpress customizer (https://developer.wordpress/themes/customize-api/).
本文标签: javascriptNeed help about understand apiWP syntax in WordPress plugin script
版权声明:本文标题:javascript - Need help about understand api, wp, $ syntax in WordPress plugin script 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744488507a2608594.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论