Skip to content

Features & Customization

Daniel M. Hendricks edited this page Nov 14, 2017 · 2 revisions

I tried to include many examples in this plugin. Depending on your needs, you won't need many of them.

TGM Plugin Activation

TGM Plugin Activation (TGMPA) is a class that allows you to easily require or recommend other dependent plugins. I mainly included it to prompt the user to download the Carbon Fields Loader if CF is not included with the plugin (via Composer), but you can configure it to require/recommend other plugins as well.

You can modify which plugins it requires/recommends in app/TGMPA.php. Documentation can be found on Configuring TGMPA page.

Removal

  1. Remove the "tgmpa/tgm-plugin-activation" line from the composer.json require section and then run composer update.
  2. Delete the app/TGMPA.php file.
  3. Remove the 2 lines that reference TGMPA in app/Plugin.php.

WordPress Settings API Class

In case you don't need/want the extra overhead of Carbon Fields and just want a simple settings page, I have included an example of the WordPress Settings API Class (WPSAC).

Removal

  1. Remove the "tareq1988/wordpress-settings-api-class" line from the composer.json require section and then run composer update.
  2. Delete the app/Settings/WPSAC_Page.php file.
  3. Remove/comment the new Settings\WPSAC_Page(); line from app/Plugin.php.

Carbon Fields

Carbon Fields is useful for creating custom fields, metaboxes and plugin settings pages. If you just want a basic settings page without the extra overhead, there is an example of using WPSAC instead.

Removal

If you don't need Carbon Fields and/or want to use something else, you can do the following:

  1. Remove all lines from app/ that reference Carbon_Fields.
  2. app/Plugin.php:
    • Remove/comment the new Settings\Carbon_Page(); line from app/Plugin.php.
    • Modify the init() function to remove checking for Carbon Fields.
    • Remove the verify_dependencies( 'carbon_fields' ) line from the load_plugin() function.

Important Note: This plugin makes extensive use of Carbon Fields in its examples, so you will have to remove/change those as well. Basically, refresh the plugin and replace/remove/comment out any errors.

Serialized Data Store

The Serialized Datastore allows you to store option field values as a serialized array instead of multiple database rows.

An example of using it with a complex field type is provided in app/Settings/Carbon_Page.php (search for "Serialized_Theme_Options_Datastore").

Removal

  1. Remove the "Carbon_Fields\Datastore\Datastore\" line from the composer.json autoload section and then run composer update.
  2. Delete the app/Datastores directory.
  3. Remove all lines from app/Settings/Carbon_Page.php that reference "Serialized_Theme_Options_Datastore".