11
11
/**
12
12
* Detect is the query for an AMP page?
13
13
*
14
- * @since 1.0.0
15
- *
16
14
* @param null $wp_query
17
15
*
16
+ * @since 1.0.0
17
+ *
18
18
* @return bool true when amp page requested
19
19
*/
20
20
function is_better_amp ( $ wp_query = null ) {
@@ -92,12 +92,12 @@ function is_amp_endpoint() {
92
92
* @type array $scripts_url component javascript URL. Example: https://cdn.ampproject.org/v0/..
93
93
* }
94
94
*
95
- * @global array $better_amp_registered_components
96
- * better-amp components information array
97
- *
98
95
* @since 1.0.0
99
96
*
100
97
* @return bool|WP_Error true on success or WP_Error on failure.
98
+ * @global array $better_amp_registered_components
99
+ * better-amp components information array
100
+ *
101
101
*/
102
102
function better_amp_register_component ( $ component_class , $ settings = array () ) {
103
103
@@ -121,7 +121,7 @@ function better_amp_register_component( $component_class, $settings = array() )
121
121
$ better_amp_registered_components [] = compact ( 'component_class ' , 'settings ' ); // maybe need add some extra indexes like __FILE__ in the future!
122
122
123
123
return true ;
124
- } catch ( Exception $ e ) {
124
+ } catch ( Exception $ e ) {
125
125
126
126
return new WP_Error ( 'error ' , $ e ->getMessage () );
127
127
}
@@ -131,11 +131,11 @@ function better_amp_register_component( $component_class, $settings = array() )
131
131
/**
132
132
* Initialize $better_amp_scripts if it has not been set.
133
133
*
134
- * @global Better_AMP_Scripts $better_amp_scripts
135
- *
136
134
* @since 1.0.0
137
135
*
138
136
* @return Better_AMP_Scripts Better_AMP_Scripts instance.
137
+ * @global Better_AMP_Scripts $better_amp_scripts
138
+ *
139
139
*/
140
140
function better_amp_scripts () {
141
141
@@ -152,14 +152,14 @@ function better_amp_scripts() {
152
152
/**
153
153
* Enqueue a js file for amp version.
154
154
*
155
- * @see wp_enqueue_script
156
- *
157
155
* @param string $handle
158
156
* @param string $src
159
157
* @param array $deps
160
158
* @param string $media
161
159
*
162
160
* @since 1.0.0
161
+ * @see wp_enqueue_script
162
+ *
163
163
*/
164
164
function better_amp_enqueue_script ( $ handle , $ src = '' , $ deps = array (), $ media = 'all ' ) {
165
165
@@ -176,8 +176,8 @@ function better_amp_enqueue_script( $handle, $src = '', $deps = array(), $media
176
176
/**
177
177
* Check whether a script has been added to the queue.
178
178
*
179
- * @param string $handle
180
- * @param string $list
179
+ * @param string $handle
180
+ * @param string $list
181
181
*
182
182
* @since 1.0.0
183
183
*
@@ -216,11 +216,11 @@ function better_amp_enqueue_scripts() {
216
216
/**
217
217
* Initialize $better_amp_styles if it has not been set.
218
218
*
219
- * @global Better_AMP_Styles $better_amp_styles
220
- *
221
219
* @since 1.0.0
222
220
*
223
221
* @return Better_AMP_Styles Better_AMP_Styles instance.
222
+ * @global Better_AMP_Styles $better_amp_styles
223
+ *
224
224
*/
225
225
function better_amp_styles () {
226
226
@@ -237,8 +237,6 @@ function better_amp_styles() {
237
237
/**
238
238
* Enqueue a css file for amp version.
239
239
*
240
- * @see wp_enqueue_style
241
- *
242
240
* @param string $handle
243
241
* @param string $src
244
242
* @param array $deps
@@ -247,6 +245,8 @@ function better_amp_styles() {
247
245
*
248
246
*
249
247
* @since 1.0.0
248
+ * @see wp_enqueue_style
249
+ *
250
250
*/
251
251
function better_amp_enqueue_style ( $ handle , $ src = '' , $ deps = array (), $ ver = false , $ media = 'all ' ) {
252
252
@@ -280,10 +280,10 @@ function better_amp_style_is( $handle, $list = 'enqueued' ) {
280
280
/**
281
281
* Handy function used to enqueue style and scripts of ads
282
282
*
283
- * @since 1.1.0
284
- *
285
283
* @param string $ad_type Ad type, needed to know the js should be printed or not
286
284
*
285
+ * @since 1.1.0
286
+ *
287
287
* @return void
288
288
*/
289
289
function better_amp_enqueue_ad ( $ ad_type = 'adsense ' ) {
@@ -315,14 +315,14 @@ function better_amp_print_styles() {
315
315
/**
316
316
* Add extra CSS styles to a registered stylesheet.
317
317
*
318
- * @see wp_add_inline_style for more information
319
- *
320
318
* @param string $handle Name of the stylesheet to add the extra styles to.
321
319
* @param string $data String containing the CSS styles to be added.
322
320
*
323
321
* @since 1.0.0
324
322
*
325
323
* @return bool True on success, false on failure.
324
+ * @see wp_add_inline_style for more information
325
+ *
326
326
*/
327
327
function better_amp_add_inline_style ( $ data , $ handle = '' ) {
328
328
@@ -344,14 +344,14 @@ function better_amp_add_inline_style( $data, $handle = '' ) {
344
344
/**
345
345
* Add css file data as inline style
346
346
*
347
- * @see wp_add_inline_style for more information
348
- *
349
347
* @param string $handle Name of the stylesheet to add the extra styles to.
350
348
* @param string $file css file path
351
349
*
352
350
* @since 1.0.0
353
351
*
354
352
* @return bool True on success, false on failure.
353
+ * @see wp_add_inline_style for more information
354
+ *
355
355
*/
356
356
function better_amp_enqueue_inline_style ( $ file , $ handle = '' ) {
357
357
@@ -382,15 +382,15 @@ function better_amp_enqueue_inline_style( $file, $handle = '' ) {
382
382
/**
383
383
* Add css file data of block
384
384
*
385
- * @see wp_add_inline_style for more information
386
- *
387
385
* @param string $handle Name of the stylesheet to add the extra styles to.
388
386
* @param string $file css file path
389
387
* @param boolean $rtl add rtl
390
388
*
391
389
* @since 1.0.0
392
390
*
393
391
* @return bool True on success, false on failure.
392
+ * @see wp_add_inline_style for more information
393
+ *
394
394
*/
395
395
function better_amp_enqueue_block_style ( $ handle , $ file = '' , $ rtl = true ) {
396
396
@@ -416,11 +416,7 @@ function better_amp_enqueue_block_style( $handle, $file = '', $rtl = true ) {
416
416
return true ;
417
417
}
418
418
419
- better_amp_enqueue_inline_style ( better_amp_min_suffix ( $ file , '.css ' ), $ handle );
420
-
421
- if ( $ rtl && is_rtl () ) {
422
- better_amp_enqueue_inline_style ( better_amp_min_suffix ( $ file . '.rtl ' , '.css ' ), $ handle . '-rtl ' );
423
- }
419
+ better_amp_enqueue_inline_style ( better_amp_min_suffix ( $ file . ( $ rtl && is_rtl () ? '.rtl ' : '' ), '.css ' ), $ handle );
424
420
425
421
return $ printed_files [ $ file ] = true ;
426
422
}
@@ -470,10 +466,10 @@ function better_amp_customize_preview_init( $customize_manager ) {
470
466
/**
471
467
* Detects Non-AMP URL of current page
472
468
*
473
- * @since 1.0.0
474
- *
475
469
* @param array $args
476
470
*
471
+ * @since 1.0.0
472
+ *
477
473
* @return string
478
474
*/
479
475
function better_amp_guess_none_amp_url ( $ args = array () ) {
@@ -483,7 +479,7 @@ function better_amp_guess_none_amp_url( $args = array() ) {
483
479
return home_url ( remove_query_arg ( 'amp ' ) );
484
480
}
485
481
486
- $ current_url = better_amp_get_canonical_url ();
482
+ $ current_url = better_amp_get_canonical_url ();
487
483
$ none_amp_url = Better_AMP_Content_Sanitizer::transform_to_none_amp_url ( $ current_url );
488
484
489
485
// Change query args from outside
@@ -543,9 +539,10 @@ function better_amp_translation_get( $key ) {
543
539
/**
544
540
* Prints translation of text
545
541
*
542
+ * @param $key
543
+ *
546
544
* @since 1.0.0
547
545
*
548
- * @param $key
549
546
*/
550
547
function better_amp_translation_echo ( $ key ) {
551
548
@@ -621,8 +618,8 @@ function better_amp_unparse_url( $parsed_url ) {
621
618
*
622
619
* @since 1.3.1
623
620
*
624
- * @todo remove this function after adding BF to better-amp
625
621
* @return string
622
+ * @todo remove this function after adding BF to better-amp
626
623
*/
627
624
function bf_get_wp_installation_slug () {
628
625
@@ -726,7 +723,7 @@ function better_amp_taxonomies_prefix() {
726
723
* Is custom permalink activated for this WP installation?
727
724
*
728
725
* @since 1.8.1
729
- * @return string Custom structure if custom permalink activated.
726
+ * @return string Custom structure if custom permalink activated.
730
727
*/
731
728
function better_amp_using_permalink_structure () {
732
729
@@ -739,11 +736,11 @@ function better_amp_using_permalink_structure() {
739
736
/**
740
737
* Get WP FileSystem Object.
741
738
*
742
- * @global WP_Filesystem_Base $wp_filesystem WordPress Filesystem Class
743
- *
744
739
* @since 1.11.0
745
740
* @return WP_Filesystem_Base
746
741
*
742
+ * @global WP_Filesystem_Base $wp_filesystem WordPress Filesystem Class
743
+ *
747
744
*/
748
745
function better_amp_file_system_instance () {
749
746
0 commit comments