-
Notifications
You must be signed in to change notification settings - Fork 1
/
class.wiz-ee-wig-editor.php
80 lines (51 loc) · 2.33 KB
/
class.wiz-ee-wig-editor.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
<?php
/**
* @package Wiz-Ee-Wig Editor
* @since 0.1.0
*/
if ( ! class_exists( 'WizEeWig_Editor' ) ) {
class WizEeWig_Editor {
private static $instance;
public static function instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
private function __construct() {
add_action( 'widgets_init', array( $this, 'widget_init' ) );
add_action( 'load-widgets.php', array( $this, 'scripts_styles' ) );
add_action( 'widgets_admin_page', array( $this, 'output_editor' ) );
add_action( 'customize_controls_print_footer_scripts', array( $this, 'output_editor' ) );
}
public function widget_init() {
register_widget( 'WEWE_Widget' );
}
public function output_editor() { ?>
<div id="wewe">
<div id="wewe-container">
<?php
$settings = array(
'textarea_rows' => 15
);
wp_editor( '', 'wewe-editor', $settings );
?>
<div id="wewe-buttons">
<input type="hidden" id="wewe-id" value="">
<input type="hidden" id="wewe-type" value="">
<a href="#" id="wewe-save" class="button button-primary">Save</a>
<a href="#" id="wewe-close" class="button button-primary">Close</a>
</div>
</div>
</div>
<?php }
public function scripts_styles() {
wp_enqueue_style( 'wewe-css', WEWE_URL . 'wiz-ee-wig-editor.css', array(), WEWE_VERSION );
wp_enqueue_script( 'wewe-js', WEWE_URL . 'wiz-ee-wig-editor.js', array( 'jquery' ), WEWE_VERSION, true );
}
}
}
// Load the Wiz-Ee-Wig Editor widget
require_once WEWE_PATH . 'class.wewe-widget.php';
// Get the Wiz-Ee-Wig Editor plugin running
WizEeWig_Editor::instance();