-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom_body_class.php
61 lines (48 loc) · 1.63 KB
/
custom_body_class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/*
Plugin Name: Custom Body Class
Plugin URI: https://a.lup.dev
Description: A plugin which allows you to add a custom CSS class the HTML body tag
Version: 0.7.3
Author: Andrei Lupu
Author URI: https://a.lup.dev
Author Email: [email protected]
Text Domain: wp-custom-body-class
License: GPL-2.0+
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
Domain Path: /lang
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
// ensure EXT is defined
if ( ! defined( 'EXT' ) ) {
define( 'EXT', '.php' );
}
require 'core/bootstrap' . EXT;
$config = include 'plugin-config' . EXT;
// set textdomain
custom_body_class::settextdomain( $config['textdomain'] );
$defaults = include 'plugin-defaults' . EXT;
$current_data = get_option( $config['settings-key'] );
if ( $current_data === false ) {
add_option( $config['settings-key'], $defaults );
} else if ( count( array_diff_key( $defaults, $current_data ) ) != 0 ) {
$plugindata = array_merge( $defaults, $current_data );
update_option( $config['settings-key'], $plugindata );
}
# else: data is available; do nothing
// Load Callbacks
// --------------
$basepath = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
$callbackpath = $basepath . 'callbacks' . DIRECTORY_SEPARATOR;
custom_body_class::require_all( $callbackpath );
require_once( plugin_dir_path( __FILE__ ) . 'class-custom_body_class.php' );
if ( ! function_exists( 'init_custom_body_class_plugin' ) ) {
function init_custom_body_class_plugin () {
global $custom_body_class_plugin;
$custom_body_class_plugin = CustomBodyClassPlugin::get_instance();
}
}
add_action('init', 'init_custom_body_class_plugin');