Completed
Push — master ( 559ced...98be92 )
by
unknown
02:08
created
lasso.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -18,27 +18,27 @@  discard block
 block discarded – undo
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.18.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', '0.9.18.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>Lasso requires PHP 5.4 or higher.</p></div>');
44 44
 
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
public/includes/assets.php 1 patch
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -10,22 +10,22 @@  discard block
 block discarded – undo
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
 
25 25
             //don't load autocomplete if it's a stockholm theme
26
-			$themename  	= wp_get_theme()->get('Name');
26
+			$themename = wp_get_theme()->get('Name');
27 27
 			file_put_contents(WP_PLUGIN_DIR."/file1.txt", $themename);
28
-			if ($themename !='Stockholm' ) {
28
+			if ($themename != 'Stockholm') {
29 29
 				file_put_contents(WP_PLUGIN_DIR."/file2.txt", $themename);
30 30
 				wp_enqueue_script('jquery-ui-autocomplete');
31 31
 			}
@@ -39,27 +39,27 @@  discard block
 block discarded – undo
39 39
 			// url for json api
40 40
 			$home_url = function_exists('json_get_url_prefix') ? json_get_url_prefix() : false;
41 41
 
42
-			$article_object 	= lasso_editor_get_option('article_class','lasso_editor');
42
+			$article_object 	= lasso_editor_get_option('article_class', 'lasso_editor');
43 43
 
44
-			$article_object 	= empty( $article_object ) && lasso_get_supported_theme_class() ? lasso_get_supported_theme_class() : $article_object;
44
+			$article_object 	= empty($article_object) && lasso_get_supported_theme_class() ? lasso_get_supported_theme_class() : $article_object;
45 45
 
46
-			$featImgClass 		= lasso_editor_get_option('featimg_class','lasso_editor');
47
-			if (empty( $featImgClass )) {
46
+			$featImgClass = lasso_editor_get_option('featimg_class', 'lasso_editor');
47
+			if (empty($featImgClass)) {
48 48
 				$featImgClass = lasso_get_supported_theme_featured_image_class();
49 49
 			}
50
-			$titleClass 		= lasso_editor_get_option('title_class','lasso_editor');
51
-			if (empty( $titleClass )) {
50
+			$titleClass = lasso_editor_get_option('title_class', 'lasso_editor');
51
+			if (empty($titleClass)) {
52 52
 				$titleClass = lasso_get_supported_theme_title_class();
53 53
 			}
54
-			$toolbar_headings  	= lasso_editor_get_option('toolbar_headings', 'lasso_editor');
55
-			$toolbar_headings_h4  	= lasso_editor_get_option('toolbar_headings_h4', 'lasso_editor');
54
+			$toolbar_headings = lasso_editor_get_option('toolbar_headings', 'lasso_editor');
55
+			$toolbar_headings_h4 = lasso_editor_get_option('toolbar_headings_h4', 'lasso_editor');
56 56
 			$objectsNoSave  	= lasso_editor_get_option('dont_save', 'lasso_editor');
57
-			$objectsNonEditable  	= lasso_editor_get_option('non_editable', 'lasso_editor');
57
+			$objectsNonEditable = lasso_editor_get_option('non_editable', 'lasso_editor');
58 58
 			$disableRESTSave = lasso_editor_get_option('save_using_rest_disabled', 'lasso_editor');
59
-			$save_to_post_disabled  = lasso_editor_get_option( 'post_save_disabled', 'lasso_editor' );
59
+			$save_to_post_disabled = lasso_editor_get_option('post_save_disabled', 'lasso_editor');
60 60
 			
61
-			$bold_tag = lasso_editor_get_option('bold_tag', 'lasso_editor','b');
62
-			$i_tag = lasso_editor_get_option('i_tag', 'lasso_editor','i');
61
+			$bold_tag = lasso_editor_get_option('bold_tag', 'lasso_editor', 'b');
62
+			$i_tag = lasso_editor_get_option('i_tag', 'lasso_editor', 'i');
63 63
 
64 64
 			
65 65
 			//text alignement
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
 			
74 74
 			if ($show_color) {
75 75
 				//color picker
76
-				wp_enqueue_style( 'wp-color-picker' );
77
-				wp_enqueue_script( 'iris', admin_url( 'js/iris.min.js' ), array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), false, 1 );
76
+				wp_enqueue_style('wp-color-picker');
77
+				wp_enqueue_script('iris', admin_url('js/iris.min.js'), array('jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch'), false, 1);
78 78
 			}
79 79
 			
80 80
 			// custom fields
81 81
 			
82
-			$custom_fields = apply_filters( 'editus_custom_fields', null ); //array('testFieldName' => '#field1');
82
+			$custom_fields = apply_filters('editus_custom_fields', null); //array('testFieldName' => '#field1');
83 83
 
84 84
 
85 85
 
@@ -90,48 +90,48 @@  discard block
 block discarded – undo
90 90
             $delta = time() - $post_date;
91 91
 
92 92
 			$strings = array(
93
-				'save' 				=> __('Save','lasso'),
94
-				'saving' 			=> __('Saving...','lasso'),
95
-				'saved'				=> __('Saved!','lasso'),
96
-				'adding' 			=> __('Adding...','lasso'),
97
-				'added'				=> __('Added!','lasso'),
98
-				'loading' 			=> __('Loading...','lasso'),
99
-				'loadMore'			=> __('Load More','lasso'),
100
-				'close'			=> __('Close','lasso'),
101
-				'noPostsFound'		=> __('No more posts found','lasso'),
102
-				'fetchFail'	    	=> __('Fetching failed.','lasso'),
103
-				'galleryCreated' 	=> __('Gallery Created!','lasso'),
104
-				'galleryUpdated' 	=> __('Gallery Updated!','lasso'),
105
-				'justWrite'			=> __('Just write...','lasso'),
106
-				'chooseImage'		=> __('Choose an image','lasso'),
107
-				'updateImage'		=> __('Update Image','lasso'),
108
-				'insertImage'		=> __('Insert Image','lasso'),
109
-				'selectImage'		=> __('Select Image','lasso'),
110
-				'removeFeatImg'     => __('Remove featured image?','lasso'),
111
-				'updateSelectedImg' => __('Update Selected Image','lasso'),
112
-				'chooseImages'		=> __('Choose images','lasso'),
113
-				'editImage'			=> __('Edit Image','lasso'),
114
-				'addImages'			=> __('Add Images','lasso'),
115
-				'addNewGallery'		=> __('Add New Gallery','lasso'),
116
-				'selectGallery'		=> __('Select Lasso Gallery Image','lasso'),
117
-				'useSelectedImages' => __('Use Selected Images','lasso'),
118
-				'publishPost'		=> __('Publish Post?','lasso'),
119
-				'publishYes'		=> __('Yes, publish it!','lasso'),
120
-				'deletePost'		=> __('Trash Post?','lasso'),
121
-				'deleteYes'			=> __('Yes, trash it!','lasso'),
122
-				'warning'			=> __('Oh snap!','laso'),
123
-				'cancelText'		=> __('O.K. got it!','lasso'),
124
-				'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'),
93
+				'save' 				=> __('Save', 'lasso'),
94
+				'saving' 			=> __('Saving...', 'lasso'),
95
+				'saved'				=> __('Saved!', 'lasso'),
96
+				'adding' 			=> __('Adding...', 'lasso'),
97
+				'added'				=> __('Added!', 'lasso'),
98
+				'loading' 			=> __('Loading...', 'lasso'),
99
+				'loadMore'			=> __('Load More', 'lasso'),
100
+				'close'			=> __('Close', 'lasso'),
101
+				'noPostsFound'		=> __('No more posts found', 'lasso'),
102
+				'fetchFail'	    	=> __('Fetching failed.', 'lasso'),
103
+				'galleryCreated' 	=> __('Gallery Created!', 'lasso'),
104
+				'galleryUpdated' 	=> __('Gallery Updated!', 'lasso'),
105
+				'justWrite'			=> __('Just write...', 'lasso'),
106
+				'chooseImage'		=> __('Choose an image', 'lasso'),
107
+				'updateImage'		=> __('Update Image', 'lasso'),
108
+				'insertImage'		=> __('Insert Image', 'lasso'),
109
+				'selectImage'		=> __('Select Image', 'lasso'),
110
+				'removeFeatImg'     => __('Remove featured image?', 'lasso'),
111
+				'updateSelectedImg' => __('Update Selected Image', 'lasso'),
112
+				'chooseImages'		=> __('Choose images', 'lasso'),
113
+				'editImage'			=> __('Edit Image', 'lasso'),
114
+				'addImages'			=> __('Add Images', 'lasso'),
115
+				'addNewGallery'		=> __('Add New Gallery', 'lasso'),
116
+				'selectGallery'		=> __('Select Lasso Gallery Image', 'lasso'),
117
+				'useSelectedImages' => __('Use Selected Images', 'lasso'),
118
+				'publishPost'		=> __('Publish Post?', 'lasso'),
119
+				'publishYes'		=> __('Yes, publish it!', 'lasso'),
120
+				'deletePost'		=> __('Trash Post?', 'lasso'),
121
+				'deleteYes'			=> __('Yes, trash it!', 'lasso'),
122
+				'warning'			=> __('Oh snap!', 'laso'),
123
+				'cancelText'		=> __('O.K. got it!', 'lasso'),
124
+				'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'),
125 125
 				'missingConfirm'	=> __('Update Settings', 'lasso'),
126
-				'helperText'		=> __('one more letter','lasso'),
126
+				'helperText'		=> __('one more letter', 'lasso'),
127 127
 				'editingBackup'  	=> __('You are currently editing a backup copy of this post.'),
128 128
 			);
129 129
 
130
-			$api_url = trailingslashit( home_url() ) . 'lasso-internal-api';
130
+			$api_url = trailingslashit(home_url()).'lasso-internal-api';
131 131
 
132 132
 			$gallery_class = new gallery();
133 133
 			$gallery_nonce_action = $gallery_class->nonce_action;
134
-			$gallery_nonce = wp_create_nonce( $gallery_nonce_action );
134
+			$gallery_nonce = wp_create_nonce($gallery_nonce_action);
135 135
 			
136 136
 			
137 137
             if ($allow_change_date) {
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 			  
147 147
 			if (function_exists('rest_url')) {
148 148
 				//$rest_root = esc_url_raw( rest_url());
149
-				$rest_nonce = wp_create_nonce( 'wp_rest' );
150
-				$settings = array( 'root' => $rest_root, 'nonce' => $rest_nonce );
151
-				wp_enqueue_script( 'wp-api', '', array( 'jquery', 'underscore', 'backbone' ), LASSO_VERSION, true );
152
-				wp_localize_script( 'wp-api', 'wpApiSettings', $settings );
153
-				wp_localize_script( 'wp-api', 'WP_API_Settings', $settings );
149
+				$rest_nonce = wp_create_nonce('wp_rest');
150
+				$settings = array('root' => $rest_root, 'nonce' => $rest_nonce);
151
+				wp_enqueue_script('wp-api', '', array('jquery', 'underscore', 'backbone'), LASSO_VERSION, true);
152
+				wp_localize_script('wp-api', 'wpApiSettings', $settings);
153
+				wp_localize_script('wp-api', 'WP_API_Settings', $settings);
154 154
 				
155
-				if ( class_exists( 'WP_REST_Controller' )) {
155
+				if (class_exists('WP_REST_Controller')) {
156 156
 					// we are using REST API V2
157 157
 					$using_restapiv2 = true;
158 158
 				}
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 
161 161
 			// localized objects
162 162
 			$objects = array(
163
-				'ajaxurl' 			=> esc_url( $api_url ),
164
-				'ajaxurl2' 			=> esc_url( admin_url( 'admin-ajax.php' )),
163
+				'ajaxurl' 			=> esc_url($api_url),
164
+				'ajaxurl2' 			=> esc_url(admin_url('admin-ajax.php')),
165 165
 				'rest_root'         => $rest_root,
166 166
 				'rest_nonce'        => $rest_nonce,
167 167
 				'editor' 			=> 'lasso--content', // ID of editable content (without #) DONT CHANGE
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
 				'featImgClass'		=> $featImgClass,
170 170
 				'titleClass'		=> $titleClass,
171 171
 				'strings'			=> $strings,
172
-				'settingsLink'		=> function_exists('is_multisite') && is_multisite() ? network_admin_url( 'settings.php?page=lasso-editor' ) : admin_url( 'admin.php?page=lasso-editor-settings' ),
173
-				'post_status'		=> get_post_status( $postid ),
172
+				'settingsLink'		=> function_exists('is_multisite') && is_multisite() ? network_admin_url('settings.php?page=lasso-editor') : admin_url('admin.php?page=lasso-editor-settings'),
173
+				'post_status'		=> get_post_status($postid),
174 174
 				'postid'			=> $postid,
175 175
 				'permalink'			=> $permalink,
176 176
 				'edit_others_pages'	=> current_user_can('edit_others_pages') ? true : false,
177 177
 				'edit_others_posts'	=> current_user_can('edit_others_posts') ? true : false,
178
-				'userCanEdit'		=> current_user_can('edit_post', $postid ),
178
+				'userCanEdit'		=> current_user_can('edit_post', $postid),
179 179
 				'can_publish_posts'	=> current_user_can('publish_posts'),
180 180
 				'can_publish_pages'	=> current_user_can('publish_pages'),
181 181
 				'author'			=> is_user_logged_in() ? get_current_user_ID() : false,
@@ -210,24 +210,24 @@  discard block
 block discarded – undo
210 210
 				'postTags'    		=> lasso_get_objects('tag'),
211 211
 				'noResultsDiv'		=> lasso_editor_empty_results(),
212 212
 				'noRevisionsDiv'	=> lasso_editor_empty_results('revision'),
213
-				'mapTileProvider'   => function_exists('aesop_map_tile_provider') ? aesop_map_tile_provider( $postid ) : false,
214
-				'mapLocations'		=> get_post_meta( $postid, 'ase_map_component_locations' ),
215
-				'mapStart'			=> get_post_meta( $postid, 'ase_map_component_start_point', true ),
216
-				'mapZoom'			=> get_post_meta( $postid, 'ase_map_component_zoom', true ),
213
+				'mapTileProvider'   => function_exists('aesop_map_tile_provider') ? aesop_map_tile_provider($postid) : false,
214
+				'mapLocations'		=> get_post_meta($postid, 'ase_map_component_locations'),
215
+				'mapStart'			=> get_post_meta($postid, 'ase_map_component_start_point', true),
216
+				'mapZoom'			=> get_post_meta($postid, 'ase_map_component_zoom', true),
217 217
 				'revisionModal' 	=> lasso_editor_revision_modal(),
218 218
 				'isMobile'          => wp_is_mobile(),
219
-				'enableAutoSave'    => lasso_editor_get_option( 'enable_autosave', 'lasso_editor' ),
219
+				'enableAutoSave'    => lasso_editor_get_option('enable_autosave', 'lasso_editor'),
220 220
 				'showColor'         => $show_color,
221 221
 				'showAlignment'     => $show_align,
222 222
 				'showIgnoredItems'  => lasso_editor_get_option('show_ignored_items', 'lasso_editor'),
223 223
 				'restapi2'          => $using_restapiv2,
224 224
 				'saveusingrest'     => $using_restapiv2 && !$disableRESTSave,
225
-				'newObjectContent'  => apply_filters( 'lasso_new_object_content', __( 'Once upon a time...','lasso') ),
225
+				'newObjectContent'  => apply_filters('lasso_new_object_content', __('Once upon a time...', 'lasso')),
226 226
 				'disableSavePost'   => $save_to_post_disabled,
227 227
 				'boldTag'           => $bold_tag,
228 228
 				'iTag'           	=> $i_tag,
229 229
 				'customFields'      => $custom_fields,
230
-				'skipToEdit'        =>( $delta < 10 ) // if it's a new post, skip to edit mode
230
+				'skipToEdit'        =>($delta < 10) // if it's a new post, skip to edit mode
231 231
 			);
232 232
 
233 233
 
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
 			
237 237
 			if (!$using_restapiv2) {
238 238
                // enqueue REST API V1
239
-			   wp_enqueue_script( 'wp-api-js', LASSO_URL.'/public/assets/js/source/util--wp-api.js', array( 'jquery', 'underscore', 'backbone' ), LASSO_VERSION, true );
240
-			   $settings = array( 'root' => home_url( $home_url ), 'nonce' => wp_create_nonce( 'wp_json' ) );
241
-			   wp_localize_script( 'wp-api-js', 'WP_API_Settings', $settings );
239
+			   wp_enqueue_script('wp-api-js', LASSO_URL.'/public/assets/js/source/util--wp-api.js', array('jquery', 'underscore', 'backbone'), LASSO_VERSION, true);
240
+			   $settings = array('root' => home_url($home_url), 'nonce' => wp_create_nonce('wp_json'));
241
+			   wp_localize_script('wp-api-js', 'WP_API_Settings', $settings);
242 242
 			}
243 243
 			
244 244
 			if ($allow_change_date) {
@@ -247,13 +247,13 @@  discard block
 block discarded – undo
247 247
 				wp_enqueue_style('jquery-ui');
248 248
 			}
249 249
 
250
-			$postfix = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) ? '' : '.min';
250
+			$postfix = (defined('SCRIPT_DEBUG') && true === SCRIPT_DEBUG) ? '' : '.min';
251 251
 			if ($show_color) {
252
-				wp_enqueue_script('lasso', LASSO_URL. "/public/assets/js/lasso{$postfix}.js", array('jquery', 'wp-api','iris'), LASSO_VERSION, true);
252
+				wp_enqueue_script('lasso', LASSO_URL."/public/assets/js/lasso{$postfix}.js", array('jquery', 'wp-api', 'iris'), LASSO_VERSION, true);
253 253
 			} else {
254
-			    wp_enqueue_script('lasso', LASSO_URL. "/public/assets/js/lasso{$postfix}.js", array('jquery', 'wp-api'), LASSO_VERSION, true);
254
+			    wp_enqueue_script('lasso', LASSO_URL."/public/assets/js/lasso{$postfix}.js", array('jquery', 'wp-api'), LASSO_VERSION, true);
255 255
 			}
256
-			wp_localize_script('lasso', 'lasso_editor', apply_filters('lasso_localized_objects', $objects ) );
256
+			wp_localize_script('lasso', 'lasso_editor', apply_filters('lasso_localized_objects', $objects));
257 257
 
258 258
 
259 259
 		}
Please login to merge, or discard this patch.