Video custop page admin post almost complete

parent b28572c5
...@@ -47,14 +47,15 @@ if(!class_exists('SH_MetaBox')) { ...@@ -47,14 +47,15 @@ if(!class_exists('SH_MetaBox')) {
// Video tags // Video tags
add_meta_box('video_tags', 'Video tags', 'wp_SexHackMe\SH_MetaBox::video_tags_meta_box', 'sexhack_video', 'side', 'default'); add_meta_box('video_tags', 'Video tags', 'wp_SexHackMe\SH_MetaBox::video_tags_meta_box', 'sexhack_video', 'side', 'default');
// Re-add featured image thumbnail
add_meta_box('video_postimagediv', 'Video Thumbnail', 'post_thumbnail_meta_box', 'sexhack_video', 'side', 'default');
// XXX Remove Paid Member Subscription meta boxes // XXX Remove Paid Member Subscription meta boxes
remove_meta_box( 'pms_post_content_restriction', 'sexhack_video', 'default'); remove_meta_box( 'pms_post_content_restriction', 'sexhack_video', 'normal');
// XXX Remove Members plugin meta box // XXX Remove Members plugin meta box
remove_meta_box( 'members-cp', 'sexhack_video', 'default'); remove_meta_box( 'members-cp', 'sexhack_video', 'advanced');
// Re-add featured image thumbnail
add_meta_box('video_postimagediv', 'Video Thumbnail', 'post_thumbnail_meta_box', 'sexhack_video', 'side', 'default');
} }
public static function main_metabox_video($post) public static function main_metabox_video($post)
...@@ -62,112 +63,60 @@ if(!class_exists('SH_MetaBox')) { ...@@ -62,112 +63,60 @@ if(!class_exists('SH_MetaBox')) {
wp_nonce_field('video_description_nonce','sh_video_description_nonce'); wp_nonce_field('video_description_nonce','sh_video_description_nonce');
$video = sh_get_video_from_post($post->ID); $video = sh_get_video_from_post($post->ID);
if(!$video) $video = new SH_Video(); if(!$video)
{
$video = new SH_Video();
$video->post_id = $post->ID; $video->post_id = $post->ID;
$video->post = $post; $video->post = $post;
}
sh_get_template("admin/metabox_video.php", array('video' => $video, 'post' => $post)); sh_get_template("admin/metabox_video.php", array('video' => $video, 'post' => $post));
} }
public static function model_select_meta_box( $post, $box ) { public static function model_select_meta_box( $post, $box ) {
sh_get_template("admin/metabox_model.php"); $video = sh_get_video_from_post($post->ID);
} if(!$video)
public static function video_categories_meta_box( $post, $box ) {
sh_get_template("admin/metabox_videocategories.php");
}
public static function video_tags_meta_box( $post, $box ) {
$user_can_assign_terms = true; //current_user_can( $taxonomy->cap->assign_terms );
$comma = _x( ',', 'tag delimiter' );
$terms_to_edit = "prova,prova2,antani"; //get_terms_to_edit( $post->ID, $tax_name );
if ( ! is_string( $terms_to_edit ) ) {
$terms_to_edit = '';
}
sh_get_template("admin/metabox_videotags.php", array('terms_to_edit' => $terms_to_edit, "comma" => $comma, 'user_can_assign_terms' => $user_can_assign_terms));
}
public static function save_meta_box_data($post_id)
{ {
return SH_MetaBox::save_sexhack_video_meta_box_data($post_id); $video = new SH_Video();
$video->post_id = $post->ID;
$video->post = $post;
}
sh_get_template("admin/metabox_model.php", array('video' => $video, 'post' => $post));
} }
public static function save_sexhack_video_meta_box_data( $post_id ) public static function video_categories_meta_box( $post, $box ) {
$video = sh_get_video_from_post($post->ID);
if(!$video)
{ {
$video = new SH_Video();
$video->post_id = $post->ID;
// Verify that the nonce is set and valid. $video->post = $post;
if (!isset( $_POST['sh_video_description_nonce'])
|| !wp_verify_nonce( $_POST['sh_video_description_nonce'], 'video_description_nonce' ) ) {
return;
} }
$cats = sh_get_categories();
// If this is an autosave, our form has not been submitted, so we don't want to do anything. sh_get_template("admin/metabox_videocategories.php",
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { array('video' => $video,
return; 'post' => $post,
'cats' => $cats,
));
} }
// Check the user's permissions.
if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) {
if ( ! current_user_can( 'edit_page', $post_id ) ) {
return;
}
public static function video_tags_meta_box( $post, $box ) {
$video = sh_get_video_from_post($post->ID);
if(!$video)
{
$video = new SH_Video();
$video->post_id = $post->ID;
$video->post = $post;
} }
else { sh_get_template("admin/metabox_videotags.php" , array('video' => $video, 'post' => $post));
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return;
}
} }
/* OK, it's safe for us to save the data now. */
// Make sure that it is set.
if ( ! isset( $_POST['video_description'] ) ) {
return;
}
$video = sh_get_video_from_post($post_id); public static function save_meta_box_data($post_id)
if(!$video) $video = new SH_Video();
$video->post_id = $post_id;
$post = $video->get_post();
// XXX TODO Sanitize inputs!
//
// Title and slug
$video->title = $post->post_title;
$video->slug = $post->post_name;
// TODO Remove debug
sexhack_log("SAVE post object:");
sexhack_log($post);
sexhack_log(' - $POST:');
sexhack_log($_POST);
// Video description
$video->description = sanitize_text_field( $_POST['video_description'] );
// Video thumbnail
if(array_key_exists('video_thumbnail', $_POST) && sanitize_text_field($_POST['video_thumbnail']))
$video->thumbnail = sanitize_text_field( $_POST['video_thumbnail'] );
else if(array_key_exists('_thumbnail_id', $_POST)
&& is_numeric($_POST['_thumbnail_id'])
&& intval($_POST['_thumbnail_id']) > 0)
{ {
$video->thumbnail = intval($_POST['_thumbnail_id']); return save_sexhack_video_meta_box_data($post_id);
}
else
$video->thumbnail = false;
// Save the video data in the database.
sh_save_video($video);
} }
} }
......
...@@ -81,6 +81,8 @@ if(!class_exists('SH_Query')) { ...@@ -81,6 +81,8 @@ if(!class_exists('SH_Query')) {
$count++; $count++;
} }
$updateid = false;
$sqlarr = array();
if((is_long($video->id) || is_numeric($video->id)) && intval($video->id) > 0) if((is_long($video->id) || is_numeric($video->id)) && intval($video->id) > 0)
{ {
// Save an already existing video entry // Save an already existing video entry
...@@ -88,8 +90,12 @@ if(!class_exists('SH_Query')) { ...@@ -88,8 +90,12 @@ if(!class_exists('SH_Query')) {
{$fields} {$fields}
WHERE WHERE
id = {$video->id};"; id = {$video->id};";
$wpdb->query( $sql ); $sqlarr[] = "DELETE FROM {$wpdb->prefix}".SH_PREFIX."videotags_assoc
WHERE
video_id = {$video->id};";
$sqlarr[] = "DELETE FROM {$wpdb->prefix}".SH_PREFIX."videocategory_assoc
WHERE
video_id = {$video->id};\n";
} }
else else
{ {
...@@ -97,12 +103,42 @@ if(!class_exists('SH_Query')) { ...@@ -97,12 +103,42 @@ if(!class_exists('SH_Query')) {
$sql = "INSERT INTO {$wpdb->prefix}".SH_PREFIX."videos $sql = "INSERT INTO {$wpdb->prefix}".SH_PREFIX."videos
({$keys}) ({$keys})
VALUES VALUES
({$values});"; ({$values});\n";
$updateid = true;
}
$wpdb->query( $sql ); $wpdb->query( $sql );
$video->id = $wpdb->insert_id; if($updateid) $video->id = $wpdb->insert_id;
sexhack_log($sql);
foreach($video->get_categories() as $cat)
{
$sqlarr[] = "INSERT INTO {$wpdb->prefix}".SH_PREFIX."videocategory_assoc
(cat_id, video_id)
VALUES
({$cat->id}, {$video->id});\n";
} }
//sexhack_log($sql); foreach($video->get_tags_names() as $tagname)
{
$tagname = $wpdb->_real_escape($tagname);
$q = "INSERT IGNORE INTO {$wpdb->prefix}".SH_PREFIX."videotags
(tag) VALUES ('{$tagname}');";
$wpdb->query($q);
$sqlarr[] = "INSERT INTO {$wpdb->prefix}".SH_PREFIX."videotags_assoc
(tag_id, video_id)
VALUES
((SELET id FROM {$wpdb->prefix}".SH_PREFIX."videotags WHERE tag='{$tagname}'), {$video->id});";
}
foreach($sqlarr as $sql)
{
sexhack_log($sql);
if($sql)
$wpdb->query( $sql );
}
return $video; return $video;
} }
...@@ -119,8 +155,18 @@ if(!class_exists('SH_Query')) { ...@@ -119,8 +155,18 @@ if(!class_exists('SH_Query')) {
if(!$idtype) return false; if(!$idtype) return false;
$sql = "DELETE FROM {$wpdb->prefix}".SH_PREFIX."videos WHERE {$idtype}=".intval($id); $sqlarr = array();
return $wpdb->query( $sql ); $sqlarr[] = "DELETE FROM {$wpdb->prefix}".SH_PREFIX."videotags_assoc WHERE video_id IN (
SELECT id FROM {$wpdb->prefix}".SH_PREFIX."videos
WHERE {$idtype}=".intval($id)." );";
$sqlarr[] = "DELETE FROM {$wpdb->prefix}".SH_PREFIX."videocategory_assoc WHERE video_id IN (
SELECT id FROM {$wpdb->prefix}".SH_PREFIX."videos
WHERE {$idtype}=".intval($id)." );";
$sqlarr[] = "DELETE FROM {$wpdb->prefix}".SH_PREFIX."videos WHERE {$idtype}=".intval($id);
foreach($sqlarr as $sql)
{
$wpdb->query( $sql );
}
} }
...@@ -172,7 +218,7 @@ if(!class_exists('SH_Query')) { ...@@ -172,7 +218,7 @@ 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 );
foreach($dbres as $row) foreach($dbres as $row)
...@@ -185,6 +231,77 @@ if(!class_exists('SH_Query')) { ...@@ -185,6 +231,77 @@ if(!class_exists('SH_Query')) {
} }
public static function get_Categories($id=false)
{
global $wpdb;
$sql = "SELECT * FROM {$wpdb->prefix}".SH_PREFIX."videocategory";
if($id && is_numeric($id))
$sql .= " WHERE id='".intval($id)."'";
$dbres = $wpdb->get_results( $sql );
return $dbres;
}
public static function get_Video_Categories($vid)
{
global $wpdb;
$sql = "SELECT * FROM {$wpdb->prefix}".SH_PREFIX."videocategory WHERE id IN ";
$sql .= "( SELECT cat_id FROM {$wpdb->prefix}".SH_PREFIX."videocategory_assoc WHERE video_id=".intval($vid)." );";
$dbres = $wpdb->get_results( $sql );
return $dbres;
}
public static function delete_Categories_assoc($id, $idtype)
{
global $wpdb;
if(!is_integer($id))
return;
$idtype=sanitize_idtype($idtype);
if(!in_array($idtype, array('id', 'cat_id', 'video_id'))) return false;
$sql = "DELETE FROM {$wpdb->prefix}".SH_PREFIX."videocategory_assoc WHERE {$idtpe}={$id}";
return $wpdb->query( $sql );
}
public static function get_Video_Tags($vid)
{
global $wpdb;
$sql = "SELECT * FROM {$wpdb->prefix}".SH_PREFIX."videotags WHERE id IN ";
$sql .= "( SELECT tag_id FROM {$wpdb->prefix}".SH_PREFIX."videotags_assoc WHERE video_id=".intval($vid)." );";
$dbres = $wpdb->get_results( $sql );
return $dbres;
}
public static function delete_Tags_assoc($id, $idtype)
{
global $wpdb;
if(!is_integer($id))
return;
$idtype=sanitize_idtype($idtype);
if(!in_array($idtype, array('id', 'tag_id', 'video_id'))) return false;
$sql = "DELETE FROM {$wpdb->prefix}".SH_PREFIX."videotags_assoc WHERE {$idtpe}={$id}";
return $wpdb->query( $sql );
}
// XXX Deprecated TODO remove it
public static function get_Products($vcat=false) public static function get_Products($vcat=false)
{ {
$filter=false; $filter=false;
......
...@@ -41,7 +41,7 @@ if(!class_exists('SH_Video')) { ...@@ -41,7 +41,7 @@ if(!class_exists('SH_Video')) {
'visible' => 'Y', 'visible' => 'Y',
'title' => '', 'title' => '',
'description' => '', 'description' => '',
'uploaded' => false, 'created' => false,
'updated' => false, 'updated' => false,
'slug' => '', 'slug' => '',
'price' => 0, 'price' => 0,
...@@ -62,6 +62,12 @@ if(!class_exists('SH_Video')) { ...@@ -62,6 +62,12 @@ if(!class_exists('SH_Video')) {
'format_public' => false, 'format_public' => false,
'format_members' => false, 'format_members' => false,
'format_premium' => false, 'format_premium' => false,
'codec_public' => 'h264',
'codec_members' => 'h264',
'codec_premium' => 'h264',
'acodec_public' => 'h264',
'acodec_members' => 'h264',
'acodec_premium' => 'h264',
'duration_public' => false, 'duration_public' => false,
'duration_members' => false, 'duration_members' => false,
'duration_premium' => false, 'duration_premium' => false,
...@@ -122,6 +128,55 @@ if(!class_exists('SH_Video')) { ...@@ -122,6 +128,55 @@ if(!class_exists('SH_Video')) {
return isset($this->attributes['key']); return isset($this->attributes['key']);
} }
public function get_tags()
{
if(isset($this->attributes['tags'])) return $this->tags;
$tags = sh_get_video_tags($this->id);
$this->tags = array();
$this->tagsnames = array();
$tags_indexed = array();
$tagsnames = array();
if($tags)
{
foreach($tags as $tag) {
$tags_indexed[$tag->id] = $tag;
$tagsnames[] = $tag->tag;
}
$this->tags = $tags_indexed;
$this->tagsnames = $tagsnames;
}
return $this->tags;
}
public function get_tags_names()
{
if(isset($this->attributes['tagsnames'])) return $this->tagsnames;
$this->get_tags();
return $this->tagsnames;
}
public function get_categories()
{
if(isset($this->attributes['categories'])) return $this->categories;
$cats = sh_get_video_categories($this->id);
$this->categories = array();
$cats_indexed = array();
if($cats)
{
foreach($cats as $cat)
$cats_indexed[$cat->id] = $cat;
$this->categories = $cats_indexed;
}
return $this->categories;
}
public function has_category($cat_id)
{
if(!isset($this->attributes['categories'])) $this->get_categories();
if(in_array($cat_id, array_keys($this->categories))) return true;
return false;
}
public function get_post() public function get_post()
{ {
if(isset($this->attributes['post'])) return $this->post; if(isset($this->attributes['post'])) return $this->post;
...@@ -163,7 +218,7 @@ if(!class_exists('SH_Video')) { ...@@ -163,7 +218,7 @@ if(!class_exists('SH_Video')) {
$r = array(); $r = array();
foreach($this->attributes as $k => $v) foreach($this->attributes as $k => $v)
{ {
if(($v) && !in_array($k, array('post', 'product')) ) $r[$k] = $v; if(($v) && !in_array($k, array('id', 'post', 'product', 'tags','categories', 'tagsnames')) ) $r[$k] = $v;
} }
return $r; return $r;
} }
......
<?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 save_sexhack_video_meta_box_data( $post_id )
{
// Verify that the nonce is set and valid.
if (!isset( $_POST['sh_video_description_nonce'])
|| !wp_verify_nonce( $_POST['sh_video_description_nonce'], 'video_description_nonce' ) ) {
return;
}
// If this is an autosave, our form has not been submitted, so we don't want to do anything.
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
// Check the user's permissions.
if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) {
if ( ! current_user_can( 'edit_page', $post_id ) ) {
return;
}
}
else {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return;
}
}
/* OK, it's safe for us to save the data now. */
// Make sure that it is set.
if ( ! isset( $_POST['video_description'] ) ) {
return;
}
// Get $video object
$video = sh_get_video_from_post($post_id);
if(!$video) $video = new SH_Video();
// Set post_id
$video->post_id = $post_id;
// set post
$post = $video->get_post();
// XXX TODO Sanitize inputs!
//
// Title and slug
$video->title = $post->post_title;
$video->slug = $post->post_name;
// TODO Remove debug
sexhack_log("SAVE post object:");
sexhack_log($post);
sexhack_log(' - $POST:');
sexhack_log($_POST);
// Model
if(array_key_exists('video_model', $_POST) && is_integer($_POST['video_model']) && intval($_POST['video_model']) > 0)
$video->model = intval($_POST['video_model']);
// Video description
if(array_key_exists('video_description', $_POST) && sanitize_text_field($_POST['video_description']))
$video->description = sanitize_text_field( $_POST['video_description'] );
// Video thumbnail
if(array_key_exists('video_thumbnail', $_POST) && sanitize_text_field($_POST['video_thumbnail']))
$video->thumbnail = sanitize_text_field( $_POST['video_thumbnail'] );
else if(array_key_exists('_thumbnail_id', $_POST)
&& is_numeric($_POST['_thumbnail_id'])
&& intval($_POST['_thumbnail_id']) > 0)
{
$video->thumbnail = intval($_POST['_thumbnail_id']);
}
else
$video->thumbnail = false;
// Video status
$validstatuses = array('creating','uploading','queue','processing','ready','published','error');
if(array_key_exists('video_status', $_POST) && in_array(sanitize_text_field($_POST['video_status']), $validstatuses))
$video->status = sanitize_text_field($_POST['video_status']);
// Video private
if(array_key_exists('video_private', $_POST) && in_array($_POST['video_private'], array('Y','N')))
$video->private = $_POST['video_private'];
// Video visible
if(array_key_exists('video_visible', $_POST) && in_array($_POST['video_visible'], array('Y','N')))
$video->private = $_POST['video_visible'];
// Video price
if(array_key_exists('video_price', $_POST) && is_numeric($_POST['video_price']) && (floatval($_POST['video_price']) > 0))
$video->price = floatval($_POST['video_price']);
// Video type
if(array_key_exists('video_type', $_POST) && in_array($_POST['video_type'], array('VR', 'FLAT')))
$video->video_type = $_POST['video_type'];
// VR Projection
if(array_key_exists('video_vr_projection', $_POST) && in_array($_POST['video_vr_projection'], array('VR180_LR','VR360_LR')))
$video->vr_projection = $_POST['video_vr_projection'];
// Preview video
if(array_key_exists('video_preview', $_POST) && check_url_or_path(sanitize_text_field($_POST['video_preview'])))
$video->preview = sanitize_text_field($_POST['video_preview']);
// Animated gif path
if(array_key_exists('video_gif', $_POST) && check_url_or_path(sanitize_text_field($_POST['video_gif'])))
$video->gif = sanitize_text_field($_POST['video_gif']);
// Differenciated content for access levels
foreach(array('public','members','premium') as $vt)
{
// HLS playlist
if(array_key_exists('video_hls_'.$vt, $_POST) &&
check_url_or_path(sanitize_text_field($_POST['video_hls_'.$vt])) &&
(strncasecmp(strrev(sanitize_text_field($_POST['video_hls_'.$vt])), '8u3m', 4) === 0))
{
$video->__set('hls_'.$vt, sanitize_text_field($_POST['video_hls_'.$vt]));
}
// Download
if(array_key_exists('video_download_'.$vt, $_POST) &&
check_url_or_path(sanitize_text_field($_POST['video_download_'.$vt])))
{
$video->__set('download_'.$vt, sanitize_text_field($_POST['video_download_'.$vt]));
}
// Text only data
foreach(array('size','format','codec','acodec','duration','resolution') as $key)
{
if(array_key_exists('video_'.$key.'_'.$vt, $_POST) &&
sanitize_text_field($_POST['video_'.$key.'_'.$vt]))
{
$video->__set($key.'_'.$vt, sanitize_text_field($_POST['video_'.$key.'_'.$vt]));
}
}
}
// Save the video data in the database.
sh_save_video($video);
}
?>
...@@ -245,6 +245,16 @@ function trim_text_preview($text, $len=340, $fill=false) ...@@ -245,6 +245,16 @@ function trim_text_preview($text, $len=340, $fill=false)
return $text; return $text;
} }
function check_url_or_path($url)
{
if (strncmp($url, "/", 1) === 0)
return 'path';
else if(filter_var($url, FILTER_VALIDATE_URL))
return 'uri';
return false;
}
function html2text($html) function html2text($html)
{ {
// remove comments and any content found in the the comment area (strip_tags only removes the actual tags). // remove comments and any content found in the the comment area (strip_tags only removes the actual tags).
......
...@@ -75,5 +75,38 @@ function sh_get_video_from_product($p) ...@@ -75,5 +75,38 @@ function sh_get_video_from_product($p)
return false; return false;
} }
function sh_get_categories($id=false)
{
return SH_Query::get_Categories($id);
}
function sh_get_video_categories($v)
{
if(is_numeric($v) and $v > 0) return SH_Query::get_Video_Categories($v);
else if(is_object($v)) return SH_Query::get_Video_Categories($v->id);
return false;
}
function sh_get_video_tags($v)
{
if(is_numeric($v) and $v > 0) return SH_Query::get_Video_Tags($v);
else if(is_object($v)) return SH_Query::get_Video_Tags($v->id);
return false;
}
function sh_delete_tags_from_video($v)
{
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');
return false;
}
function sh_delete_categories_from_video($v)
{
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');
return false;
}
?> ?>
...@@ -6,16 +6,37 @@ jQuery(document).ready(function($) { ...@@ -6,16 +6,37 @@ jQuery(document).ready(function($) {
$("#shvtags input").on({ $("#shvtags input").on({
focusout : function() { focusout : function() {
var txt = this.value.replace(/[^a-z0-9\+\-\.\#]/ig,''); // allowed characters var txt = this.value.replace(/[^a-z0-9\+\-\.\#]/ig,''); // allowed characters
if(txt) $("<span/>", {text:txt.toLowerCase(), insertBefore:this}); if(txt) {
$("<span/>", {text:txt.toLowerCase(), insertBefore:this});
$("<input>").attr( {type:"hidden",
name:"video_tags[]",
value:txt.toLowerCase(),
data:txt.toLowerCase(),
}).appendTo('#vtagsdata');
}
this.value = ""; this.value = "";
}, },
keydown : function(ev) {
if(/(13)/.test(ev.which)) {
// Prevent enter key to send the form
ev.preventDefault();
return false;
}
},
keyup : function(ev) { keyup : function(ev) {
// if: comma|enter (delimit more keyCodes with | pipe) // if: comma|enter (delimit more keyCodes with | pipe)
if(/(188|13)/.test(ev.which)) $(this).focusout(); if(/(188|13)/.test(ev.which)) {
$(this).focusout();
}
} }
}); });
$('#shvtags').on('click', 'span', function() { $('#shvtags').on('click', 'span', function() {
if(confirm("Remove "+ $(this).text() +"?")) $(this).remove(); if(confirm("Remove "+ $(this).text() +"?")) {
var txt=$(this).text();
$("input[name='video_tags[]'][data='"+txt+"']").remove();
$(this).remove();
}
}); });
}); });
...@@ -238,7 +238,7 @@ if(!class_exists('SexHackMe_Plugin')) { ...@@ -238,7 +238,7 @@ if(!class_exists('SexHackMe_Plugin')) {
id bigint(20) AUTO_INCREMENT NOT NULL, id bigint(20) AUTO_INCREMENT NOT NULL,
tag varchar(32) NOT NULL, tag varchar(32) NOT NULL,
PRIMARY KEY (id), PRIMARY KEY (id),
KEY tag (tag) UNIQUE KEY tag (tag)
) {$charset_collate}; ) {$charset_collate};
CREATE TABLE {$wpdb->prefix}{$this->prefix}videoguests_assoc ( CREATE TABLE {$wpdb->prefix}{$this->prefix}videoguests_assoc (
id bigint(20) AUTO_INCREMENT NOT NULL, id bigint(20) AUTO_INCREMENT NOT NULL,
...@@ -399,9 +399,12 @@ if(!class_exists('SexHackMe_Plugin')) { ...@@ -399,9 +399,12 @@ if(!class_exists('SexHackMe_Plugin')) {
$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');
/* Video Gallery */ /* Video Gallery */
$this->file_include('includes/class-videogallery.php'); $this->file_include('includes/class-videogallery.php');
/* Form posts functions */
$this->file_include('includes/functions-forms-save.php');
/* Shortcodes */ /* Shortcodes */
$this->file_include('includes/class-shortcodes.php'); $this->file_include('includes/class-shortcodes.php');
...@@ -469,7 +472,7 @@ if(!class_exists('SexHackMe_Plugin')) { ...@@ -469,7 +472,7 @@ if(!class_exists('SexHackMe_Plugin')) {
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
// 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'));
// Initialize shortcodes // Initialize shortcodes
add_action( 'init', array( 'wp_SexHackMe\SH_Shortcodes', 'init' ) ); add_action( 'init', array( 'wp_SexHackMe\SH_Shortcodes', 'init' ) );
...@@ -642,8 +645,8 @@ if(!class_exists('SexHackMe_Plugin')) { ...@@ -642,8 +645,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);
} }
......
...@@ -26,8 +26,18 @@ if ( ! defined( 'ABSPATH' ) ) exit; ...@@ -26,8 +26,18 @@ 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> <p><label>Select user</label></p>
<input type="text" name="vmodel" value="<?php echo get_option( 'sexhack_gallery_slug', "v" ) ?>" /> <?php // XXX When this will be with thousands of model will definely not scale! ?>
<select name='video_model'>
<?php
$models = get_users( array( 'role__in' => array( 'model' ) ) );
foreach($models as $user)
{
echo "<option value='".$user->ID."' ";
if($video->user_id==$user->ID) echo "selected";
echo '>'.$user->user_login." (id:".$user->ID.")</option>";
} ?>
</select>
</td> </td>
</tr> </tr>
</table> </table>
......
...@@ -29,17 +29,29 @@ echo '<style>div#visibility.misc-pub-section.misc-pub-visibility{display:none}</ ...@@ -29,17 +29,29 @@ echo '<style>div#visibility.misc-pub-section.misc-pub-visibility{display:none}</
<h4>Video description</h4> <h4>Video description</h4>
<textarea style="width:100%" id="video_description" name="video_description"><?php echo esc_attr( $video->description ); ?></textarea> <textarea style="width:100%" id="video_description" name="video_description"><?php echo esc_attr( $video->description ); ?></textarea>
</p> </p>
<p>
<h4>Status:</h4>
<select name='video_status'>
<option value='creating' <?php if($video->status=='creating') echo "selected"; ?>>Creating</option>
<option value='uploading' <?php if($video->status=='uploading') echo "selected"; ?>>Uploading</option>
<option value='processing' <?php if($video->status=='processing') echo "selected"; ?>>Processing</option>
<option value='ready' <?php if($video->status=='ready') echo "selected"; ?>>Ready</option>
<option value='published' <?php if($video->status=='published') echo "selected"; ?>>Published</option>
<option value='error' <?php if($video->status=='error') echo "selected"; ?>>Error</option>
</select>
</p>
<p> <p>
<h4>Privacy:</h4> <h4>Privacy:</h4>
<p> <p>
<label> * Show video in public gallery?</label> <label> * Show video in public gallery?</label>
<input type='radio' name='video_visible' value='Y'>Yes</input> <input type='radio' name='video_visible' value='Y' <?php if($video->visible=='Y') echo "checked"; ?>>Yes</input>
<input type='radio' name='video_visible' value='N'>No</input> <input type='radio' name='video_visible' value='N' <?php if($video->visible=='N') echo "checked"; ?>>No</input>
</p> </p>
<p> <p>
<label> * Show video in profile gallery?</label> <label> * Show video in profile gallery?</label>
<input type='radio' name='video_private' value='N'>Yes</input> <input type='radio' name='video_private' value='N' <?php if($video->private=='N') echo "checked"; ?>>Yes</input>
<input type='radio' name='video_private' value='Y'>No</input> <input type='radio' name='video_private' value='Y' <?php if($video->private=='Y') echo "checked"; ?>>No</input>
</p> </p>
</p> </p>
<p> <p>
...@@ -62,15 +74,16 @@ echo '<style>div#visibility.misc-pub-section.misc-pub-visibility{display:none}</ ...@@ -62,15 +74,16 @@ echo '<style>div#visibility.misc-pub-section.misc-pub-visibility{display:none}</
<h4>Virtual Reality</h4> <h4>Virtual Reality</h4>
<p> <p>
<label> * VR Video?:</label> <label> * VR Video?:</label>
<input type='radio' name='video_type' value='VR'>Yes</input> <input type='radio' name='video_type' value='VR' <?php if($video->video_type=='VR') echo "checked"; ?>>Yes</input>
<input type='radio' name='video_type' value='FLAT'>No</input> <input type='radio' name='video_type' value='FLAT' <?php if($video->video_type=='FLAT') echo "checked"; ?>>No</input>
</p> </p>
<p> <p>
<label> * VR Projection</label> <label> * VR Projection</label>
<select name='video_vr_projection'> <select name='video_vr_projection'>
<option value='VR180_LR'>Equirectangular 180 LR</option> <option value='VR180_LR' <?php if($video->video_vr_projection=='VR180_LR') echo "selected"; ?>>Equirectangular 180 LR</option>
<option value='VR360_LR'>Equirectangular 360 LR</option> <option value='VR360_LR' <?php if($video->video_vr_projection=='VR360_LR') echo "selected"; ?>>Equirectangular 360 LR</option>
</select> </select>
<label>(ignored for non VR videos)</option>
</p> </p>
</p> </p>
<p> <p>
......
...@@ -21,13 +21,22 @@ ...@@ -21,13 +21,22 @@
// Exit if accessed directly // Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit; if ( ! defined( 'ABSPATH' ) ) exit;
?> ?>
<div class="wrap"> <div class="wrap">
<table class="form-table"> <table class="form-table">
<tr align="top"> <tr align="top">
<td> <td>
<label>Slug for gallery</label> <?php
<input type="text" name="vcategory" value="<?php echo get_option( 'sexhack_gallery_slug', "v" ) ?>" /> foreach($cats as $cat)
{
echo "<p><input type='checkbox' name='vcategory[]' value='".$cat->id."' ";
if($video->has_category($cat->id)) echo "checked />";
echo "<label>".$cat->category."</label></p>\n";
}
?>
</td> </td>
</tr> </tr>
</table> </table>
......
...@@ -22,13 +22,24 @@ ...@@ -22,13 +22,24 @@
// Exit if accessed directly // Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit; if ( ! defined( 'ABSPATH' ) ) exit;
?> ?>
<p>
<div id="shvtags"> <div id="shvtags">
<span>amateur</span> <?php
<span>sexhackme</span> foreach($video->get_tags() as $tag)
{
echo " <span>".$tag->tag."</span>\n";
}
?>
<input type="text" value="" placeholder="Add a tag" /> <input type="text" value="" placeholder="Add a tag" />
</div> </div>
</p>
<div> <p>
<div width="100%">
<br><br><br>
<p class="howto" id="new-tag-video_tags-desc">Insert tag, confirm with enter or comma</p> <p class="howto" id="new-tag-video_tags-desc">Insert tag, confirm with enter or comma</p>
</div> </div>
</p>
<div id="vtagsdata"></div>
<!--
<p class="hide-if-no-js"><button type="button" class="button-link tagcloud-link" id="link-video_tags" aria-expanded="false">Choose from the most used tags</button></p> <p class="hide-if-no-js"><button type="button" class="button-link tagcloud-link" id="link-video_tags" aria-expanded="false">Choose from the most used tags</button></p>
-->
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