-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwp-discord-invite.php
More file actions
115 lines (94 loc) · 3.34 KB
/
wp-discord-invite.php
File metadata and controls
115 lines (94 loc) · 3.34 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/**
* Plugin Name: WP Discord Invite
* Plugin URI: https://plugins.sarveshmrao.in/wp-discord-invite
* Description: Create memorable Discord invite links (yoursite.com/discord) with tracking, webhooks, and social previews
* Version: 2.6.0
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: Sarvesh M Rao
* Author URI: https://www.sarveshmrao.in/
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: wp-discord-invite
* Domain Path: /languages
*/
/**
* This file is included with WP Discord Invite WordPress Plugin (https://wordpress.com/plugins/wp-discord-invite), Developed by Sarvesh M Rao (https://sarveshmrao.in/).
* This file is licensed under Generl Public License v2 (GPLv2) or later.
* Using the code on whole or in part against the license can lead to legal prosecution.
*
* Sarvesh M Rao
* https://sarveshmrao.in/
*/
if (!defined("ABSPATH")) {
exit();
}
// Plugin activation hook
register_activation_hook(__FILE__, 'smr_discord_activate');
/**
* Plugin activation callback
* Sets up default options on first activation
*
* @return void
*/
function smr_discord_activate() {
// Set default options if they don't exist
add_option('smr_discord_click_count', '0');
add_option('smr_discord_click_count_last_reset', 'Never');
add_option('smr_discord_link_last_click', 'Never');
add_option('smr_discord_uri', 'discord');
add_option('smr_discord_invite_link', '');
add_option('smr_discord_title', 'My Awesome Discord Server');
add_option('smr_discord_description', 'My server is awesome coz of these');
add_option('smr_discord_author', 'You have been invited to a server!');
add_option('smr_discord_image_url', plugin_dir_url(__FILE__) . 'assets/icon-128x128.png');
add_option('smr_discord_embed_color', '#5865f2');
add_option('smr_discord_webhook_enable', '0');
add_option('smr_discord_webhook_url', '');
// Flush rewrite rules
flush_rewrite_rules();
}
// Plugin deactivation hook
register_deactivation_hook(__FILE__, 'smr_discord_deactivate');
/**
* Plugin deactivation callback
* Cleans up rewrite rules
*
* @return void
*/
function smr_discord_deactivate() {
// Flush rewrite rules on deactivation
flush_rewrite_rules();
}
// Load plugin text domain for translations
add_action('plugins_loaded', 'smr_discord_load_textdomain');
/**
* Load plugin text domain for translations
*
* @return void
*/
function smr_discord_load_textdomain() {
load_plugin_textdomain('wp-discord-invite', false, dirname(plugin_basename(__FILE__)) . '/languages/');
}
// Configuring Plugin Row Meta
require_once('includes/pluginRowMeta.php');
// Catching URL defined in settings
require_once('includes/urlCatching.php');
// Inserting color picker for admin menu
require_once('includes/colorPicker.php');
// Registering Admin Menus
require_once('includes/registerMenu.php');
// Registering Settings
require_once('includes/settings.php');
// Settings Config Page
require_once('includes/settingsPage.php');
// Click Count Page
require_once('includes/countPage.php');
// OAuth Handler for Discord webhook integration
require_once('includes/oauthHandler.php');
// Help Page (To be removed in next major release)
// require_once('includes/helpPage.php');
// Important Functions
require_once('includes/utils.php');
?>