PluginProbe
Customify / 1.2.3
Customify v1.2.3
2.10.9 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.7.1 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.6.0 1.6.0.1 1.6.5 1.7.0 1.7.1 All 77 releases
customify / features / class-CSS_Editor.php

class-CSS_Editor.php in Customify 1.2.3, at features/class-CSS_Editor.php

119 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Customify_CSS_Live_Editor {
4
5 /**
6 * Instance of this class.
7 * @since 1.0.0
8 * @var object
9 */
10 protected static $instance = null;
11
12 protected function __construct() {
13
14 add_action( 'customify_create_custom_control', array( $this,'cle_create_custom_control'), 10, 1 );
15
16 add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_admin_customizer_styles' ), 10);
17
18 $load_location = PixCustomifyPlugin::get_plugin_option( 'style_resources_location', 'wp_head' );
19 add_action( $load_location, array( $this, 'output_dynamic_style' ), 999999999 );
20 }
21
22 /**
23 * Return an instance of this class.
24 * @since 1.0.0
25 * @return object A single instance of this class.
26 */
27 public static function get_instance() {
28
29 // If the single instance hasn't been set, set it now.
30 if ( null == self::$instance ) {
31 self::$instance = new self;
32 }
33
34 return self::$instance;
35 }
36
37 function enqueue_admin_customizer_styles(){
38 $dir = plugin_dir_url( __FILE__ );
39
40 $dir = rtrim( $dir, 'features/' );
41
42 wp_register_script('customify-ace-editor', $dir . '/js/ace/ace.js', array('jquery'), false, true);
43 wp_enqueue_script('live-css-editor', $dir . '/js/live_css_editor.js', array('customify-ace-editor'), false, true);
44
45 }
46
47 function cle_create_custom_control( $wp_customize ) {
48
49 $wp_customize->add_section( 'live_css_edit_section', array(
50 'priority' => 11,
51 'capability' => 'edit_theme_options',
52 'title' => __('CSS Editor', 'customify_txtd'),
53 ) );
54
55 $saving_type = PixCustomifyPlugin::get_plugin_option( 'values_store_mod', 'option' );
56
57 $wp_customize->add_setting( 'live_css_edit', array(
58 'type' => $saving_type,
59 'label' => __('CSS Editor', 'customify_txtd'),
60 'capability' => 'edit_theme_options',
61 'transport' => 'postMessage',
62 'default' => __("/*
63 * Welcome to the Custom CSS Editor
64 *
65 * CSS (Cascading Style Sheets) is a language that helps
66 * the browser render your website. You may remove these
67 * lines and get started with your own customizations.
68 *
69 * The generated code will be placed after the theme
70 * stylesheets, which means that your rules can take
71 * precedence and override the theme CSS rules. Just
72 * write here what you want to change, you don't need
73 * to copy all your theme's stylesheet content.
74 *
75 * Getting started with CSS (tutorial):
76 * http://bit.ly/css-getting-started
77 */
78
79 /* An example of a Custom CSS Snippet */
80 selector {
81 color: green;
82 }", 'customify_txtd')
83 ) );
84
85 $this_control = new Pix_Customize_CSS_Editor_Control(
86 $wp_customize,
87 'live_css_edit_control',
88 array(
89 'label' => __('Edit Live Css', 'customify_txtd'),
90 'section' => 'live_css_edit_section',
91 'settings' => 'live_css_edit',
92 )
93 );
94 $wp_customize->add_control( $this_control );
95 }
96
97 function output_dynamic_style() {
98 $store_type = PixCustomifyPlugin::get_plugin_option( 'values_store_mod', 'option' );
99 if ( $store_type === 'option' ) {
100 $output = get_option( 'live_css_edit' );
101 } elseif ( $store_type === 'theme_mod' ) {
102 $output = get_theme_mod( 'live_css_edit' );
103 }
104
105 if ( empty( $output ) ) {
106 return;
107 } ?>
108 <style id="customify_css_editor_output">
109 <?php echo $output; ?>
110 </style>
111 <?php
112 }
113 }
114
115 $customify_CSS_Editor = Customify_CSS_Live_Editor::get_instance();
116
117
118
119