monsterinsights_make_checkbox

Outputs a checkbox for settings.

Description

monsterinsights_make_checkbox( $option_id, (string) $title = '', (string) $description = '' ); 

Do not use this in other plugins. We may remove this at any time without forwarning and without consideration for backwards compatibility.

This is to be considered a private function, for MonsterInsights use only.

Parameters (3)

0. $option_id
The option id.
1. $title — Optional. (string) => ''
The title.
2. $description — Optional. (string) => ''
The description.

Usage

  1. if ( !function_exists( 'monsterinsights_make_checkbox' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-analytics-for-wordpress-by-monsterinsights/includes/admin/pages/settings.php'; 
  3.  
  4. // The option id. 
  5. $option_id = null; 
  6.  
  7. // The title. 
  8. $title = ''; 
  9.  
  10. // The description. 
  11. $description = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = monsterinsights_make_checkbox($option_id, $title, $description); 
  15.  

Defined (1)

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

/includes/admin/pages/settings.php  
  1. function monsterinsights_make_checkbox( $option_id, $title = '', $description = '' ) { 
  2. $option_value = monsterinsights_get_option( $option_id, 0 ); 
  3. $option_class = str_replace( '_', '-', $option_id ); 
  4. ob_start(); 
  5. ?> 
  6. <tr id="monsterinsights-input-<?php echo esc_attr( $option_class ); ?>"> 
  7. <?php if ( !empty ( $title ) ) { ?> 
  8. <th scope="row"> 
  9. <label for="monsterinsights-<?php echo esc_attr( $option_class ); ?>"><?php echo $title; ?></label> 
  10. </th> 
  11. <?php } ?> 
  12. <td> 
  13. <input type="checkbox" id="monsterinsights-<?php echo esc_attr( $option_class ); ?>" name="<?php echo esc_attr( $option_id ); ?>" <?php checked( $option_value, 1 ); ?> /> 
  14. <?php if ( ! empty ( $description ) ) { ?> 
  15. <p class="description"> 
  16. <?php echo $description; ?> 
  17. </p> 
  18. <?php } ?> 
  19. </td> 
  20. </tr> 
  21. <?php 
  22. $input_field = ob_get_contents(); 
  23. ob_end_clean(); 
  24. return $input_field;