-
Notifications
You must be signed in to change notification settings - Fork 0
/
class-pb-page-customizer-add-on.php
138 lines (116 loc) · 3.37 KB
/
class-pb-page-customizer-add-on.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
class PPB_Page_Customizer_Addon{
/**
* PPB_Page_Customizer_Addon Instance of main plugin class.
*
* @var object PPB_Page_Customizer_Addon
* @access private
* @since 1.0.0
*/
private static $_instance = null;
/**
* The token.
* @var string
* @access public
* @since 1.0.0
*/
public static $token;
/**
* The version number.
* @var string
* @access public
* @since 1.0.0
*/
public static $version;
/**
* Pootle PB Page Customizer Add-on plugin directory URL.
*
* @var string Plugin directory
* @access private
* @since 1.0.0
*/
public static $url;
/**
* Pootle PB Page Customizer Add-on plugin directory Path.
*
* @var string Plugin directory
* @access private
* @since 1.0.0
*/
public static $path;
/**
* Main Pootle PB Page Customizer Add-on Instance
*
* Ensures only one instance of Storefront_Extension_Boilerplate is loaded or can be loaded.
*
* @since 1.0.0
* @return PPB_Page_Customizer_Addon instance
*/
public static function instance() {
if ( null == self::$_instance ) {
self::$_instance = new self();
}
return self::$_instance;
} // End instance()
/**
* Constructor function.
*
* @access private
* @since 1.0.0
*/
private function __construct() {
self::$token = 'ppb-addon-boilerplate';
self::$url = plugin_dir_url( __FILE__ );
self::$path = plugin_dir_path( __FILE__ );
self::$version = '1.0.0';
add_action( 'init', array( $this, 'init' ) );
} // End __construct()
public function init() {
if ( class_exists( 'Pootle_Page_Builder' ) ) {
$this->add_actions();
$this->add_filters();
}
} // End init()
private function add_actions() {
//Adding front end JS and CSS in /assets folder
add_action( 'pootlepb_enqueue_admin_scripts', array( $this, 'enqueue' ) );
add_action( 'pootlepb_metabox_end', array( $this, 'ppb_page_customizer_meta_additions', ) );
} // End add_actions()
private function add_filters() {
//Add Pootle Page Builder Filter hooks here
} // End add_filters()
public function pb_metabox_additions() {
global $post;
$pageSettings = get_post_meta( $post->ID, 'pootlepage-page-settings', true );
if ( empty( $pageSettings ) ) {
$pageSettings = '{}';
}
$hideElements = get_post_meta( $post->ID, 'pootlepage-hide-elements', true );
if ( empty( $hideElements ) ) {
$hideElements = '{}';
}
?>
<input type="hidden" id="page-settings" name="page-settings" value="<?php esc_attr_e( $pageSettings ) ?>"/>
<input type="hidden" id="hide-elements" name="hide-elements" value="<?php esc_attr_e( $hideElements ) ?>"/>
<div id="hide-element-dialog" data-title="<?php esc_attr_e( 'Hide Elements', 'ppb-panels' ) ?>" class="panels-admin-dialog">
<?php
$hideElementsFields = ppb_pc_hide_elements_fields();
pootlepb_hide_elements_dialog_echo( $hideElementsFields );
?>
</div>
<div id="page-setting-dialog" data-title="<?php esc_attr_e( 'Page Settings', 'ppb-panels' ) ?>"
class="panels-admin-dialog">
<?php
$pageSettingsFields = ppb_pc_page_settings_fields();
pootlepb_dialog_form_echo( $pageSettingsFields );
?>
</div>
<?php
}
public function enqueue() {
$token = self::$token;
$url = self::$url;
wp_enqueue_style( $token . '-css', $url . '/assets/admin.css' );
wp_enqueue_script( $token . '-js', $url . '/assets/admin.js', array( 'jquery' ) );
} // End enqueue()
}