-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrybbit-wp.php
More file actions
62 lines (52 loc) · 1.8 KB
/
rybbit-wp.php
File metadata and controls
62 lines (52 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Plugin Name: Rybbit WP
* Plugin URI: https://wolfdevs.com/products/rybbit-wp
* Description: Quick setup for integrating Rybbit analytics into your WordPress site.
* Version: 0.0.1
* Author: WolfDevs
* Author URI: https://wolfdevs.com
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: rybbit-wp
* Domain Path: /languages
* Requires at least: 5.8
* Requires PHP: 7.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'RYBBIT_WP_VERSION', '0.0.1' );
define( 'RYBBIT_WP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'RYBBIT_WP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'RYBBIT_WP_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
require_once RYBBIT_WP_PLUGIN_DIR . 'includes/class-rybbit-wp.php';
/**
* Plugin activation hook.
*/
function rybbit_wp_activate() {
$config_file = RYBBIT_WP_PLUGIN_DIR . 'rybbit-config.json';
if ( file_exists( $config_file ) ) {
$config = json_decode( file_get_contents( $config_file ), true );
if ( $config && ! empty( $config['site_id'] ) ) {
$settings = array(
'site_id' => sanitize_text_field( $config['site_id'] ),
'host_url' => isset( $config['host_url'] ) ? esc_url_raw( $config['host_url'] ) : 'https://app.rybbit.io',
'ignore_logged_in' => true,
'track_query_params' => true,
'enable_spa_mode' => false,
);
update_option( 'rybbit_wp_settings', $settings );
}
// Remove config file after applying
@unlink( $config_file );
}
}
register_activation_hook( __FILE__, 'rybbit_wp_activate' );
/**
* Initialize the plugin.
*/
function rybbit_wp_init() {
return Rybbit_WP::get_instance();
}
rybbit_wp_init();