@@ -18,27 +18,27 @@ discard block |
||
18 | 18 | */ |
19 | 19 | |
20 | 20 | // If this file is called directly, abort. |
21 | -if ( ! defined( 'WPINC' ) ) { |
|
21 | +if (!defined('WPINC')) { |
|
22 | 22 | die; |
23 | 23 | } |
24 | 24 | |
25 | 25 | // Set some constants |
26 | -define( 'LASSO_VERSION', '1.5.0' ); |
|
27 | -define( 'LASSO_DIR', plugin_dir_path( __FILE__ ) ); |
|
28 | -define( 'LASSO_URL', plugins_url( '', __FILE__ ) ); |
|
29 | -define( 'LASSO_FILE', __FILE__ ); |
|
26 | +define('LASSO_VERSION', '1.5.0'); |
|
27 | +define('LASSO_DIR', plugin_dir_path(__FILE__)); |
|
28 | +define('LASSO_URL', plugins_url('', __FILE__)); |
|
29 | +define('LASSO_FILE', __FILE__); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Load plugin if PHP version is 5.4 or later. |
33 | 33 | */ |
34 | -if ( version_compare( PHP_VERSION, '5.4.0', '>=' ) ) { |
|
34 | +if (version_compare(PHP_VERSION, '5.4.0', '>=')) { |
|
35 | 35 | |
36 | - include_once( LASSO_DIR . '/bootstrap.php' ); |
|
36 | + include_once(LASSO_DIR.'/bootstrap.php'); |
|
37 | 37 | |
38 | 38 | } else { |
39 | 39 | |
40 | 40 | add_action('admin_head', 'lasso_fail_notice'); |
41 | - function lasso_fail_notice(){ |
|
41 | + function lasso_fail_notice() { |
|
42 | 42 | |
43 | 43 | printf('<div class="error"><p>Editus requires PHP 5.4 or higher.</p></div>'); |
44 | 44 | |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | add_filter('register_post_type_args', 'lasso_show_in_rest', 10, 2); |
49 | -function lasso_show_in_rest($args, $post_type){ |
|
49 | +function lasso_show_in_rest($args, $post_type) { |
|
50 | 50 | |
51 | - $allowed_post_types = lasso_editor_get_option( 'allowed_post_types', 'lasso_editor', array( ) ); |
|
52 | - $allowed_post_types = apply_filters( 'lasso_allowed_post_types', $allowed_post_types ); |
|
53 | - if (in_array( $post_type,$allowed_post_types)) { |
|
51 | + $allowed_post_types = lasso_editor_get_option('allowed_post_types', 'lasso_editor', array( )); |
|
52 | + $allowed_post_types = apply_filters('lasso_allowed_post_types', $allowed_post_types); |
|
53 | + if (in_array($post_type, $allowed_post_types)) { |
|
54 | 54 | $args['show_in_rest'] = true; |
55 | 55 | if ($post_type != 'post' && $post_type != 'page') { |
56 | 56 | $args['rest_base'] = $post_type; |
@@ -61,21 +61,21 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | |
64 | -function lasso_editor_get_option( $option, $section, $default = '' ) { |
|
64 | +function lasso_editor_get_option($option, $section, $default = '') { |
|
65 | 65 | |
66 | - if ( empty( $option ) ) |
|
66 | + if (empty($option)) |
|
67 | 67 | return; |
68 | 68 | |
69 | - if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
|
69 | + if (function_exists('is_multisite') && is_multisite()) { |
|
70 | 70 | |
71 | - $options = get_site_option( $section ); |
|
71 | + $options = get_site_option($section); |
|
72 | 72 | |
73 | 73 | } else { |
74 | 74 | |
75 | - $options = get_option( $section ); |
|
75 | + $options = get_option($section); |
|
76 | 76 | } |
77 | 77 | |
78 | - if ( isset( $options[$option] ) ) { |
|
78 | + if (isset($options[$option])) { |
|
79 | 79 | return $options[$option]; |
80 | 80 | } |
81 | 81 | |
@@ -88,17 +88,17 @@ discard block |
||
88 | 88 | )); |
89 | 89 | |
90 | 90 | // Gutenberg |
91 | -if( function_exists( 'is_gutenberg_page' ) ) { |
|
92 | - function add_raw_to_post( $response, $post, $request ) { |
|
91 | +if (function_exists('is_gutenberg_page')) { |
|
92 | + function add_raw_to_post($response, $post, $request) { |
|
93 | 93 | $response_data = $response->get_data(); |
94 | - if ( is_array( $response_data['content'] )) { |
|
95 | - $response_data['content']['raw'] = $post->post_content ; |
|
96 | - $response->set_data( $response_data ); |
|
94 | + if (is_array($response_data['content'])) { |
|
95 | + $response_data['content']['raw'] = $post->post_content; |
|
96 | + $response->set_data($response_data); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | return $response; |
100 | 100 | } |
101 | - add_filter( "rest_prepare_post", 'add_raw_to_post', 10, 3 ); |
|
101 | + add_filter("rest_prepare_post", 'add_raw_to_post', 10, 3); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -106,32 +106,32 @@ discard block |
||
106 | 106 | //table codes to be added |
107 | 107 | class editus_table { |
108 | 108 | |
109 | - public function __construct(){ |
|
109 | + public function __construct() { |
|
110 | 110 | $add_table = lasso_editor_get_option('add_table', 'lasso_editor', false); |
111 | 111 | if ($add_table) { |
112 | - add_action('wp_enqueue_scripts', array($this,'scripts')); |
|
112 | + add_action('wp_enqueue_scripts', array($this, 'scripts')); |
|
113 | 113 | |
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | 117 | function scripts() |
118 | 118 | { |
119 | - add_action('lasso_editor_controls_after_outside', array($this,'editus_table_edit_menu')); |
|
120 | - add_filter('lasso_components',array($this,'editus_components_add_table'),10,1); |
|
121 | - add_action( 'lasso_toolbar_components', array($this,'editus_toolbar_components_add_table'), 10 ); |
|
122 | - wp_enqueue_style( 'editus-table-style', LASSO_URL. '/public/assets/css/editus-table-edit-public.css', LASSO_VERSION, true ); |
|
123 | - wp_enqueue_script( 'editus_table', LASSO_URL. '/public/assets/js/editus-table-edit-public.js', array( 'jquery' ), LASSO_VERSION, true ); |
|
119 | + add_action('lasso_editor_controls_after_outside', array($this, 'editus_table_edit_menu')); |
|
120 | + add_filter('lasso_components', array($this, 'editus_components_add_table'), 10, 1); |
|
121 | + add_action('lasso_toolbar_components', array($this, 'editus_toolbar_components_add_table'), 10); |
|
122 | + wp_enqueue_style('editus-table-style', LASSO_URL.'/public/assets/css/editus-table-edit-public.css', LASSO_VERSION, true); |
|
123 | + wp_enqueue_script('editus_table', LASSO_URL.'/public/assets/js/editus-table-edit-public.js', array('jquery'), LASSO_VERSION, true); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | function editus_table_edit_menu() |
127 | 127 | { ?> |
128 | 128 | |
129 | 129 | <ul class='editus-table-menu'> |
130 | - <li data-action="insertcol"><?php echo __('Insert Column','lasso')?></li> |
|
131 | - <li data-action="insertrow"><?php echo __('Insert Row','lasso')?></li> |
|
132 | - <li data-action="delcol"><?php echo __('Delete Column','lasso')?></li> |
|
133 | - <li data-action="delrow"><?php echo __('Delete Row','lasso')?></li> |
|
134 | - <li data-action="deltable"><?php echo __('Delete Table','lasso')?></li |
|
130 | + <li data-action="insertcol"><?php echo __('Insert Column', 'lasso')?></li> |
|
131 | + <li data-action="insertrow"><?php echo __('Insert Row', 'lasso')?></li> |
|
132 | + <li data-action="delcol"><?php echo __('Delete Column', 'lasso')?></li> |
|
133 | + <li data-action="delrow"><?php echo __('Delete Row', 'lasso')?></li> |
|
134 | + <li data-action="deltable"><?php echo __('Delete Table', 'lasso')?></li |
|
135 | 135 | </ul> |
136 | 136 | <?php |
137 | 137 | } |
@@ -143,20 +143,20 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | |
146 | - function editus_components_add_table( $array ){ |
|
146 | + function editus_components_add_table($array) { |
|
147 | 147 | $custom = array( |
148 | 148 | 'htmltable' => array( |
149 | - 'name' => __('HTML Table','lasso'), |
|
149 | + 'name' => __('HTML Table', 'lasso'), |
|
150 | 150 | 'content' => self::editus_html_table(), |
151 | 151 | ) |
152 | 152 | ); |
153 | - return array_merge( $array, $custom ); |
|
153 | + return array_merge($array, $custom); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
157 | 157 | function editus_toolbar_components_add_table( ) { |
158 | 158 | ?> |
159 | - <li data-type="htmltable" title="<?php esc_attr_e( 'HTML Table', 'lasso' );?>" class="quote lasso-toolbar--component__htmltable dashicons dashicons-grid-view"></li> |
|
159 | + <li data-type="htmltable" title="<?php esc_attr_e('HTML Table', 'lasso'); ?>" class="quote lasso-toolbar--component__htmltable dashicons dashicons-grid-view"></li> |
|
160 | 160 | <?php |
161 | 161 | } |
162 | 162 | } |
@@ -169,31 +169,31 @@ discard block |
||
169 | 169 | //table codes to be added |
170 | 170 | class editus_paragraph { |
171 | 171 | |
172 | - public function __construct(){ |
|
172 | + public function __construct() { |
|
173 | 173 | $add_paragraph = lasso_editor_get_option('add_paragraph', 'lasso_editor', false); |
174 | 174 | if ($add_paragraph) { |
175 | - add_action('wp_enqueue_scripts', array($this,'scripts')); |
|
175 | + add_action('wp_enqueue_scripts', array($this, 'scripts')); |
|
176 | 176 | |
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | 180 | function scripts() |
181 | 181 | { |
182 | - add_action('lasso_editor_controls_after_outside', array($this,'editus_paragraph_style')); |
|
183 | - add_filter('lasso_components',array($this,'editus_components_add_paragraph'),10,1); |
|
184 | - add_action( 'lasso_toolbar_components', array($this,'editus_toolbar_components_add_paragraph'), 10 ); |
|
182 | + add_action('lasso_editor_controls_after_outside', array($this, 'editus_paragraph_style')); |
|
183 | + add_filter('lasso_components', array($this, 'editus_components_add_paragraph'), 10, 1); |
|
184 | + add_action('lasso_toolbar_components', array($this, 'editus_toolbar_components_add_paragraph'), 10); |
|
185 | 185 | //wp_enqueue_style( 'editus-table-style', LASSO_URL. '/public/assets/css/editus-table-edit-public.css', LASSO_VERSION, true ); |
186 | 186 | //wp_enqueue_script( 'editus_table', LASSO_URL. '/public/assets/js/editus-table-edit-public.js', array( 'jquery' ), LASSO_VERSION, true ); |
187 | 187 | } |
188 | 188 | |
189 | - function editus_components_add_paragraph( $array ){ |
|
189 | + function editus_components_add_paragraph($array) { |
|
190 | 190 | $custom = array( |
191 | 191 | 'htmlparagraph' => array( |
192 | - 'name' => __('HTML Paragraph','lasso'), |
|
192 | + 'name' => __('HTML Paragraph', 'lasso'), |
|
193 | 193 | 'content' => self::editus_html_paragraph(), |
194 | 194 | ) |
195 | 195 | ); |
196 | - return array_merge( $array, $custom ); |
|
196 | + return array_merge($array, $custom); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | |
218 | 218 | function editus_toolbar_components_add_paragraph( ) { |
219 | 219 | ?> |
220 | - <li data-type="htmlparagraph" title="<?php esc_attr_e( 'HTML Paragraph', 'lasso' );?>" class="quote lasso-toolbar--component__htmlparagraph dashicons dashicons-editor-paragraph"></li> |
|
220 | + <li data-type="htmlparagraph" title="<?php esc_attr_e('HTML Paragraph', 'lasso'); ?>" class="quote lasso-toolbar--component__htmlparagraph dashicons dashicons-editor-paragraph"></li> |
|
221 | 221 | <?php |
222 | 222 | } |
223 | 223 | } |