creating admin structure, classes for widgets, post types and more

parent cc2f9052
<?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;
function advert_adminpage()
{
sh_get_template('admin/advert.php');
}
function settings_advert_section()
{
echo "<h2>SexHackMe Advertising Settings</h2>";
}
?>
<?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;
function sexhackme_settings_section() {
echo "<h3></h3>";
}
?>
<?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;
function wcpms_adminpage()
{
sh_get_template('admin/wcpms.php');
}
function settings_wcpms_section()
{
echo "<h2>SexHackMe PMS - WooCommerce integration Settings</h2>";
}
function settings_wcpms_section_email()
{
echo "<h2>WooCommerce Checkout Email endpoint</h2>";
}
?>
<?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_settings_section('sexhackme-settings', ' ', 'wp_SexHackMe\sexhackme_settings_section', 'sexhackme-settings');
// 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 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');
}
}
public static function menu()
{
//add_menu_page('SexHackMe Settings', 'SexHackMe', 'manage_options', 'sexhackme-settings',
// array($this, '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', 'Modules',
'manage_options', 'sexhackme-settings');
// 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
}
// 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
}
}
}
}
?>
<?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_PostTypes')) {
class SH_PostTypes
{
public static function init()
{
// Advertising
register_post_type('sexhackadv', array(
'label' => 'Advertising','description' => '',
'public' => true,
'show_ui' => true,
'show_in_menu' => true, // Visibility in admin menu.
'menu_position' => 32,
'capability_type' => 'post',
'hierarchical' => false,
'publicly_queryable' => true,
'rewrite' => false,
'query_var' => true,
'has_archive' => true,
'supports' => array('title','editor','page-attributes', 'shortcode'),
'taxonomies' => array(),
// there are a lot more available arguments, but the above is plenty for now
));
add_filter( 'manage_sexhackadv_posts_columns', 'wp_SexHackMe\advert_add_id_column', 5 );
add_action( 'manage_sexhackadv_posts_custom_column', 'wp_SexHackMe\advert_id_column_content', 5, 2 );
}
}
}
?>
......@@ -38,6 +38,7 @@ if(!class_exists('SH_Shortcodes')) {
'sh_videohls' => __CLASS__ . '::video_hls',
'xfbp' => __CLASS__ . '::xframe_bypass',
'sexhacklive' => __CLASS__ . '::sexhacklive',
'sexadv' => __CLASS__ . '::adv_shortcode',
);
foreach( $shortcodes as $shortcode_tag => $shortcode_func ) {
......@@ -85,6 +86,33 @@ if(!class_exists('SH_Shortcodes')) {
}
public static function adv_shortcode($attr, $cont)
{
global $post;
extract( shortcode_atts(array(
"adv" => false,
), $attr));
if(!user_is_premium())
{
if($attr['adv'])
{
$post = get_post(intval($attr['adv']));
if(($post) && ($post->post_type == 'sexhackadv'))
{
$html = $post->post_content;
wp_reset_postdata();
return $html;
}
}
wp_reset_postdata();
//return 'Error in retrieving sexhackadv post. Wrong ID?';
}
return;
}
}
}
......
<?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('SexhackAddUnlockLogin')) {
class SexhackAddUnlockLogin
{
public function __construct()
{
add_filter("login_form_bottom", array($this, "add_to_login"), 10, 2);
add_action("woocommerce_after_order_notes", array($this, "add_to_checkout"));
add_filter("pms_register_shortcode_content", array($this, "add_to_register"), 10, 2);
add_filter("unlock_authenticate_user", array($this, "fix_unlock_user"), 11, 1);
sexhack_log('SexhackAddUnlockLogin() Instanced');
}
public function get_proto(){
return get_proto();
}
public function fix_unlock_user($user)
{
global $sexhack_pms;
if(is_object($user) && is_valid_eth_address($user->user_login))
{
if(!($sexhack_pms->is_member($user->ID)) && !($sexhack_pms->is_premium($user->ID)))
{
$subscription_plan = $sexhack_pms->get_default_plan();
if($subscription_plan)
{
$data = array(
'user_id' => $user->ID,
'subscription_plan_id' => $subscription_plan->id,
'start_date' => date( 'Y-m-d H:i:s' ),
'expiration_date' => $subscription_plan->get_expiration_date(),
'status' => 'active',
);
$member_subscription = new \PMS_Member_Subscription();
$inserted = $member_subscription->insert( $data );
}
}
}
return $user;
}
public function unlock_get_login_url($redirect_url=false) {
$UNLOCK_BASE_URL = 'https://app.unlock-protocol.com/checkout';
$rurl=apply_filters( 'unlock_protocol_get_redirect_uri', wp_login_url());
if($redirect_url) {
$rurl=$redirect_url;
}
$login_url = add_query_arg(
array(
'client_id' => apply_filters( 'unlock_protocol_get_client_id', wp_parse_url( home_url(), PHP_URL_HOST ) ),
'redirect_uri' => $rurl,
'state' => wp_create_nonce( 'unlock_login_state' ),
),
$UNLOCK_BASE_URL
);
return apply_filters( 'unlock_protocol_get_login_url', $login_url );
}
public function unlock_button($string, $args, $redirect_url)
{
$html="";
if(!is_user_logged_in()) {
$html="<hr><div style='text-align: center; width:100%;'><p>OR</p></div><hr>";
$html.="<br><div style='text-align:left;width:100%;'<p><button onclick=\"window.location.href='".$this->unlock_get_login_url($redirect_url);
$html.="'\" type='button'>Login with Crypto Wallet</button></p></div>";
}
return $string.$html;
}
// XXX Those 3 functions, hard-coded uri's that are dependent on a shortcode? that's sounds a bad idea, we
// should make them a configurable option
public function add_to_register($string, $args){
return $this->unlock_button($string, $args, get_proto().wp_parse_url( home_url(), PHP_URL_HOST )."/register");
}
public function add_to_login($string, $args){
return $this->unlock_button($string, $args, get_proto().wp_parse_url( home_url(), PHP_URL_HOST ));
}
public function add_to_checkout(){
echo $this->unlock_button('', $args, get_proto().wp_parse_url( home_url(), PHP_URL_HOST )."/checkout");
}
}
// Instance Unlock Login support class
new SexhackAddUnlockLogin;
}
?>
......@@ -21,9 +21,13 @@
namespace wp_SexHackMe;
if(!class_exists('SexhackAdvert')) {
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
class sexhackadv_widget extends \WP_Widget {
if(!class_exists('SH_ADVWidget')) {
class SH_ADVWidget extends \WP_Widget
{
function __construct()
{
parent::__construct(
......@@ -75,108 +79,15 @@ if(!class_exists('SexhackAdvert')) {
return $instance;
}
}
// Register and load the widget
function adv_load_widget() {
register_widget( 'wp_SexHackMe\sexhackadv_widget' );
}
add_action( 'widgets_init', 'wp_SexHackMe\adv_load_widget' );
class SexhackAdvert
{
public function __construct()
public static function register()
{
add_shortcode("sexadv", array($this, "adv_shortcode"));
add_action('init', array($this, "register_sexhackadv_post_type"));
sexhack_log('SexhackAdvert() Instanced');
register_widget('wp_SexHackMe\SH_ADVWidget');
}
public function revealid_add_id_column($columns)
{
$columns['revealid_id'] = 'ID';
$columns['revealid_short'] = 'shortcode';
return $columns;
}
public function revealid_id_column_content( $column, $id ) {
if( 'revealid_id' == $column ) {
echo $id;
}
if( 'revealid_short' == $column ) {
echo "[sexadv adv=$id]";
}
}
public function register_sexhackadv_post_type()
{
register_post_type('sexhackadv', array(
'label' => 'Advertising','description' => '',
'public' => true,
'show_ui' => true,
'show_in_menu' => true, // Visibility in admin menu.
'menu_position' => 151,
'capability_type' => 'post',
'hierarchical' => false,
'publicly_queryable' => true,
'rewrite' => false,
'query_var' => true,
'has_archive' => true,
'supports' => array('title','editor','page-attributes', 'shortcode'),
'taxonomies' => array(),
// there are a lot more available arguments, but the above is plenty for now
));
add_filter( 'manage_sexhackadv_posts_columns', array($this, 'revealid_add_id_column'), 5 );
add_action( 'manage_sexhackadv_posts_custom_column', array($this, 'revealid_id_column_content'), 5, 2 );
}
public function adv_shortcode($attr, $cont)
{
global $post;
global $sexhack_pms;
extract( shortcode_atts(array(
"adv" => false,
), $attr));
if(isset($sexhack_pms) && !$sexhack_pms->is_premium())
{
if($attr['adv'])
{
$post = get_post(intval($attr['adv']));
if(($post) && ($post->post_type == 'sexhackadv'))
{
$html = $post->post_content;
wp_reset_postdata();
return $html;
}
}
wp_reset_postdata();
//return 'Error in retrieving sexhackadv post. Wrong ID?';
}
return;
}
}
add_action( 'widgets_init', array('wp_SexHackMe\SH_ADVWidget', 'register' ));
}
$SEXHACK_SECTION = array(
'class' => 'SexhackAdvert',
'description' => 'Advertising support for SexHackMe',
'name' => 'sexhackme_advertising',
//'require-page' => 'sexhackadv'
'require-page' => array(array('post_type' => 'sexhackadv', 'title' => 'Top Banner Video Page', 'option' => 'sexadv_video_top'),
array('post_type' => 'sexhackadv', 'title' => 'Bottom Banner Video Page', 'option' => 'sexadv_video_bot')
)
);
?>
This diff is collapsed.
<?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;
function advert_add_id_column($columns)
{
$columns['revealid_id'] = 'ID';
$columns['revealid_short'] = 'shortcode';
return $columns;
}
function advert_id_column_content( $column, $id ) {
if( 'revealid_id' == $column ) {
echo $id;
}
if( 'revealid_short' == $column ) {
echo "[sexadv adv=$id]";
}
}
?>
......@@ -108,6 +108,7 @@ function user_has_premium_access($uid='')
{
global $sexhack_pms;
if(!isset($sexhack_pms)) return false;
return $sexhack_pms->is_premium($uid) AND is_user_logged_in();
}
......@@ -115,6 +116,7 @@ function user_is_premium($uid='')
{
global $sexhack_pms;
if(!isset($sexhack_pms)) return false;
return $sexhack_pms->is_premium($uid);
}
......@@ -122,6 +124,7 @@ function user_has_member_access($uid='')
{
global $sexhack_pms;
if(!isset($sexhack_pms)) return false;
if($uid) return $sexhack_pms->is_member($uid) OR $sexhack_pms->is_premium($uid);
return is_user_logged_in();
......@@ -131,6 +134,7 @@ function user_is_member($uid='')
{
global $sexhack_pms;
if(!isset($sexhack_pms)) return false;
return $sexhack_pms->is_member($uid);
}
......
<?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;
add_action('pms_register_form_after_create_user', 'pms_register_form_after_create_user');
function pms_register_form_after_create_user()
{
do_action('sh_register_form_after_create_user');
}
// XXX In the docs of PMS they indicate to use add_action but they use a filter... uhmmm
//add_action('pms_get_redirect_url', 'pms_get_redirect_url');
add_filter('pms_get_redirect_url', 'pms_get_redirect_url', 100, 2);
function pms_get_redirect_url($url, $location=false)
{
if( !isset( $_POST['pay_gate'] ) || $_POST['pay_gate'] != 'manual' )
return $url;
return apply_filter('sh_get_redirect_url', $url, $location);
}
?>
<?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;
// XXX Add Pagination
function get_wc_products_by_meta($spid=false, $metakey='_pms_woo_subscription_id')
{
if($spid) $meta = array(
'key' => $metakey,
'value' => $spid,
'compare' => '=',
);
else $meta = array(
'key' => $metakey,
'compare' => 'like',
);
$args = array(
'posts_per_page' => 100,
'post_type' => 'product',
'post_status' => 'publish',
'meta_key' => $metakey,
'meta_query' => array($meta),
);
$query = new \WP_Query( $args );
return $query;
}
// XXX Add Pagination
function get_wc_subscription_products_priced($price, $pid=false)
{
$res = array();
// XXX CACHE THIS!
$pages = get_wc_products_by_meta($pid);
if ( $pages->have_posts() )
{
foreach($pages->posts as $post)
{
$product = wc_get_product($post->ID);
if(is_object($product) && (strval($price) == strval($product->get_regular_price())))
{
$res[] = $product;
}
}
}
return $res;
}
?>
......@@ -217,9 +217,16 @@ if(!class_exists('SexHackMe_Plugin')) {
if( file_exists( SH_PLUGIN_DIR_PATH . 'includes/functions-core.php' ) )
include_once SH_PLUGIN_DIR_PATH . 'includes/functions-core.php';
/* Custom Post Types declarations */
if( file_exists( SH_PLUGIN_DIR_PATH . 'includes/class-post_types.php') )
include_once SH_PLUGIN_DIR_PATH . 'includes/class-post_types.php';
if( file_exists( SH_PLUGIN_DIR_PATH . 'includes/class-admin.php' ) )
include_once SH_PLUGIN_DIR_PATH . 'includes/class-admin.php';
/* Hooks compatibility/translation */
if( file_exists( SH_PLUGIN_DIR_PATH . 'includes/functions-hooks.php') )
include_once SH_PLUGIN_DIR_PATH . 'include/functions-hooks.php';
include_once SH_PLUGIN_DIR_PATH . 'includes/functions-hooks.php';
/* Cryptocurrencies utils */
if( file_exists( SH_PLUGIN_DIR_PATH . 'includes/functions-crypto.php' ) )
......@@ -233,6 +240,10 @@ if(!class_exists('SexHackMe_Plugin')) {
if( file_exists( SH_PLUGIN_DIR_PATH . 'includes/class-video-players.php' ) )
include_once SH_PLUGIN_DIR_PATH . 'includes/class-video-players.php';
/* Advertising support */
if(file_exists( SH_PLUGIN_DIR_PATH . 'includes/functions-advert.php' ) )
include_once SH_PLUGIN_DIR_PATH . 'includes/functions-advert.php';
/* Cam4 and Chaturbate support */
if( file_exists( SH_PLUGIN_DIR_PATH . 'includes/class-livecam-site-support.php') )
include_once SH_PLUGIN_DIR_PATH . 'includes/class-livecam-site-support.php';
......@@ -257,7 +268,9 @@ if(!class_exists('SexHackMe_Plugin')) {
if( file_exists( SH_PLUGIN_DIR_PATH . 'includes/class-shortcodes.php' ) )
include_once SH_PLUGIN_DIR_PATH . 'includes/class-shortcodes.php';
/* Widgets */
if( file_exists( SH_PLUGIN_DIR_PATH . 'includes/class-widgets.php' ) )
include_once SH_PLUGIN_DIR_PATH . 'includes/class-widgets.php';
/* Hook to include needed files */
do_action( 'pms_include_files' );
......@@ -318,6 +331,9 @@ if(!class_exists('SexHackMe_Plugin')) {
//if( is_admin() )
// add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
// Initialize Custom post_types
add_action( 'init', array( 'wp_SexHackMe\SH_PostTypes', 'init') );
// Initialize shortcodes
add_action( 'init', array( 'wp_SexHackMe\SH_Shortcodes', 'init' ) );
//add_action( 'init', array( $this, 'init_dependencies' ), 1 );
......@@ -520,6 +536,10 @@ if(!class_exists('SexHackMe_Plugin')) {
}
}
}
SH_Admin::init();
}
public function admin_menu()
......@@ -527,8 +547,9 @@ if(!class_exists('SexHackMe_Plugin')) {
add_menu_page('SexHackMe Settings', 'SexHackMe', 'manage_options', 'sexhackme-settings',
array($this, 'admin_page'), SH_PLUGIN_DIR_URL .'img/admin_icon.png', 31);
add_submenu_page( 'sexhackme-settings', 'SexHackMe Settings', 'Modules',
'manage_options', 'sexhackme-settings');
SH_Admin::menu();
foreach($this->SECTIONS as $section) {
if(get_option( $section['name'])=="1")
......@@ -552,8 +573,7 @@ if(!class_exists('SexHackMe_Plugin')) {
public function admin_page()
{
if(file_exists( SH_PLUGIN_DIR_PATH . 'templates/admin/sexhackme.php'))
include_once( SH_PLUGIN_DIR_PATH . 'templates/admin/sexhackme.php');
sh_get_template('admin/sexhackme.php', array('sections' => $this->SECTIONS));
}
}
......
<?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/>.
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
?>
<div class="wrap">
<?php do_settings_sections( 'sexhackme-advert-settings' ); ?>
<form method="post" action="/wp-admin/options.php">
<?php settings_fields( 'sexhackme-advert-settings' ); ?>
<table class="form-table">
<tr align="top">
<td>
<select id="sexadv_video_top" name="sexadv_video_top" class="widefat">
<option value="-1">Choose...</option>
<?php
$opt=get_option("sexadv_video_top");
foreach( get_posts(array('post_type' => 'sexhackadv', 'parent' => 0)) as $page ) {
echo '<option value="' . esc_attr( $page->ID ) . '"';
if ($opt == $page->ID) { echo "selected";}
echo '>' . esc_html( $page->post_title ) . ' ( ID: ' . esc_attr( $page->ID ) . ')' . '</option>';
} ?>
</select>
<p class="description">Select ADV for top Videogallery</p>
<select id="sexadv_video_bot" name="sexadv_video_bot" class="widefat">
<option value="-1">Choose...</option>
<?php
$opt=get_option("sexadv_video_bot");
foreach( get_posts(array('post_type' => 'sexhackadv', 'parent' => 0)) as $page ) {
echo '<option value="' . esc_attr( $page->ID ) . '"';
if ($opt == $page->ID) { echo "selected";}
echo '>' . esc_html( $page->post_title ) . ' ( ID: ' . esc_attr( $page->ID ) . ')' . '</option>';
} ?>
</select>
<p class="description">Select ADV for bottom Videogallery</p>
</td>
</tr>
</table>
<?php submit_button(); ?>
</form>
</div>
......@@ -21,6 +21,8 @@
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
?>
<div class="wrap">
<h2>SexHackMe Plugin Settings</h2>
......@@ -28,7 +30,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
<?php settings_fields( 'sexhackme-settings' ); ?>
<?php do_settings_sections( 'sexhackme-settings' ); ?>
<table class="form-table">
<?php foreach($this->SECTIONS as $section) { ?>
<?php foreach($sections as $section) { ?>
<tr align="top">
<th scope="row"><?php echo $section['description'];?></th>
<td>
......
<?php
<?php
/**
* Copyright: 2022 (c)Franco (nextime) Lanza <franco@nexlab.it>
* License: GNU/GPL version 3.0
......@@ -19,25 +19,10 @@
* along with SexHackMe Wordpress Plugin. If not, see <https://www.gnu.org/licenses/>.
*/
namespace wp_SexHackMe;
if(!class_exists('SH_WooCommerce_Registration_Integration')) {
class SH_WooCommerce_Registration_Integration2
{
public function gen_random_pwd()
{
sh_genpass_register_form();
}
}
}
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
function wcpms_adminpage()
{
$plans = sh_get_subscription_plans();
sexhack_log($plans);
$plans = wp_SexHackMe\sh_get_subscription_plans();
?>
<div class="wrap">
......@@ -57,12 +42,11 @@ function wcpms_adminpage()
<select id="sexhack-wcpms-<?php echo $plan->id;?>" name="sexhack-wcpms-<?php echo $plan->id; ?>" class="widefat">
<?php
$opt = get_option('sexhack-wcpms-'.strval($plan->id));
foreach(get_wc_subscription_products_priced($plan->price, $plan->id) as $prod)
foreach(wp_SexHackMe\get_wc_subscription_products_priced($plan->price, $plan->id) as $prod)
{
?>
<option value='<?php echo $prod->id; ?>' <?php if($opt == $prod->id) echo "selected"; ?> >
<?php echo $prod->get_title() ?> (<?php echo $prod->id; ?>)
<option value='<?php echo $prod->get_id(); ?>' <?php if($opt == $prod->get_id()) echo "selected"; ?> >
<?php echo $prod->get_title() ?> (<?php echo $prod->get_id(); ?>)
</option>
<?php
......@@ -76,48 +60,25 @@ function wcpms_adminpage()
}
?>
</table>
<?php do_settings_sections( 'sexhackme-wcpms-settings-email' ); ?>
<table class="form-table">
<tr align="top">
<td>
<select id="sexhack_registration_mail_endpoint" name="sexhack_registration_mail_endpoint" class="widefat">
<option value="-1">Choose...</option>
<?php
$opt=get_option("sexhack_registration_mail_endpoint");
foreach( get_posts(array('post_type' => 'page', 'parent' => 0)) as $page ) {
echo '<option value="' . esc_attr( $page->ID ) . '"';
if ($opt == $page->ID) { echo "selected";}
echo '>' . esc_html( $page->post_title ) . ' ( ID: ' . esc_attr( $page->ID ) . ')' . '</option>';
} ?>
</select>
<p class="description">Select email checkout registration redirect page</p>
</td>
</tr>
</table>
<?php submit_button(); ?>
</form>
</div>
<?php
}
function settings_wcpms_section()
{
echo "<h2>SexHackMe PMS - WooCommerce integration Settings</h2>";
}
function wcpms_initialize_options()
{
$plans = pms_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_action('admin_init', 'wp_SexHackMe\wcpms_initialize_options');
$SEXHACK_SECTION = array(
'class' => 'SH_WooCommerce_Registration_Integration2',
'description' => 'Integrate woocommerce account page and sexhack modified registration form on pms to send password change link by email',
'name' => 'sexhackme_pmswooregistration',
'require-page' => array(
array('post_type' => 'page', 'title' => 'Set password mail page', 'option' => 'sexhack_registration_mail_endpoint')
),
'adminmenu' => array(
array('title' => 'WC-PMS Integration',
'slug' => 'wcpms-integration',
'callback' => 'wp_SexHackMe\wcpms_adminpage')
),
'slugs' => array('account', 'register', 'login', 'password-reset')
);
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment