Naguro_WordPress_Settings_Init

The WooCommerce Naguro Connect Naguro WordPress Settings Init class.

Defined (1)

The class is defined in the following location(s).

/includes/wordpress/class-wordpress-settings.php  
  1. class Naguro_WordPress_Settings_Init { 
  2. public function __construct() { 
  3. add_action( 'admin_init', array( $this, 'register_settings' ) ); 
  4.  
  5. public function register_settings() { 
  6. register_setting( 'naguro', 'naguro_settings' ); 
  7.  
  8. add_settings_section( 
  9. 'naguro_dimensions',  
  10. 'Dimensions',  
  11. array( $this, 'settings_section_callback' ),  
  12. 'naguro' 
  13. ); 
  14.  
  15. add_settings_field( 
  16. 'dimension_unit',  
  17. 'Dimension unit',  
  18. array( $this, 'dimension_unit_render' ),  
  19. 'naguro',  
  20. 'naguro_dimensions' 
  21. ); 
  22.  
  23. add_settings_field( 
  24. 'dpi',  
  25. 'DPI',  
  26. array( $this, 'dimension_dpi_render' ),  
  27. 'naguro',  
  28. 'naguro_dimensions' 
  29. ); 
  30.  
  31. public function settings_section_callback() { 
  32. echo 'Settings related to the dimensions being used in the Naguro products.'; 
  33.  
  34. public function dimension_unit_render() { 
  35. $options = get_option( 'naguro_settings' ); 
  36.  
  37. $dimensions = array( 
  38. 'mm' => 'mm',  
  39. 'cm' => 'cm',  
  40. 'inch' => 'inch',  
  41. 'yard' => 'yard' 
  42. ); 
  43.  
  44. echo '<select name="naguro_settings[dimension_unit]">'; 
  45.  
  46. foreach ( $dimensions as $key => $value ) { 
  47. echo '<option' . selected( $key, $options['dimension_unit'], false ) . ' value="' . $key . '">' . $value . '</option>'; 
  48.  
  49. echo '</select>'; 
  50.  
  51. public function dimension_dpi_render() { 
  52. $options = get_option( 'naguro_settings' ); 
  53. $dpi = isset( $options['dpi'] ) ? intval( $options['dpi'] ) : 300; 
  54. echo '<input type="text" name="naguro_settings[dpi]" value="'.$dpi.'">';