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

/Settings.php

https://gitlab.com/waltspence/woocommerce-html5-video
PHP | 220 lines | 199 code | 5 blank | 16 comment | 7 complexity | 469ef148c6ca315eeb18a00d963acc38 MD5 | raw file
  1. <?php
  2. namespace WooCommerceHTML5Video;
  3. class Settings {
  4. /**
  5. * Function to register plugin settings
  6. * attached to: admin_init action
  7. */
  8. public static function register_my_setting() {
  9. register_setting( 'dimensions_group', 'wo_di_config_video_width', 'intval' );
  10. register_setting( 'dimensions_group', 'wo_di_config_video_height', 'intval' );
  11. register_setting( 'dimensions_group', 'wo_di_config_video_tab_name' );
  12. register_setting( 'dimensions_group', 'wo_di_config_video_tab_position', 'intval' );
  13. register_setting( 'dimensions_group', 'wo_di_video_hide_tab', 'intval' );
  14. register_setting( 'dimensions_group', 'wo_di_video_size_forcing', 'intval' );
  15. register_setting( 'dimensions_group', 'wo_di_video_disable_iframe', 'intval' );
  16. register_setting( 'dimensions_group', 'wo_di_config_video_description', 'intval' );
  17. }
  18. /**
  19. * Function to add a plugin configuration page
  20. * attached to: admin_menu action
  21. */
  22. public static function settings_page() {
  23. add_options_page(
  24. 'WooCommerce Html5 Video Settings',
  25. 'WooCommerce Html5 Video',
  26. 'manage_options',
  27. 'html5-video-settings',
  28. array(__CLASS__, 'settings_page_content')
  29. );
  30. }
  31. /**
  32. * Function to add settngs link in plugins page
  33. * attached to: plugin_action_links_<plugin> filter
  34. */
  35. public static function add_settings_link( $links ) {
  36. ob_start();
  37. ?>
  38. <a href="options-general.php?page=html5-video-settings">Settings</a>
  39. <?php
  40. $settings_link = ob_get_contents();
  41. ob_end_clean();
  42. array_push( $links, $settings_link );
  43. ob_start();
  44. ?>
  45. <a title="documentation" target="_blank" href="http://www.webilop.com/products/woocommerce-html5-video/">Docs</a>
  46. <?php
  47. $docs_link = ob_get_contents();
  48. ob_end_clean();
  49. array_push( $links, $docs_link);
  50. return $links;
  51. }
  52. /**
  53. * Function to create the content of the configuration page
  54. * callback in: settings_page
  55. */
  56. public static function settings_page_content() {
  57. if (!current_user_can('manage_options')) {
  58. wp_die(__('You do not have sufficient permissions to access this page.'));
  59. }
  60. ?>
  61. <div class="wrap">
  62. <?php screen_icon(); ?>
  63. <h2>WooCommerce Html5 Video Settings</h2>
  64. <form class="html5_video" method="post" action="options.php" onsubmit="return check_form_settings();">
  65. <?php
  66. settings_fields('dimensions_group');
  67. do_settings_fields('dimensions_group','html5-video-settings')
  68. ?>
  69. <p>
  70. <strong>
  71. <?= __('Configure the default video dimensions and the video tab name')?>:
  72. </strong>
  73. </p>
  74. <table class="form-table">
  75. <tr valign="top">
  76. <th scope="row">
  77. <?= __('Video Tab Name')?>:
  78. </th>
  79. <td>
  80. <?php
  81. if (strcmp(get_option('wo_di_config_video_tab_name'), ""))
  82. $value = get_option('wo_di_config_video_tab_name');
  83. else
  84. $value = "Video";
  85. ?>
  86. <input type="text" name="wo_di_config_video_tab_name" value="<?= $value ?>" />
  87. </td>
  88. </tr>
  89. <tr valign="top">
  90. <th scope="row">
  91. <?= __('Video Width')?>:
  92. </th>
  93. <td>
  94. <input type="text" name="wo_di_config_video_width" id="wo_di_config_video_width" value="<?= get_option('wo_di_config_video_width'); ?>" />
  95. </td>
  96. </tr>
  97. <tr valign="top">
  98. <th scope="row">
  99. <?= __('Video Height')?>:
  100. </th>
  101. <td>
  102. <input type="text" name="wo_di_config_video_height" id="wo_di_config_video_height" value="<?= get_option('wo_di_config_video_height'); ?>" />
  103. </td>
  104. </tr>
  105. <tr valign="top">
  106. <th scope="row">
  107. <?= __('Force video dimensions (it does not work with iframes)','html5_video')?>:
  108. </th>
  109. <td>
  110. <?php $checked = (get_option('wo_di_video_size_forcing') == 1)? "checked" : ""; ?>
  111. <input type="checkbox" name="wo_di_video_size_forcing" id="wo_di_video_size_forcing" <?= $checked ?> value="1" />
  112. </td>
  113. </tr>
  114. <tr valign="top">
  115. <th scope="row">
  116. <?= __('Video Tab Position (0-index)')?>:
  117. </th>
  118. <td>
  119. <?php
  120. if (strcmp(get_option('wo_di_config_video_tab_position'), ""))
  121. $value = get_option('wo_di_config_video_tab_position');
  122. else
  123. $value = "1";
  124. ?>
  125. <input type="text" name="wo_di_config_video_tab_position" value="<?= $value ?>" />
  126. </td>
  127. </tr>
  128. <tr valign="top">
  129. <th scope="row">
  130. <?= __('Show video tab if there is no video','html5_video')?>:
  131. </th>
  132. <td>
  133. <?php $checked = (get_option('wo_di_video_hide_tab') == 1)? "checked" : ""; ?>
  134. <input type="checkbox" name="wo_di_video_hide_tab" <?= $checked ?> value="1" />
  135. </td>
  136. </tr>
  137. <tr valign="top">
  138. <th scope="row">
  139. <?= __('Disable embedded videos with iframes','html5_video')?>:
  140. </th>
  141. <td>
  142. <?php $checked = (get_option('wo_di_video_disable_iframe') == 1)? "checked" : ""; ?>
  143. <input type="checkbox" name="wo_di_video_disable_iframe" <?= $checked ?> value="1" />
  144. </td>
  145. </tr>
  146. <tr valign="top">
  147. <th scope="row">
  148. <?= __('Disable general video description','html5_video')?>:
  149. </th>
  150. <td>
  151. <?php $checked = (get_option('wo_di_config_video_description') == 1)? "checked" : ""; ?>
  152. <input type="checkbox" name="wo_di_config_video_description" <?= $checked ?> value="1" />
  153. </td>
  154. </tr>
  155. </table>
  156. <span id="span_errors"></span>
  157. <?php submit_button(); ?>
  158. <span>
  159. <a title="WooCommerce HTML5 Video" href="http://www.webilop.com/products/woocommerce-html5-video/" target="_blank">WooCommerce Html5 Video Documentation</a>
  160. </span>
  161. </form>
  162. <table class="rate-about-table">
  163. <tr>
  164. <td>
  165. <div class="rate-div">
  166. <h3 class="hndle">
  167. <?php _e('Rate it!', 'html5_video') ?>
  168. </h3>
  169. <p>
  170. <?php _e('If you like this plugin please'); ?> <a title="rate it" href="https://wordpress.org/support/view/plugin-reviews/woocommerce-html5-video" target="_blank">leave us a rating</a>. In advance, thanks from Webilop team! &nbsp;
  171. <span class="rating">
  172. <input type="radio" class="rating-input" id="rating-input-1-5" name="rating-input-1" onclick="window.open('https://wordpress.org/support/view/plugin-reviews/woocommerce-html5-video')">
  173. <label for="rating-input-1-5" class="rating-star"></label>
  174. <input type="radio" class="rating-input" id="rating-input-1-4" name="rating-input-1" onclick="window.open('https://wordpress.org/support/view/plugin-reviews/woocommerce-html5-video')">
  175. <label for="rating-input-1-4" class="rating-star"></label>
  176. <input type="radio" class="rating-input" id="rating-input-1-3" name="rating-input-1" onclick="window.open('https://wordpress.org/support/view/plugin-reviews/woocommerce-html5-video')">
  177. <label for="rating-input-1-3" class="rating-star"></label>
  178. <input type="radio" class="rating-input" id="rating-input-1-2" name="rating-input-1" onclick="window.open('https://wordpress.org/support/view/plugin-reviews/woocommerce-html5-video')">
  179. <label for="rating-input-1-2" class="rating-star"></label>
  180. <input type="radio" class="rating-input" id="rating-input-1-1" name="rating-input-1" onclick="window.open('https://wordpress.org/support/view/plugin-reviews/woocommerce-html5-video')">
  181. <label for="rating-input-1-1" class="rating-star"></label>
  182. </span>
  183. </p>
  184. </div>
  185. </td>
  186. </tr>
  187. <tr>
  188. <td>
  189. <div class="about-webilop">
  190. <h3 class="hndle">
  191. <?php _e('About','html5_video');?>
  192. </h3>
  193. <div class="inside">
  194. <p>
  195. <strong>WooCommerce Html5 video </strong><?php _e('was developed by ', 'html5_video');?><a title="Webilop. web and mobile development" href="http://www.webilop.com" target="_blank">Webilop</a>
  196. </p>
  197. <p>
  198. <?php _e('Webilop is a company focused on web and mobile solutions. We develop custom mobile applications and templates and plugins for CMSs such as Wordpress and Joomla!', 'html5_video');?>
  199. </p>
  200. <div>
  201. <h4><?php _e('Follow us', 'html5_video')?></h4>
  202. <a title="Facebook" href="https://www.facebook.com/webilop" target="_blank"><img src="<?= WP_PLUGIN_URL;?>/woocommerce-html5-video/images/facebook.png"></a>
  203. <a title="LinkedIn" href="http://www.linkedin.com/company/webilop" target="_blank"><img src="<?= WP_PLUGIN_URL;?>/woocommerce-html5-video/images/linkedin.png"></a>
  204. <a title="Twitter" href="https://twitter.com/webilop" target="_blank"><img src="<?= WP_PLUGIN_URL;?>/woocommerce-html5-video/images/twitter.png"></a>
  205. <a title="Google Plus" href="https://www.google.com/+Webilop" target="_blank" rel="publisher"><img src="<?= WP_PLUGIN_URL;?>/woocommerce-html5-video/images/gplus.png"></a>
  206. </div>
  207. </div>
  208. </div>
  209. </td>
  210. </tr>
  211. </table>
  212. </div>
  213. <?php
  214. }
  215. }