Skip to content

Commit fb7bdb0

Browse files
2 parents eb0b575 + 1620323 commit fb7bdb0

File tree

158 files changed

+7816
-2824
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+7816
-2824
lines changed

better-amp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Plugin URI: https://betterstudio.com/wp-plugins/better-amp/
55
Description: Add FULL AMP support to your WordPress site.
66
Author: Better Studio
7-
Version: 1.11.0
7+
Version: 1.12.0
88
Author URI: http://betterstudio.com
99
*/
1010

@@ -52,7 +52,7 @@ class Better_AMP {
5252
*
5353
* @since 1.0.0
5454
*/
55-
const VERSION = '1.11.0';
55+
const VERSION = '1.12.0';
5656

5757

5858
/**

gulpfile.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
var gulp = require('gulp'),
22
cleanCSS = require('gulp-minify-css'),
33
rename = require('gulp-rename'),
4+
postcss = require('gulp-postcss'),
5+
sass = require('gulp-sass'),
6+
rtlcss = require('rtlcss'),
47
uglify = require('gulp-uglify');
58

6-
gulp.task('styles', function () {
9+
10+
gulp.task('sass', function () {
11+
return gulp.src('./template/sass/**/*.scss')
12+
.pipe(sass.sync().on('error', sass.logError))
13+
.pipe(gulp.dest(function (file) {
14+
return file.basename == 'style.css' ? './template/' : './template/css/';
15+
}));
16+
});
17+
18+
gulp.task('css', function () {
719
return gulp.src(['./template/**/*.css', '!./template/**/*.min.css'])
820
.pipe(cleanCSS({
921
keepSpecialComments: 1,
@@ -24,9 +36,30 @@ gulp.task('scripts', function () {
2436
}));
2537
});
2638

39+
gulp.task('rtl', function () {
40+
return gulp.src([
41+
'template/css/**/*.css',
42+
'!template/css/**/*.min.css',
43+
'!template/css/**/*.rtl.css',
44+
'template/*.css',
45+
'!template/*.min.css',
46+
'!template/*.rtl.css'
47+
])
48+
.pipe(postcss([rtlcss]))
49+
.pipe(rename(function (path) {
50+
path.basename += '.rtl'
51+
}))
52+
.pipe(gulp.dest(function (file) {
53+
return file.base;
54+
}));
55+
});
56+
2757
gulp.task('watch', function () {
2858
gulp.watch(['./template/**/*.css', '!./template/**/*.min.css'], gulp.series('styles'));
2959
gulp.watch(['./js/**/*.js', '!./js/**/*.min.js', '!./js/*.min.js'], gulp.series('scripts'));
3060
});
3161

62+
gulp.task('styles', gulp.series('sass', 'rtl', 'css'));
63+
3264
gulp.task('default', gulp.series('styles', 'scripts'));
65+

includes/functions/core-functions.php

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
/**
1212
* Detect is the query for an AMP page?
1313
*
14-
* @since 1.0.0
15-
*
1614
* @param null $wp_query
1715
*
16+
* @since 1.0.0
17+
*
1818
* @return bool true when amp page requested
1919
*/
2020
function is_better_amp( $wp_query = null ) {
@@ -92,12 +92,12 @@ function is_amp_endpoint() {
9292
* @type array $scripts_url component javascript URL. Example: https://cdn.ampproject.org/v0/..
9393
* }
9494
*
95-
* @global array $better_amp_registered_components
96-
* better-amp components information array
97-
*
9895
* @since 1.0.0
9996
*
10097
* @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+
*
101101
*/
102102
function better_amp_register_component( $component_class, $settings = array() ) {
103103

@@ -121,7 +121,7 @@ function better_amp_register_component( $component_class, $settings = array() )
121121
$better_amp_registered_components[] = compact( 'component_class', 'settings' ); // maybe need add some extra indexes like __FILE__ in the future!
122122

123123
return true;
124-
} catch( Exception $e ) {
124+
} catch ( Exception $e ) {
125125

126126
return new WP_Error( 'error', $e->getMessage() );
127127
}
@@ -131,11 +131,11 @@ function better_amp_register_component( $component_class, $settings = array() )
131131
/**
132132
* Initialize $better_amp_scripts if it has not been set.
133133
*
134-
* @global Better_AMP_Scripts $better_amp_scripts
135-
*
136134
* @since 1.0.0
137135
*
138136
* @return Better_AMP_Scripts Better_AMP_Scripts instance.
137+
* @global Better_AMP_Scripts $better_amp_scripts
138+
*
139139
*/
140140
function better_amp_scripts() {
141141

@@ -152,14 +152,14 @@ function better_amp_scripts() {
152152
/**
153153
* Enqueue a js file for amp version.
154154
*
155-
* @see wp_enqueue_script
156-
*
157155
* @param string $handle
158156
* @param string $src
159157
* @param array $deps
160158
* @param string $media
161159
*
162160
* @since 1.0.0
161+
* @see wp_enqueue_script
162+
*
163163
*/
164164
function better_amp_enqueue_script( $handle, $src = '', $deps = array(), $media = 'all' ) {
165165

@@ -176,8 +176,8 @@ function better_amp_enqueue_script( $handle, $src = '', $deps = array(), $media
176176
/**
177177
* Check whether a script has been added to the queue.
178178
*
179-
* @param string $handle
180-
* @param string $list
179+
* @param string $handle
180+
* @param string $list
181181
*
182182
* @since 1.0.0
183183
*
@@ -216,11 +216,11 @@ function better_amp_enqueue_scripts() {
216216
/**
217217
* Initialize $better_amp_styles if it has not been set.
218218
*
219-
* @global Better_AMP_Styles $better_amp_styles
220-
*
221219
* @since 1.0.0
222220
*
223221
* @return Better_AMP_Styles Better_AMP_Styles instance.
222+
* @global Better_AMP_Styles $better_amp_styles
223+
*
224224
*/
225225
function better_amp_styles() {
226226

@@ -237,8 +237,6 @@ function better_amp_styles() {
237237
/**
238238
* Enqueue a css file for amp version.
239239
*
240-
* @see wp_enqueue_style
241-
*
242240
* @param string $handle
243241
* @param string $src
244242
* @param array $deps
@@ -247,6 +245,8 @@ function better_amp_styles() {
247245
*
248246
*
249247
* @since 1.0.0
248+
* @see wp_enqueue_style
249+
*
250250
*/
251251
function better_amp_enqueue_style( $handle, $src = '', $deps = array(), $ver = false, $media = 'all' ) {
252252

@@ -280,10 +280,10 @@ function better_amp_style_is( $handle, $list = 'enqueued' ) {
280280
/**
281281
* Handy function used to enqueue style and scripts of ads
282282
*
283-
* @since 1.1.0
284-
*
285283
* @param string $ad_type Ad type, needed to know the js should be printed or not
286284
*
285+
* @since 1.1.0
286+
*
287287
* @return void
288288
*/
289289
function better_amp_enqueue_ad( $ad_type = 'adsense' ) {
@@ -315,14 +315,14 @@ function better_amp_print_styles() {
315315
/**
316316
* Add extra CSS styles to a registered stylesheet.
317317
*
318-
* @see wp_add_inline_style for more information
319-
*
320318
* @param string $handle Name of the stylesheet to add the extra styles to.
321319
* @param string $data String containing the CSS styles to be added.
322320
*
323321
* @since 1.0.0
324322
*
325323
* @return bool True on success, false on failure.
324+
* @see wp_add_inline_style for more information
325+
*
326326
*/
327327
function better_amp_add_inline_style( $data, $handle = '' ) {
328328

@@ -344,14 +344,14 @@ function better_amp_add_inline_style( $data, $handle = '' ) {
344344
/**
345345
* Add css file data as inline style
346346
*
347-
* @see wp_add_inline_style for more information
348-
*
349347
* @param string $handle Name of the stylesheet to add the extra styles to.
350348
* @param string $file css file path
351349
*
352350
* @since 1.0.0
353351
*
354352
* @return bool True on success, false on failure.
353+
* @see wp_add_inline_style for more information
354+
*
355355
*/
356356
function better_amp_enqueue_inline_style( $file, $handle = '' ) {
357357

@@ -382,15 +382,15 @@ function better_amp_enqueue_inline_style( $file, $handle = '' ) {
382382
/**
383383
* Add css file data of block
384384
*
385-
* @see wp_add_inline_style for more information
386-
*
387385
* @param string $handle Name of the stylesheet to add the extra styles to.
388386
* @param string $file css file path
389387
* @param boolean $rtl add rtl
390388
*
391389
* @since 1.0.0
392390
*
393391
* @return bool True on success, false on failure.
392+
* @see wp_add_inline_style for more information
393+
*
394394
*/
395395
function better_amp_enqueue_block_style( $handle, $file = '', $rtl = true ) {
396396

@@ -416,11 +416,7 @@ function better_amp_enqueue_block_style( $handle, $file = '', $rtl = true ) {
416416
return true;
417417
}
418418

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 );
424420

425421
return $printed_files[ $file ] = true;
426422
}
@@ -470,10 +466,10 @@ function better_amp_customize_preview_init( $customize_manager ) {
470466
/**
471467
* Detects Non-AMP URL of current page
472468
*
473-
* @since 1.0.0
474-
*
475469
* @param array $args
476470
*
471+
* @since 1.0.0
472+
*
477473
* @return string
478474
*/
479475
function better_amp_guess_none_amp_url( $args = array() ) {
@@ -483,7 +479,7 @@ function better_amp_guess_none_amp_url( $args = array() ) {
483479
return home_url( remove_query_arg( 'amp' ) );
484480
}
485481

486-
$current_url = better_amp_get_canonical_url();
482+
$current_url = better_amp_get_canonical_url();
487483
$none_amp_url = Better_AMP_Content_Sanitizer::transform_to_none_amp_url( $current_url );
488484

489485
// Change query args from outside
@@ -543,9 +539,10 @@ function better_amp_translation_get( $key ) {
543539
/**
544540
* Prints translation of text
545541
*
542+
* @param $key
543+
*
546544
* @since 1.0.0
547545
*
548-
* @param $key
549546
*/
550547
function better_amp_translation_echo( $key ) {
551548

@@ -621,8 +618,8 @@ function better_amp_unparse_url( $parsed_url ) {
621618
*
622619
* @since 1.3.1
623620
*
624-
* @todo remove this function after adding BF to better-amp
625621
* @return string
622+
* @todo remove this function after adding BF to better-amp
626623
*/
627624
function bf_get_wp_installation_slug() {
628625

@@ -726,7 +723,7 @@ function better_amp_taxonomies_prefix() {
726723
* Is custom permalink activated for this WP installation?
727724
*
728725
* @since 1.8.1
729-
* @return string Custom structure if custom permalink activated.
726+
* @return string Custom structure if custom permalink activated.
730727
*/
731728
function better_amp_using_permalink_structure() {
732729

@@ -739,11 +736,11 @@ function better_amp_using_permalink_structure() {
739736
/**
740737
* Get WP FileSystem Object.
741738
*
742-
* @global WP_Filesystem_Base $wp_filesystem WordPress Filesystem Class
743-
*
744739
* @since 1.11.0
745740
* @return WP_Filesystem_Base
746741
*
742+
* @global WP_Filesystem_Base $wp_filesystem WordPress Filesystem Class
743+
*
747744
*/
748745
function better_amp_file_system_instance() {
749746

0 commit comments

Comments
 (0)