@@ -22,22 +22,22 @@ discard block |
||
22 | 22 | } |
23 | 23 | |
24 | 24 | // Constants |
25 | -require('constants.php'); |
|
26 | -require('settings/buttons.php'); |
|
25 | +require( 'constants.php' ); |
|
26 | +require( 'settings/buttons.php' ); |
|
27 | 27 | // Models |
28 | -require('model/base.php'); |
|
29 | -require('model/button.php'); |
|
30 | -require('model/network_button.php'); |
|
28 | +require( 'model/base.php' ); |
|
29 | +require( 'model/button.php' ); |
|
30 | +require( 'model/network_button.php' ); |
|
31 | 31 | // Table |
32 | -require('settings/buttons_list_table.php'); |
|
32 | +require( 'settings/buttons_list_table.php' ); |
|
33 | 33 | // Media Types |
34 | -require('media_types.php'); |
|
34 | +require( 'media_types.php' ); |
|
35 | 35 | // Widget |
36 | -require('widget.php'); |
|
36 | +require( 'widget.php' ); |
|
37 | 37 | // Version control |
38 | -require('version.php'); |
|
38 | +require( 'version.php' ); |
|
39 | 39 | // Helper functions |
40 | -require('helper.php'); |
|
40 | +require( 'helper.php' ); |
|
41 | 41 | |
42 | 42 | register_activation_hook( __FILE__, array( 'PodloveSubscribeButton', 'build_models' ) ); |
43 | 43 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | $pages = array( 'settings_page_podlove-subscribe-button', 'widgets.php' ); |
77 | 77 | |
78 | - if ( ! in_array( $hook, $pages ) ) { |
|
78 | + if ( ! in_array( $hook, $pages ) ) { |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | public static function load_translations() { |
127 | - load_plugin_textdomain( 'podlove-subscribe-button', false, dirname(plugin_basename( __FILE__)) . '/languages/' ); |
|
127 | + load_plugin_textdomain( 'podlove-subscribe-button', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
@@ -163,56 +163,56 @@ discard block |
||
163 | 163 | 'format' => 'rectangle' |
164 | 164 | ); |
165 | 165 | |
166 | - foreach ($default_values as $option => $default_value) { |
|
167 | - if ( ! get_option('podlove_subscribe_button_default_' . $option ) ) { |
|
168 | - update_option('podlove_subscribe_button_default_' . $option, $default_value); |
|
166 | + foreach ( $default_values as $option => $default_value ) { |
|
167 | + if ( ! get_option( 'podlove_subscribe_button_default_' . $option ) ) { |
|
168 | + update_option( 'podlove_subscribe_button_default_' . $option, $default_value ); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
173 | 173 | public static function shortcode( $args ) { |
174 | - if ( ! $args || ! isset($args['button']) ) { |
|
175 | - return __('You need to create a Button first and provide its ID.', 'podlove-subscribe-button'); |
|
174 | + if ( ! $args || ! isset( $args[ 'button' ] ) ) { |
|
175 | + return __( 'You need to create a Button first and provide its ID.', 'podlove-subscribe-button' ); |
|
176 | 176 | } else { |
177 | - $buttonid = $args['button']; |
|
177 | + $buttonid = $args[ 'button' ]; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | // Fetch the (network)button by it's name |
181 | - if ( ! $button = \PodloveSubscribeButton\Model\Button::get_button_by_name($args['button']) ) |
|
182 | - return sprintf( __('Oops. There is no button with the ID "%s".', 'podlove-subscribe-button'), $args['button'] ); |
|
181 | + if ( ! $button = \PodloveSubscribeButton\Model\Button::get_button_by_name( $args[ 'button' ] ) ) |
|
182 | + return sprintf( __( 'Oops. There is no button with the ID "%s".', 'podlove-subscribe-button' ), $args[ 'button' ] ); |
|
183 | 183 | |
184 | 184 | // Get button styling and options |
185 | - $autowidth = self::interpret_width_attribute( self::get_array_value_with_fallback($args, 'width') ); |
|
186 | - $size = self::get_attribute( 'size', self::get_array_value_with_fallback($args, 'size') ); |
|
187 | - $style = self::get_attribute( 'style', self::get_array_value_with_fallback($args, 'style') ); |
|
188 | - $format = self::get_attribute( 'format', self::get_array_value_with_fallback($args, 'format') ); |
|
189 | - $color = self::get_attribute( 'color', self::get_array_value_with_fallback($args, 'color') ); |
|
190 | - |
|
191 | - if ( isset($args['language']) ) { |
|
192 | - $language = $args['language']; |
|
185 | + $autowidth = self::interpret_width_attribute( self::get_array_value_with_fallback( $args, 'width' ) ); |
|
186 | + $size = self::get_attribute( 'size', self::get_array_value_with_fallback( $args, 'size' ) ); |
|
187 | + $style = self::get_attribute( 'style', self::get_array_value_with_fallback( $args, 'style' ) ); |
|
188 | + $format = self::get_attribute( 'format', self::get_array_value_with_fallback( $args, 'format' ) ); |
|
189 | + $color = self::get_attribute( 'color', self::get_array_value_with_fallback( $args, 'color' ) ); |
|
190 | + |
|
191 | + if ( isset( $args[ 'language' ] ) ) { |
|
192 | + $language = $args[ 'language' ]; |
|
193 | 193 | } else { |
194 | 194 | $language = 'en'; |
195 | 195 | } |
196 | 196 | |
197 | - if ( isset($args['color']) ) { |
|
198 | - $color = $args['color']; |
|
197 | + if ( isset( $args[ 'color' ] ) ) { |
|
198 | + $color = $args[ 'color' ]; |
|
199 | 199 | } else { |
200 | - $color = get_option('podlove_subscribe_button_default_color', '#599677'); |
|
200 | + $color = get_option( 'podlove_subscribe_button_default_color', '#599677' ); |
|
201 | 201 | } |
202 | 202 | |
203 | - if ( isset($args['hide']) && $args['hide'] == 'true' ) { |
|
203 | + if ( isset( $args[ 'hide' ] ) && $args[ 'hide' ] == 'true' ) { |
|
204 | 204 | $hide = true; |
205 | 205 | } else { |
206 | 206 | $hide = false; |
207 | 207 | } |
208 | 208 | |
209 | 209 | // Render button |
210 | - return $button->render($size, $autowidth, $style, $format, $color, $hide, $buttonid, $language); |
|
210 | + return $button->render( $size, $autowidth, $style, $format, $color, $hide, $buttonid, $language ); |
|
211 | 211 | } |
212 | 212 | |
213 | - public static function get_array_value_with_fallback($args, $key) { |
|
214 | - if ( isset($args[$key]) ) |
|
215 | - return $args[$key]; |
|
213 | + public static function get_array_value_with_fallback( $args, $key ) { |
|
214 | + if ( isset( $args[ $key ] ) ) |
|
215 | + return $args[ $key ]; |
|
216 | 216 | |
217 | 217 | return false; |
218 | 218 | } |
@@ -222,11 +222,11 @@ discard block |
||
222 | 222 | * @param string $attribute_value |
223 | 223 | * @return string |
224 | 224 | */ |
225 | - private static function get_attribute($attribute=null, $attribute_value=null) { |
|
226 | - if ( isset($attribute_value) && ctype_alnum($attribute_value) && key_exists( $attribute_value, \PodloveSubscribeButton\Model\Button::$$attribute ) ) { |
|
225 | + private static function get_attribute( $attribute = null, $attribute_value = null ) { |
|
226 | + if ( isset( $attribute_value ) && ctype_alnum( $attribute_value ) && key_exists( $attribute_value, \PodloveSubscribeButton\Model\Button::$$attribute ) ) { |
|
227 | 227 | return $attribute_value; |
228 | 228 | } else { |
229 | - return get_option('podlove_subscribe_button_default_' . $attribute, \PodloveSubscribeButton\Model\Button::$properties[$attribute]); |
|
229 | + return get_option( 'podlove_subscribe_button_default_' . $attribute, \PodloveSubscribeButton\Model\Button::$properties[ $attribute ] ); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 |
@@ -151,8 +151,9 @@ discard block |
||
151 | 151 | public static function build_models() { |
152 | 152 | // Build Databases |
153 | 153 | \PodloveSubscribeButton\Model\Button::build(); |
154 | - if ( is_multisite() ) |
|
155 | - \PodloveSubscribeButton\Model\NetworkButton::build(); |
|
154 | + if ( is_multisite() ) { |
|
155 | + \PodloveSubscribeButton\Model\NetworkButton::build(); |
|
156 | + } |
|
156 | 157 | |
157 | 158 | // Set Button "default" values |
158 | 159 | $default_values = array( |
@@ -178,8 +179,9 @@ discard block |
||
178 | 179 | } |
179 | 180 | |
180 | 181 | // Fetch the (network)button by it's name |
181 | - if ( ! $button = \PodloveSubscribeButton\Model\Button::get_button_by_name($args['button']) ) |
|
182 | - return sprintf( __('Oops. There is no button with the ID "%s".', 'podlove-subscribe-button'), $args['button'] ); |
|
182 | + if ( ! $button = \PodloveSubscribeButton\Model\Button::get_button_by_name($args['button']) ) { |
|
183 | + return sprintf( __('Oops. There is no button with the ID "%s".', 'podlove-subscribe-button'), $args['button'] ); |
|
184 | + } |
|
183 | 185 | |
184 | 186 | // Get button styling and options |
185 | 187 | $autowidth = self::interpret_width_attribute( self::get_array_value_with_fallback($args, 'width') ); |
@@ -211,8 +213,9 @@ discard block |
||
211 | 213 | } |
212 | 214 | |
213 | 215 | public static function get_array_value_with_fallback($args, $key) { |
214 | - if ( isset($args[$key]) ) |
|
215 | - return $args[$key]; |
|
216 | + if ( isset($args[$key]) ) { |
|
217 | + return $args[$key]; |
|
218 | + } |
|
216 | 219 | |
217 | 220 | return false; |
218 | 221 | } |
@@ -236,10 +239,12 @@ discard block |
||
236 | 239 | * @return string |
237 | 240 | */ |
238 | 241 | private static function interpret_width_attribute( $width_attribute = null ) { |
239 | - if ( $width_attribute == 'auto' ) |
|
240 | - return 'on'; |
|
241 | - if ( $width_attribute && $width_attribute !== 'auto' ) |
|
242 | - return 'off'; |
|
242 | + if ( $width_attribute == 'auto' ) { |
|
243 | + return 'on'; |
|
244 | + } |
|
245 | + if ( $width_attribute && $width_attribute !== 'auto' ) { |
|
246 | + return 'off'; |
|
247 | + } |
|
243 | 248 | |
244 | 249 | return get_option( 'podlove_subscribe_button_default_autowidth', 'on' ); |
245 | 250 | } |