pluginSlug; $callback = [$this, 'pluginSettingsPageContent']; add_options_page($page_title, $menu_title, $capability, $slug, $callback); } public function pluginSettingsPageContent() { ?>

Adeptus Settings

adminNoticeSuccess(); } if (defined('WP_ADEPTUS_LOGGING_DISABLED') && WP_ADEPTUS_LOGGING_DISABLED == true) { $this->adminNoticeDisabled(); } ?>
pluginSlug); do_settings_sections($this->pluginSlug); submit_button(); ?>

Logging has been disabled globally by the `WP_ADEPTUS_LOGGING_DISABLED` constant.

Your settings have been updated!

pluginSlug); add_settings_section('syslog_section', 'Syslog', [$this, 'sectionCallback'], $this->pluginSlug); add_settings_section('errorlog_section', 'PHP Error Log', [$this, 'sectionCallback'], $this->pluginSlug); add_settings_section('logstash_section', 'Logstash', [$this, 'sectionCallback'], $this->pluginSlug); } public function sectionCallback($arguments) { // Display content above section form return; } public function shellCurlAvailable() { if (!function_exists('exec')) { return false; } if (strncasecmp(PHP_OS, 'WIN', 3) == 0) { return false; } @exec('curl -V', $output, $exit); return $exit == 0; } public function setupFields() { $fields = [ [ 'uid' => 'adeptus_debuglog_enabled', 'label' => 'Enabled', 'section' => 'debuglog_section', 'type' => 'select', 'datatype' => 'boolean', 'options' => [ 'yes' => 'Yes', 'no' => 'No', ], 'default' => ['no'], ], [ 'uid' => 'adeptus_syslog_enabled', 'label' => 'Enabled', 'section' => 'syslog_section', 'type' => 'select', 'datatype' => 'boolean', 'options' => [ 'yes' => 'Yes', 'no' => 'No', ], 'default' => ['no'], ], [ 'uid' => 'adeptus_errorlog_enabled', 'label' => 'Enabled', 'section' => 'errorlog_section', 'type' => 'select', 'datatype' => 'boolean', 'options' => [ 'yes' => 'Yes', 'no' => 'No', ], 'default' => ['no'], ], [ 'uid' => 'adeptus_logstash_enabled', 'label' => 'Enabled', 'section' => 'logstash_section', 'type' => 'select', 'datatype' => 'boolean', 'options' => [ 'yes' => 'Yes', 'no' => 'No', ], 'default' => ['no'], ], [ 'uid' => 'adeptus_logstash_url', 'label' => 'Server URL', 'section' => 'logstash_section', 'type' => 'text', 'placeholder' => 'https://logstashserver:8081', 'supplimental' => 'For HTTP basic auth use the following format "https://usr:pass@logstashserver:8081".' ], [ 'uid' => 'adeptus_logstash_endpoint', 'label' => 'Endpoint', 'section' => 'logstash_section', 'type' => 'text', 'placeholder' => '/events/event/1', ], [ 'uid' => 'adeptus_logstash_method', 'label' => 'Method', 'section' => 'logstash_section', 'type' => 'select', 'options' => [ 'php' => 'PHP Curl' . (function_exists('curl_init') ? '' : ' (Not available)'), 'shell' => 'Shell Fork Curl' . ($this->shellCurlAvailable() ? '' : ' (Not available)'), ], 'default' => ['php'], 'supplimental' => 'The shell method is faster, but requires the curl command to be executable by the web server process.', ], ]; foreach ($fields as $field) { add_settings_field($field['uid'], $field['label'], [$this, 'fieldCallback'], $this->pluginSlug, $field['section'], $field); register_setting($this->pluginSlug, $field['uid'], [ 'type' => !empty($field['datatype']) ? $field['datatype'] : 'string', ]); } } public function fieldCallback($arguments) { $value = get_option($arguments['uid']); if (!$value) { $value = isset($arguments['default']) ? $arguments['default'] : ''; } switch ($arguments['type']) { case 'text': case 'password': case 'number': printf('', $arguments['uid'], $arguments['type'], $arguments['placeholder'] ?? '', $value); break; case 'textarea': printf('', $arguments['uid'], $arguments['placeholder'], $value); break; case 'select': case 'multiselect': if (!empty($arguments['options']) && is_array($arguments['options'])) { $value = is_array($value) ? $value : [$value]; $attributes = ''; $options_markup = ''; foreach ($arguments['options'] as $key => $label) { $options_markup .= sprintf('', $key, selected($value[array_search($key, $value, true)], $key, false), $label); } if ($arguments['type'] === 'multiselect') { $attributes = ' multiple="multiple" '; } printf('', $arguments['uid'], $attributes, $options_markup); } break; case 'radio': case 'checkbox': if (!empty($arguments['options']) && is_array($arguments['options'])) { $options_markup = ''; $iterator = 0; foreach ($arguments['options'] as $key => $label) { $iterator++; $options_markup .= sprintf('
', $arguments['uid'], $arguments['type'], $key, checked($value[array_search($key, $value, true)], $key, false), $label, $iterator); } printf('
%s
', $options_markup); } break; } if (!empty($arguments['helper'])) { printf(' %s', $arguments['helper']); } if (!empty($arguments['supplimental'])) { printf('

%s

', $arguments['supplimental']); } } }