PluginProbe
Simple Analytics / 1.15
Simple Analytics v1.15
1.109 1.108 1.107 1.106 1.73 1.74 1.75 1.76 1.77 1.78 1.79 1.8 1.80 1.81 1.82 1.83 1.84 1.85 1.86 1.87 1.88 1.89 1.9 1.90 1.91 All 98 releases
simpleanalytics / includes / admin.php

admin.php in Simple Analytics 1.15, at includes/admin.php

78 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 function simpleanalytics_warn_not_logging() {
8 echo "<!-- Simple Analytics: Not logging requests from admins -->\n";
9 }
10
11 function simpleanalytics_add_settings_page() {
12 add_options_page(
13 __( 'Simple Analytics Settings', 'simple-analytics' ),
14 __( 'Simple Analytics', 'simple-analytics' ),
15 'manage_options',
16 'simple-analytics-settings',
17 'simpleanalytics_render_settings_page'
18 );
19 }
20
21 function simpleanalytics_render_settings_page() {
22 if ( ! current_user_can( 'manage_options' ) ) {
23 return;
24 }
25
26 if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
27 if ( ! isset( $_POST['simpleanalytics_settings_nonce'] ) ) {
28 return;
29 }
30
31 if ( ! wp_verify_nonce( $_POST['simpleanalytics_settings_nonce'], 'simpleanalytics_settings' ) ) {
32 return;
33 }
34
35 if ( ! isset( $_POST['simpleanalytics_custom_domain'] ) ) {
36 return;
37 }
38
39 $custom_domain = sanitize_text_field( $_POST['simpleanalytics_custom_domain'] );
40 $custom_domain = preg_replace( '/^https?:\/\//', '', $custom_domain );
41
42 update_option( 'simpleanalytics_custom_domain', $custom_domain );
43 }
44
45 $custom_domain = get_option( 'simpleanalytics_custom_domain' );
46 ?>
47 <div class="wrap">
48 <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
49 <form method="post"
50 action="<?php echo esc_url( admin_url( 'options-general.php?page=simple-analytics-settings' ) ); ?>">
51 <?php wp_nonce_field( 'simpleanalytics_settings', 'simpleanalytics_settings_nonce' ); ?>
52 <table class="form-table">
53 <tbody>
54 <tr>
55 <th scope="row">
56 <label for="simpleanalytics_custom_domain"><?php esc_html_e( 'Custom subdomain', 'simple-analytics' ); ?></label>
57 </th>
58 <td>
59 <input type="text" name="simpleanalytics_custom_domain" id="simpleanalytics_custom_domain"
60 value="<?php echo esc_attr( $custom_domain ); ?>" class="regular-text">
61 <p class="description">
62 <?php esc_html_e( 'E.g. api.example.com. Leave empty to use the default domain (most users).', 'simple-analytics' ); ?>
63 <a href="https://docs.simpleanalytics.com/bypass-ad-blockers"><?php esc_html_e( 'Learn more.', 'simple-analytics' ); ?></a>
64 </p>
65 </td>
66 </tr>
67 </tbody>
68 </table>
69 <?php submit_button( __( 'Save Changes', 'simple-analytics' ) ); ?>
70 </form>
71 </div>
72 <?php
73 }
74
75 add_action( 'admin_menu', 'simpleanalytics_add_settings_page' );
76 wp_enqueue_script( 'simpleanalytics_admins', plugins_url( 'public/js/admins.js', dirname( __FILE__ ) ), array(), null, true );
77 add_action( 'wp_footer', 'simpleanalytics_warn_not_logging', 10 );
78