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