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
d99c6003
Commit
d99c6003
authored
Jul 23, 2022
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Video post type complete
parent
1d64494d
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
196 additions
and
6 deletions
+196
-6
class-meta-box.php
includes/class-meta-box.php
+1
-0
class-query.php
includes/class-query.php
+50
-0
class-video.php
includes/class-video.php
+26
-1
functions-forms-save.php
includes/functions-forms-save.php
+16
-0
functions-utils.php
includes/functions-utils.php
+4
-0
functions-video.php
includes/functions-video.php
+19
-2
sexhackme_admin.js
js/sexhackme_admin.js
+1
-0
sexhackme.php
sexhackme.php
+2
-2
metabox_model.php
templates/admin/metabox_model.php
+65
-1
metabox_video.php
templates/admin/metabox_video.php
+12
-0
No files found.
includes/class-meta-box.php
View file @
d99c6003
...
@@ -80,6 +80,7 @@ if(!class_exists('SH_MetaBox')) {
...
@@ -80,6 +80,7 @@ if(!class_exists('SH_MetaBox')) {
$video
=
new
SH_Video
();
$video
=
new
SH_Video
();
$video
->
post_id
=
$post
->
ID
;
$video
->
post_id
=
$post
->
ID
;
$video
->
post
=
$post
;
$video
->
post
=
$post
;
$video
->
get_guests
(
true
);
}
}
sh_get_template
(
"admin/metabox_model.php"
,
array
(
'video'
=>
$video
,
'post'
=>
$post
));
sh_get_template
(
"admin/metabox_model.php"
,
array
(
'video'
=>
$video
,
'post'
=>
$post
));
}
}
...
...
includes/class-query.php
View file @
d99c6003
...
@@ -94,6 +94,9 @@ if(!class_exists('SH_Query')) {
...
@@ -94,6 +94,9 @@ if(!class_exists('SH_Query')) {
{
$fields
}
{
$fields
}
WHERE
WHERE
id =
{
$video
->
id
}
;"
;
id =
{
$video
->
id
}
;"
;
$sqlarr
[]
=
"DELETE FROM
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videoguests_assoc
WHERE
video_id =
{
$video
->
id
}
;"
;
$sqlarr
[]
=
"DELETE FROM
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videotags_assoc
$sqlarr
[]
=
"DELETE FROM
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videotags_assoc
WHERE
WHERE
video_id =
{
$video
->
id
}
;"
;
video_id =
{
$video
->
id
}
;"
;
...
@@ -140,6 +143,13 @@ if(!class_exists('SH_Query')) {
...
@@ -140,6 +143,13 @@ if(!class_exists('SH_Query')) {
}
}
}
}
foreach
(
$video
->
get_guests
()
as
$guest
)
{
$sqlarr
[]
=
"INSERT INTO
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videoguests_assoc
(user_id, video_id)
VALUES
('
{
$guest
->
ID
}
', '
{
$video
->
id
}
');"
;
}
foreach
(
$sqlarr
as
$sql
)
foreach
(
$sqlarr
as
$sql
)
{
{
//sexhack_log($sql);
//sexhack_log($sql);
...
@@ -148,6 +158,8 @@ if(!class_exists('SH_Query')) {
...
@@ -148,6 +158,8 @@ if(!class_exists('SH_Query')) {
}
}
do_action
(
"sh_save_video_after_query"
,
$video
);
do_action
(
"sh_save_video_after_query"
,
$video
);
//sexhack_log($video);
//sexhack_log($sqlarr);
return
$video
;
return
$video
;
}
}
...
@@ -169,6 +181,9 @@ if(!class_exists('SH_Query')) {
...
@@ -169,6 +181,9 @@ if(!class_exists('SH_Query')) {
$sqlarr
=
array
();
$sqlarr
=
array
();
$sqlarr
[]
=
"DELETE FROM
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videoguests_assoc WHERE video_id IN (
SELECT id FROM
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videos
WHERE
{
$idtype
}
="
.
intval
(
$id
)
.
" );"
;
$sqlarr
[]
=
"DELETE FROM
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videotags_assoc WHERE video_id IN (
$sqlarr
[]
=
"DELETE FROM
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videotags_assoc WHERE video_id IN (
SELECT id FROM
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videos
SELECT id FROM
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videos
WHERE
{
$idtype
}
="
.
intval
(
$id
)
.
" );"
;
WHERE
{
$idtype
}
="
.
intval
(
$id
)
.
" );"
;
...
@@ -277,6 +292,41 @@ if(!class_exists('SH_Query')) {
...
@@ -277,6 +292,41 @@ if(!class_exists('SH_Query')) {
return
false
;
return
false
;
}
}
public
static
function
get_Video_Guests
(
$vid
)
{
global
$wpdb
;
$sql
=
"SELECT user_id FROM
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videoguests_assoc WHERE video_id="
.
intval
(
$vid
)
.
" ;"
;
$dbres
=
$wpdb
->
get_results
(
$sql
);
$guests
=
array
();
if
(
$dbres
&&
count
(
$dbres
)
>
0
)
{
foreach
(
$dbres
as
$ures
)
{
$udata
=
get_userdata
(
$ures
->
user_id
);
if
(
$udata
)
$guests
[
$uid
]
=
$udata
;
}
}
if
(
count
(
$guests
)
>
0
)
return
$guests
;
return
false
;
}
public
static
function
delete_Guests_assoc
(
$id
,
$idtype
)
{
global
$wpdb
;
if
(
!
is_integer
(
$id
))
return
;
$idtype
=
sanitize_idtype
(
$idtype
);
if
(
!
in_array
(
$idtype
,
array
(
'id'
,
'user_id'
,
'video_id'
)))
return
false
;
$sql
=
"DELETE FROM
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videoguests_assoc WHERE
{
$idtpe
}
=
{
$id
}
"
;
return
$wpdb
->
query
(
$sql
);
}
public
static
function
get_Video_Categories
(
$vid
)
public
static
function
get_Video_Categories
(
$vid
)
{
{
global
$wpdb
;
global
$wpdb
;
...
...
includes/class-video.php
View file @
d99c6003
...
@@ -174,6 +174,31 @@ if(!class_exists('SH_Video')) {
...
@@ -174,6 +174,31 @@ if(!class_exists('SH_Video')) {
return
true
;
return
true
;
}
}
public
function
add_guest
(
$guest
)
{
if
(
!
is_object
(
$guest
))
return
false
;
if
(
!
isset
(
$this
->
attributes
[
'guests'
]))
$this
->
attributes
[
'guests'
]
=
array
();
$this
->
attributes
[
'guests'
][
$guest
->
ID
]
=
$guest
;
}
public
function
get_guests
(
$usedb
=
true
)
{
if
(
isset
(
$this
->
attributes
[
'guests'
]))
return
$this
->
guests
;
sexhack_log
(
"(TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT"
);
$this
->
attributes
[
'guests'
]
=
array
();
if
(
$usedb
)
{
$guests
=
sh_get_video_guests
(
$this
->
id
);
if
(
$guests
)
{
foreach
(
$guests
as
$guest
)
$this
->
attributes
[
'guests'
][
$guest
->
ID
]
=
$cat
;
}
}
return
$this
->
guests
;
}
public
function
get_categories
(
$usedb
=
true
)
public
function
get_categories
(
$usedb
=
true
)
{
{
if
(
isset
(
$this
->
attributes
[
'categories'
]))
return
$this
->
categories
;
if
(
isset
(
$this
->
attributes
[
'categories'
]))
return
$this
->
categories
;
...
@@ -239,7 +264,7 @@ if(!class_exists('SH_Video')) {
...
@@ -239,7 +264,7 @@ if(!class_exists('SH_Video')) {
foreach
(
$this
->
attributes
as
$k
=>
$v
)
foreach
(
$this
->
attributes
as
$k
=>
$v
)
{
{
if
((
$v
!==
false
)
&&
!
in_array
(
$k
,
array
(
'id'
,
'post'
,
'product'
,
'tags'
,
if
((
$v
!==
false
)
&&
!
in_array
(
$k
,
array
(
'id'
,
'post'
,
'product'
,
'tags'
,
'categories'
,
'tagsnames'
,
'created'
,
'updated'
,
'sells'
,
'categories'
,
'tagsnames'
,
'created'
,
'updated'
,
'sells'
,
'guests'
,
'views_public'
,
'views_members'
,
'views_premium'
))
)
$r
[
$k
]
=
$v
;
'views_public'
,
'views_members'
,
'views_premium'
))
)
$r
[
$k
]
=
$v
;
}
}
return
$r
;
return
$r
;
...
...
includes/functions-forms-save.php
View file @
d99c6003
...
@@ -183,6 +183,22 @@ function save_sexhack_video_meta_box_data( $post_id )
...
@@ -183,6 +183,22 @@ function save_sexhack_video_meta_box_data( $post_id )
}
}
// Video Guests
if
(
array_key_exists
(
'vguests'
,
$_POST
)
&&
is_array
(
$_POST
[
'vguests'
]))
{
foreach
(
$_POST
[
'vguests'
]
as
$guest_id
)
{
if
(
is_numeric
(
$guest_id
)
&&
intval
(
$guest_id
)
>
0
)
{
$guest
=
get_userdata
(
intval
(
$guest_id
));
if
(
$guest
)
$video
->
add_guest
(
$guest
);
}
}
}
// Make sure the guestss array is initialized
$video
->
get_guests
(
false
);
// Video Categories
// Video Categories
if
(
array_key_exists
(
'vcategory'
,
$_POST
)
&&
is_array
(
$_POST
[
'vcategory'
]))
if
(
array_key_exists
(
'vcategory'
,
$_POST
)
&&
is_array
(
$_POST
[
'vcategory'
]))
{
{
...
...
includes/functions-utils.php
View file @
d99c6003
...
@@ -47,6 +47,10 @@ function sanitize_idtype($idt=false)
...
@@ -47,6 +47,10 @@ function sanitize_idtype($idt=false)
{
{
case
'post'
:
case
'post'
:
case
'product'
:
case
'product'
:
case
'cat'
:
case
'video'
:
case
'user'
:
case
'tag'
:
return
$idt
.
"_id"
;
return
$idt
.
"_id"
;
break
;
break
;
case
'id'
:
case
'id'
:
...
...
includes/functions-video.php
View file @
d99c6003
...
@@ -31,6 +31,7 @@ function sh_save_video($video)
...
@@ -31,6 +31,7 @@ function sh_save_video($video)
// Get from database active if not cached already.
// Get from database active if not cached already.
$video
->
get_categories
(
true
);
$video
->
get_categories
(
true
);
$video
->
get_tags
(
true
);
$video
->
get_tags
(
true
);
$video
->
get_guests
(
true
);
return
SH_Query
::
save_Video
(
$video
);
return
SH_Query
::
save_Video
(
$video
);
}
}
return
false
;
return
false
;
...
@@ -94,6 +95,14 @@ function sh_get_video_categories($v)
...
@@ -94,6 +95,14 @@ function sh_get_video_categories($v)
return
false
;
return
false
;
}
}
function
sh_get_video_guests
(
$v
)
{
if
(
is_numeric
(
$v
)
and
$v
>
0
)
return
SH_Query
::
get_Video_Guests
(
$v
);
else
if
(
is_object
(
$v
))
return
SH_Query
::
get_Video_Guests
(
$v
->
ID
);
return
false
;
}
function
sh_get_video_tags
(
$v
)
function
sh_get_video_tags
(
$v
)
{
{
if
(
is_numeric
(
$v
)
and
$v
>
0
)
return
SH_Query
::
get_Video_Tags
(
$v
);
if
(
is_numeric
(
$v
)
and
$v
>
0
)
return
SH_Query
::
get_Video_Tags
(
$v
);
...
@@ -109,14 +118,22 @@ function sh_get_tag_by_name($name, $create=false)
...
@@ -109,14 +118,22 @@ function sh_get_tag_by_name($name, $create=false)
function
sh_delete_tags_from_video
(
$v
)
function
sh_delete_tags_from_video
(
$v
)
{
{
if
(
is_numeric
(
$v
)
and
$v
>
0
)
return
SH_Query
::
delete_Tags_assoc
(
$v
,
'video_id'
);
if
(
is_numeric
(
$v
)
and
$v
>
0
)
return
SH_Query
::
delete_Tags_assoc
(
$v
,
'video_id'
);
else
if
(
is_object
(
$v
))
return
SH_Query
::
get_
Video_Tags
(
$v
->
id
,
'video_id'
);
else
if
(
is_object
(
$v
))
return
SH_Query
::
get_
delete_Tags_assoc
(
$v
->
id
,
'video_id'
);
return
false
;
return
false
;
}
}
function
sh_delete_guests_from_video
(
$v
)
{
if
(
is_numeric
(
$v
)
and
$v
>
0
)
return
SH_Query
::
delete_Guests_assoc
(
$v
,
'video_id'
);
else
if
(
is_object
(
$v
))
return
SH_Query
::
delete_Guests_assoc
(
$v
->
id
,
'video_id'
);
return
false
;
}
function
sh_delete_categories_from_video
(
$v
)
function
sh_delete_categories_from_video
(
$v
)
{
{
if
(
is_numeric
(
$v
)
and
$v
>
0
)
return
SH_Query
::
delete_Categories_assoc
(
$v
,
'video_id'
);
if
(
is_numeric
(
$v
)
and
$v
>
0
)
return
SH_Query
::
delete_Categories_assoc
(
$v
,
'video_id'
);
else
if
(
is_object
(
$v
))
return
SH_Query
::
get_Categories_Tags
(
$v
->
id
,
'video_id'
);
else
if
(
is_object
(
$v
))
return
SH_Query
::
delete_Categories_assoc
(
$v
->
id
,
'video_id'
);
return
false
;
return
false
;
}
}
...
...
js/sexhackme_admin.js
View file @
d99c6003
...
@@ -2,6 +2,7 @@ jQuery(document).ready(function($) {
...
@@ -2,6 +2,7 @@ jQuery(document).ready(function($) {
$
(
"#sh_admin_tabs .hidden"
).
removeClass
(
'hidden'
);
$
(
"#sh_admin_tabs .hidden"
).
removeClass
(
'hidden'
);
$
(
"#sh_admin_tabs"
).
tabs
({
'active'
:
0
});
$
(
"#sh_admin_tabs"
).
tabs
({
'active'
:
0
});
// ::: TAGS BOX
// ::: TAGS BOX
$
(
"#shvtags input"
).
on
({
$
(
"#shvtags input"
).
on
({
focusout
:
function
()
{
focusout
:
function
()
{
...
...
sexhackme.php
View file @
d99c6003
...
@@ -649,8 +649,8 @@ if(!class_exists('SexHackMe_Plugin')) {
...
@@ -649,8 +649,8 @@ if(!class_exists('SexHackMe_Plugin')) {
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/metabox_model.php
View file @
d99c6003
...
@@ -22,11 +22,26 @@
...
@@ -22,11 +22,26 @@
// Exit if accessed directly
// Exit if accessed directly
if
(
!
defined
(
'ABSPATH'
)
)
exit
;
if
(
!
defined
(
'ABSPATH'
)
)
exit
;
?>
?>
<script
type=
"text/javascript"
>
window
.
guestChange
=
function
(
trig
)
{
if
(
trig
.
value
>
0
)
{
var
newsel
=
$
(
'.guest_selection'
).
clone
();
newsel
.
insertAfter
(
$
(
'.guest_list p'
).
last
());
newsel
.
show
()
newsel
.
removeClass
(
'guest_selection'
);
}
else
{
$
(
'.guest_list p'
).
last
().
remove
();
}
}
</script>
<div
class=
"wrap"
>
<div
class=
"wrap"
>
<table
class=
"form-table"
>
<table
class=
"form-table"
>
<tr
align=
"top"
>
<tr
align=
"top"
>
<td>
<td>
<p><label>
Select user
</label></p>
<p><label>
Select
Model
user
</label></p>
<?php
// XXX When this will be with thousands of model will definely not scale! ?>
<?php
// XXX When this will be with thousands of model will definely not scale! ?>
<
select
name
=
'video_model'
>
<
select
name
=
'video_model'
>
<?
php
<?
php
...
@@ -40,6 +55,55 @@ if ( ! defined( 'ABSPATH' ) ) exit;
...
@@ -40,6 +55,55 @@ if ( ! defined( 'ABSPATH' ) ) exit;
</select>
</select>
</td>
</td>
</tr>
</tr>
<tr
align=
"top"
>
<td
class=
'guest_list'
>
<p
style=
"display:none"
class=
"guest_selection"
>
<select
name=
'vguests[]'
onchange=
'javascript:guestChange(this);'
>
<option
value=
"0"
>
NO GUEST
</option>
<?php
foreach
(
$models
as
$user
)
{
echo
"<option value='"
.
$user
->
ID
.
"' "
;
echo
'>'
.
$user
->
user_login
.
" (id:"
.
$user
->
ID
.
")</option>"
;
}
?>
</select>
</p>
<p>
<p><label>
Add guest model
</label></p>
<?php
// XXX When this will be with thousands of model will definely not scale! ?>
<
select
name
=
'vguests[]'
onchange
=
'javascript:guestChange(this);'
>
<
option
value
=
"0"
>
NO
GUEST
</
option
>
<?
php
foreach
(
$models
as
$user
)
{
echo
"<option value='"
.
$user
->
ID
.
"' "
;
echo
'>'
.
$user
->
user_login
.
" (id:"
.
$user
->
ID
.
")</option>"
;
}
?>
</select>
</p>
<?php
foreach
(
$video
->
get_guests
(
true
)
as
$uid
=>
$guest
)
{
?>
<p>
<select
name=
'vguests[]'
onchange=
'javascript:guestChange(this);'
>
<option
value=
"0"
>
NO GUEST
</option>
<?php
foreach
(
$models
as
$user
)
{
echo
"<option value='"
.
$user
->
ID
.
"' "
;
if
(
$uid
==
$user
->
ID
)
echo
"selected"
;
echo
'>'
.
$user
->
user_login
.
" (id:"
.
$user
->
ID
.
")</option>"
;
}
?>
</select>
</p>
<?php
}
?>
</td>
</tr>
</table>
</table>
</div>
</div>
templates/admin/metabox_video.php
View file @
d99c6003
...
@@ -24,6 +24,18 @@ if ( ! defined( 'ABSPATH' ) ) exit;
...
@@ -24,6 +24,18 @@ if ( ! defined( 'ABSPATH' ) ) exit;
// This is a dirty trick to hide the Visibility section in the publish metabox.
// This is a dirty trick to hide the Visibility section in the publish metabox.
echo
'<style>div#visibility.misc-pub-section.misc-pub-visibility{display:none}</style>'
;
echo
'<style>div#visibility.misc-pub-section.misc-pub-visibility{display:none}</style>'
;
if
(
$video
->
product_id
>
0
)
{
//$prod = wc_get_product($video->product_id);
$wcprodlink
=
site_url
()
.
"/wp-admin/post.php?post="
.
$video
->
product_id
.
"&action=edit"
;
?>
<p>
<label>
WooCommerce Product:
</label>
<a
href=
'
<?php
echo
$wcprodlink
;
?>
'
>
<?php
echo
$wcprodlink
;
?>
</a>
</p>
<?php
}
?>
?>
<p>
<p>
<h4>
Video description
</h4>
<h4>
Video description
</h4>
...
...
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