PluginProbe
Webling / 3.2.0
Webling v3.2.0
trunk 2.0 3.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.3.0 3.4.0 3.4.1 3.5.0 3.6.0 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.9.0 3.9.1 3.9.2
webling / src / admin / pages / settings.php

settings.php in Webling 3.2.0, at src/admin/pages/settings.php

113 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class webling_page_settings {
4
5 public static function html () {
6
7 add_settings_section(
8 'webling_page_settings_section',
9 __( 'Webling Plugin Einstellungen', 'webling' ),
10 ['webling_page_settings','section_callback'],
11 'webling-options-group'
12 );
13
14 add_settings_field(
15 'webling_field_host',
16 __( 'Webling-URL', 'webling' ),
17 ['webling_page_settings','host_render'],
18 'webling-options-group',
19 'webling_page_settings_section'
20 );
21
22 add_settings_field(
23 'webling_field_apikey',
24 __( 'API Key', 'webling' ),
25 ['webling_page_settings','apikey_render'],
26 'webling-options-group',
27 'webling_page_settings_section'
28 );
29
30 add_settings_field(
31 'webling_field_css',
32 __( 'Eigenes CSS', 'webling' ),
33 ['webling_page_settings','css_render'],
34 'webling-options-group',
35 'webling_page_settings_section'
36 );
37
38 // display form
39 echo '<div class="wrap"><form method="post" action="options.php" id="webling-form">';
40 settings_fields('webling-options-group');
41 do_settings_sections('webling-options-group');
42 submit_button();
43 self::print_versions();
44 echo '</form></div>';
45 }
46
47 public static function host_render() {
48
49 $options = get_option('webling-options');
50 echo '<input type="text" name="webling-options[host]" value="'.$options['host'].'" style="width: 400px;">';
51 echo '<p class="description">'.__('Die Adresse deines Weblings (z.B. demo1.webling.ch)', 'webling').'</p>';
52 }
53
54
55 public static function apikey_render() {
56 $options = get_option('webling-options');
57 echo '<input type="text" name="webling-options[apikey]" value="'.$options['apikey'].'" style="width: 400px;">';
58 echo '<p class="description">'.__('Einen API-Key kannst du dir in deinem Webling unter "Administration" &raquo; "API" erstellen.', 'webling').'</p>';
59 }
60
61
62 public static function css_render() {
63 $options = get_option('webling-options');
64 echo '<textarea rows="5" cols="60" name="webling-options[css]">'.$options['css'].'</textarea>';
65 echo '<p class="description">'.__('Eigenes CSS für Designanpassungen.', 'webling').'</p>';
66 }
67
68
69 public static function section_callback() {
70 echo __( 'Mit diesem Plugin kannst du Mitgliederdaten aus deiner <a href="https://www.webling.eu" target="_blank">Webling Vereinsverwaltung</a> auf einer Seite anzeigen lassen oder via Anmeldeformular automatisch erfassen.', 'webling' );
71 echo '<br>';
72 echo __( 'Es wird mindestens ein "Webling Plus" Abo benötigt, damit dieses Plugin verwendet werden kann.', 'webling' );
73 echo '<br><br>';
74 echo '<b>'.__( 'Verbindungsstatus: ', 'webling' ) . '</b> '. self::connection_status();
75 }
76
77 public static function print_versions() {
78 global $wpdb, $wp_version;
79 echo '<div style="font-size: 90%; color: rgba(0,0,0,0.5);">';
80 $plugin = get_plugin_data(WEBLING_PLUGIN_DIR . '/webling.php', false);
81 echo 'Versionsinfo: PHP ' . phpversion() . '; MySQL ' . $wpdb->db_version() . '; WordPress ' . $wp_version . '; Webling Plugin ' . $plugin['Version']. '; Webling DB v' . WEBLING_DB_VERSION . ';';
82 echo '</div>';
83 }
84
85 public static function connection_status() {
86 $options = get_option('webling-options');
87
88 if (!$options['host'] || !$options['apikey']) {
89 return '<span style="color: grey;">Keine Zugangsdaten. Bitte Webling-URL und API Key angeben.</span>';
90 }
91 try {
92 $connection = new \Webling\API\Client($options['host'], $options['apikey']);
93 $response = $connection->get('config');
94 if ($response->getStatusCode() == '200') {
95 return '<span style="color: #79c700;">Verbindung OK</span>';
96 } else {
97 if ($response->getStatusCode() == '401') {
98 return '<span style="color: red;">Ungültige Zugangsdaten.</span>';
99 } else {
100 $data = $response->getData();
101 $error = '';
102 if (isset($data['error'])) {
103 $error = ' - ' . $data['error'];
104 }
105 return '<span style="color: red;">Verbindungsfehler: '.$response->getStatusCode().' '.$error.'</span>';
106 }
107 }
108 } catch (\Webling\API\ClientException $exception) {
109 return '<span style="color: red;">Verbindungsfehler: '.$exception->getMessage().'</span>';
110 }
111 }
112 }
113