You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Plugin Main class will be used as the plugin’s most central class and will be used to bootstrap the Plugin Check plugin. Using a class allows all bootstrapping logic for the Plugin Check plugin to be consolidated in a single class, separating it from check logic and making it easier to maintain. This class will be responsible for setting up the plugin checker by registering hooks in WordPress and any other logic required, for example:
Adding hooks and filters to register the plugin check WP-CLI command
Enqueuing any assets required for the Plugin Check admin screen
Localization support
Plugin_Main class will be instantiated in the plugin-check.php file of the Plugin Check plugin. It will accept a single $main_file parameter in its constructor which is used to create the plugin context. The context of the plugin will be handled by the protected property $context (Plugin_Context).
Acceptance Criteria
A new Plugin_Main class is created
The class contains a single protected property named $context
The class __construct() method accepts a single parameter
(string) $main_file - A string representing the absolute path to the plugin main file
The $main_file parameter is passed to a new instances of the Plugin_Context class
The new Plugin_Context instances is assigned to the protected $context property
An empty add_hooks method exists in the Plugin_Main class to be updated later to register hooks to WordPress
A new Plugin_Context class is created. This class will be empty and setup as a basic scaffold for Create Plugin_Context class #5
The plugin-check.php file is updated to include the following:
Constant WP_PLUGIN_CHECK_VERSION defined with the plugin version
Constant WP_PLUGIN_CHECK_MINIMUM_PHP defined with the minimum PHP version required for the plugin check plugin to work
A wp_plugin_check_load function exists which:
Checks the current PHP version is greater than the WP_PLUGIN_CHECK_MINIMUM_PHP constant
Checks the vendor/autoload.php file exists in the plugin
If the above checks pass
The vendor/autoload.php file is required in
The Plugin_Main class is instantiated passing __FILE__ into the constructor
The add_hooks() method is called on the instantiated Plugin_Main object
Description
The Plugin Main class will be used as the plugin’s most central class and will be used to bootstrap the Plugin Check plugin. Using a class allows all bootstrapping logic for the Plugin Check plugin to be consolidated in a single class, separating it from check logic and making it easier to maintain. This class will be responsible for setting up the plugin checker by registering hooks in WordPress and any other logic required, for example:
Plugin_Mainclass will be instantiated in theplugin-check.phpfile of the Plugin Check plugin. It will accept a single$main_fileparameter in its constructor which is used to create the plugin context. The context of the plugin will be handled by the protected property$context(Plugin_Context).Acceptance Criteria
Plugin_Mainclass is created$context__construct()method accepts a single parameter(string) $main_file- A string representing the absolute path to the plugin main file$main_fileparameter is passed to a new instances of thePlugin_ContextclassPlugin_Contextinstances is assigned to the protected$contextpropertyadd_hooksmethod exists in thePlugin_Mainclass to be updated later to register hooks to WordPressPlugin_Contextclass is created. This class will be empty and setup as a basic scaffold for Create Plugin_Context class #5plugin-check.phpfile is updated to include the following:WP_PLUGIN_CHECK_VERSIONdefined with the plugin versionWP_PLUGIN_CHECK_MINIMUM_PHPdefined with the minimum PHP version required for the plugin check plugin to workwp_plugin_check_loadfunction exists which:WP_PLUGIN_CHECK_MINIMUM_PHPconstantvendor/autoload.phpfile exists in the pluginvendor/autoload.phpfile is required inPlugin_Mainclass is instantiated passing__FILE__into the constructoradd_hooks()method is called on the instantiatedPlugin_Mainobject