@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | |
11 | 11 | class assets { |
12 | 12 | |
13 | - public function __construct(){ |
|
13 | + public function __construct() { |
|
14 | 14 | |
15 | - add_action('wp_enqueue_scripts', array($this,'scripts')); |
|
15 | + add_action('wp_enqueue_scripts', array($this, 'scripts')); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | function is_multipage() |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | if (!$pos) return -1; |
23 | 23 | |
24 | 24 | global $wp; |
25 | - $url = home_url( $wp->request ); |
|
26 | - $index = intval(basename($url)) == 0 ? 0 : intval(basename($url))-1; |
|
25 | + $url = home_url($wp->request); |
|
26 | + $index = intval(basename($url)) == 0 ? 0 : intval(basename($url)) - 1; |
|
27 | 27 | echo $index; |
28 | 28 | return $index; |
29 | 29 | } |
30 | 30 | |
31 | - public function scripts(){ |
|
31 | + public function scripts() { |
|
32 | 32 | |
33 | 33 | |
34 | 34 | global $post; |
35 | - if ( lasso_user_can('edit_posts') |
|
35 | + if (lasso_user_can('edit_posts') |
|
36 | 36 | /* uncomment this line to disable Editus on Gutenberg posts*/ |
37 | 37 | /* && !( function_exists( 'has_blocks' ) && has_blocks( $post->post_content) && !is_home()) */ |
38 | 38 | ) { |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | /** Returns the time offset from UTC |
41 | 41 | */ |
42 | 42 | function get_UTC_offset() { |
43 | - $timezone_string = get_option( 'timezone_string' ); |
|
44 | - if (empty( $timezone_string ) ) { |
|
45 | - return get_option('gmt_offset')*3600; |
|
43 | + $timezone_string = get_option('timezone_string'); |
|
44 | + if (empty($timezone_string)) { |
|
45 | + return get_option('gmt_offset') * 3600; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | $origin_dtz = new \DateTimeZone($timezone_string); |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | wp_enqueue_style('lasso-style', LASSO_URL.'/public/assets/css/lasso.css', LASSO_VERSION, true); |
55 | 55 | |
56 | 56 | //don't load autocomplete if it's a stockholm theme |
57 | - $themename = wp_get_theme()->get('Name'); |
|
58 | - if ($themename !='Stockholm' ) { |
|
57 | + $themename = wp_get_theme()->get('Name'); |
|
58 | + if ($themename != 'Stockholm') { |
|
59 | 59 | wp_enqueue_script('jquery-ui-autocomplete'); |
60 | 60 | } |
61 | 61 | wp_enqueue_script('jquery-ui-draggable'); |
@@ -68,28 +68,28 @@ discard block |
||
68 | 68 | // url for json api |
69 | 69 | $home_url = function_exists('json_get_url_prefix') ? json_get_url_prefix() : false; |
70 | 70 | |
71 | - $article_object = lasso_editor_get_option('article_class','lasso_editor'); |
|
71 | + $article_object = lasso_editor_get_option('article_class', 'lasso_editor'); |
|
72 | 72 | |
73 | - $article_object = empty( $article_object ) && lasso_get_supported_theme_class() ? lasso_get_supported_theme_class() : $article_object; |
|
73 | + $article_object = empty($article_object) && lasso_get_supported_theme_class() ? lasso_get_supported_theme_class() : $article_object; |
|
74 | 74 | |
75 | - $featImgClass = lasso_editor_get_option('featimg_class','lasso_editor'); |
|
76 | - if (empty( $featImgClass )) { |
|
75 | + $featImgClass = lasso_editor_get_option('featimg_class', 'lasso_editor'); |
|
76 | + if (empty($featImgClass)) { |
|
77 | 77 | $featImgClass = lasso_get_supported_theme_featured_image_class(); |
78 | 78 | } |
79 | - $titleClass = lasso_editor_get_option('title_class','lasso_editor'); |
|
80 | - if (empty( $titleClass )) { |
|
79 | + $titleClass = lasso_editor_get_option('title_class', 'lasso_editor'); |
|
80 | + if (empty($titleClass)) { |
|
81 | 81 | $titleClass = lasso_get_supported_theme_title_class(); |
82 | 82 | } |
83 | - $toolbar_headings = lasso_editor_get_option('toolbar_headings', 'lasso_editor'); |
|
84 | - $toolbar_headings_h4 = lasso_editor_get_option('toolbar_headings_h4', 'lasso_editor'); |
|
83 | + $toolbar_headings = lasso_editor_get_option('toolbar_headings', 'lasso_editor'); |
|
84 | + $toolbar_headings_h4 = lasso_editor_get_option('toolbar_headings_h4', 'lasso_editor'); |
|
85 | 85 | $objectsNoSave = lasso_editor_get_option('dont_save', 'lasso_editor'); |
86 | - $objectsNonEditable = lasso_editor_get_option('non_editable', 'lasso_editor'); |
|
86 | + $objectsNonEditable = lasso_editor_get_option('non_editable', 'lasso_editor'); |
|
87 | 87 | $disableRESTSave = lasso_editor_get_option('save_using_rest_disabled', 'lasso_editor'); |
88 | - $save_to_post_disabled = lasso_editor_get_option( 'post_save_disabled', 'lasso_editor' ); |
|
89 | - $edit_post_disabled = lasso_editor_get_option( 'post_edit_disabled', 'lasso_editor' ); |
|
88 | + $save_to_post_disabled = lasso_editor_get_option('post_save_disabled', 'lasso_editor'); |
|
89 | + $edit_post_disabled = lasso_editor_get_option('post_edit_disabled', 'lasso_editor'); |
|
90 | 90 | |
91 | - $bold_tag = lasso_editor_get_option('bold_tag', 'lasso_editor','b'); |
|
92 | - $i_tag = lasso_editor_get_option('i_tag', 'lasso_editor','i'); |
|
91 | + $bold_tag = lasso_editor_get_option('bold_tag', 'lasso_editor', 'b'); |
|
92 | + $i_tag = lasso_editor_get_option('i_tag', 'lasso_editor', 'i'); |
|
93 | 93 | |
94 | 94 | |
95 | 95 | //text alignement |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | |
107 | 107 | if ($show_color) { |
108 | 108 | //color picker |
109 | - wp_enqueue_style( 'wp-color-picker' ); |
|
110 | - wp_enqueue_script( 'iris', admin_url( 'js/iris.min.js' ), array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), false, 1 ); |
|
109 | + wp_enqueue_style('wp-color-picker'); |
|
110 | + wp_enqueue_script('iris', admin_url('js/iris.min.js'), array('jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch'), false, 1); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | // click to insert components, not drag and drop |
@@ -119,54 +119,54 @@ discard block |
||
119 | 119 | |
120 | 120 | // custom fields |
121 | 121 | |
122 | - $custom_fields = apply_filters( 'editus_custom_fields', null ); |
|
122 | + $custom_fields = apply_filters('editus_custom_fields', null); |
|
123 | 123 | |
124 | 124 | |
125 | 125 | // post id reference |
126 | 126 | $postid = get_the_ID(); |
127 | 127 | $tz_offset = get_UTC_offset(); |
128 | 128 | $post_date = get_the_time('U', $postid); |
129 | - $time = (time()+$tz_offset); |
|
129 | + $time = (time() + $tz_offset); |
|
130 | 130 | $delta = $time - $post_date; |
131 | 131 | |
132 | 132 | $strings = array( |
133 | - 'save' => __('Save','lasso'), |
|
134 | - 'selectText' => __('Please Select Text First.','lasso'), |
|
135 | - 'cancel' => __('Cancel','lasso'), |
|
136 | - 'exiteditor' => __('Exit Editor','lasso'), |
|
137 | - 'saving' => __('Saving...','lasso'), |
|
138 | - 'saved' => __('Saved!','lasso'), |
|
139 | - 'adding' => __('Adding...','lasso'), |
|
140 | - 'added' => __('Added!','lasso'), |
|
141 | - 'loading' => __('Loading...','lasso'), |
|
142 | - 'loadMore' => __('Load More','lasso'), |
|
143 | - 'close' => __('Close','lasso'), |
|
144 | - 'noPostsFound' => __('No more posts found','lasso'), |
|
145 | - 'fetchFail' => __('Fetching failed.','lasso'), |
|
146 | - 'galleryCreated' => __('Gallery Created!','lasso'), |
|
147 | - 'galleryUpdated' => __('Gallery Updated!','lasso'), |
|
148 | - 'justWrite' => __('Just write...','lasso'), |
|
149 | - 'chooseImage' => __('Choose an image','lasso'), |
|
150 | - 'updateImage' => __('Update Image','lasso'), |
|
151 | - 'insertImage' => __('Insert Image','lasso'), |
|
152 | - 'selectImage' => __('Select Image','lasso'), |
|
153 | - 'removeFeatImg' => __('Remove featured image?','lasso'), |
|
154 | - 'updateSelectedImg' => __('Update Selected Image','lasso'), |
|
155 | - 'chooseImages' => __('Choose images','lasso'), |
|
156 | - 'editImage' => __('Edit Image','lasso'), |
|
157 | - 'addImages' => __('Add Images','lasso'), |
|
158 | - 'addNewGallery' => __('Add New Gallery','lasso'), |
|
159 | - 'selectGallery' => __('Select Editus Gallery Image','lasso'), |
|
160 | - 'useSelectedImages' => __('Use Selected Images','lasso'), |
|
161 | - 'publishPost' => __('Publish Post?','lasso'), |
|
162 | - 'publishYes' => __('Yes, publish it!','lasso'), |
|
163 | - 'deletePost' => __('Trash Post?','lasso'), |
|
164 | - 'deleteYes' => __('Yes, trash it!','lasso'), |
|
165 | - 'warning' => __('Oh snap!','laso'), |
|
166 | - 'cancelText' => __('O.K. got it!','lasso'), |
|
167 | - 'missingClass' => __('It looks like we are either missing the Article CSS class, or it is configured incorrectly. Editus will not function correctly without this CSS class.','lasso'), |
|
133 | + 'save' => __('Save', 'lasso'), |
|
134 | + 'selectText' => __('Please Select Text First.', 'lasso'), |
|
135 | + 'cancel' => __('Cancel', 'lasso'), |
|
136 | + 'exiteditor' => __('Exit Editor', 'lasso'), |
|
137 | + 'saving' => __('Saving...', 'lasso'), |
|
138 | + 'saved' => __('Saved!', 'lasso'), |
|
139 | + 'adding' => __('Adding...', 'lasso'), |
|
140 | + 'added' => __('Added!', 'lasso'), |
|
141 | + 'loading' => __('Loading...', 'lasso'), |
|
142 | + 'loadMore' => __('Load More', 'lasso'), |
|
143 | + 'close' => __('Close', 'lasso'), |
|
144 | + 'noPostsFound' => __('No more posts found', 'lasso'), |
|
145 | + 'fetchFail' => __('Fetching failed.', 'lasso'), |
|
146 | + 'galleryCreated' => __('Gallery Created!', 'lasso'), |
|
147 | + 'galleryUpdated' => __('Gallery Updated!', 'lasso'), |
|
148 | + 'justWrite' => __('Just write...', 'lasso'), |
|
149 | + 'chooseImage' => __('Choose an image', 'lasso'), |
|
150 | + 'updateImage' => __('Update Image', 'lasso'), |
|
151 | + 'insertImage' => __('Insert Image', 'lasso'), |
|
152 | + 'selectImage' => __('Select Image', 'lasso'), |
|
153 | + 'removeFeatImg' => __('Remove featured image?', 'lasso'), |
|
154 | + 'updateSelectedImg' => __('Update Selected Image', 'lasso'), |
|
155 | + 'chooseImages' => __('Choose images', 'lasso'), |
|
156 | + 'editImage' => __('Edit Image', 'lasso'), |
|
157 | + 'addImages' => __('Add Images', 'lasso'), |
|
158 | + 'addNewGallery' => __('Add New Gallery', 'lasso'), |
|
159 | + 'selectGallery' => __('Select Editus Gallery Image', 'lasso'), |
|
160 | + 'useSelectedImages' => __('Use Selected Images', 'lasso'), |
|
161 | + 'publishPost' => __('Publish Post?', 'lasso'), |
|
162 | + 'publishYes' => __('Yes, publish it!', 'lasso'), |
|
163 | + 'deletePost' => __('Trash Post?', 'lasso'), |
|
164 | + 'deleteYes' => __('Yes, trash it!', 'lasso'), |
|
165 | + 'warning' => __('Oh snap!', 'laso'), |
|
166 | + 'cancelText' => __('O.K. got it!', 'lasso'), |
|
167 | + 'missingClass' => __('It looks like we are either missing the Article CSS class, or it is configured incorrectly. Editus will not function correctly without this CSS class.', 'lasso'), |
|
168 | 168 | 'missingConfirm' => __('Update Settings', 'lasso'), |
169 | - 'helperText' => __('one more letter','lasso'), |
|
169 | + 'helperText' => __('one more letter', 'lasso'), |
|
170 | 170 | 'editingBackup' => __('You are currently editing a backup copy of this post.'), |
171 | 171 | |
172 | 172 | 'catsPlaceholder' => __('add categories...'), |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | |
176 | 176 | ); |
177 | 177 | |
178 | - $api_url = trailingslashit( home_url() ) . 'lasso-internal-api'; |
|
178 | + $api_url = trailingslashit(home_url()).'lasso-internal-api'; |
|
179 | 179 | |
180 | 180 | $gallery_class = new gallery(); |
181 | 181 | $gallery_nonce_action = $gallery_class->nonce_action; |
182 | - $gallery_nonce = wp_create_nonce( $gallery_nonce_action ); |
|
182 | + $gallery_nonce = wp_create_nonce($gallery_nonce_action); |
|
183 | 183 | |
184 | 184 | |
185 | 185 | if ($allow_change_date) { |
@@ -194,13 +194,13 @@ discard block |
||
194 | 194 | |
195 | 195 | if (function_exists('rest_url')) { |
196 | 196 | //$rest_root = esc_url_raw( rest_url()); |
197 | - $rest_nonce = wp_create_nonce( 'wp_rest' ); |
|
198 | - $settings = array( 'root' => $rest_root, 'nonce' => $rest_nonce ); |
|
199 | - wp_enqueue_script( 'wp-api', '', array( 'jquery', 'underscore', 'backbone' ), LASSO_VERSION, true ); |
|
200 | - wp_localize_script( 'wp-api', 'wpApiSettings', $settings ); |
|
201 | - wp_localize_script( 'wp-api', 'WP_API_Settings', $settings ); |
|
197 | + $rest_nonce = wp_create_nonce('wp_rest'); |
|
198 | + $settings = array('root' => $rest_root, 'nonce' => $rest_nonce); |
|
199 | + wp_enqueue_script('wp-api', '', array('jquery', 'underscore', 'backbone'), LASSO_VERSION, true); |
|
200 | + wp_localize_script('wp-api', 'wpApiSettings', $settings); |
|
201 | + wp_localize_script('wp-api', 'WP_API_Settings', $settings); |
|
202 | 202 | |
203 | - if ( class_exists( 'WP_REST_Controller' )) { |
|
203 | + if (class_exists('WP_REST_Controller')) { |
|
204 | 204 | // we are using REST API V2 |
205 | 205 | $using_restapiv2 = true; |
206 | 206 | } |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | |
216 | 216 | // localized objects |
217 | 217 | $objects = array( |
218 | - 'ajaxurl' => esc_url( $api_url ), |
|
219 | - 'ajaxurl2' => esc_url( admin_url( 'admin-ajax.php' )), |
|
218 | + 'ajaxurl' => esc_url($api_url), |
|
219 | + 'ajaxurl2' => esc_url(admin_url('admin-ajax.php')), |
|
220 | 220 | 'siteUrl' => site_url(), |
221 | 221 | 'rest_root' => $rest_root, |
222 | 222 | 'rest_nonce' => $rest_nonce, |
@@ -225,13 +225,13 @@ discard block |
||
225 | 225 | 'featImgClass' => $featImgClass, |
226 | 226 | 'titleClass' => $titleClass, |
227 | 227 | 'strings' => $strings, |
228 | - 'settingsLink' => function_exists('is_multisite') && is_multisite() ? network_admin_url( 'settings.php?page=lasso-editor' ) : admin_url( 'admin.php?page=lasso-editor-settings' ), |
|
229 | - 'post_status' => get_post_status( $postid ), |
|
228 | + 'settingsLink' => function_exists('is_multisite') && is_multisite() ? network_admin_url('settings.php?page=lasso-editor') : admin_url('admin.php?page=lasso-editor-settings'), |
|
229 | + 'post_status' => get_post_status($postid), |
|
230 | 230 | 'postid' => $postid, |
231 | 231 | 'permalink' => $permalink, |
232 | 232 | 'edit_others_pages' => current_user_can('edit_others_pages') ? true : false, |
233 | 233 | 'edit_others_posts' => current_user_can('edit_others_posts') ? true : false, |
234 | - 'userCanEdit' => current_user_can('edit_post', $postid ), |
|
234 | + 'userCanEdit' => current_user_can('edit_post', $postid), |
|
235 | 235 | 'can_publish' => is_page() ? current_user_can('publish_pages') : current_user_can('publish_posts'), |
236 | 236 | //'can_publish_posts' => current_user_can('publish_posts'), |
237 | 237 | //'can_publish_pages' => current_user_can('publish_pages'), |
@@ -267,32 +267,32 @@ discard block |
||
267 | 267 | 'postTags' => lasso_get_objects('tag'), |
268 | 268 | 'noResultsDiv' => lasso_editor_empty_results(), |
269 | 269 | 'noRevisionsDiv' => lasso_editor_empty_results('revision'), |
270 | - 'mapTileProvider' => function_exists('aesop_map_tile_provider') ? aesop_map_tile_provider( $postid ) : false, |
|
271 | - 'mapLocations' => get_post_meta( $postid, 'ase_map_component_locations' ), |
|
272 | - 'mapStart' => get_post_meta( $postid, 'ase_map_component_start_point', true ), |
|
273 | - 'mapZoom' => get_post_meta( $postid, 'ase_map_component_zoom', true ), |
|
270 | + 'mapTileProvider' => function_exists('aesop_map_tile_provider') ? aesop_map_tile_provider($postid) : false, |
|
271 | + 'mapLocations' => get_post_meta($postid, 'ase_map_component_locations'), |
|
272 | + 'mapStart' => get_post_meta($postid, 'ase_map_component_start_point', true), |
|
273 | + 'mapZoom' => get_post_meta($postid, 'ase_map_component_zoom', true), |
|
274 | 274 | 'revisionModal' => lasso_editor_revision_modal(), |
275 | 275 | 'isMobile' => wp_is_mobile(), |
276 | - 'enableAutoSave' => lasso_editor_get_option( 'enable_autosave', 'lasso_editor' ), |
|
276 | + 'enableAutoSave' => lasso_editor_get_option('enable_autosave', 'lasso_editor'), |
|
277 | 277 | 'showColor' => $show_color, |
278 | 278 | 'showAlignment' => $show_align, |
279 | 279 | 'showIgnoredItems' => lasso_editor_get_option('show_ignored_items', 'lasso_editor'), |
280 | 280 | 'restapi2' => $using_restapiv2, |
281 | 281 | 'saveusingrest' => $using_restapiv2 && !$disableRESTSave, |
282 | - 'newObjectContent' => '<p>'.apply_filters( 'lasso_new_object_content', __( 'Once upon a time...','lasso') ).'</p>', |
|
282 | + 'newObjectContent' => '<p>'.apply_filters('lasso_new_object_content', __('Once upon a time...', 'lasso')).'</p>', |
|
283 | 283 | 'disableSavePost' => $save_to_post_disabled, |
284 | 284 | 'disableEditPost' => $edit_post_disabled, |
285 | 285 | 'boldTag' => $bold_tag, |
286 | 286 | 'iTag' => $i_tag, |
287 | 287 | 'customFields' => $custom_fields, |
288 | - 'clickToInsert' => ($insert_comp_ui =='click'), |
|
289 | - 'buttonOnEmptyP' => ($insert_comp_ui =='mediumcom'), // auto show a button to insert components on an empty paragraph |
|
288 | + 'clickToInsert' => ($insert_comp_ui == 'click'), |
|
289 | + 'buttonOnEmptyP' => ($insert_comp_ui == 'mediumcom'), // auto show a button to insert components on an empty paragraph |
|
290 | 290 | 'rtl' => is_rtl(), |
291 | - 'skipToEdit' =>( $delta < 10 && $delta >=0 ), // if it's a new post, skip to edit mode |
|
291 | + 'skipToEdit' =>($delta < 10 && $delta >= 0), // if it's a new post, skip to edit mode |
|
292 | 292 | 'linksEditable' => $links_editable, |
293 | 293 | 'supportPendingStatus' => !$no_pending_status, |
294 | - 'tableCode' => apply_filters( 'lasso_table_html_code','<table><tr><th>Cell 1</th><th>Cell 2</th></tr><tr><td>Cell 3</td><td>Cell 4</td></tr></table>'), |
|
295 | - 'hasGutenberg' => (function_exists( 'has_blocks' ) && has_blocks( $post->post_content)), |
|
294 | + 'tableCode' => apply_filters('lasso_table_html_code', '<table><tr><th>Cell 1</th><th>Cell 2</th></tr><tr><td>Cell 3</td><td>Cell 4</td></tr></table>'), |
|
295 | + 'hasGutenberg' => (function_exists('has_blocks') && has_blocks($post->post_content)), |
|
296 | 296 | 'multipages'=> $multipage, |
297 | 297 | 'post_content'=>$post_content |
298 | 298 | ); |
@@ -303,9 +303,9 @@ discard block |
||
303 | 303 | |
304 | 304 | if (!$using_restapiv2) { |
305 | 305 | // enqueue REST API V1 |
306 | - wp_enqueue_script( 'wp-api-js', LASSO_URL.'/public/assets/js/source/util--wp-api.js', array( 'jquery', 'underscore', 'backbone' ), LASSO_VERSION, true ); |
|
307 | - $settings = array( 'root' => home_url( $home_url ), 'nonce' => wp_create_nonce( 'wp_json' ) ); |
|
308 | - wp_localize_script( 'wp-api-js', 'WP_API_Settings', $settings ); |
|
306 | + wp_enqueue_script('wp-api-js', LASSO_URL.'/public/assets/js/source/util--wp-api.js', array('jquery', 'underscore', 'backbone'), LASSO_VERSION, true); |
|
307 | + $settings = array('root' => home_url($home_url), 'nonce' => wp_create_nonce('wp_json')); |
|
308 | + wp_localize_script('wp-api-js', 'WP_API_Settings', $settings); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | if ($allow_change_date) { |
@@ -314,13 +314,13 @@ discard block |
||
314 | 314 | wp_enqueue_style('jquery-ui'); |
315 | 315 | } |
316 | 316 | |
317 | - $postfix = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) ? '' : '.min'; |
|
317 | + $postfix = (defined('SCRIPT_DEBUG') && true === SCRIPT_DEBUG) ? '' : '.min'; |
|
318 | 318 | if ($show_color) { |
319 | - wp_enqueue_script('lasso', LASSO_URL. "/public/assets/js/lasso{$postfix}.js", array('jquery', 'wp-api','iris'), LASSO_VERSION, true); |
|
319 | + wp_enqueue_script('lasso', LASSO_URL."/public/assets/js/lasso{$postfix}.js", array('jquery', 'wp-api', 'iris'), LASSO_VERSION, true); |
|
320 | 320 | } else { |
321 | - wp_enqueue_script('lasso', LASSO_URL. "/public/assets/js/lasso{$postfix}.js", array('jquery', 'wp-api'), LASSO_VERSION, true); |
|
321 | + wp_enqueue_script('lasso', LASSO_URL."/public/assets/js/lasso{$postfix}.js", array('jquery', 'wp-api'), LASSO_VERSION, true); |
|
322 | 322 | } |
323 | - wp_localize_script('lasso', 'lasso_editor', apply_filters('lasso_localized_objects', $objects ) ); |
|
323 | + wp_localize_script('lasso', 'lasso_editor', apply_filters('lasso_localized_objects', $objects)); |
|
324 | 324 | |
325 | 325 | |
326 | 326 | } |
@@ -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.2.1' ); |
|
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.2.1'); |
|
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,16 +88,16 @@ 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 |