Download the PHP package dark-kitt/wordpress-theme-configuration without Composer
On this page you can find all versions of the php package dark-kitt/wordpress-theme-configuration. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dark-kitt/wordpress-theme-configuration
More information about dark-kitt/wordpress-theme-configuration
Files in dark-kitt/wordpress-theme-configuration
Package wordpress-theme-configuration
Short Description WordPress theme configuration MU-Plugin, which includes multiple WordPress hooks to improve themes
License CC-BY-4.0
Informations about the package wordpress-theme-configuration
WordPress Theme Configuration
Project: Part 1, Part 2, Part 3
Introduction
A base WordPress theme configuration written as MU-Plugin, which includes multiple WordPress hooks to improve your theme. Configure the selected theme in the functions.php file with the listed methods below.
The Autoloader MU-Plugin is required to load this plugin by WordPress. After composer update copy the mu-plugin-autoloader.php file inside of the /mu-plugins
directory, to load the WordPress Theme Configuration MU-Plugin automatically.
Note: The REST API uses the JWT Authentication for WP REST API to secure the API endpoints.
General WordPress configurations are placed in the base-configuration.php file. For each type / part of WordPress, you can find a PHP Trait in the /traits
directory. E.g.: attachment.php file for Media Library settings, post.php file for the Post settings... etc.
Note: The Gutenberg editor is always disabled! If WP_HOME is different than WP_SITEURL the Gutenberg editor throws multiple errors. If you are interested, take a look at Github WordPress / gutenberg (issue 1761).
Use ACF (Advanced Custom Fields) or install the Classic Editor Plugin, to add content to each post / page.
Methods
- get_instance()
- set_up_theme()
- post()
- page()
- attachment()
- comments()
- menu()
- custom_post_type()
- REST_API()
Control each method with the passed arguments array or use the default settings. If you are interested in the defaults, want to check out each argument, or set your own custom defaults, take a look inside the trait files in the /trait
directory.
Requirements
to maintain content (optional)
Note: If you need an easy way to install this project with all requirements take a look at WordPress Boilerplate project.
Installation
If you have a specific path to your MU-Plugin directory, please add the following lines to your composer.json file.
Afterward, configure the plugin with the functions.php
file in the /themes/your-theme
directory. Don't forget to insert the JWT Authentication for WP REST API if you want to use the REST_API()
method.
Note: For a specific commit of your VCS Repo "require": { "vendor/repo_name": "dev-main#eec8698" }
(branch#commit).
common composer cmds
Autoloader for WordPress MU-Plugins
The richardtape/subdir-loader.php Github Gist. Copy the mu-plugin-autoloader.php file inside of the /mu-plugins
directory, to load MU-Plugins automatically.
Methods [ Arguments ]
General WordPress configurations are placed in the base-configuration.php file. For each type / part of WordPress, you can find a PHP Trait in the /traits
directory. Check out the example.function.php file to get knowledge about the usage and how you can configure your theme inside of the functions.php file in your /themes/your-theme
directory.
get_instance()
Executes the singleton instance and return itself.
set_up_theme( $wpdb, $wp_rewrite, $pagenow, array $args = defaults )
Set the defined globals $wpdb
, $wp_rewrite
and $pagenow
and call the main theme set up method. This method will also call the meta_box();
and the company_settings();
methods, which includes the custom SEO meta box, the custom Homepage meta box, the custom Error Page meta box and the Company menu page. The set_up_theme()
method gives you the ability to install languages for WordPress and sets further settings for ACF (Advanced Custom Fields). All default arguments are listed below.
post( array $args = defaults )
Use this method to modify the default post section. All default arguments are listed below.
Note: Use ACF (Advanced Custom Fields) or install the Classic Editor Plugin, to add content to each post.
page( array $args = defaults )
Use this method to modify the default page section. All default arguments are listed below.
Note: Use ACF (Advanced Custom Fields) or install the Classic Editor Plugin, to add content to each page.
attachment( array $args = defaults )
Set up options for the Media Library. All default arguments are listed below.
Note: If another theme was previously activated and the new upload directory is different, check the project for the old upload directory and when it is unnecessary delete it manually.
Note: That this method can add also the "Find Duplicates" attachments modal, which goes through the database and compares images to find duplicates.
comments( array $args = defaults )
Remove completely Comments from WordPress.
menu( array $args = defaults )
This method will replace the Menu (nav-menus.php) section from an Appearance submenu page to a top-level page underneath the Pages section. Additionally, the method adds the support for the role editor to edit the Menu section (=> editors can edit menus).
custom_post_type( array $args = defaults )
This is a custom register_post_type method, which includes some additional options. A slug is required to register custom menu locations and to use the custom homepage meta box. All default arguments are listed below.
REST_API( array $args = defaults )
This REST_API()
method uses the JWT Authentication for WP REST API to secure the API endpoints. It uses also PHP Mailer to send emails via a REST route. In the examples below, you can see how you can optionally use this instance to configure PHP Mailer for your forms. You can also send the server settings via a POST body request with axios, jQuery, or any other way to send a request.
While you configure your custom REST-API, it is required to create a user with the role rest_api_user. This is important because the user with the role rest_api_user has only access to the REST-API and not to the backend system.
If you are using Postman for testing the API request, to retrieve the token from JWT Authentication for WP REST API, send the username
and password
as post body (raw/json) data. The \WP_REST_Server::CREATABLE
or other methods are described on developer.wordpress.org. Please take a deeper look inside the rest-api.php file to get more information about the handling.
Use the existing instance to push additional methods ($kitt_instance->rest_routes['posts'][] = []
) to existing routes or register totally new routes ($kitt_instance->rest_routes['new_route'][] = []
) to your REST API configuration.
Note: The axios GET (READABLE) request can not send data via the body.
EXAMPLE: define your custom REST-API
EXAMPLE: configuration for PHP Mailer in the functions.php file
EXAMPLE: for adding a custom REST route in the functions.php file
Note: The Gutenberg editor is always disabled! If WP_HOME is different from WP_SITEURL the Gutenberg editor throws multiple errors. If you are interested, take a look at Github WordPress / gutenberg (issue 1761).
Use ACF (Advanced Custom Fields) or install the Classic Editor Plugin, to add content to each post / page.