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
a9180fc5
Commit
a9180fc5
authored
Jul 06, 2022
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Admin subpages, videogallery slug configurable
parent
96e18356
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
10 deletions
+57
-10
sexhack_gallery.php
classes/sexhack_gallery.php
+57
-10
No files found.
classes/sexhack_gallery.php
View file @
a9180fc5
<?php
<?php
namespace
wp_SexHackMe
;
namespace
wp_SexHackMe
;
$SEXHACK_GALLERY_DEFAULTSLUG
=
'v'
;
if
(
!
class_exists
(
'SexHackVideoGallery'
))
{
if
(
!
class_exists
(
'SexHackVideoGallery'
))
{
// Creating the widget
// Creating the widget
...
@@ -105,6 +110,7 @@ if(!class_exists('SexHackVideoGallery')) {
...
@@ -105,6 +110,7 @@ if(!class_exists('SexHackVideoGallery')) {
add_action
(
'wp_enqueue_scripts'
,
array
(
$this
,
'add_css'
),
200
);
add_action
(
'wp_enqueue_scripts'
,
array
(
$this
,
'add_css'
),
200
);
add_shortcode
(
"sexgallery"
,
array
(
$this
,
"sexgallery_shortcode"
));
add_shortcode
(
"sexgallery"
,
array
(
$this
,
"sexgallery_shortcode"
));
add_action
(
'init'
,
array
(
$this
,
"register_sexhack_video_post_type"
));
add_action
(
'init'
,
array
(
$this
,
"register_sexhack_video_post_type"
));
add_action
(
'admin_init'
,
array
(
$this
,
"register_settings"
));
//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'
));
...
@@ -114,6 +120,25 @@ if(!class_exists('SexHackVideoGallery')) {
...
@@ -114,6 +120,25 @@ if(!class_exists('SexHackVideoGallery')) {
}
}
public
function
register_settings
()
{
add_settings_section
(
'sexhackme-gallery-settings'
,
' '
,
array
(
$this
,
'settings_section'
),
'sexhackme-gallery-settings'
);
register_setting
(
'sexhackme-gallery-settings'
,
'sexhack_gallery_slug'
);
add_settings_field
(
'sexhack_gallery_slug'
,
'sexhack_gallery_slug'
,
'sexhack_gallery_slug'
,
array
(
$this
,
'settings_field'
),
'sexhackme-gallery-settings'
,
'sexhackme-gallery-settings'
,
'sexhack_gallery_slug'
);
}
public
function
settings_section
()
{
echo
"<h2>SexHackMe Gallery Settings</h2>"
;
}
public
function
settings_field
(
$name
)
{
echo
$name
;
}
public
function
check_rewrite
(
$rules
)
public
function
check_rewrite
(
$rules
)
{
{
// TODO Check if our rules are present and call flush if not
// TODO Check if our rules are present and call flush if not
...
@@ -166,8 +191,8 @@ if(!class_exists('SexHackVideoGallery')) {
...
@@ -166,8 +191,8 @@ if(!class_exists('SexHackVideoGallery')) {
// sets custom post type
// sets custom post type
// 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 /
v
/nomevideo/ finisce sul corrispettivo prodotto woocommerce,
// Ideally /
$DEFAULTSLUG
/nomevideo/ finisce sul corrispettivo prodotto woocommerce,
// /
v
/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
...
@@ -175,6 +200,10 @@ if(!class_exists('SexHackVideoGallery')) {
...
@@ -175,6 +200,10 @@ if(!class_exists('SexHackVideoGallery')) {
public
function
register_sexhack_video_post_type
()
public
function
register_sexhack_video_post_type
()
{
{
global
$wp_rewrite
;
global
$wp_rewrite
;
global
$SEXHACK_GALLERY_DEFAULTSLUG
;
$DEFAULTSLUG
=
get_option
(
'sexhack_gallery_slug'
,
$SEXHACK_GALLERY_DEFAULTSLUG
);
sexhack_log
(
"REGISTER SEXHACK_VIDEO "
);
sexhack_log
(
"REGISTER SEXHACK_VIDEO "
);
...
@@ -194,14 +223,14 @@ if(!class_exists('SexHackVideoGallery')) {
...
@@ -194,14 +223,14 @@ if(!class_exists('SexHackVideoGallery')) {
// there are a lot more available arguments, but the above is plenty for now
// there are a lot more available arguments, but the above is plenty for now
));
));
$projects_structure
=
'/
v
/%wooprod%/'
;
$projects_structure
=
'/
'
.
$DEFAULTSLUG
.
'
/%wooprod%/'
;
$rules
=
$wp_rewrite
->
wp_rewrite_rules
();
$rules
=
$wp_rewrite
->
wp_rewrite_rules
();
if
(
array_key_exists
(
'v
/([^/]+)/?$'
,
$rules
))
{
if
(
array_key_exists
(
$DEFAULTSLUG
.
'
/([^/]+)/?$'
,
$rules
))
{
sexhack_log
(
"REWRITE: rules OK: "
.
'v/([^/]+)/?$ => '
.
$rules
[
'v
/([^/]+)/?$'
]);
sexhack_log
(
"REWRITE: rules OK: "
.
$DEFAULTSLUG
.
'/([^/]+)/?$ => '
.
$rules
[
$DEFAULTSLUG
.
'
/([^/]+)/?$'
]);
}
else
{
}
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
(
"%wooprod%"
,
'([^/]+)'
,
"post_type=sexhack_video&wooprod="
);
$wp_rewrite
->
add_permastruct
(
'v'
,
$projects_structure
,
false
);
$wp_rewrite
->
add_permastruct
(
$DEFAULTSLUG
,
$projects_structure
,
false
);
update_option
(
'need_rewrite_flush'
,
1
);
update_option
(
'need_rewrite_flush'
,
1
);
}
}
...
@@ -317,6 +346,10 @@ if(!class_exists('SexHackVideoGallery')) {
...
@@ -317,6 +346,10 @@ if(!class_exists('SexHackVideoGallery')) {
public
function
get_video_thumb
()
public
function
get_video_thumb
()
{
{
global
$SEXHACK_GALLERY_DEFAULTSLUG
;
$DEFAULTSLUG
=
get_option
(
'sexhack_gallery_slug'
,
$SEXHACK_GALLERY_DEFAULTSLUG
);
$id
=
get_the_ID
();
$id
=
get_the_ID
();
$prod
=
wc_get_product
(
$id
);
$prod
=
wc_get_product
(
$id
);
$image
=
get_the_post_thumbnail
(
$id
,
"medium"
,
array
(
"class"
=>
"sexhack_thumbnail"
));
//array("class" => "alignleft sexhack_thumbnail"));
$image
=
get_the_post_thumbnail
(
$id
,
"medium"
,
array
(
"class"
=>
"sexhack_thumbnail"
));
//array("class" => "alignleft sexhack_thumbnail"));
...
@@ -340,7 +373,7 @@ if(!class_exists('SexHackVideoGallery')) {
...
@@ -340,7 +373,7 @@ if(!class_exists('SexHackVideoGallery')) {
if
(
$gif
)
$image
.=
"<img src='
$gif
' class='alignleft sexhack_thumb_hover' loading='lazy' />"
;
if
(
$gif
)
$image
.=
"<img src='
$gif
' 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/"
,
"/
v
/"
,
esc_url
(
get_the_permalink
()
));
$vurl
=
str_replace
(
"/product/"
,
"/
"
.
$DEFAULTSLUG
.
"
/"
,
esc_url
(
get_the_permalink
()
));
$vtitle
=
esc_html
(
get_the_title
()
);
$vtitle
=
esc_html
(
get_the_title
()
);
$vtags
=
array
();
$vtags
=
array
();
...
@@ -377,9 +410,23 @@ if(!class_exists('SexHackVideoGallery')) {
...
@@ -377,9 +410,23 @@ if(!class_exists('SexHackVideoGallery')) {
function
gallery_adminpage
()
function
gallery_adminpage
()
{
{
global
$SEXHACK_GALLERY_DEFAULTSLUG
;
$DEFAULTSLUG
=
$SEXHACK_GALLERY_DEFAULTSLUG
;
?>
?>
<div
class=
"wrap"
>
<div
class=
"wrap"
>
<h2>
SexHackMe Gallery Settings
</h2>
<?php
do_settings_sections
(
'sexhackme-gallery-settings'
);
?>
<form
method=
"post"
action=
"/wp-admin/options.php"
>
<?php
settings_fields
(
'sexhackme-gallery-settings'
);
?>
<table
class=
"form-table"
>
<tr
align=
"top"
>
<td>
<label>
Slug for gallery
</label>
<input
type=
"text"
name=
"sexhack_gallery_slug"
value=
"
<?php
echo
get_option
(
'sexhack_gallery_slug'
,
"
$DEFAULTSLUG
"
)
?>
"
/>
</td>
</tr>
</table>
<?php
submit_button
();
?>
</form>
</div>
</div>
<?php
<?php
}
}
...
...
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