| Conditions | 6 |
| Paths | 16 |
| Total Lines | 88 |
| 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 |
||
| 153 | public function enqueue_scripts() { |
||
| 154 | |||
| 155 | /** |
||
| 156 | * This function is provided for demonstration purposes only. |
||
| 157 | * |
||
| 158 | * An instance of this class should be passed to the run() function |
||
| 159 | * defined in Wordlift_Loader as all of the hooks are defined |
||
| 160 | * in that particular class. |
||
| 161 | * |
||
| 162 | * The Wordlift_Loader will then create the relationship |
||
| 163 | * between the defined hooks and the functions defined in this |
||
| 164 | * class. |
||
| 165 | */ |
||
| 166 | |||
| 167 | // Enqueue the admin scripts. |
||
| 168 | wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/1/admin.js', array( |
||
| 169 | 'jquery', |
||
| 170 | 'underscore', |
||
| 171 | 'backbone', |
||
| 172 | ), $this->version, false ); |
||
| 173 | |||
| 174 | |||
| 175 | $can_edit_wordlift_entities = current_user_can( 'edit_wordlift_entities' ); |
||
| 176 | |||
| 177 | /* |
||
| 178 | * People that can create entities will see the scope set in the wp-config.php file (by default `cloud`). People |
||
| 179 | * that cannot edit create entities will always see the local entities. |
||
| 180 | * |
||
| 181 | * @see https://github.com/insideout10/wordlift-plugin/issues/839 |
||
| 182 | */ |
||
| 183 | $autocomplete_scope = $can_edit_wordlift_entities ? WL_AUTOCOMPLETE_SCOPE : "local"; |
||
| 184 | |||
| 185 | // Set the basic params. |
||
| 186 | $params = array( |
||
| 187 | // @todo scripts in admin should use wp.post. |
||
| 188 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
||
| 189 | // @todo remove specific actions from settings. |
||
| 190 | 'action' => 'entity_by_title', |
||
| 191 | 'datasetUri' => $this->configuration_service->get_dataset_uri(), |
||
| 192 | 'language' => $this->configuration_service->get_language_code(), |
||
| 193 | 'link_by_default' => $this->configuration_service->is_link_by_default(), |
||
| 194 | // Whether the current user is allowed to create new entities. |
||
| 195 | // |
||
| 196 | // @see https://github.com/insideout10/wordlift-plugin/issues/561 |
||
| 197 | 'can_create_entities' => $can_edit_wordlift_entities ? 'yes' : 'no', |
||
| 198 | 'l10n' => array( |
||
| 199 | 'You already published an entity with the same name' => __( 'You already published an entity with the same name: ', 'wordlift' ), |
||
| 200 | 'logo_selection_title' => __( 'WordLift Choose Logo', 'wordlift' ), |
||
| 201 | 'logo_selection_button' => array( 'text' => __( 'Choose Logo', 'wordlift' ) ), |
||
| 202 | 'Type at least 3 characters to search...' => _x( 'Type at least 3 characters to search...', 'Autocomplete Select', 'wordlift' ), |
||
| 203 | 'No results found for your search.' => _x( 'No results found: try changing or removing some words.', 'Autocomplete Select', 'wordlift' ), |
||
| 204 | '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' ), |
||
| 205 | ), |
||
| 206 | 'wl_autocomplete_nonce' => wp_create_nonce( 'wordlift_autocomplete' ), |
||
| 207 | 'autocomplete_scope' => $autocomplete_scope, |
||
| 208 | /** |
||
| 209 | * Allow 3rd parties to define the default editor id. This turns useful if 3rd parties load |
||
| 210 | * or change the TinyMCE id. |
||
| 211 | * |
||
| 212 | * The editor id is currently referenced by `src/coffee/editpost-widget/app.services.EditorAdapter.coffee`. |
||
| 213 | * |
||
| 214 | * @since 3.19.4 |
||
| 215 | * |
||
| 216 | * @see https://github.com/insideout10/wordlift-plugin/issues/848 |
||
| 217 | * |
||
| 218 | * @param string $editor The default editor id, by default `content`. |
||
| 219 | */ |
||
| 220 | 'default_editor_id' => apply_filters( 'wl_default_editor_id', 'content' ), |
||
| 221 | ); |
||
| 222 | |||
| 223 | // Set post-related values if there's a current post. |
||
| 224 | if ( null !== $post = $entity_being_edited = get_post() ) { |
||
| 225 | |||
| 226 | $params['post_id'] = $entity_being_edited->ID; |
||
| 227 | $entity_service = Wordlift_Entity_Service::get_instance(); |
||
| 228 | $params['entityBeingEdited'] = isset( $entity_being_edited->post_type ) && $entity_service->is_entity( $post->ID ) && is_numeric( get_the_ID() ); |
||
| 229 | // We add the `itemId` here to give a chance to the analysis to use it in order to tell WLS to exclude it |
||
| 230 | // from the results, since we don't want the current entity to be discovered by the analysis. |
||
| 231 | // |
||
| 232 | // See https://github.com/insideout10/wordlift-plugin/issues/345 |
||
| 233 | $params['itemId'] = $entity_service->get_uri( $entity_being_edited->ID ); |
||
| 234 | |||
| 235 | } |
||
| 236 | |||
| 237 | // Finally output the params as `wlSettings` for JavaScript code. |
||
| 238 | wp_localize_script( $this->plugin_name, 'wlSettings', $params ); |
||
| 239 | |||
| 240 | } |
||
| 241 | |||
| 243 |
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.