Jetpack_JITM

Jetpack just in time messaging through out the admin.

Defined (1)

The class is defined in the following location(s).

/class.jetpack-jitm.php  
  1. class Jetpack_JITM { 
  2.  
  3. /** 
  4. * @var Jetpack_JITM 
  5. **/ 
  6. private static $instance = null; 
  7.  
  8. static function init() { 
  9. if ( is_null( self::$instance ) ) { 
  10. self::$instance = new Jetpack_JITM; 
  11.  
  12. return self::$instance; 
  13.  
  14. private function __construct() { 
  15. global $pagenow; 
  16. $jetpack_hide_jitm = Jetpack_Options::get_option( 'hide_jitm' ); 
  17. if ( 'media-new.php' == $pagenow && ! Jetpack::is_module_active( 'photon' ) && 'hide' != $jetpack_hide_jitm['photon'] ) { 
  18. add_action( 'admin_enqueue_scripts', array( $this, 'jitm_enqueue_files' ) ); 
  19. add_action( 'post-plupload-upload-ui', array( $this, 'photon_msg' ) ); 
  20.  
  21. /** 
  22. * Present Photon just in time activation msg 
  23. */ 
  24. function photon_msg() { 
  25. if ( current_user_can( 'jetpack_manage_modules' ) ) { ?> 
  26. <div class="jp-jitm"> 
  27. <a href="#" data-module="photon" class="dismiss"><span class="genericon genericon-close"></span></a> 
  28. <div class="jp-emblem"> 
  29. <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0" y="0" viewBox="0 0 172.9 172.9" enable-background="new 0 0 172.9 172.9" xml:space="preserve"> 
  30. <path d="M86.4 0C38.7 0 0 38.7 0 86.4c0 47.7 38.7 86.4 86.4 86.4s86.4-38.7 86.4-86.4C172.9 38.7 134.2 0 86.4 0zM83.1 106.6l-27.1-6.9C49 98 45.7 90.1 49.3 84l33.8-58.5V106.6zM124.9 88.9l-33.8 58.5V66.3l27.1 6.9C125.1 74.9 128.4 82.8 124.9 88.9z"/> 
  31. </svg> 
  32. </div> 
  33. <p> 
  34. <?php _e( 'Deliver super-fast images to your visitors that are automatically optimized for any device.', 'jetpack' ); ?> 
  35. </p> 
  36. <p> 
  37. <a href="#" data-module="photon" class="activate button button-jetpack"> 
  38. <?php esc_html_e( 'Activate Photon', 'jetpack' ); ?> 
  39. </a> 
  40. </p> 
  41. </div> 
  42. <?php 
  43. //jitm is being viewed, track it 
  44. $jetpack = Jetpack::init(); 
  45. $jetpack->stat( 'jitm', 'photon-viewed' ); 
  46. $jetpack->do_stats( 'server_side' ); 
  47.  
  48. /** 
  49. * Function to enqueue jitm css and js 
  50. */ 
  51. function jitm_enqueue_files( $hook ) { 
  52.  
  53. $wp_styles = new WP_Styles(); 
  54. $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; 
  55. wp_enqueue_style( 'jetpack-jitm-css', plugins_url( "css/jetpack-admin-jitm{$min}.css", JETPACK__PLUGIN_FILE ), false, JETPACK__VERSION . '-20121016' ); 
  56. $wp_styles->add_data( 'jetpack-jitm-css', 'rtl', true ); 
  57.  
  58. // Enqueue javascript to handle jitm notice events 
  59. wp_enqueue_script( 'jetpack-jitm-js', plugins_url( '_inc/jetpack-jitm.js', JETPACK__PLUGIN_FILE ),  
  60. array( 'jquery' ), JETPACK__VERSION, true ); 
  61. wp_localize_script( 
  62. 'jetpack-jitm-js',  
  63. 'jitmL10n',  
  64. array( 
  65. 'ajaxurl' => admin_url( 'admin-ajax.php' ),  
  66. 'jitm_nonce' => wp_create_nonce( 'jetpack-jitm-nonce' ),  
  67. 'photon_msgs' => array( 
  68. 'success' => __( 'Success! Photon is now actively optimizing and serving your images for free.', 'jetpack' ),  
  69. 'fail' => __( 'We are sorry but unfortunately Photon did not activate.', 'jetpack' ) 
  70. );