AmitT /
podium
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * WordPress.com-specific functions and definitions. |
||
| 4 | * |
||
| 5 | * This file is centrally included from `wp-content/mu-plugins/wpcom-theme-compat.php`. |
||
| 6 | * |
||
| 7 | * @package podium |
||
| 8 | */ |
||
| 9 | |||
| 10 | // function podium_scripts() |
||
|
0 ignored issues
–
show
|
|||
| 11 | // { |
||
| 12 | |||
| 13 | // wp_enqueue_style('podium-style', get_stylesheet_directory_uri() . '/dist/styles/main.css', false, null); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
59% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 14 | // wp_enqueue_script('podium-scripts', get_stylesheet_directory_uri() . '/dist/scripts/main.js', ['jquery'], null, true); |
||
| 15 | |||
| 16 | // if (is_singular() && comments_open() && get_option('thread_comments')) { |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
57% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 17 | |||
| 18 | // wp_enqueue_script('comment-reply'); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 19 | |||
| 20 | // } |
||
| 21 | |||
| 22 | // } |
||
| 23 | function podium_scripts() |
||
| 24 | { |
||
| 25 | |||
| 26 | if (WP_ENV === 'production') { |
||
| 27 | wp_enqueue_style( |
||
| 28 | 'podium-style', |
||
| 29 | get_stylesheet_directory_uri() . '/dist/styles/main.min.css', |
||
| 30 | false, |
||
| 31 | null |
||
| 32 | ); |
||
| 33 | wp_enqueue_script( |
||
| 34 | 'podium-scripts', |
||
| 35 | get_stylesheet_directory_uri() . '/dist/scripts/main.min.js', |
||
| 36 | null, |
||
| 37 | null, |
||
| 38 | true |
||
| 39 | ); |
||
| 40 | } else { |
||
| 41 | wp_enqueue_style( |
||
| 42 | 'podium-style', |
||
| 43 | get_stylesheet_directory_uri() . '/dist/styles/main.css', |
||
| 44 | false, |
||
| 45 | null |
||
| 46 | ); |
||
| 47 | wp_enqueue_script( |
||
| 48 | 'podium-scripts', |
||
| 49 | get_stylesheet_directory_uri() . '/dist/scripts/main.js', |
||
| 50 | null, |
||
| 51 | null, |
||
| 52 | true |
||
| 53 | ); |
||
| 54 | } |
||
| 55 | |||
| 56 | // Add resources for individual page templates |
||
| 57 | // if (is_page_template('page-contact.php')) { |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
64% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 58 | |||
| 59 | // wp_enqueue_script( |
||
| 60 | // 'contact-page-script', |
||
| 61 | // get_stylesheet_directory_uri() . '/dist/scripts/contact-page.js', |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
45% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 62 | // ['jquery'], |
||
| 63 | // false, |
||
| 64 | // true |
||
| 65 | // ); |
||
| 66 | // wp_enqueue_script( |
||
| 67 | // 'google-recapcha-script', |
||
| 68 | // '//www.google.com/recaptcha/api.js?hl='.pll_current_language(), |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 69 | // ['contact-page-script'], |
||
| 70 | // false, |
||
| 71 | // true |
||
| 72 | // ); |
||
| 73 | |||
| 74 | // } |
||
| 75 | |||
| 76 | //remove emoji scripts |
||
| 77 | remove_action('wp_head', 'print_emoji_detection_script', 7); |
||
| 78 | remove_action('admin_print_scripts', 'print_emoji_detection_script'); |
||
| 79 | remove_action('wp_print_styles', 'print_emoji_styles'); |
||
| 80 | remove_action('admin_print_styles', 'print_emoji_styles'); |
||
| 81 | |||
| 82 | if (is_singular() && comments_open() && get_option('thread_comments')) { |
||
| 83 | wp_enqueue_script('comment-reply'); |
||
| 84 | } |
||
| 85 | |||
| 86 | } |
||
| 87 | |||
| 88 | add_action('wp_enqueue_scripts', 'podium_scripts'); |
||
| 89 | |||
| 90 | // Defer scripts |
||
| 91 | /** |
||
| 92 | * @param $tag |
||
| 93 | * @param $handle |
||
| 94 | * @return mixed |
||
| 95 | */ |
||
| 96 | function podium_add_defer_attribute($tag, $handle) |
||
| 97 | { |
||
| 98 | |||
| 99 | // add script handles to the array below |
||
| 100 | $scripts_to_defer = [ |
||
| 101 | 'podium-scripts' |
||
| 102 | // 'more-js-handled' |
||
| 103 | ]; |
||
| 104 | |||
| 105 | foreach ($scripts_to_defer as $defer_script) { |
||
| 106 | |||
| 107 | if ($defer_script === $handle) { |
||
| 108 | |||
| 109 | return str_replace(' src', ' defer="defer" src', $tag); |
||
| 110 | |||
| 111 | } |
||
| 112 | |||
| 113 | } |
||
| 114 | |||
| 115 | return $tag; |
||
| 116 | } |
||
| 117 | |||
| 118 | add_filter('script_loader_tag', 'podium_add_defer_attribute', 10, 2); |
||
| 119 | |||
| 120 | // Async scripts |
||
| 121 | /** |
||
| 122 | * @param $tag |
||
| 123 | * @param $handle |
||
| 124 | * @return mixed |
||
| 125 | */ |
||
| 126 | function podium_add_async_attribute($tag, $handle) |
||
| 127 | { |
||
| 128 | // add script handles to the array below |
||
| 129 | $scripts_to_async = [ |
||
| 130 | |||
| 131 | // 'my-js-handle', |
||
| 132 | // 'more-js-handled' |
||
| 133 | ]; |
||
| 134 | |||
| 135 | foreach ($scripts_to_async as $async_script) { |
||
| 136 | |||
| 137 | if ($async_script === $handle) { |
||
| 138 | |||
| 139 | return str_replace(' src', ' async="async" src', $tag); |
||
| 140 | |||
| 141 | } |
||
| 142 | |||
| 143 | } |
||
| 144 | |||
| 145 | return $tag; |
||
| 146 | } |
||
| 147 | |||
| 148 | // add_filter('script_loader_tag', 'podium_add_async_attribute', 10, 2); |
||
| 149 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.