Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
58.33% |
7 / 12 |
|
33.33% |
1 / 3 |
CRAP | |
0.00% |
0 / 1 |
| Klaviyo_Private_Key | |
58.33% |
7 / 12 |
|
33.33% |
1 / 3 |
3.65 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
| print_field_callback | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| sanitize_callback | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * This settings field is a text field to save the Klaviyo private key |
| 4 | * |
| 5 | * @link https://BrianHenry.ie |
| 6 | * @since 1.0.0 |
| 7 | * |
| 8 | * @package brianhenryie/bh-wp-autologin-urls |
| 9 | */ |
| 10 | |
| 11 | namespace BrianHenryIE\WP_Autologin_URLs\Admin\Settings_Fields; |
| 12 | |
| 13 | use BrianHenryIE\WP_Autologin_URLs\Settings_Interface; |
| 14 | |
| 15 | class Klaviyo_Private_Key extends Settings_Section_Element_Abstract { |
| 16 | |
| 17 | /** |
| 18 | * Constructor. |
| 19 | * |
| 20 | * @param string $settings_page_slug_name The slug of the page this setting is being displayed on. |
| 21 | * @param Settings_Interface $settings The existing settings saved in the database. |
| 22 | */ |
| 23 | public function __construct( $settings_page_slug_name, $settings ) { |
| 24 | |
| 25 | parent::__construct( $settings_page_slug_name ); |
| 26 | |
| 27 | $this->value = $settings->get_klaviyo_private_api_key(); |
| 28 | |
| 29 | $this->id = 'bh_wp_autologin_urls_klaviyo_private_key'; |
| 30 | $this->title = 'Klaviyo Private Key:'; |
| 31 | $this->page = $settings_page_slug_name; |
| 32 | |
| 33 | $this->add_settings_field_args['helper'] = sprintf( __( 'Find your API keys at <a href="%s" target="_blank">klaviyo.com/account#api-keys-tab</a>.', 'bh-wp-autologin-urls' ), 'https://www.klaviyo.com/account#api-keys-tab' ); |
| 34 | $this->add_settings_field_args['placeholder'] = ''; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * The function used by WordPress Settings API to output the field. |
| 39 | * |
| 40 | * @param array{placeholder:string, helper:string, supplemental:string} $arguments Settings passed from WordPress do_settings_fields() function. |
| 41 | */ |
| 42 | public function print_field_callback( $arguments ): void { |
| 43 | |
| 44 | $value = $this->value; |
| 45 | |
| 46 | $arguments['placeholder'] = ''; |
| 47 | |
| 48 | printf( '<input name="%1$s" id="%1$s" type="text" placeholder="%2$s" value="%3$s" />', esc_attr( $this->id ), esc_attr( $arguments['placeholder'] ), esc_attr( $value ) ); |
| 49 | |
| 50 | printf( '<span class="helper">%s</span>', $arguments['helper'] ); |
| 51 | |
| 52 | // printf( '<p class="description">%s</p>', esc_html( $arguments['supplemental'] ) ); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * TODO: What would show it is invalid? |
| 57 | * |
| 58 | * @param string $value The value POSTed by the Settings API. |
| 59 | * |
| 60 | * @return string |
| 61 | */ |
| 62 | public function sanitize_callback( $value ) { |
| 63 | |
| 64 | return $value; |
| 65 | } |
| 66 | } |