-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
After you have added the Zukit framework in your project folder you can start using it.
There are three simple steps involved in doing so:
- Create a new class for your plugin/theme.
- Init class instance with the plugin/theme path.
- Provide the plugin/theme configuration.
class my_Plugin extends zukit_Plugin {
}
❌ Attention! You should not define a class constructor __construct
in a new class.
Since zukit_Plugin
is based on the singleton concept, you can access the instance of your class through the static method instance
. But be sure to pass the path for your plugin/theme there at the first call (the easiest way is to pass the magic constant __FILE__
). For convenience, I recommend creating a function that makes it easier to access the instance of your class:
function myplugin($file = null) {
return my_Plugin::instance($file);
}
/*
Plugin Name: My Plugin
Description: Wonderful plugin that will change this world.
Version: 1.0.0
Author: John Appleseed
*/
defined('ABSPATH') || die('No direct script access allowed!');
// some other logic...
// somewhere at the bottom of the my-plugin.php file which contains your plugin description
myplugin(__FILE__);
❗ If you want to use the built-in compatibility test then it is better to initialize your plugin/theme using the method described in Compatibility Check.
If you need to do something in the class constructor, you should override the construct_more
method.
🙅 Attention! You cannot use the functions for working with
options
(see the Options section) inconstruct_more
method, since theoptions
there are not yet synchronized with the class methods:
protected function construct_more() {
add_action('add_attachment', [$this, 'attachment_save']);
add_filter('attachment_fields_to_edit', [$this, 'add_attachment_field'], 10, 2);
// you should avoid ‘options’ getter and setter here!!
// wrong!!!
// if($this->is_option('option1')) {
// add_action('pre_get_posts', [$this, 'pre_get_attachments']);
// }
}
You also need to customize the framework to work with your plugin or theme - this is done via configuration.
Zukit - The Developer Framework for WordPress