@@ -14,41 +14,41 @@ discard block |
||
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 | - $hook = 'wp_syndicate_' . $key . '_import'; |
|
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 |
||
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 ) { |
|
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 ); |
|
63 | + foreach ($posts as $post) { |
|
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); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | return $schedules; |
@@ -73,63 +73,63 @@ discard block |
||
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 | - $hook = 'wp_syndicate_' . $key . '_import'; |
|
92 | - $event = 'wp_syndicate_' . $key; |
|
91 | + $hook = 'wp_syndicate_'.$key.'_import'; |
|
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"; |
|
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 | 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 | - $msg .= admin_url('/post.php?post=' . $error_post_id . '&action=edit'); |
|
132 | - wp_mail( $options['error_mail'], $subject, $msg ); |
|
129 | + $msg .= __('feed URL', WPSYND_DOMAIN).':'.$feed_url; |
|
130 | + $error_post_id = WP_SYND_logger::get_instance()->error($subject, $msg); |
|
131 | + $msg .= admin_url('/post.php?post='.$error_post_id.'&action=edit'); |
|
132 | + wp_mail($options['error_mail'], $subject, $msg); |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
@@ -139,138 +139,138 @@ discard block |
||
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 | - $slug = $post->post_name . '_' . $item->get_id(); |
|
149 | - $set_post = get_page_by_path( sanitize_title($slug), OBJECT, $post_type ); |
|
148 | + $slug = $post->post_name.'_'.$item->get_id(); |
|
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 ); |
|
232 | - $msg .= admin_url('/post.php?post=' . $error_post_id . '&action=edit'); |
|
233 | - wp_mail( $options['error_mail'], $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 | + $msg .= admin_url('/post.php?post='.$error_post_id.'&action=edit'); |
|
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 |
||
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 | } |