libreform / wp-libre-form

Easy native HTML5 forms for WordPress. Version 1.5 is unmaintained, but works without issue. 2.0 has been rewritten from the ground, and can be found at https://github.com/libreform/libreform
https://wordpress.org/plugins/wp-libre-form
GNU General Public License v3.0
67 stars 27 forks source link

Plugins page & API #123

Closed k1sul1 closed 6 years ago

k1sul1 commented 6 years ago

Done unless you have any requests for changes.

Basically allows plugins to register as WPLF plugins and expose methods to wplf().

k1sul1 commented 6 years ago

And it also allows plugins to "tap into" add_submenu_page without having to deal with it's shit, which also helps keep the admin area free of otherwise useless plugin setting pages.

k1sul1 commented 6 years ago

Went a bit further. Anyone can still add their own stuff to the WPLF class instance, but at least I don't want to do it. Instead, it's now required to pass the plugin instance to wplf()->plugins->register([]).

$wplf = wplf();
$builder = WP_Libre_Formbuilder::instance();

$wplf->plugins->register([
  "name" => "Formbuilder",
  "description" => "Visual editor for the HTML impaired.",
  "link" => "https://github.com/k1sul1/wp-libre-formbuilder",
  "version" => WPLFB_VERSION,
  "instance" => $builder,
  "settings_page" => [$builder, "render_settings_page"],
]);

The plugins class is using getters to expose plugins with the name. Any public method in the instance is callable by anyone.

wplf()->plugins->Formbuilder->addField([])

k1sul1 commented 6 years ago

Screenshots:

no plugins builder activated settings page