| Conditions | 9 |
| Paths | 29 |
| Total Lines | 104 |
| 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 |
||
| 221 | public function enqueue_scripts() { |
||
| 222 | |||
| 223 | /* |
||
| 224 | * Do not load our scripts on the Filter Urls plugin admin pages. |
||
| 225 | * |
||
| 226 | * @see https://github.com/insideout10/wordlift-plugin/issues/901 |
||
| 227 | * @since 3.20.0 |
||
| 228 | */ |
||
| 229 | $screen = get_current_screen(); |
||
| 230 | if ( is_a( $screen, 'WP_Screen' ) && 'filter-urls_page_filter_urls_form' === $screen->id ) { |
||
| 231 | return; |
||
| 232 | } |
||
| 233 | |||
| 234 | // Enqueue the admin scripts. |
||
| 235 | wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/1/admin.js', array( |
||
| 236 | 'jquery', |
||
| 237 | 'underscore', |
||
| 238 | 'backbone', |
||
| 239 | ), $this->version, false ); |
||
| 240 | |||
| 241 | |||
| 242 | $can_edit_wordlift_entities = current_user_can( 'edit_wordlift_entities' ); |
||
| 243 | |||
| 244 | /* |
||
| 245 | * People that can create entities will see the scope set in the wp-config.php file (by default `cloud`). People |
||
| 246 | * that cannot edit create entities will always see the local entities. |
||
| 247 | * |
||
| 248 | * @see https://github.com/insideout10/wordlift-plugin/issues/839 |
||
| 249 | */ |
||
| 250 | $autocomplete_scope = $can_edit_wordlift_entities ? WL_AUTOCOMPLETE_SCOPE : "local"; |
||
| 251 | |||
| 252 | // Set the basic params. |
||
| 253 | $params = array( |
||
| 254 | // @todo scripts in admin should use wp.post. |
||
| 255 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
||
| 256 | // @todo remove specific actions from settings. |
||
| 257 | 'action' => 'entity_by_title', |
||
| 258 | 'datasetUri' => $this->configuration_service->get_dataset_uri(), |
||
| 259 | 'language' => $this->configuration_service->get_language_code(), |
||
| 260 | 'link_by_default' => $this->configuration_service->is_link_by_default(), |
||
| 261 | // Whether the current user is allowed to create new entities. |
||
| 262 | // |
||
| 263 | // @see https://github.com/insideout10/wordlift-plugin/issues/561 |
||
| 264 | 'can_create_entities' => $can_edit_wordlift_entities ? 'yes' : 'no', |
||
| 265 | 'l10n' => array( |
||
| 266 | 'You already published an entity with the same name' => __( 'You already published an entity with the same name: ', 'wordlift' ), |
||
| 267 | 'logo_selection_title' => __( 'WordLift Choose Logo', 'wordlift' ), |
||
| 268 | 'logo_selection_button' => array( 'text' => __( 'Choose Logo', 'wordlift' ) ), |
||
| 269 | 'Type at least 3 characters to search...' => _x( 'Type at least 3 characters to search...', 'Autocomplete Select', 'wordlift' ), |
||
| 270 | 'No results found for your search.' => _x( 'No results found: try changing or removing some words.', 'Autocomplete Select', 'wordlift' ), |
||
| 271 | 'Please wait while we look for entities in the linked data cloud...' => _x( 'Please wait while we look for entities in the linked data cloud...', 'Autocomplete Select', 'wordlift' ), |
||
| 272 | 'Add keywords to track' => __( 'Add Keywords to track', 'wordlift' ), |
||
| 273 | ), |
||
| 274 | 'wl_autocomplete_nonce' => wp_create_nonce( 'wordlift_autocomplete' ), |
||
| 275 | 'autocomplete_scope' => $autocomplete_scope, |
||
| 276 | /** |
||
| 277 | * Allow 3rd parties to define the default editor id. This turns useful if 3rd parties load |
||
| 278 | * or change the TinyMCE id. |
||
| 279 | * |
||
| 280 | * The editor id is currently referenced by `src/coffee/editpost-widget/app.services.EditorAdapter.coffee`. |
||
| 281 | * |
||
| 282 | * @since 3.19.4 |
||
| 283 | * |
||
| 284 | * @see https://github.com/insideout10/wordlift-plugin/issues/848 |
||
| 285 | * |
||
| 286 | * @param string $editor The default editor id, by default `content`. |
||
| 287 | */ |
||
| 288 | 'default_editor_id' => apply_filters( 'wl_default_editor_id', 'content' ), |
||
| 289 | /** |
||
| 290 | * Add the link to the Search Keywords admin page. |
||
| 291 | * |
||
| 292 | * @since 3.20.0 |
||
| 293 | */ |
||
| 294 | 'search_keywords_admin_page' => admin_url( 'admin.php?page=wl_configuration_admin_menu&tab=search-keywords' ), |
||
| 295 | ); |
||
| 296 | |||
| 297 | // Set post-related values if there's a current post. |
||
| 298 | if ( null !== $post = $entity_being_edited = get_post() ) { |
||
| 299 | |||
| 300 | $params['post_id'] = $entity_being_edited->ID; |
||
| 301 | $entity_service = Wordlift_Entity_Service::get_instance(); |
||
| 302 | $params['entityBeingEdited'] = isset( $entity_being_edited->post_type ) && $entity_service->is_entity( $post->ID ) && is_numeric( get_the_ID() ); |
||
| 303 | // We add the `itemId` here to give a chance to the analysis to use it in order to tell WLS to exclude it |
||
| 304 | // from the results, since we don't want the current entity to be discovered by the analysis. |
||
| 305 | // |
||
| 306 | // See https://github.com/insideout10/wordlift-plugin/issues/345 |
||
| 307 | $params['itemId'] = $entity_service->get_uri( $entity_being_edited->ID ); |
||
| 308 | $params['wl_schemaorg_property_nonce'] = wp_create_nonce( 'wl_schemaorg_property' ); |
||
| 309 | |||
| 310 | /* |
||
| 311 | * Add the `properties` if `WL_ALL_ENTITY_TYPES` is enabled. |
||
| 312 | * |
||
| 313 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
||
| 314 | */ |
||
| 315 | if ( WL_ALL_ENTITY_TYPES ) { |
||
| 316 | $params['properties'] = Wordlift_Schemaorg_Property_Service::get_instance()->get_all( $post->ID ); |
||
| 317 | } |
||
| 318 | |||
| 319 | } |
||
| 320 | |||
| 321 | // Finally output the params as `wlSettings` for JavaScript code. |
||
| 322 | wp_localize_script( $this->plugin_name, 'wlSettings', apply_filters( 'wl_admin_settings', $params ) ); |
||
| 323 | |||
| 324 | } |
||
| 325 | |||
| 360 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.