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 ( a9bb7a...f1689e )
by takahiro
07:56
created
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.
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   +107 added lines, -107 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 ) ) {
321
-					$subdir .= $dir . '/';
322
-					if ( ! file_exists( $subdir ) ) {
323
-						mkdir( $subdir );
319
+			foreach ($dirs as $dir) {
320
+				if (!empty($dir)) {
321
+					$subdir .= $dir.'/';
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   +36 added lines, -36 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
 										'menu_position' => 27,
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 										'log-category',
89 89
 										'wp-syndicate-log',
90 90
 										array(
91
-										'label' => __( 'status', WPSYND_DOMAIN ),
91
+										'label' => __('status', WPSYND_DOMAIN),
92 92
 										'public' => false,
93 93
 										'query_var' => false,
94 94
 										'show_ui' => true,
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
 	public function set_event() {
101 101
 		$action_time = time() + 60;
102 102
 
103
-		wp_schedule_event( $action_time, $this->key, $this->event );
104
-		spawn_cron( $action_time );
103
+		wp_schedule_event($action_time, $this->key, $this->event);
104
+		spawn_cron($action_time);
105 105
 	}
106 106
 
107 107
 	public function delete_event() {
108
-		wp_clear_scheduled_hook( $this->event );
108
+		wp_clear_scheduled_hook($this->event);
109 109
 	}
110 110
 
111 111
 	public function delete_log() {
@@ -115,36 +115,36 @@  discard block
 block discarded – undo
115 115
 				'suppress_filters' => false,
116 116
 		);
117 117
 
118
-		add_filter( 'post_where', array( $this, 'post_where' ) );
119
-		$results = get_posts( $args );
120
-		remove_filter( 'post_where', array( $this, 'post_where' ) );
118
+		add_filter('post_where', array($this, 'post_where'));
119
+		$results = get_posts($args);
120
+		remove_filter('post_where', array($this, 'post_where'));
121 121
 
122
-		if ( ! empty( $results ) && is_array( $results ) ) {
123
-			foreach ( $results as $result ) {
124
-				wp_delete_post( $result->ID, true );
122
+		if (!empty($results) && is_array($results)) {
123
+			foreach ($results as $result) {
124
+				wp_delete_post($result->ID, true);
125 125
 			}
126 126
 		}
127 127
 	}
128 128
 
129 129
 	public function post_where($where) {
130
-		$options = get_option( 'wp_syndicate_options', 14 );
131
-		$term_day = ! empty( $options['delete_log_term'] ) ? $options['delete_log_term'] : 7;
132
-		$date = date_i18n( 'Y/m/d H:i:s', strtotime( '-' . $term_day . ' day' ) );
130
+		$options = get_option('wp_syndicate_options', 14);
131
+		$term_day = !empty($options['delete_log_term']) ? $options['delete_log_term'] : 7;
132
+		$date = date_i18n('Y/m/d H:i:s', strtotime('-'.$term_day.' day'));
133 133
 
134
-		$where .= " AND post_date < '" . $date . "'";
134
+		$where .= " AND post_date < '".$date."'";
135 135
 		return $where;
136 136
 	}
137 137
 
138 138
 	public function restrict_manage_posts() {
139 139
 		global $post_type;
140
-		if ( is_object_in_taxonomy( $post_type, 'log-category' ) ) {
141
-			$terms = get_terms( 'log-category' );
142
-			$get = isset( $_GET['term'] ) ? $_GET['term'] : '';
140
+		if (is_object_in_taxonomy($post_type, 'log-category')) {
141
+			$terms = get_terms('log-category');
142
+			$get = isset($_GET['term']) ? $_GET['term'] : '';
143 143
 ?>
144 144
 <select name="term">
145 145
 	<option value="0"></option>
146
-	<?php foreach ( $terms as $term ) : ?>
147
-		<option <?php selected( $get, $term->slug ); ?> value="<?php echo esc_attr( $term->slug ); ?>"><?php echo esc_html( $term->name ); ?></option>
146
+	<?php foreach ($terms as $term) : ?>
147
+		<option <?php selected($get, $term->slug); ?> value="<?php echo esc_attr($term->slug); ?>"><?php echo esc_html($term->name); ?></option>
148 148
 	<?php endforeach; ?>
149 149
 </select>
150 150
 <input type="hidden" name="taxonomy" value="log-category" />
Please login to merge, or discard this patch.
modules/action.php 2 patches
Spacing   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -14,51 +14,51 @@  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( 'publish_to_trash', array( $this, 'publish_to_trash' ));
19
-		add_action( 'save_post', array( $this, 'set_event' ) );
20
-		add_action( 'admin_head', array( $this, 'ping' ) );
21
-		add_action( 'template_redirect', array( $this, 'ping' ) );
22
-		add_action( 'init', array( $this, 'init' ) );
17
+		add_filter('cron_schedules', array($this, 'cron_schedules'));
18
+		add_action('publish_to_trash', array($this, 'publish_to_trash'));
19
+		add_action('save_post', array($this, 'set_event'));
20
+		add_action('admin_head', array($this, 'ping'));
21
+		add_action('template_redirect', array($this, 'ping'));
22
+		add_action('init', array($this, 'init'));
23 23
 	}
24 24
 
25 25
 	public function init() {
26 26
 		$posts = get_posts($this->args);
27 27
 
28
-		if ( empty($posts) )
28
+		if (empty($posts))
29 29
 			return;
30 30
 
31
-		foreach ( $posts as $post ) {
32
-			add_action( 'wp_syndicate_' . $post->post_name . '_import', array( $this, 'import' ) );
31
+		foreach ($posts as $post) {
32
+			add_action('wp_syndicate_'.$post->post_name.'_import', array($this, 'import'));
33 33
 		}
34 34
 	}
35 35
 
36 36
 	public function publish_to_trash($post) {
37
-		if ( 'wp-syndicate' !== $post->post_type )
37
+		if ('wp-syndicate' !== $post->post_type)
38 38
 			return;
39 39
 
40
-		$hook = 'wp_syndicate_' .  str_replace( '__trashed', '', $post->post_name ) . '_import';
41
-		if ( wp_next_scheduled( $hook, array( $post->ID )) )
42
-			var_dump(wp_clear_scheduled_hook( $hook, array( $post->ID ) ));
40
+		$hook = 'wp_syndicate_'.str_replace('__trashed', '', $post->post_name).'_import';
41
+		if (wp_next_scheduled($hook, array($post->ID)))
42
+			var_dump(wp_clear_scheduled_hook($hook, array($post->ID)));
43 43
 	}
44 44
 
45 45
 	public function ping() {
46 46
 		$posts = get_posts($this->args);
47
-		if ( empty($posts) )
47
+		if (empty($posts))
48 48
 			return;
49 49
 
50
-		foreach ( $posts as $post ) {
50
+		foreach ($posts as $post) {
51 51
 			$key = $post->post_name;
52
-			$hook = 'wp_syndicate_' . $key . '_import';
52
+			$hook = 'wp_syndicate_'.$key.'_import';
53 53
 
54
-			if ( !wp_next_scheduled( $hook, array( $post->ID ) ) ) {
54
+			if (!wp_next_scheduled($hook, array($post->ID))) {
55 55
 				$this->set_event($post->ID);
56
-				$subject = '[' . get_bloginfo( 'name' ) . ']' . __( 'WP Cron Error', WPSYND_DOMAIN );
57
-				$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";
56
+				$subject = '['.get_bloginfo('name').']'.__('WP Cron Error', WPSYND_DOMAIN);
57
+				$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";
58 58
 				$msg .= admin_url();
59
-				WP_SYND_logger::get_instance()->error( $subject, $msg );
60
-				$options = get_option( 'wp_syndicate_options' );
61
-				wp_mail( $options['error_mail'], $subject, $msg );
59
+				WP_SYND_logger::get_instance()->error($subject, $msg);
60
+				$options = get_option('wp_syndicate_options');
61
+				wp_mail($options['error_mail'], $subject, $msg);
62 62
 			}
63 63
 		}
64 64
 	}
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
 	public function cron_schedules($schedules) {
67 67
 		$posts = get_posts($this->args);
68 68
 
69
-		if ( empty($posts) ) {
69
+		if (empty($posts)) {
70 70
 			return $schedules;
71 71
 		}
72 72
 
73
-		foreach ( $posts as $post ) {
74
-			$key = 'wp_syndicate_' . $post->post_name;
75
-			$interval_min = get_post_meta( $post->ID, 'wp_syndicate-feed-retrieve-term', true );
76
-			$interval = intval($interval_min)*60;
77
-			$display = get_the_title( $post->ID );
78
-			$schedules[$key] = array( 'interval' => $interval, 'display' => $display );
73
+		foreach ($posts as $post) {
74
+			$key = 'wp_syndicate_'.$post->post_name;
75
+			$interval_min = get_post_meta($post->ID, 'wp_syndicate-feed-retrieve-term', true);
76
+			$interval = intval($interval_min) * 60;
77
+			$display = get_the_title($post->ID);
78
+			$schedules[$key] = array('interval' => $interval, 'display' => $display);
79 79
 		}
80 80
 
81 81
 		return $schedules;
@@ -83,63 +83,63 @@  discard block
 block discarded – undo
83 83
 
84 84
 	public function set_event($post_id) {
85 85
 
86
-		if ( wp_is_post_revision($post_id) )
86
+		if (wp_is_post_revision($post_id))
87 87
 			return;
88 88
 
89
-		if ( 'wp-syndicate' != get_post_type($post_id) )
89
+		if ('wp-syndicate' != get_post_type($post_id))
90 90
 			return;
91 91
 
92
-		$post = get_post( $post_id );
93
-		if ( !is_object($post) )
92
+		$post = get_post($post_id);
93
+		if (!is_object($post))
94 94
 			return;
95 95
 
96 96
 		$key = $post->post_name;
97
-		$interval_min = get_post_meta( $post_id, 'wp_syndicate-feed-retrieve-term', true );
98
-		$interval = intval($interval_min)*60;
97
+		$interval_min = get_post_meta($post_id, 'wp_syndicate-feed-retrieve-term', true);
98
+		$interval = intval($interval_min) * 60;
99 99
 		$action_time = time() + $interval;
100 100
 
101
-		$hook = 'wp_syndicate_' . $key . '_import';
102
-		$event = 'wp_syndicate_' . $key;
101
+		$hook = 'wp_syndicate_'.$key.'_import';
102
+		$event = 'wp_syndicate_'.$key;
103 103
 
104
-		if ( wp_next_scheduled( $hook, array( $post_id )) )
105
-			wp_clear_scheduled_hook( $hook, array( $post_id ) );
104
+		if (wp_next_scheduled($hook, array($post_id)))
105
+			wp_clear_scheduled_hook($hook, array($post_id));
106 106
 
107
-		wp_schedule_event( $action_time, $event, $hook, array( $post_id )  );
108
-		spawn_cron( $action_time );
107
+		wp_schedule_event($action_time, $event, $hook, array($post_id));
108
+		spawn_cron($action_time);
109 109
 	}
110 110
 
111 111
 	public function import($post_id) {
112 112
 		global $allowedposttags;
113 113
 
114
-		$allowedposttags = apply_filters( 'wp_syndicate_allowedposttags', $allowedposttags );
114
+		$allowedposttags = apply_filters('wp_syndicate_allowedposttags', $allowedposttags);
115 115
 
116
-		$options = get_option( 'wp_syndicate_options' );
116
+		$options = get_option('wp_syndicate_options');
117 117
 		$post = get_post($post_id);
118 118
 
119
-		if ( !is_object($post) )
119
+		if (!is_object($post))
120 120
 			return;
121 121
 
122 122
 		$this->media_id = $post_id;
123
-		$feed_url = html_entity_decode(get_post_meta( $post_id, 'wp_syndicate-feed-url', true ), ENT_QUOTES, 'UTF-8');
123
+		$feed_url = html_entity_decode(get_post_meta($post_id, 'wp_syndicate-feed-url', true), ENT_QUOTES, 'UTF-8');
124 124
 
125
-		add_action('wp_feed_options', function(&$feed){
125
+		add_action('wp_feed_options', function(&$feed) {
126 126
 			$feed->set_timeout(30);
127 127
 			$feed->force_feed(true);
128 128
 			$feed->enable_cache(false);
129 129
 		}, 10);
130 130
 
131
-		add_filter( 'wp_feed_cache_transient_lifetime' , array( $this, 'return_0' ) );
132
-		$rss = fetch_feed( $feed_url );
133
-		remove_filter( 'wp_feed_cache_transient_lifetime' , array( $this, 'return_0' ) );
134
-		if ( is_wp_error( $rss ) ) {
135
-			$subject = '[' . get_bloginfo( 'name' ) . ']' . __( 'feed import failed', WPSYND_DOMAIN );
136
-			$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";
137
-			$msg .= __( 'below error message', WPSYND_DOMAIN ) . "\n";
131
+		add_filter('wp_feed_cache_transient_lifetime', array($this, 'return_0'));
132
+		$rss = fetch_feed($feed_url);
133
+		remove_filter('wp_feed_cache_transient_lifetime', array($this, 'return_0'));
134
+		if (is_wp_error($rss)) {
135
+			$subject = '['.get_bloginfo('name').']'.__('feed import failed', WPSYND_DOMAIN);
136
+			$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";
137
+			$msg .= __('below error message', WPSYND_DOMAIN)."\n";
138 138
 			$msg .= $rss->get_error_message()."\n\n";
139
-			$msg .= __( 'feed URL', WPSYND_DOMAIN ) . ':' . $feed_url;
140
-			$error_post_id = WP_SYND_logger::get_instance()->error( $subject, $msg );
141
-			$msg .= admin_url('/post.php?post=' . $error_post_id . '&action=edit');
142
-			wp_mail( $options['error_mail'], $subject, $msg );
139
+			$msg .= __('feed URL', WPSYND_DOMAIN).':'.$feed_url;
140
+			$error_post_id = WP_SYND_logger::get_instance()->error($subject, $msg);
141
+			$msg .= admin_url('/post.php?post='.$error_post_id.'&action=edit');
142
+			wp_mail($options['error_mail'], $subject, $msg);
143 143
 			return;
144 144
 		}
145 145
 
@@ -149,138 +149,138 @@  discard block
 block discarded – undo
149 149
 		$rss_items = $rss->get_items(0, 50);
150 150
 		$post_ids = array();
151 151
 		$flg = true;
152
-		$registration_method = get_post_meta( $post_id, 'wp_syndicate-registration-method', true );
153
-		$post_type = get_post_meta( $post_id, 'wp_syndicate-default-post-type', true );
154
-		foreach ( $rss_items as $item ) {
152
+		$registration_method = get_post_meta($post_id, 'wp_syndicate-registration-method', true);
153
+		$post_type = get_post_meta($post_id, 'wp_syndicate-default-post-type', true);
154
+		foreach ($rss_items as $item) {
155 155
 			$this->is_enclosure = false;
156 156
 
157 157
 			//投稿ID取得
158
-			$slug = $post->post_name . '_' . $item->get_id();
159
-			$set_post = get_page_by_path( sanitize_title($slug), OBJECT, $post_type );
158
+			$slug = $post->post_name.'_'.$item->get_id();
159
+			$set_post = get_page_by_path(sanitize_title($slug), OBJECT, $post_type);
160 160
 			$set_post_id = $set_post == null ? '' : $set_post->ID;
161 161
 
162
-			if ( empty($set_post_id) ) {
162
+			if (empty($set_post_id)) {
163 163
 				global $wpdb;
164
-				$db_ret = $wpdb->get_row( $wpdb->prepare( "SELECT count(1) as cnt FROM $wpdb->postmeta WHERE meta_key='%s'", $slug) );
165
-				if ( $db_ret === null || $db_ret->cnt !== '0' )
164
+				$db_ret = $wpdb->get_row($wpdb->prepare("SELECT count(1) as cnt FROM $wpdb->postmeta WHERE meta_key='%s'", $slug));
165
+				if ($db_ret === null || $db_ret->cnt !== '0')
166 166
 					continue;
167 167
 			}
168 168
 
169
-			if ( $registration_method == 'insert' && is_object($set_post) ) {
169
+			if ($registration_method == 'insert' && is_object($set_post)) {
170 170
 				continue;
171 171
 			}
172 172
 
173 173
 			$updated = empty($set_post_id) ? false : true;
174
-			$is_skip = apply_filters( 'wp_syndicate_is_skip', false, $item, $updated, $set_post_id, $post_id );
175
-			if ( $is_skip ) {
174
+			$is_skip = apply_filters('wp_syndicate_is_skip', false, $item, $updated, $set_post_id, $post_id);
175
+			if ($is_skip) {
176 176
 				continue;
177 177
 			}
178 178
 
179 179
 			$post_args = array(
180 180
 								'ID' => $set_post_id,
181 181
 								'post_name' => $slug,
182
-								'post_date' => apply_filters( 'wp_syndicate_get_date', $item->get_date('Y/m/d H:i:s'), $post_id ),
183
- 								'post_title' => apply_filters( 'wp_syndicate_get_title', $item->get_title(), $post_id ),
182
+								'post_date' => apply_filters('wp_syndicate_get_date', $item->get_date('Y/m/d H:i:s'), $post_id),
183
+ 								'post_title' => apply_filters('wp_syndicate_get_title', $item->get_title(), $post_id),
184 184
 								'post_content' => '',
185 185
 							);
186
-			if ( !$updated ) {
187
-				$post_args['post_author'] = get_post_meta( $post_id, 'wp_syndicate-author-id', true );
188
-				$post_args['post_status'] = get_post_meta( $post_id, 'wp_syndicate-default-post-status', true );
189
-				$post_args['post_type'] = get_post_meta( $post_id, 'wp_syndicate-default-post-type', true );
186
+			if (!$updated) {
187
+				$post_args['post_author'] = get_post_meta($post_id, 'wp_syndicate-author-id', true);
188
+				$post_args['post_status'] = get_post_meta($post_id, 'wp_syndicate-default-post-status', true);
189
+				$post_args['post_type'] = get_post_meta($post_id, 'wp_syndicate-default-post-type', true);
190 190
 			}
191 191
 			$this->post = new wp_post_helper($post_args);
192 192
 
193 193
 			//画像の登録
194
-			if ( $updated ) {
195
-				$images = get_attached_media( 'image', $set_post_id );
196
-				if ( is_array( $images ) ) {
197
-					foreach ( $images as $image ) {
198
-						wp_delete_attachment( $image->ID );
194
+			if ($updated) {
195
+				$images = get_attached_media('image', $set_post_id);
196
+				if (is_array($images)) {
197
+					foreach ($images as $image) {
198
+						wp_delete_attachment($image->ID);
199 199
 					}
200 200
 				}
201 201
 			}
202 202
 
203
-			$content = apply_filters( 'the_content', $item->get_content() );
204
-			if ( $item->get_enclosure() && !empty($item->get_enclosure()->link) ) {
203
+			$content = apply_filters('the_content', $item->get_content());
204
+			if ($item->get_enclosure() && !empty($item->get_enclosure()->link)) {
205 205
 				$this->is_enclosure = true;
206
-				$this->set_enclosure( $item->get_enclosure()->link );
206
+				$this->set_enclosure($item->get_enclosure()->link);
207 207
 			}
208 208
 
209 209
 			$this->match_count = 0;
210
-			$content = preg_replace_callback( '#<img([^>]*)src=["\']([^"\']+)["\']([^>]*)>#i',  array($this, 'update_link'), $content, -1 );
210
+			$content = preg_replace_callback('#<img([^>]*)src=["\']([^"\']+)["\']([^>]*)>#i', array($this, 'update_link'), $content, -1);
211 211
 			$this->match_count = 0;
212 212
 			$this->post->set(array(
213
-								'post_content' => apply_filters( 'wp_syndicate_get_content', $content, $post_id )
213
+								'post_content' => apply_filters('wp_syndicate_get_content', $content, $post_id)
214 214
 							));
215
-			$this->post->add_meta( 'wp_syndicate-origin-of-syndication-slug', $post->post_name, true );
216
-			$this->post->add_meta( 'wp_syndicate-origin-of-syndication-siteurl', $this->host, true );
215
+			$this->post->add_meta('wp_syndicate-origin-of-syndication-slug', $post->post_name, true);
216
+			$this->post->add_meta('wp_syndicate-origin-of-syndication-siteurl', $this->host, true);
217 217
 
218 218
 			$update_post_id = $this->post->update();
219
-			if ( !$update_post_id ) {
219
+			if (!$update_post_id) {
220 220
 				$flg = false;
221 221
 			} else {
222
-				update_post_meta( $update_post_id, $slug, 1 );
223
-				do_action( 'wp_syndicate_save_post', $update_post_id, $item, $updated, $post_id );
222
+				update_post_meta($update_post_id, $slug, 1);
223
+				do_action('wp_syndicate_save_post', $update_post_id, $item, $updated, $post_id);
224 224
 				$post_ids[] = $update_post_id;
225 225
 			}
226 226
 		}
227 227
 
228
-		if ( $flg ) {
229
-			$subject = '[' . get_bloginfo( 'name' ) . ']' . __( 'feed import success', WPSYND_DOMAIN );
230
-			$msg = __( 'feed URL:', WPSYND_DOMAIN ) . $feed_url . "\n";
231
-			$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";
232
-			$msg .= __( 'below ID data updates', WPSYND_DOMAIN ) . "\n";
233
-			$msg .= implode( "\n", $post_ids );
234
-			WP_SYND_logger::get_instance()->success( $subject, $msg );
228
+		if ($flg) {
229
+			$subject = '['.get_bloginfo('name').']'.__('feed import success', WPSYND_DOMAIN);
230
+			$msg = __('feed URL:', WPSYND_DOMAIN).$feed_url."\n";
231
+			$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";
232
+			$msg .= __('below ID data updates', WPSYND_DOMAIN)."\n";
233
+			$msg .= implode("\n", $post_ids);
234
+			WP_SYND_logger::get_instance()->success($subject, $msg);
235 235
 		} else {
236
-			$subject = '[' . get_bloginfo( 'name' ) . ']' . __( 'feed import failed', WPSYND_DOMAIN );
237
-			$msg = __( 'feed URL:', WPSYND_DOMAIN ) . $feed_url . "\n";
238
-			$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";
239
-			$msg .= __( 'below ID data updates', WPSYND_DOMAIN ) . "\n";
240
-			$msg .= implode( "\n", $post_ids );
241
-			$error_post_id = WP_SYND_logger::get_instance()->error( $subject, $msg );
242
-			$msg .= admin_url('/post.php?post=' . $error_post_id . '&action=edit');
243
-			wp_mail( $options['error_mail'], $subject, $msg );
236
+			$subject = '['.get_bloginfo('name').']'.__('feed import failed', WPSYND_DOMAIN);
237
+			$msg = __('feed URL:', WPSYND_DOMAIN).$feed_url."\n";
238
+			$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";
239
+			$msg .= __('below ID data updates', WPSYND_DOMAIN)."\n";
240
+			$msg .= implode("\n", $post_ids);
241
+			$error_post_id = WP_SYND_logger::get_instance()->error($subject, $msg);
242
+			$msg .= admin_url('/post.php?post='.$error_post_id.'&action=edit');
243
+			wp_mail($options['error_mail'], $subject, $msg);
244 244
 		}
245 245
 
246 246
 	}
247 247
 
248
-	public function return_0( $seconds ) {
248
+	public function return_0($seconds) {
249 249
 		return 0;
250 250
 	}
251 251
 
252
-	public function update_link( $matches ) {
252
+	public function update_link($matches) {
253 253
 
254
-		if ( is_array($matches) && array_key_exists(2, $matches) && isset($this->post) && is_object($this->post) && is_a($this->post, 'wp_post_helper') ) {
254
+		if (is_array($matches) && array_key_exists(2, $matches) && isset($this->post) && is_object($this->post) && is_a($this->post, 'wp_post_helper')) {
255 255
 			$args    = array();
256
-			$user    = get_post_meta( $this->media_id, 'wp_syndicate-basic-auth-user', true );
257
-			$pass    = get_post_meta( $this->media_id, 'wp_syndicate-basic-auth-pass', true );
258
-			if ( !empty($user) && !empty($pass) ) {
256
+			$user    = get_post_meta($this->media_id, 'wp_syndicate-basic-auth-user', true);
257
+			$pass    = get_post_meta($this->media_id, 'wp_syndicate-basic-auth-pass', true);
258
+			if (!empty($user) && !empty($pass)) {
259 259
 				$args = array(
260
-					'headers' => array( 'Authorization' => 'Basic ' . base64_encode( $user . ':' . $pass ) )
260
+					'headers' => array('Authorization' => 'Basic '.base64_encode($user.':'.$pass))
261 261
 				);
262 262
 			}
263 263
 
264 264
 			$args['timeout'] = 30;
265
-			if ( $media = remote_get_file($matches[2], '', $args) ) {
265
+			if ($media = remote_get_file($matches[2], '', $args)) {
266 266
 
267
-				if ( $this->is_enclosure === true ) {
267
+				if ($this->is_enclosure === true) {
268 268
 					$thumnail_flg = false;
269 269
 				} else {
270 270
 					$thumnail_flg = $this->match_count > 0 ? false : true;
271 271
 				}
272 272
 
273
-				$url = preg_split( '/wp-content/', $media );
274
-				$url = home_url( 'wp-content' . $url[1] );
273
+				$url = preg_split('/wp-content/', $media);
274
+				$url = home_url('wp-content'.$url[1]);
275 275
 
276
-				if ( $url == $this->enclosure_url ) {
276
+				if ($url == $this->enclosure_url) {
277 277
 					$thumnail_flg = true;
278 278
 				}
279 279
 
280 280
 				$this->post->add_media($media, '', '', '', $thumnail_flg);
281 281
 				$this->match_count++;
282 282
 
283
-				return apply_filters( 'wp_syndicate_return_img', '<img' . $matches[1] . 'src="' . $url . '"' . $matches[3] . '>', $thumnail_flg, $url, $this->enclosure_url, $this->match_count );
283
+				return apply_filters('wp_syndicate_return_img', '<img'.$matches[1].'src="'.$url.'"'.$matches[3].'>', $thumnail_flg, $url, $this->enclosure_url, $this->match_count);
284 284
 			} else {
285 285
 				return $matches[0];
286 286
 			}
@@ -289,21 +289,21 @@  discard block
 block discarded – undo
289 289
 	}
290 290
 
291 291
 	public function set_enclosure($link) {
292
-		if ( !empty($link) && is_object($this->post) && is_a($this->post, 'wp_post_helper') ) {
292
+		if (!empty($link) && is_object($this->post) && is_a($this->post, 'wp_post_helper')) {
293 293
 			$args    = array();
294
-			$user    = get_post_meta( $this->media_id, 'wp_syndicate-basic-auth-user', true );
295
-			$pass    = get_post_meta( $this->media_id, 'wp_syndicate-basic-auth-pass', true );
296
-			if ( !empty($user) && !empty($pass) ) {
294
+			$user    = get_post_meta($this->media_id, 'wp_syndicate-basic-auth-user', true);
295
+			$pass    = get_post_meta($this->media_id, 'wp_syndicate-basic-auth-pass', true);
296
+			if (!empty($user) && !empty($pass)) {
297 297
 				$args = array(
298
-					'headers' => array( 'Authorization' => 'Basic ' . base64_encode( $user . ':' . $pass ) )
298
+					'headers' => array('Authorization' => 'Basic '.base64_encode($user.':'.$pass))
299 299
 				);
300 300
 			}
301 301
 
302 302
 			$args['timeout'] = 30;
303
-			if ( $media = remote_get_file($link, '', $args) ) {
303
+			if ($media = remote_get_file($link, '', $args)) {
304 304
 				$this->post->add_media($media, '', '', '', true);
305
-				$url = preg_split( '/wp-content/', $media );
306
-				$url = home_url( 'wp-content' . $url[1] );
305
+				$url = preg_split('/wp-content/', $media);
306
+				$url = home_url('wp-content'.$url[1]);
307 307
 				$this->enclosure_url = $url;
308 308
 			}
309 309
 		}
Please login to merge, or discard this patch.
Braces   +30 added lines, -20 removed lines patch added patch discarded remove patch
@@ -25,8 +25,9 @@  discard block
 block discarded – undo
25 25
 	public function init() {
26 26
 		$posts = get_posts($this->args);
27 27
 
28
-		if ( empty($posts) )
29
-			return;
28
+		if ( empty($posts) ) {
29
+					return;
30
+		}
30 31
 
31 32
 		foreach ( $posts as $post ) {
32 33
 			add_action( 'wp_syndicate_' . $post->post_name . '_import', array( $this, 'import' ) );
@@ -34,18 +35,21 @@  discard block
 block discarded – undo
34 35
 	}
35 36
 
36 37
 	public function publish_to_trash($post) {
37
-		if ( 'wp-syndicate' !== $post->post_type )
38
-			return;
38
+		if ( 'wp-syndicate' !== $post->post_type ) {
39
+					return;
40
+		}
39 41
 
40 42
 		$hook = 'wp_syndicate_' .  str_replace( '__trashed', '', $post->post_name ) . '_import';
41
-		if ( wp_next_scheduled( $hook, array( $post->ID )) )
42
-			var_dump(wp_clear_scheduled_hook( $hook, array( $post->ID ) ));
43
+		if ( wp_next_scheduled( $hook, array( $post->ID )) ) {
44
+					var_dump(wp_clear_scheduled_hook( $hook, array( $post->ID ) ));
45
+		}
43 46
 	}
44 47
 
45 48
 	public function ping() {
46 49
 		$posts = get_posts($this->args);
47
-		if ( empty($posts) )
48
-			return;
50
+		if ( empty($posts) ) {
51
+					return;
52
+		}
49 53
 
50 54
 		foreach ( $posts as $post ) {
51 55
 			$key = $post->post_name;
@@ -83,15 +87,18 @@  discard block
 block discarded – undo
83 87
 
84 88
 	public function set_event($post_id) {
85 89
 
86
-		if ( wp_is_post_revision($post_id) )
87
-			return;
90
+		if ( wp_is_post_revision($post_id) ) {
91
+					return;
92
+		}
88 93
 
89
-		if ( 'wp-syndicate' != get_post_type($post_id) )
90
-			return;
94
+		if ( 'wp-syndicate' != get_post_type($post_id) ) {
95
+					return;
96
+		}
91 97
 
92 98
 		$post = get_post( $post_id );
93
-		if ( !is_object($post) )
94
-			return;
99
+		if ( !is_object($post) ) {
100
+					return;
101
+		}
95 102
 
96 103
 		$key = $post->post_name;
97 104
 		$interval_min = get_post_meta( $post_id, 'wp_syndicate-feed-retrieve-term', true );
@@ -101,8 +108,9 @@  discard block
 block discarded – undo
101 108
 		$hook = 'wp_syndicate_' . $key . '_import';
102 109
 		$event = 'wp_syndicate_' . $key;
103 110
 
104
-		if ( wp_next_scheduled( $hook, array( $post_id )) )
105
-			wp_clear_scheduled_hook( $hook, array( $post_id ) );
111
+		if ( wp_next_scheduled( $hook, array( $post_id )) ) {
112
+					wp_clear_scheduled_hook( $hook, array( $post_id ) );
113
+		}
106 114
 
107 115
 		wp_schedule_event( $action_time, $event, $hook, array( $post_id )  );
108 116
 		spawn_cron( $action_time );
@@ -116,8 +124,9 @@  discard block
 block discarded – undo
116 124
 		$options = get_option( 'wp_syndicate_options' );
117 125
 		$post = get_post($post_id);
118 126
 
119
-		if ( !is_object($post) )
120
-			return;
127
+		if ( !is_object($post) ) {
128
+					return;
129
+		}
121 130
 
122 131
 		$this->media_id = $post_id;
123 132
 		$feed_url = html_entity_decode(get_post_meta( $post_id, 'wp_syndicate-feed-url', true ), ENT_QUOTES, 'UTF-8');
@@ -162,8 +171,9 @@  discard block
 block discarded – undo
162 171
 			if ( empty($set_post_id) ) {
163 172
 				global $wpdb;
164 173
 				$db_ret = $wpdb->get_row( $wpdb->prepare( "SELECT count(1) as cnt FROM $wpdb->postmeta WHERE meta_key='%s'", $slug) );
165
-				if ( $db_ret === null || $db_ret->cnt !== '0' )
166
-					continue;
174
+				if ( $db_ret === null || $db_ret->cnt !== '0' ) {
175
+									continue;
176
+				}
167 177
 			}
168 178
 
169 179
 			if ( $registration_method == 'insert' && is_object($set_post) ) {
Please login to merge, or discard this patch.