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
213
214
215
216
217
218
219
220
<?php
/**
* Copyright: 2022 (c)Franco (nextime) Lanza <franco@nexlab.it>
* License: GNU/GPL version 3.0
*
* This file is part of SexHackMe Wordpress Plugin.
*
* SexHackMe Wordpress Plugin is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* SexHackMe Wordpress Plugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SexHackMe Wordpress Plugin. If not, see <https://www.gnu.org/licenses/>.
*/
namespace wp_SexHackMe;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if(!class_exists('SH_Admin')) {
class SH_Admin
{
public static function init()
{
// Add general settings section
add_settings_section('sexhackme-settings', ' ', 'wp_SexHackMe\sexhackme_settings_section', 'sexhackme-settings');
// Add General settings section
if( file_exists(SH_PLUGIN_DIR_PATH . 'includes/admin/functions-sexhackme.php') )
{
include_once(SH_PLUGIN_DIR_PATH . 'includes/admin/functions-sexhackme.php');
register_setting('sexhackme-settings', 'sexhack-model-role');
}
// Add WC-PMS_Integration settings
if( file_exists(SH_PLUGIN_DIR_PATH . 'includes/admin/functions-wcpms.php') )
{
include_once SH_PLUGIN_DIR_PATH . 'includes/admin/functions-wcpms.php';
$plans = sh_get_subscription_plans();
add_settings_section('sexhackme-wcpms-settings', ' ', 'wp_SexHackMe\settings_wcpms_section', 'sexhackme-wcpms-settings');
register_setting('sexhackme-wcpms-settings', 'sexhack-wcpms-checkout');
foreach($plans as $plan)
{
if($plan->price > 0)
{
register_setting('sexhackme-wcpms-settings', 'sexhack-wcpms-'.strval($plan->id));
}
}
add_settings_section('sexhackme-wcpms-settings', ' ', 'wp_SexHackMe\settings_wcpms_section_email', 'sexhackme-wcpms-settings-email');
register_setting('sexhackme-wcpms-settings', 'sexhack_registration_mail_endpoint');
add_settings_section('sexhackme-wcpms-settings', ' ', 'wp_SexHackMe\settings_wcpms_section_prodcat', 'sexhackme-wcpms-settings-prodcat');
register_setting('sexhackme-wcpms-settings', 'sexhack_wcpms-prodcat');
register_setting('sexhackme-wcpms-settings', 'sexhack_wcpms-prodvisible');
register_setting('sexhackme-wcpms-settings', 'sexhack_wcpms_premium_discount');
}
// Add Advertising settings
if( file_exists(SH_PLUGIN_DIR_PATH . 'includes/admin/functions-advert.php') )
{
include_once SH_PLUGIN_DIR_PATH . 'includes/admin/functions-advert.php';
add_settings_section('sexhackme-advert-settings', ' ', 'wp_SexHackMe\settings_advert_section', 'sexhackme-advert-settings');
register_setting('sexhackme-advert-settings', 'sexadv_video_top');
register_setting('sexhackme-advert-settings', 'sexadv_video_bot');
register_setting('sexhackme-advert-settings', 'sexadv_video_native');
}
// Gallery settings
if( file_exists(SH_PLUGIN_DIR_PATH . 'includes/admin/functions-gallery.php') )
{
include_once SH_PLUGIN_DIR_PATH . 'includes/admin/functions-gallery.php';
add_settings_section('sexhackme-gallery-settings', ' ','wp_SexHackMe\gallery_settings_section', 'sexhackme-gallery-settings');
register_setting('sexhackme-gallery-settings', 'sexhack_video_page');
register_setting('sexhackme-gallery-settings', 'sexhack_gallery_page');
register_setting('sexhackme-gallery-settings', 'sexhack_video404_page');
register_setting('sexhackme-gallery-settings', 'sexhack_shmdown');
register_setting('sexhackme-gallery-settings', 'sexhack_shmdown_uri');
register_setting('sexhackme-gallery-settings', 'sexhack_video_tmp_path');
register_setting('sexhackme-gallery-settings', 'sexhack_video_flat_path');
register_setting('sexhackme-gallery-settings', 'sexhack_video_vr_path');
register_setting('sexhackme-gallery-settings', 'sexhack_video_hls_storage');
register_setting('sexhackme-gallery-settings', 'sexhack_video_hls_uri');
register_setting('sexhackme-gallery-settings', 'sexhack_video_video_storage');
register_setting('sexhackme-gallery-settings', 'sexhack_video_video_uri');
register_setting('sexhackme-gallery-settings', 'sexhack_video_photo_storage');
register_setting('sexhackme-gallery-settings', 'sexhack_video_photo_uri');
register_setting('sexhackme-gallery-settings', 'sexhack_video_gif_storage');
register_setting('sexhackme-gallery-settings', 'sexhack_video_gif_uri');
register_setting('sexhackme-gallery-settings', 'sexhack_video_vr_storage');
register_setting('sexhackme-gallery-settings', 'sexhack_video_vr_uri');
register_setting('sexhackme-gallery-settings', 'sexhack_thumbnail_storage');
register_setting('sexhackme-gallery-settings', 'sexhack_thumbnail_uri');
register_setting('sexhackme-gallery-settings', 'sexhack_socialpost_storage');
add_action('update_option', '\wp_SexHackMe\SH_Admin::update_gallery_slug', 10, 3);
//register_setting('sexhackme-gallery-settings', 'sexhack_gallery_slug');
}
// RClone settings
if( file_exists(SH_PLUGIN_DIR_PATH . 'includes/admin/functions-rclone.php') )
{
include_once SH_PLUGIN_DIR_PATH . 'includes/admin/functions-rclone.php';
add_settings_section('sexhackme-rclone-settings', ' ','wp_SexHackMe\rclone_settings_section', 'sexhackme-rclone-settings');
register_setting('sexhackme-rclone-settings', 'sexhack_rclone_path');
register_setting('sexhackme-rclone-settings', 'sexhack_rclone_gdrive_name');
register_setting('sexhackme-rclone-settings', 'sexhack_rclone_gdrive_shared');
}
}
public static function update_gallery_slug($option, $old, $new)
{
switch($option)
{
case 'sexhack_video_page':
if(!is_int($new)) break;
$page = get_post($new);
set_option('sexhack_gallery_slug', $page->post_name);
update_option('need_rewrite_flush', 1);
break;
case 'sexhack_gallery_page':
update_option('need_rewrite_flush', 1);
break;
case 'sexhack_video404_page':
update_option('need_rewrite_flush', 1);
break;
default:
break;
}
}
public static function menu()
{
add_menu_page('SexHackMe Settings', 'SexHackMe', 'manage_options', 'sexhackme-settings',
'wp_SexHackMe\sexhackme_admin_page', SH_PLUGIN_DIR_URL .'img/admin_icon.png', 31);
// Add The main page again cause with multiple subpages apparently we need to do it.
add_submenu_page( 'sexhackme-settings', 'SexHackMe Settings', 'General Settings',
'manage_options', 'sexhackme-settings');
// TODO We don't have a main page yet, so, remove it.
//remove_submenu_page( 'sexhackme-settings', 'sexhackme-settings' );
// Add Gallery settings page
if( file_exists(SH_PLUGIN_DIR_PATH . 'includes/admin/functions-gallery.php') )
{
add_submenu_page( 'sexhackme-settings', // root slug
'Gallery', // title
'Gallery', // title
'manage_options', // capabilities
'gallery', // slug
'wp_SexHackMe\gallery_adminpage', // callback
20);
}
// Add RClone interface
if (file_exists(SH_PLUGIN_DIR_PATH . 'includes/admin/functions-rclone.php') )
{
add_submenu_page( 'sexhackme-settings',
'RClone',
'RClone',
'manage_options',
'rclone',
'wp_SexHackMe\rclone_adminpage',
50);
}
// Add page WC-PMS_Integration
if( file_exists(SH_PLUGIN_DIR_PATH . 'includes/admin/functions-wcpms.php') )
{
add_submenu_page( 'sexhackme-settings', // root slug
'WC-PMS Integration', // title
'WC-PMS Integration', // title
'manage_options', // capabilities
'pmswc-integration', // slug
'wp_SexHackMe\wcpms_adminpage', // callback
60); // position
}
// Add Advertising settings
if( file_exists(SH_PLUGIN_DIR_PATH . 'includes/admin/functions-advert.php') )
{
add_submenu_page( 'sexhackme-settings', // root slug
'Advertising', // title
'Advertising', // title
'manage_options', // capabilities
'advert', // slug
'wp_SexHackMe\advert_adminpage', // callback
80);
}
// Add Video tags and categories subpages to Video edit menu
//if(in_array('sexhack_video', get_post_types())
//{
//}
}
}
}
?>