press-this-plugin.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Press This
  4. *
  5. * Plugin Name: Press This
  6. * Plugin URI: https://wordpress.org
  7. * Description: A little tool that lets you grab bits of the web and create new posts with ease.
  8. * Version: 1.0.0
  9. * Author: WordPress Contributors
  10. * Author URI: https://wordpress.org
  11. * License: GPL-2.0+
  12. * License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  13. * Text Domain: press-this
  14. * Domain Path: /languages
  15. */
  16. /*
  17. * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
  18. * General Public License version 2, as published by the Free Software Foundation. You may NOT assume
  19. * that you can use any other version of the GPL.
  20. *
  21. * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
  22. * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  23. *
  24. */
  25. add_action( 'wp_ajax_press-this-plugin-save-post', 'wp_ajax_press_this_plugin_save_post');
  26. add_action( 'wp_ajax_press-this-plugin-add-category', 'wp_ajax_press_this_plugin_add_category' );
  27. add_action( 'tool_box', 'press_this_tool_box' );
  28. /**
  29. * Ajax handler for saving a post from Press This.
  30. *
  31. * @since 1.0.0
  32. */
  33. function wp_ajax_press_this_plugin_save_post() {
  34. include( plugin_dir_path( __FILE__ ) . 'class-wp-press-this-plugin.php' );
  35. $wp_press_this = new WP_Press_This_Plugin();
  36. $wp_press_this->save_post();
  37. }
  38. /**
  39. * Ajax handler for creating new category from Press This.
  40. *
  41. * @since 1.0.0
  42. */
  43. function wp_ajax_press_this_plugin_add_category() {
  44. include( plugin_dir_path( __FILE__ ) . 'class-wp-press-this-plugin.php' );
  45. $wp_press_this = new WP_Press_This_Plugin();
  46. $wp_press_this->add_category();
  47. }
  48. function press_this_tool_box() {
  49. if ( current_user_can('edit_posts') ) { ?>
  50. <div class="card pressthis">
  51. <h2><?php _e('Press This', 'press-this') ?></h2>
  52. <p><?php _e( 'Press This is a little tool that lets you grab bits of the web and create new posts with ease.', 'press-this' ); ?>
  53. <?php _e( 'It will even allow you to choose from images or videos included on the page and use them in your post.', 'press-this' ); ?>
  54. <?php _e( 'Use Press This as a quick and lightweight way to highlight another page on the web.', 'press-this' ); ?></p>
  55. <p><a href="<?php echo htmlspecialchars( admin_url( 'press-this.php' ) ); ?>"><?php _e( 'Open Press This', 'press-this' ); ?></a>
  56. <?php _e( 'then add it to your device&#8217;s bookmarks or home screen.', 'press-this' ); ?></p>
  57. </div>
  58. <?php }
  59. }