Advertisement
Guest User

Plugin

a guest
Nov 25th, 2013
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.70 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Orbisius Simple Notice
  4. Plugin URI: http://club.orbisius.com/products/wordpress-plugins/orbisius-simple-notice/
  5. Description: This plugin allows you to show a simple notice to alert your users about server maintenance, new product launches etc.
  6. Version: 1.0.4
  7. Author: Svetoslav Marinov (Slavi)
  8. Author URI: http://orbisius.com
  9. */
  10.  
  11. /* Copyright 2012-2050 Svetoslav Marinov (Slavi) <slavi@orbisius.com>
  12.  
  13. This program is free software; you can redistribute it and/or modify
  14. it under the terms of the GNU General Public License as published by
  15. the Free Software Foundation; either version 2 of the License, or
  16. (at your option) any later version.
  17.  
  18. This program is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. GNU General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with this program; if not, write to the Free Software
  25. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  26. */
  27.  
  28. // Set up plugin
  29. add_action('init', 'orbisius_simple_notice_init');
  30. add_action('wp_footer', 'orbisius_simple_notice_inject_notice', 50, 0); // be the last in the footer
  31. add_action('admin_init', 'orbisius_simple_notice_admin_init');
  32. add_action('admin_menu', 'orbisius_simple_notice_setup_admin');
  33.  
  34. /**
  35. * Adds the action link to settings. That's from Plugins. It is a nice thing.
  36. * @param type $links
  37. * @param type $file
  38. * @return type
  39. */
  40. function orbisius_simple_notice_add_quick_settings_link($links, $file) {
  41. if ($file == plugin_basename(__FILE__)) {
  42. $link = admin_url('options-general.php?page=' . plugin_basename(__FILE__));
  43. $dashboard_link = "<a href=\"{$link}\">Settings</a>";
  44. array_unshift($links, $dashboard_link);
  45. }
  46.  
  47. return $links;
  48. }
  49.  
  50. /**
  51. * Setups loading of assets (css, js).
  52. * for live servers we'll use the minified versions e.g. main.min.js otherwise .js or .css (dev)
  53. * @see http://jscompress.com/ - used for JS compression
  54. * @see http://refresh-sf.com/yui/ - used for CSS compression
  55. * @return type
  56. */
  57. function orbisius_simple_notice_init() {
  58. $dev = empty($_SERVER['DEV_ENV']) ? 0 : 1;
  59. $suffix = $dev ? '' : '.min';
  60.  
  61. /*wp_register_style('simple_notice', plugins_url("/assets/main{$suffix}.css", __FILE__));
  62. wp_enqueue_style('simple_notice');*/
  63.  
  64. $opts = orbisius_simple_notice_get_options();
  65.  
  66. // load cookies only if the user wants to have a close button.
  67. if (!empty($opts['show_close_button'])) {
  68. wp_register_script('simple_notice', plugins_url("/assets/jquery.cookie$suffix.js", __FILE__), array('jquery', ), '1.0', true);
  69. wp_enqueue_script('simple_notice');
  70. }
  71. }
  72.  
  73. function orbisius_simple_notice_admin_init() {
  74. orbisius_simple_notice_register_settings();
  75.  
  76. global $wp_version;
  77.  
  78. $color_picker = version_compare($wp_version, '3.5') >= 0 ? 'wp-color-picker' // new WP
  79. : 'farbtastic'; // old WP
  80.  
  81. wp_enqueue_style($color_picker);
  82. wp_enqueue_script($color_picker);
  83.  
  84. wp_register_script('simple_notice_admin', plugins_url("/assets/admin_main.js", __FILE__), array('jquery',), '1.0', true);
  85. wp_enqueue_script('simple_notice_admin');
  86. }
  87.  
  88. /**
  89. * Outputs the feedback form + container. if the user is logged in we'll take their email
  90. * requires: wp_footer
  91. */
  92. function orbisius_simple_notice_inject_notice($is_site_front_end = 1) {
  93. $opts = orbisius_simple_notice_get_options();
  94. $data = orbisius_simple_notice_get_plugin_data();
  95.  
  96. // The user doesn't want to show the notice.
  97. // This applies only for the live site.
  98. if (empty($opts['status']) && !empty($is_site_front_end)) {
  99. echo "\n<!-- {$data['name']} | {$data['url']} : is disabled. Skipping rendering. -->\n";
  100. return;
  101. }
  102.  
  103. $close_button_line = $js_code = '';
  104.  
  105. // Enable close dismiss button
  106. if (!empty($opts['show_close_button'])) {
  107. $close_button_line =
  108. "<div class='orbisius_simple_notice_dismiss_container'>"
  109. . "<a title='Click to close/dismiss message.' "
  110. . "href='javascript:void(0);' class='dismiss_message'>[X] Close</a>"
  111. . "</div>\n";
  112.  
  113. $js_code .= <<<FORM_EOF
  114. <script>
  115. jQuery(document).ready(function ($) {
  116. var msg_id = jQuery('#orbisius_simple_notice').data('msg_id');
  117.  
  118. if (!jQuery('body').hasClass('wp-admin')) { // public area only
  119. var orb_simp_ntc_dismiss_hash = jQuery.cookie('orb_simp_ntc_dismiss') || '';
  120.  
  121. /* if the cookie exists and matches the msg_id that means the user has dismissed the message already. So don't show it for another day. */
  122. if (orb_simp_ntc_dismiss_hash == msg_id) {
  123. jQuery('#orbisius_simple_notice_container').hide();
  124. }
  125. }
  126.  
  127. // The user has clicked on the X sign
  128. jQuery('#orbisius_simple_notice_container .dismiss_message').on('click', function() {
  129. jQuery('#orbisius_simple_notice_container').slideUp('slow');
  130.  
  131. // for WP admin show the message.
  132. if (jQuery('body').hasClass('wp-admin')) {
  133. setTimeout(function () {
  134. jQuery('#orbisius_simple_notice_container').slideDown('slow');
  135. }, 2000);
  136. } else {
  137. // this will be empty for new messages or expired cookies
  138. var orb_simp_ntc_dismiss_hash = jQuery.cookie('orb_simp_ntc_dismiss') || '';
  139.  
  140. if (orb_simp_ntc_dismiss_hash == '') {
  141. jQuery.cookie('orb_simp_ntc_dismiss', msg_id, { expires: 2 } );
  142. }
  143. }
  144. });
  145. });
  146. </script>
  147. FORM_EOF;
  148. }
  149.  
  150. $powered_by_line = '';
  151.  
  152. if (!empty($opts['show_powered_by'])) {
  153. $host = $_SERVER['HTTP_HOST'];
  154. $powered_by_url_trk = $data['url'] . "?utm_source=orbisius-simple-notice&utm_medium=$host&utm_campaign=powered_by";
  155.  
  156. $powered_by_line =
  157. "<span class='orbisius_simple_notice_powered_by_container'><div class='orbisius_simple_notice_powered_by'>"
  158. . "<a title='Powered by {$data['name']}. Free hellobar WordPress Plugin, hellobar,alert notice,notice bar'"
  159. . " href='$powered_by_url_trk' class='little_info' target='_blank'>i</a>"
  160. . "</div></span>\n";
  161.  
  162. // in case if somebody wants to get rid if the feedback link
  163. $powered_by_line = apply_filters('orbisius_simple_notice_filter_powered_by', $powered_by_line);
  164. }
  165.  
  166. $notice = empty($opts['notice']) ? '' : $opts['notice'];
  167. $text_color = empty($opts['text_color']) ? '#000' : $opts['text_color'];
  168. $text_bg_color = empty($opts['text_bg_color']) ? '#B4CFD3' : $opts['text_bg_color'];
  169. $link_color = empty($opts['link_color']) ? '' : $opts['link_color'];
  170.  
  171. // if the user is logged in WP admin bar is obstructive the view.
  172. $top_pos = is_user_logged_in() ? '28px' : 0;
  173. $left_pos = 0;
  174.  
  175. $inline_css_arr = array(
  176. // configurable
  177. "color:$text_color",
  178. "background:none repeat scroll 0 0 $text_bg_color",
  179. // static
  180. "margin:0",
  181. "padding:4px 0",
  182. "text-align:center",
  183. "width:100%",
  184. //"z-index:99999",
  185. "font-family:arial",
  186. );
  187.  
  188. // does the user want a bigger font?
  189. if (!empty($opts['font_size'])) {
  190. $inline_css_arr[] = 'font-size:' . $opts['font_size'];
  191. }
  192.  
  193. if (!empty($is_site_front_end)) {
  194. // show only on home page
  195. if ($opts['show_notice_criteria'] == 'home_page'
  196. && ( !is_home() && !is_front_page() ) ) {
  197. echo "\n<!-- {$data['name']} | {$data['url']} : selected to be rendered on home page only. Skipping rendering. -->\n";
  198. return '';
  199. }
  200.  
  201. if ($opts['show_notice_method'] == 'on_top') {
  202. $inline_css_arr[] = "top:$top_pos";
  203. $inline_css_arr[] = "left:$left_pos";
  204. $inline_css_arr[] = "position:fixed";
  205. } else {
  206. $js_code .= <<<FORM_EOF
  207. <script>
  208. jQuery(document).ready(function ($) {
  209. jQuery('#orbisius_simple_notice_container').prependTo('body'); // .css('postion', '')
  210. });
  211. </script>
  212. FORM_EOF;
  213. }
  214. }
  215.  
  216. $link_color_css = '';
  217. $inline_css = join(";\n", $inline_css_arr);
  218.  
  219. // do we have a specific color for links?. Yep. Include its CSS then.
  220. if (!empty($link_color)) {
  221. $link_color_css .= ".orbisius_simple_notice_container .orbisius_simple_notice a,
  222. .orbisius_simple_notice_container .orbisius_simple_notice a:visited {
  223. color: $link_color;
  224. }\n";
  225. }
  226.  
  227. $msg_id = 'orb_ntc_'. md5($notice);
  228.  
  229. $form_buff = <<<FORM_EOF
  230. <!-- orbisius_simple_notice : {$data['name']} | {$data['url']} -->
  231. <style>
  232. .orbisius_simple_notice_container .orbisius_simple_notice {
  233. $inline_css
  234. }
  235.  
  236. $link_color_css
  237.  
  238. .orbisius_simple_notice_powered_by_container {
  239. float:left;
  240. text-decoration:none;
  241. }
  242.  
  243. .orbisius_simple_notice_dismiss_container {
  244. float:right;
  245. margin-right:3px;
  246. padding:0px 2px;
  247. }
  248.  
  249. .orbisius_simple_notice_dismiss_container a {
  250. text-decoration:none;
  251. display:inline-block;
  252. }
  253.  
  254. .orbisius_simple_notice_powered_by_container .little_info {
  255. text-decoration:none;
  256. display:block-inline;
  257. padding:0px 3px;
  258. }
  259. </style>
  260. $js_code
  261. <div id="orbisius_simple_notice_container" class="orbisius_simple_notice_container">
  262. <div id="orbisius_simple_notice" class="orbisius_simple_notice" data-msg_id="$msg_id">
  263. $powered_by_line
  264. $notice
  265. $close_button_line
  266. </div> <!-- /orbisius_simple_notice -->
  267. </div> <!-- /orbisius_simple_notice_container -->
  268. <!-- /orbisius_simple_notice -->
  269. FORM_EOF;
  270.  
  271. //show_notice_method
  272.  
  273. echo $form_buff;
  274. }
  275.  
  276. /**
  277. * Set up administration
  278. *
  279. * @package Orbisius Simple Notice
  280. * @since 0.1
  281. */
  282. function orbisius_simple_notice_setup_admin() {
  283. add_options_page('Orbisius Simple Notice', 'Orbisius Simple Notice', 'manage_options', __FILE__, 'orbisius_simple_notice_options_page');
  284.  
  285. add_filter('plugin_action_links', 'orbisius_simple_notice_add_quick_settings_link', 10, 2);
  286. }
  287.  
  288. /**
  289. * Sets the setting variables
  290. */
  291. function orbisius_simple_notice_register_settings() { // whitelist options
  292. register_setting('orbisius_simple_notice_settings', 'orbisius_simple_notice_options', 'orbisius_simple_notice_validate_settings');
  293. }
  294.  
  295. /**
  296. * This is called by WP after the user hits the submit button.
  297. * The variables are trimmed first and then passed to the who ever wantsto filter them.
  298. * @param array the entered data from the settings page.
  299. * @return array the modified input array
  300. */
  301. function orbisius_simple_notice_validate_settings($input) { // whitelist options
  302. $input = array_map('trim', $input);
  303.  
  304. // let extensions do their thing
  305. $input_filtered = apply_filters('orbisius_simple_notice_ext_filter_settings', $input);
  306.  
  307. // did the extension break stuff?
  308. $input = is_array($input_filtered) ? $input_filtered : $input;
  309.  
  310. // for font size we want 12px or 14pt
  311. if (!empty($input['font_size'])) {
  312. $input['font_size'] = preg_replace('#\s#si', '', $input['font_size']);
  313. }
  314.  
  315. return $input;
  316. }
  317.  
  318. /**
  319. * Retrieves the plugin options. It inserts some defaults.
  320. * The saving is handled by the settings page. Basically, we submit to WP and it takes
  321. * care of the saving.
  322. *
  323. * @return array
  324. */
  325. function orbisius_simple_notice_get_options() {
  326. $defaults = array(
  327. 'status' => 0,
  328. 'show_powered_by' => 1,
  329. 'show_in_admin' => 0,
  330. 'show_notice_method' => 'on_top',
  331. 'show_close_button' => 1,
  332. 'show_notice_criteria' => 'all_pages', // home_page
  333. 'text_color' => '#555',
  334. 'text_bg_color' => '#B4CFD3',
  335. 'link_color' => '',
  336. 'font_size' => '',
  337. 'notice' => 'We have launched a new product ...',
  338. );
  339.  
  340. $opts = get_option('orbisius_simple_notice_options');
  341.  
  342. $opts = (array) $opts;
  343. $opts = array_merge($defaults, $opts);
  344.  
  345. return $opts;
  346. }
  347.  
  348. /**
  349. * Options page
  350. *
  351. * @package Orbisius Simple Notice
  352. * @since 1.0
  353. */
  354. function orbisius_simple_notice_options_page() {
  355. $opts = orbisius_simple_notice_get_options();
  356. global $wp_version;
  357. ?>
  358. <div id="orbisius_simple_notice_admin_wrapper" class="wrap orbisius_simple_notice_admin_wrapper">
  359. <h2>Orbisius Simple Notice</h2>
  360. <p>
  361. This plugin allows you to show a simple notice to alert your users about server maintenance, new product launches etc.
  362. </p>
  363.  
  364. <div id="poststuff">
  365.  
  366. <div id="post-body" class="metabox-holder columns-2">
  367.  
  368. <!-- main content -->
  369. <div id="post-body-content">
  370.  
  371. <div class="meta-box-sortables ui-sortable">
  372.  
  373. <div class="postbox">
  374. <h3><span>Settings</span></h3>
  375. <div class="inside">
  376. <form method="post" action="options.php">
  377. <?php settings_fields('orbisius_simple_notice_settings'); ?>
  378. <table class="form-table">
  379. <tr valign="top">
  380. <th scope="row">Show Notice</th>
  381. <td>
  382. <label for="orbisius_simple_notice_options_radio1">
  383. <input type="radio" id="orbisius_simple_notice_options_radio1" name="orbisius_simple_notice_options[status]"
  384. value="1" <?php echo empty($opts['status']) ? '' : 'checked="checked"'; ?> /> Enabled
  385. </label>
  386. <br/>
  387. <label for="orbisius_simple_notice_options_radio2">
  388. <input type="radio" id="orbisius_simple_notice_options_radio2" name="orbisius_simple_notice_options[status]"
  389. value="0" <?php echo!empty($opts['status']) ? '' : 'checked="checked"'; ?> /> Disabled
  390. </label>
  391. </td>
  392. </tr>
  393. <tr>
  394. <th scope="row">Notice</th>
  395. <td>
  396. <?php if (1) : ?>
  397. <?php
  398. wp_editor($opts['notice'], "orbisius_simple_notice_options[notice]", array('teeny' => true, 'media_buttons' => false, 'textarea_rows' => 2));
  399. ?>
  400. <?php else : // simple editor ?>
  401. <input type="text" id="orbisius_simple_notice_options_notice" class="widefat"
  402. name="orbisius_simple_notice_options[notice]"
  403. value="<?php echo esc_attr($opts['notice']); ?>" />
  404. <?php endif; ?>
  405. <p>
  406. Example: We are going to be doing server maintenance at 9pm today.
  407. <br/>Example: We have just launched a new product ...
  408. </p>
  409. </td>
  410. </tr>
  411. <tr valign="top">
  412. <th scope="row">Show the Notice Text On</th>
  413. <td>
  414. <label for="show_notice_criteria_radio1">
  415. <input type="radio" id="show_notice_criteria_radio1" name="orbisius_simple_notice_options[show_notice_criteria]"
  416. value='all_pages' <?php checked('all_pages', $opts['show_notice_criteria']); ?> /> All pages/posts
  417. </label>
  418. <br/>
  419. <label for="show_notice_criteria_radio2">
  420. <input type="radio" id="show_notice_criteria_radio2" name="orbisius_simple_notice_options[show_notice_criteria]"
  421. value='home_page' <?php checked('home_page', $opts['show_notice_criteria']); ?> /> Home Page only
  422. </label>
  423. </td>
  424. </tr>
  425. <tr valign="top">
  426. <th scope="row">How to Show the Notice Text</th>
  427. <td>
  428. <label for="show_notice_method_radio1">
  429. <input type="radio" id="show_notice_method_radio1" name="orbisius_simple_notice_options[show_notice_method]"
  430. value='on_top' <?php checked('on_top', $opts['show_notice_method']); ?> /> On top of existing content
  431. <br/><small>It will be added on top of all content (with higher z-index value)</small>
  432. </label>
  433. <br/>
  434. <label for="show_notice_method_radio2">
  435. <input type="radio" id="show_notice_method_radio2" name="orbisius_simple_notice_options[show_notice_method]"
  436. value='push_down' <?php checked('push_down', $opts['show_notice_method']); ?> /> Push down existing content
  437. <br/><small>It will be added as first element in the &lt;body&gt; tag</small>
  438. </label>
  439. </td>
  440. </tr>
  441. <tr>
  442. <th scope="row">Text Color</th>
  443. <td>
  444. <label for="orbisius_simple_notice_options_text_color">
  445. <input type="text" id="orbisius_simple_notice_options_text_color" size="7"
  446. name="orbisius_simple_notice_options[text_color]"
  447. value="<?php echo esc_attr($opts['text_color']); ?>" />
  448.  
  449. <div id="text_color_picker"></div> <!-- Used for old WP color picker WP < 3.5 -->
  450. </label>
  451. <?php if (version_compare($wp_version, '3.5') >= 0) : ?>
  452. <p>Once you open the color picker, you will need to click outside of it to close it</p>
  453. <?php endif; ?>
  454. </td>
  455. </tr>
  456. <tr>
  457. <th scope="row">Text Background Color</th>
  458. <td>
  459. <label for="orbisius_simple_notice_options_text_bg_color">
  460. <input type="text" id="orbisius_simple_notice_options_text_bg_color" size="7"
  461. name="orbisius_simple_notice_options[text_bg_color]"
  462. value="<?php echo esc_attr($opts['text_bg_color']); ?>" />
  463. <div id="text_bg_color_picker"></div>
  464. </label>
  465. <?php if (version_compare($wp_version, '3.5') >= 0) : ?>
  466. <p>Once you open the color picker, you will need to click outside of it to close it</p>
  467. <?php endif; ?>
  468. </td>
  469. </tr>
  470. <tr>
  471. <th scope="row">Link Color (optional)</th>
  472. <td>
  473. <label for="orbisius_simple_notice_options_link_color">
  474. <input type="text" id="orbisius_simple_notice_options_link_color" size="7"
  475. name="orbisius_simple_notice_options[link_color]"
  476. value="<?php echo esc_attr($opts['link_color']); ?>" />
  477. <div id="link_color_picker"></div>
  478. </label>
  479. <p>Use this if links don't look good on a selected background.
  480. <?php if (version_compare($wp_version, '3.5') >= 0) : ?>
  481. <br/>Once you open the color picker, you will need to click outside of it to close it
  482. <?php endif; ?>
  483. </p>
  484. </td>
  485. </tr>
  486. <tr>
  487. <th scope="row">Font Size (optional)</th>
  488. <td>
  489. <label for="orbisius_simple_notice_options_font_size">
  490. <input type="text" id="orbisius_simple_notice_options_font_size" size="7"
  491. name="orbisius_simple_notice_options[font_size]"
  492. value="<?php echo esc_attr($opts['font_size']); ?>" />
  493. </label> Example: To change the font size enter e.g. 14pt, 12px or lower/higher number.
  494. </td>
  495. </tr>
  496. <tr valign="top">
  497. <th scope="row">Show Close Button</th>
  498. <td>
  499. <label for="show_close_button_radio1">
  500. <input type="radio" id="show_close_button_radio1" name="orbisius_simple_notice_options[show_close_button]"
  501. value='1' <?php checked(1, $opts['show_close_button']); ?> /> Yes
  502. </label>
  503. <br/>
  504. <label for="show_close_button_radio2">
  505. <input type="radio" id="show_close_button_radio2" name="orbisius_simple_notice_options[show_close_button]"
  506. value='0' <?php checked(0, $opts['show_close_button']); ?> /> No
  507. </label>
  508. <p>When a notice is closed/dismissed it won't be shown again
  509. until the message is changed or more than 2 days have passed.</p>
  510. </td>
  511. </tr>
  512. <tr valign="top">
  513. <th scope="row">Show Little Powered By Icon</th>
  514. <td>
  515. <div>
  516. This is the small <strong>i</strong> icon displayed in the far left of the message.
  517. We'd appreciate if you leave it enabled.
  518. </div>
  519. <label for="show_powered_by_radio1">
  520. <input type="radio" id="show_powered_by_radio1" name="orbisius_simple_notice_options[show_powered_by]"
  521. value='1' <?php checked(1, $opts['show_powered_by']); ?> /> Enabled
  522. </label>
  523. <br/>
  524. <label for="show_powered_by_radio2">
  525. <input type="radio" id="show_powered_by_radio2" name="orbisius_simple_notice_options[show_powered_by]"
  526. value='0' <?php checked(0, $opts['show_powered_by']); ?> /> Disabled
  527. </label>
  528. </td>
  529. </tr>
  530. <tr>
  531. <th scope="row">Preview </th>
  532. <td>
  533. <?php echo orbisius_simple_notice_inject_notice(0); ?>
  534. <div>Save changes to see a new preview.
  535. Only in WP admin area: if you click the close button the message will hide and then show up in 2 seconds.</div>
  536. </td>
  537. </tr>
  538. <?php if (0) : ?>
  539. <?php if (has_action('orbisius_simple_notice_ext_action_render_settings')) : ?>
  540. <tr valign="top">
  541. <th scope="row"><strong>Extensions (see list)</strong></th>
  542. <td colspan="1">
  543. </td>
  544. </tr>
  545. <?php do_action('orbisius_simple_notice_ext_action_render_settings', $opts, $settings_key); ?>
  546. <?php else : ?>
  547. <tr valign="top">
  548. <!--<th scope="row">Extension Name</th>-->
  549. <td colspan="2">
  550. No extensions found.
  551. </td>
  552. </tr>
  553. <?php endif; ?>
  554. <?php endif; ?>
  555. </table>
  556.  
  557. <p class="submit">
  558. <input type="submit" class="button-primary" value="<?php _e('Save') ?>" />
  559. </p>
  560. </form>
  561. </div> <!-- .inside -->
  562. </div> <!-- .postbox -->
  563.  
  564. </div> <!-- .meta-box-sortables .ui-sortable -->
  565.  
  566. </div> <!-- post-body-content -->
  567.  
  568. <!-- sidebar -->
  569. <div id="postbox-container-1" class="postbox-container">
  570.  
  571. <div class="meta-box-sortables">
  572. <div class="postbox">
  573. <h3><span>Free Quote | Hire Us</span></h3>
  574. <div class="inside">
  575. Do you need any Programming (web/mobile app) or WordPress work (custom themes/plugins, speed/security improvements).
  576.  
  577. <br/><a href='http://orbisius.com/page/free-quote/?utm_source=orbisius-simple-notice&utm_medium=plugin-settings-about&utm_campaign=plugin-update'
  578. target="_blank" class="button-primary">Get a Free Quote</a>
  579. </div> <!-- .inside -->
  580. </div> <!-- .postbox -->
  581.  
  582. <div class="postbox">
  583. <h3><span>Newsletter</span></h3>
  584. <div class="inside">
  585. <?php echo orbisius_simple_notice_generate_newsletter_box(); ?>
  586. </div> <!-- .inside -->
  587. </div> <!-- .postbox -->
  588.  
  589. <div class="postbox">
  590. <h3><span>Donation</span></h3>
  591. <div class="inside">
  592. Donations help us dedicate more resources to improve this and create new plugins.
  593.  
  594. <br/>
  595. <!--<a href='http://orbisius.com/page/donate/?utm_source=orbisius-simple-notice&utm_medium=plugin-settings-about&utm_campaign=plugin-update'
  596. target="_blank" class="button-primary">Donate</a>-->
  597.  
  598. <a href='https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7APYDVPBCSY9A'
  599. target="_blank" class="button-primary">Donate</a>
  600.  
  601. | <a href='http://orbisius.com/page/why-donate/?utm_source=orbisius-simple-notice&utm_medium=plugin-settings-about&utm_campaign=plugin-update'
  602. target="_blank">Why Donate</a>
  603. </div> <!-- .inside -->
  604. </div> <!-- .postbox -->
  605.  
  606. <div class="postbox">
  607. <h3><span>Want to see more products of ours? </span></h3>
  608. <div class="inside">
  609. <p>
  610. Go to <a href="http://club.orbisius.com/products/" target="_blank"
  611. title="Opens a page with the pugins we developed. [New Window/Tab]">http://club.orbisius.com/products/</a>.
  612. </p>
  613. </div> <!-- .inside -->
  614. </div> <!-- .postbox -->
  615.  
  616. <div class="postbox">
  617. <h3><span>Support & Feature Requests</span></h3>
  618. <div class="inside">
  619. Support is handled on our site: <a href="http://club.orbisius.com/support/?utm_source=orbisius-simple-notice&utm_medium=settings-top-bar&utm_campaign=plugin-update" target="_blank" title="[new window]">http://club.orbisius.com/support/</a>.
  620. Please do NOT use the WordPress forums or other places to seek support.
  621. </div> <!-- .inside -->
  622. </div> <!-- .postbox -->
  623.  
  624. <div class="postbox">
  625. <h3><span>About the Author</span></h3>
  626. <div class="inside">
  627. <p>
  628. <a href="http://slavi.biz/linkedin" target="_blank" title="Click to see Slavi's linkedin profile. Opens in a new tab/window">
  629. <img width="64" height="64" class="avatar avatar-64 photo" alt="" style="float: left;padding-right: 3px;"
  630. src="http://1.gravatar.com/avatar/fd5bd959efce7d8c5c40518276bb3998?s=64&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D64&amp;r=G" /></a>
  631.  
  632. This plugin was created by Svetoslav Marinov (Slavi),
  633. Founder of <a href="http://orbisius.com/?utm_source=orbisius-simple-notice&utm_medium=plugin-settings-about&utm_campaign=plugin-update" target="_blank">orbisius.com</a>.
  634. Connect with him on <a href="http://slavi.biz/linkedin" target="_blank"
  635. title="Click to see Slavi's linkedin profile. Opens in a new tab/window">Linkedin</a>
  636. and
  637. <a href="http://slavi.biz/twitter" target="_blank"
  638. title="Click to see Slavi's twitter profile. Opens in a new tab/window">Twitter</a>.
  639. </p>
  640. </div> <!-- .inside -->
  641. </div> <!-- .postbox -->
  642.  
  643. </div> <!-- .meta-box-sortables -->
  644.  
  645. </div> <!-- #postbox-container-1 .postbox-container -->
  646.  
  647. </div> <!-- #post-body .metabox-holder .columns-2 -->
  648.  
  649. <br class="clear">
  650. </div> <!-- #poststuff -->
  651.  
  652. <h2>Extensions</h2>
  653. <p>Extensions allow you to add an extra functionality to this plugin.</p>
  654. <div>
  655. <?php
  656. if (!has_action('orbisius_simple_notice_ext_action_extension_list')) {
  657. echo "No extensions have been installed.";
  658. } else {
  659. echo "The following extensions have been found.<br/><ul>";
  660. do_action('orbisius_simple_notice_ext_action_extension_list');
  661. echo "</ul>";
  662. }
  663. ?>
  664. </div>
  665.  
  666. <!-- share -->
  667. <?php
  668. $plugin_data = orbisius_simple_notice_get_plugin_data();
  669.  
  670. $app_link = urlencode($plugin_data['url']);
  671. $app_title = urlencode($plugin_data['name']);
  672. $app_descr = urlencode($plugin_data['description']);
  673. ?>
  674.  
  675. <h2>Share</h2>
  676. <p>
  677. <!-- AddThis Button BEGIN -->
  678. <div class="addthis_toolbox addthis_default_style addthis_32x32_style">
  679. <a class="addthis_button_facebook" addthis:url="<?php echo $app_link ?>" addthis:title="<?php echo $app_title ?>" addthis:description="<?php echo $app_descr ?>"></a>
  680. <a class="addthis_button_twitter" addthis:url="<?php echo $app_link ?>" addthis:title="<?php echo $app_title ?>" addthis:description="<?php echo $app_descr ?>"></a>
  681. <a class="addthis_button_google_plusone" g:plusone:count="false" addthis:url="<?php echo $app_link ?>" addthis:title="<?php echo $app_title ?>" addthis:description="<?php echo $app_descr ?>"></a>
  682. <a class="addthis_button_linkedin" addthis:url="<?php echo $app_link ?>" addthis:title="<?php echo $app_title ?>" addthis:description="<?php echo $app_descr ?>"></a>
  683. <a class="addthis_button_email" addthis:url="<?php echo $app_link ?>" addthis:title="<?php echo $app_title ?>" addthis:description="<?php echo $app_descr ?>"></a>
  684. <a class="addthis_button_myspace" addthis:url="<?php echo $app_link ?>" addthis:title="<?php echo $app_title ?>" addthis:description="<?php echo $app_descr ?>"></a>
  685. <a class="addthis_button_google" addthis:url="<?php echo $app_link ?>" addthis:title="<?php echo $app_title ?>" addthis:description="<?php echo $app_descr ?>"></a>
  686. <a class="addthis_button_digg" addthis:url="<?php echo $app_link ?>" addthis:title="<?php echo $app_title ?>" addthis:description="<?php echo $app_descr ?>"></a>
  687. <a class="addthis_button_delicious" addthis:url="<?php echo $app_link ?>" addthis:title="<?php echo $app_title ?>" addthis:description="<?php echo $app_descr ?>"></a>
  688. <a class="addthis_button_stumbleupon" addthis:url="<?php echo $app_link ?>" addthis:title="<?php echo $app_title ?>" addthis:description="<?php echo $app_descr ?>"></a>
  689. <a class="addthis_button_tumblr" addthis:url="<?php echo $app_link ?>" addthis:title="<?php echo $app_title ?>" addthis:description="<?php echo $app_descr ?>"></a>
  690. <a class="addthis_button_favorites" addthis:url="<?php echo $app_link ?>" addthis:title="<?php echo $app_title ?>" addthis:description="<?php echo $app_descr ?>"></a>
  691. <a class="addthis_button_compact"></a>
  692. </div>
  693. <!-- The JS code is in the footer -->
  694.  
  695. <script type="text/javascript">
  696. var addthis_config = {"data_track_clickback": true};
  697. var addthis_share = {
  698. templates: {twitter: 'Check out {{title}} @ {{lurl}} (from @orbisius)'}
  699. }
  700. </script>
  701. <!-- AddThis Button START part2 -->
  702. <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=lordspace"></script>
  703. <!-- AddThis Button END part2 -->
  704. </p>
  705. <!-- /share -->
  706.  
  707. <?php
  708. $plugin_slug = basename(__FILE__);
  709. $plugin_slug = str_replace('.php', '', $plugin_slug);
  710. ?>
  711. <iframe style="width:100%;min-height:300px;height: auto;" width="640" height="480"
  712. src="http://club.orbisius.com/wpu/content/wp/<?php echo $plugin_slug; ?>/" frameborder="0" allowfullscreen></iframe>
  713.  
  714. </div>
  715. <?php
  716. }
  717.  
  718. function orbisius_simple_notice_generate_newsletter_box() {
  719. $current_user = wp_get_current_user();
  720. $email = empty($current_user->user_email) ? '' : $current_user->user_email;
  721.  
  722. $plugin_data = orbisius_simple_notice_get_plugin_data();
  723. $plugin_name = $plugin_data['name'];
  724. ?>
  725.  
  726. <table>
  727. <tr>
  728. <td valign="top">
  729. <div id='app-plugin-notice' class='app_mailing_list_box' width="100%">
  730. <!-- Begin MailChimp Signup Form -->
  731. <div id="mc_embed_signup">
  732. <form action="http://orbisius.us2.list-manage.com/subscribe/post?u=005070a78d0e52a7b567e96df&amp;id=1b83cd2093" method="post"
  733. id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank">
  734. <input type="hidden" value="<?php echo esc_attr($plugin_name); ?>" name="SRC" id="mce-SRC" />
  735. <input type="hidden" value="<?php echo esc_attr($plugin_name); ?>" name="MERGE3" id="mce-MERGE3" />
  736.  
  737. <p>Join our newsletter and we will be notify you when we release cool plugins.</p>
  738. <div class="mc-field-group">
  739. <label for="mce-EMAIL">Email <span class="app_asterisk">*</span>
  740. </label>
  741. <input type="email" value="<?php echo esc_attr($email); ?>" name="EMAIL" class="required email" id="mce-EMAIL" />
  742. </div>
  743. <div id="mce-responses" class="clear">
  744. <div class="response" id="mce-error-response" style="display:none"></div>
  745. <div class="response" id="mce-success-response" style="display:none"></div>
  746. </div>
  747. <div class="clear"><input type="submit" value="Join" name="subscribe" id="mc-embedded-subscribe" class="button button-primary"></div>
  748. </form>
  749. </div>
  750. <!--End mc_embed_signup-->
  751. </div>
  752. </td>
  753. <!--<td valign="top">
  754. <p>
  755. You can also signup using this link: <a href="http://eepurl.com/guNzr" target="_blank">http://eepurl.com/guNzr</a> <br/>
  756. You can also signup using this QR code: <br/>
  757. <img src="%%PLUGIN_URL%%/zzz_media/qr_code.png" alt="" width="100"/>
  758. </p>
  759. </td>-->
  760. </tr>
  761. </table>
  762.  
  763. <?php
  764. }
  765.  
  766. function orbisius_simple_notice_get_plugin_data() {
  767. // pull only these vars
  768. $default_headers = array(
  769. 'Name' => 'Plugin Name',
  770. 'PluginURI' => 'Plugin URI',
  771. 'Description' => 'Description',
  772. );
  773.  
  774. $plugin_data = get_file_data(__FILE__, $default_headers, 'plugin');
  775.  
  776. $data['name'] = $plugin_data['Name'];
  777. $data['url'] = $plugin_data['PluginURI'];
  778. $data['description'] = $plugin_data['Description'];
  779.  
  780. return $data;
  781. }
  782.  
  783. /**
  784. * adds some HTML comments in the page so people would know that this plugin powers their site.
  785. */
  786. function orbisius_simple_notice_add_plugin_credits() {
  787. $plugin_data = orbisius_simple_notice_get_plugin_data();
  788.  
  789. $url = $plugin_data['url'];
  790. $name = $plugin_data['name'];
  791.  
  792. printf(PHP_EOL . PHP_EOL . '<!-- ' . "Powered by $name | URL: $url " . '-->' . PHP_EOL . PHP_EOL);
  793. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement