Conditions | 6 |
Paths | 11 |
Total Lines | 52 |
Lines | 20 |
Ratio | 38.46 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
25 | public static function enqueue_block_assets() { |
||
26 | if ( ! self::should_load_blocks() ) { |
||
27 | return; |
||
28 | } |
||
29 | |||
30 | $rtl = is_rtl() ? '.rtl' : ''; |
||
31 | |||
32 | /** |
||
33 | * Filter to enable serving blocks via CDN |
||
34 | * |
||
35 | * CDN cache is busted once a day or when Jetpack version changes. To customize it: |
||
36 | * add_filter( 'jetpack_gutenberg_cdn_cache_buster', function( $version ) { return time(); }, 10, 1 ); |
||
37 | * |
||
38 | * @since 6.5.0 |
||
39 | * |
||
40 | * @param bool false Whether to load Gutenberg blocks from CDN |
||
41 | */ |
||
42 | View Code Duplication | if ( apply_filters( 'jetpack_gutenberg_cdn', false ) ) { |
|
43 | $cdn_base = 'https://s0.wp.com/wp-content/mu-plugins/jetpack/_inc/blocks'; |
||
44 | $view_script = "$cdn_base/view.js"; |
||
45 | $view_style = "$cdn_base/view$rtl.css"; |
||
46 | |||
47 | /** |
||
48 | * Filter to modify cache busting for Gutenberg block assets loaded from CDN |
||
49 | * |
||
50 | * @since 6.5.0 |
||
51 | * |
||
52 | * @param string |
||
53 | */ |
||
54 | $version = apply_filters( 'jetpack_gutenberg_cdn_cache_buster', sprintf( '%s-%s', gmdate( 'd-m-Y' ), JETPACK__VERSION ) ); |
||
55 | } else { |
||
56 | $view_script = plugins_url( '_inc/blocks/view.js', JETPACK__PLUGIN_FILE ); |
||
57 | $view_style = plugins_url( "_inc/blocks/view$rtl.css", JETPACK__PLUGIN_FILE ); |
||
58 | $version = Jetpack::is_development_version() && file_exists( JETPACK__PLUGIN_DIR . '_inc/blocks/view.js' ) |
||
59 | ? filemtime( JETPACK__PLUGIN_DIR . '_inc/blocks/view.js' ) |
||
60 | : JETPACK__VERSION; |
||
61 | } |
||
62 | |||
63 | wp_enqueue_script( |
||
64 | 'jetpack-blocks-view', |
||
65 | $view_script, |
||
66 | array( |
||
67 | 'wp-element', |
||
68 | 'wp-i18n', |
||
69 | ), |
||
70 | $version |
||
71 | ); |
||
72 | |||
73 | Jetpack::setup_wp_i18n_locale_data(); |
||
74 | |||
75 | wp_enqueue_style( 'jetpack-blocks-view', $view_style, array(), $version ); |
||
76 | } |
||
77 | |||
174 |