GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( ee6724...5fe8d9 )
by takahiro
02:38
created
modules/action.php 2 patches
Braces   +24 added lines, -16 removed lines patch added patch discarded remove patch
@@ -24,8 +24,9 @@  discard block
 block discarded – undo
24 24
 	public function init() {
25 25
 		$posts = get_posts($this->args);
26 26
 
27
-		if ( empty($posts) )
28
-			return;
27
+		if ( empty($posts) ) {
28
+					return;
29
+		}
29 30
 
30 31
 		foreach ( $posts as $post ) {
31 32
 			add_action( 'wp_syndicate_' . $post->post_name . '_import', array( $this, 'import' ) );
@@ -34,8 +35,9 @@  discard block
 block discarded – undo
34 35
 
35 36
 	public function ping() {
36 37
 		$posts = get_posts($this->args);
37
-		if ( empty($posts) )
38
-			return;
38
+		if ( empty($posts) ) {
39
+					return;
40
+		}
39 41
 
40 42
 		foreach ( $posts as $post ) {
41 43
 			$key = $post->post_name;
@@ -73,15 +75,18 @@  discard block
 block discarded – undo
73 75
 	
74 76
 	public function set_event($post_id) {
75 77
 
76
-		if ( wp_is_post_revision($post_id) )
77
-			return;
78
+		if ( wp_is_post_revision($post_id) ) {
79
+					return;
80
+		}
78 81
 
79
-		if ( 'wp-syndicate' != get_post_type($post_id) )
80
-			return;
82
+		if ( 'wp-syndicate' != get_post_type($post_id) ) {
83
+					return;
84
+		}
81 85
 
82 86
 		$post = get_post( $post_id );
83
-		if ( !is_object($post) )
84
-			return;
87
+		if ( !is_object($post) ) {
88
+					return;
89
+		}
85 90
 
86 91
 		$key = $post->post_name;
87 92
 		$interval_min = get_post_meta( $post_id, 'wp_syndicate-feed-retrieve-term', true );
@@ -91,8 +96,9 @@  discard block
 block discarded – undo
91 96
 		$hook = 'wp_syndicate_' . $key . '_import';
92 97
 		$event = 'wp_syndicate_' . $key;
93 98
 
94
-		if ( wp_next_scheduled( $hook, array( $post_id )) )
95
-			wp_clear_scheduled_hook( $hook, array( $post_id ) );
99
+		if ( wp_next_scheduled( $hook, array( $post_id )) ) {
100
+					wp_clear_scheduled_hook( $hook, array( $post_id ) );
101
+		}
96 102
 
97 103
 		wp_schedule_event( $action_time, $event, $hook, array( $post_id )  );
98 104
 		spawn_cron( $action_time );
@@ -106,8 +112,9 @@  discard block
 block discarded – undo
106 112
 		$options = get_option( 'wp_syndicate_options' );
107 113
 		$post = get_post($post_id);
108 114
 		
109
-		if ( !is_object($post) )
110
-			return;
115
+		if ( !is_object($post) ) {
116
+					return;
117
+		}
111 118
 
112 119
 		$this->media_id = $post_id;
113 120
 		$feed_url = html_entity_decode(get_post_meta( $post_id, 'wp_syndicate-feed-url', true ), ENT_QUOTES, 'UTF-8');
@@ -152,8 +159,9 @@  discard block
 block discarded – undo
152 159
 			if ( empty($set_post_id) ) {
153 160
 				global $wpdb;
154 161
 				$db_ret = $wpdb->get_row( $wpdb->prepare( "SELECT count(1) as cnt FROM $wpdb->postmeta WHERE meta_key='%s'", $slug) );
155
-				if ( $db_ret === null || $db_ret->cnt !== '0' )
156
-					continue; 
162
+				if ( $db_ret === null || $db_ret->cnt !== '0' ) {
163
+									continue;
164
+				}
157 165
 			}
158 166
 			
159 167
 			if ( $registration_method == 'insert' && is_object($set_post) ) {
Please login to merge, or discard this patch.
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -14,41 +14,41 @@  discard block
 block discarded – undo
14 14
 
15 15
 
16 16
 	public function __construct() {
17
-		add_filter( 'cron_schedules', array( $this, 'cron_schedules' ) );
18
-		add_action( 'save_post', array( $this, 'set_event' ) );
19
-		add_action( 'admin_head', array( $this, 'ping' ) );
20
-		add_action( 'template_redirect', array( $this, 'ping' ) );
21
-		add_action( 'init', array( $this, 'init' ) );
17
+		add_filter('cron_schedules', array($this, 'cron_schedules'));
18
+		add_action('save_post', array($this, 'set_event'));
19
+		add_action('admin_head', array($this, 'ping'));
20
+		add_action('template_redirect', array($this, 'ping'));
21
+		add_action('init', array($this, 'init'));
22 22
 	}
23 23
 	
24 24
 	public function init() {
25 25
 		$posts = get_posts($this->args);
26 26
 
27
-		if ( empty($posts) )
27
+		if (empty($posts))
28 28
 			return;
29 29
 
30
-		foreach ( $posts as $post ) {
31
-			add_action( 'wp_syndicate_' . $post->post_name . '_import', array( $this, 'import' ) );
30
+		foreach ($posts as $post) {
31
+			add_action('wp_syndicate_' . $post->post_name . '_import', array($this, 'import'));
32 32
 		}
33 33
 	}
34 34
 
35 35
 	public function ping() {
36 36
 		$posts = get_posts($this->args);
37
-		if ( empty($posts) )
37
+		if (empty($posts))
38 38
 			return;
39 39
 
40
-		foreach ( $posts as $post ) {
40
+		foreach ($posts as $post) {
41 41
 			$key = $post->post_name;
42 42
 			$hook = 'wp_syndicate_' . $key . '_import';
43 43
 
44
-			if ( !wp_next_scheduled( $hook, array( $post->ID ) ) ) {
44
+			if (!wp_next_scheduled($hook, array($post->ID))) {
45 45
 				$this->set_event($post->ID);
46
-				$subject = '[' . get_bloginfo( 'name' ) . ']' . __( 'WP Cron Error', WPSYND_DOMAIN );
47
-				$msg  = sprintf( __( '%s of WP Cron restart, because it stopped.', WPSYND_DOMAIN ), $hook ) . "\n". __( 'action time', WPSYND_DOMAIN ). ':' . date_i18n('Y/m/d:H:i:s') . "\n\n\n";
46
+				$subject = '[' . get_bloginfo('name') . ']' . __('WP Cron Error', WPSYND_DOMAIN);
47
+				$msg  = sprintf(__('%s of WP Cron restart, because it stopped.', WPSYND_DOMAIN), $hook) . "\n" . __('action time', WPSYND_DOMAIN) . ':' . date_i18n('Y/m/d:H:i:s') . "\n\n\n";
48 48
 				$msg .= admin_url();
49
-				WP_SYND_logger::get_instance()->error( $subject, $msg );
50
-				$options = get_option( 'wp_syndicate_options' );
51
-				wp_mail( $options['error_mail'], $subject, $msg );
49
+				WP_SYND_logger::get_instance()->error($subject, $msg);
50
+				$options = get_option('wp_syndicate_options');
51
+				wp_mail($options['error_mail'], $subject, $msg);
52 52
 			}
53 53
 		}
54 54
 	}
@@ -56,16 +56,16 @@  discard block
 block discarded – undo
56 56
 	public function cron_schedules($schedules) {
57 57
 		$posts = get_posts($this->args);
58 58
 
59
-		if ( empty($posts) ) {
59
+		if (empty($posts)) {
60 60
 			return $schedules;
61 61
 		}
62 62
 
63
-		foreach ( $posts as $post ) {
63
+		foreach ($posts as $post) {
64 64
 			$key = 'wp_syndicate_' . $post->post_name;
65
-			$interval_min = get_post_meta( $post->ID, 'wp_syndicate-feed-retrieve-term', true );
66
-			$interval = intval($interval_min)*60;
67
-			$display = get_the_title( $post->ID );
68
-			$schedules[$key] = array( 'interval' => $interval, 'display' => $display );
65
+			$interval_min = get_post_meta($post->ID, 'wp_syndicate-feed-retrieve-term', true);
66
+			$interval = intval($interval_min) * 60;
67
+			$display = get_the_title($post->ID);
68
+			$schedules[$key] = array('interval' => $interval, 'display' => $display);
69 69
 		}
70 70
 
71 71
 		return $schedules;
@@ -73,63 +73,63 @@  discard block
 block discarded – undo
73 73
 	
74 74
 	public function set_event($post_id) {
75 75
 
76
-		if ( wp_is_post_revision($post_id) )
76
+		if (wp_is_post_revision($post_id))
77 77
 			return;
78 78
 
79
-		if ( 'wp-syndicate' != get_post_type($post_id) )
79
+		if ('wp-syndicate' != get_post_type($post_id))
80 80
 			return;
81 81
 
82
-		$post = get_post( $post_id );
83
-		if ( !is_object($post) )
82
+		$post = get_post($post_id);
83
+		if (!is_object($post))
84 84
 			return;
85 85
 
86 86
 		$key = $post->post_name;
87
-		$interval_min = get_post_meta( $post_id, 'wp_syndicate-feed-retrieve-term', true );
88
-		$interval = intval($interval_min)*60;
87
+		$interval_min = get_post_meta($post_id, 'wp_syndicate-feed-retrieve-term', true);
88
+		$interval = intval($interval_min) * 60;
89 89
 		$action_time = time() + $interval;
90 90
 
91 91
 		$hook = 'wp_syndicate_' . $key . '_import';
92 92
 		$event = 'wp_syndicate_' . $key;
93 93
 
94
-		if ( wp_next_scheduled( $hook, array( $post_id )) )
95
-			wp_clear_scheduled_hook( $hook, array( $post_id ) );
94
+		if (wp_next_scheduled($hook, array($post_id)))
95
+			wp_clear_scheduled_hook($hook, array($post_id));
96 96
 
97
-		wp_schedule_event( $action_time, $event, $hook, array( $post_id )  );
98
-		spawn_cron( $action_time );
97
+		wp_schedule_event($action_time, $event, $hook, array($post_id));
98
+		spawn_cron($action_time);
99 99
 	}
100 100
 
101 101
 	public function import($post_id) {
102 102
 		global $allowedposttags;
103 103
 
104
-		$allowedposttags = apply_filters( 'wp_syndicate_allowedposttags', $allowedposttags );
104
+		$allowedposttags = apply_filters('wp_syndicate_allowedposttags', $allowedposttags);
105 105
 
106
-		$options = get_option( 'wp_syndicate_options' );
106
+		$options = get_option('wp_syndicate_options');
107 107
 		$post = get_post($post_id);
108 108
 		
109
-		if ( !is_object($post) )
109
+		if (!is_object($post))
110 110
 			return;
111 111
 
112 112
 		$this->media_id = $post_id;
113
-		$feed_url = html_entity_decode(get_post_meta( $post_id, 'wp_syndicate-feed-url', true ), ENT_QUOTES, 'UTF-8');
113
+		$feed_url = html_entity_decode(get_post_meta($post_id, 'wp_syndicate-feed-url', true), ENT_QUOTES, 'UTF-8');
114 114
 
115
-		add_action('wp_feed_options', function(&$feed){
115
+		add_action('wp_feed_options', function(&$feed) {
116 116
 			$feed->set_timeout(30);
117 117
 			$feed->force_feed(true);
118 118
 			$feed->enable_cache(false);
119 119
 		}, 10);
120 120
 		
121
-		add_filter( 'wp_feed_cache_transient_lifetime' , array( $this, 'return_0' ) );
122
-		$rss = fetch_feed( $feed_url );
123
-		remove_filter( 'wp_feed_cache_transient_lifetime' , array( $this, 'return_0' ) );
124
-		if ( is_wp_error( $rss ) ) {
125
-			$subject = '[' . get_bloginfo( 'name' ) . ']' . __( 'feed import failed', WPSYND_DOMAIN );
126
-			$msg  = sprintf( __( 'An error occurred at a feed retrieval of %s', WPSYND_DOMAIN ), $post->post_name ) . "\n". __( 'action time', WPSYND_DOMAIN ). ':' . date_i18n('Y/m/d:H:i:s') . "\n\n\n";
127
-			$msg .= __( 'below error message', WPSYND_DOMAIN ) . "\n";
128
-			$msg .= $rss->get_error_message()."\n\n";
129
-			$msg .= __( 'feed URL', WPSYND_DOMAIN ) . ':' . $feed_url;
130
-			$error_post_id = WP_SYND_logger::get_instance()->error( $subject, $msg );
121
+		add_filter('wp_feed_cache_transient_lifetime', array($this, 'return_0'));
122
+		$rss = fetch_feed($feed_url);
123
+		remove_filter('wp_feed_cache_transient_lifetime', array($this, 'return_0'));
124
+		if (is_wp_error($rss)) {
125
+			$subject = '[' . get_bloginfo('name') . ']' . __('feed import failed', WPSYND_DOMAIN);
126
+			$msg  = sprintf(__('An error occurred at a feed retrieval of %s', WPSYND_DOMAIN), $post->post_name) . "\n" . __('action time', WPSYND_DOMAIN) . ':' . date_i18n('Y/m/d:H:i:s') . "\n\n\n";
127
+			$msg .= __('below error message', WPSYND_DOMAIN) . "\n";
128
+			$msg .= $rss->get_error_message() . "\n\n";
129
+			$msg .= __('feed URL', WPSYND_DOMAIN) . ':' . $feed_url;
130
+			$error_post_id = WP_SYND_logger::get_instance()->error($subject, $msg);
131 131
 			$msg .= admin_url('/post.php?post=' . $error_post_id . '&action=edit');
132
-			wp_mail( $options['error_mail'], $subject, $msg );
132
+			wp_mail($options['error_mail'], $subject, $msg);
133 133
 			return;
134 134
 		}
135 135
 
@@ -139,138 +139,138 @@  discard block
 block discarded – undo
139 139
 		$rss_items = $rss->get_items(0, 50);
140 140
 		$post_ids = array();
141 141
 		$flg = true;
142
-		$registration_method = get_post_meta( $post_id, 'wp_syndicate-registration-method', true );
143
-		$post_type = get_post_meta( $post_id, 'wp_syndicate-default-post-type', true );
144
-		foreach ( $rss_items as $item ) {
142
+		$registration_method = get_post_meta($post_id, 'wp_syndicate-registration-method', true);
143
+		$post_type = get_post_meta($post_id, 'wp_syndicate-default-post-type', true);
144
+		foreach ($rss_items as $item) {
145 145
 			$this->is_enclosure = false;
146 146
 			
147 147
 			//投稿ID取得
148 148
 			$slug = $post->post_name . '_' . $item->get_id();
149
-			$set_post = get_page_by_path( sanitize_title($slug), OBJECT, $post_type );
149
+			$set_post = get_page_by_path(sanitize_title($slug), OBJECT, $post_type);
150 150
 			$set_post_id = $set_post == null ? '' : $set_post->ID;
151 151
 			
152
-			if ( empty($set_post_id) ) {
152
+			if (empty($set_post_id)) {
153 153
 				global $wpdb;
154
-				$db_ret = $wpdb->get_row( $wpdb->prepare( "SELECT count(1) as cnt FROM $wpdb->postmeta WHERE meta_key='%s'", $slug) );
155
-				if ( $db_ret === null || $db_ret->cnt !== '0' )
154
+				$db_ret = $wpdb->get_row($wpdb->prepare("SELECT count(1) as cnt FROM $wpdb->postmeta WHERE meta_key='%s'", $slug));
155
+				if ($db_ret === null || $db_ret->cnt !== '0')
156 156
 					continue; 
157 157
 			}
158 158
 			
159
-			if ( $registration_method == 'insert' && is_object($set_post) ) {
159
+			if ($registration_method == 'insert' && is_object($set_post)) {
160 160
 				continue;
161 161
 			}
162 162
 
163 163
 			$updated = empty($set_post_id) ? false : true;
164
-			$is_skip = apply_filters( 'wp_syndicate_is_skip', false, $item, $updated, $set_post_id, $post_id );
165
-			if ( $is_skip ) {
164
+			$is_skip = apply_filters('wp_syndicate_is_skip', false, $item, $updated, $set_post_id, $post_id);
165
+			if ($is_skip) {
166 166
 				continue;
167 167
 			}
168 168
 
169 169
 			$post_args = array(
170 170
 								'ID' => $set_post_id,
171 171
 								'post_name' => $slug,
172
-								'post_date' => apply_filters( 'wp_syndicate_get_date', $item->get_date('Y/m/d H:i:s'), $post_id ),
173
- 								'post_title' => apply_filters( 'wp_syndicate_get_title', $item->get_title(), $post_id ),
172
+								'post_date' => apply_filters('wp_syndicate_get_date', $item->get_date('Y/m/d H:i:s'), $post_id),
173
+ 								'post_title' => apply_filters('wp_syndicate_get_title', $item->get_title(), $post_id),
174 174
 								'post_content' => '',
175 175
 							);
176
-			if ( !$updated ) {
177
-				$post_args['post_author'] = get_post_meta( $post_id, 'wp_syndicate-author-id', true );
178
-				$post_args['post_status'] = get_post_meta( $post_id, 'wp_syndicate-default-post-status', true );
179
-				$post_args['post_type'] = get_post_meta( $post_id, 'wp_syndicate-default-post-type', true );
176
+			if (!$updated) {
177
+				$post_args['post_author'] = get_post_meta($post_id, 'wp_syndicate-author-id', true);
178
+				$post_args['post_status'] = get_post_meta($post_id, 'wp_syndicate-default-post-status', true);
179
+				$post_args['post_type'] = get_post_meta($post_id, 'wp_syndicate-default-post-type', true);
180 180
 			}
181 181
 			$this->post = new wp_post_helper($post_args);
182 182
 
183 183
 			//画像の登録
184
-			if ( $updated ) {
185
-				$images = get_attached_media( 'image', $set_post_id );
186
-				if ( is_array( $images ) ) {
187
-					foreach ( $images as $image ) {
188
-						wp_delete_attachment( $image->ID );
184
+			if ($updated) {
185
+				$images = get_attached_media('image', $set_post_id);
186
+				if (is_array($images)) {
187
+					foreach ($images as $image) {
188
+						wp_delete_attachment($image->ID);
189 189
 					}
190 190
 				}
191 191
 			}
192 192
 
193
-			$content = apply_filters( 'the_content', $item->get_content() );
194
-			if ( $item->get_enclosure() && !empty($item->get_enclosure()->link) ) {
193
+			$content = apply_filters('the_content', $item->get_content());
194
+			if ($item->get_enclosure() && !empty($item->get_enclosure()->link)) {
195 195
 				$this->is_enclosure = true;
196
-				$this->set_enclosure( $item->get_enclosure()->link );
196
+				$this->set_enclosure($item->get_enclosure()->link);
197 197
 			} 
198 198
 
199 199
 			$this->match_count = 0;
200
-			$content = preg_replace_callback( '#<img([^>]*)src=["\']([^"\']+)["\']([^>]*)>#i',  array($this, 'update_link'), $content, -1 );
200
+			$content = preg_replace_callback('#<img([^>]*)src=["\']([^"\']+)["\']([^>]*)>#i', array($this, 'update_link'), $content, -1);
201 201
 			$this->match_count = 0;
202 202
 			$this->post->set(array(
203
-								'post_content' => apply_filters( 'wp_syndicate_get_content', $content, $post_id )
203
+								'post_content' => apply_filters('wp_syndicate_get_content', $content, $post_id)
204 204
 							));
205
-			$this->post->add_meta( 'wp_syndicate-origin-of-syndication-slug', $post->post_name, true );
206
-			$this->post->add_meta( 'wp_syndicate-origin-of-syndication-siteurl', $this->host, true );
205
+			$this->post->add_meta('wp_syndicate-origin-of-syndication-slug', $post->post_name, true);
206
+			$this->post->add_meta('wp_syndicate-origin-of-syndication-siteurl', $this->host, true);
207 207
 
208 208
 			$update_post_id = $this->post->update();
209
-			if ( !$update_post_id ) {
209
+			if (!$update_post_id) {
210 210
 				$flg = false;
211 211
 			} else {
212
-				update_post_meta( $update_post_id, $slug, 1 );
213
-				do_action( 'wp_syndicate_save_post', $update_post_id, $item, $updated, $post_id );
212
+				update_post_meta($update_post_id, $slug, 1);
213
+				do_action('wp_syndicate_save_post', $update_post_id, $item, $updated, $post_id);
214 214
 				$post_ids[] = $update_post_id;
215 215
 			}
216 216
 		} 
217 217
 		
218
-		if ( $flg ) {
219
-			$subject = '[' . get_bloginfo( 'name' ) . ']' . __( 'feed import success', WPSYND_DOMAIN );
220
-			$msg = __( 'feed URL:', WPSYND_DOMAIN ) . $feed_url . "\n";
221
-			$msg .= sprintf( __( 'Feed acquisition completion of %s', WPSYND_DOMAIN ), $post->post_name ) . "\n" . __( 'action time', WPSYND_DOMAIN ). ':' . date_i18n('Y/m/d:H:i:s') . "\n\n\n";
222
-			$msg .= __( 'below ID data updates', WPSYND_DOMAIN ) . "\n";
223
-			$msg .= implode( "\n", $post_ids );
224
-			WP_SYND_logger::get_instance()->success( $subject, $msg );
218
+		if ($flg) {
219
+			$subject = '[' . get_bloginfo('name') . ']' . __('feed import success', WPSYND_DOMAIN);
220
+			$msg = __('feed URL:', WPSYND_DOMAIN) . $feed_url . "\n";
221
+			$msg .= sprintf(__('Feed acquisition completion of %s', WPSYND_DOMAIN), $post->post_name) . "\n" . __('action time', WPSYND_DOMAIN) . ':' . date_i18n('Y/m/d:H:i:s') . "\n\n\n";
222
+			$msg .= __('below ID data updates', WPSYND_DOMAIN) . "\n";
223
+			$msg .= implode("\n", $post_ids);
224
+			WP_SYND_logger::get_instance()->success($subject, $msg);
225 225
 		} else {
226
-			$subject = '[' . get_bloginfo( 'name' ) . ']' . __( 'feed import failed', WPSYND_DOMAIN );
227
-			$msg = __( 'feed URL:', WPSYND_DOMAIN ) . $feed_url . "\n";
228
-			$msg .= sprintf( __( 'Failed to some data registration of %s', WPSYND_DOMAIN ), $post->post_name ) . "\n". __( 'action time', WPSYND_DOMAIN ). ':' . date_i18n('Y/m/d:H:i:s') . "\n\n\n";
229
-			$msg .= __( 'below ID data updates', WPSYND_DOMAIN ) . "\n";
230
-			$msg .= implode( "\n", $post_ids );
231
-			$error_post_id = WP_SYND_logger::get_instance()->error( $subject, $msg );
226
+			$subject = '[' . get_bloginfo('name') . ']' . __('feed import failed', WPSYND_DOMAIN);
227
+			$msg = __('feed URL:', WPSYND_DOMAIN) . $feed_url . "\n";
228
+			$msg .= sprintf(__('Failed to some data registration of %s', WPSYND_DOMAIN), $post->post_name) . "\n" . __('action time', WPSYND_DOMAIN) . ':' . date_i18n('Y/m/d:H:i:s') . "\n\n\n";
229
+			$msg .= __('below ID data updates', WPSYND_DOMAIN) . "\n";
230
+			$msg .= implode("\n", $post_ids);
231
+			$error_post_id = WP_SYND_logger::get_instance()->error($subject, $msg);
232 232
 			$msg .= admin_url('/post.php?post=' . $error_post_id . '&action=edit');
233
-			wp_mail( $options['error_mail'], $subject, $msg );
233
+			wp_mail($options['error_mail'], $subject, $msg);
234 234
 		}
235 235
 		
236 236
 	}
237 237
 
238
-	public function return_0( $seconds ) {
238
+	public function return_0($seconds) {
239 239
 		return 0;
240 240
 	}
241 241
 
242
-	public function update_link( $matches ) {
242
+	public function update_link($matches) {
243 243
 	
244
-		if ( is_array($matches) && array_key_exists(2, $matches) && isset($this->post) && is_object($this->post) && is_a($this->post, 'wp_post_helper') ) {
244
+		if (is_array($matches) && array_key_exists(2, $matches) && isset($this->post) && is_object($this->post) && is_a($this->post, 'wp_post_helper')) {
245 245
 			$args    = array();
246
-			$user    = get_post_meta( $this->media_id, 'wp_syndicate-basic-auth-user', true );
247
-			$pass    = get_post_meta( $this->media_id, 'wp_syndicate-basic-auth-pass', true );
248
-			if ( !empty($user) && !empty($pass) ) {
246
+			$user    = get_post_meta($this->media_id, 'wp_syndicate-basic-auth-user', true);
247
+			$pass    = get_post_meta($this->media_id, 'wp_syndicate-basic-auth-pass', true);
248
+			if (!empty($user) && !empty($pass)) {
249 249
 				$args = array(
250
-					'headers' => array( 'Authorization' => 'Basic ' . base64_encode( $user . ':' . $pass ) )
250
+					'headers' => array('Authorization' => 'Basic ' . base64_encode($user . ':' . $pass))
251 251
 				);
252 252
 			}
253 253
 
254 254
 			$args['timeout'] = 30;
255
-			if ( $media = remote_get_file($matches[2], '', $args) ) {
255
+			if ($media = remote_get_file($matches[2], '', $args)) {
256 256
 
257
-				if ( $this->is_enclosure === true ) {
257
+				if ($this->is_enclosure === true) {
258 258
 					$thumnail_flg = false;
259 259
 				} else {
260 260
 					$thumnail_flg = $this->match_count > 0 ? false : true;
261 261
 				}
262 262
 
263
-				$url = preg_split( '/wp-content/', $media );
264
-				$url = home_url( 'wp-content' . $url[1] );
263
+				$url = preg_split('/wp-content/', $media);
264
+				$url = home_url('wp-content' . $url[1]);
265 265
 
266
-				if ( $url == $this->enclosure_url ) {
266
+				if ($url == $this->enclosure_url) {
267 267
 					$thumnail_flg = true;
268 268
 				}
269 269
 				
270 270
 				$this->post->add_media($media, '', '', '', $thumnail_flg);
271 271
 				$this->match_count++;
272 272
 
273
-				return apply_filters( 'wp_syndicate_return_img', '<img' . $matches[1] . 'src="' . $url . '"' . $matches[3] . '>', $thumnail_flg, $url, $this->enclosure_url, $this->match_count );
273
+				return apply_filters('wp_syndicate_return_img', '<img' . $matches[1] . 'src="' . $url . '"' . $matches[3] . '>', $thumnail_flg, $url, $this->enclosure_url, $this->match_count);
274 274
 			} else {
275 275
 				return $matches[0];
276 276
 			} 
@@ -279,21 +279,21 @@  discard block
 block discarded – undo
279 279
 	}
280 280
 	
281 281
 	public function set_enclosure($link) {
282
-		if ( !empty($link) && is_object($this->post) && is_a($this->post, 'wp_post_helper') ) {
282
+		if (!empty($link) && is_object($this->post) && is_a($this->post, 'wp_post_helper')) {
283 283
 			$args    = array();
284
-			$user    = get_post_meta( $this->media_id, 'wp_syndicate-basic-auth-user', true );
285
-			$pass    = get_post_meta( $this->media_id, 'wp_syndicate-basic-auth-pass', true );
286
-			if ( !empty($user) && !empty($pass) ) {
284
+			$user    = get_post_meta($this->media_id, 'wp_syndicate-basic-auth-user', true);
285
+			$pass    = get_post_meta($this->media_id, 'wp_syndicate-basic-auth-pass', true);
286
+			if (!empty($user) && !empty($pass)) {
287 287
 				$args = array(
288
-					'headers' => array( 'Authorization' => 'Basic ' . base64_encode( $user . ':' . $pass ) )
288
+					'headers' => array('Authorization' => 'Basic ' . base64_encode($user . ':' . $pass))
289 289
 				);
290 290
 			}
291 291
 
292 292
 			$args['timeout'] = 30;
293
-			if ( $media = remote_get_file($link, '', $args) ) {
293
+			if ($media = remote_get_file($link, '', $args)) {
294 294
 				$this->post->add_media($media, '', '', '', true);
295
-				$url = preg_split( '/wp-content/', $media );
296
-				$url = home_url( 'wp-content' . $url[1] );
295
+				$url = preg_split('/wp-content/', $media);
296
+				$url = home_url('wp-content' . $url[1]);
297 297
 				$this->enclosure_url = $url;
298 298
 			}
299 299
 		}
Please login to merge, or discard this patch.
modules/admin.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-add_action( 'admin_menu', 'wp_syndicate_admin_menu' );
2
+add_action('admin_menu', 'wp_syndicate_admin_menu');
3 3
 function wp_syndicate_admin_menu() {
4
-	add_options_page( 'WP Syndicate', 'WP Syndicate', 'manage_options', 'wp_syndicate', 'wp_syndicate_options_page' );
4
+	add_options_page('WP Syndicate', 'WP Syndicate', 'manage_options', 'wp_syndicate', 'wp_syndicate_options_page');
5 5
 }
6 6
 
7 7
 function wp_syndicate_options_page() {
@@ -11,47 +11,47 @@  discard block
 block discarded – undo
11 11
 <h2>WP Syndicate</h2>
12 12
 
13 13
 <form action="options.php" method="post">
14
-<?php settings_fields( 'wp_syndicate_options' ); ?>
15
-<?php do_settings_sections( 'wp_syndicate' ); ?>
14
+<?php settings_fields('wp_syndicate_options'); ?>
15
+<?php do_settings_sections('wp_syndicate'); ?>
16 16
 
17
-<p class="submit"><input name="Submit" type="submit" value="<?php esc_attr_e( 'save' ); ?>" class="button-primary" /></p>
17
+<p class="submit"><input name="Submit" type="submit" value="<?php esc_attr_e('save'); ?>" class="button-primary" /></p>
18 18
 </form>
19 19
 
20 20
 </div>
21 21
 <?php
22 22
 }
23 23
 
24
-add_action( 'admin_init', 'wp_syndicate_admin_init' );
24
+add_action('admin_init', 'wp_syndicate_admin_init');
25 25
 function wp_syndicate_admin_init() {
26
-	register_setting( 'wp_syndicate_options', 'wp_syndicate_options', 'wp_syndicate_options_validate' );
26
+	register_setting('wp_syndicate_options', 'wp_syndicate_options', 'wp_syndicate_options_validate');
27 27
 
28
-	add_settings_section( 'wp_syndicate_main', __( 'configuration', WPSYND_DOMAIN ), 'wp_syndicate_section_text', 'wp_syndicate' );
28
+	add_settings_section('wp_syndicate_main', __('configuration', WPSYND_DOMAIN), 'wp_syndicate_section_text', 'wp_syndicate');
29 29
 
30
-	add_settings_field( 'wp_syndicate_error_mail', __( 'error mail recipient', WPSYND_DOMAIN ), 'wp_syndicate_setting_error_mail',
31
-	'wp_syndicate', 'wp_syndicate_main' );
32
-	add_settings_field( 'wp_syndicate_delete_log_term', __( 'feed log delete term', WPSYND_DOMAIN ), 'wp_syndicate_setting_delete_log_term',
33
-	'wp_syndicate', 'wp_syndicate_main' );
30
+	add_settings_field('wp_syndicate_error_mail', __('error mail recipient', WPSYND_DOMAIN), 'wp_syndicate_setting_error_mail',
31
+	'wp_syndicate', 'wp_syndicate_main');
32
+	add_settings_field('wp_syndicate_delete_log_term', __('feed log delete term', WPSYND_DOMAIN), 'wp_syndicate_setting_delete_log_term',
33
+	'wp_syndicate', 'wp_syndicate_main');
34 34
 }
35 35
 
36 36
 function wp_syndicate_section_text() {
37 37
 }
38 38
 
39 39
 function wp_syndicate_setting_error_mail() {
40
-	$options = get_option( 'wp_syndicate_options' );
40
+	$options = get_option('wp_syndicate_options');
41 41
 
42
-	echo '<input id="wp_syndicate_error_mail" name="wp_syndicate_options[error_mail]" size="40" type="text" value="' . esc_attr( $options['error_mail'] ) . '" />';
42
+	echo '<input id="wp_syndicate_error_mail" name="wp_syndicate_options[error_mail]" size="40" type="text" value="' . esc_attr($options['error_mail']) . '" />';
43 43
 }
44 44
 
45 45
 function wp_syndicate_setting_delete_log_term() {
46
-	$options = get_option( 'wp_syndicate_options' );
46
+	$options = get_option('wp_syndicate_options');
47 47
 
48
-	echo '<input id="wp_syndicate_delete_log_term" name="wp_syndicate_options[delete_log_term]" size="5" type="text" value="' . esc_attr( $options['delete_log_term'] ) . '" /> ' . esc_html( __( 'day', WPSYND_DOMAIN ) );
48
+	echo '<input id="wp_syndicate_delete_log_term" name="wp_syndicate_options[delete_log_term]" size="5" type="text" value="' . esc_attr($options['delete_log_term']) . '" /> ' . esc_html(__('day', WPSYND_DOMAIN));
49 49
 }
50 50
 
51
-function wp_syndicate_options_validate( $input ) {
51
+function wp_syndicate_options_validate($input) {
52 52
 	$newinput = array();
53
-	$newinput['error_mail'] = trim( $input['error_mail'] );
54
-	$newinput['delete_log_term'] = absint( $input['delete_log_term'] );
53
+	$newinput['error_mail'] = trim($input['error_mail']);
54
+	$newinput['delete_log_term'] = absint($input['delete_log_term']);
55 55
 	return $newinput;
56 56
 }
57 57
 
Please login to merge, or discard this patch.
wp-syndicate.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -10,28 +10,28 @@
 block discarded – undo
10 10
  * @package WordPress
11 11
  */
12 12
 
13
-if ( ! defined( 'WPSYND_DOMAIN' ) ) {
14
-	define( 'WPSYND_DOMAIN', 'wp-syndicate' ); }
13
+if (!defined('WPSYND_DOMAIN')) {
14
+	define('WPSYND_DOMAIN', 'wp-syndicate'); }
15 15
 
16
-if ( ! defined( 'WPSYND_PLUGIN_URL' ) ) {
17
-	define( 'WPSYND_PLUGIN_URL', plugins_url() . '/' . dirname( plugin_basename( __FILE__ ) ) ); }
16
+if (!defined('WPSYND_PLUGIN_URL')) {
17
+	define('WPSYND_PLUGIN_URL', plugins_url() . '/' . dirname(plugin_basename(__FILE__))); }
18 18
 
19
-if ( ! defined( 'WPSYND_PLUGIN_DIR' ) ) {
20
-	define( 'WPSYND_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . dirname( plugin_basename( __FILE__ ) ) ); }
19
+if (!defined('WPSYND_PLUGIN_DIR')) {
20
+	define('WPSYND_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . dirname(plugin_basename(__FILE__))); }
21 21
 
22
-load_plugin_textdomain( WPSYND_DOMAIN, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
23
-require_once( dirname( __FILE__ ) . '/lib/class-wp-post-helper.php' );
24
-require_once( dirname( __FILE__ ) . '/lib/class-logger.php' );
22
+load_plugin_textdomain(WPSYND_DOMAIN, false, dirname(plugin_basename(__FILE__)) . '/languages');
23
+require_once(dirname(__FILE__) . '/lib/class-wp-post-helper.php');
24
+require_once(dirname(__FILE__) . '/lib/class-logger.php');
25 25
 $portal_db_log_operator = new WP_SYND_Log_Operator();
26
-register_activation_hook( __FILE__, array( $portal_db_log_operator, 'set_event' ) );
27
-register_deactivation_hook( __FILE__, array( $portal_db_log_operator, 'delete_event' ) );
26
+register_activation_hook(__FILE__, array($portal_db_log_operator, 'set_event'));
27
+register_deactivation_hook(__FILE__, array($portal_db_log_operator, 'delete_event'));
28 28
 
29 29
 
30
-$hack_dir = trailingslashit( dirname( __FILE__ ) ) . 'modules/';
31
-opendir( $hack_dir );
32
-while ( ($ent = readdir()) !== false ) {
33
-	if ( ! is_dir( $ent ) && strtolower( substr( $ent,-4 ) ) === '.php' ) {
34
-		require_once( $hack_dir.$ent );
30
+$hack_dir = trailingslashit(dirname(__FILE__)) . 'modules/';
31
+opendir($hack_dir);
32
+while (($ent = readdir()) !== false) {
33
+	if (!is_dir($ent) && strtolower(substr($ent, -4)) === '.php') {
34
+		require_once($hack_dir . $ent);
35 35
 	}
36 36
 }
37 37
 closedir();
Please login to merge, or discard this patch.
lib/class-wp-post-helper.php 1 patch
Spacing   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 25
 */
26 26
 
27
-if ( defined( 'ABSPATH' ) ) :
27
+if (defined('ABSPATH')) :
28 28
 
29
-	require_once( ABSPATH . 'wp-admin/includes/image.php' );
30
-	require_once( ABSPATH . 'wp-admin/includes/post.php' );
29
+	require_once(ABSPATH . 'wp-admin/includes/image.php');
30
+	require_once(ABSPATH . 'wp-admin/includes/post.php');
31 31
 
32 32
 	class WP_Post_Helper {
33 33
 		public $post;
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		private $terms  = array();
45 45
 
46 46
 		public function __construct($args = array()) {
47
-			$this->init( $args );
47
+			$this->init($args);
48 48
 		}
49 49
 
50 50
 		// Get PostID
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 
60 60
 		// Init Post Data
61 61
 		public function init($args = array()) {
62
-			if ( is_object( $args ) ) {
63
-				$args = (array) $args; }
62
+			if (is_object($args)) {
63
+				$args = (array)$args; }
64 64
 			$this->attachment_id = array();
65 65
 			$this->tags   = array();
66 66
 			$this->medias = array();
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
 			$this->fields = array();
69 69
 			$this->media_count = 0;
70 70
 
71
-			if ( is_numeric( $args ) ) {
72
-				$post = get_post( intval( $args ) );
73
-				if ( $post && isset( $post->ID ) && ! is_wp_error( $post ) ) {
71
+			if (is_numeric($args)) {
72
+				$post = get_post(intval($args));
73
+				if ($post && isset($post->ID) && !is_wp_error($post)) {
74 74
 					$this->post_id = $post->ID;
75 75
 					$this->post = $post;
76 76
 					return true;
@@ -80,44 +80,44 @@  discard block
 block discarded – undo
80 80
 			} else {
81 81
 				$this->post = get_default_post_to_edit();
82 82
 				$this->post->post_category = null;
83
-				if ( is_array( $args ) && count( $args ) > 0 ) {
84
-					return $this->set( $args );
83
+				if (is_array($args) && count($args) > 0) {
84
+					return $this->set($args);
85 85
 				} else { 				return true; }
86 86
 			}
87 87
 		}
88 88
 
89 89
 		// Set Post Data
90 90
 		public function set($args) {
91
-			if ( is_object( $args ) ) {
92
-				$args = (array) $args; }
93
-			if ( ! is_array( $args ) ) {
91
+			if (is_object($args)) {
92
+				$args = (array)$args; }
93
+			if (!is_array($args)) {
94 94
 				return false; }
95 95
 
96
-			if ( isset( $args['ID'] ) || isset( $args['post_id'] ) ) {
97
-				$post_id = isset( $args['ID'] ) ? $args['ID'] : $args['post_id'];
98
-				$post = get_post( $post_id, 'ARRAY_A' );
99
-				if ( isset( $post['ID'] ) ) {
96
+			if (isset($args['ID']) || isset($args['post_id'])) {
97
+				$post_id = isset($args['ID']) ? $args['ID'] : $args['post_id'];
98
+				$post = get_post($post_id, 'ARRAY_A');
99
+				if (isset($post['ID'])) {
100 100
 					$this->post_id  = $post_id;
101 101
 					$this->post->ID = $post_id;
102
-					unset( $post['ID'] );
103
-					$this->set( $post );
102
+					unset($post['ID']);
103
+					$this->set($post);
104 104
 				}
105
-				unset( $post );
105
+				unset($post);
106 106
 			}
107 107
 
108 108
 			$post = $this->post;
109
-			foreach ( $post as $key => &$val ) {
110
-				if ( 'ID' !== $key && isset( $args[ $key ] ) ) {
111
-					$val = $args[ $key ];
109
+			foreach ($post as $key => &$val) {
110
+				if ('ID' !== $key && isset($args[$key])) {
111
+					$val = $args[$key];
112 112
 				}
113 113
 			}
114 114
 			$this->post = $post;
115 115
 
116
-			if ( isset( $args['post_tags'] ) ) {
116
+			if (isset($args['post_tags'])) {
117 117
 				$this->add_tags(
118
-					is_array( $args['post_tags'] )
118
+					is_array($args['post_tags'])
119 119
 					? $args['post_tags']
120
-					: explode( ',', $args['post_tags'] )
120
+					: explode(',', $args['post_tags'])
121 121
 				);
122 122
 			}
123 123
 
@@ -126,16 +126,16 @@  discard block
 block discarded – undo
126 126
 
127 127
 		// Add Post
128 128
 		public function insert() {
129
-			if ( ! isset( $this->post ) ) {
129
+			if (!isset($this->post)) {
130 130
 				return false; }
131 131
 
132 132
 			$this->postid   = 0;
133 133
 			$this->post->ID = 0;
134
-			$postid = wp_insert_post( $this->post );
135
-			if ( $postid && ! is_wp_error( $postid ) ) {
134
+			$postid = wp_insert_post($this->post);
135
+			if ($postid && !is_wp_error($postid)) {
136 136
 				$this->postid   = $postid;
137 137
 				$this->post->ID = $postid;
138
-				return $this->add_related_meta( $postid ) ? $postid : false;
138
+				return $this->add_related_meta($postid) ? $postid : false;
139 139
 			} else {
140 140
 				$this->postid   = $postid;
141 141
 				$this->post->ID = 0;
@@ -145,16 +145,16 @@  discard block
 block discarded – undo
145 145
 
146 146
 		// Update Post
147 147
 		public function update() {
148
-			if ( ! isset( $this->post ) ) {
148
+			if (!isset($this->post)) {
149 149
 				return false; }
150 150
 
151 151
 			$postid = $this->postid
152
-			? wp_update_post( $this->post )
153
-			: wp_insert_post( $this->post );
154
-			if ( $postid && ! is_wp_error( $postid ) ) {
152
+			? wp_update_post($this->post)
153
+			: wp_insert_post($this->post);
154
+			if ($postid && !is_wp_error($postid)) {
155 155
 				$this->postid   = $postid;
156 156
 				$this->post->ID = $postid;
157
-				return $this->add_related_meta( $postid ) ? $postid : false;
157
+				return $this->add_related_meta($postid) ? $postid : false;
158 158
 			} else {
159 159
 				$this->postid   = false;
160 160
 				$this->post->ID = 0;
@@ -163,39 +163,39 @@  discard block
 block discarded – undo
163 163
 		}
164 164
 
165 165
 		private function add_related_meta($postid) {
166
-			if ( ! $postid || is_wp_error( $postid ) ) {
166
+			if (!$postid || is_wp_error($postid)) {
167 167
 				return false; }
168 168
 
169
-			$this->postid   = $postid;
169
+			$this->postid = $postid;
170 170
 
171 171
 			// add Tags
172
-			if ( count( $this->tags ) > 0 ) {
173
-				$this->add_tags( $this->tags ); }
172
+			if (count($this->tags) > 0) {
173
+				$this->add_tags($this->tags); }
174 174
 			$this->tags = array();
175 175
 
176 176
 			// add medias
177
-			foreach ( $this->medias as $key => $val ) {
178
-				$this->add_media( $key, $val[0], $val[1], $val[2], $val[3] );
177
+			foreach ($this->medias as $key => $val) {
178
+				$this->add_media($key, $val[0], $val[1], $val[2], $val[3]);
179 179
 			}
180 180
 			$this->medias = array();
181 181
 
182 182
 			// add terms
183
-			foreach ( $this->terms as $taxonomy => $terms ) {
184
-				$this->add_terms( $taxonomy, $terms );
183
+			foreach ($this->terms as $taxonomy => $terms) {
184
+				$this->add_terms($taxonomy, $terms);
185 185
 			}
186 186
 			$this->terms = array();
187 187
 
188 188
 			// add Custom Fields
189
-			foreach ( $this->metas as $key => $val ) {
190
-				if ( is_array( $val ) ) {
191
-					$this->add_meta( $key, $val[0], isset( $val[1] ) ? $val[1] : true );
192
-				} else { 				$this->add_meta( $key, $val ); }
189
+			foreach ($this->metas as $key => $val) {
190
+				if (is_array($val)) {
191
+					$this->add_meta($key, $val[0], isset($val[1]) ? $val[1] : true);
192
+				} else { 				$this->add_meta($key, $val); }
193 193
 			}
194 194
 			$this->metas = array();
195 195
 
196 196
 			// add ACF Fields
197
-			foreach ( $this->fields as $key => $val ) {
198
-				$this->add_field( $key, $val );
197
+			foreach ($this->fields as $key => $val) {
198
+				$this->add_field($key, $val);
199 199
 			}
200 200
 			$this->fields = array();
201 201
 
@@ -204,38 +204,38 @@  discard block
 block discarded – undo
204 204
 
205 205
 		// Add Tag
206 206
 		public function add_tags($tags = array()) {
207
-			$tags = is_array( $tags ) ? $tags : explode( ',', $tags );
208
-			foreach ( $tags as $tag ) {
209
-				if ( ! empty( $tag ) && ! array_search( $tag, $this->tags ) ) {
207
+			$tags = is_array($tags) ? $tags : explode(',', $tags);
208
+			foreach ($tags as $tag) {
209
+				if (!empty($tag) && !array_search($tag, $this->tags)) {
210 210
 					$this->tags[] = $tag; }
211 211
 			}
212
-			unset( $tags );
212
+			unset($tags);
213 213
 
214
-			if ( $this->postid ) {
215
-				$tags = implode( ',', $this->tags );
214
+			if ($this->postid) {
215
+				$tags = implode(',', $this->tags);
216 216
 				$this->tags = array();
217
-				return wp_add_post_tags( $this->postid, $tags );
217
+				return wp_add_post_tags($this->postid, $tags);
218 218
 			}
219 219
 		}
220 220
 
221 221
 		// add terms
222 222
 		public function add_terms($taxonomy, $terms) {
223
-			if ( ! $this->postid ) {
224
-				if ( ! isset( $this->terms[ $taxonomy ] ) ) {
225
-					$this->terms[ $taxonomy ] = array(); }
226
-				foreach ( (array) $terms as $term ) {
227
-					if ( array_search( $term, $this->terms[ $taxonomy ] ) === false ) {
228
-						$this->terms[ $taxonomy ][] = $term; }
223
+			if (!$this->postid) {
224
+				if (!isset($this->terms[$taxonomy])) {
225
+					$this->terms[$taxonomy] = array(); }
226
+				foreach ((array)$terms as $term) {
227
+					if (array_search($term, $this->terms[$taxonomy]) === false) {
228
+						$this->terms[$taxonomy][] = $term; }
229 229
 				}
230 230
 			} else {
231
-				return wp_set_object_terms( $this->postid, $terms, $taxonomy );
231
+				return wp_set_object_terms($this->postid, $terms, $taxonomy);
232 232
 			}
233 233
 		}
234 234
 
235 235
 		// Add Media
236 236
 		public function add_media($filename, $title = null, $content = null, $excerpt = null, $thumbnail = false) {
237
-			if ( ! $this->postid ) {
238
-				$this->medias[ $filename ] = array(
237
+			if (!$this->postid) {
238
+				$this->medias[$filename] = array(
239 239
 				$title,
240 240
 				$content,
241 241
 				$excerpt,
@@ -244,16 +244,16 @@  discard block
 block discarded – undo
244 244
 				return;
245 245
 			}
246 246
 
247
-			if ( $filename && file_exists( $filename ) ) {
247
+			if ($filename && file_exists($filename)) {
248 248
 				$mime_type = '';
249
-				$wp_filetype = wp_check_filetype( basename( $filename ), null );
250
-				if ( isset( $wp_filetype['type'] ) && $wp_filetype['type'] ) {
249
+				$wp_filetype = wp_check_filetype(basename($filename), null);
250
+				if (isset($wp_filetype['type']) && $wp_filetype['type']) {
251 251
 					$mime_type = $wp_filetype['type']; }
252
-				unset( $wp_filetype );
252
+				unset($wp_filetype);
253 253
 
254
-				$title = isset( $title ) ? $title : preg_replace( '/\.[^.]+$/', '', basename( $filename ) );
255
-				$content = isset( $content ) ? $content : $title;
256
-				$excerpt = isset( $excerpt ) ? $excerpt : $content;
254
+				$title = isset($title) ? $title : preg_replace('/\.[^.]+$/', '', basename($filename));
255
+				$content = isset($content) ? $content : $title;
256
+				$excerpt = isset($excerpt) ? $excerpt : $content;
257 257
 				$attachment = array(
258 258
 				'post_mime_type' => $mime_type,
259 259
 				'post_parent'    => $this->postid,
@@ -264,19 +264,19 @@  discard block
 block discarded – undo
264 264
 				'post_status'    => 'inherit',
265 265
 				'menu_order'     => $this->media_count + 1,
266 266
 				);
267
-				if ( isset( $this->post->post_name ) && $this->post->post_name ) {
267
+				if (isset($this->post->post_name) && $this->post->post_name) {
268 268
 					$attachment['post_name'] = $this->post->post_name; }
269
-				$attachment_id = wp_insert_attachment( $attachment, $filename, $this->postid );
270
-				unset( $attachment );
269
+				$attachment_id = wp_insert_attachment($attachment, $filename, $this->postid);
270
+				unset($attachment);
271 271
 
272
-				if ( ! is_wp_error( $attachment_id ) ) {
272
+				if (!is_wp_error($attachment_id)) {
273 273
 					$this->media_count++;
274 274
 					$this->attachment_id[] = $attachment_id;
275
-					$attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
276
-					wp_update_attachment_metadata( $attachment_id,  $attachment_data );
277
-					unset( $attachment_data );
278
-					if ( $thumbnail ) {
279
-						set_post_thumbnail( $this->postid, $attachment_id ); }
275
+					$attachment_data = wp_generate_attachment_metadata($attachment_id, $filename);
276
+					wp_update_attachment_metadata($attachment_id, $attachment_data);
277
+					unset($attachment_data);
278
+					if ($thumbnail) {
279
+						set_post_thumbnail($this->postid, $attachment_id); }
280 280
 
281 281
 					return $attachment_id;
282 282
 				} else {
@@ -289,58 +289,58 @@  discard block
 block discarded – undo
289 289
 
290 290
 		// Add Custom Field
291 291
 		public function add_meta($metakey, $val, $unique = true) {
292
-			if ( ! $this->postid ) {
293
-				$this->metas[ $metakey ] = array( $val, $unique );
294
-			} else { 			return $val ? add_post_meta( $this->postid, $metakey, $val, $unique ) : false; }
292
+			if (!$this->postid) {
293
+				$this->metas[$metakey] = array($val, $unique);
294
+			} else { 			return $val ? add_post_meta($this->postid, $metakey, $val, $unique) : false; }
295 295
 		}
296 296
 
297 297
 		// Add Advanced Custom Field
298 298
 		public function add_field($field_key, $val) {
299
-			if ( ! $this->postid ) {
300
-				$this->fields[ $field_key ] = $val;
301
-			} else { 			return $val ? update_field( $field_key, $val, $this->postid ) : false; }
299
+			if (!$this->postid) {
300
+				$this->fields[$field_key] = $val;
301
+			} else { 			return $val ? update_field($field_key, $val, $this->postid) : false; }
302 302
 		}
303 303
 	}
304 304
 
305 305
 	function remote_get_file($url = null, $file_dir = '', $headers = array()) {
306
-		if ( ! $url ) {
306
+		if (!$url) {
307 307
 			return false; }
308 308
 
309
-		if ( empty( $file_dir ) ) {
309
+		if (empty($file_dir)) {
310 310
 			 $upload_dir = wp_upload_dir();
311
-			 $file_dir = isset( $upload_dir['path'] ) ? $upload_dir['path'] : '';
311
+			 $file_dir = isset($upload_dir['path']) ? $upload_dir['path'] : '';
312 312
 		}
313
-		$file_dir = trailingslashit( $file_dir );
313
+		$file_dir = trailingslashit($file_dir);
314 314
 
315 315
 		// make directory
316
-		if ( ! file_exists( $file_dir ) ) {
317
-			$dirs = explode( '/', $file_dir );
316
+		if (!file_exists($file_dir)) {
317
+			$dirs = explode('/', $file_dir);
318 318
 			$subdir = '/';
319
-			foreach ( $dirs as $dir ) {
320
-				if ( ! empty( $dir ) ) {
319
+			foreach ($dirs as $dir) {
320
+				if (!empty($dir)) {
321 321
 					$subdir .= $dir . '/';
322
-					if ( ! file_exists( $subdir ) ) {
323
-						mkdir( $subdir );
322
+					if (!file_exists($subdir)) {
323
+						mkdir($subdir);
324 324
 					}
325 325
 				}
326 326
 			}
327 327
 		}
328 328
 
329 329
 		// remote get!
330
-		$photo = $file_dir . basename( $url );
330
+		$photo = $file_dir . basename($url);
331 331
 
332
-		if ( ! file_exists( $photo ) ) {
333
-			$response = wp_remote_get( $url, $headers );
334
-			if ( ! is_wp_error( $response ) && 200 === $response['response']['code'] ) {
332
+		if (!file_exists($photo)) {
333
+			$response = wp_remote_get($url, $headers);
334
+			if (!is_wp_error($response) && 200 === $response['response']['code']) {
335 335
 				$photo_data = $response['body'];
336
-				file_put_contents( $photo, $photo_data );
337
-				unset( $photo_data );
336
+				file_put_contents($photo, $photo_data);
337
+				unset($photo_data);
338 338
 			} else {
339 339
 				$photo = false;
340 340
 			}
341
-			unset( $response );
341
+			unset($response);
342 342
 		}
343
-		return file_exists( $photo ) ? $photo : false;
343
+		return file_exists($photo) ? $photo : false;
344 344
 	}
345 345
 
346 346
 endif;
Please login to merge, or discard this patch.
lib/class-logger.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 	private static $instance;
4 4
 
5 5
 	public static function get_instance() {
6
-		if ( isset( self::$instance ) ) {
6
+		if (isset(self::$instance)) {
7 7
 			return self::$instance; }
8 8
 
9 9
 		self::$instance = new WP_SYND_logger;
@@ -12,15 +12,15 @@  discard block
 block discarded – undo
12 12
 
13 13
 	private function __construct() {}
14 14
 
15
-	public function success( $title, $msg ) {
16
-		return $this->create_log( 'success', $title, $msg );
15
+	public function success($title, $msg) {
16
+		return $this->create_log('success', $title, $msg);
17 17
 	}
18 18
 
19
-	public function error( $title, $msg ) {
20
-		return $this->create_log( 'error', $title, $msg );
19
+	public function error($title, $msg) {
20
+		return $this->create_log('error', $title, $msg);
21 21
 	}
22 22
 
23
-	private function create_log( $status, $title, $msg ) {
23
+	private function create_log($status, $title, $msg) {
24 24
 		$args = array(
25 25
 					'post_title'    => $title,
26 26
 					'post_content'  => $msg,
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
 					'post_status'   => 'publish',
29 29
 					'post_type'     => 'wp-syndicate-log',
30 30
 				);
31
-		$post_id = wp_insert_post( $args );
32
-		$post_id && wp_set_object_terms( $post_id, $status, 'log-category', true );
31
+		$post_id = wp_insert_post($args);
32
+		$post_id && wp_set_object_terms($post_id, $status, 'log-category', true);
33 33
 
34 34
 		return $post_id;
35 35
 	}
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 	private $key = 'twicedaily';
42 42
 
43 43
 	public function __construct() {
44
-		add_action( 'init', array( $this, 'init' ) );
45
-		add_action( $this->event, array( $this, 'delete_log' ) );
46
-		add_action( 'restrict_manage_posts', array( $this, 'restrict_manage_posts' ) );
44
+		add_action('init', array($this, 'init'));
45
+		add_action($this->event, array($this, 'delete_log'));
46
+		add_action('restrict_manage_posts', array($this, 'restrict_manage_posts'));
47 47
 	}
48 48
 
49 49
 	public function init() {
@@ -63,18 +63,18 @@  discard block
 block discarded – undo
63 63
 			'edit_published_feed_logs',
64 64
 		);
65 65
 
66
-		$role = get_role( 'administrator' );
67
-		foreach ( $capabilities as $cap ) {
68
-			$role->add_cap( $cap );
66
+		$role = get_role('administrator');
67
+		foreach ($capabilities as $cap) {
68
+			$role->add_cap($cap);
69 69
 		}
70
-		register_post_type( 'wp-syndicate-log',
70
+		register_post_type('wp-syndicate-log',
71 71
 			array(
72
-										'labels' => array( 'name' => __( 'Syndication Log', WPSYND_DOMAIN ) ),
72
+										'labels' => array('name' => __('Syndication Log', WPSYND_DOMAIN)),
73 73
 										'public' => true,
74 74
 										'publicly_queryable' => false,
75 75
 										'has_archive' => false,
76 76
 										'hierarchical' => false,
77
-										'supports' => array( 'title', 'editor' ),
77
+										'supports' => array('title', 'editor'),
78 78
 										'rewrite' => false,
79 79
 										'can_export' => true,
80 80
 										'capability_type' => 'feed_log',
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 										'log-category',
88 88
 										'wp-syndicate-log',
89 89
 										array(
90
-										'label' => __( 'status', WPSYND_DOMAIN ),
90
+										'label' => __('status', WPSYND_DOMAIN),
91 91
 										'public' => false,
92 92
 										'query_var' => false,
93 93
 										'show_ui' => true,
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
 	public function set_event() {
100 100
 		$action_time = time() + 60;
101 101
 
102
-		wp_schedule_event( $action_time, $this->key, $this->event );
103
-		spawn_cron( $action_time );
102
+		wp_schedule_event($action_time, $this->key, $this->event);
103
+		spawn_cron($action_time);
104 104
 	}
105 105
 
106 106
 	public function delete_event() {
107
-		wp_clear_scheduled_hook( $this->event );
107
+		wp_clear_scheduled_hook($this->event);
108 108
 	}
109 109
 
110 110
 	public function delete_log() {
@@ -114,21 +114,21 @@  discard block
 block discarded – undo
114 114
 				'suppress_filters' => false,
115 115
 		);
116 116
 
117
-		add_filter( 'post_where', array( $this, 'post_where' ) );
118
-		$results = get_posts( $args );
119
-		remove_filter( 'post_where', array( $this, 'post_where' ) );
117
+		add_filter('post_where', array($this, 'post_where'));
118
+		$results = get_posts($args);
119
+		remove_filter('post_where', array($this, 'post_where'));
120 120
 
121
-		if ( ! empty( $results ) && is_array( $results ) ) {
122
-			foreach ( $results as $result ) {
123
-				wp_delete_post( $result->ID, true );
121
+		if (!empty($results) && is_array($results)) {
122
+			foreach ($results as $result) {
123
+				wp_delete_post($result->ID, true);
124 124
 			}
125 125
 		}
126 126
 	}
127 127
 
128 128
 	public function post_where($where) {
129
-		$options = get_option( 'wp_syndicate_options', 14 );
130
-		$term_day = ! empty( $options['delete_log_term'] ) ? $options['delete_log_term'] : 7;
131
-		$date = date_i18n( 'Y/m/d H:i:s', strtotime( '-' . $term_day . ' day' ) );
129
+		$options = get_option('wp_syndicate_options', 14);
130
+		$term_day = !empty($options['delete_log_term']) ? $options['delete_log_term'] : 7;
131
+		$date = date_i18n('Y/m/d H:i:s', strtotime('-' . $term_day . ' day'));
132 132
 
133 133
 		$where .= " AND post_date < '" . $date . "'";
134 134
 		return $where;
@@ -136,14 +136,14 @@  discard block
 block discarded – undo
136 136
 
137 137
 	public function restrict_manage_posts() {
138 138
 		global $post_type;
139
-		if ( is_object_in_taxonomy( $post_type, 'log-category' ) ) {
140
-			$terms = get_terms( 'log-category' );
141
-			$get = isset( $_GET['term'] ) ? $_GET['term'] : '';
139
+		if (is_object_in_taxonomy($post_type, 'log-category')) {
140
+			$terms = get_terms('log-category');
141
+			$get = isset($_GET['term']) ? $_GET['term'] : '';
142 142
 ?>
143 143
 <select name="term">
144 144
 	<option value="0"></option>
145
-	<?php foreach ( $terms as $term ) : ?>
146
-		<option <?php selected( $get, $term->slug ); ?> value="<?php echo esc_attr( $term->slug ); ?>"><?php echo esc_html( $term->name ); ?></option>
145
+	<?php foreach ($terms as $term) : ?>
146
+		<option <?php selected($get, $term->slug); ?> value="<?php echo esc_attr($term->slug); ?>"><?php echo esc_html($term->name); ?></option>
147 147
 	<?php endforeach; ?>
148 148
 </select>
149 149
 <input type="hidden" name="taxonomy" value="log-category" />
Please login to merge, or discard this patch.
modules/syndicate.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 	public function init() {
10 10
 		$capabilities = array(
11
-		    'read_wp_syndicate',
11
+			'read_wp_syndicate',
12 12
 			'edit_wp_syndicate',
13 13
 			'delete_wp_syndicate',
14 14
 			'edit_wp_syndicates',
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
 		}
30 30
 		register_post_type( 'wp-syndicate',
31 31
 			array(
32
-	    								'labels' => array( 'name' => __( 'Syndication', WPSYND_DOMAIN ) ),
33
-	    								'public' => true,
34
-	    								'publicly_queryable' => false,
32
+										'labels' => array( 'name' => __( 'Syndication', WPSYND_DOMAIN ) ),
33
+										'public' => true,
34
+										'publicly_queryable' => false,
35 35
 										'has_archive' => false,
36
-	    								'hierarchical' => false,
37
-	    								'supports' => array( 'title' ),
38
-	    								'rewrite' => false,
39
-	    								'can_export' => true,
40
-	    								'menu_position' => 28,
41
-	    								'capability_type' => 'wp_syndicate',
36
+										'hierarchical' => false,
37
+										'supports' => array( 'title' ),
38
+										'rewrite' => false,
39
+										'can_export' => true,
40
+										'menu_position' => 28,
41
+										'capability_type' => 'wp_syndicate',
42 42
 										'capabilities'    => $capabilities,
43 43
 										'map_meta_cap' => true,
44 44
 										'register_meta_box_cb' => array( $this, 'add_meta_box' ),
45
-	    							));
45
+									));
46 46
 	}
47 47
 
48 48
 	public function add_meta_box() {
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 class WP_SYNDICATE {
3 3
 
4 4
 	public function __construct() {
5
-		add_action( 'init', array( $this, 'init' ) );
6
-		add_action( 'save_post', array( $this, 'save_meta_box' ) );
5
+		add_action('init', array($this, 'init'));
6
+		add_action('save_post', array($this, 'save_meta_box'));
7 7
 	}
8 8
 
9 9
 	public function init() {
@@ -23,114 +23,114 @@  discard block
 block discarded – undo
23 23
 			'edit_published_wp_syndicates',
24 24
 		);
25 25
 
26
-		$role = get_role( 'administrator' );
27
-		foreach ( $capabilities as $cap ) {
28
-			$role->add_cap( $cap );
26
+		$role = get_role('administrator');
27
+		foreach ($capabilities as $cap) {
28
+			$role->add_cap($cap);
29 29
 		}
30
-		register_post_type( 'wp-syndicate',
30
+		register_post_type('wp-syndicate',
31 31
 			array(
32
-	    								'labels' => array( 'name' => __( 'Syndication', WPSYND_DOMAIN ) ),
32
+	    								'labels' => array('name' => __('Syndication', WPSYND_DOMAIN)),
33 33
 	    								'public' => true,
34 34
 	    								'publicly_queryable' => false,
35 35
 										'has_archive' => false,
36 36
 	    								'hierarchical' => false,
37
-	    								'supports' => array( 'title' ),
37
+	    								'supports' => array('title'),
38 38
 	    								'rewrite' => false,
39 39
 	    								'can_export' => true,
40 40
 	    								'menu_position' => 28,
41 41
 	    								'capability_type' => 'wp_syndicate',
42 42
 										'capabilities'    => $capabilities,
43 43
 										'map_meta_cap' => true,
44
-										'register_meta_box_cb' => array( $this, 'add_meta_box' ),
44
+										'register_meta_box_cb' => array($this, 'add_meta_box'),
45 45
 	    							));
46 46
 	}
47 47
 
48 48
 	public function add_meta_box() {
49 49
 		global $hook_suffix;
50 50
 
51
-		add_meta_box( 'wp_syndicate_meta_box', __( 'configuration', WPSYND_DOMAIN ), array( $this, 'meta_box_wp_syndicate' ),'wp-syndicate' );
52
-		if ( 'post.php' === $hook_suffix ) {
53
-			add_meta_box( 'wp_syndicate_meta_box_import_test', __( 'Import Test', WPSYND_DOMAIN ), array( $this, 'meta_box_wp_syndicate_import_test' ),'wp-syndicate' );
51
+		add_meta_box('wp_syndicate_meta_box', __('configuration', WPSYND_DOMAIN), array($this, 'meta_box_wp_syndicate'), 'wp-syndicate');
52
+		if ('post.php' === $hook_suffix) {
53
+			add_meta_box('wp_syndicate_meta_box_import_test', __('Import Test', WPSYND_DOMAIN), array($this, 'meta_box_wp_syndicate_import_test'), 'wp-syndicate');
54 54
 		}
55 55
 	}
56 56
 
57 57
 	public function meta_box_wp_syndicate() {
58
-		wp_nonce_field( 'wp_syndicate_meta_box', 'wp_syndicate_meta_box_nonce' );
58
+		wp_nonce_field('wp_syndicate_meta_box', 'wp_syndicate_meta_box_nonce');
59 59
 
60
-		$feed_url = get_post_meta( get_the_ID(), 'wp_syndicate-feed-url', true );
61
-		$feed_retrieve_term = get_post_meta( get_the_ID(), 'wp_syndicate-feed-retrieve-term', true );
62
-		$author_id = get_post_meta( get_the_ID(), 'wp_syndicate-author-id', true );
60
+		$feed_url = get_post_meta(get_the_ID(), 'wp_syndicate-feed-url', true);
61
+		$feed_retrieve_term = get_post_meta(get_the_ID(), 'wp_syndicate-feed-retrieve-term', true);
62
+		$author_id = get_post_meta(get_the_ID(), 'wp_syndicate-author-id', true);
63 63
 		$statuses = get_post_statuses();
64
-		unset( $statuses['pending'] );
65
-		$status = get_post_meta( get_the_ID(), 'wp_syndicate-default-post-status', true );
66
-		$post_types = get_post_types( array( 'public' => true ) );
67
-		$post_type = get_post_meta( get_the_ID(), 'wp_syndicate-default-post-type', true );
68
-		$registration_method = get_post_meta( get_the_ID(), 'wp_syndicate-registration-method', true );
69
-		$user_id = get_post_meta( get_the_ID(), 'wp_syndicate-basic-auth-user', true );
70
-		$password = get_post_meta( get_the_ID(), 'wp_syndicate-basic-auth-pass', true );
64
+		unset($statuses['pending']);
65
+		$status = get_post_meta(get_the_ID(), 'wp_syndicate-default-post-status', true);
66
+		$post_types = get_post_types(array('public' => true));
67
+		$post_type = get_post_meta(get_the_ID(), 'wp_syndicate-default-post-type', true);
68
+		$registration_method = get_post_meta(get_the_ID(), 'wp_syndicate-registration-method', true);
69
+		$user_id = get_post_meta(get_the_ID(), 'wp_syndicate-basic-auth-user', true);
70
+		$password = get_post_meta(get_the_ID(), 'wp_syndicate-basic-auth-pass', true);
71 71
 
72 72
 ?>
73 73
 <table class="form-table">
74
-<tr><th><?php esc_html_e( 'feed URL', WPSYND_DOMAIN ) ?></th><td><input type="text" name="wp_syndicate-feed-url" size="40" value="<?php echo esc_attr( $feed_url ); ?>" /></td></tr>
75
-<tr><th><?php esc_html_e( 'feed retrieve term', WPSYND_DOMAIN ) ?></th><td><input type="number" step="1" min="1" max="999" name="wp_syndicate-feed-retrieve-term" size="20" value="<?php echo esc_attr( $feed_retrieve_term ); ?>" /> <?php esc_html_e( 'min', WPSYND_DOMAIN ) ?></td></tr>
76
-<tr><th><?php esc_html_e( 'Author ID', WPSYND_DOMAIN ) ?></th><td><input type="text" name="wp_syndicate-author-id" size="7" value="<?php echo esc_attr( $author_id ); ?>" /></td></tr>
77
-<tr><th><?php esc_html_e( 'Default Post Type', WPSYND_DOMAIN ) ?></th>
74
+<tr><th><?php esc_html_e('feed URL', WPSYND_DOMAIN) ?></th><td><input type="text" name="wp_syndicate-feed-url" size="40" value="<?php echo esc_attr($feed_url); ?>" /></td></tr>
75
+<tr><th><?php esc_html_e('feed retrieve term', WPSYND_DOMAIN) ?></th><td><input type="number" step="1" min="1" max="999" name="wp_syndicate-feed-retrieve-term" size="20" value="<?php echo esc_attr($feed_retrieve_term); ?>" /> <?php esc_html_e('min', WPSYND_DOMAIN) ?></td></tr>
76
+<tr><th><?php esc_html_e('Author ID', WPSYND_DOMAIN) ?></th><td><input type="text" name="wp_syndicate-author-id" size="7" value="<?php echo esc_attr($author_id); ?>" /></td></tr>
77
+<tr><th><?php esc_html_e('Default Post Type', WPSYND_DOMAIN) ?></th>
78 78
 <td>
79 79
 <select name="wp_syndicate-default-post-type">
80
-<?php foreach ( $post_types as $key => $val ) : ?>
81
-	<option <?php selected( $post_type, $key ); ?> value="<?php echo esc_attr( $key ); ?>"><?php echo esc_attr( $val ); ?></option>
80
+<?php foreach ($post_types as $key => $val) : ?>
81
+	<option <?php selected($post_type, $key); ?> value="<?php echo esc_attr($key); ?>"><?php echo esc_attr($val); ?></option>
82 82
 <?php endforeach; ?>
83 83
 </select>
84 84
 </td></tr>
85
-<tr><th><?php esc_html_e( 'Default Post Status', WPSYND_DOMAIN ) ?></th>
85
+<tr><th><?php esc_html_e('Default Post Status', WPSYND_DOMAIN) ?></th>
86 86
 <td>
87 87
 <select name="wp_syndicate-default-post-status">
88
-<?php foreach ( $statuses as $key => $val ) : ?>
89
-	<option <?php selected( $status, $key ); ?> value="<?php echo esc_attr( $key ); ?>"><?php echo esc_attr( $val ); ?></option>
88
+<?php foreach ($statuses as $key => $val) : ?>
89
+	<option <?php selected($status, $key); ?> value="<?php echo esc_attr($key); ?>"><?php echo esc_attr($val); ?></option>
90 90
 <?php endforeach; ?>
91 91
 </select>
92 92
 </td></tr>
93
-<tr><th><?php esc_html_e( 'Registration method', WPSYND_DOMAIN ) ?></th>
93
+<tr><th><?php esc_html_e('Registration method', WPSYND_DOMAIN) ?></th>
94 94
 <td>
95 95
 <select name="wp_syndicate-registration-method">
96
-	<option <?php selected( $registration_method, 'insert' ); ?> value="insert">insert only</option>
97
-	<option <?php selected( $registration_method, 'insert-or-update' ); ?> value="insert-or-update">insert or update</option>
96
+	<option <?php selected($registration_method, 'insert'); ?> value="insert">insert only</option>
97
+	<option <?php selected($registration_method, 'insert-or-update'); ?> value="insert-or-update">insert or update</option>
98 98
 </select>
99 99
 </td></tr>
100
-<tr><th><?php esc_html_e( 'Basic Auth User ID', WPSYND_DOMAIN ) ?></th><td><input type="text" name="wp_syndicate-basic-auth-user" size="40" value="<?php echo esc_attr( $user_id ); ?>" /></td></tr>
101
-<tr><th><?php esc_html_e( 'Basic Auth Password', WPSYND_DOMAIN ) ?></th><td><input type="password" name="wp_syndicate-basic-auth-pass" size="40" value="<?php echo esc_attr( $password ); ?>" /></td></tr>
102
-<?php do_action( 'wp_syndicate_add_metabox' ); ?>
100
+<tr><th><?php esc_html_e('Basic Auth User ID', WPSYND_DOMAIN) ?></th><td><input type="text" name="wp_syndicate-basic-auth-user" size="40" value="<?php echo esc_attr($user_id); ?>" /></td></tr>
101
+<tr><th><?php esc_html_e('Basic Auth Password', WPSYND_DOMAIN) ?></th><td><input type="password" name="wp_syndicate-basic-auth-pass" size="40" value="<?php echo esc_attr($password); ?>" /></td></tr>
102
+<?php do_action('wp_syndicate_add_metabox'); ?>
103 103
 </table>
104 104
 <?php
105 105
 	}
106 106
 
107 107
 	public function meta_box_wp_syndicate_import_test($post) {
108
-		submit_button( 'Save and Test Excute', 'primary', 'wp_syndicate_import_test_excute' );
108
+		submit_button('Save and Test Excute', 'primary', 'wp_syndicate_import_test_excute');
109 109
 	}
110 110
 
111
-	public function save_meta_box( $post_id ) {
112
-		if ( wp_is_post_revision( $post_id ) || get_post_type() !== 'wp-syndicate' || ! current_user_can( 'edit_wp_syndicate', $post_id )
113
-				|| ! isset( $_POST['wp_syndicate_meta_box_nonce'] ) || ! wp_verify_nonce( $_POST['wp_syndicate_meta_box_nonce'], 'wp_syndicate_meta_box' ) ) {
111
+	public function save_meta_box($post_id) {
112
+		if (wp_is_post_revision($post_id) || get_post_type() !== 'wp-syndicate' || !current_user_can('edit_wp_syndicate', $post_id)
113
+				|| !isset($_POST['wp_syndicate_meta_box_nonce']) || !wp_verify_nonce($_POST['wp_syndicate_meta_box_nonce'], 'wp_syndicate_meta_box')) {
114 114
 			return;
115 115
 		}
116 116
 
117
-		isset( $_POST['wp_syndicate-feed-url'] ) && update_post_meta( $post_id, 'wp_syndicate-feed-url', esc_url( $_POST['wp_syndicate-feed-url'] ) );
118
-		isset( $_POST['wp_syndicate-feed-retrieve-term'] ) && update_post_meta( $post_id, 'wp_syndicate-feed-retrieve-term', absint( $_POST['wp_syndicate-feed-retrieve-term'] ) );
119
-		isset( $_POST['wp_syndicate-author-id'] ) && update_post_meta( $post_id, 'wp_syndicate-author-id', absint( $_POST['wp_syndicate-author-id'] ) );
120
-		isset( $_POST['wp_syndicate-default-post-status'] ) && update_post_meta( $post_id, 'wp_syndicate-default-post-status', trim( $_POST['wp_syndicate-default-post-status'] ) );
121
-		isset( $_POST['wp_syndicate-default-post-type'] ) && update_post_meta( $post_id, 'wp_syndicate-default-post-type', trim( $_POST['wp_syndicate-default-post-type'] ) );
122
-		isset( $_POST['wp_syndicate-registration-method'] ) && update_post_meta( $post_id, 'wp_syndicate-registration-method', trim( $_POST['wp_syndicate-registration-method'] ) );
123
-		isset( $_POST['wp_syndicate-basic-auth-user'] ) && update_post_meta( $post_id, 'wp_syndicate-basic-auth-user', trim( $_POST['wp_syndicate-basic-auth-user'] ) );
124
-		isset( $_POST['wp_syndicate-basic-auth-pass'] ) && update_post_meta( $post_id, 'wp_syndicate-basic-auth-pass', trim( $_POST['wp_syndicate-basic-auth-pass'] ) );
117
+		isset($_POST['wp_syndicate-feed-url']) && update_post_meta($post_id, 'wp_syndicate-feed-url', esc_url($_POST['wp_syndicate-feed-url']));
118
+		isset($_POST['wp_syndicate-feed-retrieve-term']) && update_post_meta($post_id, 'wp_syndicate-feed-retrieve-term', absint($_POST['wp_syndicate-feed-retrieve-term']));
119
+		isset($_POST['wp_syndicate-author-id']) && update_post_meta($post_id, 'wp_syndicate-author-id', absint($_POST['wp_syndicate-author-id']));
120
+		isset($_POST['wp_syndicate-default-post-status']) && update_post_meta($post_id, 'wp_syndicate-default-post-status', trim($_POST['wp_syndicate-default-post-status']));
121
+		isset($_POST['wp_syndicate-default-post-type']) && update_post_meta($post_id, 'wp_syndicate-default-post-type', trim($_POST['wp_syndicate-default-post-type']));
122
+		isset($_POST['wp_syndicate-registration-method']) && update_post_meta($post_id, 'wp_syndicate-registration-method', trim($_POST['wp_syndicate-registration-method']));
123
+		isset($_POST['wp_syndicate-basic-auth-user']) && update_post_meta($post_id, 'wp_syndicate-basic-auth-user', trim($_POST['wp_syndicate-basic-auth-user']));
124
+		isset($_POST['wp_syndicate-basic-auth-pass']) && update_post_meta($post_id, 'wp_syndicate-basic-auth-pass', trim($_POST['wp_syndicate-basic-auth-pass']));
125 125
 
126
-		if ( isset( $_POST['wp_syndicate_import_test_excute'] ) ) {
127
-			remove_action( 'save_post', array( $this, 'save_meta_box' ) );
126
+		if (isset($_POST['wp_syndicate_import_test_excute'])) {
127
+			remove_action('save_post', array($this, 'save_meta_box'));
128 128
 			$action = new WP_SYND_Action();
129
-			$action->import( $post_id );
130
-			add_action( 'save_post', array( $this, 'save_meta_box' ) );
129
+			$action->import($post_id);
130
+			add_action('save_post', array($this, 'save_meta_box'));
131 131
 		}
132 132
 		
133
-		do_action( 'wp_syndicate_save_meta_box', $post_id );
133
+		do_action('wp_syndicate_save_meta_box', $post_id);
134 134
 	}
135 135
 }
136 136
 new WP_SYNDICATE();
Please login to merge, or discard this patch.