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
5dade490
Commit
5dade490
authored
Jul 24, 2022
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Released version 0.0.2
parent
bf0f01e3
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
409 additions
and
146 deletions
+409
-146
CHANGELOG.txt
CHANGELOG.txt
+8
-0
TODO.txt
TODO.txt
+4
-7
class-admin.php
includes/class-admin.php
+33
-1
class-gdrive.php
includes/class-gdrive.php
+89
-0
class-integrate-google-drive.php
includes/class-integrate-google-drive.php
+20
-1
class-post_types.php
includes/class-post_types.php
+44
-12
class-query.php
includes/class-query.php
+18
-3
class-shortcodes.php
includes/class-shortcodes.php
+9
-4
class-video.php
includes/class-video.php
+15
-3
class-videogallery.php
includes/class-videogallery.php
+54
-46
class-woocommerce-support.php
includes/class-woocommerce-support.php
+1
-1
functions-utils.php
includes/functions-utils.php
+1
-0
functions-video.php
includes/functions-video.php
+5
-0
sexhackme.php
sexhackme.php
+10
-7
gallery.php
templates/admin/gallery.php
+42
-2
video.php
templates/video.php
+56
-59
No files found.
CHANGELOG.txt
View file @
5dade490
== Sat 16 July 2022, 11:35am ==
== Sat 16 July 2022, 11:35am ==
- Released version 0.0.1
- Released version 0.0.1
== Mon 25 July 2022, 00:26am ==
- Released version 0.0.2
* Proper functioning Video post type page for Videos (with initial rough admin editing interface).
* use WC products only for downloads and memberships.
* Database table dedicated for Video pages.
* Support Gdrive download links through the plugin "Integrate Google Drive"
TODO.txt
View file @
5dade490
This is a very rough plan for this plugin
This is a very rough plan for this plugin
based on the ideas I planned for www.sexhack.me:
based on the ideas I planned for www.sexhack.me:
- Version 0.0.2:
* Proper functioning Video post type page for Videos (with initial rough admin editing interface).
* use WC products only for downloads and memberships.
* Database table dedicated for Video pages.
- Version 0.0.3:
- Version 0.0.3:
* Integration of Ultimate Members plugin for user and model profiles
* Integration of Ultimate Members plugin for user and model profiles
* Show thumbnail in video post list in admin
* Show thumbnail in video post list in admin
* 404 Not Found page with gallery instead of WC products
* 404 Not Found page with gallery instead of WC products
* Fix caching problems with "integrate google drive"
- Version 0.0.4:
- Version 0.0.4:
* Upload Videos page for models
* Upload Videos page for models
...
@@ -21,6 +14,10 @@ based on the ideas I planned for www.sexhack.me:
...
@@ -21,6 +14,10 @@ based on the ideas I planned for www.sexhack.me:
- Version 0.0.5:
- Version 0.0.5:
* Better Video Page
* Better Video Page
* Tag filtering/support
* Tag filtering/support
* Proper installation dependencies management,
- Version 0.0.9:
* Remove integrate google drive plugin support and implement internal gdrive api
- Version 0.1.0:
- Version 0.1.0:
* Fixes of all the features on the previous versions
* Fixes of all the features on the previous versions
...
...
includes/class-admin.php
View file @
5dade490
...
@@ -72,10 +72,42 @@ if(!class_exists('SH_Admin')) {
...
@@ -72,10 +72,42 @@ if(!class_exists('SH_Admin')) {
{
{
include_once
SH_PLUGIN_DIR_PATH
.
'includes/admin/functions-gallery.php'
;
include_once
SH_PLUGIN_DIR_PATH
.
'includes/admin/functions-gallery.php'
;
add_settings_section
(
'sexhackme-gallery-settings'
,
' '
,
'wp_SexHackMe\gallery_settings_section'
,
'sexhackme-gallery-settings'
);
add_settings_section
(
'sexhackme-gallery-settings'
,
' '
,
'wp_SexHackMe\gallery_settings_section'
,
'sexhackme-gallery-settings'
);
register_setting
(
'sexhackme-gallery-settings'
,
'sexhack_gallery_slug'
);
register_setting
(
'sexhackme-gallery-settings'
,
'sexhack_video_page'
);
register_setting
(
'sexhackme-gallery-settings'
,
'sexhack_gallery_page'
);
register_setting
(
'sexhackme-gallery-settings'
,
'sexhack_video404_page'
);
add_action
(
'update_option'
,
'\wp_SexHackMe\SH_Admin::update_gallery_slug'
,
10
,
3
);
//register_setting('sexhackme-gallery-settings', 'sexhack_gallery_slug');
}
}
}
}
public
static
function
update_gallery_slug
(
$option
,
$old
,
$new
)
{
switch
(
$option
)
{
case
'sexhack_video_page'
:
if
(
!
is_int
(
$new
))
break
;
$page
=
get_post
(
$new
);
set_option
(
'sexhack_gallery_slug'
,
$page
->
post_name
);
update_option
(
'need_rewrite_flush'
,
1
);
break
;
case
'sexhack_gallery_page'
:
update_option
(
'need_rewrite_flush'
,
1
);
break
;
case
'sexhack_video404_page'
:
update_option
(
'need_rewrite_flush'
,
1
);
break
;
default
:
break
;
}
sexhack_log
(
"UPDATE OPTIONS: "
.
$option
.
" OLD
$old
NEW
$new
"
);
sexhack_log
(
get_option
(
'neew_rewrite_flush'
,
'NOT SET'
));
}
public
static
function
menu
()
public
static
function
menu
()
{
{
...
...
includes/class-gdrive.php
0 → 100644
View file @
5dade490
<?php
/**
*
* This Google Drive API handler class is a custom PHP library to handle the Google Drive API calls.
*
* @class GoogleDriveApi
* @author CodexWorld
* @link http://www.codexworld.com
* @version 1.0
*/
class
GoogleDriveApi
{
const
OAUTH2_TOKEN_URI
=
'https://oauth2.googleapis.com/token'
;
const
DRIVE_FILE_UPLOAD_URI
=
'https://www.googleapis.com/upload/drive/v3/files'
;
const
DRIVE_FILES_URI
=
'https://www.googleapis.com/drive/v3/files/'
;
function
__construct
(
$params
=
array
())
{
if
(
count
(
$params
)
>
0
){
$this
->
initialize
(
$params
);
}
}
function
initialize
(
$params
=
array
())
{
if
(
count
(
$params
)
>
0
){
foreach
(
$params
as
$key
=>
$val
){
if
(
isset
(
$this
->
$key
)){
$this
->
$key
=
$val
;
}
}
}
}
public
function
GetAccessToken
(
$client_id
,
$redirect_uri
,
$client_secret
,
$code
)
{
$curlPost
=
'client_id='
.
$client_id
.
'&redirect_uri='
.
$redirect_uri
.
'&client_secret='
.
$client_secret
.
'&code='
.
$code
.
'&grant_type=authorization_code'
;
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
self
::
OAUTH2_TOKEN_URI
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
FALSE
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$curlPost
);
$data
=
json_decode
(
curl_exec
(
$ch
),
true
);
$http_code
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
if
(
$http_code
!=
200
)
{
$error_msg
=
'Failed to receieve access token'
;
if
(
curl_errno
(
$ch
))
{
$error_msg
=
curl_error
(
$ch
);
}
else
{
$error_msg
=
!
empty
(
$data
[
'error'
][
'message'
])
?
$data
[
'error'
][
'message'
]
:
''
;
}
throw
new
Exception
(
'Error '
.
$http_code
.
': '
.
$error_msg
);
}
return
$data
;
}
public
function
DeleteFile
(
$access_token
,
$file_id
,
$googleOauthURL
=
''
)
{
$apiURL
=
self
::
DRIVE_FILES_URI
.
$file_id
;
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
$apiURL
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
FALSE
);
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
array
(
'Content-Type: application/json'
,
'Authorization: Bearer '
.
$access_token
));
curl_setopt
(
$ch
,
CURLOPT_CUSTOMREQUEST
,
'DELETE'
);
$data
=
json_decode
(
curl_exec
(
$ch
),
true
);
$http_code
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
if
(
$http_code
!=
200
&&
$http_code
!=
204
){
$error_msg
=
'Failed to delete file.'
;
if
(
curl_errno
(
$ch
))
{
$error_msg
=
curl_error
(
$ch
);
}
else
{
$error_msg
=
!
empty
(
$data
[
'error'
][
'message'
])
?
$data
[
'error'
][
'message'
]
:
''
;
}
if
(
$http_code
==
401
&&
!
empty
(
$googleOauthURL
)){
unset
(
$_SESSION
[
'google_access_token'
]);
$error_msg
.=
'<br/>Click to <a href="'
.
$googleOauthURL
.
'">authenticate with Google Drive</a>'
;
}
throw
new
Exception
(
'Error '
.
$http_code
.
': '
.
$error_msg
);
}
else
{
return
true
;
}
}
}
?>
includes/class-integrate-google-drive.php
View file @
5dade490
...
@@ -21,6 +21,10 @@
...
@@ -21,6 +21,10 @@
namespace
wp_SexHackMe
;
namespace
wp_SexHackMe
;
use
\IGD\Account
;
use
\IGD\App
;
// Exit if accessed directly
// Exit if accessed directly
if
(
!
defined
(
'ABSPATH'
)
)
exit
;
if
(
!
defined
(
'ABSPATH'
)
)
exit
;
...
@@ -36,6 +40,11 @@ if(!class_exists('SH_GDrive')) {
...
@@ -36,6 +40,11 @@ if(!class_exists('SH_GDrive')) {
function
get_download_url
(
$file
)
function
get_download_url
(
$file
)
{
{
$active
=
Account
::
get_active_account
();
if
(
!
$active
)
return
$file
;
$account_id
=
$active
[
'id'
];
if
(
!
(
$file
&&
is_string
(
$file
)
&&
strlen
(
$file
)
>
3
))
return
$file
;
if
(
!
(
$file
&&
is_string
(
$file
)
&&
strlen
(
$file
)
>
3
))
return
$file
;
if
(
function_exists
(
'igd_fs'
)
)
if
(
function_exists
(
'igd_fs'
)
)
{
{
...
@@ -52,7 +61,7 @@ if(!class_exists('SH_GDrive')) {
...
@@ -52,7 +61,7 @@ if(!class_exists('SH_GDrive')) {
$parent
=
false
;
$parent
=
false
;
$gfile
=
false
;
$gfile
=
false
;
$success
=
false
;
$success
=
false
;
$igd
=
\IGD\App
::
instance
(
);
$igd
=
App
::
instance
(
$account_id
);
// Try root first
// Try root first
foreach
(
$gparts
as
$k
=>
$part
)
foreach
(
$gparts
as
$k
=>
$part
)
{
{
...
@@ -92,6 +101,16 @@ if(!class_exists('SH_GDrive')) {
...
@@ -92,6 +101,16 @@ if(!class_exists('SH_GDrive')) {
}
else
{
}
else
{
$gdo
=
$igd
->
get_files
(
array
(
'q'
=>
"name='
{
$part
}
"
),
$parent
,
false
);
$gdo
=
$igd
->
get_files
(
array
(
'q'
=>
"name='
{
$part
}
"
),
$parent
,
false
);
}
}
if
(
!
is_array
(
$gdo
)
||
(
count
(
$gdo
)
<
1
)
||
array_key_exists
(
'error'
,
$gdo
))
{
if
(
$k
==
0
)
{
$gdo
=
$igd
->
get_files
(
array
(
'q'
=>
"parents='' and sharedWithMe=true and '
{
$part
}
' in name"
),
'shared'
,
true
);
}
else
{
$gdo
=
$igd
->
get_files
(
array
(
'q'
=>
"name='
{
$part
}
"
),
$parent
,
true
);
}
}
if
(
!
is_array
(
$gdo
)
||
(
count
(
$gdo
)
<
1
)
||
array_key_exists
(
'error'
,
$gdo
))
break
;
if
(
!
is_array
(
$gdo
)
||
(
count
(
$gdo
)
<
1
)
||
array_key_exists
(
'error'
,
$gdo
))
break
;
$parent
=
false
;
$parent
=
false
;
...
...
includes/class-post_types.php
View file @
5dade490
...
@@ -94,25 +94,57 @@ if(!class_exists('SH_PostTypes')) {
...
@@ -94,25 +94,57 @@ if(!class_exists('SH_PostTypes')) {
'supports'
=>
array
(
'title'
,
'thumbnail'
),
//'editor','excerpt','trackbacks','custom-fields','comments','revisions','author','page-attributes'),
'supports'
=>
array
(
'title'
,
'thumbnail'
),
//'editor','excerpt','trackbacks','custom-fields','comments','revisions','author','page-attributes'),
'taxonomies'
=>
array
(),
//'category','post_tag'), // TODO Shouldn't we have a "video_type" taxonomy for VR or flat?
'taxonomies'
=>
array
(),
//'category','post_tag'), // TODO Shouldn't we have a "video_type" taxonomy for VR or flat?
));
));
$DEFAULTSLUG
=
get_option
(
'sexhack_gallery_slug'
,
'v'
);
$projects_structure
=
'/'
.
$DEFAULTSLUG
.
'/%wooprod%/'
;
$rules
=
$wp_rewrite
->
wp_rewrite_rules
();
$rules
=
$wp_rewrite
->
wp_rewrite_rules
();
$DEFAULTSLUG
=
get_option
(
'sexhack_gallery_slug'
,
'v'
);
//sexhack_log($rules);
if
(
!
array_key_exists
(
$DEFAULTSLUG
.
'/([^/]+)/?$'
,
$rules
))
{
if
(
!
array_key_exists
(
$DEFAULTSLUG
.
'/([^/]+)/?$'
,
$rules
))
{
// sexhack_log("REWRITE: rules OK: ".$DEFAULTSLUG.'/([^/]+)/?$ => '.$rules[$DEFAULTSLUG.'/([^/]+)/?$']);
update_option
(
'need_rewrite_flush'
,
1
);
//} else {
sexhack_log
(
"REWRITE: Need to add and flush our rules!"
);
sexhack_log
(
"REWRITE: Need to add and flush our rules!"
);
}
$wp_rewrite
->
add_rewrite_tag
(
"%wooprod%"
,
'([^/]+)'
,
"post_type=sexhack_video&wooprod="
);
}
$wp_rewrite
->
add_rewrite_tag
(
"%videoaccess%"
,
'([^/]+)'
,
"videoaccess="
);
$wp_rewrite
->
add_permastruct
(
$DEFAULTSLUG
,
$projects_structure
,
false
);
$wp_rewrite
->
add_permastruct
(
$DEFAULTSLUG
,
$projects_structure
.
"%videoaccess%/"
,
false
);
update_option
(
'need_rewrite_flush'
,
1
);
}
public
static
function
add_rewrites
()
{
global
$wp_rewrite
;
}
$DEFAULTSLUG
=
get_option
(
'sexhack_gallery_slug'
,
'v'
);
sexhack_log
(
"REWRITE: ADDING RULES"
);
//flush_rewrite_rules();
$pid
=
get_option
(
'sexhack_video_page'
,
false
);
if
(
$pid
)
$redir
=
"page_id=
$pid
"
;
else
$redir
=
"pagename=
$DEFAULTSLUG
"
;
add_rewrite_rule
(
$DEFAULTSLUG
.
'/([^/]+)/([^/]+)/page/?([0-9]{1,})/?$'
,
'index.php?'
.
$redir
.
'&sh_video=$matches[1]&videoaccess=$matches[2]&paged=$matches[3]'
,
'top'
);
add_rewrite_rule
(
$DEFAULTSLUG
.
'/([^/]+)/([^/]+)/?$'
,
'index.php?'
.
$redir
.
'&sh_video=$matches[1]&videoaccess=$matches[2]'
,
'top'
);
add_rewrite_rule
(
$DEFAULTSLUG
.
'/([^/]+)/page/?([0-9]{1,})/?$'
,
'index.php?'
.
$redir
.
'&sh_video=$matches[1]&paged=$matches[2]'
,
'top'
);
add_rewrite_rule
(
$DEFAULTSLUG
.
'/([^/]+)/?$'
,
'index.php?'
.
$redir
.
'&sh_video=$matches[1]'
,
'top'
);
$vg_id
=
get_option
(
'sexhack_video404_page'
,
false
);
//if(is_int($vg_id) && $vg_id>0)
add_rewrite_rule
(
$DEFAULTSLUG
.
'/?$'
,
'index.php?page_id='
.
strval
(
$vg_id
),
'top'
);
//update_option('need_rewrite_flush', 1);
sexhack_log
(
$wp_rewrite
->
wp_rewrite_rules
());
}
}
}
}
}
...
...
includes/class-query.php
View file @
5dade490
...
@@ -198,6 +198,21 @@ if(!class_exists('SH_Query')) {
...
@@ -198,6 +198,21 @@ if(!class_exists('SH_Query')) {
}
}
public
static
function
get_VideoFromSlug
(
$slug
)
{
global
$wpdb
;
$slug
=
$wpdb
->
_real_escape
(
$slug
);
$sql
=
"SELECT * FROM
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videos WHERE slug='"
.
$slug
.
"'"
;
$dbres
=
$wpdb
->
get_results
(
$sql
);
if
(
is_array
(
$dbres
)
&&
count
(
$dbres
)
>
0
)
{
return
new
SH_Video
((
array
)
$dbres
[
0
]);
}
return
false
;
}
public
static
function
get_Video
(
$id
,
$idtype
=
''
)
public
static
function
get_Video
(
$id
,
$idtype
=
''
)
{
{
global
$wpdb
;
global
$wpdb
;
...
@@ -247,13 +262,13 @@ if(!class_exists('SH_Query')) {
...
@@ -247,13 +262,13 @@ if(!class_exists('SH_Query')) {
$results
=
array
();
$results
=
array
();
//$sql = $wpdb->prepare("SELECT * from {$wpdb->prefix}{$prefix}videos");
//$sql = $wpdb->prepare("SELECT * from {$wpdb->prefix}{$prefix}videos");
$sql
=
"SELECT * FROM
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videos"
;
$sql
=
"SELECT * FROM
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videos"
;
$dbres
=
$wpdb
->
get_results
(
$sql
);
$dbres
=
$wpdb
->
get_results
(
$sql
,
ARRAY_A
);
sexhack_log
(
$dbres
);
foreach
(
$dbres
as
$row
)
foreach
(
$dbres
as
$row
)
{
{
$results
[]
=
new
SH_Video
(
$row
);
$results
[]
=
new
SH_Video
(
$row
);
}
}
sexhack_log
(
$results
);
return
$results
;
return
$results
;
...
...
includes/class-shortcodes.php
View file @
5dade490
...
@@ -125,10 +125,15 @@ if(!class_exists('SH_Shortcodes')) {
...
@@ -125,10 +125,15 @@ 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">'
;
$products
=
$sh_videogallery
->
getProducts
();
$videos
=
$sh_videogallery
->
get_videos
();
while
(
$products
->
have_posts
()
)
{
foreach
(
$videos
as
$video
)
$products
->
the_post
();
{
$html
.=
$sh_videogallery
->
get_video_thumb
();
if
(
$video
->
status
==
'published'
)
{
$post
=
$video
->
get_post
();
if
(
$post
)
setup_postdata
(
$post
);
$html
.=
$sh_videogallery
->
get_video_thumb
(
$video
);
}
}
}
wp_reset_postdata
();
wp_reset_postdata
();
$html
.=
"</ul></div>"
;
$html
.=
"</ul></div>"
;
...
...
includes/class-video.php
View file @
5dade490
...
@@ -66,9 +66,9 @@ if(!class_exists('SH_Video')) {
...
@@ -66,9 +66,9 @@ if(!class_exists('SH_Video')) {
'codec_public'
=>
'h264'
,
'codec_public'
=>
'h264'
,
'codec_members'
=>
'h264'
,
'codec_members'
=>
'h264'
,
'codec_premium'
=>
'h264'
,
'codec_premium'
=>
'h264'
,
'acodec_public'
=>
'
h264
'
,
'acodec_public'
=>
'
AAC
'
,
'acodec_members'
=>
'
h264
'
,
'acodec_members'
=>
'
AAC
'
,
'acodec_premium'
=>
'
h264
'
,
'acodec_premium'
=>
'
AAC
'
,
'duration_public'
=>
false
,
'duration_public'
=>
false
,
'duration_members'
=>
false
,
'duration_members'
=>
false
,
'duration_premium'
=>
false
,
'duration_premium'
=>
false
,
...
@@ -87,6 +87,18 @@ if(!class_exists('SH_Video')) {
...
@@ -87,6 +87,18 @@ if(!class_exists('SH_Video')) {
}
}
public
function
get_title
()
{
return
$this
->
attributes
[
'title'
];
}
public
function
has_downloads
()
{
if
(
$this
->
download_public
OR
$this
->
download_members
OR
$this
->
download_premium
)
return
true
;
return
false
;
}
function
setAttributes
(
$attr
,
$post
=
false
,
$wcprod
=
false
)
function
setAttributes
(
$attr
,
$post
=
false
,
$wcprod
=
false
)
{
{
...
...
includes/class-videogallery.php
View file @
5dade490
...
@@ -37,11 +37,11 @@ if(!class_exists('SH_VideoGallery')) {
...
@@ -37,11 +37,11 @@ if(!class_exists('SH_VideoGallery')) {
// TODO What an horrible and inefficient way to cache the query result.
// TODO What an horrible and inefficient way to cache the query result.
// Think about moving it in session and with a better data structure.
// Think about moving it in session and with a better data structure.
$this
->
product
list
=
false
;
$this
->
video
list
=
false
;
// Register Query Vars
// Register Query Vars
add_filter
(
"query_vars"
,
array
(
$this
,
"query_vars"
));
add_filter
(
"query_vars"
,
array
(
$this
,
"query_vars"
));
//
add_filter('page_template', array($this, 'sexhack_video_template'));
add_filter
(
'page_template'
,
array
(
$this
,
'sexhack_video_template'
));
add_filter
(
'archive_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
);
add_action
(
'pre_get_posts'
,
array
(
$this
,
'fix_video_query'
),
1
,
1
);
...
@@ -51,31 +51,32 @@ if(!class_exists('SH_VideoGallery')) {
...
@@ -51,31 +51,32 @@ if(!class_exists('SH_VideoGallery')) {
public
function
query_vars
(
$vars
)
public
function
query_vars
(
$vars
)
{
{
$vars
[]
=
'
wooprod
'
;
$vars
[]
=
'
sh_video
'
;
$vars
[]
=
'videoaccess'
;
$vars
[]
=
'videoaccess'
;
return
$vars
;
return
$vars
;
}
}
public
function
sexhack_video_template
(
$template
)
public
function
sexhack_video_template
(
$template
)
{
{
$template
=
'video.php'
;
if
(
isset
(
$_GET
[
'SHDEV'
]))
$templ
=
'newvideo.php'
;
if
(
isset
(
$_GET
[
'SHDEV'
]))
$template
=
'newvideo.php'
;
$is_sexhack_video
=
get_query_var
(
'sh_video'
,
false
);
$is_sexhack_video
=
get_query_var
(
'wooprod'
,
false
);
if
(
$is_sexhack_video
)
{
if
(
$is_sexhack_video
)
{
$templ
=
'video.php'
;
set_query_var
(
'post_type'
,
'sexhack_video'
);
set_query_var
(
'post_type'
,
'sexhack_video'
);
if
(
file_exists
(
plugin_dir_path
(
__DIR__
)
.
'/templates/'
.
$templ
ate
))
{
if
(
file_exists
(
plugin_dir_path
(
__DIR__
)
.
'/templates/'
.
$templ
))
{
return
plugin_dir_path
(
__DIR__
)
.
'/templates/'
.
$templ
ate
;
return
plugin_dir_path
(
__DIR__
)
.
'/templates/'
.
$templ
;
}
}
}
}
return
$template
;
return
$template
;
}
}
public
function
fix_video_query
(
$query
)
public
function
fix_video_query
(
$query
)
{
{
if
(
$query
->
get
(
'post_type'
)
==
'sexhack_video'
)
{
if
(
$query
->
get
(
'post_type'
)
==
'sexhack_video'
)
{
$
wooprod
=
$query
->
get
(
'wooprod
'
,
false
);
$
sh_video
=
$query
->
get
(
'sh_video
'
,
false
);
if
(
$
wooprod
)
{
if
(
$
sh_video
)
{
$query
->
query
[
'post_type'
]
=
'sexhack_video'
;
$query
->
query
[
'post_type'
]
=
'sexhack_video'
;
$query
->
set
(
'name'
,
esc_sql
(
$wooprod
));
$query
->
set
(
'name'
,
esc_sql
(
$wooprod
));
$query
->
set
(
'post_type'
,
'any'
);
$query
->
set
(
'post_type'
,
'any'
);
...
@@ -84,58 +85,65 @@ if(!class_exists('SH_VideoGallery')) {
...
@@ -84,58 +85,65 @@ if(!class_exists('SH_VideoGallery')) {
}
}
}
}
public
function
getProducts
(
$vcat
=
false
)
{
public
function
get_videos
(
$vcat
=
false
)
{
// XXX TODO Only published videos!
if
(
!
$this
->
productlist
&&
!
$vcat
)
$this
->
productlist
=
SH_Query
::
get_Products
(
$vcat
);
//$this->_getProducts($vcat);
else
if
(
$vcat
)
return
SH_Query
::
get_Products
(
$vcat
);
//$this->_getProducts($vcat);
if
(
!
$this
->
videolist
&&
!
$vcat
)
$this
->
videolist
=
sh_get_videos
(
$vcat
);
//SH_Query::get_Videos($vcat); //$this->_getProducts($vcat);
else
if
(
$vcat
)
return
sh_get_videos
(
$vcat
);
//SH_Query::get_Videos($vcat); //$this->_getProducts($vcat);
return
$this
->
product
list
;
return
$this
->
video
list
;
}
}
public
function
get_video_thumb
()
public
function
get_video_thumb
(
$video
=
false
)
{
{
$DEFAULTSLUG
=
get_option
(
'sexhack_gallery_slug'
,
'v'
);
$DEFAULTSLUG
=
get_option
(
'sexhack_gallery_slug'
,
'v'
);
$id
=
get_the_ID
();
$post_id
=
get_the_ID
();
$prod
=
wc_get_product
(
$id
);
if
(
!
$video
)
$video
=
sh_get_video_from_post
(
$post_id
);
$image
=
get_the_post_thumbnail
(
$id
,
"medium"
,
array
(
"class"
=>
"sexhack_thumbnail"
));
//array("class" => "alignleft sexhack_thumbnail"));
if
(
is_numeric
(
$video
->
thumbnail
))
{
//$image = get_post_thumbnail_id($video->thumbnail);
//$image = wp_get_attachment_link($video->thumbnail);
$image
=
wp_get_attachment_image
(
$video
->
thumbnail
,
"320x160"
);
// XXX Seriously fixed size?
}
else
$image
=
$video
->
thumbnail
;
$hls_public
=
$video
->
hls_public
;
$hls_member
=
$video
->
hls_members
;
$hls_premium
=
$video
->
hls_premium
;
$video_preview
=
$video
->
video_preview
;
$gif_preview
=
$video
->
gif_small
;
sexhack_log
(
$video
);
$hls
=
$prod
->
get_attribute
(
"hls_public"
);
$categories
=
$video
->
get_categories
(
true
);
$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"
);
$categories
=
explode
(
", "
,
html2text
(
wc_get_product_category_list
(
$id
)));
//print_r($categories);
//print_r($categories);
$gif
=
$prod
->
get_attribute
(
"gif_thumbnail"
);
$gif
=
$video
->
gif
;
if
(
!
$gif
)
$gif
=
$gif_preview
;
if
(
$gif
)
$image
.=
"<img src='
$gif
' class='alignleft sexhack_thumb_hover' loading='lazy' />"
;
if
(
!
$gif_preview
)
$gif_preview
=
$gif
;
if
(
$gif_preview
)
$image
.=
"<img src='
$gif_preview
' class='alignleft sexhack_thumb_hover' loading='lazy' />"
;
$html
=
'<li class="product type-product sexhack_thumbli">'
;
$html
=
'<li class="product type-product sexhack_thumbli">'
;
$vurl
=
str_replace
(
"/product/"
,
"/"
.
$DEFAULTSLUG
.
"/"
,
esc_url
(
get_the_permalink
()
));
$vtitle
=
esc_html
(
get_the_title
()
);
$vurl
=
site_url
()
.
esc_url
(
"/"
.
$DEFAULTSLUG
.
"/"
.
$video
->
slug
)
.
"/"
;
if
(
isset
(
$_GET
[
'SHDEV'
]))
$vurl
.=
"?SHDEV=true"
;
$vtitle
=
$video
->
get_title
();
$vtags
=
array
();
$vtags
=
array
();
$downtag
=
''
;
$downtag
=
''
;
if
((
!
$hls
)
AND
(
!
$hls_member
)
AND
(
!
$hls_premium
)
AND
((
$video_preview
)
OR
(
$vr_preview
)))
$vtags
[]
=
'<label class="sexhack_vtag sexhack_preview" style="*LEFT*">preview</label>'
;
if
((
!
$hls_public
)
AND
(
!
$hls_member
)
AND
(
!
$hls_premium
)
AND
(
$video_preview
)
)
$vtags
[]
=
'<label class="sexhack_vtag sexhack_preview" style="*LEFT*">preview</label>'
;
if
((
$hls
)
OR
(
$vr_public
))
$vtags
[]
=
'<label class="sexhack_vtag sexhack_public" style="*LEFT*">public</label>'
;
if
(
$hls_public
)
$vtags
[]
=
'<label class="sexhack_vtag sexhack_public" style="*LEFT*">public</label>'
;
if
((
$hls_member
)
OR
(
$vr_member
))
$vtags
[]
=
'<label class="sexhack_vtag sexhack_members" style="*LEFT*">members</label>'
;
if
(
$hls_member
)
$vtags
[]
=
'<label class="sexhack_vtag sexhack_members" style="*LEFT*">members</label>'
;
if
((
$hls_premium
)
OR
(
$vr_premium
))
$vtags
[]
=
'<label class="sexhack_vtag sexhack_premium" style="*LEFT*">premium</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
(
$video
->
has_downloads
())
$html
.=
'<label class="sexhack_vtag sexhack_download"">download</label>'
;
if
((
$vr_premium
)
OR
(
$vr_member
)
OR
(
$vr_public
)
OR
(
$vr_preview
)
if
(
$video
->
video_type
==
'VR'
)
$html
.=
'<label class="sexhack_vtag sexhack_VR"">VR/3D</label>'
;
OR
((
count
(
$prod
->
get_downloads
())
>
0
)
AND
(
in_array
(
"VR180"
,
$categories
)
OR
in_array
(
"VR360"
,
$categories
))))
$html
.=
'<label class="sexhack_vtag sexhack_VR"">VR/3D</label>'
;
$html
.=
"<a href=
\"
$vurl
\"
class=
\"
woocommerce-LoopProduct-link woocommerce-loop-product__link
\"
>"
;
$html
.=
"<a href=
\"
$vurl
\"
class=
\"
woocommerce-LoopProduct-link woocommerce-loop-product__link
\"
>"
;
$html
.=
"<div class='sexhack_thumb_cont'>"
.
$image
.
"</div>"
;
$html
.=
"<div class='sexhack_thumb_cont'>"
.
$image
.
"</div>"
;
...
...
includes/class-woocommerce-support.php
View file @
5dade490
...
@@ -34,7 +34,7 @@ if(!class_exists("SH_VideoProducts")) {
...
@@ -34,7 +34,7 @@ if(!class_exists("SH_VideoProducts")) {
//add_action('sh_save_video_after_query', array($this, 'sync_product_from_video'), 1, 10);
//add_action('sh_save_video_after_query', array($this, 'sync_product_from_video'), 1, 10);
add_filter
(
'video_before_save'
,
array
(
$this
,
'sync_product_from_video'
));
add_filter
(
'video_before_save'
,
array
(
$this
,
'sync_product_from_video'
));
add_action
(
'sh_delete_video'
,
array
(
$this
,
'delete_video_product'
),
1
,
10
);
add_action
(
'sh_delete_video'
,
array
(
$this
,
'delete_video_product'
),
9
,
1
);
}
}
public
function
delete_video_product
(
$video
)
public
function
delete_video_product
(
$video
)
...
...
includes/functions-utils.php
View file @
5dade490
...
@@ -54,6 +54,7 @@ function sanitize_idtype($idt=false)
...
@@ -54,6 +54,7 @@ function sanitize_idtype($idt=false)
return
$idt
.
"_id"
;
return
$idt
.
"_id"
;
break
;
break
;
case
'id'
:
case
'id'
:
case
'slug'
:
return
$idt
;
return
$idt
;
break
;
break
;
default
:
default
:
...
...
includes/functions-video.php
View file @
5dade490
...
@@ -83,6 +83,11 @@ function sh_get_video_from_product($p)
...
@@ -83,6 +83,11 @@ function sh_get_video_from_product($p)
return
false
;
return
false
;
}
}
function
sh_get_video_from_slug
(
$slug
)
{
return
SH_Query
::
get_VideoFromSlug
(
$slug
);
}
function
sh_get_categories
(
$id
=
false
)
function
sh_get_categories
(
$id
=
false
)
{
{
return
SH_Query
::
get_Categories
(
$id
);
return
SH_Query
::
get_Categories
(
$id
);
...
...
sexhackme.php
View file @
5dade490
...
@@ -463,8 +463,8 @@ if(!class_exists('SexHackMe_Plugin')) {
...
@@ -463,8 +463,8 @@ if(!class_exists('SexHackMe_Plugin')) {
// Check if we need to flush rewrite rules
// Check if we need to flush rewrite rules
add_action
(
'init'
,
array
(
$this
,
'register_flush'
),
10
);
add_action
(
'init'
,
array
(
$this
,
'register_flush'
),
10
);
add_action
(
'init'
,
array
(
$this
,
'flush_rewrite'
),
900
);
add_action
(
'init'
,
array
(
$this
,
'flush_rewrite'
),
11
);
// Enqueue scripts on the front end side. Priority 200 because of WooCommerce.
// Enqueue scripts on the front end side. Priority 200 because of WooCommerce.
add_action
(
'wp_enqueue_scripts'
,
array
(
$this
,
'enqueue_front_end_scripts'
),
200
);
add_action
(
'wp_enqueue_scripts'
,
array
(
$this
,
'enqueue_front_end_scripts'
),
200
);
...
@@ -477,6 +477,7 @@ if(!class_exists('SexHackMe_Plugin')) {
...
@@ -477,6 +477,7 @@ if(!class_exists('SexHackMe_Plugin')) {
// Initialize Custom post_types
// Initialize Custom post_types
add_action
(
'init'
,
array
(
'wp_SexHackMe\SH_PostTypes'
,
'init'
));
add_action
(
'init'
,
array
(
'wp_SexHackMe\SH_PostTypes'
,
'init'
));
add_action
(
'sh_rewrite_flushed'
,
array
(
'wp_SexHackMe\SH_PostTypes'
,
'add_rewrites'
)
);
// Initialize shortcodes
// Initialize shortcodes
add_action
(
'init'
,
array
(
'wp_SexHackMe\SH_Shortcodes'
,
'init'
)
);
add_action
(
'init'
,
array
(
'wp_SexHackMe\SH_Shortcodes'
,
'init'
)
);
...
@@ -531,6 +532,7 @@ if(!class_exists('SexHackMe_Plugin')) {
...
@@ -531,6 +532,7 @@ if(!class_exists('SexHackMe_Plugin')) {
public
function
register_flush
()
public
function
register_flush
()
{
{
register_setting
(
'sexhackme-settings'
,
'need_rewrite_flush'
);
register_setting
(
'sexhackme-settings'
,
'need_rewrite_flush'
);
register_setting
(
'sexhackme-settings'
,
'rewrite_flush_done'
);
}
}
public
function
flush_rewrite
()
public
function
flush_rewrite
()
...
@@ -538,8 +540,10 @@ if(!class_exists('SexHackMe_Plugin')) {
...
@@ -538,8 +540,10 @@ if(!class_exists('SexHackMe_Plugin')) {
if
(
get_option
(
'need_rewrite_flush'
))
if
(
get_option
(
'need_rewrite_flush'
))
{
{
sexhack_log
(
"FLUSHING REWRITE RULES"
);
sexhack_log
(
"FLUSHING REWRITE RULES"
);
flush_rewrite_rules
(
false
);
//flush_rewrite_rules(false);
flush_rewrite_rules
();
update_option
(
'need_rewrite_flush'
,
0
);
update_option
(
'need_rewrite_flush'
,
0
);
do_action
(
'sh_rewrite_flushed'
);
}
}
}
}
...
@@ -644,13 +648,12 @@ if(!class_exists('SexHackMe_Plugin')) {
...
@@ -644,13 +648,12 @@ if(!class_exists('SexHackMe_Plugin')) {
}
}
//if(isset($_GET['SHDEV'])) {
// DEBUG REWRITE RULES
if
(
WP_DEBUG
===
true
){
if
(
WP_DEBUG
===
true
){
// only matched?
// only matched?
//add_action("the_post", 'wp_SexHackMe\debug_rewrite_rules');
//add_action("the_post", 'wp_SexHackMe\debug_rewrite_rules');
//
sexhack_log("REQUEST: ".$_SERVER['REQUEST_URI']." QUERY: ".$_SERVER['QUERY_STRING']. "POST:");
sexhack_log
(
"REQUEST: "
.
$_SERVER
[
'REQUEST_URI'
]
.
" QUERY: "
.
$_SERVER
[
'QUERY_STRING'
]
.
"POST:"
);
//
sexhack_log($_POST);
sexhack_log
(
$_POST
);
}
}
...
...
templates/admin/gallery.php
View file @
5dade490
...
@@ -29,10 +29,50 @@ if ( ! defined( 'ABSPATH' ) ) exit;
...
@@ -29,10 +29,50 @@ if ( ! defined( 'ABSPATH' ) ) exit;
<table
class=
"form-table"
>
<table
class=
"form-table"
>
<tr
align=
"top"
>
<tr
align=
"top"
>
<td>
<td>
<label>
Slug for gallery
</label>
<select
id=
"sexhack_video_page"
name=
"sexhack_video_page"
class=
"widefat"
>
<input
type=
"text"
name=
"sexhack_gallery_slug"
value=
"
<?php
echo
get_option
(
'sexhack_gallery_slug'
,
"v"
)
?>
"
/>
<option
value=
"-1"
>
Choose...
</option>
<?php
$opt
=
get_option
(
"sexhack_video_page"
);
foreach
(
get_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"
>
Select Video page
</p>
</td>
</td>
</tr>
</tr>
<tr
align=
"top"
>
<td>
<select
id=
"sexhack_gallery_page"
name=
"sexhack_gallery_page"
class=
"widefat"
>
<option
value=
"-1"
>
Choose...
</option>
<?php
$opt
=
get_option
(
"sexhack_gallery_page"
);
foreach
(
get_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"
>
Select Gallery page
</p>
</td>
</tr>
<tr
align=
"top"
>
<td>
<select
id=
"sexhack_video404_page"
name=
"sexhack_video404_page"
class=
"widefat"
>
<option
value=
"-1"
>
Choose...
</option>
<?php
$opt
=
get_option
(
"sexhack_video404_page"
);
foreach
(
get_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"
>
Select Gallery page
</p>
</td>
</tr>
</table>
</table>
<?php
submit_button
();
?>
<?php
submit_button
();
?>
</form>
</form>
...
...
templates/video.php
View file @
5dade490
This diff is collapsed.
Click to expand it.
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