PageRenderTime 27ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/wp-ui/inc/editor-dialogs.php

https://gitlab.com/Blueprint-Marketing/interoccupy.net
PHP | 473 lines | 390 code | 45 blank | 38 comment | 20 complexity | 401af759a7a5df1daa69732bfde0d62a MD5 | raw file
  1. <?php
  2. /**
  3. * Delivers the HTML for editor dialogs through wp_ajax.
  4. *
  5. * Editor dialogs api.
  6. *
  7. *
  8. *
  9. * @since 0.8.1
  10. * @package wp-ui
  11. * @subpackage editor-dialogs
  12. **/
  13. global $wpui_skins_list;
  14. $wpui_skins_list = wpui_get_skins_list();
  15. add_action( 'admin_footer', 'wpui_editor_container_inputs' );
  16. function wpui_editor_container_inputs() {
  17. global $pagenow;
  18. $wpui_editor_script_pages = apply_filters( 'wpui_editor_script_pages', array( 'post-new.php', 'page-new.php', 'post.php', 'page.php' ));
  19. if (( in_array( basename( $_SERVER['PHP_SELF'] ), $wpui_editor_script_pages ) ) &&
  20. ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) ) ) {
  21. $wpuiMNonce = wp_create_nonce( 'wpui_editor_ajax_dialog_nonce' );
  22. $wpuiPNonce = wp_create_nonce( 'wpui-editor-post-nonce' );
  23. $wpuiTNonce = wp_create_nonce( 'wpui-editor-tax-nonce' );
  24. ?>
  25. <div style="display:none; !important" id="wpui-editor-dialog"></div>
  26. <div style="display:none; !important" id="_wpui-editor-dialog">
  27. <input type="hidden" id="wpui-editor-main-nonce" value="<?php echo $wpuiMNonce ?>" />
  28. <input type="hidden" id="wpui-editor-post-nonce" value="<?php echo $wpuiPNonce ?>" />
  29. <input type="hidden" id="wpui-editor-tax-nonce" value="<?php echo $wpuiTNonce ?>" />
  30. <input type="hidden" id="wpui-dialog-mode" value="0" />
  31. </div><!-- end #_wpui-editor-dialog -->
  32. <?php
  33. }
  34. }
  35. add_action( 'wp_ajax_wpui_get_editor_dialog', 'wpui_get_editor_dialog_ajax' );
  36. /**
  37. * Get the wrapped up dialog.
  38. */
  39. function wpui_get_editor_dialog_ajax()
  40. {
  41. if ( ! isset( $_POST ) ) die( '-1' );
  42. $type = isset( $_POST[ 'panel' ] ) ? $_POST[ 'panel' ] : 'addtab';
  43. $nonce = $_POST[ 'nonce' ];
  44. if ( ! wp_verify_nonce( $nonce, 'wpui_editor_ajax_dialog_nonce' ))
  45. return;
  46. else
  47. echo '<!-- secure -->';
  48. // Get the content now. /*/
  49. call_user_func( 'wpui_editor_html_' . $type );
  50. call_user_func( 'wpui_editor_html_load_posts' );
  51. wpui_editor_dialog_enqueue_css();
  52. exit();
  53. } // END function wpui_get_editor_dialog_ajax
  54. function wpui_editor_html_addfeed() {
  55. ?>
  56. <h2 class="wpui-dialog-title">Tabs/acc/dialogs from Feeds</h2>
  57. <p class="howto">The shortcode [wpuifeeds], when supplied with a valid feed URL</p>
  58. <div>
  59. <label>
  60. <span>Enter a Valid RSS feed URL</span>
  61. </label>
  62. <input class="widefat" id="wpui-feed-url" type="text" name="wpuifeedurl" tabindex="10" />
  63. <span class="error-message"></span>
  64. </div>
  65. <div>
  66. <label>
  67. <span>Number of feed entries to show</span>
  68. </label>
  69. <input class="widefat" id="wpui-feed-number" type="text" name="wpuifeednumber" value="5" tabindex="11" />
  70. <span class="error-message"></span>
  71. </div>
  72. <?php
  73. } // END function wpui_editor_html_addfeed.
  74. function wpui_editor_html_addtab() {
  75. ?>
  76. <h2 class="wpui-dialog-title">Add a tab set</h2>
  77. <p class="howto">Each tab is the combination of [wptabtitle] and [wptabcontent] shortcodes.</p>
  78. <div>
  79. <label>
  80. <span>Title of the tab</span>
  81. </label>
  82. <input class="widefat" id="wpui-tab-name" type="text" name="tabname" tabindex="10" />
  83. <span class="error-message"></span>
  84. </div>
  85. <p class="howto toggle-arrow wpui-reveal">Contents of the tab</p>
  86. <div>
  87. <label>
  88. <span>Contents of the tab</span>
  89. </label>
  90. <textarea rows="6" class="widefat" id="wpui-tab-contents" name="tabcontents" tabindex="10"></textarea>
  91. <span class="error-message"></span>
  92. </div>
  93. <?php
  94. } // end function wpui_editor_addset
  95. function wpui_editor_html_wraptab() {
  96. ?>
  97. <h2 class="wpui-dialog-title">Wrap the tabs/ Display posts</h2>
  98. <p class="howto wpui-reveal toggle-arrow">Wrap the previously created tabsets, using [wptabs]. </p>
  99. <div>
  100. <table class="widefat">
  101. <thead>
  102. </thead>
  103. <tbody>
  104. <tr>
  105. <td>
  106. <label><span>Type</span></label>
  107. <select name="type" id="tabs-type">
  108. <option value="tabs">Tabs</option>
  109. <option value="accordion">Accordion</option>
  110. </select></label>
  111. </td>
  112. <td>
  113. <label><span>Style<span></label>
  114. <select name="style" id="tabs-style">
  115. <option value="default">Default</option>
  116. <?php global $wpui_skins_list;
  117. foreach( $wpui_skins_list as $skin=>$name ) {
  118. if ( stristr( $skin, 'startoptgroup' ) ) {
  119. echo '<optgroup label="' . $name . '">';
  120. } else if ( stristr( $skin, 'endoptgroup') ) {
  121. echo '</optgroup>';
  122. } else {
  123. echo '<option value="' . $skin . '">' . $name . '</option>';
  124. }
  125. }
  126. ?>
  127. </select>
  128. </td>
  129. </tr>
  130. <tr>
  131. <td>
  132. <label><span>Effects</span>
  133. <select name="effect" id="tabs-effect">
  134. <option value="disable">None</option>
  135. <option value="fade">Fade</option>
  136. <option value="slide">Slide</option>
  137. </select></label>
  138. </td>
  139. <td>
  140. <label><span>Mode</span>
  141. <select name="mode" id="tabs-mode">
  142. <option value="horizontal">Horizontal</option>
  143. <option value="vertical">Vertical</option>
  144. </select><br /></label>
  145. </td>
  146. </tr>
  147. <tr>
  148. <td colspan="2">
  149. <label>
  150. <span>Auto rotation</span>
  151. <input name="rotate" type="text" id="tabs-rotate" />
  152. <p class="howto">Set a valid microsecond value( e.g. 6000 for 6 seconds ) to enable. Leave blank to disable.</p>
  153. </label>
  154. <span class="error-message"></span>
  155. </td>
  156. </tr>
  157. <tr>
  158. <td colspan="2">
  159. <label>
  160. <span>Seamless tabs : </span>
  161. <input type="checkbox" name="no-bg" id="tabs-no-bg">Inits tabs without background, suitable for long articles.</label>
  162. </td>
  163. </tr>
  164. </tbody>
  165. </table>
  166. </div>
  167. <p class="howto wpui-reveal toggle-arrow">or Display posts</p>
  168. <div style="display : none;">
  169. <form id="wpui-tax-search-form">
  170. <label><span>Search</span>
  171. <input type="text" id="wpui-tax-search-field">
  172. </label>
  173. <select id="wpui-tax-search-type">
  174. <option value="cat">Categories</option>
  175. <option value="tag">Tags</option>
  176. <option value="recent">Recent</option>
  177. <option value="popular">Popular</option>
  178. <option value="Random">Random</option>
  179. </select>
  180. </form>
  181. <div id="wpui-search-tax">
  182. <p class="howto display-type">Type and enter to search. Click to toggle selection.</p>
  183. <div id="wpui-tax-search-results" class="wpui-search-results">
  184. <ul class="wpui-tax-list"></ul>
  185. <div style="display : none;" class="wpui-waiting" style="text-align: center;"><img src="<?php echo admin_url('/images/wpspin_light.gif' ); ?>"></div>
  186. </div>
  187. <input type="text" id="wpui-selected-tax" class="wpui-selected">
  188. <label><span>Number of tabs to display</span><input type="text" id="wpui-tax-number" name="wpui-tax-number" value="5"></label>
  189. <style type="text/css">
  190. #wpui-editor-dialog #wpui-tax-number { width : 30px; }
  191. #wpui-tax-search-results { background : #FFF; border : 1px solid #DFDFDF; height : 185px; margin : 0 5px 5px; overflow : auto; position : relative; overflow : auto;}
  192. #wpui-editor-dialog ul.wpui-tax-list { list-style : none;}
  193. #wpui-editor-dialog ul.wpui-tax-list li { border-bottom: 1px solid #F1F1F1; padding : 4px 6px; position : relative; cursor : pointer; margin-bottom : 0;}
  194. #wpui-editor-dialog ul.wpui-tax-list li.selected { background : #DDD; font-weight : bold !important; }
  195. #wpui-editor-dialog ul.wpui-tax-list li a { text-decoration : none; color : #777; text-shadow: 0 1px 0 #FFF; display : block; width : 300px; overflow : hide;}
  196. span.info { position : absolute; top : 0; right : 0; height: 100%; padding : 4px; }
  197. span.wpui-post-count { float:right; background: #868686; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); border-radius: 15px; padding : 0 6px; color: #EEE; text-shadow : 0 1px 0 #222;}
  198. </style>
  199. <!-- <?php $wpui_cats = get_categories( array( 'taxonomy' => 'tag') ); ?>
  200. <select name="wpui-cat-list" id="wpui-cat-list">
  201. <?php
  202. foreach( $wpui_cats as $wcat ) {
  203. echo '<option value="' . $wcat->term_id . '">' . $wcat->category_nicename . '</option>';
  204. }
  205. ?>
  206. </select> -->
  207. </div>
  208. </div>
  209. <?php
  210. } // END function wpui_editor_wraptab.
  211. function wpui_editor_html_spoiler() {
  212. ?>
  213. <h2 class="wpui-dialog-title">Add a spoiler</h2>
  214. <p class="howto">Select some text, enter a name.</p>
  215. <div>
  216. <label>
  217. <span><abbr title="Clickable part of the tab">Title of the spoiler</abbr></span>
  218. </label>
  219. <input class="widefat" type="text" name="spoil-title" id="spoil-title">
  220. <span class="error-message"></span>
  221. </div>
  222. <p class="howto toggle-arrow wpui-reveal">Enter the content</p>
  223. <div>
  224. <label>
  225. <textarea rows="6" class="widefat" name="spoil-content" id="spoil-content"></textarea>
  226. </label>
  227. <p class="howto" style="display: none;">Select some text and click open this panel, text will be added automatically.</p>
  228. <span class="error-message"></span>
  229. </div>
  230. <h5> + <a href="" onclick="jQuery( this ).parent().next('div').toggle(); return false;">Show advanced options</a></h5>
  231. <div class="show-advanced-spoiler-options" style="display :none;">
  232. <table class="widefat">
  233. <tbody>
  234. <tr>
  235. <td>
  236. <label>
  237. <span>Style</span>
  238. <select name="style" id="spoils-style">
  239. <option value="default">Default</option>
  240. <?php global $wpui_skins_list;
  241. foreach( $wpui_skins_list as $skin=>$name ) {
  242. if ( stristr( $skin, 'startoptgroup' ) ) {
  243. echo '<optgroup label="' . $name . '">';
  244. } else if ( stristr( $skin, 'endoptgroup') ) {
  245. echo '</optgroup>';
  246. } else {
  247. echo '<option value="' . $skin . '">' . $name . '</option>';
  248. }
  249. } ?>
  250. </select>
  251. </label>
  252. </td>
  253. </tr>
  254. <tr>
  255. <td>
  256. <label>
  257. <span>Open at load</span>
  258. <input type="checkbox" id="spoils-open" name="spoils-open">Check here to open spoilers at page load.
  259. </label>
  260. <span class="error-message"></span>
  261. </td>
  262. </tr>
  263. <tr>
  264. <td>
  265. <label>
  266. <span>Close button Label</span>
  267. <input type="text" id="spoils-closebtn" name="spoils-closebtn"><br/>This button allows you to close the spoiler.Leave blank to disable.
  268. </label>
  269. <span class="error-message"></span>
  270. </td>
  271. </tr>
  272. </table>
  273. </div><!-- end show advanced spoiler options -->
  274. <?php
  275. } // END function wpui_editor_spoiler
  276. function wpui_editor_html_dialog() {
  277. ?>
  278. <h2 class="wpui-dialog-title">Add a Dialog</h2>
  279. <p class="howto">Select some text, enter a title for the dialog.</p>
  280. <div>
  281. <label>
  282. <span>Title</span>
  283. <input class="widefat" type="text" name="title-dialog" id="dialog-title" />
  284. <span class="error-message"></span>
  285. </label>
  286. </div>
  287. <p class="howto toggle-arrow wpui-reveal">Enter the content</p>
  288. <div>
  289. <label>
  290. <textarea rows="6" class="widefat" name="content-of-dialog" id="dialog-contents"></textarea>
  291. </label>
  292. <p class="howto" style="display: none;">Select some text in editor and click open this panel, text will be added automatically.</p>
  293. <span class="error-message"></span>
  294. </div>
  295. <h5> + <a href="" onclick="jQuery( this ).parent().next('div').toggle(); return false;">Show advanced options</a></h5>
  296. <div class="show-advanced-dialog-options" style="display :none;">
  297. <table class="widefat">
  298. <tbody>
  299. <tr>
  300. <td colspan="2">
  301. <label>
  302. <span>Style</span>
  303. </label>
  304. <select name="style" id="dialog-style">
  305. <option value="default">Default</option>
  306. <?php global $wpui_skins_list;
  307. foreach( $wpui_skins_list as $skin=>$name ) {
  308. if ( stristr( $skin, 'startoptgroup' ) ) {
  309. echo '<optgroup label="' . $name . '">';
  310. } else if ( stristr( $skin, 'endoptgroup') ) {
  311. echo '</optgroup>';
  312. } else {
  313. echo '<option value="' . $skin . '">' . $name . '</option>';
  314. }
  315. } ?>
  316. </select>
  317. </td>
  318. </tr>
  319. <tr>
  320. <td colspan="2">
  321. <label>
  322. <span>Auto open Button label</span>
  323. </label>
  324. <input type="text" name="dialog-openlabel" id="dialog-openlabel" value="">
  325. <p class="howto">Disables autoopen at load and displays button for manually opening dialog. Leave blank to auto open.</p>
  326. </td>
  327. </tr>
  328. <tr>
  329. <td>
  330. <label>
  331. <span>Width</span>
  332. <input type="text" name="dialog-width" id="dialog-width" value="" />
  333. </label>
  334. </td>
  335. <td>
  336. <label>
  337. <span>Height</span>
  338. <input type="text" length="10" name="dialog-height" id="dialog-height" value="" />
  339. </label>
  340. </td>
  341. </tr>
  342. </tbody>
  343. </table>
  344. </div><!-- end show-advanced-dialog-options -->
  345. <?php
  346. } // END function wpui_editor_dialog();
  347. /**
  348. * Load the posts.
  349. */
  350. function wpui_editor_html_load_posts() {
  351. ?>
  352. <div style="display: none;" class="wpui-search-posts">
  353. <p class="howto toggle-arrow wpui-reveal">Or choose a post</p>
  354. <form id="wpui-search-posts-form">
  355. <label><span>Search</span>
  356. <input type="text" id="wpui-post-search-field" tabindex="60" autocomplete="off">
  357. </label>
  358. </form>
  359. <input id="wpui-selected-post" class="wpui-selected" type="hidden">
  360. <p class="howto display-type">Displaying recent posts</p>
  361. <div id="wpui-search-results" class="wpui-search-results">
  362. <ul class="wpui-post-list"></ul>
  363. <div style="display : none;" class="wpui-waiting" style="text-align: center;"><img src="<?php echo admin_url('/images/wpspin_light.gif' ); ?>"></div>
  364. </div>
  365. <style type="text/css">
  366. #wpui-editor-dialog #wpui-post-search-number { width : 30px; }
  367. #wpui-search-results { background : #FFF; border : 1px solid #DFDFDF; height : 185px; margin : 0 5px 5px; overflow : auto; position : relative; overflow : auto;}
  368. #wpui-editor-dialog ul.wpui-post-list { list-style : none;}
  369. #wpui-editor-dialog ul.wpui-post-list li { border-bottom: 1px solid #F1F1F1; padding : 4px 6px; position : relative; cursor : pointer; margin-bottom : 0;}
  370. #wpui-editor-dialog ul.wpui-post-list li.selected { background : #DDD; font-weight : bold !important; }
  371. #wpui-editor-dialog ul.wpui-post-list li a { text-decoration : none; color : #777; text-shadow: 0 1px 0 #FFF; display : block; width : 300px; overflow : hide;}
  372. span.info { position : absolute; top : 0; right : 0; height: 100%; padding : 4px; }
  373. </style>
  374. </div>
  375. <?php
  376. }
  377. /**
  378. * Load the css.
  379. */
  380. function wpui_editor_dialog_enqueue_css() {
  381. ?>
  382. <style type="text/css">
  383. .wpui-dialog-wrapper {
  384. margin : 10px;
  385. }
  386. label {
  387. font-size : 12px;
  388. }
  389. label input[type="text"],
  390. label textarea {
  391. background-color : #FFF;
  392. border-color : #DFDFDF;
  393. border-radius : 4px;
  394. margin : 1px;
  395. padding : 3px;
  396. font-size : 12px;
  397. }
  398. #wpui-wrap-tabs table label span {
  399. width : 70px;
  400. display : inline-block;
  401. }
  402. #wpui-add-spoiler table label span {
  403. width : 120px;
  404. display : inline-block;
  405. }
  406. #wpui-add-dialog table label span {
  407. display : inline-block;
  408. width : 120px;
  409. }
  410. span.error-message.active {
  411. color : #F00 ;
  412. background : pink;
  413. display : block;
  414. padding : 2px 5px;
  415. font-size : 12px;
  416. }
  417. #wpui-editor-dialog .toggle-arrow {
  418. background: url("<?php echo wpui_url( '/images/toggle-arrow.png' ) ?>") no-repeat scroll left top transparent;
  419. height: 23px;
  420. line-height: 23px;
  421. padding-left : 18px;
  422. cursor : pointer;
  423. }
  424. #wpui-editor-dialog .toggle-arrow-active {
  425. background-position : left center !important;
  426. }
  427. </style>
  428. <?php } ?>