BWS_Settings_Fields

The Bootstrap Widget Styling BWS Settings Fields class.

Defined (1)

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

/includes/class-bws-settings-fields.php  
  1. class BWS_Settings_Fields { 
  2.  
  3. private static $instance ; 
  4. static $input_type = 'checkbox' ; 
  5. private $type ; 
  6.  
  7. private function __construct( $type ) { 
  8. $this->type = $type ; 
  9.  
  10. static function add_fields_for_widget_types( $types ) { 
  11. foreach ( $types as $type ) { 
  12. self::instantiate_and_add_setting( $type ) ; 
  13.  
  14. static function instantiate_and_add_setting( $type ) { 
  15. self::$instance = new self( $type ) ; 
  16. self::$instance->bws_add_settings_field() ; 
  17.  
  18. function bws_add_settings_field() { 
  19. $type = ucfirst( $this->type ) ; 
  20. add_settings_field( "bws_plugin_disable_{$type}_widget" , _( '"' . $type . '" widget' ) , array( $this , 'output_callback_for_setting' ) , 'bws_options_page' , 'bws_plugin_primary' ) ; 
  21.  
  22. function output_callback_for_setting() { 
  23. $disable_widget_setting = $this->is_filter_disabled_for_this_widget() ; 
  24. $name = 'bws_plugin_options[disable_' . $this->type . '_widget]' ; 
  25. ?> 
  26. <input type="<?php echo self::$input_type ; ?>" name="<?php echo $name ; ?>" <?php checked( $disable_widget_setting , '1' , true ) ; ?> value="1"/> 
  27. <?php 
  28.  
  29. function is_filter_disabled_for_this_widget() { 
  30. $options = get_option( 'bws_plugin_options' ) ; 
  31. $key = 'disable_' . $this->type . '_widget' ; 
  32. $is_disabled = isset( $options[ $key ] ) ? $options[ $key ] : 0 ; 
  33. return $is_disabled ; 
  34.