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
14b9c1dd
Commit
14b9c1dd
authored
Jul 16, 2022
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Almost there...
parent
77988842
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
216 additions
and
296 deletions
+216
-296
functions-gallery.php
includes/admin/functions-gallery.php
+38
-0
functions-sexhackme.php
includes/admin/functions-sexhackme.php
+3
-0
class-admin.php
includes/class-admin.php
+9
-4
class-post_types.php
includes/class-post_types.php
+55
-0
class-videogallery.php
includes/class-videogallery.php
+12
-197
class-widgets.php
includes/class-widgets.php
+92
-0
sexhackme.php
sexhackme.php
+7
-95
No files found.
includes/admin/functions-gallery.php
0 → 100644
View file @
14b9c1dd
<?php
/**
* Copyright: 2022 (c)Franco (nextime) Lanza <franco@nexlab.it>
* License: GNU/GPL version 3.0
*
* This file is part of SexHackMe Wordpress Plugin.
*
* SexHackMe Wordpress Plugin is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* SexHackMe Wordpress Plugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SexHackMe Wordpress Plugin. If not, see <https://www.gnu.org/licenses/>.
*/
namespace
wp_SexHackMe
;
// Exit if accessed directly
if
(
!
defined
(
'ABSPATH'
)
)
exit
;
function
gallery_adminpage
()
{
sh_get_template
(
'admin/gallery.php'
);
}
function
gallery_settings_section
()
{
echo
"<h2>SexHackMe Gallery Settings</h2>"
;
}
?>
includes/admin/functions-sexhackme.php
View file @
14b9c1dd
...
...
@@ -29,5 +29,8 @@ function sexhackme_settings_section() {
echo
"<h3></h3>"
;
}
function
sexhackme_admin_page
()
sh_get_template
(
'admin/sexhackme.php'
));
}
?>
includes/class-admin.php
View file @
14b9c1dd
...
...
@@ -31,9 +31,9 @@ if(!class_exists('SH_Admin')) {
public
static
function
init
()
{
// Add general settings section
add_settings_section
(
'sexhackme-settings'
,
' '
,
'wp_SexHackMe\sexhackme_settings_section'
,
'sexhackme-settings'
);
// Add WC-PMS_Integration settings
if
(
file_exists
(
SH_PLUGIN_DIR_PATH
.
'includes/admin/functions-wcpms.php'
)
)
{
...
...
@@ -65,19 +65,24 @@ if(!class_exists('SH_Admin')) {
if
(
file_exists
(
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'
);
register_setting
(
'sexhackme-gallery-settings'
,
'sexhack_gallery_slug'
);
}
}
public
static
function
menu
()
{
//add_menu_page('SexHackMe Settings', 'SexHackMe', 'manage_options', 'sexhackme-settings',
// array($this, 'admin_page'), SH_PLUGIN_DIR_URL .'img/admin_icon.png', 31);
add_menu_page
(
'SexHackMe Settings'
,
'SexHackMe'
,
'manage_options'
,
'sexhackme-settings'
,
'wp_SexHackMe\sexhackme_admin_page'
,
SH_PLUGIN_DIR_URL
.
'img/admin_icon.png'
,
31
);
// Add The main page again cause with multiple subpages apparently we need to do it.
add_submenu_page
(
'sexhackme-settings'
,
'SexHackMe Settings'
,
'Module
s'
,
add_submenu_page
(
'sexhackme-settings'
,
'SexHackMe Settings'
,
'General Setting
s'
,
'manage_options'
,
'sexhackme-settings'
);
// TODO We don't have a main page yet, so, remove it.
remove_submenu_page
(
'sexhackme-settings'
,
'sexhackme-settings'
);
// Add page WC-PMS_Integration
if
(
file_exists
(
SH_PLUGIN_DIR_PATH
.
'includes/admin/functions-wcpms.php'
)
)
{
...
...
includes/class-post_types.php
View file @
14b9c1dd
...
...
@@ -31,6 +31,8 @@ if(!class_exists('SH_PostTypes')) {
public
static
function
init
()
{
// For some pages we need to add also rewrite rules
global
$wp_rewrite
;
// Advertising
register_post_type
(
'sexhackadv'
,
array
(
...
...
@@ -53,6 +55,59 @@ if(!class_exists('SH_PostTypes')) {
add_filter
(
'manage_sexhackadv_posts_columns'
,
'wp_SexHackMe\advert_add_id_column'
,
5
);
add_action
(
'manage_sexhackadv_posts_custom_column'
,
'wp_SexHackMe\advert_id_column_content'
,
5
,
2
);
// SexHack Videos
// TODO: the idea is to have custom post type for models profiles and for videos.
// Ideally /$DEFAULTSLUG/nomevideo/ finisce sul corrispettivo prodotto woocommerce,
// /$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
// per ogni pagina sexhack_video che credo, sincronizzare prodotti e video pagine, gestire prodotti con lo stesso nome
// ( credo si possa fare dandogli differenti slugs )
register_post_type
(
'sexhack_video'
,
array
(
'labels'
=>
array
(
'name'
=>
'Videos'
,
'singular_name'
=>
'Video'
,
'add_new'
=>
'Add New'
,
'add_new_item'
=>
'Add New Video'
,
'edit_item'
=>
'Edit Video'
,
'not_found'
=>
'There are no videos yet'
,
'not_found_in_trash'
=>
'Nothing found in Trash'
,
'search_items'
=>
'Search videos'
,
),
'description'
=>
'Videos for SexHack.me gallery'
,
'public'
=>
true
,
//'register_meta_box_cb' => array($this, 'sexhack_video_metaboxes'), // XXX BUG We need this NOW!!
'show_ui'
=>
true
,
'show_in_menu'
=>
true
,
'show_in_rest'
=>
true
,
'menu_position'
=>
32
,
'capability_type'
=>
'post'
,
// TODO Maybe We should create our own cap type?
// 'capabilities' => array(), // Or just select specific capabilities here
'hierarchical'
=>
true
,
'publicly_queryable'
=>
true
,
'rewrite'
=>
false
,
'query_var'
=>
true
,
'has_archive'
=>
true
,
'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?
));
$DEFAULTSLUG
=
get_option
(
'sexhack_gallery_slug'
,
'v'
);
$projects_structure
=
'/'
.
$DEFAULTSLUG
.
'/%wooprod%/'
;
$rules
=
$wp_rewrite
->
wp_rewrite_rules
();
if
(
array_key_exists
(
$DEFAULTSLUG
.
'/([^/]+)/?$'
,
$rules
))
{
sexhack_log
(
"REWRITE: rules OK: "
.
$DEFAULTSLUG
.
'/([^/]+)/?$ => '
.
$rules
[
$DEFAULTSLUG
.
'/([^/]+)/?$'
]);
}
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_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
);
}
}
...
...
deprecated/sexhack_
gallery.php
→
includes/class-video
gallery.php
View file @
14b9c1dd
...
...
@@ -22,113 +22,26 @@
namespace
wp_SexHackMe
;
$SEXHACK_GALLERY_DEFAULTSLUG
=
'v'
;
if
(
!
class_exists
(
'S
exHack
VideoGallery'
))
{
if
(
!
class_exists
(
'S
H_
VideoGallery'
))
{
// 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
class
SH_VideoGallery
{
public
function
__construct
()
{
// TODO What an horrible and inefficient way to cache the query result.
// Think about moving it in session and with a better data structure.
$this
->
productlist
=
false
;
// Register Query Vars
add_filter
(
"query_vars"
,
array
(
$this
,
"query_vars"
));
add_shortcode
(
"sexgallery"
,
array
(
$this
,
"sexgallery_shortcode"
));
add_action
(
'init'
,
array
(
$this
,
"register_sexhack_video_post_type"
));
//add_action('add_meta_boxes', array($this, "sexhack_video_metaboxes"));
add_action
(
'admin_init'
,
array
(
$this
,
"register_settings"
));
//
add_action('admin_init', array($this, "register_settings"));
//add_filter('page_template', array($this, 'sexhack_video_template'));
add_filter
(
'archive_template'
,
array
(
$this
,
'sexhack_video_template'
));
add_action
(
'save_post'
,
array
(
$this
,
'save_sexhack_video_meta_box_data'
));
...
...
@@ -139,35 +52,6 @@ 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' );
}
public
function
settings_section
()
{
echo
"<h2>SexHackMe Gallery Settings</h2>"
;
}
/*
public function settings_field($name)
{
echo $name;
}
*/
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
;
}
public
function
query_vars
(
$vars
)
{
$vars
[]
=
'wooprod'
;
...
...
@@ -208,69 +92,6 @@ if(!class_exists('SexHackVideoGallery')) {
// sets custom post type
// TODO: the idea is to have custom post type for models profiles and for videos.
// Ideally /$DEFAULTSLUG/nomevideo/ finisce sul corrispettivo prodotto woocommerce,
// /$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
// per ogni pagina sexhack_video che credo, sincronizzare prodotti e video pagine, gestire prodotti con lo stesso nome
// ( credo si possa fare dandogli differenti slugs )
public
function
register_sexhack_video_post_type
()
{
global
$wp_rewrite
;
global
$SEXHACK_GALLERY_DEFAULTSLUG
;
$DEFAULTSLUG
=
get_option
(
'sexhack_gallery_slug'
,
$SEXHACK_GALLERY_DEFAULTSLUG
);
sexhack_log
(
"REGISTER SEXHACK_VIDEO "
);
register_post_type
(
'sexhack_video'
,
array
(
'labels'
=>
array
(
'name'
=>
'Videos'
,
'singular_name'
=>
'Video'
,
'add_new'
=>
'Add New'
,
'add_new_item'
=>
'Add New Video'
,
'edit_item'
=>
'Edit Video'
,
'not_found'
=>
'There are no videos yet'
,
'not_found_in_trash'
=>
'Nothing found in Trash'
,
'search_items'
=>
'Search videos'
,
),
'description'
=>
'Videos for SexHack.me gallery'
,
'public'
=>
true
,
'register_meta_box_cb'
=>
array
(
$this
,
'sexhack_video_metaboxes'
),
'show_ui'
=>
true
,
'show_in_menu'
=>
true
,
'show_in_rest'
=>
true
,
'menu_position'
=>
32
,
'capability_type'
=>
'post'
,
// XXX We should create our own cap type?
// 'capabilities' => array(), // Or just select specific capabilities here
'hierarchical'
=>
true
,
'publicly_queryable'
=>
true
,
'rewrite'
=>
false
,
'query_var'
=>
true
,
'has_archive'
=>
true
,
'supports'
=>
array
(
'title'
),
// 'thumbnail', 'editor','excerpt','trackbacks','custom-fields','comments','revisions','author','page-attributes'),
'taxonomies'
=>
array
(
'category'
,
'post_tag'
),
// XXX Shouldn't we have a "video_type" taxonomy for VR or flat?
));
$projects_structure
=
'/'
.
$DEFAULTSLUG
.
'/%wooprod%/'
;
$rules
=
$wp_rewrite
->
wp_rewrite_rules
();
if
(
array_key_exists
(
$DEFAULTSLUG
.
'/([^/]+)/?$'
,
$rules
))
{
sexhack_log
(
"REWRITE: rules OK: "
.
$DEFAULTSLUG
.
'/([^/]+)/?$ => '
.
$rules
[
$DEFAULTSLUG
.
'/([^/]+)/?$'
]);
}
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_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
function
sexhack_video_metaboxes
(
$post
=
false
)
{
add_meta_box
(
'sh-mbox-videodescription'
,
'Video Description'
,
array
(
$this
,
'load_metabox_videodescription'
),
'sexhack_video'
,
'normal'
,
'default'
);
...
...
@@ -341,8 +162,8 @@ if(!class_exists('SexHackVideoGallery')) {
public
function
getProducts
(
$vcat
=
false
)
{
if
(
!
$this
->
productlist
)
$this
->
productlist
=
$this
->
_getProducts
(
$vcat
);
if
(
!
$this
->
productlist
&&
!
$vcat
)
$this
->
productlist
=
$this
->
_getProducts
(
$vcat
);
else
if
(
$vcat
)
return
$this
->
_getProducts
(
$vcat
);
return
$this
->
productlist
;
...
...
@@ -448,9 +269,8 @@ if(!class_exists('SexHackVideoGallery')) {
public
function
get_video_thumb
()
{
global
$SEXHACK_GALLERY_DEFAULTSLUG
;
$DEFAULTSLUG
=
get_option
(
'sexhack_gallery_slug'
,
$SEXHACK_GALLERY_DEFAULTSLUG
);
$DEFAULTSLUG
=
get_option
(
'sexhack_gallery_slug'
,
'v'
);
$id
=
get_the_ID
();
$prod
=
wc_get_product
(
$id
);
...
...
@@ -507,14 +327,9 @@ if(!class_exists('SexHackVideoGallery')) {
return
$html
;
}
}
}
$SEXHACK_SECTION
=
array
(
'class'
=>
'SexHackVideoGallery'
,
'description'
=>
'Create Video galleries for Sexhack Video products'
,
//'require-page' => true,
'name'
=>
'sexhackme_videogallery'
);
$gal
=
new
SH_VideoGallery
();
$GLOBAL
[
'sh_videogallery'
]
=
$gal
;
}
?>
includes/class-widgets.php
View file @
14b9c1dd
...
...
@@ -87,7 +87,99 @@ if(!class_exists('SH_ADVWidget')) {
}
add_action
(
'widgets_init'
,
array
(
'wp_SexHackMe\SH_ADVWidget'
,
'register'
));
}
if
(
!
class_exists
(
'SH_GalleryWidget'
))
{
// Creating the widget
class
SH_GalleryWidget
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
;
}
public
static
function
register
()
{
register_widget
(
'wp_SexHackMe\SH_GalleryWidget'
);
}
}
// Class widget ends here
add_action
(
'widgets_init'
,
array
(
'wp_SexHackMe\SH_GalleryWidget'
,
'register'
));
}
?>
sexhackme.php
View file @
14b9c1dd
...
...
@@ -264,6 +264,11 @@ if(!class_exists('SexHackMe_Plugin')) {
if
(
file_exists
(
SH_PLUGIN_DIR_PATH
.
'includes/class-unlock-support.php'
)
)
include_once
SH_PLUGIN_DIR_PATH
.
'includes/class-unlock-support.php'
;
/* Video Gallery */
if
(
file_exists
(
SH_PLUGIN_DIR_PATH
.
'includes/class-videogallery.php'
)
)
include_once
SH_PLUGIN_DIR_PATH
.
'includes/class-videogallery.php'
;
/* Shortcodes */
if
(
file_exists
(
SH_PLUGIN_DIR_PATH
.
'includes/class-shortcodes.php'
)
)
include_once
SH_PLUGIN_DIR_PATH
.
'includes/class-shortcodes.php'
;
...
...
@@ -314,8 +319,8 @@ if(!class_exists('SexHackMe_Plugin')) {
add_action
(
'tgmpa_register'
,
array
(
$this
,
'plugin_dependencies'
));
// Set the main menu page
add_action
(
'admin_menu'
,
array
(
$this
,
'admin_
menu'
));
add_action
(
'admin_init'
,
array
(
$this
,
'initialize_plugin
'
));
add_action
(
'admin_menu'
,
array
(
'wp_SexHackMe\SH_Admin'
,
'
menu'
));
add_action
(
'admin_init'
,
array
(
'wp_SexHackMe\SH_Admin'
,
'init
'
));
// Check if we need to flush rewrite rules
...
...
@@ -356,10 +361,6 @@ if(!class_exists('SexHackMe_Plugin')) {
sexhack_log
(
"SexHackMe PLUGIN Loaded!"
);
// Initialize the deprecated plugin parts
// XXX To be removed soon!
$this
->
deprecated
();
}
// XXX There are so many dependencies to add here...
...
...
@@ -487,95 +488,6 @@ if(!class_exists('SexHackMe_Plugin')) {
}
/* FROM HERE IS THE DEPRECATED PART */
public
function
deprecated
()
{
$SECTIONS
=
array
();
foreach
(
glob
(
dirname
(
__FILE__
)
.
'/deprecated/*.php'
)
as
$class_path
)
{
$SEXHACK_SECTION
=
false
;
try
{
include_once
(
$class_path
);
}
catch
(
\Throwable
$e
)
{
sexhack_log
(
$e
);
}
if
(
is_array
(
$SEXHACK_SECTION
))
$SECTIONS
[]
=
$SEXHACK_SECTION
;
}
$this
->
SECTIONS
=
$SECTIONS
;
$this
->
instances
=
array
();
foreach
(
$SECTIONS
as
$section
)
{
$class
=
"wp_SexHackMe
\\
"
.
$section
[
'class'
];
$this
->
instances
[
$section
[
'name'
]]
=
new
$class
();
}
}
/* public function settings_section() {
* echo "<h3>Enable following functionalities:</h3>";
* }
*/
public
function
initialize_plugin
()
{
add_settings_section
(
'sexhackme-settings'
,
' '
,
array
(
$this
,
'settings_section'
),
'sexhackme-settings'
);
foreach
(
$this
->
SECTIONS
as
$section
)
{
register_setting
(
'sexhackme-settings'
,
$section
[
'name'
]);
if
(
array_key_exists
(
'require-page'
,
$section
)
&&
(
$section
[
'require-page'
]))
{
if
(
is_array
(
$section
[
'require-page'
]))
{
foreach
(
$section
[
'require-page'
]
as
$pagereq
)
{
if
(
array_key_exists
(
'post_type'
,
$pagereq
))
{
if
(
array_key_exists
(
'option'
,
$pagereq
))
register_setting
(
'sexhackme-settings'
,
$pagereq
[
'option'
]);
}
}
}
else
{
register_setting
(
'sexhackme-settings'
,
$section
[
'name'
]
.
"-page"
);
}
}
}
SH_Admin
::
init
();
}
public
function
admin_menu
()
{
add_menu_page
(
'SexHackMe Settings'
,
'SexHackMe'
,
'manage_options'
,
'sexhackme-settings'
,
array
(
$this
,
'admin_page'
),
SH_PLUGIN_DIR_URL
.
'img/admin_icon.png'
,
31
);
SH_Admin
::
menu
();
foreach
(
$this
->
SECTIONS
as
$section
)
{
if
(
get_option
(
$section
[
'name'
])
==
"1"
)
{
if
(
array_key_exists
(
'adminmenu'
,
$section
)
&&
is_array
(
$section
[
'adminmenu'
]))
{
foreach
(
$section
[
'adminmenu'
]
as
$admsub
)
{
sexhack_log
(
$admsub
);
if
(
is_array
(
$admsub
)
&&
array_key_exists
(
'title'
,
$admsub
)
&&
array_key_exists
(
'callback'
,
$admsub
)
&&
array_key_exists
(
'slug'
,
$admsub
))
{
add_submenu_page
(
'sexhackme-settings'
,
$admsub
[
'title'
],
$admsub
[
'title'
],
'manage_options'
,
$admsub
[
'slug'
],
$admsub
[
'callback'
]);
}
}
}
}
}
}
public
function
admin_page
()
{
sh_get_template
(
'admin/sexhackme.php'
,
array
(
'sections'
=>
$this
->
SECTIONS
));
}
}
// Let's run the plugin!
...
...
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