Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
W
WordPress_SexHackMe_Plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SexHackMe
WordPress_SexHackMe_Plugin
Commits
0e29a15d
Commit
0e29a15d
authored
Jun 19, 2022
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Labeling for gallery
parent
c9db4573
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
263 additions
and
35 deletions
+263
-35
sexhack_gallery.php
classes/sexhack_gallery.php
+171
-18
storefront_headercart_credit.php
classes/storefront_headercart_credit.php
+9
-1
sexhackme_gallery.css
css/sexhackme_gallery.css
+54
-2
web.php
helpers/web.php
+10
-2
video.php
template/video.php
+19
-12
No files found.
classes/sexhack_gallery.php
View file @
0e29a15d
...
...
@@ -2,6 +2,95 @@
namespace
wp_SexHackMe
;
if
(
!
class_exists
(
'SexHackVideoGallery'
))
{
// Creating the widget
class
sexhack_gallery_widget
extends
\WP_Widget
{
function
__construct
()
{
parent
::
__construct
(
// Base ID of your widget
'sexhack_gallery_widget'
,
// Widget name will appear in UI
__
(
'SexHack Gallery'
,
'sexhack_widget_domain'
),
// Widget description
array
(
'description'
=>
__
(
'Add SexHack Gallery links'
,
'sexhack_widget_domain'
),
)
);
}
// Creating widget front-end
public
function
widget
(
$args
,
$instance
)
{
global
$post
;
$pattern
=
get_shortcode_regex
();
if
(
preg_match_all
(
'/'
.
$pattern
.
'/s'
,
$post
->
post_content
,
$matches
)
&&
array_key_exists
(
2
,
$matches
)
&&
in_array
(
'sexgallery'
,
$matches
[
2
]
)
)
{
$current_url
=
get_permalink
(
get_the_ID
());
$title
=
apply_filters
(
'widget_title'
,
$instance
[
'title'
]
);
// before and after widget arguments are defined by themes
echo
$args
[
'before_widget'
];
if
(
!
empty
(
$title
)
)
echo
$args
[
'before_title'
]
.
$title
.
$args
[
'after_title'
];
?>
<ul>
<li><a
href=
""
>
All videos
</a></li>
<li><a
href=
"?sexhack_vselect=public"
>
Public videos
</a></li>
<li><a
href=
"?sexhack_vselect=members"
>
Members videos
</a></li>
<li><a
href=
"?sexhack_vselect=premium"
>
Premium videos
</a></li>
<li><a
href=
"?sexhack_vselect=preview"
>
Previews videos
</a></li>
</ul>
<?php
echo
$args
[
'after_widget'
];
}
}
// Widget Backend
public
function
form
(
$instance
)
{
if
(
isset
(
$instance
[
'title'
]
)
)
{
$title
=
$instance
[
'title'
];
}
else
{
$title
=
__
(
'Filter gallery'
,
'sexhack_widget_domain'
);
}
// Widget admin form
?>
<p>
<label
for=
"
<?php
echo
$this
->
get_field_id
(
'title'
);
?>
"
>
<?php
_e
(
'Title:'
);
?>
</label>
<input
class=
"widefat"
id=
"
<?php
echo
$this
->
get_field_id
(
'title'
);
?>
"
name=
"
<?php
echo
$this
->
get_field_name
(
'title'
);
?>
"
type=
"text"
value=
"
<?php
echo
esc_attr
(
$title
);
?>
"
/>
</p>
<?php
}
// Updating widget replacing old instances with new
public
function
update
(
$new_instance
,
$old_instance
)
{
$instance
=
array
();
$instance
[
'title'
]
=
(
!
empty
(
$new_instance
[
'title'
]
)
)
?
strip_tags
(
$new_instance
[
'title'
]
)
:
''
;
return
$instance
;
}
// Class wpb_widget ends here
}
// Register and load the widget
function
gallery_load_widget
()
{
register_widget
(
'wp_SexHackMe\sexhack_gallery_widget'
);
}
add_action
(
'widgets_init'
,
'wp_SexHackMe\gallery_load_widget'
);
class
SexHackVideoGallery
{
...
...
@@ -18,6 +107,7 @@ if(!class_exists('SexHackVideoGallery')) {
add_action
(
'init'
,
array
(
$this
,
"register_sexhack_video_post_type"
));
//add_filter('page_template', array($this, 'sexhack_video_template'));
add_filter
(
'archive_template'
,
array
(
$this
,
'sexhack_video_template'
));
add_action
(
'pre_get_posts'
,
array
(
$this
,
'fix_video_query'
),
1
,
1
);
sexhack_log
(
'SexHackVideoGallery() Instanced'
);
...
...
@@ -27,6 +117,7 @@ if(!class_exists('SexHackVideoGallery')) {
public
function
check_rewrite
(
$rules
)
{
// TODO Check if our rules are present and call flush if not
// (double check if already done in the $this->register_sexhack_video_post_type and it's enough)
sexhack_log
(
$rules
);
return
$rules
;
}
...
...
@@ -119,10 +210,10 @@ if(!class_exists('SexHackVideoGallery')) {
}
public
function
getProducts
()
{
public
function
getProducts
(
$vcat
=
false
)
{
if
(
!
$this
->
productlist
)
$this
->
productlist
=
$this
->
_getProducts
();
$this
->
productlist
=
$this
->
_getProducts
(
$vcat
);
return
$this
->
productlist
;
...
...
@@ -130,9 +221,23 @@ if(!class_exists('SexHackVideoGallery')) {
// TODO: add pagination support
public
function
_getProducts
()
{
$products
=
new
\WP_Query
(
array
(
public
function
_getProducts
(
$vcat
=
false
)
{
$filter
=
false
;
if
(
isset
(
$_GET
[
'sexhack_vselect'
]))
{
switch
(
$_GET
[
'sexhack_vselect'
])
{
case
'premium'
:
case
'members'
:
case
'public'
:
case
'preview'
:
$filter
=
$_GET
[
'sexhack_vselect'
];
break
;
}
}
$queryarr
=
array
(
/*
* We're limiting the results to 100 products, change this as you
...
...
@@ -149,27 +254,48 @@ if(!class_exists('SexHackVideoGallery')) {
'terms'
=>
array
(
'exclude-from-catalog'
),
'field'
=>
'name'
,
'operator'
=>
'NOT IN'
,
)
)
,
)
)
//'meta_query' => array( array(
// 'value' => 'hls_public',
// 'compare' => 'like'
//) ),
)
);
);
if
(
$filter
)
{
if
(
$filter
==
"preview"
)
{
$queryarr
[
'meta_query'
][
'relation'
]
=
'OR'
;
$queryarr
[
'meta_query'
][]
=
array
(
'value'
=>
'video_preview'
,
'compare'
=>
'like'
);
$queryarr
[
'meta_query'
][]
=
array
(
'value'
=>
'hls_preview'
,
'compare'
=>
'like'
);
}
else
{
$queryarr
[
'meta_query'
]
=
array
(
array
(
'value'
=>
'hls_'
.
$filter
,
'compare'
=>
'like'
)
);
}
}
$products
=
new
\WP_Query
(
$queryarr
);
//sexhack_log(var_dump($products));
return
$products
;
}
public
function
sexgallery_shortcode
(
$attr
,
$cont
)
{
global
$post
;
extract
(
shortcode_atts
(
array
(
"category"
=>
"
free
"
,
"category"
=>
"
all
"
,
),
$attr
));
$html
=
"<div class='sexhack_gallery'>"
;
//<h3>SexHack VideoGallery</h3>";
$html
.=
'<ul class="products columns-4">'
;
$html
.=
'<ul class="products columns-4">'
;
$products
=
$this
->
getProducts
();
while
(
$products
->
have_posts
()
)
{
$products
->
the_post
();
...
...
@@ -186,20 +312,47 @@ 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"));
$hls
=
$prod
->
get_attribute
(
"hls_public"
);
$hls_member
=
$prod
->
get_attribute
(
"hls_members"
);
$hls_premium
=
$prod
->
get_attribute
(
"hls_premium"
);
$video_preview
=
$prod
->
get_attribute
(
"video_preview"
);
$gif_preview
=
$prod
->
get_attribute
(
"gif_preview"
);
$vr_premium
=
$prod
->
get_attribute
(
"vr_premium"
);
$vr_member
=
$prod
->
get_attribute
(
"vr_members"
);
$vr_public
=
$prod
->
get_attribute
(
"vr_public"
);
$vr_preview
=
$prod
->
get_attribute
(
"vr_preview"
);
$gif
=
$prod
->
get_attribute
(
"gif_thumbnail"
);
if
(
!
$gif
)
$gif
=
$
prod
->
get_attribute
(
"gif_preview"
)
;
if
(
!
$gif
)
$gif
=
$
gif_preview
;
if
(
$gif
)
$image
.=
"<img src='
$gif
' class='alignleft sexhack_thumb_hover' loading='lazy' />"
;
$html
=
'<li class="product type-product sexhack_thumbli">'
;
$vurl
=
str_replace
(
"/product/"
,
"/v/"
,
esc_url
(
get_the_permalink
()
));
$vtitle
=
esc_html
(
get_the_title
()
);
$vtitle
=
esc_html
(
get_the_title
()
);
$vtags
=
array
();
$downtag
=
''
;
if
((
!
$hls
)
AND
(
!
$hls_member
)
AND
(
!
$hls_premium
)
AND
(
$video_preview
))
$vtags
[]
=
'<label class="sexhack_vtag sexhack_preview" style="*LEFT*">preview</label>'
;
if
(
$hls
)
$vtags
[]
=
'<label class="sexhack_vtag sexhack_public" style="*LEFT*">public</label>'
;
if
(
$hls_member
)
$vtags
[]
=
'<label class="sexhack_vtag sexhack_members" style="*LEFT*">members</label>'
;
if
(
$hls_premium
)
$vtags
[]
=
'<label class="sexhack_vtag sexhack_premium" style="*LEFT*">premium</label>'
;
if
(
count
(
$prod
->
get_downloads
())
>
0
)
$html
.=
'<label class="sexhack_vtag sexhack_download"">download</label>'
;
if
((
$vr_premium
)
OR
(
$vr_member
)
OR
(
$vr_public
)
OR
(
$vr_preview
))
$html
.=
'<label class="sexhack_vtag sexhack_VR"">VR/3D</label>'
;
$html
.=
"<a href=
\"
$vurl
\"
class=
\"
woocommerce-LoopProduct-link woocommerce-loop-product__link
\"
>"
;
$html
.=
"<div class='sexhack_thumb_cont'>"
.
$image
.
"</div>"
;
foreach
(
$vtags
as
$vid
=>
$vtag
)
{
$left
=
intval
(
$vid
)
*
12
;
$vtag
=
str_replace
(
"*LEFT*"
,
"left:-"
.
$left
.
"px"
,
$vtag
);
$html
.=
$vtag
;
}
$html
.=
"<a href=
\"
$vurl
\"
class=
\"
woocommerce-LoopProduct-link woocommerce-loop-product__link
\"
>"
;
$html
.=
"<div class='sexhack_thumb_cont'>"
.
$image
.
"</div>"
;
// XXX Add the "hover" text preview, in "alt"?
$html
.=
"<h2 class=
\"
woocommerce-loop-product__title
\"
alt='"
.
$vtitle
.
"'>"
.
trim_text_preview
(
$vtitle
,
120
)
.
"</h2>"
;
$html
.=
"<h3 class=
\"
sexhack_gallery_title woocommerce-loop-product__title
\"
alt='"
.
$vtitle
.
"'>"
.
trim_text_preview
(
$vtitle
,
60
,
false
)
.
"</h3>"
;
$html
.=
"</a></li>"
;
return
$html
;
...
...
classes/storefront_headercart_credit.php
View file @
0e29a15d
...
...
@@ -10,10 +10,18 @@ if(!class_exists('StorefrontMoveHeaderCart')) {
add_action
(
'init'
,
array
(
$this
,
'remove_header_cart'
));
add_filter
(
'storefront_credit_link'
,
false
);
add_action
(
'wp_enqueue_scripts'
,
array
(
$this
,
'add_css'
),
200
);
//add_action('storefront_footer', array($this, 'disclaimer')); // XXX I don't like positioning this way. Fix in CSS or sobstitute footer theme file?
add_action
(
'storefront_header'
,
array
(
$this
,
'add_header_cart'
),
40
);
}
public
function
disclaimer
()
{
?>
<div
class=
"site-info"
>
All pictures and videos are property of the respective models. Please copy them for personal use but do not republish any without permission.
</div>
<?php
}
public
function
add_css
()
{
wp_enqueue_style
(
'sexhackme_header'
,
plugin_dir_url
(
__DIR__
)
.
'css/sexhackme_header.css'
);
...
...
css/sexhackme_gallery.css
View file @
0e29a15d
.sexhack_gallery_title
{
top
:
-30px
;
}
.sexhack_gallery_thumbnail
{
padding
:
10px
10px
10px
10px
;
}
ul
.products
li
.sexhack_thumbli
{
border
:
2px
solid
#253e50
;
border-radius
:
15px
;
margin-bottom
:
1.6em
;
}
.sexhack_vtag
{
position
:
relative
;
float
:
left
;
border-radius
:
20px
;
padding
:
0
10px
0
10px
;
text-align
:
center
;
font-size
:
9px
;
color
:
white
;
top
:
-30px
;
}
.sexhack_vtag
:hover
{
z-index
:
100
;
}
.sexhack_download
{
position
:
absolute
;
top
:
1px
;
left
:
-15px
;
z-index
:
100
;
border-bottom
:
-20px
;
background-color
:
#4a235a
;
}
.sexhack_public
{
background-color
:
#145a32
;
}
.sexhack_premium
{
background-color
:
#78281f
;
}
.sexhack_members
{
background-color
:
#154360
;
}
.sexhack_preview
{
background-color
:
#283747
;
}
@media
screen
and
(
max-width
:
767px
)
{
.sexhack_gallery_thumbnail
{
...
...
@@ -30,9 +79,10 @@
/* This to solve the different title lenght, combine with right trim and popup full title maybe,
and maybe not here but adding another container.
I should also re-check the sexhack class naming...
//height: 200px;
*/
//
height
:
210px
;
height
:
fit-content
;
//
overflow
:
hidden
;
*/
}
.sexhack_gallery_row
{
...
...
@@ -57,6 +107,8 @@
position
:
relative
;
max-width
:
100%
;
display
:
block
;
//
border
:
2px
solid
red
;
//
border-radius
:
6px
;
}
.sexhack_thumb_cont
.sexhack_thumb_hover
{
position
:
absolute
;
...
...
helpers/web.php
View file @
0e29a15d
...
...
@@ -14,7 +14,7 @@ function sexhack_getURL($url)
}
function
trim_text_preview
(
$text
,
$len
=
340
)
function
trim_text_preview
(
$text
,
$len
=
340
,
$fill
=
false
)
{
$min
=
"10"
;
if
(
$len
<
$min
)
$len
=
$min
;
...
...
@@ -22,7 +22,15 @@ function trim_text_preview($text, $len=340)
{
$offset
=
(
$len
-
3
)
-
strlen
(
$text
);
$text
=
substr
(
$text
,
0
,
strrpos
(
$text
,
' '
,
$offset
))
.
'...'
;
}
}
if
(
$fill
)
{
$start
=
strlen
(
$text
);
while
(
$start
<
$len
+
1
)
{
$start
++
;
$text
.=
" "
;
}
}
return
$text
;
}
...
...
template/video.php
View file @
0e29a15d
...
...
@@ -33,11 +33,12 @@ get_header(); ?>
$hls_member
=
$prod
->
get_attribute
(
"hls_members"
);
$hls_premium
=
$prod
->
get_attribute
(
"hls_premium"
);
$video_preview
=
$prod
->
get_attribute
(
"video_preview"
);
$gif_preview
=
$prod
->
get_attribute
(
"gif_preview"
);
if
((
$hls
)
AND
wp_SexHackMe\starts_with
(
'/'
,
$hls
))
$hls
=
site_url
()
.
$hls
;
if
((
$hls_member
)
AND
wp_SexHackMe\starts_with
(
'/'
,
$hls_member
))
$hls_member
=
site_url
()
.
$hls_member
;
if
((
$hls_premium
)
AND
wp_SexHackMe\starts_with
(
'/'
,
$hls_premium
))
$hls_premium
=
site_url
()
.
$hls_premium
;
if
((
$video_preview
)
AND
wp_SexHackMe\starts_with
(
'/'
,
$video_preview
))
$video_preview
=
site_url
()
.
$video_preview
;
if
((
$hls
)
OR
(
$hls_member
)
OR
(
$hls_premium
)
OR
(
$video
_preview
))
:
?>
//if (($hls) OR ($hls_member) OR ($hls_premium) OR ($video_preview) OR ($gif
_preview)) : ?>
<
article
id
=
"post-<?php echo get_the_ID();?>"
class
="
post
-<?
php
echo
get_the_ID
();
?>
product type-product">
<header
class=
"entry-header"
>
<h2
class=
"alpha entry-title sexhack_video_title"
>
...
...
@@ -48,44 +49,50 @@ get_header(); ?>
//$thumb = wp_get_attachment_image_src(get_post_thumbnail_id( get_the_ID(), 'full' ));
$thumb
=
wp_get_attachment_url
(
$prod
->
get_image_id
());
$endhtml
=
'<br><hr>'
;
if
(
$sexhack_pms
->
is_premium
())
{
if
(
$hls_premium
)
echo
do_shortcode
(
"[sexhls url=
\"
"
.
$hls_premium
.
"
\"
posters=
\"
"
.
$thumb
.
"
\"
]"
);
else
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>'
;
else
echo
"Error fetching the video..."
;
// This should never happen
else
if
(
$gif_preview
)
echo
'<img src="'
.
$gif_preview
.
'" loading="lazy"></img>'
;
else
echo
'<img src="'
.
$thumb
.
'" loading="lazy"></img>'
;
}
elseif
(
$sexhack_pms
->
is_member
())
{
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>'
;
else
if
(
$gif_preview
)
echo
'<img src="'
.
$gif_preview
.
'" loading="lazy"></img>'
;
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_premium
)
$endhtml
.=
"<h3><a href='/product-category/subscriptions/'>Premium full lenght version available here</a></h3
>"
;
}
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>'
;
else
if
(
$gif_preview
)
echo
'<img src="'
.
$gif_preview
.
'" loading="lazy"></img>'
;
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
>"
;
if
(
$hls_premium
)
$endhtml
.=
"<h3><a href='/product-category/subscriptions/'>Premium full lenght version available here</a></h3
>"
;
if
(
$hls_member
)
$endhtml
.=
"<h3><a href='/login'>Free members only version available! Sign up or Login to watch</a></h3
>"
;
}
?>
</article>
<?php
else
:
get_template_part
(
'content'
,
get_post_format
()
);
// get_post_format() return empty for us
endif
;
//else :
// get_template_part( 'content', get_post_format() ); // get_post_format() return empty for us
//endif;
echo
$endhtml
;
?>
<h3><a
href=
"
<?php
echo
get_the_permalink
();
?>
"
>
Download the full lenght hi-res version of this video
</a><h3>
<br><hr>
<?php
endwhile
;
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment