PhpStorm 2024.3 Help

WordPress code completion and navigation

To take advantage of coding assistance provided by PhpStorm, the WordPress installation you are working with must be configured in the project as an external library. This way, the WordPress core files will be involved in indexing, which is the basis for resolving references and providing code completion, navigation, search, and other PhpStorm's coding-assistance features.

Hooks support

PhpStorm indexes all hooks declared in the WordPress core and in the included plugins. This makes the basis for coding assistance when working with hooks.

Hook names completion

Hook names are available in code completion of standard parameters for action and filter functions add_action() and add_filter().

  1. Start typing the declaration of an add_action() or add_filter() function.

  2. Press Ctrl+Space and choose the relevant parameter from the list.

    ps_wp_hooks_completion.png

You can navigate from a hook registration (add_action() or add_filter() functions) to the hook invocation (functions like do_action() or apply_filters()).

  • Click ps_wp_hooks_navigation_gutter_icon.png in the gutter area next to the hook registration.

    ps_wp_hooks_navigation.png

    PhpStorm opens the file where the hook is invoked and places the caret at the invocation method, in the current example it is do_action.

    If there are several hook invocations, PhpStorm prompts you to choose the relevant one from the popup.

    ps_wp_hooks_navigation.png
  • Click ps_wp_hooks_navigation_gutter_icon.png in the gutter area next to the hook invocation function.

    ps_wp_hooks_navigation.png

    PhpStorm opens the file where the hook is registered and places the caret at the registration method.

    If there are several hook registrations, PhpStorm prompts you to choose the relevant one from the popup.

    ps_wp_hooks_navigation.png

Go to callback function from a hook registration

You can navigate to the declaration or usages of the callback function that is specified as the second parameter of a hook registration (add_action() or add_filter() function).

To go to the callback function declaration:

  • With the Ctrl key pressed, hover over the relevant parameter. PhpStorm displays a popup information message with the definition of the function or method specified as this parameter:

    ps_wp_hooks_callback.png

    The parameter turns into a link. When you click this link, PhpStorm opens the file where the function or method was declared and places the caret at thedeclaration.

To go to the callback function usages:

  • Place the caret at the relevant parameter and press Alt+F7 or choose Edit | Find Usages | Find Usages from the main menu. The Find tool window opens with a new tab showing all the detected occurrences of the function.

Viewing the official WordPress documentation from PhpStorm

You can view the official WordPress Documentation at http://wordpress.org/ right from the PhpStorm editor.

  1. Select the text you are interested in.

  2. From the context menu of the selection, choose Search on WordPress.org.

    PhpStorm opens the page with the relevant documentation in the default browser.

Last modified: 17 June 2024