← All changes
|
admin/section/class-convertkit-settings-base.php
+29
-119
2.2.8
→
1.9.7.2
View file →
| @@ -46,22 +46,13 @@ | ||
| 46 | 46 | * Holds the settings class for the section. |
| 47 | 47 | * |
| 48 | 48 | * @since 1.9.6 |
| 49 | 49 | * |
| 50 | - * @var false|ConvertKit_Settings|ConvertKit_ContactForm7_Settings|ConvertKit_Wishlist_Settings|ConvertKit_Settings_Restrict_Content | |
| 50 | + * @var false|ConvertKit_Settings|ConvertKit_ContactForm7_Settings|ConvertKit_Wishlist_Settings | |
| 51 | 51 | */ |
| 52 | 52 | public $settings; |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | - * Holds whether this settings section is for beta functionality. | |
| 56 | - * | |
| 57 | - * @since 2.1.0 | |
| 58 | - * | |
| 59 | - * @var bool | |
| 60 | - */ | |
| 61 | - public $is_beta = false; | |
| 62 | - | |
| 63 | - /** | |
| 64 | 55 | * Constructor |
| 65 | 56 | */ |
| 66 | 57 | public function __construct() { |
| 67 | 58 | |
| @@ -107,26 +98,19 @@ | ||
| 107 | 98 | */ |
| 108 | 99 | abstract public function print_section_info(); |
| 109 | 100 | |
| 110 | 101 | /** |
| 111 | - * Returns the URL for the ConvertKit documentation for this setting section. | |
| 112 | - */ | |
| 113 | - abstract public function documentation_url(); | |
| 114 | - | |
| 115 | - /** | |
| 116 | 102 | * Renders the section |
| 117 | 103 | */ |
| 118 | 104 | public function render() { |
| 119 | 105 | |
| 120 | 106 | /** |
| 121 | - * Performs actions prior to rendering the settings form. | |
| 107 | + * Performs actions prior to rendering the settings form. | |
| 122 | 108 | * |
| 123 | 109 | * @since 1.9.6 |
| 124 | 110 | */ |
| 125 | 111 | do_action( 'convertkit_settings_base_render_before' ); |
| 126 | 112 | |
| 127 | - $this->render_container_start(); | |
| 128 | - | |
| 129 | 113 | do_settings_sections( $this->settings_key ); |
| 130 | 114 | |
| 131 | 115 | settings_fields( $this->settings_key ); |
| 132 | 116 | |
| @@ -131,10 +115,8 @@ | ||
| 131 | 115 | settings_fields( $this->settings_key ); |
| 132 | 116 | |
| 133 | 117 | submit_button(); |
| 134 | 118 | |
| 135 | - $this->render_container_end(); | |
| 136 | - | |
| 137 | 119 | /** |
| 138 | 120 | * Performs actions after rendering of the settings form. |
| 139 | 121 | * |
| 140 | 122 | * @since 1.9.6 |
| @@ -143,57 +125,8 @@ | ||
| 143 | 125 | |
| 144 | 126 | } |
| 145 | 127 | |
| 146 | 128 | /** |
| 147 | - * Outputs .metabox-holder and .postbox container div elements, | |
| 148 | - * used before beginning a setting screen's output. | |
| 149 | - * | |
| 150 | - * @since 2.0.0 | |
| 151 | - */ | |
| 152 | - public function render_container_start() { | |
| 153 | - | |
| 154 | - ?> | |
| 155 | - <div class="metabox-holder"> | |
| 156 | - <div class="postbox <?php echo sanitize_html_class( $this->is_beta ? 'convertkit-beta' : '' ); ?>"> | |
| 157 | - <?php | |
| 158 | - | |
| 159 | - } | |
| 160 | - | |
| 161 | - /** | |
| 162 | - * Outputs closing .metabox-holder and .postbox container div elements, | |
| 163 | - * used after finishing a setting screen's output. | |
| 164 | - * | |
| 165 | - * @since 2.0.0 | |
| 166 | - */ | |
| 167 | - public function render_container_end() { | |
| 168 | - | |
| 169 | - ?> | |
| 170 | - </div> | |
| 171 | - </div> | |
| 172 | - <?php | |
| 173 | - | |
| 174 | - } | |
| 175 | - | |
| 176 | - /** | |
| 177 | - * Outputs the given success message in an inline notice. | |
| 178 | - * | |
| 179 | - * @since 2.0.0 | |
| 180 | - * | |
| 181 | - * @param string $success_message Success Message. | |
| 182 | - */ | |
| 183 | - public function output_success( $success_message ) { | |
| 184 | - | |
| 185 | - ?> | |
| 186 | - <div class="notice notice-success is-dismissible"> | |
| 187 | - <p> | |
| 188 | - <?php echo esc_attr( $success_message ); ?> | |
| 189 | - </p> | |
| 190 | - </div> | |
| 191 | - <?php | |
| 192 | - | |
| 193 | - } | |
| 194 | - | |
| 195 | - /** | |
| 196 | 129 | * Outputs the given error message in an inline notice. |
| 197 | 130 | * |
| 198 | 131 | * @since 1.9.6 |
| 199 | 132 | * |
| @@ -201,9 +134,9 @@ | ||
| 201 | 134 | */ |
| 202 | 135 | public function output_error( $error_message ) { |
| 203 | 136 | |
| 204 | 137 | ?> |
| 205 | - <div class="notice notice-error is-dismissible"> | |
| 138 | + <div class="inline notice notice-error"> | |
| 206 | 139 | <p> |
| 207 | 140 | <?php echo esc_attr( $error_message ); ?> |
| 208 | 141 | </p> |
| 209 | 142 | </div> |
| @@ -215,11 +148,11 @@ | ||
| 215 | 148 | * Returns a masked value. |
| 216 | 149 | * |
| 217 | 150 | * @since 1.9.6 |
| 218 | 151 | * |
| 219 | - * @param string $value Value. | |
| 220 | - * @param bool|string $description Description. | |
| 221 | - * @return string Masked Value | |
| 152 | + * @param string $value Value. | |
| 153 | + * @param mixed $description Description (false|string). | |
| 154 | + * @return string Masked Value | |
| 222 | 155 | */ |
| 223 | 156 | public function get_masked_value( $value, $description = false ) { |
| 224 | 157 | |
| 225 | 158 | $html = sprintf( |
| @@ -239,19 +172,17 @@ | ||
| 239 | 172 | * Returns a text field. |
| 240 | 173 | * |
| 241 | 174 | * @since 1.9.6 |
| 242 | 175 | * |
| 243 | - * @param string $name Name. | |
| 244 | - * @param string $value Value. | |
| 245 | - * @param bool|string|array $description Description (false|string|array). | |
| 246 | - * @param bool|array $css_classes CSS Classes (false|array). | |
| 247 | - * @return string HTML Field | |
| 176 | + * @param string $name Name. | |
| 177 | + * @param string $value Value. | |
| 178 | + * @param mixed $description Description (false|string|array). | |
| 179 | + * @return string HTML Field | |
| 248 | 180 | */ |
| 249 | - public function get_text_field( $name, $value = '', $description = false, $css_classes = false ) { | |
| 181 | + public function get_text_field( $name, $value = '', $description = false ) { | |
| 250 | 182 | |
| 251 | 183 | $html = sprintf( |
| 252 | - '<input type="text" class="%s" id="%s" name="%s[%s]" value="%s" />', | |
| 253 | - ( is_array( $css_classes ) ? implode( ' ', $css_classes ) : 'regular-text' ), | |
| 184 | + '<input type="text" class="regular-text code" id="%s" name="%s[%s]" value="%s" />', | |
| 254 | 185 | $name, |
| 255 | 186 | $this->settings_key, |
| 256 | 187 | $name, |
| 257 | 188 | $value |
| @@ -265,26 +196,24 @@ | ||
| 265 | 196 | * Returns a select dropdown field. |
| 266 | 197 | * |
| 267 | 198 | * @since 1.9.6 |
| 268 | 199 | * |
| 269 | - * @param string $name Name. | |
| 270 | - * @param string $value Value. | |
| 271 | - * @param array $options Options / Choices. | |
| 272 | - * @param bool|string $description Description. | |
| 273 | - * @param bool|array $css_classes <select> CSS class(es). | |
| 274 | - * @param bool|array $attributes <select> attributes. | |
| 275 | - * @return string HTML Select Field | |
| 200 | + * @param string $name Name. | |
| 201 | + * @param string $value Value. | |
| 202 | + * @param array $options Options / Choices. | |
| 203 | + * @param mixed $description Description (false|string). | |
| 204 | + * @param mixed $css_classes <select> CSS class(es) (false|array). | |
| 205 | + * @return string HTML Select Field | |
| 276 | 206 | */ |
| 277 | - public function get_select_field( $name, $value = '', $options = array(), $description = false, $css_classes = false, $attributes = false ) { | |
| 207 | + public function get_select_field( $name, $value = '', $options = array(), $description = false, $css_classes = false ) { | |
| 278 | 208 | |
| 279 | 209 | // Build opening <select> tag. |
| 280 | 210 | $html = sprintf( |
| 281 | - '<select id="%s" name="%s[%s]" class="%s" size="1" %s>', | |
| 211 | + '<select id="%s" name="%s[%s]" class="%s" size="1">', | |
| 282 | 212 | $this->settings_key . '_' . $name, |
| 283 | 213 | $this->settings_key, |
| 284 | 214 | $name, |
| 285 | - ( is_array( $css_classes ) ? implode( ' ', $css_classes ) : '' ), | |
| 286 | - ( is_array( $attributes ) ? $this->array_to_attributes( $attributes ) : '' ) | |
| 215 | + ( is_array( $css_classes ) ? implode( ' ', $css_classes ) : '' ) | |
| 287 | 216 | ); |
| 288 | 217 | |
| 289 | 218 | // Build <option> tags. |
| 290 | 219 | foreach ( $options as $option => $label ) { |
| @@ -313,14 +242,14 @@ | ||
| 313 | 242 | * Returns a checkbox field. |
| 314 | 243 | * |
| 315 | 244 | * @since 1.9.6 |
| 316 | 245 | * |
| 317 | - * @param string $name Name. | |
| 318 | - * @param string $value Value. | |
| 319 | - * @param bool $checked Should checkbox be checked/ticked. | |
| 320 | - * @param bool|string $label Label. | |
| 321 | - * @param bool|string|array $description Description. | |
| 322 | - * @return string HTML Checkbox | |
| 246 | + * @param string $name Name. | |
| 247 | + * @param string $value Value. | |
| 248 | + * @param bool $checked Should checkbox be checked/ticked. | |
| 249 | + * @param mixed $label Label (false|string). | |
| 250 | + * @param mixed $description Description (false|string). | |
| 251 | + * @return string HTML Checkbox | |
| 323 | 252 | */ |
| 324 | 253 | public function get_checkbox_field( $name, $value, $checked = false, $label = '', $description = '' ) { |
| 325 | 254 | |
| 326 | 255 | $html = ''; |
| @@ -356,10 +285,10 @@ | ||
| 356 | 285 | * Returns the given text wrapped in a paragraph with the description class. |
| 357 | 286 | * |
| 358 | 287 | * @since 1.9.6 |
| 359 | 288 | * |
| 360 | - * @param bool|string|array $description Description. | |
| 361 | - * @return string HTML Description | |
| 289 | + * @param mixed $description Description (false|string|array). | |
| 290 | + * @return string HTML Description | |
| 362 | 291 | */ |
| 363 | 292 | private function get_description( $description ) { |
| 364 | 293 | |
| 365 | 294 | // Return blank string if no description specified. |
| @@ -373,27 +302,8 @@ | ||
| 373 | 302 | } |
| 374 | 303 | |
| 375 | 304 | // Return description lines in a paragraph, using breaklines for each description entry in the array. |
| 376 | 305 | return '<p class="description">' . implode( '<br />', $description ); |
| 377 | - | |
| 378 | - } | |
| 379 | - | |
| 380 | - /** | |
| 381 | - * Converts the given key/value array pairs into a HTML attribute="value" string. | |
| 382 | - * | |
| 383 | - * @since 1.9.8.5 | |
| 384 | - * | |
| 385 | - * @param array $array Attributes. | |
| 386 | - * @return string HTML attributes string | |
| 387 | - */ | |
| 388 | - private function array_to_attributes( $array ) { | |
| 389 | - | |
| 390 | - $attributes = ''; | |
| 391 | - foreach ( $array as $key => $value ) { | |
| 392 | - $attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" '; | |
| 393 | - } | |
| 394 | - | |
| 395 | - return trim( $attributes ); | |
| 396 | 306 | |
| 397 | 307 | } |
| 398 | 308 | |
| 399 | 309 | /** |