press-this.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * Press This Display and Handler.
  4. *
  5. * @package WordPress
  6. * @subpackage Press_This
  7. */
  8. define( 'IFRAME_REQUEST' , true );
  9. /** WordPress Administration Bootstrap */
  10. require_once( dirname( __FILE__ ) . '/admin.php' );
  11. function wp_load_press_this() {
  12. $plugin_slug = 'press-this';
  13. $plugin_file = 'press-this/press-this-plugin.php';
  14. if ( ! current_user_can( 'edit_posts' ) || ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
  15. wp_die(
  16. __( 'Sorry, you are not allowed to create posts as this user.' ),
  17. __( 'You need a higher level of permission.' ),
  18. 403
  19. );
  20. } elseif ( is_plugin_active( $plugin_file ) ) {
  21. include( WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php' );
  22. $wp_press_this = new WP_Press_This_Plugin();
  23. $wp_press_this->html();
  24. } elseif ( current_user_can( 'activate_plugins' ) ) {
  25. if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_file ) ) {
  26. $url = wp_nonce_url( add_query_arg( array(
  27. 'action' => 'activate',
  28. 'plugin' => $plugin_file,
  29. 'from' => 'press-this',
  30. ), admin_url( 'plugins.php' ) ), 'activate-plugin_' . $plugin_file );
  31. $action = sprintf(
  32. '<a href="%1$s" aria-label="%2$s">%2$s</a>',
  33. esc_url( $url ),
  34. __( 'Activate Press This' )
  35. );
  36. } else {
  37. if ( is_main_site() ) {
  38. $url = wp_nonce_url( add_query_arg( array(
  39. 'action' => 'install-plugin',
  40. 'plugin' => $plugin_slug,
  41. 'from' => 'press-this',
  42. ), self_admin_url( 'update.php' ) ), 'install-plugin_' . $plugin_slug );
  43. $action = sprintf(
  44. '<a href="%1$s" class="install-now" data-slug="%2$s" data-name="%2$s" aria-label="%3$s">%3$s</a>',
  45. esc_url( $url ),
  46. esc_attr( $plugin_slug ),
  47. __( 'Install Now' )
  48. );
  49. } else {
  50. $action = sprintf(
  51. /* translators: URL to wp-admin/press-this.php */
  52. __( 'Press This is not installed. Please install Press This from <a href="%s">the main site</a>.' ),
  53. get_admin_url( get_current_network_id(), 'press-this.php' )
  54. );
  55. }
  56. }
  57. wp_die(
  58. __( 'The Press This plugin is required.' ) . '<br />' . $action,
  59. __( 'Installation Required' ),
  60. 200
  61. );
  62. } else {
  63. wp_die(
  64. __( 'Press This is not available. Please contact your site administrator.' ),
  65. __( 'Installation Required' ),
  66. 200
  67. );
  68. }
  69. }
  70. wp_load_press_this();