Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Adjust to Class-Based Core Setup #163

Open
cjkoepke opened this issue Oct 24, 2019 · 1 comment
Open

Adjust to Class-Based Core Setup #163

cjkoepke opened this issue Oct 24, 2019 · 1 comment
Assignees
Labels
Enhancement New feature or request

Comments

@cjkoepke
Copy link

cjkoepke commented Oct 24, 2019

Is your enhancement related to a problem? Please describe.
Yes. Basically, right now, if you go to /includes/core.php, we use a helper function to make calling hooks easier. i.e.

function setup() {
	$n = function( $function ) {
		return __NAMESPACE__ . "\\$function";
	};

	add_action( 'after_setup_theme', $n( 'example_function_name' ) );
}

The point here, it seems, is to allow an easy reference function for namespace-scoped functions. However, in IDE's like PhpStorm, you cannot click-jump to its declaration like you would a normal function.

Describe the solution you'd like
Moving to a class-based setup would allow for namespace usability with a similar signature, but keep the indexing capabilities of modern IDE's intact:

class Setup {
    public function __contstruct() {
        add_action( 'after_setup_theme', [ $this, 'example_function_name'] );
    }

    public static function example_function_name() {
      // do something
   }
}

Then, it's a minor change do the initial function call:

new TenUpScaffold\Core\Setup();

Additional context
Jumping around the codebase via click-jumping is super efficient, and the disconnect between the main entry-point of the theme code and other areas that utilize this pattern is a bit disjointed.

@jeffpaul jeffpaul added the Enhancement New feature or request label Nov 8, 2019
@cjkoepke
Copy link
Author

@timwright12 @samikeijonen @christianc1 Happy to open a PR for this if no one has objections.

@timwright12 timwright12 removed their assignment Jan 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants