@@ -39,8 +39,9 @@ discard block |
||
| 39 | 39 | require('helper.php'); |
| 40 | 40 | |
| 41 | 41 | add_action( 'admin_menu', array( 'PodloveSubscribeButton', 'admin_menu') ); |
| 42 | -if ( is_multisite() ) |
|
| 42 | +if ( is_multisite() ) { |
|
| 43 | 43 | add_action( 'network_admin_menu', array( 'PodloveSubscribeButton', 'admin_network_menu') ); |
| 44 | +} |
|
| 44 | 45 | |
| 45 | 46 | add_action( 'admin_init', array( 'PodloveSubscribeButton\Settings\Buttons', 'process_form' ) ); |
| 46 | 47 | register_activation_hook( __FILE__, array( 'PodloveSubscribeButton', 'build_models' ) ); |
@@ -121,8 +122,9 @@ discard block |
||
| 121 | 122 | public static function build_models() { |
| 122 | 123 | // Build Databases |
| 123 | 124 | \PodloveSubscribeButton\Model\Button::build(); |
| 124 | - if ( is_multisite() ) |
|
| 125 | - \PodloveSubscribeButton\Model\NetworkButton::build(); |
|
| 125 | + if ( is_multisite() ) { |
|
| 126 | + \PodloveSubscribeButton\Model\NetworkButton::build(); |
|
| 127 | + } |
|
| 126 | 128 | |
| 127 | 129 | // Set Button "default" values |
| 128 | 130 | $default_values = array( |
@@ -148,8 +150,9 @@ discard block |
||
| 148 | 150 | } |
| 149 | 151 | |
| 150 | 152 | // Fetch the (network)button by it's name |
| 151 | - if ( ! $button = \PodloveSubscribeButton\Model\Button::get_button_by_name($args['button']) ) |
|
| 152 | - return sprintf( __('Oops. There is no button with the ID "%s".', 'podlove-subscribe-button'), $args['button'] ); |
|
| 153 | + if ( ! $button = \PodloveSubscribeButton\Model\Button::get_button_by_name($args['button']) ) { |
|
| 154 | + return sprintf( __('Oops. There is no button with the ID "%s".', 'podlove-subscribe-button'), $args['button'] ); |
|
| 155 | + } |
|
| 153 | 156 | |
| 154 | 157 | // Get button styling and options |
| 155 | 158 | $autowidth = self::interpret_width_attribute( self::get_array_value_with_fallback($args, 'width') ); |
@@ -181,8 +184,9 @@ discard block |
||
| 181 | 184 | } |
| 182 | 185 | |
| 183 | 186 | public static function get_array_value_with_fallback($args, $key) { |
| 184 | - if ( isset($args[$key]) ) |
|
| 185 | - return $args[$key]; |
|
| 187 | + if ( isset($args[$key]) ) { |
|
| 188 | + return $args[$key]; |
|
| 189 | + } |
|
| 186 | 190 | |
| 187 | 191 | return false; |
| 188 | 192 | } |
@@ -206,10 +210,12 @@ discard block |
||
| 206 | 210 | * @return string |
| 207 | 211 | */ |
| 208 | 212 | private static function interpret_width_attribute( $width_attribute = null ) { |
| 209 | - if ( $width_attribute == 'auto' ) |
|
| 210 | - return 'on'; |
|
| 211 | - if ( $width_attribute && $width_attribute !== 'auto' ) |
|
| 212 | - return 'off'; |
|
| 213 | + if ( $width_attribute == 'auto' ) { |
|
| 214 | + return 'on'; |
|
| 215 | + } |
|
| 216 | + if ( $width_attribute && $width_attribute !== 'auto' ) { |
|
| 217 | + return 'off'; |
|
| 218 | + } |
|
| 213 | 219 | |
| 214 | 220 | return get_option('podlove_subscribe_button_default_autowidth', 'on'); |
| 215 | 221 | } |
@@ -45,8 +45,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -45,11 +45,13 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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() |