Add simple 404 redirect

parent b5704689
...@@ -43,6 +43,20 @@ if(!class_exists('SH_StoreFront')) { ...@@ -43,6 +43,20 @@ if(!class_exists('SH_StoreFront')) {
// Re add the cart in the right position // Re add the cart in the right position
add_action( 'storefront_header', 'storefront_header_cart', 40); add_action( 'storefront_header', 'storefront_header_cart', 40);
// Replace 404 page if /404.php exists
if (is_readable($_SERVER['DOCUMENT_ROOT'].'/404.php')) {
add_action( 'template_redirect', 'wp_SexHackMe\SH_StoreFront::page404' );
}
}
public static function page404()
{
if(is_404())
{
wp_redirect( home_url( '/404.php' ) );
die;
}
} }
public static function credits($cred) public static function credits($cred)
......
...@@ -25,32 +25,29 @@ namespace wp_SexHackMe; ...@@ -25,32 +25,29 @@ namespace wp_SexHackMe;
if ( ! defined( 'ABSPATH' ) ) exit; if ( ! defined( 'ABSPATH' ) ) exit;
if(!class_exists('SH_StoreFront')) { if(!class_exists('SH_VideoUpload')) {
class SH_StoreFront class SH_VideoUpload
{ {
public static function init() public function __construct()
{ {
// Remove the cart and the product search add_action('wp_ajax_file_upload', array($this, 'file_upload_callback'));
remove_action( 'storefront_header', 'storefront_header_cart', 60 ); add_action('wp_ajax_nopriv_file_upload', array($this, 'file_upload_callback'));
remove_action( 'storefront_header', 'storefront_product_search', 40);
// Remove StoreFront credits
add_filter('storefront_credit_link', 'wp_SexHackMe\SH_StoreFront::credits');
// add footer disclaimer
//add_action('storefront_footer', 'wp_SexHackMe\sh_get_disclaimer')); // XXX I don't like positioning this way. Fix in CSS or sobstitute footer theme file?
// Re add the cart in the right position
add_action( 'storefront_header', 'storefront_header_cart', 40);
} }
public static function credits($cred) public function file_upload_callback()
{ {
return ''; check_ajax_referer('sh_video_upload', 'security');
$arr_img_ext = array('image/png', 'image/jpeg', 'image/jpg', 'image/gif');
if (in_array($_FILES['file']['type'], $arr_img_ext)) {
$upload = wp_upload_bits($_FILES["file"]["name"], null, file_get_contents($_FILES["file"]["tmp_name"]));
//$upload['url'] will gives you uploaded file path
}
wp_die();
} }
} }
new SH_VideoUpload;
} }
......
...@@ -38,7 +38,7 @@ function pms_get_redirect_url($url, $location=false) ...@@ -38,7 +38,7 @@ function pms_get_redirect_url($url, $location=false)
{ {
if( !isset( $_POST['pay_gate'] ) || $_POST['pay_gate'] != 'manual' ) if( !isset( $_POST['pay_gate'] ) || $_POST['pay_gate'] != 'manual' )
return $url; return $url;
// XXX BUG apply_filter ont found??
return apply_filter('sh_get_redirect_url', $url, $location); return apply_filter('sh_get_redirect_url', $url, $location);
} }
......
...@@ -402,7 +402,7 @@ if(!class_exists('SexHackMe_Plugin')) { ...@@ -402,7 +402,7 @@ if(!class_exists('SexHackMe_Plugin')) {
$this->file_include('includes/class-video.php'); $this->file_include('includes/class-video.php');
$this->file_include('includes/functions-video.php'); $this->file_include('includes/functions-video.php');
$this->file_include('includes/class-post_type-video.php'); $this->file_include('includes/class-post_type-video.php');
$this->file_include('includes/class-video-upload.php');
/* Video Gallery */ /* Video Gallery */
$this->file_include('includes/class-videogallery.php'); $this->file_include('includes/class-videogallery.php');
......
...@@ -22,6 +22,30 @@ ...@@ -22,6 +22,30 @@
// Exit if accessed directly // Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit; if ( ! defined( 'ABSPATH' ) ) exit;
?> ?>
<script language="javascript">
jQuery(function($) {
$('body').on('change', '#file', function() {
$this = $(this);
file_data = $(this).prop('files')[0];
form_data = new FormData();
form_data.append('file', file_data);
form_data.append('action', 'file_upload');
form_data.append('security', '<?php echo wp_create_nonce( 'sh_video_upload' );?>');
$.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' );?>',
type: 'POST',
contentType: false,
processData: false,
data: form_data,
success: function (response) {
$this.val('');
alert('File uploaded successfully.');
}
});
});
});
</script>
<form class="fileUpload" enctype="multipart/form-data"> <form class="fileUpload" enctype="multipart/form-data">
<div class="form-group"> <div class="form-group">
<label>Choose File:</label> <label>Choose File:</label>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment