godaddy-wordpress / godaddy-wordpress/wc-plugin-framework

Create abstract admin classes

Open
#158 3 comments 0 reactions 0 assignees View on GitHub
Feature
Dominant language
PHP
Stars
146
Forks
43
Avg merge
21m
Merged PRs (30d)
3

Description

A lot of our plugins are using dedicated admin pages outside of WC Settings area. Some plugins simply have a dedicated settings page while others have more complex admin areas with settings, list tables, etc (Memberships, CSV Import/Export). To create those admin areas, a lot of boilerplate code is needed, and each plugin implements things a bit different. This makes it harder to maintain.

We should look into creating some sort of abstraction that would allow plugins to easily register dedicated admin areas/pages/settings, with support for tabs & sections out-of-the-box. This could reduce boilerplate code and provide a more consistent experience & architecture in plugins.

For settings pages, we could probably subclass `WC_Settings_Page` and make it more generic, to support adding settings pages to other plugin admin areas, rather than to WC Settings.

I would imagine some kind of abstract admin class that would already have all the plumbing required for adding the menu/submenu pages, tabs and sections. The subclass would then simply need to provide a list of tabs & sections and callbacks for rendering those.

Perhaps something like

``` php
Admin_Area extends SV_WC_Admin_Area {

public __construct() {

$this->tabs = array(
'tab_1' => array(
'label' => __( 'Tab 1' ),
'sections' => array(
'section_1' => __( 'Section 1' ),
'section_2' => __( 'Section 2' ),
),
),
'tab_2' => __( 'Tab 2' ),
);

}

public function render_tab_1( $current_section ) {
// .. render the tab...
}

}
```

In summary, some of the features that would be nice:
- a common structure for adding dedicated admin areas/pages
- built-in support for tabs and sections
- built-in support for the plumbing required for settings pages
- making `current_tab` && `current_section` available in JS (similar to `pagenow`)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.