Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: pkvideos
- Plugin URI: http://pavan.com
- Author: Pavan
- Version: 1.0
- Description: Videos of IndianFolk.
- Text Domain: pavan
- Requires at least: 3.0
- Tested up to: 4.7.3
- */
- add_action('admin_menu', 'test_plugin_setup_menu');
- function test_plugin_setup_menu(){
- add_menu_page( 'If Videos', 'If Videos by PK', 'manage_options', 'if-videos-by-pk', 'postvideo' );
- add_submenu_page('if-videos-by-pk', 'Edit Videos', 'Edit Videos', 'manage_options', 'if-videos-edit' );
- add_submenu_page('if-videos-by-pk', 'About Me', 'About Me', 'manage_options', 'if-videos-about' );
- }
- function postvideo(){
- echo "<h1>IndianFolk Videos</h1>";
- ?>
- <form action="" method="post">
- Title :<input type="text" name="title" required><br>
- Video Url: <input type="text" name="url" required><br>
- Thumbnail Url: <input type="text" name="thurl" required><br>
- <input type="submit" value="Submit" name="submit">
- </form>
- <?php
- if(isset($_POST['submit'])){ //check if form was submitted
- $title = $_POST['title']; //get input text
- $url = $_POST['url'];
- $thurl = $_POST['thurl'];
- $aData = array(
- 'title' => $title,
- 'url' => $url,
- 'thurl'=> $thurl
- );
- global $wpdb;
- $res = $wpdb->insert('wp_ifvideos', $aData);
- $siteurll=get_site_url();
- }
- }
- function create_plugin_database_table() {
- global $wpdb;
- $table_name = $wpdb->prefix . 'ifvideos';
- $sql = "CREATE TABLE $table_name (
- id mediumint(9) unsigned NOT NULL AUTO_INCREMENT,
- title varchar(50) NOT NULL,
- url longtext NOT NULL,
- thurl longtext NOT NULL,
- PRIMARY KEY (id)
- );";
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
- dbDelta( $sql );
- }
- register_activation_hook( __FILE__, 'create_plugin_database_table' );
- /*=//This is used for adding form as the shortcode in pages or posts or widgets
- function wp_first_shortcode(){
- echo "Hello, This is your another shortcode!";
- ?>
- <form action="" method="post">
- Title :<input type="text" name="title"><br>
- Url: <input type="text" name="url"><br>
- Thumbnail Url: <input type="text" name="thurl"><br>
- <input type="submit" value="Submit" name="submit">
- </form>
- <?php
- if(isset($_POST['submit'])){ //check if form was submitted
- $title = $_POST['title']; //get input text
- $url = $_POST['url'];
- $thurl = $_POST['thurl'];
- $aData = array(
- 'title' => $title,
- 'url' => $url,
- 'thurl'=> $thurl
- );
- global $wpdb;
- $res = $wpdb->insert('wp_ifvideos', $aData);
- $siteurll=get_site_url();
- }
- }//this is used for adding short code
- add_shortcode('first', 'wp_first_shortcode');*/
- function videos_info()
- {
- global $wpdb;
- $videos = $wpdb->get_results( "SELECT * FROM wp_ifvideos ORDER BY id DESC" , ARRAY_N);
- foreach ( $videos as $video ) {
- //Here $user[1], 1 is the column number.
- echo do_shortcode("[video width='256' height='144'
- poster='$video[3]' mp4='$video[2]'][/video]");
- echo $video[1]. '<br>';
- }
- ?>
- <?php
- }
- add_shortcode('showinfo','videos_info');
- function video_ajax()
- {
- ?>
- <?php
- }
- add_shortcode('ajaxvideo','video_ajax');
- ?>
- $videos = $wpdb->get_results( "SELECT * FROM wp_ifvideos ORDER BY id DESC" , ARRAY_N);
- foreach ( $videos as $video ) {
- //Here $user[1], 1 is the column number.
- echo do_shortcode("[video width='256' height='144'
- poster='$video[3]' mp4='$video[2]'][/video]");
- echo $video[1]. '<br>';
- }
- ?>
- <?php
- }
- add_shortcode('showinfo','videos_info');
- function video_ajax()
- {
- ?>
- <?php
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement