https://github.com/doubleedesign/doublee-base-plugin
Common customisations for Double-E Design WordPress websites, and example of building a plugin in an OOP fashion.
https://github.com/doubleedesign/doublee-base-plugin
wordpress wordpress-development wordpress-plugin
Last synced: about 2 months ago
JSON representation
Common customisations for Double-E Design WordPress websites, and example of building a plugin in an OOP fashion.
- Host: GitHub
- URL: https://github.com/doubleedesign/doublee-base-plugin
- Owner: doubleedesign
- Created: 2023-06-25T07:13:02.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2025-02-23T03:22:01.000Z (over 1 year ago)
- Last Synced: 2025-02-23T04:20:45.691Z (over 1 year ago)
- Topics: wordpress, wordpress-development, wordpress-plugin
- Language: PHP
- Homepage:
- Size: 152 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# doublee-base-plugin
Common customisations for client websites.
- [Features](#features)
- [Welcome screen](#welcome-screen)
- [Global settings](#global-settings)
- ["Editor Plus" custom role](#editor-plus-custom-role)
- [CPT Index post type](#cpt-index-post-type)
- [Other features](#other-features)
- [General intentions and advice](#general-intentions-and-advice)
- [Information for developers](#information-for-developers)
- [Available filter hooks](#filter-hook-summary)
- [Changelog](#changelog)
---
## Features
### Welcome screen
The default WordPress welcome screen is replaced with a custom welcome screen that provides links to common actions relevant to the current site, using its post types, and the presence of particular plugins and options pages, and the current user's permissions to determine which actions to show.

The post types for which an "Add or edit" button is provided can be customised using the `doublee_welcome_screen_post_types` filter. For example, for clients who don't blog, you can remove the "Posts" button like so:
```php
add_filter('doublee_welcome_screen_post_types', function(array $post_types): array {
unset($post_types['post']);
return $post_types;
});
```
### Global settings
An ACF Options page is included for site-wide, client-specific global settings such as logos and contact information. As of version 4.1.1 it is located under `General Settings → (Site name)` in the admin menu (in older versions, you may find it under Appearance or as a top-level item). Where this information is used on the front-end is determined by the active theme and plugins.

If you are using ClassicPress, the logo field here automatically syncs with the ClassicPress logo setting in the General Settings page. It's kept in this options page as well because of the assumption that clients would expect to find it here.
The fields can be customised by plugins and themes using the `doublee_global_settings_fields` filter. If adding fields, please use the `doublee_global_settings_contributors` filter to ensure that the "About" tab content is accurate - this is helpful for troubleshooting.
> [!WARNING]
> Filtering out fields from the global settings in code _does not_ delete existing data for them from the database.
### Integrations settings
This was split off from the Global Settings in version 4.1.1 because it's more intuitive to have its own page. It provides a place to enter API Keys for things like Font Awesome and other third-party services to be used by custom themes and plugins.
The fields can be customised using the `doublee_integrations_settings_fields` filter. If adding fields, please use the `doublee_integrations_settings_contributors` filter to ensure that the "About" tab content is accurate - this is helpful for troubleshooting.
> [!WARNING]
> Filtering out fields from the integrations settings in code _does not_ delete existing data for them from the database.
### "Editor Plus" custom role
#### Permissions
- All the capabilities an Editor has
- Capabiltiies to add, edit, promote, and delete non-admin users
- All capabilities for Ninja Forms
- Capabilities to manage SmashBalloon Instagram and Facebook feed settings
#### How it works
- Upon plugin activation, the Editor Plus role is created based on the built-in Editor role, and some capabilities I commonly assign to clients are added to it
- Upon deactivation, users with the role are reverted to Editors
- Upon reactivation (without uninstallation), users who had the Editor Plus role should get it back (note: this is because a capability by the same name is left there unless the plugin is uninstalled; if you intend to use `current_user_can('editor_plus')` then this may not suit your needs)
- Upon uninstallation, the remnants of the role are totally wiped so if the plugin is reactivated again, custom roles must be manually reassigned.
### CPT Index post type
A "CPT Index" custom post type is registered, which creates post objects corresponding to custom post types. This enables CPT archives to be treated like posts in query contexts such as using them in ACF post object and relationship fields. Indexes are created and deleted automatically according to post type eligibility.

Indexes are a mostly "under the hood" post type used to provide functionality using features where we want to treat a CPT archive like a post or page.
- On the front-end, they redirect to their corresponding CPT archive pages by default, and functions like `get_the_permalink` should return the archive URL. Theme templates like `single-cpt_index.php` and `archive-cpt_index.php` should have no effect because the post type is not publicly queryable.
- On the back-end, admins can edit the index title, featured image, and excerpt as it is expected that those are the fields that will be used when treating indexes like pages in theme templates. Indexes cannot be manually created or deleted in the admin - their existence is entirely managed by the plugin logic.
Out of the box, indexes are created for non-built-in post types that are publicly queryable. Themes and plugins can alter which post types are "indexable" using the `doublee_cpt_indexable_post_types` filter.
```php
add_filter('doublee_indexable_custom_post_types', function(array $post_types): array {
$post_types[] = 'product';
return $post_types;
});
```
### Other features
- Customised admin menu ordering and sectioning
- Admin notices for required/recommended plugins
- Defaults for hiding and positioning of certain metaboxes in the admin edit screens (for simplicity)
- Defaults for hiding and positioning of certain columns in the admin list tables (for simplicity)
- An additional context for displaying metaboxes (`after_title`)
- Automatic basic `` tags (for sites that don't need a full SEO plugin)
- "Page Behaviour" options on edit screens for selected post types, providing options such as redirecting to a different URL.
---
## Information for developers
### Available filter hooks
| Filter | Arguments | Description |
|--------------------------------------------------------|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `doublee_welcome_screen_included_post_types` | `array $post_types` | Modify the post types for which "Add or edit" buttons are shown on the [welcome screen](#welcome-screen). |
| `doublee_welcome_screen_primary_links` | `array $links` | Modify the primary action links shown on the [welcome screen](#welcome-screen). |
| `doublee_welcome_screen_secondary_links` | `array $links` | Modify the secondary action links shown on the [welcome screen](#welcome-screen). |
| `doublee_indexable_custom_post_types` | `array $post_types` | Modify the post types for which [CPT Indexes](#cpt-index-post-type) are created. |
| `doublee_enable_page_behaviour_options_for_post_types` | `array $post_types` | Modify the post types for which "Page Behaviour" options are enabled on the edit screen. |
| `doublee_global_settings_fields` | `array $fields` | Modify the ACF fields available on the [global settings](#global-settings) screen. |
| `doublee_integrations_settings_fields` | `array $fields` | Modify the ACF fields available on the [integrations settings](#integrations-settings) screen. |
| `doublee_global_settings_contributors` | `array $names` | Modify the list of contributors shown on the "About" tab of the [global settings](#global-settings). |
| `doublee_integrations_settings_contributors` | `array $names` | Modify the list of contributors shown on the "About" tab of the [integrations settings](#integrations-settings). |
| `doublee_include_google_maps_api_key_global_setting` | `bool $include` | Whether to include the Google Maps API Key field in the [global settings](#global-settings). If a value was already stored before version 4.1.1, this defaults to true, otherwise it defaults to false. |
| `doublee_integrations_settings_third_party_settings_links` | `array $links` | Edit the links to third-party plugin settings pages listed in the Integrations settings screen. They are an associative array of label → URL pairs. |
### General intentions and advice
I use this with my own theme starterkits, and client-specific custom plugins, and other plugins I have developed to create custom sites with clear separation of concerns as much as is practical. As a guide:
- Code related to front-end design and content display belongs in the theme
- Custom functionality, custom post types, custom taxonomies, modifications to WordPress functionality (including the admin UI), site-specific data structures and management belong in plugins.
---
## Changelog
Please see [CHANGELOG.md](CHANGELOG.md).