monsterinsights_save_settings

Saves Settings.

Description

(null) monsterinsights_save_settings(); 

Returns (null)

Return early if not fixing the broken migration


Usage

  1. if ( !function_exists( 'monsterinsights_save_settings' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-analytics-for-wordpress-by-monsterinsights/includes/admin/settings/settings-api.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = monsterinsights_save_settings(); 
  7.  

Defined (1)

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

/includes/admin/settings/settings-api.php  
  1. function monsterinsights_save_settings() { 
  2.  
  3. // Check if user pressed the 'Update' button and nonce is valid 
  4. if ( ! isset( $_POST['monsterinsights-settings-submit'] ) ) { 
  5. return; 
  6.  
  7. if ( ! wp_verify_nonce( $_POST['monsterinsights-settings-nonce'], 'monsterinsights-settings-nonce' ) ) { 
  8. return; 
  9.  
  10. if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { 
  11. return; 
  12.  
  13. if ( empty( $_POST['monsterinsights_settings_tab'] ) || empty( $_POST['monsterinsights_settings_sub_tab'] ) || $_POST['monsterinsights_settings_tab'] !== 'tracking' ) { 
  14. return; 
  15.  
  16. // get subtab 
  17. $tab = $_POST['monsterinsights_settings_sub_tab']; 
  18. if ( empty( $settings ) || !is_array( $settings ) || empty( $settings[ $tab ] ) || ! is_array( $settings[ $tab ] ) ) { 
  19. return; 
  20.  
  21. // Okay we're good to sanitize, validate, and save this section's settings 
  22.  
  23. // We only care about this sections's settings 
  24. $settings = $settings[ $tab ];  
  25.  
  26. // Run a general sanitization for the tab for special fields 
  27. $input = ! empty( $_POST['monsterinsights_settings'] ) ? $_POST['monsterinsights_settings'] : array(); 
  28. $input = apply_filters( 'monsterinsights_settings_' . $tab . '_sanitize', $input ); 
  29.  
  30. foreach( $settings as $id => $setting ) { 
  31.  
  32. // If the value wasn't passed in, set to false, which will delete the option 
  33. $value = isset( $input[ $id ] ) ? $input[ $id ] : false; 
  34. $previous_value = monsterinsights_get_option( $id, false ); 
  35.  
  36. // Sanitize/Validate 
  37. if ( empty( $setting['type'] ) ) { 
  38. continue; 
  39.  
  40. // Some setting types are not actually settings, just keep moving along here 
  41. $non_setting_types = monsterinsights_get_non_setting_types(); 
  42. $type = $setting['type']; 
  43.  
  44. if ( in_array( $type, $non_setting_types ) ) { 
  45. continue; 
  46.  
  47. $args = wp_parse_args( $setting, array( 
  48. 'id' => null,  
  49. 'desc' => '',  
  50. 'name' => '',  
  51. 'size' => null,  
  52. 'options' => '',  
  53. 'std' => '',  
  54. 'min' => null,  
  55. 'max' => null,  
  56. 'step' => null,  
  57. 'select2' => null,  
  58. 'placeholder' => null,  
  59. 'allow_blank' => true,  
  60. 'readonly' => false,  
  61. 'faux' => false,  
  62. 'tooltip_title' => false,  
  63. 'tooltip_desc' => false,  
  64. 'field_class' => '',  
  65. 'multiple' => false,  
  66. 'allowclear' => true,  
  67. 'notice_type' => 'info',  
  68. ) ); 
  69.  
  70. // Sanitize settings 
  71. $value = apply_filters( 'monsterinsights_settings_sanitize_' . $id , $value, $id, $args, $previous_value ); 
  72. $value = apply_filters( 'monsterinsights_settings_sanitize_' . $type, $value, $id, $args, $previous_value ); 
  73. $value = apply_filters( 'monsterinsights_settings_sanitize' , $value, $id, $args, $previous_value ); 
  74.  
  75. // Save 
  76. do_action( 'monsterinsights_settings_save_' . $args['type'], $value, $id, $args, $previous_value ); 
  77. if ( ! has_action( 'monsterinsights_settings_save_' . $args['type'] ) ) {