PluginProbe
Webling / 3.0.3
Webling v3.0.3
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.0.3, at src/admin/pages/settings.php

104 lines 3.5 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 echo '</form></div>';
44 }
45
46 public static function host_render() {
47
48 $options = get_option('webling-options');
49 echo '<input type="text" name="webling-options[host]" value="'.$options['host'].'" style="width: 400px;">';
50 echo '<p class="description">'.__('Die Adresse deines Weblings (z.B. demo1.webling.ch)', 'webling').'</p>';
51 }
52
53
54 public static function apikey_render() {
55 $options = get_option('webling-options');
56 echo '<input type="text" name="webling-options[apikey]" value="'.$options['apikey'].'" style="width: 400px;">';
57 echo '<p class="description">'.__('Einen API-Key kannst du dir in deinem Webling unter "Administration" &raquo; "API" erstellen.', 'webling').'</p>';
58 }
59
60
61 public static function css_render() {
62 $options = get_option('webling-options');
63 echo '<textarea rows="5" cols="60" name="webling-options[css]">'.$options['css'].'</textarea>';
64 echo '<p class="description">'.__('Eigenes CSS für Designanpassungen.', 'webling').'</p>';
65 }
66
67
68 public static function section_callback() {
69 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' );
70 echo '<br>';
71 echo __( 'Es wird mindestens ein "Webling Plus" Abo benötigt, damit dieses Plugin verwendet werden kann.', 'webling' );
72 echo '<br><br>';
73 echo '<b>'.__( 'Verbindungsstatus: ', 'webling' ) . '</b> '. self::connection_status();
74 }
75
76 public static function connection_status() {
77 $options = get_option('webling-options');
78
79 if (!$options['host'] || !$options['apikey']) {
80 return '<span style="color: grey;">Keine Zugangsdaten. Bitte Webling-URL und API Key angeben.</span>';
81 }
82 try {
83 $connection = new \Webling\API\Client($options['host'], $options['apikey']);
84 $response = $connection->get('config');
85 if ($response->getStatusCode() == '200') {
86 return '<span style="color: #79c700;">Verbindung OK</span>';
87 } else {
88 if ($response->getStatusCode() == '401') {
89 return '<span style="color: red;">Ungültige Zugangsdaten.</span>';
90 } else {
91 $data = $response->getData();
92 $error = '';
93 if (isset($data['error'])) {
94 $error = ' - ' . $data['error'];
95 }
96 return '<span style="color: red;">Verbindungsfehler: '.$response->getStatusCode().' '.$error.'</span>';
97 }
98 }
99 } catch (\Webling\API\ClientException $exception) {
100 return '<span style="color: red;">Verbindungsfehler: '.$exception->getMessage().'</span>';
101 }
102 }
103 }
104