Skip to content

Latest commit

 

History

History
204 lines (127 loc) · 9.81 KB

README.md

File metadata and controls

204 lines (127 loc) · 9.81 KB

License: AGPL v3 Docs gitmoji-changelog GitHub Workflow Status Codacy Badge GitHub stars Managed with Taiga.io

WP Plugin Advanced Leaflet

🐘 ⚗️ WP Plugin Advanced Leaflet

Check readme.txt for plugin usage documentation (required by WordPress.org).

This template is highly inspired from hlashbrooke/WordPress Plugin Template.

📘 Docs

See WordPress.org plugin at wordpress.org/plugins/wp-plugin-advanced-leaflet.

A technical documentation is also available at https://monogramm.github.io/wp-plugin-advanced-leaflet/. You can generate the PHP documentation using PHPDocumentor:

docker run --rm -v "${PWD}:/data" phpdoc/phpdoc:3 run

📈 Changes

All notable changes to this project will be documented in CHANGELOG file.

This (technical) CHANGELOG is generated with ❤️ by gitmoji-changelog.

This project adheres to Semantic Versioning.

🔖 Roadmap

See Taiga.io

🚧 Install

Docker

You can use the docker test environment to install this plugin. Check tests section for details.

Git clone

If you already have a WordPress instance, you can clone this plugin directly:

cd wp-content/plugins/
git clone https://github.com/Monogramm/wp-plugin-advanced-leaflet.git

ZIP Archive

You can build the WordPress plugin zip file using the following command:

./bin/generate-plugin-zip.sh 'wp-plugin-advanced-leaflet'

You can then manually install the plugin on your WordPress.

🚀 Usage

Easy management script

This template provides a shell script for easy management of your plugin.

./manage.sh

API functions

There are a few libraries built into it that will make a number of common tasks a lot easier.

Registering a new post type

Using the post type API and the wrapper function from the main plugin class you can easily register new post types with one line of code. For example if you wanted to register a listing post type then you could do it like this:

WP_Plugin_Advanced_Leaflet()->register_post_type( 'listing', __( 'Listings', 'wp-plugin-advanced-leaflet' ), __( 'Listing', 'wp-plugin-advanced-leaflet' ) );

Note that the WP_Plugin_Advanced_Leaflet() function name and the wp-plugin-advanced-leaflet text domain will each be unique to your plugin after you have used the cloning script.

This will register a new post type with all the standard settings. If you would like to modify the post type settings you can use the {$post_type}_register_args filter. See the WordPress codex page for all available arguments.

Registering a new taxonomy

Using the taxonomy API and the wrapper function from the main plugin class you can easily register new taxonomies with one line of code. For example if you wanted to register a location taxonomy that applies to the listing post type then you could do it like this:

WP_Plugin_Advanced_Leaflet()->register_taxonomy( 'location', __( 'Locations', 'wp-plugin-advanced-leaflet' ), __( 'Location', 'wp-plugin-advanced-leaflet' ), 'listing' );

Note that the WP_Plugin_Advanced_Leaflet() function name and the wp-plugin-advanced-leaflet text domain will each be unique to your plugin after you have used the cloning script.

This will register a new taxonomy with all the standard settings. If you would like to modify the taxonomy settings you can use the {$taxonomy}_register_args filter. See the WordPress codex page for all available arguments.

Defining your Settings Page Location

Using the filter {base}menu_settings you can define the placement of your settings page. Set the location key to options, menu or submenu. When using submenu also set the parent_slug key to your preferred parent menu, e.g themes.php. For example use the following code to let your options page display under the Appearance parent menu.

$settings['location'] = 'submenu';
$settings['parent_slug'] = 'themes.php';

See respective codex pages for location option defined below:

Calling your Options

Using the Settings API and the wrapper function from the main plugin class you can easily store options from the WP admin like text boxes, radio options, dropdown, etc. You can call the values by using id that you have set under the settings_fields function. For example you have the id - text_field, you can call its value by using get_option('wp_plugin_advanced_leaflet_text_field'). Take note that by default, this plugin is using a prefix of wp_plugin_advanced_leaflet_ before the id that you will be calling, you can override that value by changing it under the __construct function $this->base variable;

What does this template offers

This template includes the following features:

  • Plugin headers as required by WordPress & WordPress.org
  • Readme.txt file as required by WordPress.org
  • Main plugin class
  • Full & minified Javascript files
  • Grunt.js support
  • Standard enqueue functions for the dashboard and the frontend
  • A library for easily registering a new post type
  • A library for easily registering a new taxonomy
  • A library for handling common admin functions (including adding meta boxes to any post type, displaying settings fields and display custom fields for posts)
  • A complete and versatile settings class like you see here
  • A .pot generation / update to make localisation easier
  • Full text of the AGPLv3 license
  • Automated tests and code quality monitoring using PHPUnit, PHPCS and ESLint
  • GitHub and GitLab templates for Issues and Pull Requests
  • Docker dev and test environments for easy integration into any CI (with current integration to Travis CI)
  • Plugin install and uninstall hooks
  • Easy class to manage shortcodes

See the changelog for a complete list of changes as the template develops.

✅ Run tests

You can use the docker-compose file to run a dev / test environment:

./manage.sh start

You can now access a local WordPress env at http://localhost:8080.

Follow the tests logs (Ctrl + C to exit):

./manage.sh logs sut

The sut container will run:

  • PHPUnit for this plugin
  • PHPCS for Code quality

You can also check Travis-CI Build Status for the latest tests results.

To reset your test environment, you can just drop the containers and the persisted data:

./manage.sh reset

👤 Authors

Monogramm

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page. Check the contributing guide.

👍 Show your support

Give a ⭐ if this project helped you!

📄 License

Copyright © 2020 Monogramm.
This project is AGPL v3 licensed.


This README was generated with ❤️ by readme-md-generator