',
esc_url( admin_url( 'admin-post.php' ) ),
'' !== $confirm ? ' data-abs-courier-confirm="' . esc_attr( $confirm ) . '"' : ''
);
printf( '', esc_attr( $action ) );
wp_nonce_field( $action );
printf(
'',
'primary' === $style ? 'button-primary' : ( 'delete' === $style ? 'button-link-delete' : 'button-secondary' ),
esc_html( $label )
);
}
/**
* Account section.
*
* @return void
*/
private static function render_account() {
echo '
' . esc_html__( 'ABS account', 'abs-courier' ) . '
';
if ( Credentials::from_constant() ) {
echo '' . esc_html__( 'The API key is set in wp-config.php (ABS_COURIER_API_KEY).', 'abs-courier' ) . ' ';
echo '' . esc_html( Credentials::mask( Credentials::get() ) ) . '
';
self::action_button( Actions::TEST, __( 'Test connection', 'abs-courier' ) );
return;
}
$api_key = Credentials::get();
if ( '' !== $api_key ) {
$state = Connection::state_saved();
echo '';
self::action_button( Actions::TEST, __( 'Test connection', 'abs-courier' ) );
self::action_button( Actions::DISCONNECT, __( 'Disconnect', 'abs-courier' ), 'delete', __( 'Disconnect from ABS Courier? The API key will be removed from this site.', 'abs-courier' ) );
echo '' . esc_html__( 'Use a different API key', 'abs-courier' ) . '
';
self::key_form( __( 'Replace key', 'abs-courier' ) );
echo ' ';
return;
}
echo '' . esc_html__( 'Paste the API key from your ABS Courier portal. It is checked with ABS before it is saved.', 'abs-courier' ) . '
';
self::key_form( __( 'Connect', 'abs-courier' ) );
}
/**
* API key form with the key requirements.
*
* @param string $button Submit button label.
* @return void
*/
private static function key_form( $button ) {
printf( '', esc_html( $button ) );
}
/**
* Shipment settings form.
*
* @return void
*/
private static function render_settings() {
$s = Settings::all();
$products = Lookups::products();
$services = Lookups::services();
echo '' . esc_html__( 'Shipments', 'abs-courier' ) . '
';
printf( '', esc_html__( 'Save settings', 'abs-courier' ) );
}
/**
* Opens a form-table row.
*
* @param string $label Row label.
* @param string $input_id Optional ID of the labelled input.
* @return void
*/
private static function row_start( $label, $input_id = '' ) {
echo '| ';
if ( '' !== $input_id ) {
printf( '', esc_attr( $input_id ), esc_html( $label ) );
} else {
echo esc_html( $label );
}
echo ' | ';
}
/**
* Closes a form-table row.
*
* @return void
*/
private static function row_end() {
echo ' |
';
}
/**
* Checkbox field.
*
* @param string $name Setting name.
* @param bool $checked Current value.
* @param string $label Label.
* @return void
*/
private static function checkbox( $name, $checked, $label ) {
printf(
'',
esc_attr( $name ),
checked( (bool) $checked, true, false ),
esc_html( $label )
);
}
/**
* Radio option.
*
* @param string $name Setting name.
* @param string $value Option value.
* @param string $current Current value.
* @param string $label Label.
* @return void
*/
private static function radio( $name, $value, $current, $label ) {
printf(
'',
esc_attr( $name ),
esc_attr( $value ),
checked( $current, $value, false ),
esc_html( $label )
);
}
/**
* Select field.
*
* @param string $name Setting name.
* @param array $options Value => label.
* @param string $current Current value.
* @param string $id Element ID.
* @return void
*/
private static function select( $name, array $options, $current, $id ) {
printf( '';
}
}