-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwordpress-copyright-protector.php
213 lines (132 loc) · 4.02 KB
/
wordpress-copyright-protector.php
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<?php
/**
* @package wordpress-copyright-protector
* @version 0.1
*/
/*
Plugin Name: Wordpress Copyright Protector
Plugin URI: http://www.example.com
Description: Copyright Copy and Paste Protector
Author: Mike Roberto
Version: 0.1
Author URI: http://www.example.com
Text Domain: wordpress-copyright-protector
*/
define('WPCP_PLUGIN_NAME', plugin_basename(__FILE__));
define('WPCP_PLUGIN_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
define('WPCP_PLUGIN_VERSION','0.1');
require_once 'classes/settings.php';
if (!class_exists('Wp_Copyright_Protector')) {
class Wp_Copyright_Protector{
/**
* @var Wp_Copyright_Protector
*/
static private $_instance = null;
private $_contactmixcore;
/**
* Get Wp_Copyright_Protector object
*
* @return Wp_Copyright_Protector
*/
static public function getInstance()
{
if (self::$_instance == null) {
self::$_instance = new Wp_Copyright_Protector();
}
return self::$_instance;
}
private function __construct()
{
register_activation_hook(WPCP_PLUGIN_NAME, array(&$this, 'pluginActivate'));
register_deactivation_hook(WPCP_PLUGIN_NAME, array(&$this, 'pluginDeactivate'));
register_uninstall_hook(WPCP_PLUGIN_NAME, array('contactmix', 'pluginUninstall'));
## Register plugin widgets
add_action('init', array($this, 'load_transl'));
add_action('plugins_loaded', array(&$this, 'pluginLoad'));
add_action( 'widgets_init', array(&$this, 'widgetsRegistration') );
if (is_admin()) {
add_action('wp_print_scripts', array(&$this, 'adminLoadScripts'));
add_action('wp_print_styles', array(&$this, 'adminLoadStyles'));
}
else{
add_action('wp_print_scripts', array(&$this, 'siteLoadScripts'));
add_action('wp_print_styles', array(&$this, 'siteLoadStyles'));
}
add_action( 'wp_footer',array(&$this, 'footerScript'));
}
public function load_transl()
{
load_plugin_textdomain('wordpress-copyright-protector', FALSE, dirname(plugin_basename(__FILE__)).'/languages/');
}
##
## Loading Scripts and Styles
##
public function adminLoadStyles()
{
}
public function adminLoadScripts(){
}
public function siteLoadStyles(){
}
public function siteLoadScripts(){
$wpcp_general_settings = get_option('wpcp_general_settings');
$wpcp_text_before_url = (!empty($wpcp_general_settings['wpcp_text_before_url'])?$wpcp_general_settings['wpcp_text_before_url']:'');
$wpcp_disable_admin = (!empty($wpcp_general_settings['wpcp_disable_admin'])?$wpcp_general_settings['wpcp_disable_admin']:'');
$enable_script = true;
if ( is_super_admin() && $wpcp_disable_admin == "on" ) {
$enable_script = false;
}
if($enable_script){
wp_enqueue_script( 'jquery' );
wp_enqueue_script(
'wpcp-script',
plugins_url('js/wpcp-script.js', __FILE__),
array('jquery')
);
$wpcp_config = array('wpcp_text_before_url'=>$wpcp_text_before_url,'enable_script'=>$enable_script);
wp_localize_script( 'wpcp-script', 'wpcp_config',$wpcp_config );
}
}
##
## Widgets initializations
##
public function widgetsRegistration(){
}
##
## Plugin Activation and Deactivation
##
/**
* Activate plugin
* @return void
*/
public function pluginActivate()
{
$settings_general = get_option('wpcp_general_settings');
if(empty($settings_general['wpcp_text_before_url'])){
$settings_general['wpcp_text_before_url'] = 'Read more at: ';
}
update_option('wpcp_general_settings', $settings_general);
}
/**
* Deactivate plugin
* @return void
*/
public function pluginDeactivate(){
}
/**
* Uninstall plugin
* @return void
*/
static public function pluginUninstall()
{
}
public function pluginLoad(){
}
public function footerScript(){
}
}
}
//instantiate the class
if (class_exists('Wp_Copyright_Protector')) {
$Wp_Copyright_Protector = Wp_Copyright_Protector::getInstance();
}