@@ -10,15 +10,15 @@ 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 | - public function scripts(){ |
|
18 | + public function scripts() { |
|
19 | 19 | |
20 | 20 | |
21 | - if ( lasso_user_can('edit_posts')) { |
|
21 | + if (lasso_user_can('edit_posts')) { |
|
22 | 22 | |
23 | 23 | wp_enqueue_style('lasso-style', LASSO_URL.'/public/assets/css/lasso.css', LASSO_VERSION, true); |
24 | 24 | |
@@ -33,27 +33,27 @@ discard block |
||
33 | 33 | // url for json api |
34 | 34 | $home_url = function_exists('json_get_url_prefix') ? json_get_url_prefix() : false; |
35 | 35 | |
36 | - $article_object = lasso_editor_get_option('article_class','lasso_editor'); |
|
36 | + $article_object = lasso_editor_get_option('article_class', 'lasso_editor'); |
|
37 | 37 | |
38 | - $article_object = empty( $article_object ) && lasso_get_supported_theme_class() ? lasso_get_supported_theme_class() : $article_object; |
|
38 | + $article_object = empty($article_object) && lasso_get_supported_theme_class() ? lasso_get_supported_theme_class() : $article_object; |
|
39 | 39 | |
40 | - $featImgClass = lasso_editor_get_option('featimg_class','lasso_editor'); |
|
41 | - if (empty( $featImgClass )) { |
|
40 | + $featImgClass = lasso_editor_get_option('featimg_class', 'lasso_editor'); |
|
41 | + if (empty($featImgClass)) { |
|
42 | 42 | $featImgClass = lasso_get_supported_theme_featured_image_class(); |
43 | 43 | } |
44 | - $titleClass = lasso_editor_get_option('title_class','lasso_editor'); |
|
45 | - if (empty( $titleClass )) { |
|
44 | + $titleClass = lasso_editor_get_option('title_class', 'lasso_editor'); |
|
45 | + if (empty($titleClass)) { |
|
46 | 46 | $titleClass = lasso_get_supported_theme_title_class(); |
47 | 47 | } |
48 | - $toolbar_headings = lasso_editor_get_option('toolbar_headings', 'lasso_editor'); |
|
49 | - $toolbar_headings_h4 = lasso_editor_get_option('toolbar_headings_h4', 'lasso_editor'); |
|
48 | + $toolbar_headings = lasso_editor_get_option('toolbar_headings', 'lasso_editor'); |
|
49 | + $toolbar_headings_h4 = lasso_editor_get_option('toolbar_headings_h4', 'lasso_editor'); |
|
50 | 50 | $objectsNoSave = lasso_editor_get_option('dont_save', 'lasso_editor'); |
51 | - $objectsNonEditable = lasso_editor_get_option('non_editable', 'lasso_editor'); |
|
51 | + $objectsNonEditable = lasso_editor_get_option('non_editable', 'lasso_editor'); |
|
52 | 52 | $disableRESTSave = lasso_editor_get_option('save_using_rest_disabled', 'lasso_editor'); |
53 | - $save_to_post_disabled = lasso_editor_get_option( 'post_save_disabled', 'lasso_editor' ); |
|
53 | + $save_to_post_disabled = lasso_editor_get_option('post_save_disabled', 'lasso_editor'); |
|
54 | 54 | |
55 | - $bold_tag = lasso_editor_get_option('bold_tag', 'lasso_editor','b'); |
|
56 | - $i_tag = lasso_editor_get_option('i_tag', 'lasso_editor','i'); |
|
55 | + $bold_tag = lasso_editor_get_option('bold_tag', 'lasso_editor', 'b'); |
|
56 | + $i_tag = lasso_editor_get_option('i_tag', 'lasso_editor', 'i'); |
|
57 | 57 | |
58 | 58 | |
59 | 59 | //text alignement |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | |
68 | 68 | if ($show_color) { |
69 | 69 | //color picker |
70 | - wp_enqueue_style( 'wp-color-picker' ); |
|
71 | - wp_enqueue_script( 'iris', admin_url( 'js/iris.min.js' ), array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), false, 1 ); |
|
70 | + wp_enqueue_style('wp-color-picker'); |
|
71 | + wp_enqueue_script('iris', admin_url('js/iris.min.js'), array('jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch'), false, 1); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | // custom fields |
75 | 75 | |
76 | - $custom_fields = apply_filters( 'editus_custom_fields', null ); //array('testFieldName' => '#field1'); |
|
76 | + $custom_fields = apply_filters('editus_custom_fields', null); //array('testFieldName' => '#field1'); |
|
77 | 77 | |
78 | 78 | |
79 | 79 | |
@@ -84,47 +84,47 @@ discard block |
||
84 | 84 | $delta = time() - $post_date; |
85 | 85 | |
86 | 86 | $strings = array( |
87 | - 'save' => __('Save','lasso'), |
|
88 | - 'saving' => __('Saving...','lasso'), |
|
89 | - 'saved' => __('Saved!','lasso'), |
|
90 | - 'adding' => __('Adding...','lasso'), |
|
91 | - 'added' => __('Added!','lasso'), |
|
92 | - 'loading' => __('Loading...','lasso'), |
|
93 | - 'loadMore' => __('Load More','lasso'), |
|
94 | - 'noPostsFound' => __('No more posts found','lasso'), |
|
95 | - 'fetchFail' => __('Fetching failed.','lasso'), |
|
96 | - 'galleryCreated' => __('Gallery Created!','lasso'), |
|
97 | - 'galleryUpdated' => __('Gallery Updated!','lasso'), |
|
98 | - 'justWrite' => __('Just write...','lasso'), |
|
99 | - 'chooseImage' => __('Choose an image','lasso'), |
|
100 | - 'updateImage' => __('Update Image','lasso'), |
|
101 | - 'insertImage' => __('Insert Image','lasso'), |
|
102 | - 'selectImage' => __('Select Image','lasso'), |
|
103 | - 'removeFeatImg' => __('Remove featured image?','lasso'), |
|
104 | - 'updateSelectedImg' => __('Update Selected Image','lasso'), |
|
105 | - 'chooseImages' => __('Choose images','lasso'), |
|
106 | - 'editImage' => __('Edit Image','lasso'), |
|
107 | - 'addImages' => __('Add Images','lasso'), |
|
108 | - 'addNewGallery' => __('Add New Gallery','lasso'), |
|
109 | - 'selectGallery' => __('Select Lasso Gallery Image','lasso'), |
|
110 | - 'useSelectedImages' => __('Use Selected Images','lasso'), |
|
111 | - 'publishPost' => __('Publish Post?','lasso'), |
|
112 | - 'publishYes' => __('Yes, publish it!','lasso'), |
|
113 | - 'deletePost' => __('Trash Post?','lasso'), |
|
114 | - 'deleteYes' => __('Yes, trash it!','lasso'), |
|
115 | - 'warning' => __('Oh snap!','laso'), |
|
116 | - 'cancelText' => __('O.K. got it!','lasso'), |
|
117 | - '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'), |
|
87 | + 'save' => __('Save', 'lasso'), |
|
88 | + 'saving' => __('Saving...', 'lasso'), |
|
89 | + 'saved' => __('Saved!', 'lasso'), |
|
90 | + 'adding' => __('Adding...', 'lasso'), |
|
91 | + 'added' => __('Added!', 'lasso'), |
|
92 | + 'loading' => __('Loading...', 'lasso'), |
|
93 | + 'loadMore' => __('Load More', 'lasso'), |
|
94 | + 'noPostsFound' => __('No more posts found', 'lasso'), |
|
95 | + 'fetchFail' => __('Fetching failed.', 'lasso'), |
|
96 | + 'galleryCreated' => __('Gallery Created!', 'lasso'), |
|
97 | + 'galleryUpdated' => __('Gallery Updated!', 'lasso'), |
|
98 | + 'justWrite' => __('Just write...', 'lasso'), |
|
99 | + 'chooseImage' => __('Choose an image', 'lasso'), |
|
100 | + 'updateImage' => __('Update Image', 'lasso'), |
|
101 | + 'insertImage' => __('Insert Image', 'lasso'), |
|
102 | + 'selectImage' => __('Select Image', 'lasso'), |
|
103 | + 'removeFeatImg' => __('Remove featured image?', 'lasso'), |
|
104 | + 'updateSelectedImg' => __('Update Selected Image', 'lasso'), |
|
105 | + 'chooseImages' => __('Choose images', 'lasso'), |
|
106 | + 'editImage' => __('Edit Image', 'lasso'), |
|
107 | + 'addImages' => __('Add Images', 'lasso'), |
|
108 | + 'addNewGallery' => __('Add New Gallery', 'lasso'), |
|
109 | + 'selectGallery' => __('Select Lasso Gallery Image', 'lasso'), |
|
110 | + 'useSelectedImages' => __('Use Selected Images', 'lasso'), |
|
111 | + 'publishPost' => __('Publish Post?', 'lasso'), |
|
112 | + 'publishYes' => __('Yes, publish it!', 'lasso'), |
|
113 | + 'deletePost' => __('Trash Post?', 'lasso'), |
|
114 | + 'deleteYes' => __('Yes, trash it!', 'lasso'), |
|
115 | + 'warning' => __('Oh snap!', 'laso'), |
|
116 | + 'cancelText' => __('O.K. got it!', 'lasso'), |
|
117 | + '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'), |
|
118 | 118 | 'missingConfirm' => __('Update Settings', 'lasso'), |
119 | - 'helperText' => __('one more letter','lasso'), |
|
119 | + 'helperText' => __('one more letter', 'lasso'), |
|
120 | 120 | 'editingBackup' => __('You are currently editing a backup copy of this post.'), |
121 | 121 | ); |
122 | 122 | |
123 | - $api_url = trailingslashit( home_url() ) . 'lasso-internal-api'; |
|
123 | + $api_url = trailingslashit(home_url()).'lasso-internal-api'; |
|
124 | 124 | |
125 | 125 | $gallery_class = new gallery(); |
126 | 126 | $gallery_nonce_action = $gallery_class->nonce_action; |
127 | - $gallery_nonce = wp_create_nonce( $gallery_nonce_action ); |
|
127 | + $gallery_nonce = wp_create_nonce($gallery_nonce_action); |
|
128 | 128 | |
129 | 129 | |
130 | 130 | if ($allow_change_date) { |
@@ -139,13 +139,13 @@ discard block |
||
139 | 139 | |
140 | 140 | if (function_exists('rest_url')) { |
141 | 141 | //$rest_root = esc_url_raw( rest_url()); |
142 | - $rest_nonce = wp_create_nonce( 'wp_rest' ); |
|
143 | - $settings = array( 'root' => $rest_root, 'nonce' => $rest_nonce ); |
|
144 | - wp_enqueue_script( 'wp-api', '', array( 'jquery', 'underscore', 'backbone' ), LASSO_VERSION, true ); |
|
145 | - wp_localize_script( 'wp-api', 'wpApiSettings', $settings ); |
|
146 | - wp_localize_script( 'wp-api', 'WP_API_Settings', $settings ); |
|
142 | + $rest_nonce = wp_create_nonce('wp_rest'); |
|
143 | + $settings = array('root' => $rest_root, 'nonce' => $rest_nonce); |
|
144 | + wp_enqueue_script('wp-api', '', array('jquery', 'underscore', 'backbone'), LASSO_VERSION, true); |
|
145 | + wp_localize_script('wp-api', 'wpApiSettings', $settings); |
|
146 | + wp_localize_script('wp-api', 'WP_API_Settings', $settings); |
|
147 | 147 | |
148 | - if ( class_exists( 'WP_REST_Controller' )) { |
|
148 | + if (class_exists('WP_REST_Controller')) { |
|
149 | 149 | // we are using REST API V2 |
150 | 150 | $using_restapiv2 = true; |
151 | 151 | } |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | |
154 | 154 | // localized objects |
155 | 155 | $objects = array( |
156 | - 'ajaxurl' => esc_url( $api_url ), |
|
157 | - 'ajaxurl2' => esc_url( admin_url( 'admin-ajax.php' )), |
|
156 | + 'ajaxurl' => esc_url($api_url), |
|
157 | + 'ajaxurl2' => esc_url(admin_url('admin-ajax.php')), |
|
158 | 158 | 'rest_root' => $rest_root, |
159 | 159 | 'rest_nonce' => $rest_nonce, |
160 | 160 | 'editor' => 'lasso--content', // ID of editable content (without #) DONT CHANGE |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | 'featImgClass' => $featImgClass, |
163 | 163 | 'titleClass' => $titleClass, |
164 | 164 | 'strings' => $strings, |
165 | - 'settingsLink' => function_exists('is_multisite') && is_multisite() ? network_admin_url( 'settings.php?page=lasso-editor' ) : admin_url( 'admin.php?page=lasso-editor-settings' ), |
|
166 | - 'post_status' => get_post_status( $postid ), |
|
165 | + 'settingsLink' => function_exists('is_multisite') && is_multisite() ? network_admin_url('settings.php?page=lasso-editor') : admin_url('admin.php?page=lasso-editor-settings'), |
|
166 | + 'post_status' => get_post_status($postid), |
|
167 | 167 | 'postid' => $postid, |
168 | 168 | 'permalink' => $permalink, |
169 | 169 | 'edit_others_pages' => current_user_can('edit_others_pages') ? true : false, |
170 | 170 | 'edit_others_posts' => current_user_can('edit_others_posts') ? true : false, |
171 | - 'userCanEdit' => current_user_can('edit_post', $postid ), |
|
171 | + 'userCanEdit' => current_user_can('edit_post', $postid), |
|
172 | 172 | 'can_publish_posts' => current_user_can('publish_posts'), |
173 | 173 | 'can_publish_pages' => current_user_can('publish_pages'), |
174 | 174 | 'author' => is_user_logged_in() ? get_current_user_ID() : false, |
@@ -203,24 +203,24 @@ discard block |
||
203 | 203 | 'postTags' => lasso_get_objects('tag'), |
204 | 204 | 'noResultsDiv' => lasso_editor_empty_results(), |
205 | 205 | 'noRevisionsDiv' => lasso_editor_empty_results('revision'), |
206 | - 'mapTileProvider' => function_exists('aesop_map_tile_provider') ? aesop_map_tile_provider( $postid ) : false, |
|
207 | - 'mapLocations' => get_post_meta( $postid, 'ase_map_component_locations' ), |
|
208 | - 'mapStart' => get_post_meta( $postid, 'ase_map_component_start_point', true ), |
|
209 | - 'mapZoom' => get_post_meta( $postid, 'ase_map_component_zoom', true ), |
|
206 | + 'mapTileProvider' => function_exists('aesop_map_tile_provider') ? aesop_map_tile_provider($postid) : false, |
|
207 | + 'mapLocations' => get_post_meta($postid, 'ase_map_component_locations'), |
|
208 | + 'mapStart' => get_post_meta($postid, 'ase_map_component_start_point', true), |
|
209 | + 'mapZoom' => get_post_meta($postid, 'ase_map_component_zoom', true), |
|
210 | 210 | 'revisionModal' => lasso_editor_revision_modal(), |
211 | 211 | 'isMobile' => wp_is_mobile(), |
212 | - 'enableAutoSave' => lasso_editor_get_option( 'enable_autosave', 'lasso_editor' ), |
|
212 | + 'enableAutoSave' => lasso_editor_get_option('enable_autosave', 'lasso_editor'), |
|
213 | 213 | 'showColor' => $show_color, |
214 | 214 | 'showAlignment' => $show_align, |
215 | 215 | 'showIgnoredItems' => lasso_editor_get_option('show_ignored_items', 'lasso_editor'), |
216 | 216 | 'restapi2' => $using_restapiv2, |
217 | 217 | 'saveusingrest' => $using_restapiv2 && !$disableRESTSave, |
218 | - 'newObjectContent' => apply_filters( 'lasso_new_object_content', __( 'Once upon a time...','lasso') ), |
|
218 | + 'newObjectContent' => apply_filters('lasso_new_object_content', __('Once upon a time...', 'lasso')), |
|
219 | 219 | 'disableSavePost' => $save_to_post_disabled, |
220 | 220 | 'boldTag' => $bold_tag, |
221 | 221 | 'iTag' => $i_tag, |
222 | 222 | 'customFields' => $custom_fields, |
223 | - 'skipToEdit' =>( $delta < 30 ) // if it's a new post, skip to edit mode |
|
223 | + 'skipToEdit' =>($delta < 30) // if it's a new post, skip to edit mode |
|
224 | 224 | ); |
225 | 225 | |
226 | 226 | |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | |
230 | 230 | if (!$using_restapiv2) { |
231 | 231 | // enqueue REST API V1 |
232 | - wp_enqueue_script( 'wp-api-js', LASSO_URL.'/public/assets/js/source/util--wp-api.js', array( 'jquery', 'underscore', 'backbone' ), LASSO_VERSION, true ); |
|
233 | - $settings = array( 'root' => home_url( $home_url ), 'nonce' => wp_create_nonce( 'wp_json' ) ); |
|
234 | - wp_localize_script( 'wp-api-js', 'WP_API_Settings', $settings ); |
|
232 | + wp_enqueue_script('wp-api-js', LASSO_URL.'/public/assets/js/source/util--wp-api.js', array('jquery', 'underscore', 'backbone'), LASSO_VERSION, true); |
|
233 | + $settings = array('root' => home_url($home_url), 'nonce' => wp_create_nonce('wp_json')); |
|
234 | + wp_localize_script('wp-api-js', 'WP_API_Settings', $settings); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | if ($allow_change_date) { |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | wp_enqueue_style('jquery-ui'); |
241 | 241 | } |
242 | 242 | |
243 | - $postfix = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) ? '' : '.min'; |
|
243 | + $postfix = (defined('SCRIPT_DEBUG') && true === SCRIPT_DEBUG) ? '' : '.min'; |
|
244 | 244 | if ($show_color) { |
245 | - wp_enqueue_script('lasso', LASSO_URL. "/public/assets/js/lasso{$postfix}.js", array('jquery', 'wp-api','iris'), LASSO_VERSION, true); |
|
245 | + wp_enqueue_script('lasso', LASSO_URL."/public/assets/js/lasso{$postfix}.js", array('jquery', 'wp-api', 'iris'), LASSO_VERSION, true); |
|
246 | 246 | } else { |
247 | - wp_enqueue_script('lasso', LASSO_URL. "/public/assets/js/lasso{$postfix}.js", array('jquery', 'wp-api'), LASSO_VERSION, true); |
|
247 | + wp_enqueue_script('lasso', LASSO_URL."/public/assets/js/lasso{$postfix}.js", array('jquery', 'wp-api'), LASSO_VERSION, true); |
|
248 | 248 | } |
249 | - wp_localize_script('lasso', 'lasso_editor', apply_filters('lasso_localized_objects', $objects ) ); |
|
249 | + wp_localize_script('lasso', 'lasso_editor', apply_filters('lasso_localized_objects', $objects)); |
|
250 | 250 | |
251 | 251 | |
252 | 252 | } |
@@ -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', '0.9.17.3' ); |
|
27 | -define( 'LASSO_DIR', plugin_dir_path( __FILE__ ) ); |
|
28 | -define( 'LASSO_URL', plugins_url( '', __FILE__ ) ); |
|
29 | -define( 'LASSO_FILE', __FILE__ ); |
|
26 | +define('LASSO_VERSION', '0.9.17.3'); |
|
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>Lasso 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 |