class-admin.php 5.72 KB
Newer Older
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
<?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()
      {
34
         // Add general settings section     
35 36
         add_settings_section('sexhackme-settings', ' ', 'wp_SexHackMe\sexhackme_settings_section', 'sexhackme-settings');

37
         // Add WC-PMS_Integration settings
38 39
         if( file_exists(SH_PLUGIN_DIR_PATH . 'includes/admin/functions-wcpms.php') )
         {
40 41 42 43 44 45 46 47 48 49
            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));
               }
50 51 52
            }
            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');
53
         }
54 55 56 57 58

         // 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';
59
            add_settings_section('sexhackme-advert-settings', ' ', 'wp_SexHackMe\settings_advert_section', 'sexhackme-advert-settings');
60
            register_setting('sexhackme-advert-settings', 'sexadv_video_top');
61
            register_setting('sexhackme-advert-settings', 'sexadv_video_bot');
62
         }
63 64 65 66 67

         // 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';
68
             add_settings_section('sexhackme-gallery-settings', ' ','wp_SexHackMe\gallery_settings_section', 'sexhackme-gallery-settings');
69 70
             register_setting('sexhackme-gallery-settings', 'sexhack_gallery_slug');
         }
71 72 73 74
      }

      public static function menu()
      {
75

76 77
         add_menu_page('SexHackMe Settings', 'SexHackMe', 'manage_options', 'sexhackme-settings',
               'wp_SexHackMe\sexhackme_admin_page', SH_PLUGIN_DIR_URL .'img/admin_icon.png', 31);
78

79
         // Add The main page again cause with multiple subpages apparently we need to do it.
80
          add_submenu_page( 'sexhackme-settings', 'SexHackMe Settings', 'General Settings',
81 82
                  'manage_options', 'sexhackme-settings');

83 84 85
         // TODO We don't have a main page yet, so, remove it.
         remove_submenu_page( 'sexhackme-settings', 'sexhackme-settings' );

86 87 88 89 90 91 92 93 94 95 96
         // 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
         }
97 98

         // Add Advertising settings
99 100
         if( file_exists(SH_PLUGIN_DIR_PATH . 'includes/admin/functions-advert.php') )
         {
101 102 103 104 105 106 107
               add_submenu_page( 'sexhackme-settings',            // root slug
                           'Advertising',                         // title
                           'Advertising',                         // title
                           'manage_options',                      // capabilities
                           'advert',                              // slug
                           'wp_SexHackMe\advert_adminpage');      // callback

108
         }
109 110


111 112 113 114 115 116 117 118 119 120 121
         // 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

         }
122

123 124 125 126
         // Add Video tags and categories subpages to Video edit menu
         //if(in_array('sexhack_video', get_post_types())
         //{
         //}
127 128 129 130 131 132 133
      }

   }
}


?>