Import_Now::render_button( string $label = '', string $redirect = '' )
Summary
No summary available.Parameters
- $label
-
(string) (Optional) The label for the button.
Default value: ''
- $redirect
-
(string) (Optional) The redirect destination after starting the import. Defaults to the settings page.
Default value: ''
Return
(void)
Source
File: src/BigCommerce/Settings/Import_Now.php
public function render_button( $label = '', $redirect = '' ) { if ( ! $this->current_user_can_start_import() ) { return; } $label = $label ?: __( 'Sync Products', 'bigcommerce' ); $button = sprintf( '<button class="button bc-admin-btn bc-admin-btn--outline">%s</button>', $label ); /** * Hidden form fields */ $hidden_fields = [ [ 'name' => 'redirect_to', 'value' => $redirect, ], [ 'name' => 'action', 'value' => self::ACTION, ], [ 'name' => '_wpnonce', 'value' => wp_create_nonce( self::ACTION ), ], ]; $hidden_fields = implode( '', array_map( function ( $field ) { return sprintf( '<input type="hidden" name="%s" value="%s">', $field['name'], $field['value'] ); }, $hidden_fields ) ); /** * Import type dropdown */ $import_type_dropdown = [ [ 'name' => __( 'New/Updated since last sync', 'bigcommerce' ), 'value' => Import_Type::IMPORT_TYPE_PARTIAL, ], [ 'name' => __( 'All Products', 'bigcommerce' ), 'value' => Import_Type::IMPORT_TYPE_FULL, ], ]; $import_type_dropdown = implode( '', array_map( function ( $option ) { return sprintf( '<option value="%s">%s</option>', $option['value'], $option['name'] ); }, $import_type_dropdown ) ); $import_type_dropdown = sprintf( '<select name="%s">%s</select>', Import_Type::IMPORT_TYPE, $import_type_dropdown ); printf( '<form action="%s" class="bc-product-sync-form">%s %s %s</form>', admin_url( 'admin-post.php' ), $hidden_fields, $import_type_dropdown, $button ); }