fix registration

parent 7414e5c6
......@@ -10,7 +10,7 @@ if(!class_exists('PmsWoocommerceRegistrationIntegration')) {
sexhack_log('PmsWoocommerceRegistrationIntegration() Instanced');
// Register new endpoint (URL) for My Account page
add_action( 'init', array($this, 'add_subscriptions_endpoint') );
add_action( 'init', array($this, 'add_subscriptions_endpoint'), 300 );
// Add new QUERY vars
add_filter( 'query_vars', array($this, 'subscriptions_query_vars'), 0 );
......@@ -35,7 +35,7 @@ if(!class_exists('PmsWoocommerceRegistrationIntegration')) {
// you find a dick
// pretty much
// everywhere
add_action( 'init', array($this, 'gen_random_pwd'));
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
add_action("pms_register_form_after_create_user", array($this, "send_register_email_reset_password") );
......@@ -46,7 +46,10 @@ if(!class_exists('PmsWoocommerceRegistrationIntegration')) {
// Note: Re-save Permalinks or it will give 404 error
function add_subscriptions_endpoint()
{
sexhack_log("SUBSCRIPTION ENDPOINT ADDED");
add_rewrite_endpoint( 'subscriptions', EP_ROOT | EP_PAGES );
//update_option('need_rewrite_flush', 1);
//flush_rewrite_rules();
}
// Add new QUERY vars
......
......@@ -105,17 +105,17 @@ if(!class_exists('SexHackVideoGallery')) {
$projects_structure = '/v/%wooprod%/';
$rules = $wp_rewrite->wp_rewrite_rules();
// XXX This is HORRIBLE. Using a Try/Catch to test an array key is stupid. But apparently php is also
// stupid and array_key_exists() doesn't work.
try {
if(array_key_exists('v/([^/]+)/?$', $rules)) {
sexhack_log("REWRITE: rules OK: ".'v/([^/]+)/?$ => '.$rules['v/([^/]+)/?$']);
} catch(Exception $e) {
} else {
sexhack_log("REWRITE: Need to add and flush our rules!");
$wp_rewrite->add_rewrite_tag("%wooprod%", '([^/]+)', "post_type=sexhack_video&wooprod=");
$wp_rewrite->add_permastruct('v', $projects_structure, false);
$wp_rewrite->flush_rules();
//$wp_rewrite->flush_rules();
update_option('need_rewrite_flush', 1);
}
//$wp_rewrite->flush_rules();
}
......@@ -186,8 +186,10 @@ if(!class_exists('SexHackVideoGallery')) {
$prod = wc_get_product($id);
$image = get_the_post_thumbnail($id, "medium", array("class" => "sexhack_thumbnail")); //array("class" => "alignleft sexhack_thumbnail"));
$gif = $prod->get_attribute("gif_preview");
if($gif) $image .= "<img src='$gif' class='alignleft sexhack_thumb_hover' />";
$gif = $prod->get_attribute("gif_thumbnail");
if(!$gif) $gif = $prod->get_attribute("gif_preview");
if($gif) $image .= "<img src='$gif' class='alignleft sexhack_thumb_hover' loading='lazy' />";
$html = '<li class="product type-product sexhack_thumbli">';
......
......@@ -84,6 +84,8 @@ if(!class_exists('SexHackMe')) {
$this->instances = array();
add_action('admin_menu', array($this, 'admin_menu'));
add_action('admin_init', array($this, 'initialize_plugin'));
add_action('init', array($this, 'register_flush'), 10);
add_action('init', array($this, 'flush_rewrite'), 900);
foreach($this->SECTIONS as $section) {
if(get_option( $section['name'])=="1")
{
......@@ -129,9 +131,25 @@ if(!class_exists('SexHackMe')) {
if($res=="1") return "checked";
}
public function register_flush() {
register_setting('sexhackme-settings', 'need_rewrite_flush');
}
public function flush_rewrite()
{
if( get_option('need_rewrite_flush'))
{
sexhack_log("FLUSHING REWRITE RULES");
flush_rewrite_rules(false);
update_option('need_rewrite_flush', 0);
}
}
public function initialize_plugin()
{
add_settings_section('sexhackme-settings', ' ', array($this, 'settings_section'), 'sexhackme-settings');
//register_setting('sexhackme-settings', 'need_rewrite_flush');
foreach($this->SECTIONS as $section) {
add_settings_field($section['name'], $section['name'], $section['name'],
array($this, 'settings_field'), 'sexhackme-settings', 'sexhackme-settings', $section['name'] );
......
......@@ -61,14 +61,18 @@ get_header(); ?>
if($hls_member) echo do_shortcode( "[sexhls url=\"".$hls_member."\" posters=\"".$thumb."\"]" );
else if($hls) echo do_shortcode( "[sexhls url=\"".$hls."\" posters=\"".$thumb."\"]" );
else if($video_preview) echo '<video src='."'$video_preview'".' controls autoplay muted playsinline loop poster="'.$thumb.'"></video>';
if($hls_premium) echo "Premium versions for subscribers available..";
else echo '<img src="'.$thumb.'" loading="lazy"></img>';
if($hls_premium) echo "<a href='/product-category/subscriptions/'>Premium version for subscribers available...</a>";
}
else
{
if($hls) echo do_shortcode( "[sexhls url=\"".$hls."\" posters=\"".$thumb."\"]" );
else if($video_preview) echo '<video src='."'$video_preview'".' controls autoplay muted playsinline loop poster="'.$thumb.'"></video>';
if($hls_premium) echo "Premium version for subscribers available...";
if($hls_member) echo "Members version available...";
else echo '<img src="'.$thumb.'" loading="lazy"></img>';
if($hls_premium) echo "<a href='/product-category/subscriptions/'>Premium version for subscribers available...</a>";
if($hls_member) echo "<a href='/register'>Members version available...</a>";
}
?>
</article>
......
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