Conditions | 12 |
Paths | 33 |
Total Lines | 33 |
Code Lines | 26 |
Lines | 0 |
Ratio | 0 % |
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 |
||
140 | function monsterinsights_frontend_admin_bar_scripts() { |
||
141 | if ( ! is_admin_bar_showing() || monsterinsights_get_option( 'hide_admin_bar_reports' ) ) { |
||
142 | return; |
||
143 | } |
||
144 | |||
145 | $version_path = monsterinsights_is_pro_version() ? 'pro' : 'lite'; |
||
146 | $rtl = is_rtl() ? '.rtl' : ''; |
||
147 | $frontend_js_url = defined( 'MONSTERINSIGHTS_LOCAL_FRONTEND_JS_URL' ) && MONSTERINSIGHTS_LOCAL_FRONTEND_JS_URL ? MONSTERINSIGHTS_LOCAL_FRONTEND_JS_URL : plugins_url( $version_path . '/assets/vue/js/frontend.js', MONSTERINSIGHTS_PLUGIN_FILE ); |
||
|
|||
148 | |||
149 | if ( ! defined( 'MONSTERINSIGHTS_LOCAL_FRONTEND_JS_URL' ) ) { |
||
150 | wp_enqueue_style( 'monsterinsights-vue-frontend-style', plugins_url( $version_path . '/assets/vue/css/frontend' . $rtl . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() ); |
||
151 | wp_enqueue_script( 'monsterinsights-vue-vendors', plugins_url( $version_path . '/assets/vue/js/chunk-vendors.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), true ); |
||
152 | wp_enqueue_script( 'monsterinsights-vue-common', plugins_url( $version_path . '/assets/vue/js/chunk-common.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), true ); |
||
153 | } |
||
154 | |||
155 | wp_register_script( 'monsterinsights-vue-frontend', $frontend_js_url, array(), monsterinsights_get_asset_version(), true ); |
||
156 | wp_enqueue_script( 'monsterinsights-vue-frontend' ); |
||
157 | |||
158 | wp_localize_script( |
||
159 | 'monsterinsights-vue-frontend', |
||
160 | 'monsterinsights', |
||
161 | array( |
||
162 | 'ajax' => admin_url( 'admin-ajax.php' ), |
||
163 | 'nonce' => wp_create_nonce( 'mi-admin-nonce' ), |
||
164 | 'network' => is_network_admin(), |
||
165 | 'translations' => wp_get_jed_locale_data( monsterinsights_is_pro_version() ? 'ga-premium' : 'google-analytics-for-wordpress' ), |
||
166 | 'assets' => plugins_url( $version_path . '/assets/vue', MONSTERINSIGHTS_PLUGIN_FILE ), |
||
167 | 'addons_url' => is_multisite() ? network_admin_url( 'admin.php?page=monsterinsights_network#/addons' ) : admin_url( 'admin.php?page=monsterinsights_settings#/addons' ), |
||
168 | 'page_id' => is_singular() ? get_the_ID() : false, |
||
169 | 'page_title' => is_singular() ? get_the_title() : false, |
||
170 | 'plugin_version' => MONSTERINSIGHTS_VERSION, |
||
171 | 'shareasale_id' => monsterinsights_get_shareasale_id(), |
||
172 | 'shareasale_url' => monsterinsights_get_shareasale_url( monsterinsights_get_shareasale_id(), '' ), |
||
173 | ) |
||
178 |