Passed
Branch master (56cde3)
by Christian
02:25
created
version.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,17 +40,17 @@  discard block
 block discarded – undo
40 40
 namespace PodloveSubscribeButton;
41 41
 use \PodloveSubscribeButton\Model;
42 42
 
43
-define( __NAMESPACE__ . '\DATABASE_VERSION', 2 );
43
+define(__NAMESPACE__ . '\DATABASE_VERSION', 2);
44 44
 
45
-add_action( 'admin_init', '\PodloveSubscribeButton\maybe_run_database_migrations' );
46
-add_action( 'admin_init', '\PodloveSubscribeButton\run_database_migrations', 5 );
45
+add_action('admin_init', '\PodloveSubscribeButton\maybe_run_database_migrations');
46
+add_action('admin_init', '\PodloveSubscribeButton\run_database_migrations', 5);
47 47
 
48 48
 function maybe_run_database_migrations() {
49 49
 	$database_version = get_option('podlove_subscribe_button_plugin_database_version');
50 50
 
51
-	if ( $database_version === false ) {
51
+	if ($database_version === false) {
52 52
 		// plugin has just been installed or Plugin Version < 1.3
53
-		update_option( 'podlove_subscribe_button_plugin_database_version', DATABASE_VERSION );
53
+		update_option('podlove_subscribe_button_plugin_database_version', DATABASE_VERSION);
54 54
 	}
55 55
 }
56 56
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 function migrate_for_current_blog() {
75 75
 	$database_version = get_option('podlove_subscribe_button_plugin_database_version');
76 76
 
77
-	for ($i = $database_version+1; $i <= DATABASE_VERSION; $i++) { 
77
+	for ($i = $database_version + 1; $i <= DATABASE_VERSION; $i++) { 
78 78
 		\PodloveSubscribeButton\run_migrations_for_version($i);
79 79
 		update_option('podlove_subscribe_button_plugin_database_version', $i);
80 80
 	}
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
  * 
88 88
  * @param  int $version
89 89
  */
90
-function run_migrations_for_version( $version ) {
90
+function run_migrations_for_version($version) {
91 91
 	global $wpdb;
92 92
 	
93
-	switch ( $version ) {}
93
+	switch ($version) {}
94 94
 
95 95
 }
96 96
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,8 +55,9 @@
 block discarded – undo
55 55
 }
56 56
 
57 57
 function run_database_migrations() {
58
-	if (get_option('podlove_subscribe_button_plugin_database_version') >= DATABASE_VERSION)
59
-		return;
58
+	if (get_option('podlove_subscribe_button_plugin_database_version') >= DATABASE_VERSION) {
59
+			return;
60
+	}
60 61
 
61 62
 	if (is_multisite()) {
62 63
 		set_time_limit(0); // may take a while, depending on network size
Please login to merge, or discard this patch.
helper.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 	$plugin  = basename(\PodloveSubscribeButton\PLUGIN_DIR) . '/' . \PodloveSubscribeButton\PLUGIN_FILE_NAME;
9 9
 	$blogids = $wpdb->get_col("SELECT blog_id FROM " . $wpdb->blogs);
10 10
 
11
-	if (!is_array($blogids))
11
+	if ( ! is_array($blogids))
12 12
 		return;
13 13
 
14 14
 	foreach ($blogids as $blog_id) {
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,9 @@
 block discarded – undo
8 8
 	$plugin  = basename(\PodloveSubscribeButton\PLUGIN_DIR) . '/' . \PodloveSubscribeButton\PLUGIN_FILE_NAME;
9 9
 	$blogids = $wpdb->get_col("SELECT blog_id FROM " . $wpdb->blogs);
10 10
 
11
-	if (!is_array($blogids))
12
-		return;
11
+	if (!is_array($blogids)) {
12
+			return;
13
+	}
13 14
 
14 15
 	foreach ($blogids as $blog_id) {
15 16
 		switch_to_blog($blog_id);
Please login to merge, or discard this patch.
constants.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 namespace PodloveSubscribeButton;
4 4
 
5
-define( __NAMESPACE__ . '\PLUGIN_FILE_NAME', strtolower( preg_replace( '/([a-z])([A-Z])/', '$1-$2', __NAMESPACE__ ) ) . '.php' );
6
-define( __NAMESPACE__ . '\PLUGIN_DIR' , plugin_dir_path( dirname(__FILE__) ) );
7
-define( __NAMESPACE__ . '\PLUGIN_FILE', PLUGIN_DIR . PLUGIN_FILE_NAME );
8
-define( __NAMESPACE__ . '\PLUGIN_URL' , plugins_url( '', PLUGIN_FILE ) );
9 5
\ No newline at end of file
6
+define(__NAMESPACE__ . '\PLUGIN_FILE_NAME', strtolower(preg_replace('/([a-z])([A-Z])/', '$1-$2', __NAMESPACE__)) . '.php');
7
+define(__NAMESPACE__ . '\PLUGIN_DIR', plugin_dir_path(dirname(__FILE__)));
8
+define(__NAMESPACE__ . '\PLUGIN_FILE', PLUGIN_DIR . PLUGIN_FILE_NAME);
9
+define(__NAMESPACE__ . '\PLUGIN_URL', plugins_url('', PLUGIN_FILE));
10 10
\ No newline at end of file
Please login to merge, or discard this patch.
podlove.php 2 patches
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
  * Text Domain: podlove-subscribe-button
12 12
  */
13 13
 
14
-$correct_php_version = version_compare( phpversion(), "5.3", ">=" );
14
+$correct_php_version = version_compare(phpversion(), "5.3", ">=");
15 15
 
16
-if ( ! $correct_php_version ) {
16
+if ( ! $correct_php_version) {
17 17
 	_e("Podlove Subscribe Button Plugin requires <strong>PHP 5.3</strong> or higher.<br>", 'podlove-subscribe-button');
18 18
 	echo __("You are running PHP ", 'podlove-subscribe-button') . phpversion();
19 19
 	exit;
@@ -37,35 +37,35 @@  discard block
 block discarded – undo
37 37
 // Helper functions
38 38
 require('helper.php');
39 39
 
40
-add_action( 'admin_menu', array( 'PodloveSubscribeButton', 'admin_menu') );
41
-if ( is_multisite() )
42
-	add_action( 'network_admin_menu', array( 'PodloveSubscribeButton', 'admin_network_menu') );
40
+add_action('admin_menu', array('PodloveSubscribeButton', 'admin_menu'));
41
+if (is_multisite())
42
+	add_action('network_admin_menu', array('PodloveSubscribeButton', 'admin_network_menu'));
43 43
 
44
-add_action( 'admin_init', array( 'PodloveSubscribeButton\Settings\Buttons', 'process_form' ) );
45
-register_activation_hook( __FILE__, array( 'PodloveSubscribeButton', 'build_models' ) );
44
+add_action('admin_init', array('PodloveSubscribeButton\Settings\Buttons', 'process_form'));
45
+register_activation_hook(__FILE__, array('PodloveSubscribeButton', 'build_models'));
46 46
 
47
-add_action( 'admin_enqueue_scripts', function () {
48
-	wp_register_style( 'podlove-subscribe-button', plugin_dir_url(__FILE__).'style.css' );
49
-	wp_enqueue_style( 'podlove-subscribe-button' );
47
+add_action('admin_enqueue_scripts', function() {
48
+	wp_register_style('podlove-subscribe-button', plugin_dir_url(__FILE__) . 'style.css');
49
+	wp_enqueue_style('podlove-subscribe-button');
50 50
 
51
-	wp_enqueue_style('podlove-subscribe-button-spectrum', plugin_dir_url(__FILE__). 'js/spectrum/spectrum.css');
52
-	wp_enqueue_script('podlove-subscribe-button-spectrum', plugin_dir_url(__FILE__). 'js/spectrum/spectrum.js', array('jquery'));
53
-	wp_enqueue_script('podlove-subscribe-button-admin-tools', plugin_dir_url(__FILE__). 'js/admin.js', array('jquery'));
51
+	wp_enqueue_style('podlove-subscribe-button-spectrum', plugin_dir_url(__FILE__) . 'js/spectrum/spectrum.css');
52
+	wp_enqueue_script('podlove-subscribe-button-spectrum', plugin_dir_url(__FILE__) . 'js/spectrum/spectrum.js', array('jquery'));
53
+	wp_enqueue_script('podlove-subscribe-button-admin-tools', plugin_dir_url(__FILE__) . 'js/admin.js', array('jquery'));
54 54
 } );
55 55
 
56 56
 // Register Settings
57
-add_action( 'admin_init', function () {
57
+add_action('admin_init', function() {
58 58
 	$settings = array('size', 'autowidth', 'style', 'format', 'color');
59 59
 
60 60
 	foreach ($settings as $setting) {
61
-		register_setting( 'podlove-subscribe-button', 'podlove_subscribe_button_default_' . $setting );
61
+		register_setting('podlove-subscribe-button', 'podlove_subscribe_button_default_' . $setting);
62 62
 	}
63 63
 } );
64 64
 
65
-add_shortcode( 'podlove-subscribe-button', array( 'PodloveSubscribeButton', 'shortcode' ) );
65
+add_shortcode('podlove-subscribe-button', array('PodloveSubscribeButton', 'shortcode'));
66 66
 
67
-add_action( 'plugins_loaded', function () {
68
-	load_plugin_textdomain( 'podlove-subscribe-button' );
67
+add_action('plugins_loaded', function() {
68
+	load_plugin_textdomain('podlove-subscribe-button');
69 69
 } );
70 70
 
71 71
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 				'Podlove Subscribe Button',
78 78
 				'manage_options',
79 79
 				'podlove-subscribe-button',
80
-				array( 'PodloveSubscribeButton\Settings\Buttons', 'page')
80
+				array('PodloveSubscribeButton\Settings\Buttons', 'page')
81 81
 			);
82 82
 	}
83 83
 
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
 				'Podlove Subscribe Button',
89 89
 				'manage_options',
90 90
 				'podlove-subscribe-button',
91
-				array( 'PodloveSubscribeButton\Settings\Buttons', 'page')
91
+				array('PodloveSubscribeButton\Settings\Buttons', 'page')
92 92
 			);
93 93
 	}
94 94
 
95 95
 	public static function build_models() {
96 96
 		// Build Databases
97 97
 		\PodloveSubscribeButton\Model\Button::build();
98
-		if ( is_multisite() )
98
+		if (is_multisite())
99 99
 			\PodloveSubscribeButton\Model\NetworkButton::build();
100 100
 
101 101
 		// Set Button "default" values
@@ -108,43 +108,43 @@  discard block
 block discarded – undo
108 108
 			);
109 109
 
110 110
 		foreach ($default_values as $option => $default_value) {
111
-			if ( ! get_option('podlove_subscribe_button_default_' . $option ) ) {
111
+			if ( ! get_option('podlove_subscribe_button_default_' . $option)) {
112 112
 				update_option('podlove_subscribe_button_default_' . $option, $default_value);
113 113
 			}
114 114
 		}
115 115
 	}
116 116
 
117
-	public static function shortcode( $args ) {
118
-		if ( ! $args || ! isset($args['button']) ) {
117
+	public static function shortcode($args) {
118
+		if ( ! $args || ! isset($args['button'])) {
119 119
 			return __('You need to create a Button first and provide its ID.', 'podlove-subscribe-button');
120 120
 		} else {
121 121
 			$buttonid = $args['button'];
122 122
 		}
123 123
 
124 124
 		// Fetch the (network)button by it's name
125
-		if ( ! $button = \PodloveSubscribeButton\Model\Button::get_button_by_name($args['button']) )
126
-			return sprintf( __('Oops. There is no button with the ID "%s".', 'podlove-subscribe-button'), $args['button'] );
125
+		if ( ! $button = \PodloveSubscribeButton\Model\Button::get_button_by_name($args['button']))
126
+			return sprintf(__('Oops. There is no button with the ID "%s".', 'podlove-subscribe-button'), $args['button']);
127 127
 
128 128
 		// Get button styling and options
129
-		$autowidth = self::interpret_width_attribute( self::get_array_value_with_fallback($args, 'width') );
130
-		$size = self::get_attribute( 'size', self::get_array_value_with_fallback($args, 'size') );
131
-		$style = self::get_attribute( 'style', self::get_array_value_with_fallback($args, 'style') );
132
-		$format = self::get_attribute( 'format', self::get_array_value_with_fallback($args, 'format') );
133
-		$color = self::get_attribute( 'color', self::get_array_value_with_fallback($args, 'color') );
129
+		$autowidth = self::interpret_width_attribute(self::get_array_value_with_fallback($args, 'width'));
130
+		$size = self::get_attribute('size', self::get_array_value_with_fallback($args, 'size'));
131
+		$style = self::get_attribute('style', self::get_array_value_with_fallback($args, 'style'));
132
+		$format = self::get_attribute('format', self::get_array_value_with_fallback($args, 'format'));
133
+		$color = self::get_attribute('color', self::get_array_value_with_fallback($args, 'color'));
134 134
 
135
-		if ( isset($args['language']) ) {
135
+		if (isset($args['language'])) {
136 136
 			$language = $args['language'];
137 137
 		} else {
138 138
 			$language = 'en';
139 139
 		}
140 140
 
141
-		if ( isset($args['color']) ) {
141
+		if (isset($args['color'])) {
142 142
 			$color = $args['color'];
143 143
 		} else {
144 144
 			$color = get_option('podlove_subscribe_button_default_color', '#599677');
145 145
 		}
146 146
 
147
-		if ( isset($args['hide']) && $args['hide'] == 'true' ) {
147
+		if (isset($args['hide']) && $args['hide'] == 'true') {
148 148
 			$hide = TRUE;
149 149
 		} else {
150 150
 			$hide = FALSE;
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	}
156 156
 
157 157
 	public static function get_array_value_with_fallback($args, $key) {
158
-		if ( isset($args[$key]) )
158
+		if (isset($args[$key]))
159 159
 			return $args[$key];
160 160
 
161 161
 		return FALSE;
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 	 * @param  string $attribute_value
167 167
 	 * @return string
168 168
 	 */
169
-	private static function get_attribute($attribute=NULL, $attribute_value=NULL) {
170
-		if ( isset($attribute_value) && ctype_alnum($attribute_value) && key_exists( $attribute_value, \PodloveSubscribeButton\Model\Button::$$attribute ) ) {
169
+	private static function get_attribute($attribute = NULL, $attribute_value = NULL) {
170
+		if (isset($attribute_value) && ctype_alnum($attribute_value) && key_exists($attribute_value, \PodloveSubscribeButton\Model\Button::$$attribute)) {
171 171
 			return $attribute_value;
172 172
 		} else {
173 173
 			return get_option('podlove_subscribe_button_default_' . $attribute, \PodloveSubscribeButton\Model\Button::$properties[$attribute]);
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
 	 * @param  string $width_attribute
180 180
 	 * @return string
181 181
 	 */
182
-	private static function interpret_width_attribute( $width_attribute = NULL ) {
183
-		if ( $width_attribute == 'auto' )
182
+	private static function interpret_width_attribute($width_attribute = NULL) {
183
+		if ($width_attribute == 'auto')
184 184
 			return 'on';
185
-		if ( $width_attribute && $width_attribute !== 'auto' )
185
+		if ($width_attribute && $width_attribute !== 'auto')
186 186
 			return 'off';
187 187
 
188 188
 		return get_option('podlove_subscribe_button_default_autowidth', 'on');
Please login to merge, or discard this patch.
Braces   +17 added lines, -11 removed lines patch added patch discarded remove patch
@@ -38,8 +38,9 @@  discard block
 block discarded – undo
38 38
 require('helper.php');
39 39
 
40 40
 add_action( 'admin_menu', array( 'PodloveSubscribeButton', 'admin_menu') );
41
-if ( is_multisite() )
41
+if ( is_multisite() ) {
42 42
 	add_action( 'network_admin_menu', array( 'PodloveSubscribeButton', 'admin_network_menu') );
43
+}
43 44
 
44 45
 add_action( 'admin_init', array( 'PodloveSubscribeButton\Settings\Buttons', 'process_form' ) );
45 46
 register_activation_hook( __FILE__, array( 'PodloveSubscribeButton', 'build_models' ) );
@@ -95,8 +96,9 @@  discard block
 block discarded – undo
95 96
 	public static function build_models() {
96 97
 		// Build Databases
97 98
 		\PodloveSubscribeButton\Model\Button::build();
98
-		if ( is_multisite() )
99
-			\PodloveSubscribeButton\Model\NetworkButton::build();
99
+		if ( is_multisite() ) {
100
+					\PodloveSubscribeButton\Model\NetworkButton::build();
101
+		}
100 102
 
101 103
 		// Set Button "default" values
102 104
 		$default_values = array(
@@ -122,8 +124,9 @@  discard block
 block discarded – undo
122 124
 		}
123 125
 
124 126
 		// Fetch the (network)button by it's name
125
-		if ( ! $button = \PodloveSubscribeButton\Model\Button::get_button_by_name($args['button']) )
126
-			return sprintf( __('Oops. There is no button with the ID "%s".', 'podlove-subscribe-button'), $args['button'] );
127
+		if ( ! $button = \PodloveSubscribeButton\Model\Button::get_button_by_name($args['button']) ) {
128
+					return sprintf( __('Oops. There is no button with the ID "%s".', 'podlove-subscribe-button'), $args['button'] );
129
+		}
127 130
 
128 131
 		// Get button styling and options
129 132
 		$autowidth = self::interpret_width_attribute( self::get_array_value_with_fallback($args, 'width') );
@@ -155,8 +158,9 @@  discard block
 block discarded – undo
155 158
 	}
156 159
 
157 160
 	public static function get_array_value_with_fallback($args, $key) {
158
-		if ( isset($args[$key]) )
159
-			return $args[$key];
161
+		if ( isset($args[$key]) ) {
162
+					return $args[$key];
163
+		}
160 164
 
161 165
 		return FALSE;
162 166
 	}
@@ -180,10 +184,12 @@  discard block
 block discarded – undo
180 184
 	 * @return string
181 185
 	 */
182 186
 	private static function interpret_width_attribute( $width_attribute = NULL ) {
183
-		if ( $width_attribute == 'auto' )
184
-			return 'on';
185
-		if ( $width_attribute && $width_attribute !== 'auto' )
186
-			return 'off';
187
+		if ( $width_attribute == 'auto' ) {
188
+					return 'on';
189
+		}
190
+		if ( $width_attribute && $width_attribute !== 'auto' ) {
191
+					return 'off';
192
+		}
187 193
 
188 194
 		return get_option('podlove_subscribe_button_default_autowidth', 'on');
189 195
 	}
Please login to merge, or discard this patch.
model/network_button.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@
 block discarded – undo
12 12
 
13 13
 }
14 14
 
15
-NetworkButton::property( 'id', 'INT NOT NULL AUTO_INCREMENT PRIMARY KEY' );
16
-NetworkButton::property( 'name', 'VARCHAR(255)' );
17
-NetworkButton::property( 'title', 'VARCHAR(255)' );
18
-NetworkButton::property( 'subtitle', 'VARCHAR(255)' );
19
-NetworkButton::property( 'description', 'TEXT' );
20
-NetworkButton::property( 'cover', 'VARCHAR(255)' );
21
-NetworkButton::property( 'feeds', 'TEXT' );
22 15
\ No newline at end of file
16
+NetworkButton::property('id', 'INT NOT NULL AUTO_INCREMENT PRIMARY KEY');
17
+NetworkButton::property('name', 'VARCHAR(255)');
18
+NetworkButton::property('title', 'VARCHAR(255)');
19
+NetworkButton::property('subtitle', 'VARCHAR(255)');
20
+NetworkButton::property('description', 'TEXT');
21
+NetworkButton::property('cover', 'VARCHAR(255)');
22
+NetworkButton::property('feeds', 'TEXT');
23 23
\ No newline at end of file
Please login to merge, or discard this patch.
model/button.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 	 * @return object||FALSE
46 46
 	 */
47 47
 	public static function get_button_by_name($name) {
48
-		if ( $button = \PodloveSubscribeButton\Model\Button::find_one_by_property('name', $name) ) {
48
+		if ($button = \PodloveSubscribeButton\Model\Button::find_one_by_property('name', $name)) {
49 49
 			return $button;
50 50
 		}
51 51
 
52
-		if ( $network_button = \PodloveSubscribeButton\Model\NetworkButton::find_one_by_property('name', $name) ) {
52
+		if ($network_button = \PodloveSubscribeButton\Model\NetworkButton::find_one_by_property('name', $name)) {
53 53
 			$network_button->id = $network_button->id . 'N';
54 54
 			return $network_button;
55 55
 		}
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
 	 * @param  array
63 63
 	 * @return array
64 64
 	 */
65
-	public static function get_global_setting_with_fallback( $settings=array() ) {
65
+	public static function get_global_setting_with_fallback($settings = array()) {
66 66
 		foreach (self::$properties as $property => $default) {
67
-			$settings[$property] = ( get_option('podlove_subscribe_button_default_' . $property) ? get_option('podlove_subscribe_button_default_' . $property) : $default );
67
+			$settings[$property] = (get_option('podlove_subscribe_button_default_' . $property) ? get_option('podlove_subscribe_button_default_' . $property) : $default);
68 68
 		}
69 69
 
70 70
 		return $settings;
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 * @param  boolean $buttonid
82 82
 	 * @return string
83 83
 	 */
84
-	public function render( $size='big', $autowidth='on', $style='filled', $format='rectangle', $color='#599677', $hide = FALSE, $buttonid = FALSE, $language='en' ) {
84
+	public function render($size = 'big', $autowidth = 'on', $style = 'filled', $format = 'rectangle', $color = '#599677', $hide = FALSE, $buttonid = FALSE, $language = 'en') {
85 85
 		$button_styling = array_merge(
86 86
 				$this->get_button_styling($size, $autowidth, $style, $format, $color),
87 87
 				array(
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 	 * Provides the feed as an array in the required format
106 106
 	 * @return array
107 107
 	 */
108
-	private function get_feeds_as_array( $feeds=array() ) {
108
+	private function get_feeds_as_array($feeds = array()) {
109 109
 		foreach ($feeds as $feed) {
110
-			if ( isset(\PodloveSubscribeButton\MediaTypes::$audio[$feed['format']]['extension']) ) {
110
+			if (isset(\PodloveSubscribeButton\MediaTypes::$audio[$feed['format']]['extension'])) {
111 111
 				$new_feed = array(
112 112
 						'type' => 'audio',
113 113
 						'format' => \PodloveSubscribeButton\MediaTypes::$audio[$feed['format']]['extension'],
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 						'variant' => 'high'
116 116
 					);
117 117
 
118
-				if ( isset($feed['itunesfeedid']) && $feed['itunesfeedid'] > 0 )
118
+				if (isset($feed['itunesfeedid']) && $feed['itunesfeedid'] > 0)
119 119
 					$new_feed['directory-url-itunes'] = "https://itunes.apple.com/podcast/id" . $feed['itunesfeedid'];
120 120
 
121 121
 				$feeds[] = $new_feed;
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * @param  string $data_attributes
133 133
 	 * @return string 
134 134
 	 */
135
-	private function provide_button_html($podcast_data, $button_styling, $data_attributes="") {
135
+	private function provide_button_html($podcast_data, $button_styling, $data_attributes = "") {
136 136
 		// Create data attributes for Button
137 137
 		foreach ($button_styling as $attribute => $value) {
138 138
 			$data_attributes .= 'data-' . $attribute . '="' . $value . '" ';
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
 		return"
142 142
 			<script>
143
-				podcastData".$this->id . " = ".json_encode($podcast_data)."
143
+				podcastData".$this->id . " = " . json_encode($podcast_data) . "
144 144
 			</script>
145 145
 			<script 
146 146
 				class=\"podlove-subscribe-button\" 
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
 
163 163
 		return array(
164 164
 				// $attribute => $value
165
-				'size' => ( $size == 'default' ? get_option('podlove_subscribe_button_default_size', $size) : $size )
165
+				'size' => ($size == 'default' ? get_option('podlove_subscribe_button_default_size', $size) : $size)
166 166
 			 	. self::interpret_autowidth_attribute($autowidth),
167
-				'style' => ( $style == 'default' ? get_option('podlove_subscribe_button_default_style', $style) : $style ),
168
-				'format' => ( $format == 'default' ? get_option('podlove_subscribe_button_default_format', $format) : $format ),
169
-				'color' => ( isset($color) ? $color : get_option('podlove_subscribe_button_default_color', $color) ),
167
+				'style' => ($style == 'default' ? get_option('podlove_subscribe_button_default_style', $style) : $style),
168
+				'format' => ($format == 'default' ? get_option('podlove_subscribe_button_default_format', $format) : $format),
169
+				'color' => (isset($color) ? $color : get_option('podlove_subscribe_button_default_color', $color)),
170 170
 				'json-data' => 'podcastData' . $this->id
171 171
 			);
172 172
 	}
@@ -177,20 +177,20 @@  discard block
 block discarded – undo
177 177
 	 * @return string
178 178
 	 */
179 179
 	private static function interpret_autowidth_attribute($autowidth) {
180
-		if ( $autowidth == 'default' && get_option('podlove_subscribe_button_default_autowidth') !== 'on' )
180
+		if ($autowidth == 'default' && get_option('podlove_subscribe_button_default_autowidth') !== 'on')
181 181
 			return '';
182 182
 
183
-		if ( $autowidth !== 'default' && $autowidth !== 'on' )
183
+		if ($autowidth !== 'default' && $autowidth !== 'on')
184 184
 			return '';
185 185
 
186 186
 		return ' auto';
187 187
 	}
188 188
 }
189 189
 
190
-Button::property( 'id', 'INT NOT NULL AUTO_INCREMENT PRIMARY KEY' );
191
-Button::property( 'name', 'VARCHAR(255)' );
192
-Button::property( 'title', 'VARCHAR(255)' );
193
-Button::property( 'subtitle', 'VARCHAR(255)' );
194
-Button::property( 'description', 'TEXT' );
195
-Button::property( 'cover', 'VARCHAR(255)' );
196
-Button::property( 'feeds', 'TEXT' );
197 190
\ No newline at end of file
191
+Button::property('id', 'INT NOT NULL AUTO_INCREMENT PRIMARY KEY');
192
+Button::property('name', 'VARCHAR(255)');
193
+Button::property('title', 'VARCHAR(255)');
194
+Button::property('subtitle', 'VARCHAR(255)');
195
+Button::property('description', 'TEXT');
196
+Button::property('cover', 'VARCHAR(255)');
197
+Button::property('feeds', 'TEXT');
198 198
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -115,8 +115,9 @@  discard block
 block discarded – undo
115 115
 						'variant' => 'high'
116 116
 					);
117 117
 
118
-				if ( isset($feed['itunesfeedid']) && $feed['itunesfeedid'] > 0 )
119
-					$new_feed['directory-url-itunes'] = "https://itunes.apple.com/podcast/id" . $feed['itunesfeedid'];
118
+				if ( isset($feed['itunesfeedid']) && $feed['itunesfeedid'] > 0 ) {
119
+									$new_feed['directory-url-itunes'] = "https://itunes.apple.com/podcast/id" . $feed['itunesfeedid'];
120
+				}
120 121
 
121 122
 				$feeds[] = $new_feed;
122 123
 			}
@@ -177,11 +178,13 @@  discard block
 block discarded – undo
177 178
 	 * @return string
178 179
 	 */
179 180
 	private static function interpret_autowidth_attribute($autowidth) {
180
-		if ( $autowidth == 'default' && get_option('podlove_subscribe_button_default_autowidth') !== 'on' )
181
-			return '';
181
+		if ( $autowidth == 'default' && get_option('podlove_subscribe_button_default_autowidth') !== 'on' ) {
182
+					return '';
183
+		}
182 184
 
183
-		if ( $autowidth !== 'default' && $autowidth !== 'on' )
184
-			return '';
185
+		if ( $autowidth !== 'default' && $autowidth !== 'on' ) {
186
+					return '';
187
+		}
185 188
 
186 189
 		return ' auto';
187 190
 	}
Please login to merge, or discard this patch.
model/base.php 3 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -389,14 +389,14 @@  discard block
 block discarded – undo
389 389
 			$this->set_defaults();
390 390
 
391 391
 			$sql = 'INSERT INTO '
392
-			     . static::table_name()
393
-			     . ' ( '
394
-			     . implode( ',', static::property_names() )
395
-			     . ' ) '
396
-			     . 'VALUES'
397
-			     . ' ( '
398
-			     . implode( ',', array_map( array( $this, 'property_name_to_sql_value' ), static::property_names() ) )
399
-			     . ' );'
392
+				 . static::table_name()
393
+				 . ' ( '
394
+				 . implode( ',', static::property_names() )
395
+				 . ' ) '
396
+				 . 'VALUES'
397
+				 . ' ( '
398
+				 . implode( ',', array_map( array( $this, 'property_name_to_sql_value' ), static::property_names() ) )
399
+				 . ' );'
400 400
 			;
401 401
 			$success = $wpdb->query( $sql );
402 402
 			if ( $success ) {
@@ -404,9 +404,9 @@  discard block
 block discarded – undo
404 404
 			}
405 405
 		} else {
406 406
 			$sql = 'UPDATE ' . static::table_name()
407
-			     . ' SET '
408
-			     . implode( ',', array_map( array( $this, 'property_name_to_sql_update_statement' ), static::property_names() ) )
409
-			     . ' WHERE id = ' . $this->id
407
+				 . ' SET '
408
+				 . implode( ',', array_map( array( $this, 'property_name_to_sql_update_statement' ), static::property_names() ) )
409
+				 . ' WHERE id = ' . $this->id
410 410
 			;
411 411
 
412 412
 			$success = $wpdb->query( $sql );
@@ -454,13 +454,13 @@  discard block
 block discarded – undo
454 454
 		global $wpdb;
455 455
 		
456 456
 		$sql = 'DELETE FROM '
457
-		     . static::table_name()
458
-		     . ' WHERE id = ' . $this->id;
457
+			 . static::table_name()
458
+			 . ' WHERE id = ' . $this->id;
459 459
 
460 460
 		$rows_affected = $wpdb->query( $sql );
461 461
 
462
-	    do_action('podlove_model_delete', $this);
463
-	    do_action('podlove_model_change', $this);
462
+		do_action('podlove_model_delete', $this);
463
+		do_action('podlove_model_change', $this);
464 464
 
465 465
 		return $rows_affected !== false;
466 466
 	}
@@ -499,10 +499,10 @@  discard block
 block discarded – undo
499 499
 			$property_sql[] = "`{$property['name']}` {$property['type']}";
500 500
 		
501 501
 		$sql = 'CREATE TABLE IF NOT EXISTS '
502
-		     . static::table_name()
503
-		     . ' ('
504
-		     . implode( ',', $property_sql )
505
-		     . ' ) CHARACTER SET utf8;'
502
+			 . static::table_name()
503
+			 . ' ('
504
+			 . implode( ',', $property_sql )
505
+			 . ' ) CHARACTER SET utf8;'
506 506
 		;
507 507
 		
508 508
 		$wpdb->query( $sql );
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -14,41 +14,41 @@  discard block
 block discarded – undo
14 14
 	 */
15 15
 	private $data = array();
16 16
 	
17
-	public function __set( $name, $value ) {
18
-		if ( static::has_property( $name ) ) {
19
-			$this->set_property( $name, $value );
17
+	public function __set($name, $value) {
18
+		if (static::has_property($name)) {
19
+			$this->set_property($name, $value);
20 20
 		} else {
21 21
 			$this->$name = $value;
22 22
 		}
23 23
 	}
24 24
 	
25
-	private function set_property( $name, $value ) {
26
-		$this->data[ $name ] = $value;
25
+	private function set_property($name, $value) {
26
+		$this->data[$name] = $value;
27 27
 	}
28 28
 	
29
-	public function __get( $name ) {
30
-		if ( static::has_property( $name ) ) {
31
-			return $this->get_property( $name );
32
-		} elseif ( property_exists( $this, $name ) ) {
29
+	public function __get($name) {
30
+		if (static::has_property($name)) {
31
+			return $this->get_property($name);
32
+		} elseif (property_exists($this, $name)) {
33 33
 			return $this->$name;
34 34
 		} else {
35 35
 			return NULL;
36 36
 		}
37 37
 	}
38 38
 	
39
-	private function get_property( $name ) {
40
-		if ( isset( $this->data[ $name ] ) ) {
41
-			return $this->data[ $name ];
39
+	private function get_property($name) {
40
+		if (isset($this->data[$name])) {
41
+			return $this->data[$name];
42 42
 		} else {
43 43
 			return NULL;
44 44
 		}
45 45
 	}
46 46
 
47 47
 	private static function unserialize_property($property) {
48
-		if ( ! isset($property) )
48
+		if ( ! isset($property))
49 49
 			return;
50 50
 
51
-		if ( $unserialized_string = is_serialized($property) )
51
+		if ($unserialized_string = is_serialized($property))
52 52
 			return unserialize($property);
53 53
 
54 54
 		return $property;
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
 	 * @param string $name Name of the property / column
80 80
 	 * @param string $type mySQL column type 
81 81
 	 */
82
-	public static function property( $name, $type, $args = array() ) {
82
+	public static function property($name, $type, $args = array()) {
83 83
 		$class = get_called_class();
84 84
 		
85
-		if ( ! isset( static::$properties[ $class ] ) ) {
86
-			static::$properties[ $class ] = array();
85
+		if ( ! isset(static::$properties[$class])) {
86
+			static::$properties[$class] = array();
87 87
 		}
88 88
 
89 89
 		// "id" columns and those ending on "_id" get an index by default
90
-		$index = $name == 'id' || stripos( $name, '_id' );
90
+		$index = $name == 'id' || stripos($name, '_id');
91 91
 		// but if the argument is set, it overrides the default
92 92
 		if (isset($args['index'])) {
93 93
 			$index = $args['index'];
94 94
 		}
95 95
 		
96
-		static::$properties[ $class ][] = array(
96
+		static::$properties[$class][] = array(
97 97
 			'name'  => $name,
98 98
 			'type'  => $type,
99 99
 			'index' => $index,
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
 	private static function properties() {
111 111
 		$class = get_called_class();
112 112
 		
113
-		if ( ! isset( static::$properties[ $class ] ) ) {
114
-			static::$properties[ $class ] = array();
113
+		if ( ! isset(static::$properties[$class])) {
114
+			static::$properties[$class] = array();
115 115
 		}
116 116
 		
117
-		return static::$properties[ $class ];
117
+		return static::$properties[$class];
118 118
 	}
119 119
 	
120 120
 	/**
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 	 * @param string $name name of the property to test
124 124
 	 * @return bool True if the property exists, else false.
125 125
 	 */
126
-	public static function has_property( $name ) {
127
-		return in_array( $name, static::property_names() );
126
+	public static function has_property($name) {
127
+		return in_array($name, static::property_names());
128 128
 	}
129 129
 	
130 130
 	/**
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * @return array property names
134 134
 	 */
135 135
 	public static function property_names() {
136
-		return array_map( function ( $p ) { return $p['name']; } , static::properties() );
136
+		return array_map(function($p) { return $p['name']; } , static::properties());
137 137
 	}
138 138
 	
139 139
 	/**
@@ -154,47 +154,47 @@  discard block
 block discarded – undo
154 154
 		global $wpdb;
155 155
 		
156 156
 		$sql = 'SELECT COUNT(*) FROM ' . static::table_name();
157
-		return (int) $wpdb->get_var( $sql );
157
+		return (int) $wpdb->get_var($sql);
158 158
 	}
159 159
 
160
-	public static function find_by_id( $id ) {
160
+	public static function find_by_id($id) {
161 161
 		global $wpdb;
162 162
 		
163 163
 		$class = get_called_class();
164 164
 		$model = new $class();
165 165
 		$model->flag_as_not_new();
166 166
 		
167
-		$row = $wpdb->get_row( 'SELECT * FROM ' . static::table_name() . ' WHERE id = ' . (int) $id );
167
+		$row = $wpdb->get_row('SELECT * FROM ' . static::table_name() . ' WHERE id = ' . (int) $id);
168 168
 		
169
-		if ( ! $row ) {
169
+		if ( ! $row) {
170 170
 			return NULL;
171 171
 		}
172 172
 		
173
-		foreach ( $row as $property => $value ) {
173
+		foreach ($row as $property => $value) {
174 174
 			$model->$property = static::unserialize_property($value);
175 175
 		}
176 176
 		
177 177
 		return $model;
178 178
 	}
179 179
 
180
-	public static function find_all_by_property( $property, $value ) {
180
+	public static function find_all_by_property($property, $value) {
181 181
 		global $wpdb;
182 182
 		
183 183
 		$class = get_called_class();
184 184
 		$models = array();
185 185
 		
186 186
 		$rows = $wpdb->get_results(
187
-			'SELECT * FROM ' . static::table_name() . ' WHERE ' . $property .  ' = \'' . $value . '\''
187
+			'SELECT * FROM ' . static::table_name() . ' WHERE ' . $property . ' = \'' . $value . '\''
188 188
 		);
189 189
 		
190
-		if ( ! $rows ) {
190
+		if ( ! $rows) {
191 191
 			return array();
192 192
 		}
193 193
 		
194
-		foreach ( $rows as $row ) {
194
+		foreach ($rows as $row) {
195 195
 			$model = new $class();
196 196
 			$model->flag_as_not_new();
197
-			foreach ( $row as $property => $value ) {
197
+			foreach ($row as $property => $value) {
198 198
 				$model->$property = static::unserialize_property($value);
199 199
 			}
200 200
 			$models[] = $model;
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		return $models;
204 204
 	}
205 205
 
206
-	public static function find_one_by_property( $property, $value ) {
206
+	public static function find_one_by_property($property, $value) {
207 207
 		global $wpdb;
208 208
 		
209 209
 		$class = get_called_class();
@@ -211,21 +211,21 @@  discard block
 block discarded – undo
211 211
 		$model->flag_as_not_new();
212 212
 		
213 213
 		$row = $wpdb->get_row(
214
-			'SELECT * FROM ' . static::table_name() . ' WHERE ' . $property .  ' = \'' . $value . '\' LIMIT 0,1'
214
+			'SELECT * FROM ' . static::table_name() . ' WHERE ' . $property . ' = \'' . $value . '\' LIMIT 0,1'
215 215
 		);
216 216
 		
217
-		if ( ! $row ) {
217
+		if ( ! $row) {
218 218
 			return NULL;
219 219
 		}
220 220
 		
221
-		foreach ( $row as $property => $value ) {
221
+		foreach ($row as $property => $value) {
222 222
 			$model->$property = static::unserialize_property($value);
223 223
 		}
224 224
 		
225 225
 		return $model;
226 226
 	}
227 227
 
228
-	public static function find_all_by_where( $where ) {
228
+	public static function find_all_by_where($where) {
229 229
 		global $wpdb;
230 230
 		
231 231
 		$class = get_called_class();
@@ -235,14 +235,14 @@  discard block
 block discarded – undo
235 235
 			'SELECT * FROM ' . static::table_name() . ' WHERE ' . $where
236 236
 		);
237 237
 		
238
-		if ( ! $rows ) {
238
+		if ( ! $rows) {
239 239
 			return array();
240 240
 		}
241 241
 		
242
-		foreach ( $rows as $row ) {
242
+		foreach ($rows as $row) {
243 243
 			$model = new $class();
244 244
 			$model->flag_as_not_new();
245
-			foreach ( $row as $property => $value ) {
245
+			foreach ($row as $property => $value) {
246 246
 				$model->$property = static::unserialize_property($value);
247 247
 			}
248 248
 			$models[] = $model;
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 		return $models;
252 252
 	}
253 253
 	
254
-	public static function find_one_by_where( $where ) {
254
+	public static function find_one_by_where($where) {
255 255
 		global $wpdb;
256 256
 		
257 257
 		$class = get_called_class();
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
 			'SELECT * FROM ' . static::table_name() . ' WHERE ' . $where . ' LIMIT 0,1'
263 263
 		);
264 264
 		
265
-		if ( ! $row ) {
265
+		if ( ! $row) {
266 266
 			return NULL;
267 267
 		}
268 268
 		
269
-		foreach ( $row as $property => $value ) {
269
+		foreach ($row as $property => $value) {
270 270
 			$model->$property = static::unserialize_property($value);
271 271
 		}
272 272
 		
@@ -278,18 +278,18 @@  discard block
 block discarded – undo
278 278
 	 * @param  string $sql_suffix optional SQL, appended after FROM clause
279 279
 	 * @return array list of model objects
280 280
 	 */
281
-	public static function all( $sql_suffix = '' ) {
281
+	public static function all($sql_suffix = '') {
282 282
 		global $wpdb;
283 283
 		
284 284
 		$class = get_called_class();
285 285
 		$models = array();
286 286
 		
287
-		$rows = $wpdb->get_results( 'SELECT * FROM ' . static::table_name() . ' ' . $sql_suffix );
287
+		$rows = $wpdb->get_results('SELECT * FROM ' . static::table_name() . ' ' . $sql_suffix);
288 288
 
289
-		foreach ( $rows as $row ) {
289
+		foreach ($rows as $row) {
290 290
 			$model = new $class();
291 291
 			$model->flag_as_not_new();
292
-			foreach ( $row as $property => $value ) {
292
+			foreach ($row as $property => $value) {
293 293
 				$model->$property = static::unserialize_property($value);
294 294
 			}
295 295
 			$models[] = $model;
@@ -317,24 +317,24 @@  discard block
 block discarded – undo
317 317
 	 * @param  array $attributes
318 318
 	 * @return bool
319 319
 	 */
320
-	public function update_attributes( $attributes ) {
320
+	public function update_attributes($attributes) {
321 321
 
322
-		if ( ! is_array( $attributes ) )
322
+		if ( ! is_array($attributes))
323 323
 			return false;
324 324
 
325 325
 		$request = filter_input_array(INPUT_POST); // Do this for security reasons
326 326
 			
327
-		foreach ( $attributes as $key => $value ) {
328
-			if ( is_array($value) ) {
327
+		foreach ($attributes as $key => $value) {
328
+			if (is_array($value)) {
329 329
 				$this->{$key} = serialize($value);
330 330
 			} else {
331 331
 				$this->{$key} = esc_sql($value);
332 332
 			}
333 333
 		}
334 334
 		
335
-		if ( isset( $request['checkboxes'] ) && is_array( $request['checkboxes'] ) ) {
336
-			foreach ( $request['checkboxes'] as $checkbox ) {
337
-				if ( isset( $attributes[ $checkbox ] ) && $attributes[ $checkbox ] === 'on' ) {
335
+		if (isset($request['checkboxes']) && is_array($request['checkboxes'])) {
336
+			foreach ($request['checkboxes'] as $checkbox) {
337
+				if (isset($attributes[$checkbox]) && $attributes[$checkbox] === 'on') {
338 338
 					$this->$checkbox = 1;
339 339
 				} else {
340 340
 					$this->$checkbox = 0;
@@ -345,9 +345,9 @@  discard block
 block discarded – undo
345 345
 		// @todo this is the wrong place to do this!
346 346
 		// The feed password is the only "passphrase" which is saved. It is not encrypted!
347 347
 		// However, we keep this function for later use
348
-		if ( isset( $request['passwords'] ) && is_array( $request['passwords'] ) ) {
349
-			foreach ( $request['passwords'] as $password ) {
350
-				$this->$password = $attributes[ $password ];
348
+		if (isset($request['passwords']) && is_array($request['passwords'])) {
349
+			foreach ($request['passwords'] as $password) {
350
+				$this->$password = $attributes[$password];
351 351
 			}
352 352
 		}
353 353
 		return $this->save();
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 			$this->id
374 374
 		);
375 375
 
376
-		return $wpdb->query( $sql );
376
+		return $wpdb->query($sql);
377 377
 	}
378 378
 	
379 379
 	/**
@@ -384,32 +384,32 @@  discard block
 block discarded – undo
384 384
 	public function save() {
385 385
 		global $wpdb;
386 386
 
387
-		if ( $this->is_new() ) {
387
+		if ($this->is_new()) {
388 388
 
389 389
 			$this->set_defaults();
390 390
 
391 391
 			$sql = 'INSERT INTO '
392 392
 			     . static::table_name()
393 393
 			     . ' ( '
394
-			     . implode( ',', static::property_names() )
394
+			     . implode(',', static::property_names())
395 395
 			     . ' ) '
396 396
 			     . 'VALUES'
397 397
 			     . ' ( '
398
-			     . implode( ',', array_map( array( $this, 'property_name_to_sql_value' ), static::property_names() ) )
398
+			     . implode(',', array_map(array($this, 'property_name_to_sql_value'), static::property_names()))
399 399
 			     . ' );'
400 400
 			;
401
-			$success = $wpdb->query( $sql );
402
-			if ( $success ) {
401
+			$success = $wpdb->query($sql);
402
+			if ($success) {
403 403
 				$this->id = $wpdb->insert_id;
404 404
 			}
405 405
 		} else {
406 406
 			$sql = 'UPDATE ' . static::table_name()
407 407
 			     . ' SET '
408
-			     . implode( ',', array_map( array( $this, 'property_name_to_sql_update_statement' ), static::property_names() ) )
408
+			     . implode(',', array_map(array($this, 'property_name_to_sql_update_statement'), static::property_names()))
409 409
 			     . ' WHERE id = ' . $this->id
410 410
 			;
411 411
 
412
-			$success = $wpdb->query( $sql );
412
+			$success = $wpdb->query($sql);
413 413
 		}
414 414
 
415 415
 		$this->is_new = false;
@@ -429,11 +429,11 @@  discard block
 block discarded – undo
429 429
 		
430 430
 		$defaults = $this->default_values();
431 431
 
432
-		if ( ! is_array( $defaults ) || empty( $defaults ) )
432
+		if ( ! is_array($defaults) || empty($defaults))
433 433
 			return;
434 434
 
435
-		foreach ( $defaults as $property => $value ) {
436
-			if ( $this->$property === NULL )
435
+		foreach ($defaults as $property => $value) {
436
+			if ($this->$property === NULL)
437 437
 				$this->$property = $value;
438 438
 		}
439 439
 
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 		     . static::table_name()
458 458
 		     . ' WHERE id = ' . $this->id;
459 459
 
460
-		$rows_affected = $wpdb->query( $sql );
460
+		$rows_affected = $wpdb->query($sql);
461 461
 
462 462
 	    do_action('podlove_model_delete', $this);
463 463
 	    do_action('podlove_model_change', $this);
@@ -465,21 +465,21 @@  discard block
 block discarded – undo
465 465
 		return $rows_affected !== false;
466 466
 	}
467 467
 
468
-	private function property_name_to_sql_update_statement( $p ) {
468
+	private function property_name_to_sql_update_statement($p) {
469 469
 		global $wpdb;
470 470
 
471
-		if ( $this->$p !== NULL && $this->$p !== '' ) {
472
-			return sprintf( "%s = '%s'", $p, ( is_array($this->$p) ? serialize($this->$p) : $this->$p ) );
471
+		if ($this->$p !== NULL && $this->$p !== '') {
472
+			return sprintf("%s = '%s'", $p, (is_array($this->$p) ? serialize($this->$p) : $this->$p));
473 473
 		} else {
474 474
 			return "$p = NULL";
475 475
 		}
476 476
 	}
477 477
 	
478
-	private function property_name_to_sql_value( $p ) {
478
+	private function property_name_to_sql_value($p) {
479 479
 		global $wpdb;
480 480
 
481
-		if ( $this->$p !== NULL && $this->$p !== '' ) {
482
-			return sprintf( "'%s'", $this->$p );
481
+		if ($this->$p !== NULL && $this->$p !== '') {
482
+			return sprintf("'%s'", $this->$p);
483 483
 		} else {
484 484
 			return 'NULL';
485 485
 		}
@@ -495,17 +495,17 @@  discard block
 block discarded – undo
495 495
 		global $wpdb;
496 496
 		
497 497
 		$property_sql = array();
498
-		foreach ( static::properties() as $property )
498
+		foreach (static::properties() as $property)
499 499
 			$property_sql[] = "`{$property['name']}` {$property['type']}";
500 500
 		
501 501
 		$sql = 'CREATE TABLE IF NOT EXISTS '
502 502
 		     . static::table_name()
503 503
 		     . ' ('
504
-		     . implode( ',', $property_sql )
504
+		     . implode(',', $property_sql)
505 505
 		     . ' ) CHARACTER SET utf8;'
506 506
 		;
507 507
 		
508
-		$wpdb->query( $sql );
508
+		$wpdb->query($sql);
509 509
 
510 510
 		static::build_indices();
511 511
 	}
@@ -521,16 +521,16 @@  discard block
 block discarded – undo
521 521
 		global $wpdb;
522 522
 
523 523
 		$indices_sql = 'SHOW INDEX FROM `' . static::table_name() . '`';
524
-		$indices = $wpdb->get_results( $indices_sql );
525
-		$index_columns = array_map( function($index){ return $index->Column_name; }, $indices );
524
+		$indices = $wpdb->get_results($indices_sql);
525
+		$index_columns = array_map(function($index) { return $index->Column_name; }, $indices);
526 526
 
527
-		foreach ( static::properties() as $property ) {
527
+		foreach (static::properties() as $property) {
528 528
 
529
-			if ( $property['index'] && ! in_array( $property['name'], $index_columns ) ) {
529
+			if ($property['index'] && ! in_array($property['name'], $index_columns)) {
530 530
 				$length = isset($property['index_length']) ? '(' . (int) $property['index_length'] . ')' : '';
531 531
 				$unique = isset($property['unique']) && $property['unique'] ? 'UNIQUE' : '';
532 532
 				$sql = 'ALTER TABLE `' . static::table_name() . '` ADD ' . $unique . ' INDEX `' . $property['name'] . '` (' . $property['name'] . $length . ')';
533
-				$wpdb->query( $sql );
533
+				$wpdb->query($sql);
534 534
 			}
535 535
 		}
536 536
 	}
@@ -542,11 +542,11 @@  discard block
 block discarded – undo
542 542
 		// get name of implementing class
543 543
 		$table_name = get_called_class();
544 544
 		// replace backslashes from namespace by underscores
545
-		$table_name = str_replace( '\\', '_', $table_name );
545
+		$table_name = str_replace('\\', '_', $table_name);
546 546
 		// remove Models subnamespace from name
547
-		$table_name = str_replace( 'Model_', '', $table_name );
547
+		$table_name = str_replace('Model_', '', $table_name);
548 548
 		// all lowercase
549
-		$table_name = strtolower( $table_name );
549
+		$table_name = strtolower($table_name);
550 550
 
551 551
 		return $table_name;
552 552
 	}
Please login to merge, or discard this patch.
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -45,11 +45,13 @@  discard block
 block discarded – undo
45 45
 	}
46 46
 
47 47
 	private static function unserialize_property($property) {
48
-		if ( ! isset($property) )
49
-			return;
48
+		if ( ! isset($property) ) {
49
+					return;
50
+		}
50 51
 
51
-		if ( $unserialized_string = is_serialized($property) )
52
-			return unserialize($property);
52
+		if ( $unserialized_string = is_serialized($property) ) {
53
+					return unserialize($property);
54
+		}
53 55
 
54 56
 		return $property;
55 57
 	}
@@ -319,8 +321,9 @@  discard block
 block discarded – undo
319 321
 	 */
320 322
 	public function update_attributes( $attributes ) {
321 323
 
322
-		if ( ! is_array( $attributes ) )
323
-			return false;
324
+		if ( ! is_array( $attributes ) ) {
325
+					return false;
326
+		}
324 327
 
325 328
 		$request = filter_input_array(INPUT_POST); // Do this for security reasons
326 329
 			
@@ -429,12 +432,14 @@  discard block
 block discarded – undo
429 432
 		
430 433
 		$defaults = $this->default_values();
431 434
 
432
-		if ( ! is_array( $defaults ) || empty( $defaults ) )
433
-			return;
435
+		if ( ! is_array( $defaults ) || empty( $defaults ) ) {
436
+					return;
437
+		}
434 438
 
435 439
 		foreach ( $defaults as $property => $value ) {
436
-			if ( $this->$property === NULL )
437
-				$this->$property = $value;
440
+			if ( $this->$property === NULL ) {
441
+							$this->$property = $value;
442
+			}
438 443
 		}
439 444
 
440 445
 	}
@@ -495,8 +500,9 @@  discard block
 block discarded – undo
495 500
 		global $wpdb;
496 501
 		
497 502
 		$property_sql = array();
498
-		foreach ( static::properties() as $property )
499
-			$property_sql[] = "`{$property['name']}` {$property['type']}";
503
+		foreach ( static::properties() as $property ) {
504
+					$property_sql[] = "`{$property['name']}` {$property['type']}";
505
+		}
500 506
 		
501 507
 		$sql = 'CREATE TABLE IF NOT EXISTS '
502 508
 		     . static::table_name()
Please login to merge, or discard this patch.
settings/buttons.php 2 patches
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -9,29 +9,29 @@  discard block
 block discarded – undo
9 9
 		$action = null !== filter_input(INPUT_GET, 'action') ? filter_input(INPUT_GET, 'action') : NULL;
10 10
 		$is_network = is_network_admin();
11 11
 
12
-		if ( $action == 'confirm_delete' && null !== filter_input(INPUT_GET, 'button') ) {
13
-			$button = ( $is_network === TRUE ? \PodloveSubscribeButton\Model\NetworkButton::find_by_id( (int) filter_input(INPUT_GET, 'button') ) : \PodloveSubscribeButton\Model\Button::find_by_id( (int) filter_input(INPUT_GET, 'button') ) );
12
+		if ($action == 'confirm_delete' && null !== filter_input(INPUT_GET, 'button')) {
13
+			$button = ($is_network === TRUE ? \PodloveSubscribeButton\Model\NetworkButton::find_by_id((int) filter_input(INPUT_GET, 'button')) : \PodloveSubscribeButton\Model\Button::find_by_id((int) filter_input(INPUT_GET, 'button')));
14 14
 			?>
15 15
 			<div class="updated">
16 16
 				<p>
17 17
 					<strong>
18
-						<?php echo sprintf( __( 'You selected to delete the button "%s". Please confirm this action.', 'podlove-subscribe-button' ), $button->title ) ?>
18
+						<?php echo sprintf(__('You selected to delete the button "%s". Please confirm this action.', 'podlove-subscribe-button'), $button->title) ?>
19 19
 					</strong>
20 20
 				</p>
21 21
 				<p>
22
-					<?php echo self::get_action_link( $button, __( 'Delete button permanently', 'podlove-subscribe-button' ), 'delete', 'button' ) ?>
23
-					<?php echo self::get_action_link( $button, __( 'Don\'t change anything', 'podlove-subscribe-button' ), 'keep', 'button-primary' ) ?>
22
+					<?php echo self::get_action_link($button, __('Delete button permanently', 'podlove-subscribe-button'), 'delete', 'button') ?>
23
+					<?php echo self::get_action_link($button, __('Don\'t change anything', 'podlove-subscribe-button'), 'keep', 'button-primary') ?>
24 24
 				</p>
25 25
 			</div>
26 26
 			<?php
27 27
 		}
28 28
 		?>
29 29
 		<div class="wrap">
30
-			<h2><?php echo __( 'Podcast Subscribe Button', 'podlove-subscribe-button' ); ?> <a href="?page=<?php echo filter_input(INPUT_GET, 'page'); ?>&amp;action=new&amp;network=<?php echo $is_network; ?>" class="add-new-h2"><?php echo __( 'Add New', 'podlove-subscribe-button' ); ?></a></h2>
30
+			<h2><?php echo __('Podcast Subscribe Button', 'podlove-subscribe-button'); ?> <a href="?page=<?php echo filter_input(INPUT_GET, 'page'); ?>&amp;action=new&amp;network=<?php echo $is_network; ?>" class="add-new-h2"><?php echo __('Add New', 'podlove-subscribe-button'); ?></a></h2>
31 31
 			<?php
32 32
 
33
-			switch ( $action ) {
34
-				case 'new':   self::new_template();  break;
33
+			switch ($action) {
34
+				case 'new':   self::new_template(); break;
35 35
 				case 'edit':  self::edit_template(); break;
36 36
 				case 'index': self::view_template(); break;
37 37
 				default:      self::view_template(); break;
@@ -45,18 +45,18 @@  discard block
 block discarded – undo
45 45
 	 * Process form: save/update a format
46 46
 	 */
47 47
 	public static function save() {
48
-		if ( null == filter_input(INPUT_GET, 'button') )
48
+		if (null == filter_input(INPUT_GET, 'button'))
49 49
 			return;
50 50
 
51 51
 		$post = filter_input_array(INPUT_POST);
52 52
 
53
-		$button = ( filter_input(INPUT_GET, 'network') === '1' ? \PodloveSubscribeButton\Model\NetworkButton::find_by_id( filter_input(INPUT_GET, 'button') ) : \PodloveSubscribeButton\Model\Button::find_by_id( filter_input(INPUT_GET, 'button') ) );
54
-		$button->update_attributes( $post['podlove_button'] );
53
+		$button = (filter_input(INPUT_GET, 'network') === '1' ? \PodloveSubscribeButton\Model\NetworkButton::find_by_id(filter_input(INPUT_GET, 'button')) : \PodloveSubscribeButton\Model\Button::find_by_id(filter_input(INPUT_GET, 'button')));
54
+		$button->update_attributes($post['podlove_button']);
55 55
 
56
-		if ( isset($post['submit_and_stay']) ) {
57
-			self::redirect( 'edit', $button->id, array( 'network' => filter_input(INPUT_GET, 'network') ), ( filter_input(INPUT_GET, 'network') === '1' ? TRUE : FALSE ) );
56
+		if (isset($post['submit_and_stay'])) {
57
+			self::redirect('edit', $button->id, array('network' => filter_input(INPUT_GET, 'network')), (filter_input(INPUT_GET, 'network') === '1' ? TRUE : FALSE));
58 58
 		} else {
59
-			self::redirect( 'index', $button->id, array(), ( filter_input(INPUT_GET, 'network') === '1' ? TRUE : FALSE ) );
59
+			self::redirect('index', $button->id, array(), (filter_input(INPUT_GET, 'network') === '1' ? TRUE : FALSE));
60 60
 		}
61 61
 	}
62 62
 	/**
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
 
68 68
 		$post = filter_input_array(INPUT_POST);
69 69
 
70
-		$button = ( filter_input(INPUT_GET, 'network') === '1' ? new \PodloveSubscribeButton\Model\NetworkButton : new \PodloveSubscribeButton\Model\Button );
71
-		$button->update_attributes( $post['podlove_button'] );
70
+		$button = (filter_input(INPUT_GET, 'network') === '1' ? new \PodloveSubscribeButton\Model\NetworkButton : new \PodloveSubscribeButton\Model\Button);
71
+		$button->update_attributes($post['podlove_button']);
72 72
 
73
-		if ( isset($post['submit_and_stay']) ) {
74
-			self::redirect( 'edit', $button->id, array( 'network' => filter_input(INPUT_GET, 'network') ), ( filter_input(INPUT_GET, 'network') === '1' ? TRUE : FALSE ) );
73
+		if (isset($post['submit_and_stay'])) {
74
+			self::redirect('edit', $button->id, array('network' => filter_input(INPUT_GET, 'network')), (filter_input(INPUT_GET, 'network') === '1' ? TRUE : FALSE));
75 75
 		} else {
76
-			self::redirect( 'index', $button->id, array(), ( filter_input(INPUT_GET, 'network') === '1' ? TRUE : FALSE ) );
76
+			self::redirect('index', $button->id, array(), (filter_input(INPUT_GET, 'network') === '1' ? TRUE : FALSE));
77 77
 		}
78 78
 	}
79 79
 
@@ -81,64 +81,64 @@  discard block
 block discarded – undo
81 81
 	 * Process form: delete a format
82 82
 	 */
83 83
 	public static function delete() {
84
-		if ( null ==  filter_input(INPUT_GET, 'button') )
84
+		if (null == filter_input(INPUT_GET, 'button'))
85 85
 			return;
86 86
 
87
-		$button = ( filter_input(INPUT_GET, 'network') === '1' ? \PodloveSubscribeButton\Model\NetworkButton::find_by_id( filter_input(INPUT_GET, 'button') ) : \PodloveSubscribeButton\Model\Button::find_by_id( filter_input(INPUT_GET, 'button') ) );
87
+		$button = (filter_input(INPUT_GET, 'network') === '1' ? \PodloveSubscribeButton\Model\NetworkButton::find_by_id(filter_input(INPUT_GET, 'button')) : \PodloveSubscribeButton\Model\Button::find_by_id(filter_input(INPUT_GET, 'button')));
88 88
 		$button->delete();
89 89
 
90
-		self::redirect( 'index', NULL, array(), ( filter_input(INPUT_GET, 'network') === '1' ? TRUE : FALSE ) );
90
+		self::redirect('index', NULL, array(), (filter_input(INPUT_GET, 'network') === '1' ? TRUE : FALSE));
91 91
 	}
92 92
 
93 93
 	/**
94 94
 	 * Helper method: redirect to a certain page.
95 95
 	 */
96
-	public static function redirect( $action, $button_id = NULL, $params = array(), $network = FALSE ) {
97
-		$page    = ( $network ? '/network/settings' : 'options-general' ) . '.php?page=' . filter_input(INPUT_GET, 'page');
98
-		$show    = ( $button_id ) ? '&button=' . $button_id : '';
96
+	public static function redirect($action, $button_id = NULL, $params = array(), $network = FALSE) {
97
+		$page    = ($network ? '/network/settings' : 'options-general') . '.php?page=' . filter_input(INPUT_GET, 'page');
98
+		$show    = ($button_id) ? '&button=' . $button_id : '';
99 99
 		$action  = '&action=' . $action;
100 100
 
101
-		array_walk( $params, function(&$value, $key) { $value = "&$key=$value"; } );
101
+		array_walk($params, function(&$value, $key) { $value = "&$key=$value"; } );
102 102
 
103
-		wp_redirect( admin_url( $page . $show . $action . implode( '', $params ) ) );
103
+		wp_redirect(admin_url($page . $show . $action . implode('', $params)));
104 104
 	}
105 105
 
106 106
 	public static function process_form() {
107
-		if ( null === filter_input(INPUT_GET, 'button') )
107
+		if (null === filter_input(INPUT_GET, 'button'))
108 108
 			return;
109 109
 
110
-		$action = ( null !== filter_input(INPUT_GET, 'action') ? filter_input(INPUT_GET, 'action') : NULL );
110
+		$action = (null !== filter_input(INPUT_GET, 'action') ? filter_input(INPUT_GET, 'action') : NULL);
111 111
 
112
-		if ( $action === 'save' ) {
112
+		if ($action === 'save') {
113 113
 			self::save();
114
-		} elseif ( $action === 'create' ) {
114
+		} elseif ($action === 'create') {
115 115
 			self::create();
116
-		} elseif ( $action === 'delete' ) {
116
+		} elseif ($action === 'delete') {
117 117
 			self::delete();
118 118
 		}
119 119
 	}
120 120
 
121 121
 	public static function new_template() {
122
-		if ( filter_input(INPUT_GET, 'network') == '1' ) {
122
+		if (filter_input(INPUT_GET, 'network') == '1') {
123 123
 			$button = new \PodloveSubscribeButton\Model\NetworkButton;
124 124
 		} else {
125 125
 			$button = new \PodloveSubscribeButton\Model\Button;
126 126
 		}
127 127
 
128
-		echo '<h3>' . __( 'New Subscribe button', 'podlove-subscribe-button' ) . '</h3>'.
129
-				__( 'Please fill in your Podcast metadata to create a Podlove Subscription button', 'podlove-subscribe-button' );
130
-		self::form_template( $button, 'create' );
128
+		echo '<h3>' . __('New Subscribe button', 'podlove-subscribe-button') . '</h3>' .
129
+				__('Please fill in your Podcast metadata to create a Podlove Subscription button', 'podlove-subscribe-button');
130
+		self::form_template($button, 'create');
131 131
 	}
132 132
 
133 133
 	public static function edit_template() {
134
-		if ( filter_input(INPUT_GET, 'network') == '1' ) {
135
-			$button = \PodloveSubscribeButton\Model\NetworkButton::find_by_id( filter_input(INPUT_GET, 'button') );
134
+		if (filter_input(INPUT_GET, 'network') == '1') {
135
+			$button = \PodloveSubscribeButton\Model\NetworkButton::find_by_id(filter_input(INPUT_GET, 'button'));
136 136
 		} else {
137
-			$button = \PodloveSubscribeButton\Model\Button::find_by_id( filter_input(INPUT_GET, 'button') );
137
+			$button = \PodloveSubscribeButton\Model\Button::find_by_id(filter_input(INPUT_GET, 'button'));
138 138
 		}
139 139
 
140
-		echo '<h3>' . sprintf( __( 'Edit Subscribe button: %s', 'podlove-subscribe-button' ), $button->title ) . '</h3>';
141
-		self::form_template( $button, 'save' );
140
+		echo '<h3>' . sprintf(__('Edit Subscribe button: %s', 'podlove-subscribe-button'), $button->title) . '</h3>';
141
+		self::form_template($button, 'save');
142 142
 	}
143 143
 
144 144
 	public static function view_template() {
@@ -155,19 +155,19 @@  discard block
 block discarded – undo
155 155
 		// Get the global button settings (with fallback to default values)
156 156
 		$settings = \PodloveSubscribeButton\Model\Button::get_global_setting_with_fallback();
157 157
 
158
-		if ( ! $is_network ) :
158
+		if ( ! $is_network) :
159 159
 		?>
160 160
 		<h3><?php _e('Default Settings', 'podlove'); ?></h3>
161 161
 		<form method="post" action="options.php">
162
-			<?php settings_fields( 'podlove-subscribe-button' ); ?>
163
-			<?php do_settings_sections( 'podlove-subscribe-button' ); ?>
162
+			<?php settings_fields('podlove-subscribe-button'); ?>
163
+			<?php do_settings_sections('podlove-subscribe-button'); ?>
164 164
 			<table class="form-table">
165 165
 				<tr valign="top">
166 166
 				<th scope="row"><label for="podlove_subscribe_button_default_size"><?php _e('Size', 'podlove'); ?></label></th>
167 167
 				<td>
168 168
 					<select name="podlove_subscribe_button_default_size" id="podlove_subscribe_button_default_size">
169 169
 						<?php foreach (\PodloveSubscribeButton\Model\Button::$size as $value => $description) : ?>
170
-							<option value="<?php echo $value; ?>" <?php echo ( $settings['size'] == $value ? "selected" : '' ); ?>><?php echo $description; ?></option>
170
+							<option value="<?php echo $value; ?>" <?php echo ($settings['size'] == $value ? "selected" : ''); ?>><?php echo $description; ?></option>
171 171
 						<?php endforeach; ?>
172 172
 					</select>
173 173
 				</td>
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 				<tr valign="top">
176 176
 				<th scope="row"><label for="podlove_subscribe_button_default_autowidth"><?php _e('Autowidth', 'podlove'); ?></label></th>
177 177
 				<td>
178
-					<input type="checkbox" name="podlove_subscribe_button_default_autowidth" id="podlove_subscribe_button_default_autowidth" <?php echo ( $settings['autowidth'] == 'on' ? 'checked' : '' ) ?> />
178
+					<input type="checkbox" name="podlove_subscribe_button_default_autowidth" id="podlove_subscribe_button_default_autowidth" <?php echo ($settings['autowidth'] == 'on' ? 'checked' : '') ?> />
179 179
 				</td>
180 180
 				</tr>
181 181
 				<tr valign="top">
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 				<td>
190 190
 					<select name="podlove_subscribe_button_default_style" id="podlove_subscribe_button_default_style">
191 191
 						<?php foreach (\PodloveSubscribeButton\Model\Button::$style as $value => $description) : ?>
192
-							<option value="<?php echo $value; ?>" <?php echo ( $settings['style'] == $value ? "selected" : '' ); ?>><?php echo $description; ?></option>
192
+							<option value="<?php echo $value; ?>" <?php echo ($settings['style'] == $value ? "selected" : ''); ?>><?php echo $description; ?></option>
193 193
 						<?php endforeach; ?>
194 194
 					</select>
195 195
 				</td>
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 				<td>
200 200
 					<select name="podlove_subscribe_button_default_format" id="podlove_subscribe_button_default_format">
201 201
 						<?php foreach (\PodloveSubscribeButton\Model\Button::$format as $value => $description) : ?>
202
-							<option value="<?php echo $value; ?>" <?php echo ( $settings['format'] == $value ? "selected" : '' ); ?>><?php echo $description; ?></option>
202
+							<option value="<?php echo $value; ?>" <?php echo ($settings['format'] == $value ? "selected" : ''); ?>><?php echo $description; ?></option>
203 203
 						<?php endforeach; ?>
204 204
 					</select>
205 205
 				</td>
@@ -211,13 +211,13 @@  discard block
 block discarded – undo
211 211
 		endif;
212 212
 	}
213 213
 
214
-	private static function form_template( $button, $action ) {
214
+	private static function form_template($button, $action) {
215 215
 		// Enqueue Scripts for Media Manager
216 216
 		wp_enqueue_media();
217 217
 		// Adjust if is_network
218 218
 		$is_network = is_network_admin();
219 219
 		?>
220
-		<form method="post" action="<?php echo ( $is_network === TRUE ? '/wp-admin/network/settings' : 'options-general' ) ?>.php?page=podlove-subscribe-button&button=<?php echo $button->id; ?>&action=<?php echo $action; ?>&network=<?php echo $is_network; ?>">
220
+		<form method="post" action="<?php echo ($is_network === TRUE ? '/wp-admin/network/settings' : 'options-general') ?>.php?page=podlove-subscribe-button&button=<?php echo $button->id; ?>&action=<?php echo $action; ?>&network=<?php echo $is_network; ?>">
221 221
 			<input type="hidden" value="<?php echo $button->id; ?>" name="podlove_button[id]" />
222 222
 			<table class="form-table" border="0" cellspacing="0">
223 223
 					<tbody>
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 							<select class="regular-text podlove-media-format" name="podlove_button[feeds][{{id}}][format]">
311 311
 								<?php
312 312
 									foreach (\PodloveSubscribeButton\MediaTypes::$audio as $id => $audio) {
313
-										echo "<option value='".$id."'>".$audio['title']."</option>\n";
313
+										echo "<option value='" . $id . "'>" . $audio['title'] . "</option>\n";
314 314
 									}
315 315
 								?>
316 316
 							</select>
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
 		<?php
326 326
 	}
327 327
 
328
-	public static function get_action_link( $button, $title, $action = 'edit', $type = 'link' ) {
328
+	public static function get_action_link($button, $title, $action = 'edit', $type = 'link') {
329 329
 		return sprintf(
330
-			'<a href="?page=%s&action=%s&button=%s&network='.is_network_admin().'"%s>' . $title . '</a>',
330
+			'<a href="?page=%s&action=%s&button=%s&network=' . is_network_admin() . '"%s>' . $title . '</a>',
331 331
 			filter_input(INPUT_GET, 'page'),
332 332
 			$action,
333 333
 			$button->id,
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -45,8 +45,9 @@  discard block
 block discarded – undo
45 45
 	 * Process form: save/update a format
46 46
 	 */
47 47
 	public static function save() {
48
-		if ( null == filter_input(INPUT_GET, 'button') )
49
-			return;
48
+		if ( null == filter_input(INPUT_GET, 'button') ) {
49
+					return;
50
+		}
50 51
 
51 52
 		$post = filter_input_array(INPUT_POST);
52 53
 
@@ -81,8 +82,9 @@  discard block
 block discarded – undo
81 82
 	 * Process form: delete a format
82 83
 	 */
83 84
 	public static function delete() {
84
-		if ( null ==  filter_input(INPUT_GET, 'button') )
85
-			return;
85
+		if ( null ==  filter_input(INPUT_GET, 'button') ) {
86
+					return;
87
+		}
86 88
 
87 89
 		$button = ( filter_input(INPUT_GET, 'network') === '1' ? \PodloveSubscribeButton\Model\NetworkButton::find_by_id( filter_input(INPUT_GET, 'button') ) : \PodloveSubscribeButton\Model\Button::find_by_id( filter_input(INPUT_GET, 'button') ) );
88 90
 		$button->delete();
@@ -104,8 +106,9 @@  discard block
 block discarded – undo
104 106
 	}
105 107
 
106 108
 	public static function process_form() {
107
-		if ( null === filter_input(INPUT_GET, 'button') )
108
-			return;
109
+		if ( null === filter_input(INPUT_GET, 'button') ) {
110
+					return;
111
+		}
109 112
 
110 113
 		$action = ( null !== filter_input(INPUT_GET, 'action') ? filter_input(INPUT_GET, 'action') : NULL );
111 114
 
Please login to merge, or discard this patch.
settings/buttons_list_table.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 namespace PodloveSubscribeButton;
3 3
 
4 4
 if( ! class_exists( 'WP_List_Table' ) ){
5
-    require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
5
+	require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
6 6
 }
7 7
 
8 8
 class Button_List_Table extends \WP_List_Table {
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
 		        
13 13
 		// Set parent defaults
14 14
 		parent::__construct( array(
15
-		    'singular'  => 'feed',   // singular name of the listed records
16
-		    'plural'    => 'feeds',  // plural name of the listed records
17
-		    'ajax'      => false  // does this table support ajax?
15
+			'singular'  => 'feed',   // singular name of the listed records
16
+			'plural'    => 'feeds',  // plural name of the listed records
17
+			'ajax'      => false  // does this table support ajax?
18 18
 		) );
19 19
 	}
20 20
 	
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 		);
27 27
 	
28 28
 		return sprintf('%1$s %2$s',
29
-		    /*$1%s*/ $button->title . '<br><code>[podlove-subscribe-button button="' . $button->name . '"]</code>',
30
-		    /*$3%s*/ $this->row_actions( $actions )
29
+			/*$1%s*/ $button->title . '<br><code>[podlove-subscribe-button button="' . $button->name . '"]</code>',
30
+			/*$3%s*/ $this->row_actions( $actions )
31 31
 		);
32 32
 	}
33 33
 
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
 		
84 84
 		// register pagination options & calculations
85 85
 		$this->set_pagination_args( array(
86
-		    'total_items' => $total_items,
87
-		    'per_page'    => $per_page,
88
-		    'total_pages' => ceil( $total_items / $per_page )
86
+			'total_items' => $total_items,
87
+			'per_page'    => $per_page,
88
+			'total_pages' => ceil( $total_items / $per_page )
89 89
 		) );
90 90
 	}
91 91
 
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,38 +1,38 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace PodloveSubscribeButton;
3 3
 
4
-if( ! class_exists( 'WP_List_Table' ) ){
5
-    require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
4
+if ( ! class_exists('WP_List_Table')) {
5
+    require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
6 6
 }
7 7
 
8 8
 class Button_List_Table extends \WP_List_Table {
9 9
 
10
-	function __construct(){
10
+	function __construct() {
11 11
 		global $status, $page;
12 12
 		        
13 13
 		// Set parent defaults
14
-		parent::__construct( array(
15
-		    'singular'  => 'feed',   // singular name of the listed records
16
-		    'plural'    => 'feeds',  // plural name of the listed records
14
+		parent::__construct(array(
15
+		    'singular'  => 'feed', // singular name of the listed records
16
+		    'plural'    => 'feeds', // plural name of the listed records
17 17
 		    'ajax'      => false  // does this table support ajax?
18
-		) );
18
+		));
19 19
 	}
20 20
 	
21
-	function column_name( $button ) {
21
+	function column_name($button) {
22 22
 
23 23
 		$actions = array(
24
-			'edit'   => Settings\Buttons::get_action_link( $button, __( 'Edit', 'podlove-subscribe-button' ), 'edit' ),
25
-			'delete' => Settings\Buttons::get_action_link( $button, __( 'Delete', 'podlove-subscribe-button' ), 'confirm_delete' )
24
+			'edit'   => Settings\Buttons::get_action_link($button, __('Edit', 'podlove-subscribe-button'), 'edit'),
25
+			'delete' => Settings\Buttons::get_action_link($button, __('Delete', 'podlove-subscribe-button'), 'confirm_delete')
26 26
 		);
27 27
 	
28 28
 		return sprintf('%1$s %2$s',
29 29
 		    /*$1%s*/ $button->title . '<br><code>[podlove-subscribe-button button="' . $button->name . '"]</code>',
30
-		    /*$3%s*/ $this->row_actions( $actions )
30
+		    /*$3%s*/ $this->row_actions($actions)
31 31
 		);
32 32
 	}
33 33
 
34
-	function column_button_preview( $button ) {
35
-		if ( ! $button->feeds )
34
+	function column_button_preview($button) {
35
+		if ( ! $button->feeds)
36 36
 			return;
37 37
 
38 38
 		$is_network = is_network_admin();
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
 			. "</div>";
48 48
 	}
49 49
 	
50
-	function column_id( $button ) {
50
+	function column_id($button) {
51 51
 		return $button->id;
52 52
 	}
53 53
 
54
-	function get_columns(){
54
+	function get_columns() {
55 55
 		return array(
56
-			'name'    => __( 'Title & Shortcode', 'podlove-subscribe-button' ),
57
-			'button_preview'    => __( 'Preview', 'podlove-subscribe-button' )
56
+			'name'    => __('Title & Shortcode', 'podlove-subscribe-button'),
57
+			'button_preview'    => __('Preview', 'podlove-subscribe-button')
58 58
 		);
59 59
 	}
60 60
 	
@@ -66,27 +66,27 @@  discard block
 block discarded – undo
66 66
 		$columns = $this->get_columns();
67 67
 		$hidden = array();
68 68
 		$sortable = $this->get_sortable_columns();
69
-		$this->_column_headers = array( $columns, $hidden, $sortable );
69
+		$this->_column_headers = array($columns, $hidden, $sortable);
70 70
 		
71 71
 		// retrieve data
72 72
 		// TODO select data for current page only
73
-		$data = ( is_network_admin() ? \PodloveSubscribeButton\Model\NetworkButton::all() : \PodloveSubscribeButton\Model\Button::all() );
73
+		$data = (is_network_admin() ? \PodloveSubscribeButton\Model\NetworkButton::all() : \PodloveSubscribeButton\Model\Button::all());
74 74
 
75 75
 		// get current page
76 76
 		$current_page = $this->get_pagenum();
77 77
 		// get total items
78
-		$total_items = count( $data );
78
+		$total_items = count($data);
79 79
 		// extrage page for current page only
80
-		$data = array_slice( $data, ( ( $current_page - 1 ) * $per_page ) , $per_page );
80
+		$data = array_slice($data, (($current_page - 1) * $per_page), $per_page);
81 81
 		// add items to table
82 82
 		$this->items = $data;
83 83
 		
84 84
 		// register pagination options & calculations
85
-		$this->set_pagination_args( array(
85
+		$this->set_pagination_args(array(
86 86
 		    'total_items' => $total_items,
87 87
 		    'per_page'    => $per_page,
88
-		    'total_pages' => ceil( $total_items / $per_page )
89
-		) );
88
+		    'total_pages' => ceil($total_items / $per_page)
89
+		));
90 90
 	}
91 91
 
92 92
 }
93 93
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,8 +32,9 @@
 block discarded – undo
32 32
 	}
33 33
 
34 34
 	function column_button_preview( $button ) {
35
-		if ( ! $button->feeds )
36
-			return;
35
+		if ( ! $button->feeds ) {
36
+					return;
37
+		}
37 38
 
38 39
 		$is_network = is_network_admin();
39 40
 
Please login to merge, or discard this patch.