| Conditions | 5 |
| Paths | 8 |
| Total Lines | 63 |
| Code Lines | 27 |
| 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 |
||
| 130 | public function enqueue_scripts() { |
||
| 131 | |||
| 132 | /** |
||
| 133 | * This function is provided for demonstration purposes only. |
||
| 134 | * |
||
| 135 | * An instance of this class should be passed to the run() function |
||
| 136 | * defined in Wordlift_Loader as all of the hooks are defined |
||
| 137 | * in that particular class. |
||
| 138 | * |
||
| 139 | * The Wordlift_Loader will then create the relationship |
||
| 140 | * between the defined hooks and the functions defined in this |
||
| 141 | * class. |
||
| 142 | */ |
||
| 143 | |||
| 144 | // Enqueue the admin scripts. |
||
| 145 | wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/1/admin.js', array( |
||
| 146 | 'jquery', |
||
| 147 | 'underscore', |
||
| 148 | 'backbone', |
||
| 149 | ), $this->version, false ); |
||
| 150 | |||
| 151 | // Set the basic params. |
||
| 152 | $params = array( |
||
| 153 | // @todo scripts in admin should use wp.post. |
||
| 154 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
||
| 155 | // @todo remove specific actions from settings. |
||
| 156 | 'action' => 'entity_by_title', |
||
| 157 | 'datasetUri' => $this->configuration_service->get_dataset_uri(), |
||
| 158 | 'language' => $this->configuration_service->get_language_code(), |
||
| 159 | 'link_by_default' => $this->configuration_service->is_link_by_default(), |
||
| 160 | // Whether the current user is allowed to create new entities. |
||
| 161 | // |
||
| 162 | // @see https://github.com/insideout10/wordlift-plugin/issues/561 |
||
| 163 | 'can_create_entities' => current_user_can( 'edit_wordlift_entities' ) ? 'yes' : 'no', |
||
| 164 | 'l10n' => array( |
||
| 165 | 'You already published an entity with the same name' => __( 'You already published an entity with the same name: ', 'wordlift' ), |
||
| 166 | 'logo_selection_title' => __( 'WordLift Choose Logo', 'wordlift' ), |
||
| 167 | 'logo_selection_button' => array( 'text' => __( 'Choose Logo', 'wordlift' ) ), |
||
| 168 | 'Type at least 3 characters to search...' => _x( 'Type at least 3 characters to search...', 'Autocomplete Select', 'wordlift' ), |
||
| 169 | 'No results found for your search.' => _x( 'No results found: try changing or removing some words.', 'Autocomplete Select', 'wordlift' ), |
||
| 170 | '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' ), |
||
| 171 | ), |
||
| 172 | 'wl_autocomplete_nonce' => wp_create_nonce( 'wordlift_autocomplete' ), |
||
| 173 | ); |
||
| 174 | |||
| 175 | // Set post-related values if there's a current post. |
||
| 176 | if ( null !== $post = $entity_being_edited = get_post() ) { |
||
| 177 | |||
| 178 | $params['post_id'] = $entity_being_edited->ID; |
||
| 179 | $entity_service = Wordlift_Entity_Service::get_instance(); |
||
| 180 | $params['entityBeingEdited'] = isset( $entity_being_edited->post_type ) && $entity_service->is_entity( $post->ID ) && is_numeric( get_the_ID() ); |
||
| 181 | // We add the `itemId` here to give a chance to the analysis to use it in order to tell WLS to exclude it |
||
| 182 | // from the results, since we don't want the current entity to be discovered by the analysis. |
||
| 183 | // |
||
| 184 | // See https://github.com/insideout10/wordlift-plugin/issues/345 |
||
| 185 | $params['itemId'] = $entity_service->get_uri( $entity_being_edited->ID ); |
||
| 186 | |||
| 187 | } |
||
| 188 | |||
| 189 | // Finally output the params as `wlSettings` for JavaScript code. |
||
| 190 | wp_localize_script( $this->plugin_name, 'wlSettings', $params ); |
||
| 191 | |||
| 192 | } |
||
| 193 | |||
| 195 |
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.