PageRenderTime 52ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/youtube-embed/includes/options-general.php

https://bitbucket.org/crypticrod/sr_wp_code
PHP | 257 lines | 191 code | 51 blank | 15 comment | 44 complexity | 5044ae3bbf5b2101b9779467a027c520 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. * General Options Page
  4. *
  5. * Screen for generic options
  6. *
  7. * @package YouTubeEmbed
  8. * @since 2.0
  9. */
  10. ?>
  11. <div class="wrap">
  12. <div class="icon32"><img src="<?php echo plugins_url(); ?>/youtube-embed/images/screen_icon.png" alt="" title="" height="32px" width="32px"/><br /></div>
  13. <h2>Artiss YouTube Embed Options</h2>
  14. <?php
  15. // If options have been updated on screen, update the database
  16. if ( ( !empty( $_POST ) ) && ( check_admin_referer( 'youtube-embed-general', 'youtube_embed_general_nonce' ) ) ) {
  17. $options[ 'editor_button' ] = $_POST[ 'youtube_embed_editor_button' ];
  18. $options[ 'admin_bar' ] = $_POST[ 'youtube_embed_admin_bar' ];
  19. $options[ 'profile_no' ] = $_POST[ 'youtube_embed_profile_no' ];
  20. // If the number of profiles is less than zero, put it to 0
  21. if ( $options[ 'profile_no' ] < 0 ) { $options[ 'profile_no' ] = 0; }
  22. $options[ 'list_no' ] = $_POST[ 'youtube_embed_list_no' ];
  23. // If the number of lists is less than 1, put it to 1
  24. if ( $options[ 'list_no' ] < 1 ) { $options[ 'list_no' ] = 1; }
  25. $options[ 'embed_cache' ] = $_POST[ 'youtube_embed_embed_cache' ];
  26. $options[ 'info_cache' ] = $_POST[ 'youtube_embed_info_cache' ];
  27. $options[ 'transcript_cache' ] = $_POST[ 'youtube_embed_transcript_cache' ];
  28. $options[ 'fetch_title' ] = $_POST[ 'youtube_embed_fetch_title' ];
  29. $options[ 'alt_profile' ] = $_POST[ 'youtube_embed_alt_profile' ];
  30. $options[ 'alt_profile2' ] = $_POST[ 'youtube_embed_alt_profile2' ];
  31. $options[ 'bracket' ] = $_POST[ 'youtube_embed_bracket' ];
  32. $options[ 'alt' ] = $_POST[ 'youtube_embed_alt' ];
  33. $options[ 'other_profile' ] = $_POST[ 'youtube_embed_other_profile' ];
  34. $options[ 'url_profile' ] = $_POST[ 'youtube_embed_url_profile' ];
  35. $options[ 'comments' ] = $_POST[ 'youtube_embed_comments' ];
  36. $options[ 'comments_profile' ] = $_POST[ 'youtube_embed_comments_profile' ];
  37. $options[ 'metadata' ] = $_POST[ 'youtube_embed_metadata' ];
  38. $options[ 'feed' ] = $_POST[ 'youtube_embed_feed' ];
  39. $options[ 'api' ] = $_POST[ 'youtube_embed_api' ];
  40. $options[ 'error_message' ] = htmlspecialchars( $_POST[ 'youtube_embed_error_message' ] );
  41. $options[ 'thumbnail' ] = $_POST[ 'youtube_embed_thumbnail' ];
  42. // Update the options
  43. update_option( 'youtube_embed_general', $options );
  44. // Update the alternative shortcodes
  45. $shortcode[ 1 ] = $_POST[ 'youtube_embed_shortcode' ];
  46. $shortcode[ 1 ] = trim( $shortcode[ 1 ], '[]' );
  47. $shortcode[ 2 ] = $_POST[ 'youtube_embed_shortcode2' ];
  48. $shortcode[ 2 ] = trim( $shortcode[ 2 ], '[]' );
  49. update_option( 'youtube_embed_shortcode', $shortcode );
  50. // Update the URL override
  51. update_option( 'youtube_embed_url', $_POST[ 'youtube_embed_url' ] );
  52. echo '<div class="updated fade"><p><strong>' . __( 'Settings Saved.' ) . "</strong></p></div>\n";
  53. }
  54. // Get options
  55. $options = ye_set_general_defaults();
  56. $shortcode = ye_set_shortcode_option();
  57. $url = ye_set_url_option();
  58. ?>
  59. <p><?php _e( 'These are the general settings for Artiss YouTube Embed. Please select <a href="http://www.artiss.co.uk/wp-admin/admin.php?page=youtube-embed-profiles">Profiles</a> for default embedding settings.' ); ?></p>
  60. <form method="post" action="<?php echo get_bloginfo( 'wpurl' ).'/wp-admin/admin.php?page=youtube-embed-general' ?>">
  61. <span class="yt_heading"><?php _e( 'Embedding' ); ?></span>
  62. <table class="form-table">
  63. <tr>
  64. <th scope="row"><?php _e( 'Add Metadata' ); ?></th>
  65. <td><input type="checkbox" name="youtube_embed_metadata" value="1"<?php if ( $options[ 'metadata' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Allow rich metadata to be added to code. <a href="http://www.artiss.co.uk/artiss-youtube-embed/further-help#ye-metadata">Learn more</a>' ); ?></span></td>
  66. </tr>
  67. <tr>
  68. <th scope="row"><?php _e( 'URL Embedding' ); ?></th>
  69. <td><input type="checkbox" name="youtube_embed_url" value="1"<?php if ( $url == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Override built-in WP processing of YouTube URLs. <a href="http://www.artiss.co.uk/artiss-youtube-embed/further-help#ye-urls">Learn more</a>' ); ?></span></td>
  70. </tr>
  71. <tr>
  72. <th scope="row">&nbsp;&nbsp;&nbsp;&nbsp;<?php _e( 'Profile to use' ); ?></th>
  73. <td><select name="youtube_embed_url_profile">
  74. <?php ye_generate_profile_list( $options[ 'url_profile' ], $options[ 'profile_no' ] ) ?>
  75. </select></td>
  76. </tr>
  77. <tr>
  78. <th scope="row"><?php _e( 'Comment Embedding' ); ?></th>
  79. <td><input type="checkbox" name="youtube_embed_comments" value="1"<?php if ( $options[ 'comments' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Allow YouTube URLs in comments - will display as embedded videos. <a href="http://www.artiss.co.uk/artiss-youtube-embed/further-help#ye-comments">Learn more</a>' ); ?></span></td>
  80. </tr>
  81. <tr>
  82. <th scope="row">&nbsp;&nbsp;&nbsp;&nbsp;<?php _e( 'Profile to use' ); ?></th>
  83. <td><select name="youtube_embed_comments_profile">
  84. <?php ye_generate_profile_list( $options[ 'comments_profile' ], $options[ 'profile_no' ] ) ?>
  85. </select></td>
  86. </tr>
  87. <tr>
  88. <th scope="row"><?php _e( 'Feed' ); ?></th>
  89. <td><select name="youtube_embed_feed">
  90. <option value="t"<?php if ( $options[ 'feed' ] == "t" ) { echo " selected='selected'"; } ?>><?php _e ( 'Text link' ); ?></option>
  91. <option value="v"<?php if ( $options[ 'feed' ] == "v" ) { echo " selected='selected'"; } ?>><?php _e ( 'Thumbnail' ); ?></option>
  92. <option value="b"<?php if ( $options[ 'feed' ] == "b" ) { echo " selected='selected'"; } ?>><?php _e ( 'Thumbnail &amp; Text Link' ); ?></option>
  93. </select>&nbsp;<span class="description"><?php _e( 'Videos cannot be embedded in feeds. Select how you wish them to be shown instead' ); ?></span></td>
  94. </tr>
  95. <tr>
  96. <th scope="row">&nbsp;&nbsp;&nbsp;&nbsp;<?php _e( 'Thumbnail to use' ); ?></th>
  97. <td><select name="youtube_embed_thumbnail">
  98. <option value="default"<?php if ( $options[ 'thumbnail' ] == "default" ) { echo " selected='selected'"; } ?>><?php _e ( 'Default' ); ?></option>
  99. <option value="hqdefault"<?php if ( $options[ 'thumbnail' ] == "hqdefault" ) { echo " selected='selected'"; } ?>><?php _e ( 'Default (HQ)' ); ?></option>
  100. <option value="1"<?php if ( $options[ 'thumbnail' ] == "1" ) { echo " selected='selected'"; } ?>><?php _e ( 'Start' ); ?></option>
  101. <option value="2"<?php if ( $options[ 'thumbnail' ] == "2" ) { echo " selected='selected'"; } ?>><?php _e ( 'Middle' ); ?></option>
  102. <option value="3"<?php if ( $options[ 'thumbnail' ] == "3" ) { echo " selected='selected'"; } ?>><?php _e ( 'End' ); ?></option>
  103. </select>&nbsp;<span class="description"><?php _e( 'Which thumbnail to use' ); ?></span></td>
  104. </tr>
  105. </table>
  106. <br/><span class="yt_heading"><?php _e( 'Alternative Shortcodes' ); ?></span><br/><br/>Specify up to 2 alternative shortcodes to compliment the standard <code>youtube</code> shortcode. <strong>NB: These should be specified without the surrounding square brackets.</strong>
  107. <table class="form-table">
  108. <tr>
  109. <th scope="row"><?php _e( 'Alternative Shortcode 1' ); ?></th>
  110. <td><input type="text" size="30" name="youtube_embed_shortcode" value="<?php echo $shortcode[ 1 ]; ?>"/></td>
  111. </tr>
  112. <tr>
  113. <th scope="row">&nbsp;&nbsp;&nbsp;&nbsp;<?php _e( 'Profile to use' ); ?></th>
  114. <td><select name="youtube_embed_alt_profile">
  115. <?php ye_generate_profile_list( $options[ 'alt_profile' ], $options[ 'profile_no' ] ) ?>
  116. </select></td>
  117. </tr>
  118. <tr>
  119. <th scope="row"><?php _e( 'Alternative Shortcode 2' ); ?></th>
  120. <td><input type="text" size="30" name="youtube_embed_shortcode2" value="<?php echo $shortcode[ 2 ]; ?>"/></td>
  121. </tr>
  122. <tr>
  123. <th scope="row">&nbsp;&nbsp;&nbsp;&nbsp;<?php _e( 'Profile to use' ); ?></th>
  124. <td><select name="youtube_embed_alt_profile2">
  125. <?php ye_generate_profile_list( $options[ 'alt_profile2' ], $options[ 'profile_no' ] ) ?>
  126. </select></td>
  127. </tr>
  128. </table>
  129. <br/><span class="yt_heading"><?php _e( 'Migration' ); ?></span><br/><br/>Switch on compatibility with other embedding plugins. For more details on migrating from another plugin, please <a href="http://www.artiss.co.uk/artiss-youtube-embed/compatibility">click here</a>.
  130. <table class="form-table">
  131. <tr>
  132. <th scope="row"><?php _e( 'Bracket Embedding' ); ?></th>
  133. <td><input type="checkbox" name="youtube_embed_bracket" value="1"<?php if ( $options[ 'bracket' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Allow embedding using URLs within brackets. Activating impacts performance' ); ?></span></td>
  134. </tr>
  135. <tr>
  136. <th scope="row"><?php _e( 'Alternative Embedding' ); ?></th>
  137. <td><input type="checkbox" name="youtube_embed_alt" value="1"<?php if ( $options[ 'alt' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Allow all other types of embedding. Activating impacts performance' ); ?></span></td>
  138. </tr>
  139. <tr>
  140. <th scope="row">&nbsp;&nbsp;&nbsp;&nbsp;<?php _e( 'Profile to use' ); ?></th>
  141. <td><select name="youtube_embed_other_profile">
  142. <?php ye_generate_profile_list( $options[ 'other_profile' ], $options[ 'profile_no' ] ) ?>
  143. </select>&nbsp;<span class="description"><?php _e( 'For above 2 options' ); ?></span></td>
  144. </tr>
  145. </table>
  146. <br/><span class="yt_heading"><?php _e( 'Admin Options' ); ?></span>
  147. <table class="form-table">
  148. <tr>
  149. <th scope="row"><?php _e( 'Show YouTube Button' ); ?></th>
  150. <td><input type="checkbox" name="youtube_embed_editor_button" value="1"<?php if ( $options[ 'editor_button' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Show the YouTube button on the post editor' ); ?></span></td>
  151. </tr>
  152. <tr>
  153. <th scope="row"><?php _e( 'Add to Admin Bar' ); ?></th>
  154. <td><input type="checkbox" name="youtube_embed_admin_bar" value="1"<?php if ( $options[ 'admin_bar' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Add link to options screen to Admin Bar' ); ?></span></td>
  155. </tr>
  156. </table>
  157. <br/><span class="yt_heading"><?php _e( 'Profile &amp; List Sizes' ); ?></span>
  158. <table class="form-table">
  159. <tr>
  160. <th scope="row"><?php _e( 'Number of Profiles' ); ?></th>
  161. <td><input type="text" size="2" maxlength="2" name="youtube_embed_profile_no" value="<?php echo $options[ 'profile_no' ]; ?>"/>&nbsp;<span class="description"><?php _e( 'Maximum number of profiles' ); ?></span></td>
  162. </tr>
  163. <tr>
  164. <th scope="row"><?php _e( 'Number of Lists' ); ?></th>
  165. <td><input type="text" size="2" maxlength="2" name="youtube_embed_list_no" value="<?php echo $options[ 'list_no' ]; ?>"/>&nbsp;<span class="description"><?php _e( 'Maximum number of lists' ); ?></span></td>
  166. </tr>
  167. </table>
  168. <br/><span class="yt_heading"><?php _e( 'Performance' ); ?></span>
  169. <table class="form-table">
  170. <tr>
  171. <th scope="row"><?php _e( 'Embed Cache' ); ?></th>
  172. <td><input type="text" size="3" maxlength="3" name="youtube_embed_embed_cache" value="<?php echo $options[ 'embed_cache' ]; ?>"/>&nbsp;<span class="description"><?php _e( 'How many hours to retain embed output. 0 to switch off' ); ?></span></td>
  173. </tr>
  174. <tr>
  175. <th scope="row"><?php _e( 'Video Information Cache' ); ?></th>
  176. <td><input type="text" size="3" maxlength="3" name="youtube_embed_info_cache" value="<?php echo $options[ 'info_cache' ]; ?>"/>&nbsp;<span class="description"><?php _e( 'How many hours to retain video information, including it\'s validity. 0 to switch off' ); ?></span></td>
  177. </tr>
  178. <tr>
  179. <th scope="row"><?php _e( 'Transcript Cache' ); ?></th>
  180. <td><input type="text" size="3" maxlength="3" name="youtube_embed_transcript_cache" value="<?php echo $options[ 'transcript_cache' ]; ?>"/>&nbsp;<span class="description"><?php _e( 'How many hours to store transcripts for in cache. 0 to switch off' ); ?></span></td>
  181. </tr>
  182. </table>
  183. <br/><span class="yt_heading"><?php _e( 'YouTube API' ); ?></span>
  184. <p><?php _e( 'The YouTube API is used to validate video IDs and to determine if it is a video or playlist.' ); ?></p>
  185. <table class="form-table">
  186. <tr>
  187. <th scope="row"><?php _e( 'API State' ); ?></th>
  188. <td><select name="youtube_embed_api">
  189. <option value="0"<?php if ( $options[ 'api' ] == "0" ) { echo " selected='selected'"; } ?>><?php _e ( 'API should not be used' ); ?></option>
  190. <option value="1"<?php if ( $options[ 'api' ] == "1" ) { echo " selected='selected'"; } ?>><?php _e ( 'HTTP API used and errors are reported' ); ?></option>
  191. <option value="2"<?php if ( $options[ 'api' ] == "2" ) { echo " selected='selected'"; } ?>><?php _e ( 'HTTPS API used and errors are reported' ); ?></option>
  192. <option value="3"<?php if ( $options[ 'api' ] == "3" ) { echo " selected='selected'"; } ?>><?php _e ( 'HTTP API used and no errors are reported' ); ?></option>
  193. <option value="4"<?php if ( $options[ 'api' ] == "4" ) { echo " selected='selected'"; } ?>><?php _e ( 'HTTPS API used and no errors are reported' ); ?></option>
  194. </select>&nbsp;<span class="description"><?php _e( '' ); ?></span></td>
  195. </tr>
  196. </table>
  197. <br/><span class="yt_heading"><?php _e( 'Error Reporting' ); ?></span>
  198. <p><?php _e( 'Playback errors are within the XHTML source code as comments - parameter errors and other types are displayed on the post output.' ); ?></p>
  199. <table class="form-table"><tr>
  200. <th scope="row"><?php _e( 'Video Playback Error Message' ); ?></th>
  201. <td><input type="text" size="60" name="youtube_embed_error_message" value="<?php echo $options[ 'error_message' ]; ?>"/>&nbsp;<span class="description"><?php _e( 'This is the message that will be shown on the post' ); ?></span></td>
  202. </tr></table>
  203. <?php wp_nonce_field( 'youtube-embed-general','youtube_embed_general_nonce', true, true ); ?>
  204. <p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php _e( 'Save Settings' ); ?>"/></p>
  205. </form>
  206. </div>