My account page model settings initial adds

parent a368024a
.woocommerce-MyAccount-navigation ul li.woocommerce-MyAccount-navigation-link--videomanager a::before {
content: "\f03d";
}
.woocommerce-MyAccount-navigation ul li.woocommerce-MyAccount-navigation-link--modelsettings a::before {
content: "\f2c2";
}
...@@ -30,7 +30,8 @@ function sexhackme_settings_section() { ...@@ -30,7 +30,8 @@ function sexhackme_settings_section() {
} }
function sexhackme_admin_page() function sexhackme_admin_page()
sh_get_template('admin/sexhackme.php')); {
sh_get_template('admin/sexhackme.php');
} }
?> ?>
...@@ -42,7 +42,7 @@ function settings_wcpms_section_email() ...@@ -42,7 +42,7 @@ function settings_wcpms_section_email()
function settings_wcpms_section_prodcat() function settings_wcpms_section_prodcat()
{ {
echo "<h2>WooCommerce auto-roducts for Videos</h2>"; echo "<h2>WooCommerce auto-products for Videos</h2>";
} }
?> ?>
...@@ -34,6 +34,13 @@ if(!class_exists('SH_Admin')) { ...@@ -34,6 +34,13 @@ if(!class_exists('SH_Admin')) {
// Add general settings section // Add general settings section
add_settings_section('sexhackme-settings', ' ', 'wp_SexHackMe\sexhackme_settings_section', 'sexhackme-settings'); 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 // Add WC-PMS_Integration settings
if( file_exists(SH_PLUGIN_DIR_PATH . 'includes/admin/functions-wcpms.php') ) if( file_exists(SH_PLUGIN_DIR_PATH . 'includes/admin/functions-wcpms.php') )
{ {
...@@ -78,6 +85,8 @@ if(!class_exists('SH_Admin')) { ...@@ -78,6 +85,8 @@ if(!class_exists('SH_Admin')) {
add_action('update_option', '\wp_SexHackMe\SH_Admin::update_gallery_slug', 10, 3); add_action('update_option', '\wp_SexHackMe\SH_Admin::update_gallery_slug', 10, 3);
//register_setting('sexhackme-gallery-settings', 'sexhack_gallery_slug'); //register_setting('sexhackme-gallery-settings', 'sexhack_gallery_slug');
} }
// RClone settings
if( file_exists(SH_PLUGIN_DIR_PATH . 'includes/admin/functions-rclone.php') ) if( file_exists(SH_PLUGIN_DIR_PATH . 'includes/admin/functions-rclone.php') )
{ {
include_once SH_PLUGIN_DIR_PATH . 'includes/admin/functions-rclone.php'; include_once SH_PLUGIN_DIR_PATH . 'includes/admin/functions-rclone.php';
...@@ -125,31 +134,7 @@ if(!class_exists('SH_Admin')) { ...@@ -125,31 +134,7 @@ if(!class_exists('SH_Admin')) {
'manage_options', 'sexhackme-settings'); 'manage_options', 'sexhackme-settings');
// TODO We don't have a main page yet, so, remove it. // TODO We don't have a main page yet, so, remove it.
remove_submenu_page( 'sexhackme-settings', 'sexhackme-settings' ); //remove_submenu_page( 'sexhackme-settings', '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
}
// Add Gallery settings page // Add Gallery settings page
...@@ -160,7 +145,8 @@ if(!class_exists('SH_Admin')) { ...@@ -160,7 +145,8 @@ if(!class_exists('SH_Admin')) {
'Gallery', // title 'Gallery', // title
'manage_options', // capabilities 'manage_options', // capabilities
'gallery', // slug 'gallery', // slug
'wp_SexHackMe\gallery_adminpage'); // callback 'wp_SexHackMe\gallery_adminpage', // callback
20);
} }
...@@ -172,7 +158,34 @@ if(!class_exists('SH_Admin')) { ...@@ -172,7 +158,34 @@ if(!class_exists('SH_Admin')) {
'RClone', 'RClone',
'manage_options', 'manage_options',
'rclone', 'rclone',
'wp_SexHackMe\rclone_adminpage'); '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 // Add Video tags and categories subpages to Video edit menu
......
...@@ -203,7 +203,7 @@ if(!class_exists('SexhackPmsPasswordDataLeak')) { ...@@ -203,7 +203,7 @@ if(!class_exists('SexhackPmsPasswordDataLeak')) {
$page = get_page($mailpage); $page = get_page($mailpage);
$mailpage = $page->post_name; $mailpage = $page->post_name;
} }
send_changepwd_mail($user, $mailpage); send_changepwd_mail($username_email, $mailpage);
......
...@@ -61,7 +61,7 @@ if(!class_exists('SH_PostTypes')) { ...@@ -61,7 +61,7 @@ if(!class_exists('SH_PostTypes')) {
// TODO: the idea is to have custom post type for models profiles and for videos. // TODO: the idea is to have custom post type for models profiles and for videos.
// Ideally /$DEFAULTSLUG/nomevideo/ finisce sul corrispettivo prodotto woocommerce, // Ideally /$DEFAULTSLUG/nomevideo/ finisce sul corrispettivo prodotto woocommerce,
// /$DEFAULTSLUG/modelname/nomevideo/ finisce sul corrispettivo page sexhackme_video quando show_in_menu e' attivo. // /$DEFAULTSLUG/modelname/nomevideo/ finisce sul corrispettivo page sexhackme_video quando show_in_menu e' attivo.
// //
// Devo pero' verificare le varie taxonomy e attributi della pagina, vedere come creare un prodotto in wordpress // Devo pero' verificare le varie taxonomy e attributi della pagina, vedere come creare un prodotto in wordpress
// per ogni pagina sexhack_video che credo, sincronizzare prodotti e video pagine, gestire prodotti con lo stesso nome // per ogni pagina sexhack_video che credo, sincronizzare prodotti e video pagine, gestire prodotti con lo stesso nome
// ( credo si possa fare dandogli differenti slugs ) // ( credo si possa fare dandogli differenti slugs )
......
...@@ -213,7 +213,17 @@ if(!class_exists('SH_Query')) { ...@@ -213,7 +213,17 @@ if(!class_exists('SH_Query')) {
} }
public static function get_Videos($id, $idtype='')
{
return SH_Query::_get_Videos($id, $idtype, false);
}
public static function get_Video($id, $idtype='') public static function get_Video($id, $idtype='')
{
return SH_Query::_get_Videos($id, $idtype, true);
}
public static function _get_Videos($id, $idtype='', $firstres=true)
{ {
global $wpdb; global $wpdb;
...@@ -229,6 +239,14 @@ if(!class_exists('SH_Query')) { ...@@ -229,6 +239,14 @@ if(!class_exists('SH_Query')) {
$dbres = $wpdb->get_results( $sql ); $dbres = $wpdb->get_results( $sql );
if(is_array($dbres) && count($dbres) > 0) if(is_array($dbres) && count($dbres) > 0)
{ {
if($firstres) return new SH_Video((array)$dbres[0]);
else {
$videos = array();
foreach($dbres as $res) {
$videos[] = new SH_Video((array)$res);
}
return $videos;
}
return new SH_Video((array)$dbres[0]); return new SH_Video((array)$dbres[0]);
} }
return false; return false;
...@@ -237,7 +255,7 @@ if(!class_exists('SH_Query')) { ...@@ -237,7 +255,7 @@ if(!class_exists('SH_Query')) {
public static function get_Videos($vcat=false) public static function get_VideosCat($vcat=false)
{ {
global $wpdb; global $wpdb;
......
...@@ -38,8 +38,9 @@ if(!class_exists('SH_Shortcodes')) { ...@@ -38,8 +38,9 @@ if(!class_exists('SH_Shortcodes')) {
'sh_videohls' => __CLASS__ . '::video_hls', 'sh_videohls' => __CLASS__ . '::video_hls',
'xfbp' => __CLASS__ . '::xframe_bypass', 'xfbp' => __CLASS__ . '::xframe_bypass',
'sexhacklive' => __CLASS__ . '::sexhacklive', 'sexhacklive' => __CLASS__ . '::sexhacklive',
'sexadv' => __CLASS__ . '::adv_shortcode', 'sexadv' => __CLASS__ . '::adv_shortcode',
'sexgallery' => __CLASS__ . '::videogallery_shortcode', 'sexgallery' => __CLASS__ . '::videogallery_shortcode',
'shvideomanager' => __CLASS__ . '::video_manager_shortcode',
); );
foreach( $shortcodes as $shortcode_tag => $shortcode_func ) { foreach( $shortcodes as $shortcode_tag => $shortcode_func ) {
...@@ -125,7 +126,7 @@ if(!class_exists('SH_Shortcodes')) { ...@@ -125,7 +126,7 @@ if(!class_exists('SH_Shortcodes')) {
$html = "<div class='sexhack_gallery'>"; //<h3>SexHack VideoGallery</h3>"; $html = "<div class='sexhack_gallery'>"; //<h3>SexHack VideoGallery</h3>";
if(isset($_GET['SHDEV'])) $html .= '<h3>DEVELOPEMENT MODE</h3>'; if(isset($_GET['SHDEV'])) $html .= '<h3>DEVELOPEMENT MODE</h3>';
$html .= '<ul class="products columns-4">'; $html .= '<ul class="products columns-4">';
$videos = $sh_videogallery->get_videos(); $videos = $sh_videogallery->get_videos_by_cat();
foreach($videos as $video) foreach($videos as $video)
{ {
if($video->status == 'published') if($video->status == 'published')
...@@ -140,6 +141,35 @@ if(!class_exists('SH_Shortcodes')) { ...@@ -140,6 +141,35 @@ if(!class_exists('SH_Shortcodes')) {
return $html; return $html;
} }
public static function video_manager_shortcode($attr, $cont)
{
//$post = get_post();
//echo $post->post_name;
//echo get_permalink();
//echo $_SERVER['REQUEST_URI'];
if(isset($_GET['vedit'])) {
if(is_numeric($_GET['vedit']) && intval($_GET['vedit']) > 0)
{
$video = sh_get_video(intval($_GET['vedit']));
if(is_object($video) && $video->user_id == get_current_user_id()) sh_get_template('edit_video.php',
array(
'video' => $video,
'post' => get_post($video->post_id)
)
);
else sh_get_template('video_access_negate.php');
return;
} else if($_GET['vedit'] == 'new') {
sh_get_template('new_video.php');
return;
} else {
sh_get_template('video_access_negate.php');
return;
}
}
sh_get_template('videomanager.php');
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('SH_StoreFront')) {
class SH_StoreFront
{
public static function init()
{
// Remove the cart and the product search
remove_action( 'storefront_header', 'storefront_header_cart', 60 );
remove_action( 'storefront_header', 'storefront_product_search', 40);
// Remove StoreFront credits
add_filter('storefront_credit_link', 'wp_SexHackMe\SH_StoreFront::credits');
// add footer disclaimer
//add_action('storefront_footer', 'wp_SexHackMe\sh_get_disclaimer')); // XXX I don't like positioning this way. Fix in CSS or sobstitute footer theme file?
// Re add the cart in the right position
add_action( 'storefront_header', 'storefront_header_cart', 40);
}
public static function credits($cred)
{
return '';
}
}
}
?>
...@@ -85,11 +85,11 @@ if(!class_exists('SH_VideoGallery')) { ...@@ -85,11 +85,11 @@ if(!class_exists('SH_VideoGallery')) {
} }
} }
public function get_videos($vcat=false) { public function get_videos_by_cat($vcat=false) {
// XXX TODO Only published videos! // XXX TODO Only published videos!
if(!$this->videolist && !$vcat) $this->videolist = sh_get_videos($vcat); //SH_Query::get_Videos($vcat); //$this->_getProducts($vcat); if(!$this->videolist && !$vcat) $this->videolist = sh_get_videos_by_cat();
else if($vcat) return sh_get_videos($vcat); //SH_Query::get_Videos($vcat); //$this->_getProducts($vcat); else if($vcat) return sh_get_videos_by_cat($vcat);
return $this->videolist; return $this->videolist;
......
...@@ -349,23 +349,25 @@ if(!class_exists('SH_WooCommerce_Registration_Integration')) { ...@@ -349,23 +349,25 @@ if(!class_exists('SH_WooCommerce_Registration_Integration')) {
// Register new endpoint (URL) for My Account page // Register new endpoint (URL) for My Account page
add_action( 'init', array($this, 'add_subscriptions_endpoint'), 300 ); add_action( 'init', array($this, 'add_endpoints'), 300 );
// Add new QUERY vars // Add new QUERY vars
add_filter( 'query_vars', array($this, 'subscriptions_query_vars'), 0 ); add_filter( 'query_vars', array($this, 'add_query_vars'), 0 );
// Insert the new endpoint into the My Account menu // Insert the new endpoints into the My Account page from woocommerce and remove the unused ones
add_filter( 'woocommerce_account_menu_items', array($this, 'add_subscriptions_link_my_account') ); add_filter( 'woocommerce_account_menu_items', array($this, 'modify_my_account_page_tabs'), 99 );
/* Add content to the new tab /* Add content to the new tab
* NOTE: add_action must follow 'woocommerce_account_{your-endpoint-slug}_endpoint' format */ * NOTE: add_action must follow 'woocommerce_account_{your-endpoint-slug}_endpoint' format */
add_action( 'woocommerce_account_subscriptions_endpoint', array($this, 'subscriptions_content'), 50, 6 ); add_action( 'woocommerce_account_subscriptions_endpoint', array($this, 'subscriptions_content'), 50, 6 );
add_action( 'woocommerce_account_videomanager_endpoint', array($this, 'videomanager_content'), 50, 6 );
add_action( 'woocommerce_account_modelsettings_endpoint', array($this, 'modelsettings_content'), 50, 6 );
/* Inject random generate pass as we don't send it from the registration form */ /* Inject random generate pass as we don't send it from the registration form */
add_action( 'init', array($this, 'gen_random_pwd'), 5); // This need to happen before PMS detect the form at "10" sequence firing add_action( 'init', array($this, 'gen_random_pwd'), 5); // This need to happen before PMS detect the form at "10" sequence firing
// Sending email with link to set user password // Sending email with link to set user password
add_action("sh_register_form_after_create_user", array($this, "send_register_email_reset_password") ); add_action("sh_register_form_after_create_user", array($this, "send_register_email_reset_password"), 10, 1 );
// Manage manual payments for Paid Member Subscriptions plugin // Manage manual payments for Paid Member Subscriptions plugin
...@@ -399,28 +401,45 @@ if(!class_exists('SH_WooCommerce_Registration_Integration')) { ...@@ -399,28 +401,45 @@ if(!class_exists('SH_WooCommerce_Registration_Integration')) {
// Register new endpoint (URL) for My Account page // Register new endpoint (URL) for My Account page
// Note: Re-save Permalinks or it will give 404 error // Note: Re-save Permalinks or it will give 404 error
function add_subscriptions_endpoint() function add_endpoints()
{ {
global $wp_rewrite; global $wp_rewrite;
add_rewrite_endpoint( 'subscriptions', EP_ROOT | EP_PAGES ); add_rewrite_endpoint( 'subscriptions', EP_ROOT | EP_PAGES );
add_rewrite_endpoint( 'videomanager', EP_ROOT | EP_PAGES );
add_rewrite_endpoint( 'modelsettings', EP_ROOT | EP_PAGES );
$rules = $wp_rewrite->wp_rewrite_rules(); $rules = $wp_rewrite->wp_rewrite_rules();
if(!array_key_exists('(.?.+?)/subscriptions(/(.*))?/?$', $rules)) if(!array_key_exists('(.?.+?)/subscriptions(/(.*))?/?$', $rules)
|| !array_key_exists('(.?.+?)/videomanager(/(.*))?/?$', $rules)
|| !array_key_exists('(.?.+?)/modelsettings(/(.*))?/?$', $rules))
{ {
update_option('need_rewrite_flush', 1); update_option('need_rewrite_flush', 1);
} }
} }
// Add new QUERY vars // Add new QUERY vars
public function subscriptions_query_vars( $vars ) public function add_query_vars( $vars )
{ {
$vars[] = 'subscriptions'; $vars[] = 'subscriptions';
return $vars; return $vars;
} }
// Insert the new endpoint into the My Account menu // Insert the new endpoint into the My Account menu
public function add_subscriptions_link_my_account( $items ) public function modify_my_account_page_tabs( $items )
{ {
// Add CSS for icons
wp_enqueue_style('sh_myaccount', SH_PLUGIN_DIR_URL.'css/sexhackme_myaccount.css', array(), SH_VERSION);
$items['subscriptions'] = 'Subscriptions'; $items['subscriptions'] = 'Subscriptions';
if(array_key_exists('edit-address', $items)) unset($items['edit-address']);
if(array_key_exists('payment-methods', $items)) unset($items['payment-methods']);
if(user_is_model())
{
$items['videomanager'] = 'My Videos';
$items['modelsettings'] = 'Model settings';
}
return $items; return $items;
} }
...@@ -431,6 +450,16 @@ if(!class_exists('SH_WooCommerce_Registration_Integration')) { ...@@ -431,6 +450,16 @@ if(!class_exists('SH_WooCommerce_Registration_Integration')) {
sh_account_subscription_content(); sh_account_subscription_content();
} }
public function videomanager_content()
{
sh_account_videomanager_content();
}
public function modelsettings_content()
{
sh_account_modelsettings_content();
}
public function send_register_email_reset_password($user_data) public function send_register_email_reset_password($user_data)
{ {
$mailpage = get_option('sexhack_registration_mail_endpoint', false); $mailpage = get_option('sexhack_registration_mail_endpoint', false);
...@@ -438,7 +467,9 @@ if(!class_exists('SH_WooCommerce_Registration_Integration')) { ...@@ -438,7 +467,9 @@ if(!class_exists('SH_WooCommerce_Registration_Integration')) {
$page = get_page($mailpage); $page = get_page($mailpage);
$mailpage = $page->post_name; $mailpage = $page->post_name;
} }
send_changepwd_mail($user_data["user_login"], $mailpage); $ulogin = $user_data;
if(is_array($user_data) OR is_object($user_data)) $ulogin = $user_data["user_login"];
send_changepwd_mail($ulogin, $mailpage);
} }
public function gen_random_pwd() public function gen_random_pwd()
......
...@@ -50,6 +50,16 @@ function sh_account_subscription_content() ...@@ -50,6 +50,16 @@ function sh_account_subscription_content()
echo do_shortcode( '[pms-payment-history]'); echo do_shortcode( '[pms-payment-history]');
} }
function sh_account_videomanager_content()
{
echo do_shortcode( '[shvideomanager]' );
}
function sh_account_modelsettings_content()
{
echo "Modelsettings";
}
function sh_genpass_register_form() function sh_genpass_register_form()
{ {
// Check nonce // Check nonce
...@@ -138,5 +148,11 @@ function user_is_member($uid='') ...@@ -138,5 +148,11 @@ function user_is_member($uid='')
} }
function user_is_model($uid=false)
{
if(!$uid) $uid = get_current_user_id();
$model = get_option('sexhack-model-role', false);
if(!$model) return false;
return user_has_role($uid, $model);
}
?> ?>
...@@ -24,15 +24,16 @@ namespace wp_SexHackMe; ...@@ -24,15 +24,16 @@ namespace wp_SexHackMe;
// Exit if accessed directly // Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit; 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($user_data)
function pms_register_form_after_create_user()
{ {
do_action('sh_register_form_after_create_user'); do_action('sh_register_form_after_create_user', $user_data);
} }
add_action('pms_register_form_after_create_user', 'wp_SexHackMe\pms_register_form_after_create_user');
// XXX In the docs of PMS they indicate to use add_action but they use a filter... uhmmm // 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_action('pms_get_redirect_url', 'pms_get_redirect_url');
add_filter('pms_get_redirect_url', 'pms_get_redirect_url', 100, 2); add_filter('pms_get_redirect_url', 'wp_SexHackMe\pms_get_redirect_url', 100, 2);
function pms_get_redirect_url($url, $location=false) function pms_get_redirect_url($url, $location=false)
{ {
if( !isset( $_POST['pay_gate'] ) || $_POST['pay_gate'] != 'manual' ) if( !isset( $_POST['pay_gate'] ) || $_POST['pay_gate'] != 'manual' )
......
...@@ -131,24 +131,29 @@ function get_proto(){ ...@@ -131,24 +131,29 @@ function get_proto(){
function send_changepwd_mail($user_login, $baseurl=false){ function send_changepwd_mail($user_login, $baseurl=false){
global $wpdb, $wp_hasher; global $wpdb; //, $wp_hasher;
if(!is_object($user_login)) { if(!is_object($user_login)) {
$user_login = sanitize_text_field($user_login); $user_login = sanitize_text_field($user_login);
if ( empty( $user_login) ) { if ( empty( $user_login) ) {
sexhack_log("EMPTY LOGIN");
return false; return false;
} else if ( strpos( $user_login, '@' ) ) { } else if ( strpos( $user_login, '@' ) ) {
$user_data = get_user_by( 'email', trim( $user_login ) ); $user_data = get_user_by( 'email', trim( $user_login ) );
if ( empty( $user_data ) ) if ( empty( $user_data ) )
{
sexhack_log("EMPTY USER DATA");
return false; return false;
}
} else { } else {
$login = trim($user_login); $login = trim($user_login);
$user_data = get_user_by('login', $login); $user_data = get_user_by('login', $login);
} }
} }
do_action('lostpassword_post'); do_action('lostpassword_post');
if ( !$user_data ) return false; if ( !isset($user_data) ) return false;
if ( !is_object($user_data) ) return false; if ( !is_object($user_data) ) return false;
// redefining user_login ensures we return the right case in the email // redefining user_login ensures we return the right case in the email
...@@ -157,19 +162,22 @@ function send_changepwd_mail($user_login, $baseurl=false){ ...@@ -157,19 +162,22 @@ function send_changepwd_mail($user_login, $baseurl=false){
do_action('retreive_password', $user_login); // Misspelled and deprecated do_action('retreive_password', $user_login); // Misspelled and deprecated
do_action('retrieve_password', $user_login); do_action('retrieve_password', $user_login);
$allow = apply_filters('allow_password_reset', true, $user_data->ID); $allow = apply_filters('allow_password_reset', true, $user_data->ID);
if ( ! $allow ) if ( ! $allow )
return false; return false;
else if ( is_wp_error($allow) ) else if ( is_wp_error($allow) )
return false; return false;
$key = pms_retrieve_activation_key( $user_login ); $key = pms_retrieve_activation_key( $user_login );
//$key = get_password_reset_key( $user_data ); //$key = get_password_reset_key( $user_data );
do_action( 'retrieve_password_key', $user_login, $key ); do_action( 'retrieve_password_key', $user_login, $key );
if ( empty( $wp_hasher ) ) { //if ( empty( $wp_hasher ) ) {
require_once ABSPATH . 'wp-includes/class-phpass.php'; // require_once ABSPATH . 'wp-includes/class-phpass.php';
$wp_hasher = new PasswordHash( 8, true ); // $wp_hasher = new \PasswordHash( 8, true );
} //}
//$hashed = $wp_hasher->HashPassword( $key ); //$hashed = $wp_hasher->HashPassword( $key );
//$wpdb->update( $wpdb->users, array( 'user_activation_key' => time().":".$hashed ), array( 'user_login' => $user_login ) ); //$wpdb->update( $wpdb->users, array( 'user_activation_key' => time().":".$hashed ), array( 'user_login' => $user_login ) );
$message = __('Someone requested that the password be reset for the following account:') . "\r\n\r\n"; $message = __('Someone requested that the password be reset for the following account:') . "\r\n\r\n";
...@@ -212,8 +220,10 @@ function send_changepwd_mail($user_login, $baseurl=false){ ...@@ -212,8 +220,10 @@ function send_changepwd_mail($user_login, $baseurl=false){
$activation_keys[$user_data->ID]['time'] = time(); $activation_keys[$user_data->ID]['time'] = time();
update_option( 'pms_recover_password_activation_keys', $activation_keys ); update_option( 'pms_recover_password_activation_keys', $activation_keys );
if ( $message && !wp_mail($user_email, $title, $message) ) if ( $message && !wp_mail($user_email, $title, $message) )
wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') ); wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') );
sexhack_log("SENT EMAIL TO ".$user_email);
} }
...@@ -262,6 +272,13 @@ function check_url_or_path($url) ...@@ -262,6 +272,13 @@ function check_url_or_path($url)
return false; return false;
} }
function user_has_role($user_id, $role_name)
{
$user_meta = get_userdata($user_id);
$user_roles = $user_meta->roles;
return in_array($role_name, $user_roles);
}
function uniqidReal($lenght = 13) { function uniqidReal($lenght = 13) {
// uniqid gives 13 chars, but you could adjust it to your needs. // uniqid gives 13 chars, but you could adjust it to your needs.
if (function_exists("random_bytes")) { if (function_exists("random_bytes")) {
......
...@@ -24,6 +24,12 @@ namespace wp_SexHackMe; ...@@ -24,6 +24,12 @@ namespace wp_SexHackMe;
// Exit if accessed directly // Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit; if ( ! defined( 'ABSPATH' ) ) exit;
function sh_get_my_videos()
{
// XXX Get Only the first result
return SH_Query::get_Videos(get_current_user_id(), 'user');
}
function sh_save_video($video) function sh_save_video($video)
{ {
if(is_object($video)) { if(is_object($video)) {
...@@ -59,9 +65,9 @@ function sh_delete_video_from_product($p) ...@@ -59,9 +65,9 @@ function sh_delete_video_from_product($p)
} }
function sh_get_videos($vcat=false) function sh_get_videos_by_cat($vcat=false)
{ {
return SH_Query::get_Videos($vcat); return SH_Query::get_VideosCat($vcat);
} }
function sh_get_video($id) function sh_get_video($id)
......
...@@ -33,7 +33,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; ...@@ -33,7 +33,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
<option value="-1">Choose...</option> <option value="-1">Choose...</option>
<?php <?php
$opt=get_option("sexadv_video_top"); $opt=get_option("sexadv_video_top");
foreach( get_posts(array('post_type' => 'sexhackadv', 'parent' => 0)) as $page ) { foreach( get_posts(array('post_type' => 'sexhackadv', 'parent' => 0, 'numberposts' => -1)) as $page ) {
echo '<option value="' . esc_attr( $page->ID ) . '"'; echo '<option value="' . esc_attr( $page->ID ) . '"';
if ($opt == $page->ID) { echo "selected";} if ($opt == $page->ID) { echo "selected";}
echo '>' . esc_html( $page->post_title ) . ' ( ID: ' . esc_attr( $page->ID ) . ')' . '</option>'; echo '>' . esc_html( $page->post_title ) . ' ( ID: ' . esc_attr( $page->ID ) . ')' . '</option>';
......
<?php <?php
/** /**
* Copyright: 2022 (c)Franco (nextime) Lanza <franco@nexlab.it> * Copyright: 2022 (c)Franco (nextime) Lanza <franco@nexlab.it>
* License: GNU/GPL version 3.0 * License: GNU/GPL version 3.0
...@@ -20,69 +20,36 @@ ...@@ -20,69 +20,36 @@
*/ */
// Exit if accessed directly // Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit; $wp_roles = wp_roles();
$roles = $wp_roles->get_names();
if ( ! defined( 'ABSPATH' ) ) exit;
?> ?>
<div class="wrap"> <div class="wrap">
<h2>SexHackMe Plugin Settings</h2> <?php do_settings_sections( 'sexhackme-settings' ); ?>
<form method="post" action="/wp-admin/options.php"> <h3>SexHackMe general settings</h3>
<?php settings_fields( 'sexhackme-settings' ); ?> <form method="post" action="/wp-admin/options.php">
<?php do_settings_sections( 'sexhackme-settings' ); ?> <?php settings_fields( 'sexhackme-settings' ); ?>
<table class="form-table"> <table class="form-table">
<?php foreach($sections as $section) { ?> <tr align="top">
<tr align="top"> <td>
<th scope="row"><?php echo $section['description'];?></th> <label>Choose the wp role for Models:</label>
<td> <select name="sexhack-model-role">
<input type="checkbox" name="<?php echo $section['name'];?>" value="1" <?php echo wp_SexHackMe\checkbox(get_option( $section['name'] )); ?>/> <option value="0">Choose...</option>
<br> <?php
<?php $model = get_option('sexhack-model-role', false);
if(array_key_exists('require-page', $section) && ($section['require-page'])) foreach($roles as $role)
{ {
$reqps = array(); $add='';
if(is_string($section['require-page'])) if(($model) && ($model==$role)) $add='selected';
{ echo "<option value='".$role."' ".$add." >".$role."</option>";
$reqtitle="Select the base plugin module page"; }
$reqpages=get_posts(array('post_type' => $section['require-page'], 'parent' => 0)); ?>
$reqps[] = array('title' => $reqtitle, 'pages' => $reqpages, 'option' => $section['name']."-page"); </select>
} elseif(is_array($section['require-page'])) { </td>
$i=0; </tr>
foreach($section['require-page'] as $rpage) { </table>
if(array_key_exists('post_type', $rpage)) { <?php submit_button(); ?>
$reqpsa = array('title' => 'Select Page', 'option' => $section['name']."-page$i", </form>
'pages' => get_posts(array('post_type' => $rpage['post_type'], 'parent' => 0))); </div>
if(array_key_exists('option', $rpage)) $reqpsa['option'] = $rpage['option'];
if(array_key_exists('title', $rpage)) $reqpsa['title'] = $rpage['title'];
$reqps[] = $reqpsa;
}
$i++;
}
} else {
$reqtitle="Select the base plugin module page";
$reqpages=get_pages();
$reqps[] = array('title' => $reqtitle, 'pages' => $reqpages, 'option' => $section['name']."-page");
}
foreach($reqps as $reqarr) {
?>
<select id="<?php echo $reqarr['option'];?>" name="<?php echo $reqarr['option']; ?>" class="widefat">
<option value="-1"><?php esc_html_e( 'Choose...', 'paid-member-subscriptions' ) ?></option>
<?php
$opt=get_option($reqarr['option']);
foreach( $reqarr['pages'] 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"><?php echo $reqarr['title']; ?></p>
<?php } ?>
<?php } ?>
</td>
</tr>
<?php } ?>
</table>
<?php submit_button(); ?>
</form>
</div>
...@@ -68,7 +68,7 @@ $plans = wp_SexHackMe\sh_get_subscription_plans(); ...@@ -68,7 +68,7 @@ $plans = wp_SexHackMe\sh_get_subscription_plans();
<option value="-1">Choose...</option> <option value="-1">Choose...</option>
<?php <?php
$opt=get_option("sexhack_registration_mail_endpoint"); $opt=get_option("sexhack_registration_mail_endpoint");
foreach( get_posts(array('post_type' => 'page', 'parent' => 0)) as $page ) { foreach( get_posts(array('post_type' => 'page', 'parent' => 0, 'numberposts' => -1)) as $page ) {
echo '<option value="' . esc_attr( $page->ID ) . '"'; echo '<option value="' . esc_attr( $page->ID ) . '"';
if ($opt == $page->ID) { echo "selected";} if ($opt == $page->ID) { echo "selected";}
echo '>' . esc_html( $page->post_title ) . ' ( ID: ' . esc_attr( $page->ID ) . ')' . '</option>'; echo '>' . esc_html( $page->post_title ) . ' ( ID: ' . esc_attr( $page->ID ) . ')' . '</option>';
......
<?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 ( !isset($video) || !is_object($video) ) exit;
$post = $video->get_post();
?>
<h3>Edit Video</h3>
<h4><?php echo $video->get_title(); ?></h4>
<form class="sexhack_video_edit" name="sexhack_video_edit" method="post">
<input type="text" name="title" value="<?php echo $video->get_title(); ?>" />
<input type=submit value="Save Video" />
</form>
<form class="fileUpload" enctype="multipart/form-data">
<div class="form-group">
<label>Choose File:</label>
<input type="file" id="file" accept="image/*" />
</div>
</form>
<?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;
?>
<form class="fileUpload" enctype="multipart/form-data">
<div class="form-group">
<label>Choose File:</label>
<input type="file" id="file" accept="image/*" />
</div>
</form>
<?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;
?>
<h2> YOU DON'T HAVE ACCESS TO THIS VIDEO </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;
$videos = sh_get_my_videos();
?>
<h3>My Videos</h3>
<p><a href="?vedit=new"><button>+ Add New Video </button></a></p>
<?php
foreach($videos as $video)
{
?>
<p>
<table style="border: 1px solid white">
<tr>
<label><?php echo $video->get_title();?></label>
</tr>
<tr>
<td>thumbnail</td>
<td>others data</td>
<td>
<a href="?vedit=<?php echo $video->id; ?>"><button>Edit</button></a>
</td>
</tr>
</table>
</p>
<?php
}
?>
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