Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: pkvideos
  4. Plugin URI: http://pavan.com
  5. Author: Pavan
  6. Version: 1.0
  7. Description: Videos of IndianFolk.
  8. Text Domain: pavan
  9. Requires at least: 3.0
  10. Tested up to: 4.7.3
  11. */
  12.  
  13. add_action('admin_menu', 'test_plugin_setup_menu');
  14.  
  15. function test_plugin_setup_menu(){
  16. add_menu_page( 'If Videos', 'If Videos by PK', 'manage_options', 'if-videos-by-pk', 'postvideo' );
  17. add_submenu_page('if-videos-by-pk', 'Edit Videos', 'Edit Videos', 'manage_options', 'if-videos-edit' );
  18. add_submenu_page('if-videos-by-pk', 'About Me', 'About Me', 'manage_options', 'if-videos-about' );
  19. }
  20.  
  21. function postvideo(){
  22. echo "<h1>IndianFolk Videos</h1>";
  23.  
  24. ?>
  25. <form action="" method="post">
  26. Title :<input type="text" name="title" required><br>
  27. Video Url: <input type="text" name="url" required><br>
  28. Thumbnail Url: <input type="text" name="thurl" required><br>
  29. <input type="submit" value="Submit" name="submit">
  30. </form>
  31.  
  32.  
  33. <?php
  34. if(isset($_POST['submit'])){ //check if form was submitted
  35. $title = $_POST['title']; //get input text
  36. $url = $_POST['url'];
  37. $thurl = $_POST['thurl'];
  38. $aData = array(
  39. 'title' => $title,
  40. 'url' => $url,
  41. 'thurl'=> $thurl
  42. );
  43.  
  44. global $wpdb;
  45. $res = $wpdb->insert('wp_ifvideos', $aData);
  46. $siteurll=get_site_url();
  47.  
  48. }
  49.  
  50. }
  51.  
  52. function create_plugin_database_table() {
  53. global $wpdb;
  54. $table_name = $wpdb->prefix . 'ifvideos';
  55. $sql = "CREATE TABLE $table_name (
  56. id mediumint(9) unsigned NOT NULL AUTO_INCREMENT,
  57. title varchar(50) NOT NULL,
  58. url longtext NOT NULL,
  59. thurl longtext NOT NULL,
  60. PRIMARY KEY (id)
  61. );";
  62.  
  63. require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
  64. dbDelta( $sql );
  65. }
  66.  
  67. register_activation_hook( __FILE__, 'create_plugin_database_table' );
  68.  
  69. /*=//This is used for adding form as the shortcode in pages or posts or widgets
  70. function wp_first_shortcode(){
  71. echo "Hello, This is your another shortcode!";
  72. ?>
  73.  
  74. <form action="" method="post">
  75. Title :<input type="text" name="title"><br>
  76. Url: <input type="text" name="url"><br>
  77. Thumbnail Url: <input type="text" name="thurl"><br>
  78. <input type="submit" value="Submit" name="submit">
  79. </form>
  80. <?php
  81.  
  82. if(isset($_POST['submit'])){ //check if form was submitted
  83. $title = $_POST['title']; //get input text
  84. $url = $_POST['url'];
  85. $thurl = $_POST['thurl'];
  86. $aData = array(
  87. 'title' => $title,
  88. 'url' => $url,
  89. 'thurl'=> $thurl
  90. );
  91.  
  92. global $wpdb;
  93. $res = $wpdb->insert('wp_ifvideos', $aData);
  94. $siteurll=get_site_url();
  95.  
  96. }
  97.  
  98. }//this is used for adding short code
  99. add_shortcode('first', 'wp_first_shortcode');*/
  100.  
  101. function videos_info()
  102. {
  103. global $wpdb;
  104.  
  105. $videos = $wpdb->get_results( "SELECT * FROM wp_ifvideos ORDER BY id DESC" , ARRAY_N);
  106.  
  107. foreach ( $videos as $video ) {
  108. //Here $user[1], 1 is the column number.
  109. echo do_shortcode("[video width='256' height='144'
  110. poster='$video[3]' mp4='$video[2]'][/video]");
  111. echo $video[1]. '<br>';
  112. }
  113. ?>
  114.  
  115. <?php
  116. }
  117. add_shortcode('showinfo','videos_info');
  118.  
  119.  
  120. function video_ajax()
  121. {
  122. ?>
  123.  
  124. <?php
  125.  
  126. }
  127. add_shortcode('ajaxvideo','video_ajax');
  128. ?>
  129.  
  130. $videos = $wpdb->get_results( "SELECT * FROM wp_ifvideos ORDER BY id DESC" , ARRAY_N);
  131.  
  132. foreach ( $videos as $video ) {
  133. //Here $user[1], 1 is the column number.
  134. echo do_shortcode("[video width='256' height='144'
  135. poster='$video[3]' mp4='$video[2]'][/video]");
  136. echo $video[1]. '<br>';
  137. }
  138. ?>
  139.  
  140. <?php
  141. }
  142. add_shortcode('showinfo','videos_info');
  143.  
  144.  
  145. function video_ajax()
  146. {
  147. ?>
  148.  
  149. <?php
  150.  
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement