@@ -22,43 +22,43 @@ 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 | -add_action( 'admin_menu', array( 'PodloveSubscribeButton', 'admin_menu') ); |
|
42 | +add_action( 'admin_menu', array( 'PodloveSubscribeButton', 'admin_menu' ) ); |
|
43 | 43 | if ( is_multisite() ) |
44 | - add_action( 'network_admin_menu', array( 'PodloveSubscribeButton', 'admin_network_menu') ); |
|
44 | + add_action( 'network_admin_menu', array( 'PodloveSubscribeButton', 'admin_network_menu' ) ); |
|
45 | 45 | |
46 | 46 | add_action( 'admin_init', array( 'PodloveSubscribeButton\Settings\Buttons', 'process_form' ) ); |
47 | 47 | register_activation_hook( __FILE__, array( 'PodloveSubscribeButton', 'build_models' ) ); |
48 | 48 | |
49 | 49 | // Register Settings |
50 | -add_action( 'admin_init', function () { |
|
51 | - $settings = array('size', 'autowidth', 'style', 'format', 'color'); |
|
50 | +add_action( 'admin_init', function() { |
|
51 | + $settings = array( 'size', 'autowidth', 'style', 'format', 'color' ); |
|
52 | 52 | |
53 | - foreach ($settings as $setting) { |
|
53 | + foreach ( $settings as $setting ) { |
|
54 | 54 | register_setting( 'podlove-subscribe-button', 'podlove_subscribe_button_default_' . $setting ); |
55 | 55 | } |
56 | 56 | } ); |
57 | 57 | |
58 | 58 | add_shortcode( 'podlove-subscribe-button', array( 'PodloveSubscribeButton', 'shortcode' ) ); |
59 | 59 | |
60 | -add_action( 'plugins_loaded', function () { |
|
61 | - load_plugin_textdomain( 'podlove-subscribe-button', false, dirname(plugin_basename( __FILE__)) . '/languages/'); |
|
60 | +add_action( 'plugins_loaded', function() { |
|
61 | + load_plugin_textdomain( 'podlove-subscribe-button', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
|
62 | 62 | } ); |
63 | 63 | |
64 | 64 | PodloveSubscribeButton::run(); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | $pages = array( 'settings_page_podlove-subscribe-button', 'widgets.php' ); |
76 | 76 | |
77 | - if ( ! in_array( $hook, $pages ) ) { |
|
77 | + if ( ! in_array( $hook, $pages ) ) { |
|
78 | 78 | return; |
79 | 79 | } |
80 | 80 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | 'Podlove Subscribe Button', |
105 | 105 | 'manage_options', |
106 | 106 | 'podlove-subscribe-button', |
107 | - array( 'PodloveSubscribeButton\Settings\Buttons', 'page') |
|
107 | + array( 'PodloveSubscribeButton\Settings\Buttons', 'page' ) |
|
108 | 108 | ); |
109 | 109 | } |
110 | 110 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | 'Podlove Subscribe Button', |
116 | 116 | 'manage_options', |
117 | 117 | 'podlove-subscribe-button', |
118 | - array( 'PodloveSubscribeButton\Settings\Buttons', 'page') |
|
118 | + array( 'PodloveSubscribeButton\Settings\Buttons', 'page' ) |
|
119 | 119 | ); |
120 | 120 | } |
121 | 121 | |
@@ -134,56 +134,56 @@ discard block |
||
134 | 134 | 'format' => 'rectangle' |
135 | 135 | ); |
136 | 136 | |
137 | - foreach ($default_values as $option => $default_value) { |
|
138 | - if ( ! get_option('podlove_subscribe_button_default_' . $option ) ) { |
|
139 | - update_option('podlove_subscribe_button_default_' . $option, $default_value); |
|
137 | + foreach ( $default_values as $option => $default_value ) { |
|
138 | + if ( ! get_option( 'podlove_subscribe_button_default_' . $option ) ) { |
|
139 | + update_option( 'podlove_subscribe_button_default_' . $option, $default_value ); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
144 | 144 | public static function shortcode( $args ) { |
145 | - if ( ! $args || ! isset($args['button']) ) { |
|
146 | - return __('You need to create a Button first and provide its ID.', 'podlove-subscribe-button'); |
|
145 | + if ( ! $args || ! isset( $args[ 'button' ] ) ) { |
|
146 | + return __( 'You need to create a Button first and provide its ID.', 'podlove-subscribe-button' ); |
|
147 | 147 | } else { |
148 | - $buttonid = $args['button']; |
|
148 | + $buttonid = $args[ 'button' ]; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | // Fetch the (network)button by it's name |
152 | - if ( ! $button = \PodloveSubscribeButton\Model\Button::get_button_by_name($args['button']) ) |
|
153 | - return sprintf( __('Oops. There is no button with the ID "%s".', 'podlove-subscribe-button'), $args['button'] ); |
|
152 | + if ( ! $button = \PodloveSubscribeButton\Model\Button::get_button_by_name( $args[ 'button' ] ) ) |
|
153 | + return sprintf( __( 'Oops. There is no button with the ID "%s".', 'podlove-subscribe-button' ), $args[ 'button' ] ); |
|
154 | 154 | |
155 | 155 | // Get button styling and options |
156 | - $autowidth = self::interpret_width_attribute( self::get_array_value_with_fallback($args, 'width') ); |
|
157 | - $size = self::get_attribute( 'size', self::get_array_value_with_fallback($args, 'size') ); |
|
158 | - $style = self::get_attribute( 'style', self::get_array_value_with_fallback($args, 'style') ); |
|
159 | - $format = self::get_attribute( 'format', self::get_array_value_with_fallback($args, 'format') ); |
|
160 | - $color = self::get_attribute( 'color', self::get_array_value_with_fallback($args, 'color') ); |
|
161 | - |
|
162 | - if ( isset($args['language']) ) { |
|
163 | - $language = $args['language']; |
|
156 | + $autowidth = self::interpret_width_attribute( self::get_array_value_with_fallback( $args, 'width' ) ); |
|
157 | + $size = self::get_attribute( 'size', self::get_array_value_with_fallback( $args, 'size' ) ); |
|
158 | + $style = self::get_attribute( 'style', self::get_array_value_with_fallback( $args, 'style' ) ); |
|
159 | + $format = self::get_attribute( 'format', self::get_array_value_with_fallback( $args, 'format' ) ); |
|
160 | + $color = self::get_attribute( 'color', self::get_array_value_with_fallback( $args, 'color' ) ); |
|
161 | + |
|
162 | + if ( isset( $args[ 'language' ] ) ) { |
|
163 | + $language = $args[ 'language' ]; |
|
164 | 164 | } else { |
165 | 165 | $language = 'en'; |
166 | 166 | } |
167 | 167 | |
168 | - if ( isset($args['color']) ) { |
|
169 | - $color = $args['color']; |
|
168 | + if ( isset( $args[ 'color' ] ) ) { |
|
169 | + $color = $args[ 'color' ]; |
|
170 | 170 | } else { |
171 | - $color = get_option('podlove_subscribe_button_default_color', '#599677'); |
|
171 | + $color = get_option( 'podlove_subscribe_button_default_color', '#599677' ); |
|
172 | 172 | } |
173 | 173 | |
174 | - if ( isset($args['hide']) && $args['hide'] == 'true' ) { |
|
174 | + if ( isset( $args[ 'hide' ] ) && $args[ 'hide' ] == 'true' ) { |
|
175 | 175 | $hide = true; |
176 | 176 | } else { |
177 | 177 | $hide = false; |
178 | 178 | } |
179 | 179 | |
180 | 180 | // Render button |
181 | - return $button->render($size, $autowidth, $style, $format, $color, $hide, $buttonid, $language); |
|
181 | + return $button->render( $size, $autowidth, $style, $format, $color, $hide, $buttonid, $language ); |
|
182 | 182 | } |
183 | 183 | |
184 | - public static function get_array_value_with_fallback($args, $key) { |
|
185 | - if ( isset($args[$key]) ) |
|
186 | - return $args[$key]; |
|
184 | + public static function get_array_value_with_fallback( $args, $key ) { |
|
185 | + if ( isset( $args[ $key ] ) ) |
|
186 | + return $args[ $key ]; |
|
187 | 187 | |
188 | 188 | return false; |
189 | 189 | } |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | * @param string $attribute_value |
194 | 194 | * @return string |
195 | 195 | */ |
196 | - private static function get_attribute($attribute=null, $attribute_value=null) { |
|
197 | - if ( isset($attribute_value) && ctype_alnum($attribute_value) && key_exists( $attribute_value, \PodloveSubscribeButton\Model\Button::$$attribute ) ) { |
|
196 | + private static function get_attribute( $attribute = null, $attribute_value = null ) { |
|
197 | + if ( isset( $attribute_value ) && ctype_alnum( $attribute_value ) && key_exists( $attribute_value, \PodloveSubscribeButton\Model\Button::$$attribute ) ) { |
|
198 | 198 | return $attribute_value; |
199 | 199 | } else { |
200 | - return get_option('podlove_subscribe_button_default_' . $attribute, \PodloveSubscribeButton\Model\Button::$properties[$attribute]); |
|
200 | + return get_option( 'podlove_subscribe_button_default_' . $attribute, \PodloveSubscribeButton\Model\Button::$properties[ $attribute ] ); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
@@ -212,6 +212,6 @@ discard block |
||
212 | 212 | if ( $width_attribute && $width_attribute !== 'auto' ) |
213 | 213 | return 'off'; |
214 | 214 | |
215 | - return get_option('podlove_subscribe_button_default_autowidth', 'on'); |
|
215 | + return get_option( 'podlove_subscribe_button_default_autowidth', 'on' ); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | \ No newline at end of file |