Name: CSS_Customizer
Owner: 10up
Description: Drop in class for implementing a custom CSS editor either as a standalone settings page or a meta box.
Created: 2013-02-08 16:05:54.0
Updated: 2017-06-03 03:11:26.0
Pushed: 2013-10-30 17:13:14.0
Homepage: null
Size: 249
Language: PHP
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Drop in class for implementing a custom CSS editor either as a standalone settings page or a meta box.
/plugin-name/includes/css-customizer
TenUp_CSS_Customizer.php
class in your pluginThe TenUp_CSS_Customizer
class takes several options opon instantiation:
$handle
- The first parameter is the unique string used to identify the instance. This string will be used in rewrites, option names, and permalinks, so it should be URL and database safe. Defaults to 'tenup_css'.$scheme
- Either 'page' when using the class in a settings page or 'meta' when using the page as a meta box. Defaults to 'page.'$settings
- Associative array of translated labels and post types for use with the meta box.The 'tenup_css_customizer_instances' filter will return an associative array of all instances. For example, if the class is instantiated with default options:
new TenUp_CSS_Customizer();
The filter will return:
array(
'tenup_css' => object of type TenUp_CSS_Customizer
)
If multiple instances exist, they will all be returned by the filter.
The class uses a set of custom permalinks to fetch and return the custom CSS document. However, these permalinks will not work unless rewrite rules are flushed after they're added.
To make life easier, you can add a do_action()
call to your plugin activation hook to force the rewrite rules into the system.
new TenUp_CSS_Customizer();
function my_plugin_activation() {
do_action( 'tenup_css_register_rewrites' );
flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'my_plugin_activation' );