PageRenderTime 40ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/youtube-embed/includes/widgets.php

https://bitbucket.org/crypticrod/sr_wp_code
PHP | 161 lines | 82 code | 19 blank | 60 comment | 2 complexity | 3681b300317b7eeeb18c1b049f01e8d9 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1, GPL-3.0, LGPL-2.0, AGPL-3.0
  1. <?php
  2. /**
  3. * Widgets
  4. *
  5. * Create and display widgets
  6. *
  7. * @package YouTubeEmbed
  8. */
  9. global $wp_version;
  10. if ( ( float ) $wp_version >= 2.8 ) {
  11. class YouTubeEmbedWidget extends WP_Widget {
  12. /**
  13. * Widget Constructor
  14. *
  15. * Call WP_Widget class to define widget
  16. *
  17. * @since 2.0
  18. *
  19. * @uses WP_Widget Standard WP_Widget class
  20. */
  21. function YouTubeEmbedWidget() {
  22. parent::WP_Widget( 'youtube_embed_widget',
  23. 'YouTube Embed',
  24. array( 'description' => 'Embed YouTube Widget.', 'class' => 'my-widget-class' )
  25. );
  26. }
  27. /**
  28. * Display widget
  29. *
  30. * Display the YouTube widget
  31. *
  32. * @since 2.0
  33. *
  34. * @uses generate_youtube_code Generate the required YouTube code
  35. *
  36. * @param string $args Arguments
  37. * @param string $instance Instance
  38. */
  39. function widget( $args, $instance ) {
  40. extract( $args, EXTR_SKIP );
  41. // Output the header
  42. echo $before_widget;
  43. // Extract title for heading
  44. $title = $instance[ 'titles' ];
  45. // Output title, if one exists
  46. if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }
  47. // Generate the video and output it
  48. echo ye_generate_youtube_code ( $instance[ 'id' ],
  49. $instance[ 'type' ],
  50. $instance[ 'width' ],
  51. $instance[ 'height' ],
  52. $instance[ 'fullscreen' ],
  53. $instance[ 'related' ],
  54. $instance[ 'autoplay' ],
  55. $instance[ 'loop' ],
  56. $instance[ 'start' ],
  57. $instance[ 'info' ],
  58. $instance[ 'annotation' ],
  59. $instance[ 'cc' ],
  60. $instance[ 'style' ],
  61. $instance[ 'link' ],
  62. $instance[ 'react' ],
  63. $instance[ 'stop' ],
  64. $instance[ 'sweetspot' ],
  65. $instance[ 'disablekb' ],
  66. '',
  67. $instance[ 'autohide' ],
  68. $instance[ 'controls' ],
  69. $instance[ 'profile' ],
  70. $instance[ 'list' ],
  71. '',
  72. $instance[ 'template' ],
  73. $instance[ 'hd' ] );
  74. // Output the trailer
  75. echo $after_widget;
  76. }
  77. /**
  78. * Widget update/save function
  79. *
  80. * Update and save widget
  81. *
  82. * @since 2.0
  83. *
  84. * @param string $new_instance New instance
  85. * @param string $old_instance Old instance
  86. * @return string Instance
  87. */
  88. function update( $new_instance, $old_instance ) {
  89. $instance = $old_instance;
  90. $instance[ 'titles' ] = strip_tags( $new_instance[ 'titles' ] );
  91. $instance[ 'id' ] = $new_instance[ 'id' ];
  92. $instance[ 'type' ] = $new_instance[ 'type' ];
  93. $instance[ 'width' ] = $new_instance[ 'width' ];
  94. $instance[ 'height' ] = $new_instance[ 'height' ];
  95. $instance[ 'fullscreen' ] = $new_instance[ 'fullscreen' ];
  96. $instance[ 'related' ] = $new_instance[ 'related' ];
  97. $instance[ 'autoplay' ] = $new_instance[ 'autoplay' ];
  98. $instance[ 'loop' ] = $new_instance[ 'loop' ];
  99. $instance[ 'start' ] = $new_instance[ 'start' ];
  100. $instance[ 'info' ] = $new_instance[ 'info' ];
  101. $instance[ 'annotation' ] = $new_instance[ 'annotation' ];
  102. $instance[ 'cc' ] = $new_instance[ 'cc' ];
  103. $instance[ 'style' ] = $new_instance[ 'style' ];
  104. $instance[ 'link' ] = $new_instance[ 'link' ];
  105. $instance[ 'react' ] = $new_instance[ 'react' ];
  106. $instance[ 'stop' ] = $new_instance[ 'stop' ];
  107. $instance[ 'sweetspot' ] = $new_instance[ 'sweetspot' ];
  108. $instance[ 'disablekb' ] = $new_instance[ 'disablekb' ];
  109. $instance[ 'autohide' ] = $new_instance[ 'autohide' ];
  110. $instance[ 'controls' ] = $new_instance[ 'controls' ];
  111. $instance[ 'profile' ] = $new_instance[ 'profile' ];
  112. $instance[ 'list' ] = $new_instance[ 'list' ];
  113. $instance[ 'template' ] = $new_instance[ 'template' ];
  114. $instance[ 'hd' ] = $new_instance[ 'hd' ];
  115. return $instance;
  116. }
  117. /**
  118. * Widget Admin control form
  119. *
  120. * Define admin file
  121. *
  122. * @since 2.0
  123. *
  124. * @param string $instance Instance
  125. */
  126. function form( $instance ) {
  127. include ( WP_PLUGIN_DIR . '/youtube-embed/includes/options-widgets.php' );
  128. }
  129. }
  130. /**
  131. * Register Widget
  132. *
  133. * Register widget when loading the WP core
  134. *
  135. * @since 2.0
  136. */
  137. function youtube_embed_register_widgets() {
  138. register_widget( 'YouTubeEmbedWidget' );
  139. }
  140. add_action( 'widgets_init', 'youtube_embed_register_widgets' );
  141. }
  142. ?>