@@ -62,7 +62,7 @@ function _wp_lazy_loading_initialize_filters() {
62
62
* @return string Modified tag.
63
63
*/
64
64
function _wp_lazy_loading_add_attribute_to_avatar ( $ avatar ) {
65
- if ( wp_add_lazy_loading_to ( 'img ' , 'get_avatar ' ) && false === strpos ( $ avatar , ' loading= ' ) ) {
65
+ if ( wp_lazy_loading_enabled ( 'img ' , 'get_avatar ' ) && false === strpos ( $ avatar , ' loading= ' ) ) {
66
66
$ avatar = str_replace ( '<img ' , '<img loading="lazy" ' , $ avatar );
67
67
}
68
68
@@ -83,7 +83,7 @@ function _wp_lazy_loading_add_attribute_to_avatar( $avatar ) {
83
83
* @return array Modified attributes.
84
84
*/
85
85
function _wp_lazy_loading_add_attribute_to_attachment_image ( $ attr ) {
86
- if ( wp_add_lazy_loading_to ( 'img ' , 'wp_get_attachment_image ' ) && ! isset ( $ attr ['loading ' ] ) ) {
86
+ if ( wp_lazy_loading_enabled ( 'img ' , 'wp_get_attachment_image ' ) && ! isset ( $ attr ['loading ' ] ) ) {
87
87
$ attr ['loading ' ] = 'lazy ' ;
88
88
}
89
89
@@ -102,21 +102,21 @@ function _wp_lazy_loading_add_attribute_to_attachment_image( $attr ) {
102
102
* @param string $context Additional context, like the current filter name or the function name from where this was called.
103
103
* @return boolean Whether to add the attribute.
104
104
*/
105
- function wp_add_lazy_loading_to ( $ tag_name , $ context ) {
105
+ function wp_lazy_loading_enabled ( $ tag_name , $ context ) {
106
106
// By default add to all 'img' tags.
107
107
// See https://github.com/whatwg/html/issues/2806
108
- $ add = ( 'img ' === $ tag_name );
108
+ $ default = ( 'img ' === $ tag_name );
109
109
110
110
/**
111
111
* Filters whether to add the `loading` attribute to the specified tag in the specified context.
112
112
*
113
113
* @since (TBD)
114
114
*
115
- * @param boolean $add Defatls value.
115
+ * @param boolean $default Defatls value.
116
116
* @param string $tag_name The tag name.
117
117
* @param string $context Additional context, like the current filter name or the function name from where this was called.
118
118
*/
119
- return (bool ) apply_filters ( 'wp_add_lazy_loading_to ' , $ add , $ tag_name , $ context );
119
+ return (bool ) apply_filters ( 'wp_lazy_loading_enabled ' , $ default , $ tag_name , $ context );
120
120
}
121
121
122
122
@@ -140,12 +140,12 @@ function wp_add_lazy_load_attributes( $content, $context = null ) {
140
140
$ context = current_filter ();
141
141
}
142
142
143
- if ( wp_add_lazy_loading_to ( 'img ' , $ context ) ) {
143
+ if ( wp_lazy_loading_enabled ( 'img ' , $ context ) ) {
144
144
$ tags [] = 'img ' ;
145
145
}
146
146
147
147
// Experimental. Will be removed when merging unless the HTML specs are updated by that time.
148
- if ( wp_add_lazy_loading_to ( 'iframe ' , $ context ) ) {
148
+ if ( wp_lazy_loading_enabled ( 'iframe ' , $ context ) ) {
149
149
$ tags [] = 'iframe ' ;
150
150
}
151
151
0 commit comments