/**
  * Return settings fields
  *
  * @return array
  */
 public function get_fields()
 {
     $fields = array('general' => array('title' => esc_html__('General', 'stream'), 'fields' => array(array('name' => 'role_access', 'title' => esc_html__('Role Access', 'stream'), 'type' => 'multi_checkbox', 'desc' => esc_html__('Users from the selected roles above will have permission to view Stream Records. However, only site Administrators can access Stream Settings.', 'stream'), 'choices' => $this->get_roles(), 'default' => array('administrator')), array('name' => 'records_ttl', 'title' => esc_html__('Keep Records for', 'stream'), 'type' => 'number', 'class' => 'small-text', 'desc' => esc_html__('Maximum number of days to keep activity records.', 'stream'), 'default' => 30, 'min' => 1, 'max' => 999, 'step' => 1, 'after_field' => esc_html__('days', 'stream')), array('name' => 'keep_records_indefinitely', 'title' => esc_html__('Keep Records Indefinitely', 'stream'), 'type' => 'checkbox', 'desc' => sprintf('<strong>%s</strong> %s', esc_html__('Not recommended.', 'stream'), esc_html__('Purging old records helps to keep your WordPress installation running optimally.', 'stream')), 'after_field' => esc_html__('Enabled', 'stream'), 'default' => 0))), 'exclude' => array('title' => esc_html__('Exclude', 'stream'), 'fields' => array(array('name' => 'rules', 'title' => esc_html__('Exclude Rules', 'stream'), 'type' => 'rule_list', 'desc' => esc_html__('Create rules to exclude certain kinds of activity from being recorded by Stream.', 'stream'), 'default' => array(), 'nonce' => 'stream_get_ips'))), 'advanced' => array('title' => esc_html__('Advanced', 'stream'), 'fields' => array(array('name' => 'comment_flood_tracking', 'title' => esc_html__('Comment Flood Tracking', 'stream'), 'type' => 'checkbox', 'desc' => esc_html__('WordPress will automatically prevent duplicate comments from flooding the database. By default, Stream does not track these attempts unless you opt-in here. Enabling this is not necessary or recommended for most sites.', 'stream'), 'after_field' => esc_html__('Enabled', 'stream'), 'default' => 0), array('name' => 'delete_all_records', 'title' => esc_html__('Reset Stream Database', 'stream'), 'type' => 'link', 'href' => add_query_arg(array('action' => 'wp_stream_reset', 'wp_stream_nonce' => wp_create_nonce('stream_nonce')), admin_url('admin-ajax.php')), 'class' => 'warning', 'desc' => esc_html__('Warning: This will delete all activity records from the database.', 'stream'), 'default' => 0, 'sticky' => 'bottom'))));
     // If Akismet is active, allow Admins to opt-in to Akismet tracking
     if (class_exists('Akismet')) {
         $akismet_tracking = array('name' => 'akismet_tracking', 'title' => esc_html__('Akismet Tracking', 'stream'), 'type' => 'checkbox', 'desc' => esc_html__('Akismet already keeps statistics for comment attempts that it blocks as SPAM. By default, Stream does not track these attempts unless you opt-in here. Enabling this is not necessary or recommended for most sites.', 'stream'), 'after_field' => esc_html__('Enabled', 'stream'), 'default' => 0);
         array_push($fields['advanced']['fields'], $akismet_tracking);
     }
     // If WP Cron is enabled, allow Admins to opt-in to WP Cron tracking
     if (wp_stream_is_cron_enabled()) {
         $wp_cron_tracking = array('name' => 'wp_cron_tracking', 'title' => esc_html__('WP Cron Tracking', 'stream'), 'type' => 'checkbox', 'desc' => esc_html__('By default, Stream does not track activity performed by WordPress cron events unless you opt-in here. Enabling this is not necessary or recommended for most sites.', 'stream'), 'after_field' => esc_html__('Enabled', 'stream'), 'default' => 0);
         array_push($fields['advanced']['fields'], $wp_cron_tracking);
     }
     /**
      * Filter allows for modification of options fields
      *
      * @return array  Array of option fields
      */
     $this->fields = apply_filters('wp_stream_settings_option_fields', $fields);
     // Sort option fields in each tab by title ASC
     foreach ($this->fields as $tab => $options) {
         $titles = array();
         foreach ($options['fields'] as $field) {
             $prefix = null;
             if (!empty($field['sticky'])) {
                 $prefix = 'bottom' === $field['sticky'] ? 'ZZZ' : 'AAA';
             }
             $titles[] = $prefix . $field['title'];
         }
         array_multisort($titles, SORT_ASC, $this->fields[$tab]['fields']);
     }
     return $this->fields;
 }
Exemple #2
0
 /**
  * True if doing WP Cron, otherwise false
  *
  * Note: If native WP Cron has been disabled and you are
  * hitting the cron endpoint with a system cron job, this
  * method will always return false.
  *
  * @return bool
  */
 function is_doing_wp_cron()
 {
     return wp_stream_is_cron_enabled() && defined('DOING_CRON') && DOING_CRON;
 }