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

/wp-content/plugins/LayerSlider/list.php

https://github.com/alniko009/magic
PHP | 255 lines | 231 code | 16 blank | 8 comment | 16 complexity | 764147bef6bd7540d148fef69da6ff7a MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. // Get WPDB Object
  3. global $wpdb;
  4. // Table name
  5. $table_name = $wpdb->prefix . "layerslider";
  6. // Get sliders
  7. $sliders = lsSliders(200, false, true);
  8. // Custom capability
  9. $custom_capability = $custom_role = get_option('layerslider_custom_capability', 'manage_options');
  10. $default_capabilities = array('manage_network', 'manage_options', 'publish_pages', 'publish_posts', 'edit_posts');
  11. if(in_array($custom_capability, $default_capabilities)) {
  12. $custom_capability = '';
  13. $custom_role_placeholder = "Select 'Custom' to enter a capability";
  14. } else {
  15. $custom_role = 'custom';
  16. }
  17. // Auto-updates
  18. $code = get_option('layerslider-purchase-code', '');
  19. $validity = get_option('layerslider-validated', '0');
  20. $channel = get_option('layerslider-release-channel', 'stable');
  21. // Get screen options
  22. $lsScreenOptions = get_option('lsScreenOptions', '0');
  23. $lsScreenOptions = ($lsScreenOptions == 0) ? array() : $lsScreenOptions;
  24. $lsScreenOptions = is_array($lsScreenOptions) ? $lsScreenOptions : unserialize($lsScreenOptions);
  25. // Defaults
  26. if(!isset($lsScreenOptions['showTooltips'])) {
  27. $lsScreenOptions['showTooltips'] = 'true';
  28. }
  29. ?>
  30. <div id="ls-screen-options" class="metabox-prefs hidden">
  31. <div id="screen-options-wrap" class="hidden">
  32. <form id="ls-screen-options-form" action="<?php echo $_SERVER['REQUEST_URI']?>" method="post">
  33. <h5>Show on screen</h5>
  34. <label>
  35. <input type="checkbox" name="showTooltips"<?php echo $lsScreenOptions['showTooltips'] == 'true' ? ' checked="checked"' : ''?>> Tooltips
  36. </label>
  37. </form>
  38. </div>
  39. <div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
  40. <a href="#screen-options-wrap" id="show-settings-link" class="show-settings">Screen Options</a>
  41. </div>
  42. </div>
  43. <?php if(isset($_GET['message'])) : ?>
  44. <div class="<?php echo isset($_GET['error']) ? 'error' : 'updated' ?>"><?php echo $_GET['message'] ?></div>
  45. <?php endif; ?>
  46. <div class="wrap">
  47. <div class="ls-icon-layers"></div>
  48. <h2>
  49. <?php _e('LayerSlider sliders', 'LayerSlider') ?>
  50. <a href="?page=layerslider_add_new" class="add-new-h2"><?php _e('Add New', 'LayerSlider') ?></a>
  51. <a href="?page=layerslider&action=import_sample" class="add-new-h2"><?php _e('Import sample sliders', 'LayerSlider') ?></a>
  52. </h2>
  53. <div class="ls-box ls-slider-list">
  54. <table>
  55. <thead>
  56. <tr>
  57. <td>ID</td>
  58. <td><?php _e('Name', 'LayerSlider') ?></td>
  59. <td><?php _e('Shortcode', 'LayerSlider') ?></td>
  60. <td><?php _e('Actions', 'LayerSlider') ?></td>
  61. <td><?php _e('Created', 'LayerSlider') ?></td>
  62. <td><?php _e('Modified', 'LayerSlider') ?></td>
  63. </tr>
  64. </thead>
  65. <tbody>
  66. <?php if(!empty($sliders)) : ?>
  67. <?php foreach($sliders as $key => $item) : ?>
  68. <?php $name = empty($item['name']) ? 'Unnamed' : $item['name']; ?>
  69. <tr>
  70. <td><?php echo $item['id'] ?></td>
  71. <td><a href="?page=layerslider&action=edit&id=<?php echo $item['id'] ?>"><?php echo $name ?></a></td>
  72. <td>[layerslider id="<?php echo $item['id'] ?>"]</td>
  73. <td>
  74. <a href="?page=layerslider&action=edit&id=<?php echo $item['id'] ?>"><?php _e('Edit', 'LayerSlider') ?></a> |
  75. <a href="?page=layerslider&action=duplicate&id=<?php echo $item['id'] ?>"><?php _e('Duplicate', 'LayerSlider') ?></a> |
  76. <a href="?page=layerslider&action=remove&id=<?php echo $item['id'] ?>" class="remove"><?php _e('Remove', 'LayerSlider') ?></a>
  77. </td>
  78. <td><?php echo date('M. d. Y.', $item['date_c']) ?></td>
  79. <td><?php echo date('M. d. Y.', $item['date_m']) ?></td>
  80. </tr>
  81. <?php endforeach; ?>
  82. <?php endif; ?>
  83. <?php if(empty($sliders)) : ?>
  84. <tr>
  85. <td colspan="6"><?php _e("You didn't create a slider yet.", "LayerSlider") ?></td>
  86. </tr>
  87. <?php endif; ?>
  88. </tbody>
  89. </table>
  90. </div>
  91. <?php if($GLOBALS['lsAutoUpdateBox'] == true) : ?>
  92. <form action="<?php echo $_SERVER['REQUEST_URI'] ?>" method="post" class="ls-box ls-settings ls-auto-update">
  93. <input type="hidden" name="action" value="layerslider_verify_purchase_code">
  94. <h3 class="header"><?php _e('Auto-updates', 'LayerSlider') ?></h3>
  95. <table>
  96. <tbody>
  97. <tr>
  98. <td>
  99. <?php _e('Purchase code:', 'LayerSlider') ?>
  100. <input type="texT" name="purchase_code" value="<?php echo $code ?>" class="key" placeholder="bc8e2b24-3f8c-4b21-8b4b-90d57a38e3c7" data-help="<?php _e('To receive auto-updates, you need to enter your item purchase code. You can find it on your CodeCanyon downloads page, just click on the Download button and choose the "Licence Certificate" option. This will download a text file that contains your purchase code.', 'LayerSlider') ?>">
  101. <?php _e('Release channel:', 'LayerSlider') ?>
  102. <label><input type="radio" name="channel" value="stable" <?php echo ($channel === 'stable') ? 'checked="checked"' : ''?>> <?php _e('Stable', 'LayerSlider') ?></label>
  103. <label data-help="<?php _e('Although pre-release versions should be fine, they might contain unknown issues, and are not recommended for sites in production.', 'LayerSlider') ?>">
  104. <input type="radio" name="channel" value="beta" <?php echo ($channel === 'beta') ? 'checked="checked"' : ''?>> <?php _e('Beta', 'LayerSlider') ?>
  105. </label>
  106. </td>
  107. </tr>
  108. </tbody>
  109. <tfoot>
  110. <tr>
  111. <td colspan="2">
  112. <button class="button"><?php _e('Save changes', 'LayerSlider') ?></button>
  113. <span style="<?php echo ($validity == '0' && $code != '') ? 'color: #c33219;' : 'color: #4b982f'?>">
  114. <?php
  115. if($validity == '1') {
  116. _e('Thank you for purchasing LayerSlider WP. You successfully validated your purchase code for auto-updates.', 'LayerSlider');
  117. } else if($code != '') {
  118. _e("Your purchase code doesn't appear to be valid. Please make sure that you entered your purchase code correctly.", "LayerSlider");
  119. }
  120. ?>
  121. </span>
  122. </td>
  123. </tr>
  124. </tfoot>
  125. </table>
  126. </form>
  127. <?php endif; ?>
  128. <div class="columns clearfix">
  129. <div class="half">
  130. <div class="ls-import-export-box ls-box">
  131. <h3 class="header medium"><?php _e('Import & Export Sliders', 'LayerSlider') ?></h3>
  132. <form action="<?php echo $_SERVER['REQUEST_URI'] ?>" method="post" enctype="multipart/form-data" class="ls-import-box">
  133. <input type="hidden" name="ls-import" value="1">
  134. <table data-help="<?php _e('Choose a LayerSlider export file downloaded previously to import your sliders. To import from older versions, you need to create a file and paste the export code into it. Only the file contents matters, its name does not.', 'LayerSlider') ?>">
  135. <tbody>
  136. <tr>
  137. <td><?php _e('Import Sliders', 'LayerSlider') ?></td>
  138. <td><input type="file" name="import_file"></td>
  139. <td><button class="button"><?php _e('Import', 'LayerSlider') ?></button></td>
  140. </tr>
  141. </tbody>
  142. </table>
  143. </form>
  144. <form action="<?php echo $_SERVER['REQUEST_URI'] ?>" method="post">
  145. <input type="hidden" name="ls-export" value="1">
  146. <table data-help="<?php _e('Downloads an export file that contains your selected sliders to import on your new site.', 'LayerSlider') ?>">
  147. <tbody>
  148. <tr>
  149. <td><?php _e('Export Sliders', 'LayerSlider') ?></td>
  150. <td>
  151. <select name="sliders">
  152. <option value="-1">All Sliders</option>
  153. <?php foreach($sliders as $slider) : ?>
  154. <option value="<?php echo $slider['id'] ?>">
  155. #<?php echo str_replace(' ', '&nbsp;', str_pad($slider['id'], 3, " ")) ?> -
  156. <?php echo apply_filters('ls_slider_title', $slider['name'], 25) ?>
  157. </option>
  158. <?php endforeach; ?>
  159. </select>
  160. </td>
  161. <td><button class="button"><?php _e('Export', 'LayerSlider') ?></button></td>
  162. </tr>
  163. </tbody>
  164. </table>
  165. </form>
  166. </div>
  167. </div>
  168. <div class="half">
  169. <form action="<?php echo $_SERVER['REQUEST_URI'] ?>" method="post" class="ls-box ls-import-export-box" id="ls-permission-form">
  170. <input type="hidden" name="ls-access-permission" value="1">
  171. <h3 class="header medium"><?php _e('Allow LayerSlider access to users with ...', 'LayerSlider') ?></h3>
  172. <table>
  173. <tbody>
  174. <tr>
  175. <td><?php _e('Role', 'LayerSlider') ?></td>
  176. <td>
  177. <select name="custom_role">
  178. <?php if(is_multisite()) : ?>
  179. <option value="manage_network" <?php echo ($custom_role == 'manage_network') ? 'selected="selected"' : '' ?>>Super Admin</option>
  180. <?php endif; ?>
  181. <option value="manage_options" <?php echo ($custom_role == 'manage_options') ? 'selected="selected"' : '' ?>>Admin</option>
  182. <option value="publish_pages" <?php echo ($custom_role == 'publish_pages') ? 'selected="selected"' : '' ?>>Editor</option>
  183. <option value="publish_posts" <?php echo ($custom_role == 'publish_posts') ? 'selected="selected"' : '' ?>>Author</option>
  184. <option value="edit_posts" <?php echo ($custom_role == 'edit_posts') ? 'selected="selected"' : '' ?>>Contributor</option>
  185. <option value="custom" <?php echo ($custom_role == 'custom') ? 'selected="selected"' : '' ?>>Custom</option>
  186. </select>
  187. </td>
  188. <td><button class="button"><?php _e('Update', 'LayerSlider') ?></button></td>
  189. <!-- <td class="desc"><?php _e('If you want to give access for other users than admins to this page, you can specify a custom capability. You can find all the available capabilities on', 'LayerSlider') ?> <a href="http://codex.wordpress.org/Roles_and_Capabilities#Capabilities" target="_blank"><?php _e('this page', 'LayerSlider') ?></a>.</td> -->
  190. </tr>
  191. <tr>
  192. <td><?php _e('Capability', 'LayerSlider') ?></td>
  193. <td><input type="text" name="custom_capability" value="<?php echo $custom_capability ?>" placeholder="<?php echo $custom_role_placeholder ?>"></td>
  194. <td></td>
  195. </tr>
  196. </tbody>
  197. </table>
  198. </form>
  199. </div>
  200. </div>
  201. <div class="ls-box ls-news">
  202. <h2 class="header">LayerSlider News</h2>
  203. <div>
  204. <iframe src="http://news.kreaturamedia.com/layerslider/"></iframe>
  205. </div>
  206. </div>
  207. </div>
  208. <!-- Help menu WP Pointer -->
  209. <?php
  210. // Get users data
  211. global $current_user;
  212. get_currentuserinfo();
  213. if(get_user_meta($current_user->ID, 'layerslider_help_wp_pointer', true) != '1') {
  214. add_user_meta($current_user->ID, 'layerslider_help_wp_pointer', '1'); ?>
  215. <script type="text/javascript">
  216. jQuery(document).ready(function() {
  217. jQuery('#contextual-help-link-wrap').pointer({
  218. pointerClass : 'ls-help-pointer',
  219. pointerWidth : 320,
  220. content: '<h3><?php _e('The documentation is here', 'LayerSlider') ?></h3><div class="inner"><?php _e('This is a WordPress contextual help menu, we use it to give you fast access to our documentation. Please keep in mind that because this menu is contextual, it only shows the relevant information to the page that you are currently viewing. So if you search something, you should visit the corresponding page first and then open this help menu.', 'LayerSlider') ?></div>',
  221. position: {
  222. edge : 'top',
  223. align : 'right'
  224. }
  225. }).pointer('open');
  226. });
  227. </script>
  228. <?php } ?>
  229. <script type="text/javascript">
  230. // Screen options
  231. var lsScreenOptions = <?php echo json_encode($lsScreenOptions) ?>;
  232. </script>