Jetpack by WordPress.com - Version 3.8.3

Version Description

Release Date: May 26, 2016

  • Important security update. Please upgrade immediately.
Download this release

Release Info

Developer samhotchkiss
Plugin Icon 128x128 Jetpack by WordPress.com
Version 3.8.3
Comparing to
See all releases

Code changes from version 3.7.3 to 3.8.3

Files changed (222) hide show
  1. 3rd-party/bitly.php +8 -8
  2. _inc/jetpack-jitm.js +40 -16
  3. _inc/jetpack-modules.js +2 -0
  4. _inc/jp.js +6 -1
  5. _inc/lib/admin-pages/class.jetpack-landing-page.php +1 -1
  6. _inc/lib/admin-pages/class.jetpack-settings-page.php +1 -1
  7. _inc/lib/markdown/gfm.php +2 -2
  8. _inc/lib/tonesque.php +2 -0
  9. class.jetpack-admin.php +2 -2
  10. class.jetpack-autoupdate.php +127 -95
  11. class.jetpack-client-server.php +0 -1
  12. class.jetpack-client.php +3 -3
  13. class.jetpack-debugger.php +34 -4
  14. class.jetpack-heartbeat.php +6 -0
  15. class.jetpack-ixr-client.php +2 -4
  16. class.jetpack-jitm.php +168 -11
  17. class.jetpack-network.php +6 -2
  18. class.jetpack-options.php +0 -1
  19. class.jetpack-post-images.php +13 -43
  20. class.jetpack-sync.php +46 -11
  21. class.jetpack-user-agent.php +34 -29
  22. class.jetpack-xmlrpc-server.php +0 -2
  23. class.jetpack.php +226 -41
  24. class.json-api-endpoints.php +18 -1
  25. class.json-api.php +36 -3
  26. class.media-summary.php +1 -1
  27. class.photon.php +91 -14
  28. css/jetpack-admin-jitm-rtl.css +39 -23
  29. css/jetpack-admin-jitm-rtl.min.css +1 -1
  30. css/jetpack-admin-jitm.css +38 -22
  31. css/jetpack-admin-jitm.css.map +1 -1
  32. css/jetpack-admin-jitm.min.css +1 -1
  33. css/jetpack-admin-jitm.min.css.map +1 -1
  34. css/jetpack-admin-rtl.css +45 -78
  35. css/jetpack-admin-rtl.min.css +1 -1
  36. css/jetpack-admin.css +44 -77
  37. css/jetpack-admin.css.map +1 -1
  38. css/jetpack-admin.min.css +1 -1
  39. css/jetpack-admin.min.css.map +1 -1
  40. css/jetpack-banners-rtl.css +4 -5
  41. css/jetpack-banners-rtl.min.css +1 -1
  42. css/jetpack-banners.css +3 -4
  43. css/jetpack-banners.css.map +1 -1
  44. css/jetpack-banners.min.css +1 -1
  45. css/jetpack-banners.min.css.map +1 -1
  46. css/jetpack-rtl.css +1 -1
  47. css/jetpack.css +1 -1
  48. functions.compat.php +3 -2
  49. functions.gallery.php +4 -0
  50. functions.opengraph.php +26 -6
  51. functions.photon.php +12 -0
  52. images/custom-css.jpg +0 -0
  53. images/custom-css@2x.jpg +0 -0
  54. images/jetpack-icon.jpg +0 -0
  55. images/jetpack-logo.png +0 -0
  56. images/rss/blue-large.png +0 -0
  57. images/rss/blue-medium.png +0 -0
  58. images/rss/green-large.png +0 -0
  59. images/rss/green-medium.png +0 -0
  60. images/rss/green-small.png +0 -0
  61. images/rss/orange-large.png +0 -0
  62. images/rss/orange-medium.png +0 -0
  63. images/rss/orange-small.png +0 -0
  64. images/rss/pink-large.png +0 -0
  65. images/rss/pink-medium.png +0 -0
  66. images/rss/pink-small.png +0 -0
  67. images/rss/purple-large.png +0 -0
  68. images/rss/purple-medium.png +0 -0
  69. images/rss/purple-small.png +0 -0
  70. images/rss/red-large.png +0 -0
  71. images/rss/red-medium.png +0 -0
  72. images/rss/red-small.png +0 -0
  73. images/rss/silver-large.png +0 -0
  74. images/rss/silver-medium.png +0 -0
  75. images/rss/silver-small.png +0 -0
  76. images/screenshots/beautifulmath.jpg +0 -0
  77. images/screenshots/beautifulmath.png +0 -0
  78. images/screenshots/carousel.jpg +0 -0
  79. images/screenshots/carousel.png +0 -0
  80. images/screenshots/comments.jpg +0 -0
  81. images/screenshots/comments.png +0 -0
  82. images/screenshots/contactform.jpg +0 -0
  83. images/screenshots/contactform.png +0 -0
  84. images/screenshots/custom-content-types.jpg +0 -0
  85. images/screenshots/custom-content-types.png +0 -0
  86. images/screenshots/custom-css.jpg +0 -0
  87. images/screenshots/custom-css.png +0 -0
  88. images/screenshots/google-plus.jpg +0 -0
  89. images/screenshots/google-plus.png +0 -0
  90. images/screenshots/hovercards.jpg +0 -0
  91. images/screenshots/hovercards.png +0 -0
  92. images/screenshots/likes.jpg +0 -0
  93. images/screenshots/likes.png +0 -0
  94. images/screenshots/manage-sm.png +0 -0
  95. images/screenshots/manage.jpg +0 -0
  96. images/screenshots/manage.png +0 -0
  97. images/screenshots/mobile-push-notifications.jpg +0 -0
  98. images/screenshots/mobile-theme.jpg +0 -0
  99. images/screenshots/mobile-theme.png +0 -0
  100. images/screenshots/notes.jpg +0 -0
  101. images/screenshots/notes.png +0 -0
  102. images/screenshots/post-by-email.jpg +0 -0
  103. images/screenshots/post-by-email.png +0 -0
  104. images/screenshots/publicize.jpg +0 -0
  105. images/screenshots/publicize.png +0 -0
  106. images/screenshots/related-posts.jpg +0 -0
  107. images/screenshots/related-posts.png +0 -0
  108. images/screenshots/sharing.jpg +0 -0
  109. images/screenshots/sharing.png +0 -0
  110. images/screenshots/shortcodes.jpg +0 -0
  111. images/screenshots/shortcodes.png +0 -0
  112. images/screenshots/shortlinks.jpg +0 -0
  113. images/screenshots/shortlinks.png +0 -0
  114. images/screenshots/site-icon.png +0 -0
  115. images/screenshots/spelling.jpg +0 -0
  116. images/screenshots/spelling.png +0 -0
  117. images/screenshots/stats.jpg +0 -0
  118. images/screenshots/stats.png +0 -0
  119. images/screenshots/subscriptions.jpg +0 -0
  120. images/screenshots/subscriptions.png +0 -0
  121. images/screenshots/tiled-gallery.jpg +0 -0
  122. images/screenshots/tiled-gallery.png +0 -0
  123. images/screenshots/vaultpress.jpg +0 -0
  124. images/screenshots/vaultpress.png +0 -0
  125. images/screenshots/widgets.jpg +0 -0
  126. images/screenshots/widgets.png +0 -0
  127. images/wordpress-connect.jpg +0 -0
  128. images/wordpress-connect@2x.jpg +0 -0
  129. images/wordpress-stats.jpg +0 -0
  130. images/wordpress-stats@2x.jpg +0 -0
  131. jetpack.php +2 -2
  132. json-endpoints.php +70 -0
  133. json-endpoints/class.wpcom-json-api-get-customcss.php +34 -0
  134. json-endpoints/class.wpcom-json-api-get-site-endpoint.php +44 -1
  135. json-endpoints/class.wpcom-json-api-list-posts-v1-1-endpoint.php +1 -2
  136. json-endpoints/class.wpcom-json-api-post-endpoint.php +2 -0
  137. json-endpoints/class.wpcom-json-api-publicize-endpoint.php +2 -0
  138. json-endpoints/class.wpcom-json-api-site-settings-endpoint.php +22 -0
  139. json-endpoints/class.wpcom-json-api-update-comment-endpoint.php +2 -0
  140. json-endpoints/class.wpcom-json-api-update-customcss.php +50 -0
  141. json-endpoints/class.wpcom-json-api-update-post-endpoint.php +9 -4
  142. json-endpoints/class.wpcom-json-api-update-post-v1-1-endpoint.php +7 -4
  143. json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php +11 -8
  144. json-endpoints/jetpack/class.jetpack-json-api-log-endpoint.php +16 -0
  145. json-endpoints/jetpack/class.jetpack-json-api-maybe-auto-update-endpoint.php +32 -0
  146. json-endpoints/jetpack/class.jetpack-json-api-plugins-install-endpoint.php +112 -7
  147. json-endpoints/jetpack/class.wpcom-json-api-get-option-endpoint.php +39 -0
  148. json-endpoints/jetpack/class.wpcom-json-api-update-option-endpoint.php +23 -0
  149. json-endpoints/jetpack/json-api-jetpack-endpoints.php +92 -0
  150. languages/jetpack-af.mo +0 -0
  151. languages/jetpack-ar.mo +0 -0
  152. languages/jetpack-bg_BG.mo +0 -0
  153. languages/jetpack-cy.mo +0 -0
  154. languages/jetpack-de_DE.mo +0 -0
  155. languages/jetpack-el.mo +0 -0
  156. languages/jetpack-es_CL.mo +0 -0
  157. languages/jetpack-es_ES.mo +0 -0
  158. languages/jetpack-fa_IR.mo +0 -0
  159. languages/jetpack-fr_FR.mo +0 -0
  160. languages/jetpack-he_IL.mo +0 -0
  161. languages/jetpack-id_ID.mo +0 -0
  162. languages/jetpack-is_IS.mo +0 -0
  163. languages/jetpack-it_IT.mo +0 -0
  164. languages/jetpack-ja.mo +0 -0
  165. languages/jetpack-ka_GE.mo +0 -0
  166. languages/jetpack-ko_KR.mo +0 -0
  167. languages/jetpack-lt_LT.mo +0 -0
  168. languages/jetpack-lv.mo +0 -0
  169. languages/jetpack-ms_MY.mo +0 -0
  170. languages/jetpack-my_MM.mo +0 -0
  171. languages/jetpack-nl_NL.mo +0 -0
  172. languages/jetpack-nn_NO.mo +0 -0
  173. languages/jetpack-pt_BR.mo +0 -0
  174. languages/jetpack-ru_RU.mo +0 -0
  175. languages/jetpack-sa_IN.mo +0 -0
  176. languages/jetpack-sv_SE.mo +0 -0
  177. languages/jetpack-th.mo +0 -0
  178. languages/jetpack-tr_TR.mo +0 -0
  179. languages/jetpack-uk.mo +0 -0
  180. languages/jetpack-zh_CN.mo +0 -0
  181. languages/jetpack-zh_TW.mo +0 -0
  182. languages/readme.txt +2 -6
  183. locales.php +146 -67
  184. modules/after-the-deadline.php +4 -0
  185. modules/after-the-deadline/proxy.php +6 -0
  186. modules/carousel.php +1 -0
  187. modules/carousel/jetpack-carousel.js +74 -34
  188. modules/carousel/jetpack-carousel.php +20 -0
  189. modules/comments.php +1 -0
  190. modules/comments/base.php +1 -7
  191. modules/comments/comments.php +32 -0
  192. modules/contact-form.php +1 -0
  193. modules/contact-form/admin.php +44 -19
  194. modules/contact-form/css/rtl/grunion-rtl.css +3 -1
  195. modules/contact-form/css/rtl/menu-alter-rtl.css +52 -1
  196. modules/contact-form/grunion-contact-form.php +209 -36
  197. modules/contact-form/grunion-form-view.php +13 -4
  198. modules/contact-form/js/grunion.js +57 -4
  199. modules/custom-content-types.php +1 -0
  200. modules/custom-css.php +2 -1
  201. modules/custom-css/custom-css.php +325 -96
  202. modules/custom-post-types/comics.php +16 -13
  203. modules/custom-post-types/nova.php +32 -23
  204. modules/custom-post-types/portfolios.php +76 -30
  205. modules/custom-post-types/testimonial.php +36 -18
  206. modules/enhanced-distribution.php +1 -0
  207. modules/gravatar-hovercards.php +10 -0
  208. modules/holiday-snow.php +15 -3
  209. modules/infinite-scroll.php +24 -3
  210. modules/infinite-scroll/infinity.js +1 -1
  211. modules/infinite-scroll/infinity.php +219 -12
  212. modules/infinite-scroll/themes/twentysixteen-rtl.css +161 -0
  213. modules/infinite-scroll/themes/twentysixteen.css +161 -0
  214. modules/infinite-scroll/themes/twentysixteen.php +41 -0
  215. modules/json-api.php +1 -0
  216. modules/latex.php +1 -1
  217. modules/likes.php +52 -5
  218. modules/manage.php +6 -0
  219. modules/manage/activate-admin.php +95 -0
  220. modules/manage/confirm-admin.php +107 -0
  221. modules/markdown.php +2 -1
  222. modules/markdown/easy-markdown.php +9 -0
3rd-party/bitly.php CHANGED
@@ -1,11 +1,11 @@
1
- <?php
2
 
3
- /*
4
  * Fixes issues with the Official Bitly for WordPress
5
  * http://wordpress.org/plugins/bitly/
6
  */
7
  if( class_exists( 'Bitly' ) ) {
8
-
9
  if( isset( $GLOBALS['bitly'] ) ) {
10
  remove_action( 'wp_head', array( $GLOBALS['bitly'], 'og_tags' ) );
11
  add_action( 'wp_head', 'jetpack_bitly_og_tag', 100 );
@@ -14,8 +14,8 @@ if( class_exists( 'Bitly' ) ) {
14
  }
15
 
16
  /**
17
- * jetpack_bitly_og_tag
18
- *
19
  * @return null
20
  */
21
  function jetpack_bitly_og_tag() {
@@ -23,7 +23,7 @@ function jetpack_bitly_og_tag() {
23
  // Add the bitly part again back if we don't have any jetpack_og_tags added
24
  $GLOBALS['bitly']->og_tags();
25
  } elseif ( isset( $GLOBALS['posts'] ) && $GLOBALS['posts'][0]->ID > 0 ) {
26
- printf( "<meta property=\"bitly:url\" content=\"%s\" /> \n", esc_attr( $GLOBALS['bitly']->get_bitly_link_for_post_id( $GLOBALS['posts'][0]->ID ) ) );
27
- }
28
 
29
- }
1
+ <?php
2
 
3
+ /*
4
  * Fixes issues with the Official Bitly for WordPress
5
  * http://wordpress.org/plugins/bitly/
6
  */
7
  if( class_exists( 'Bitly' ) ) {
8
+
9
  if( isset( $GLOBALS['bitly'] ) ) {
10
  remove_action( 'wp_head', array( $GLOBALS['bitly'], 'og_tags' ) );
11
  add_action( 'wp_head', 'jetpack_bitly_og_tag', 100 );
14
  }
15
 
16
  /**
17
+ * jetpack_bitly_og_tag
18
+ *
19
  * @return null
20
  */
21
  function jetpack_bitly_og_tag() {
23
  // Add the bitly part again back if we don't have any jetpack_og_tags added
24
  $GLOBALS['bitly']->og_tags();
25
  } elseif ( isset( $GLOBALS['posts'] ) && $GLOBALS['posts'][0]->ID > 0 ) {
26
+ printf( "<meta property=\"bitly:url\" content=\"%s\" /> \n", esc_attr( $GLOBALS['bitly']->get_bitly_link_for_post_id( $GLOBALS['posts'][0]->ID ) ) );
27
+ }
28
 
29
+ }
_inc/jetpack-jitm.js CHANGED
@@ -11,9 +11,11 @@
11
  $(document).ready(function () {
12
 
13
  data = {
14
- 'action' : 'jitm_ajax',
15
- 'jitmNonce' : jitmL10n.jitm_nonce,
16
- 'photon' : jitmL10n.photon_msgs
 
 
17
  };
18
 
19
  initEvents();
@@ -29,47 +31,69 @@
29
  var module_slug, success_msg, fail_msg, hide_msg;
30
 
31
  // On dismiss of JITM admin notice
32
- $('.jp-jitm .dismiss').click(function() {
33
  // hide the notice
34
- $('.jp-jitm').hide();
35
 
36
  // ajax request to save dismiss and never show again
37
  data.jitmActionToTake = 'dismiss';
38
- module_slug = $(this).data('module');
39
  data.jitmModule = module_slug;
40
 
41
- $.post( jitmL10n.ajaxurl, data, function (response) {
42
  if ( true === response.success ) {
43
  //console.log('successfully dismissed for ever')
44
  }
45
  });
46
  });
47
 
48
- $('.jp-jitm .activate').click(function() {
49
 
 
 
 
50
  data.jitmActionToTake = 'activate';
51
 
52
  // get the module we're working with using the data-module attribute
53
- module_slug = $(this).data('module');
54
- success_msg = data[module_slug].success;
 
55
  fail_msg = data[module_slug].fail;
56
 
57
  data.jitmModule = module_slug;
58
 
59
  // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
60
- $.post( jitmL10n.ajaxurl, data, function (response) {
61
  // If there's no response, something bad happened
62
  if ( true === response.success ) {
63
- $('.jp-jitm').html('<p><span class="icon"></span>'+success_msg+'</p>');
64
- hide_msg = setTimeout(function () {
65
- $('.jp-jitm').hide('slow');
66
- }, 5000);
 
 
 
 
 
67
  } else {
68
- $('.jp-jitm').html('<p><span class="icon"></span>'+fail_msg+'</p>');
69
  }
70
  });
71
 
72
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  }
74
 
75
  })(jQuery, jitmL10n);
11
  $(document).ready(function () {
12
 
13
  data = {
14
+ 'action' : 'jitm_ajax',
15
+ 'jitmNonce' : jitmL10n.jitm_nonce,
16
+ 'photon' : jitmL10n.photon_msgs,
17
+ 'manage' : jitmL10n.manage_msgs,
18
+ 'jitm_stats_url' : jitmL10n.jitm_stats_url
19
  };
20
 
21
  initEvents();
31
  var module_slug, success_msg, fail_msg, hide_msg;
32
 
33
  // On dismiss of JITM admin notice
34
+ $( '.jp-jitm .dismiss' ).click( function() {
35
  // hide the notice
36
+ $( '.jp-jitm' ).hide();
37
 
38
  // ajax request to save dismiss and never show again
39
  data.jitmActionToTake = 'dismiss';
40
+ module_slug = $(this).data( 'module' );
41
  data.jitmModule = module_slug;
42
 
43
+ $.post( jitmL10n.ajaxurl, data, function ( response ) {
44
  if ( true === response.success ) {
45
  //console.log('successfully dismissed for ever')
46
  }
47
  });
48
  });
49
 
50
+ $( '.jp-jitm .activate' ).click(function() {
51
 
52
+ var $self = $( this );
53
+ $( '.button' ).addClass( 'hide' );
54
+ $( '.j-spinner' ).toggleClass( 'hide' );
55
  data.jitmActionToTake = 'activate';
56
 
57
  // get the module we're working with using the data-module attribute
58
+ module_slug = $self.data( 'module' );
59
+ // Check if there's a custom success message, otherwise use default.
60
+ success_msg = $self.data( 'module-success' ) ? $self.data( 'module-success' ) : data[module_slug].success;
61
  fail_msg = data[module_slug].fail;
62
 
63
  data.jitmModule = module_slug;
64
 
65
  // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
66
+ $.post( jitmL10n.ajaxurl, data, function ( response ) {
67
  // If there's no response, something bad happened
68
  if ( true === response.success ) {
69
+ var $msg = $( '.msg' );
70
+ $msg.html( success_msg );
71
+ $( '#jetpack-wordpressdotcom, .j-spinner' ).toggleClass( 'hide' );
72
+ if ( 'manage' !== data.jitmModule ) {
73
+ hide_msg = setTimeout( function () {
74
+ $( '.jp-jitm' ).hide( 'slow' );
75
+ }, 5000 );
76
+ }
77
+ $msg.closest( '.jp-jitm' ).find( '.show-after-enable.hide' ).removeClass( 'hide' );
78
  } else {
79
+ $( '.jp-jitm' ).html( '<p><span class="icon"></span>' + fail_msg + '</p>' );
80
  }
81
  });
82
 
83
  });
84
+
85
+ $( '.jp-jitm .launch' ).click(function() {
86
+ data.jitmActionToTake = 'launch';
87
+ module_slug = $(this).data( 'module' );
88
+ data.jitmModule = module_slug;
89
+ // ajax request to save click in stat
90
+ $.post( jitmL10n.ajaxurl, data );
91
+ } );
92
+
93
+ $( '#jetpack-wordpressdotcom' ).click(function() {
94
+ //Log user heads to wordpress.com/plugins
95
+ new Image().src = data.jitm_stats_url;
96
+ });
97
  }
98
 
99
  })(jQuery, jitmL10n);
_inc/jetpack-modules.js CHANGED
@@ -57,6 +57,7 @@
57
  $( '.modal ').empty().html( wp.template( 'modal' )( items[ module ] ) );
58
  $( '.modal' )[0].setAttribute( 'tabindex', '0' );
59
  $( '.modal' ).focus();
 
60
  };
61
 
62
  /**
@@ -74,6 +75,7 @@
74
  set_modal_tab( null );
75
  originPoint.focus();
76
  $( '.modal' )[0].removeAttribute( 'tabindex' );
 
77
  event.preventDefault();
78
  };
79
 
57
  $( '.modal ').empty().html( wp.template( 'modal' )( items[ module ] ) );
58
  $( '.modal' )[0].setAttribute( 'tabindex', '0' );
59
  $( '.modal' ).focus();
60
+ $( 'body' ).css( 'overflow', 'hidden' );
61
  };
62
 
63
  /**
75
  set_modal_tab( null );
76
  originPoint.focus();
77
  $( '.modal' )[0].removeAttribute( 'tabindex' );
78
+ $( 'body' ).css( 'overflow', 'auto' );
79
  event.preventDefault();
80
  };
81
 
_inc/jp.js CHANGED
@@ -56,6 +56,7 @@
56
  $( '.manage-right' ).removeClass( 'show' );
57
  originPoint.focus();
58
  $( '.modal' )[0].removeAttribute( 'tabindex' );
 
59
  return false;
60
  });
61
 
@@ -66,6 +67,7 @@
66
  $( '.manage-right' ).removeClass( 'show' );
67
  originPoint.focus();
68
  $( '.modal' )[0].removeAttribute( 'tabindex' );
 
69
  }
70
  });
71
  }
@@ -138,6 +140,9 @@
138
  $modal[0].setAttribute( 'tabindex', '0' );
139
  $modal.focus();
140
 
 
 
 
141
  closeShadeToggle();
142
 
143
  // Modal header links
@@ -302,7 +307,7 @@
302
  });
303
 
304
  $( '.jumpstart-spinner, .jstart, #jumpstart-cta, .manage-cta-inactive' ).hide();
305
- $( '.jumpstart-message, .miguel, .manage-cta-active' ).toggle();
306
  $( '#jump-start-area' ).delay( 5000 ).hide( 600 );
307
 
308
  // Log Jump Start event in MC Stats
56
  $( '.manage-right' ).removeClass( 'show' );
57
  originPoint.focus();
58
  $( '.modal' )[0].removeAttribute( 'tabindex' );
59
+ $( 'body' ).css( 'overflow', 'auto' );
60
  return false;
61
  });
62
 
67
  $( '.manage-right' ).removeClass( 'show' );
68
  originPoint.focus();
69
  $( '.modal' )[0].removeAttribute( 'tabindex' );
70
+ $( 'body' ).css( 'overflow', 'auto' );
71
  }
72
  });
73
  }
140
  $modal[0].setAttribute( 'tabindex', '0' );
141
  $modal.focus();
142
 
143
+ // Disallow scroll
144
+ $( 'body' ).css( 'overflow', 'hidden' );
145
+
146
  closeShadeToggle();
147
 
148
  // Modal header links
307
  });
308
 
309
  $( '.jumpstart-spinner, .jstart, #jumpstart-cta, .manage-cta-inactive' ).hide();
310
+ $( '.jumpstart-message, .manage-cta-active' ).toggle();
311
  $( '#jump-start-area' ).delay( 5000 ).hide( 600 );
312
 
313
  // Log Jump Start event in MC Stats
_inc/lib/admin-pages/class.jetpack-landing-page.php CHANGED
@@ -203,7 +203,7 @@ class Jetpack_Landing_Page extends Jetpack_Admin_Page {
203
  ?>
204
  <div id="message" class="jetpack-message">
205
  <div class="squeezer">
206
- <h4><?php echo wp_kses( $message, array( 'strong' => array(), 'a' => array( 'href' => true ), 'br' => true ) ); ?></h4>
207
  <?php
208
  /**
209
  * Fires within the displayed message when a feature configuation is updated.
203
  ?>
204
  <div id="message" class="jetpack-message">
205
  <div class="squeezer">
206
+ <h2><?php echo wp_kses( $message, array( 'strong' => array(), 'a' => array( 'href' => true ), 'br' => true ) ); ?></h2>
207
  <?php
208
  /**
209
  * Fires within the displayed message when a feature configuation is updated.
_inc/lib/admin-pages/class.jetpack-settings-page.php CHANGED
@@ -19,7 +19,7 @@ class Jetpack_Settings_Page extends Jetpack_Admin_Page {
19
  $list_table = new Jetpack_Modules_List_Table;
20
  ?>
21
  <div class="clouds-sm"></div>
22
- <?php /** This action is documented in class.jetpack.php */
23
  do_action( 'jetpack_notices' ) ?>
24
  <div class="page-content configure">
25
  <div class="frame top hide-if-no-js">
19
  $list_table = new Jetpack_Modules_List_Table;
20
  ?>
21
  <div class="clouds-sm"></div>
22
+ <?php /** This action is already documented in views/admin/admin-page.php */
23
  do_action( 'jetpack_notices' ) ?>
24
  <div class="page-content configure">
25
  <div class="frame top hide-if-no-js">
_inc/lib/markdown/gfm.php CHANGED
@@ -265,10 +265,10 @@ class WPCom_GHF_Markdown_Parser extends MarkdownExtra_Parser {
265
  */
266
  protected function get_shortcode_regex() {
267
  $pattern = get_shortcode_regex();
268
-
269
  // don't match markdown link anchors that could be mistaken for shortcodes.
270
  $pattern .= '(?!\()';
271
-
272
  return "/$pattern/s";
273
  }
274
 
265
  */
266
  protected function get_shortcode_regex() {
267
  $pattern = get_shortcode_regex();
268
+
269
  // don't match markdown link anchors that could be mistaken for shortcodes.
270
  $pattern .= '(?!\()';
271
+
272
  return "/$pattern/s";
273
  }
274
 
_inc/lib/tonesque.php CHANGED
@@ -25,6 +25,8 @@ class Tonesque {
25
  /**
26
  * Allows any image URL to be passed in for $this->image_url.
27
  *
 
 
28
  * @since 2.5.0
29
  *
30
  * @param string $image_url The URL to any image
25
  /**
26
  * Allows any image URL to be passed in for $this->image_url.
27
  *
28
+ * @module theme-tools
29
+ *
30
  * @since 2.5.0
31
  *
32
  * @param string $image_url The URL to any image
class.jetpack-admin.php CHANGED
@@ -143,7 +143,7 @@ class Jetpack_Admin {
143
  /**
144
  * Filter the search terms for a module
145
  *
146
- * Search terms are be typically added to a module in module-info.php.
147
  *
148
  * Use syntax:
149
  * function jetpack_$module_search_terms( $terms ) {
@@ -156,7 +156,7 @@ class Jetpack_Admin {
156
  *
157
  * @param string The search terms (comma separated).
158
  */
159
- echo apply_filters( 'jetpack_search_terms_' . $module, '' );
160
  $module_array['search_terms'] = ob_get_clean();
161
 
162
  $module_array['configurable'] = false;
143
  /**
144
  * Filter the search terms for a module
145
  *
146
+ * Search terms are typically added to the module headers, under "Additional Search Queries".
147
  *
148
  * Use syntax:
149
  * function jetpack_$module_search_terms( $terms ) {
156
  *
157
  * @param string The search terms (comma separated).
158
  */
159
+ echo apply_filters( 'jetpack_search_terms_' . $module, $module_array['additional_search_queries'] );
160
  $module_array['search_terms'] = ob_get_clean();
161
 
162
  $module_array['configurable'] = false;
class.jetpack-autoupdate.php CHANGED
@@ -6,17 +6,16 @@
6
  */
7
  class Jetpack_Autoupdate {
8
 
9
- public $updates_allowed;
10
- public $jetpack;
11
- public $autoupdate_results;
12
- public $is_updating = false;
13
 
14
- public $autoupdate_expected = array(
15
- 'plugin'=> array(),
 
 
16
  'theme' => array(),
17
  );
18
 
19
- public $log = array(
20
  'plugin' => array(),
21
  'theme' => array(),
22
  );
@@ -31,38 +30,33 @@ class Jetpack_Autoupdate {
31
  }
32
 
33
  private function __construct() {
34
-
35
- $this->updates_allowed = Jetpack::is_module_active( 'manage' );
36
- // Only run automatic updates if a user as opted in by activating the manage module.
37
- if ( $this->updates_allowed ) {
38
  add_filter( 'auto_update_plugin', array( $this, 'autoupdate_plugin' ), 10, 2 );
39
  add_filter( 'auto_update_theme', array( $this, 'autoupdate_theme' ), 10, 2 );
40
  add_filter( 'auto_update_core', array( $this, 'autoupdate_core' ), 10, 2 );
41
- add_action( 'automatic_updates_complete', array( $this, 'automatic_updates_complete' ), 10, 1 );
42
- add_action( 'shutdown', array( $this, 'log_results' ) );
43
  }
44
  }
45
 
46
- function autoupdate_plugin( $update, $item ) {
47
  $autoupdate_plugin_list = Jetpack_Options::get_option( 'autoupdate_plugins', array() );
48
  if ( in_array( $item->plugin, $autoupdate_plugin_list ) ) {
49
- $this->expect( $item->plugin );
50
  return true;
51
  }
52
-
53
  return $update;
54
  }
55
 
56
- function autoupdate_theme( $update, $item ) {
57
  $autoupdate_theme_list = Jetpack_Options::get_option( 'autoupdate_themes', array() );
58
  if ( in_array( $item->theme , $autoupdate_theme_list) ) {
59
- $this->expect( $item->theme, $type = 'theme' );
60
  return true;
61
  }
62
  return $update;
63
  }
64
 
65
- function autoupdate_core( $update, $item ) {
66
  $autoupdate_core = Jetpack_Options::get_option( 'autoupdate_core', false );
67
  if ( $autoupdate_core ) {
68
  return $autoupdate_core;
@@ -71,14 +65,16 @@ class Jetpack_Autoupdate {
71
  }
72
 
73
  /**
74
- * Stores the an item identifier to the autoupdate_expected array.
75
  *
76
  * @param string $item Example: 'jetpack/jetpack.php' for type 'plugin' or 'twentyfifteen' for type 'theme'
77
  * @param string $type 'plugin' or 'theme'
78
  */
79
- function expect( $item, $type='plugin' ) {
80
- $this->is_updating = true;
81
- $this->autoupdate_expected[ $type ][] = $item;
 
 
82
  }
83
 
84
  /**
@@ -86,30 +82,30 @@ class Jetpack_Autoupdate {
86
  *
87
  * @param $results - Sent by WP_Automatic_Updater after it completes an autoupdate action. Results may be empty.
88
  */
89
- function automatic_updates_complete( $results ) {
90
- $this->autoupdate_results = $results;
91
- }
 
 
92
 
93
- /**
94
- * On shutdown, let's check to see if we've preformed an automatic update.
95
- * If so, let's compare the expected results to the actual results, and log our findings.
96
- *
97
- * Results are logged locally via Jetpack::log(), and globally via Jetpack::do_stats()
98
- */
99
- function log_results() {
100
 
101
- if ( $this->is_updating ) {
102
 
103
- $this->jetpack = Jetpack::init();
104
- $items_to_log = array( 'plugin', 'theme' );
 
 
105
 
106
- foreach( $items_to_log as $items ) {
107
- $this->log_items( $items );
108
- }
109
 
110
- $this->jetpack->do_stats( 'server_side' );
111
- $this->jetpack->log( 'autoupdates', $this->log );
112
- }
 
 
 
113
  }
114
 
115
  /**
@@ -117,41 +113,60 @@ class Jetpack_Autoupdate {
117
  *
118
  * @param $items 'plugin' or 'theme'
119
  */
120
- function log_items( $items ) {
121
- $num_items_updated = 0;
122
- $num_items_failed = 0;
123
- $item_results = $this->get_successful_updates( $items );
124
- $items_failed = array();
125
-
126
- foreach( $this->autoupdate_expected[ $items ] as $item ) {
127
- if ( in_array( $item, $item_results ) ) {
128
- $num_items_updated++;
129
- $this->log[ $items ][ $item ] = true;
130
- } else {
131
- $num_items_failed++;
132
- $this->log[ $items ][ $item ] = new WP_Error( "$items-fail", $this->get_error_message( $item, $type = $items ) );
133
- $items_failed[] = $item;
 
134
  }
135
  }
 
136
 
137
- if ( $num_items_updated ) {
138
- $this->jetpack->stat( "autoupdates/$items-success", $num_items_updated );
 
 
 
 
 
139
  }
140
 
141
- if ( $num_items_failed ) {
142
- // bump stats
143
- $this->jetpack->stat( "autoupdates/$items-fail", $num_items_failed );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  Jetpack::load_xml_rpc_client();
145
  $xml = new Jetpack_IXR_Client( array(
146
  'user_id' => get_current_user_id()
147
  ) );
148
- $request = array(
149
- 'plugins' => $items_failed,
150
- 'blog_id' => Jetpack_Options::get_option( 'id' ),
151
- );
152
- $xml->query( 'jetpack.debug_autoupdate', $request );
153
  }
154
-
155
  }
156
 
157
  /**
@@ -161,20 +176,20 @@ class Jetpack_Autoupdate {
161
  *
162
  * @return array
163
  */
164
- private function get_successful_updates( $type = 'plugin' ) {
165
  $successful_updates = array();
166
 
167
- if ( ! isset( $this->autoupdate_results[ $type ] ) ) {
168
  return $successful_updates;
169
  }
170
 
171
- foreach( $this->autoupdate_results[ $type ] as $result ) {
172
  if ( $result->result ) {
173
  switch( $type ) {
174
  case 'theme':
175
  $successful_updates[] = $result->item->theme;
176
  break;
177
- default:
178
  $successful_updates[] = $result->item->plugin;
179
  }
180
  }
@@ -183,31 +198,48 @@ class Jetpack_Autoupdate {
183
  return $successful_updates;
184
  }
185
 
186
- /**
187
- * Cycles through results generated by WP_Automatic_Updater to find the messages for the given item and item type.
188
- *
189
- * @param $item Example: 'jetpack/jetpack.php' for type 'plugin' or 'twentyfifteen' for type 'theme'
190
- * @param string $type 'plugin' or 'theme'
191
- *
192
- * @return bool|string
193
- */
194
- private function get_error_message( $item, $type = 'plugin' ) {
195
- if ( ! isset( $this->autoupdate_results[ $type ] ) ) {
196
- return false;
197
- }
198
- foreach( $this->autoupdate_results[ $type ] as $result ) {
199
- switch( $type ) {
200
- case 'theme':
201
- $id = $result->item->theme;
202
- break;
203
- default:
204
- $id = $result->item->plugin;
205
- }
206
- if ( $id == $item && isset( $result->messages ) ) {
207
- return implode( ', ', $result->messages );
208
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  }
210
- return false;
211
  }
212
 
213
  }
6
  */
7
  class Jetpack_Autoupdate {
8
 
9
+ private $results = array();
 
 
 
10
 
11
+ private $expected = array();
12
+
13
+ private $success = array(
14
+ 'plugin' => array(),
15
  'theme' => array(),
16
  );
17
 
18
+ private $failed = array(
19
  'plugin' => array(),
20
  'theme' => array(),
21
  );
30
  }
31
 
32
  private function __construct() {
33
+ if ( Jetpack::is_module_active( 'manage' ) ) {
 
 
 
34
  add_filter( 'auto_update_plugin', array( $this, 'autoupdate_plugin' ), 10, 2 );
35
  add_filter( 'auto_update_theme', array( $this, 'autoupdate_theme' ), 10, 2 );
36
  add_filter( 'auto_update_core', array( $this, 'autoupdate_core' ), 10, 2 );
37
+ add_action( 'automatic_updates_complete', array( $this, 'automatic_updates_complete' ), 999, 1 );
 
38
  }
39
  }
40
 
41
+ public function autoupdate_plugin( $update, $item ) {
42
  $autoupdate_plugin_list = Jetpack_Options::get_option( 'autoupdate_plugins', array() );
43
  if ( in_array( $item->plugin, $autoupdate_plugin_list ) ) {
44
+ $this->expect( $item->plugin, 'plugin' );
45
  return true;
46
  }
 
47
  return $update;
48
  }
49
 
50
+ public function autoupdate_theme( $update, $item ) {
51
  $autoupdate_theme_list = Jetpack_Options::get_option( 'autoupdate_themes', array() );
52
  if ( in_array( $item->theme , $autoupdate_theme_list) ) {
53
+ $this->expect( $item->theme, 'theme' );
54
  return true;
55
  }
56
  return $update;
57
  }
58
 
59
+ public function autoupdate_core( $update, $item ) {
60
  $autoupdate_core = Jetpack_Options::get_option( 'autoupdate_core', false );
61
  if ( $autoupdate_core ) {
62
  return $autoupdate_core;
65
  }
66
 
67
  /**
68
+ * Stores the an item identifier to the expected array.
69
  *
70
  * @param string $item Example: 'jetpack/jetpack.php' for type 'plugin' or 'twentyfifteen' for type 'theme'
71
  * @param string $type 'plugin' or 'theme'
72
  */
73
+ private function expect( $item, $type ) {
74
+ if ( ! isset( $this->expected[ $type ] ) ) {
75
+ $this->expected[ $type ] = array();
76
+ }
77
+ $this->expected[ $type ][] = $item;
78
  }
79
 
80
  /**
82
  *
83
  * @param $results - Sent by WP_Automatic_Updater after it completes an autoupdate action. Results may be empty.
84
  */
85
+ public function automatic_updates_complete( $results ) {
86
+ if ( empty( $this->expected ) ) {
87
+ return;
88
+ }
89
+ $this->results = empty( $results ) ? self::get_possible_failures() : $results;
90
 
91
+ add_action( 'shutdown', array( $this, 'bump_stats' ) );
 
 
 
 
 
 
92
 
93
+ Jetpack::init();
94
 
95
+ $items_to_log = array( 'plugin', 'theme' );
96
+ foreach( $items_to_log as $items ) {
97
+ $this->log_items( $items );
98
+ }
99
 
100
+ Jetpack::log( 'autoupdates', $this->get_log() );
101
+ }
 
102
 
103
+ public function get_log() {
104
+ return array(
105
+ 'results' => $this->results,
106
+ 'failed' => $this->failed,
107
+ 'success' => $this->success
108
+ );
109
  }
110
 
111
  /**
113
  *
114
  * @param $items 'plugin' or 'theme'
115
  */
116
+ private function log_items( $items ) {
117
+
118
+ if ( ! isset( $this->expected[ $items ] ) ) {
119
+ return;
120
+ }
121
+
122
+ $item_results = $this->get_successful_updates( $items );
123
+
124
+ if ( is_array( $this->expected[ $items ] ) ) {
125
+ foreach( $this->expected[ $items ] as $item ) {
126
+ if ( in_array( $item, $item_results ) ) {
127
+ $this->success[ $items ][] = $item;
128
+ } else {
129
+ $this->failed[ $items ][] = $item;
130
+ }
131
  }
132
  }
133
+ }
134
 
135
+ public function bump_stats() {
136
+ $instance = Jetpack::init();
137
+ $log = array();
138
+ // Bump numbers
139
+ if ( ! empty( $this->success['plugin'] ) ) {
140
+ $instance->stat( 'autoupdates/plugin-success', count( $this->success['plugin'] ) );
141
+ $log['plugins_success'] = $this->success['plugin'];
142
  }
143
 
144
+ if ( ! empty( $this->failed['plugin'] ) ) {
145
+ $instance->stat( 'autoupdates/plugin-fail', count( $this->failed['plugin'] ) );
146
+ $log['plugins_failed'] = $this->failed['plugin'];
147
+ }
148
+
149
+ if ( ! empty( $this->success['theme'] ) ) {
150
+ $instance->stat( 'autoupdates/theme-success', count( $this->success['theme'] ) );
151
+ $log['themes_success'] = $this->success['theme'];
152
+ }
153
+
154
+ if ( ! empty( $this->failed['theme'] ) ) {
155
+ $instance->stat( 'autoupdates/theme-fail', count( $this->failed['theme'] ) );
156
+ $log['themes_failed'] = $this->failed['theme'];
157
+ }
158
+
159
+ $instance->do_stats( 'server_side' );
160
+
161
+ // Send a more detailed log to logstash
162
+ if ( ! empty( $log ) ) {
163
  Jetpack::load_xml_rpc_client();
164
  $xml = new Jetpack_IXR_Client( array(
165
  'user_id' => get_current_user_id()
166
  ) );
167
+ $log['blog_id'] = Jetpack_Options::get_option( 'id' );
168
+ $xml->query( 'jetpack.debug_autoupdate', $log );
 
 
 
169
  }
 
170
  }
171
 
172
  /**
176
  *
177
  * @return array
178
  */
179
+ private function get_successful_updates( $type ) {
180
  $successful_updates = array();
181
 
182
+ if ( ! isset( $this->results[ $type ] ) ) {
183
  return $successful_updates;
184
  }
185
 
186
+ foreach( $this->results[ $type ] as $result ) {
187
  if ( $result->result ) {
188
  switch( $type ) {
189
  case 'theme':
190
  $successful_updates[] = $result->item->theme;
191
  break;
192
+ case 'plugin':
193
  $successful_updates[] = $result->item->plugin;
194
  }
195
  }
198
  return $successful_updates;
199
  }
200
 
201
+ static function get_possible_failures() {
202
+ $result = array();
203
+ // Lets check some reasons why it might not be working as expected
204
+ include_once( ABSPATH . '/wp-admin/includes/admin.php' );
205
+ include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' );
206
+ $upgrader = new WP_Automatic_Updater;
207
+
208
+ if ( $upgrader->is_disabled() ) {
209
+ $result[] = 'autoupdates-disabled';
210
+ }
211
+ if ( ! is_main_site() ) {
212
+ $result[] = 'is-not-main-site';
213
+ }
214
+ if ( ! is_main_network() ) {
215
+ $result[] = 'is-not-main-network';
216
+ }
217
+ if ( $upgrader->is_vcs_checkout( ABSPATH ) ) {
218
+ $result[] = 'site-on-vcs';
219
+ }
220
+ if ( $upgrader->is_vcs_checkout( WP_PLUGIN_DIR ) ) {
221
+ $result[] = 'plugin-directory-on-vcs';
222
+ }
223
+ if ( $upgrader->is_vcs_checkout( WP_CONTENT_DIR ) ) {
224
+ $result[] = 'content-directory-on-vcs';
225
+ }
226
+ $lock = get_option( 'auto_updater.lock' );
227
+ if ( $lock > ( time() - HOUR_IN_SECONDS ) ) {
228
+ $result[] = 'lock-is-set';
229
+ }
230
+ $skin = new Automatic_Upgrader_Skin;
231
+ include_once( ABSPATH . 'wp-admin/includes/file.php' );
232
+ include_once( ABSPATH . 'wp-admin/includes/template.php' );
233
+ if ( ! $skin->request_filesystem_credentials( false, ABSPATH, false ) ) {
234
+ $result[] = 'no-system-write-access';
235
+ }
236
+ if ( ! $skin->request_filesystem_credentials( false, WP_PLUGIN_DIR, false ) ) {
237
+ $result[] = 'no-plugin-directory-write-access';
238
+ }
239
+ if ( ! $skin->request_filesystem_credentials( false, WP_CONTENT_DIR, false ) ) {
240
+ $result[] = 'no-wp-content-directory-write-access';
241
  }
242
+ return $result;
243
  }
244
 
245
  }
class.jetpack-client-server.php CHANGED
@@ -8,7 +8,6 @@ class Jetpack_Client_Server {
8
 
9
  function authorize() {
10
  $data = stripslashes_deep( $_GET );
11
- $args = array();
12
  $redirect = isset( $data['redirect'] ) ? esc_url_raw( (string) $data['redirect'] ) : '';
13
 
14
  $jetpack_unique_connection = Jetpack_Options::get_option( 'unique_connection' );
8
 
9
  function authorize() {
10
  $data = stripslashes_deep( $_GET );
 
11
  $redirect = isset( $data['redirect'] ) ? esc_url_raw( (string) $data['redirect'] ) : '';
12
 
13
  $jetpack_unique_connection = Jetpack_Options::get_option( 'unique_connection' );
class.jetpack-client.php CHANGED
@@ -54,7 +54,7 @@ class Jetpack_Client {
54
  $jetpack_signature = new Jetpack_Signature( $token->secret, $time_diff );
55
 
56
  $timestamp = time() + $time_diff;
57
-
58
  if( function_exists( 'wp_generate_password' ) ) {
59
  $nonce = wp_generate_password( 10, false );
60
  } else {
@@ -141,14 +141,14 @@ class Jetpack_Client {
141
  * Return `true` to ENABLE SSL verification, return `false`
142
  * to DISABLE SSL verification.
143
  *
144
- * @since 3.6
145
  *
146
  * @param bool Whether to force `sslverify` or not.
147
  */
148
  if ( apply_filters( 'jetpack_client_verify_ssl_certs', false ) ) {
149
  return wp_remote_request( $url, $args );
150
  }
151
-
152
  $fallback = Jetpack_Options::get_option( 'fallback_no_verify_ssl_certs' );
153
  if ( false === $fallback ) {
154
  Jetpack_Options::update_option( 'fallback_no_verify_ssl_certs', 0 );
54
  $jetpack_signature = new Jetpack_Signature( $token->secret, $time_diff );
55
 
56
  $timestamp = time() + $time_diff;
57
+
58
  if( function_exists( 'wp_generate_password' ) ) {
59
  $nonce = wp_generate_password( 10, false );
60
  } else {
141
  * Return `true` to ENABLE SSL verification, return `false`
142
  * to DISABLE SSL verification.
143
  *
144
+ * @since 3.6.0
145
  *
146
  * @param bool Whether to force `sslverify` or not.
147
  */
148
  if ( apply_filters( 'jetpack_client_verify_ssl_certs', false ) ) {
149
  return wp_remote_request( $url, $args );
150
  }
151
+
152
  $fallback = Jetpack_Options::get_option( 'fallback_no_verify_ssl_certs' );
153
  if ( false === $fallback ) {
154
  Jetpack_Options::update_option( 'fallback_no_verify_ssl_certs', 0 );
class.jetpack-debugger.php CHANGED
@@ -14,9 +14,8 @@ class Jetpack_Debugger {
14
  }
15
  }
16
 
17
- public static function jetpack_increase_timeout($time) {
18
- $time = 30; //seconds
19
- return $time;
20
  }
21
 
22
  public static function jetpack_debug_display_handler() {
@@ -57,6 +56,37 @@ class Jetpack_Debugger {
57
  $debug_info .= "\r\n" . esc_html( "JETPACK__PLUGIN_DIR: " . JETPACK__PLUGIN_DIR );
58
  $debug_info .= "\r\n" . esc_html( "SITE_URL: " . site_url() );
59
  $debug_info .= "\r\n" . esc_html( "HOME_URL: " . home_url() );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
  $debug_info .= "\r\n\r\nTEST RESULTS:\r\n\r\n";
62
  $debug_raw_info = '';
@@ -139,7 +169,7 @@ class Jetpack_Debugger {
139
  <ol>
140
  <li><b><em><?php esc_html_e( 'A known issue.', 'jetpack' ); ?></em></b> <?php echo sprintf( __( 'Some themes and plugins have <a href="%1$s">known conflicts</a> with Jetpack – check the <a href="%2$s">list</a>. (You can also browse the <a href="%3$s">Jetpack support pages</a> or <a href="%4$s">Jetpack support forum</a> to see if others have experienced and solved the problem.)', 'jetpack' ), 'http://jetpack.me/support/getting-started-with-jetpack/known-issues/', 'http://jetpack.me/support/getting-started-with-jetpack/known-issues/', 'http://jetpack.me/support/', 'http://wordpress.org/support/plugin/jetpack' ); ?></li>
141
  <li><b><em><?php esc_html_e( 'An incompatible plugin.', 'jetpack' ); ?></em></b> <?php esc_html_e( "Find out by disabling all plugins except Jetpack. If the problem persists, it's not a plugin issue. If the problem is solved, turn your plugins on one by one until the problem pops up again – there's the culprit! Let us know, and we'll try to help.", 'jetpack' ); ?></li>
142
- <li><b><em><?php esc_html_e( 'A theme conflict.', 'jetpack' ); ?></em></b> <?php esc_html_e( "If your problem isn't known or caused by a plugin, try activating Twenty Twelve (the default WordPress theme). If this solves the problem, something in your theme is probably broken – let the theme's author know.", 'jetpack' ); ?></li>
143
  <li><b><em><?php esc_html_e( 'A problem with your XMLRPC file.', 'jetpack' ); ?></em></b> <?php echo sprintf( __( 'Load your <a href="%s">XMLRPC file</a>. It should say “XML-RPC server accepts POST requests only.” on a line by itself.', 'jetpack' ), site_url( 'xmlrpc.php' ) ); ?>
144
  <ul>
145
  <li>- <?php esc_html_e( "If it's not by itself, a theme or plugin is displaying extra characters. Try steps 2 and 3.", 'jetpack' ); ?></li>
14
  }
15
  }
16
 
17
+ public static function jetpack_increase_timeout() {
18
+ return 30; // seconds
 
19
  }
20
 
21
  public static function jetpack_debug_display_handler() {
56
  $debug_info .= "\r\n" . esc_html( "JETPACK__PLUGIN_DIR: " . JETPACK__PLUGIN_DIR );
57
  $debug_info .= "\r\n" . esc_html( "SITE_URL: " . site_url() );
58
  $debug_info .= "\r\n" . esc_html( "HOME_URL: " . home_url() );
59
+ $debug_info .= "\r\n" . esc_html( "SERVER_PORT: " . $_SERVER['SERVER_PORT'] );
60
+
61
+
62
+ foreach ( array (
63
+ 'GD_PHP_HANDLER',
64
+ 'HTTP_AKAMAI_ORIGIN_HOP',
65
+ 'HTTP_CF_CONNECTING_IP',
66
+ 'HTTP_CLIENT_IP',
67
+ 'HTTP_FASTLY_CLIENT_IP',
68
+ 'HTTP_FORWARDED',
69
+ 'HTTP_FORWARDED_FOR',
70
+ 'HTTP_INCAP_CLIENT_IP',
71
+ 'HTTP_TRUE_CLIENT_IP',
72
+ 'HTTP_X_CLIENTIP',
73
+ 'HTTP_X_CLUSTER_CLIENT_IP',
74
+ 'HTTP_X_FORWARDED',
75
+ 'HTTP_X_FORWARDED_FOR',
76
+ 'HTTP_X_IP_TRAIL',
77
+ 'HTTP_X_REAL_IP',
78
+ 'HTTP_X_VARNISH',
79
+ 'REMOTE_ADDR'
80
+ ) as $header ) {
81
+ if( isset( $_SERVER[$header] ) ) {
82
+ $debug_info .= "\r\n" . esc_html( 'IP HEADER: '.$header . ": " . $_SERVER[$header] );
83
+ } else {
84
+ $debug_info .= "\r\n" . esc_html( 'IP HEADER: '.$header . ": Not Set" );
85
+ }
86
+ }
87
+
88
+
89
+ $debug_info .= "\r\n" . esc_html( "PROTECT_TRUSTED_HEADER: " . json_encode(get_site_option( 'trusted_ip_header' )));
90
 
91
  $debug_info .= "\r\n\r\nTEST RESULTS:\r\n\r\n";
92
  $debug_raw_info = '';
169
  <ol>
170
  <li><b><em><?php esc_html_e( 'A known issue.', 'jetpack' ); ?></em></b> <?php echo sprintf( __( 'Some themes and plugins have <a href="%1$s">known conflicts</a> with Jetpack – check the <a href="%2$s">list</a>. (You can also browse the <a href="%3$s">Jetpack support pages</a> or <a href="%4$s">Jetpack support forum</a> to see if others have experienced and solved the problem.)', 'jetpack' ), 'http://jetpack.me/support/getting-started-with-jetpack/known-issues/', 'http://jetpack.me/support/getting-started-with-jetpack/known-issues/', 'http://jetpack.me/support/', 'http://wordpress.org/support/plugin/jetpack' ); ?></li>
171
  <li><b><em><?php esc_html_e( 'An incompatible plugin.', 'jetpack' ); ?></em></b> <?php esc_html_e( "Find out by disabling all plugins except Jetpack. If the problem persists, it's not a plugin issue. If the problem is solved, turn your plugins on one by one until the problem pops up again – there's the culprit! Let us know, and we'll try to help.", 'jetpack' ); ?></li>
172
+ <li><b><em><?php esc_html_e( 'A theme conflict.', 'jetpack' ); ?></em></b> <?php esc_html_e( "If your problem isn't known or caused by a plugin, try activating Twenty Fifteen (the default WordPress theme). If this solves the problem, something in your theme is probably broken – let the theme's author know.", 'jetpack' ); ?></li>
173
  <li><b><em><?php esc_html_e( 'A problem with your XMLRPC file.', 'jetpack' ); ?></em></b> <?php echo sprintf( __( 'Load your <a href="%s">XMLRPC file</a>. It should say “XML-RPC server accepts POST requests only.” on a line by itself.', 'jetpack' ), site_url( 'xmlrpc.php' ) ); ?>
174
  <ul>
175
  <li>- <?php esc_html_e( "If it's not by itself, a theme or plugin is displaying extra characters. Try steps 2 and 3.", 'jetpack' ); ?></li>
class.jetpack-heartbeat.php CHANGED
@@ -91,6 +91,11 @@ class Jetpack_Heartbeat {
91
 
92
  $jetpack->do_stats( 'server_side' );
93
 
 
 
 
 
 
94
  do_action( 'jetpack_heartbeat' );
95
  }
96
 
@@ -105,6 +110,7 @@ class Jetpack_Heartbeat {
105
  $return["{$prefix}php-branch"] = floatval( PHP_VERSION );
106
  $return["{$prefix}public"] = Jetpack_Options::get_option( 'public' );
107
  $return["{$prefix}ssl"] = Jetpack::permit_ssl();
 
108
  $return["{$prefix}language"] = get_bloginfo( 'language' );
109
  $return["{$prefix}charset"] = get_bloginfo( 'charset' );
110
  $return["{$prefix}is-multisite"] = is_multisite() ? 'multisite' : 'singlesite';
91
 
92
  $jetpack->do_stats( 'server_side' );
93
 
94
+ /**
95
+ * Fires when we synchronize all registered options on heartbeat.
96
+ *
97
+ * @since 3.3.0
98
+ */
99
  do_action( 'jetpack_heartbeat' );
100
  }
101
 
110
  $return["{$prefix}php-branch"] = floatval( PHP_VERSION );
111
  $return["{$prefix}public"] = Jetpack_Options::get_option( 'public' );
112
  $return["{$prefix}ssl"] = Jetpack::permit_ssl();
113
+ $return["{$prefix}is-https"] = is_ssl() ? 'https' : 'http';
114
  $return["{$prefix}language"] = get_bloginfo( 'language' );
115
  $return["{$prefix}charset"] = get_bloginfo( 'charset' );
116
  $return["{$prefix}is-multisite"] = is_multisite() ? 'multisite' : 'singlesite';
class.jetpack-ixr-client.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
  /**
4
  * IXR_Client
5
  *
@@ -29,10 +31,6 @@ class Jetpack_IXR_Client extends IXR_Client {
29
  $request = new IXR_Request( $method, $args );
30
  $xml = trim( $request->getXml() );
31
 
32
- $headers = array(
33
- 'Content-Type' => 'text/xml',
34
- );
35
-
36
  $response = Jetpack_Client::remote_request( $this->jetpack_args, $xml );
37
 
38
  if ( is_wp_error( $response ) ) {
1
  <?php
2
 
3
+ require_once( ABSPATH . WPINC . '/class-IXR.php' );
4
+
5
  /**
6
  * IXR_Client
7
  *
31
  $request = new IXR_Request( $method, $args );
32
  $xml = trim( $request->getXml() );
33
 
 
 
 
 
34
  $response = Jetpack_Client::remote_request( $this->jetpack_args, $xml );
35
 
36
  if ( is_wp_error( $response ) ) {
class.jetpack-jitm.php CHANGED
@@ -12,6 +12,13 @@ class Jetpack_JITM {
12
  **/
13
  private static $instance = null;
14
 
 
 
 
 
 
 
 
15
  static function init() {
16
  if ( is_null( self::$instance ) ) {
17
  self::$instance = new Jetpack_JITM;
@@ -21,12 +28,74 @@ class Jetpack_JITM {
21
  }
22
 
23
  private function __construct() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  global $pagenow;
25
- $jetpack_hide_jitm = Jetpack_Options::get_option( 'hide_jitm' );
26
- if ( 'media-new.php' == $pagenow && ! Jetpack::is_module_active( 'photon' ) && 'hide' != $jetpack_hide_jitm['photon'] ) {
 
 
 
 
 
27
  add_action( 'admin_enqueue_scripts', array( $this, 'jitm_enqueue_files' ) );
28
  add_action( 'post-plupload-upload-ui', array( $this, 'photon_msg' ) );
29
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  }
31
 
32
  /*
@@ -42,23 +111,103 @@ class Jetpack_JITM {
42
  <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"/>
43
  </svg>
44
  </div>
45
- <p>
46
- <?php _e( 'Deliver super-fast images to your visitors that are automatically optimized for any device.', 'jetpack' ); ?>
47
  </p>
48
  <p>
49
- <a href="#" data-module="photon" class="activate button button-jetpack">
50
- <?php esc_html_e( 'Activate Photon', 'jetpack' ); ?>
51
- </a>
52
  </p>
53
  </div>
54
  <?php
55
  //jitm is being viewed, track it
56
  $jetpack = Jetpack::init();
57
- $jetpack->stat( 'jitm', 'photon-viewed' );
58
  $jetpack->do_stats( 'server_side' );
59
  }
60
  }
61
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  /*
63
  * Function to enqueue jitm css and js
64
  */
@@ -66,9 +215,12 @@ class Jetpack_JITM {
66
 
67
  $wp_styles = new WP_Styles();
68
  $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
69
- wp_enqueue_style( 'jetpack-jitm-css', plugins_url( "css/jetpack-admin-jitm{$min}.css", JETPACK__PLUGIN_FILE ), false, JETPACK__VERSION . '-20121016' );
70
  $wp_styles->add_data( 'jetpack-jitm-css', 'rtl', true );
71
 
 
 
 
72
  // Enqueue javascript to handle jitm notice events
73
  wp_enqueue_script( 'jetpack-jitm-js', plugins_url( '_inc/jetpack-jitm.js', JETPACK__PLUGIN_FILE ),
74
  array( 'jquery' ), JETPACK__VERSION, true );
@@ -81,7 +233,12 @@ class Jetpack_JITM {
81
  'photon_msgs' => array(
82
  'success' => __( 'Success! Photon is now actively optimizing and serving your images for free.', 'jetpack' ),
83
  'fail' => __( 'We are sorry but unfortunately Photon did not activate.', 'jetpack' )
84
- )
 
 
 
 
 
85
  )
86
  );
87
  }
12
  **/
13
  private static $instance = null;
14
 
15
+ /**
16
+ * Get user dismissed messages.
17
+ *
18
+ * @var array
19
+ */
20
+ private static $jetpack_hide_jitm = array();
21
+
22
  static function init() {
23
  if ( is_null( self::$instance ) ) {
24
  self::$instance = new Jetpack_JITM;
28
  }
29
 
30
  private function __construct() {
31
+ if ( ! Jetpack::is_active() ) {
32
+ return;
33
+ }
34
+ add_action( 'current_screen', array( $this, 'prepare_jitms' ) );
35
+ }
36
+
37
+ /**
38
+ * Prepare actions according to screen and post type.
39
+ *
40
+ * @since 3.8.2
41
+ *
42
+ * @param object $screen
43
+ */
44
+ function prepare_jitms( $screen ) {
45
  global $pagenow;
46
+ $post_type = $screen->post_type;
47
+ self::$jetpack_hide_jitm = Jetpack_Options::get_option( 'hide_jitm' );
48
+ $showphoton = empty( self::$jetpack_hide_jitm['photon'] ) ? 'show' : self::$jetpack_hide_jitm['photon'];
49
+ $showmanage = empty( self::$jetpack_hide_jitm['manage'] ) ? 'show' : self::$jetpack_hide_jitm['manage'];
50
+ $show_manage_pi = empty( self::$jetpack_hide_jitm['manage-pi'] ) ? 'show' : self::$jetpack_hide_jitm['manage-pi'];
51
+ $show_editor = empty( self::$jetpack_hide_jitm['editor'] ) ? 'show' : self::$jetpack_hide_jitm['editor'];
52
+ if ( 'media-new.php' == $pagenow && ! Jetpack::is_module_active( 'photon' ) && 'hide' != $showphoton ) {
53
  add_action( 'admin_enqueue_scripts', array( $this, 'jitm_enqueue_files' ) );
54
  add_action( 'post-plupload-upload-ui', array( $this, 'photon_msg' ) );
55
  }
56
+ else if ( 'update-core.php' == $pagenow && 'hide' != $showmanage ) {
57
+ add_action( 'admin_enqueue_scripts', array( $this, 'jitm_enqueue_files' ) );
58
+ add_action( 'admin_notices', array( $this, 'manage_msg' ) );
59
+ }
60
+ elseif ( 'plugins.php' === $pagenow && isset( $_GET['activate'] ) && 'true' === $_GET['activate'] && 'hide' != $show_manage_pi ) {
61
+ add_action( 'admin_enqueue_scripts', array( $this, 'jitm_enqueue_files' ) );
62
+ add_action( 'pre_current_active_plugins', array( $this, 'manage_pi_msg' ) );
63
+ }
64
+ elseif ( 'post-new.php' === $pagenow && in_array( $post_type, array( 'post', 'page' ) ) && 'hide' != $show_editor ) {
65
+ add_action( 'admin_enqueue_scripts', array( $this, 'jitm_enqueue_files' ) );
66
+ add_action( 'admin_notices', array( $this, 'editor_msg' ) );
67
+ }
68
+ }
69
+
70
+ /*
71
+ * Present Manage just in time activation msg on update-core.php
72
+ *
73
+ */
74
+ function manage_msg() {
75
+ if ( current_user_can( 'jetpack_manage_modules' ) ) {
76
+ $normalized_site_url = Jetpack::build_raw_urls( get_home_url() );
77
+ $manage_active = Jetpack::is_module_active( 'manage' );
78
+ ?>
79
+ <div class="jp-jitm">
80
+ <a href="#" data-module="manage" class="dismiss"><span class="genericon genericon-close"></span></a>
81
+ <div class="jp-emblem">
82
+ <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">
83
+ <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"/>
84
+ </svg>
85
+ </div>
86
+ <p class="msg">
87
+ <?php _e( 'Reduce security risks with automated plugin updates.', 'jetpack' ); ?>
88
+ </p>
89
+ <p>
90
+ <img class="j-spinner hide" src="<?php echo esc_url( includes_url( 'images/spinner-2x.gif' ) ); ?>" alt="Loading ..." /><a href="#" data-module="manage" class="activate button <?php if( Jetpack::is_module_active( 'manage' ) ) { echo 'hide'; } ?>"><?php esc_html_e( 'Activate Now', 'jetpack' ); ?></a><a href="<?php echo esc_url( 'https://wordpress.com/plugins/' . $normalized_site_url ); ?>" target="_blank" title="<?php esc_attr_e( 'Go to WordPress.com to try these features', 'jetpack' ); ?>" id="jetpack-wordpressdotcom" class="button button-jetpack <?php if( ! Jetpack::is_module_active( 'manage' ) ) { echo 'hide'; } ?>"><?php esc_html_e( 'Go to WordPress.com', 'jetpack' ); ?></a>
91
+ </p>
92
+ </div>
93
+ <?php
94
+ //jitm is being viewed, track it
95
+ $jetpack = Jetpack::init();
96
+ $jetpack->stat( 'jitm', 'manage-viewed-' . JETPACK__VERSION );
97
+ $jetpack->do_stats( 'server_side' );
98
+ }
99
  }
100
 
101
  /*
111
  <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"/>
112
  </svg>
113
  </div>
114
+ <p class="msg">
115
+ <?php _e( 'Speed up your photos and save bandwidth costs by using a free content delivery network.', 'jetpack' ); ?>
116
  </p>
117
  <p>
118
+ <img class="j-spinner hide" style="margin-top: 13px;" width="17" height="17" src="<?php echo esc_url( includes_url( 'images/spinner-2x.gif' ) ); ?>" alt="Loading ..." /><a href="#" data-module="photon" class="activate button button-jetpack"><?php esc_html_e( 'Activate Photon', 'jetpack' ); ?></a>
 
 
119
  </p>
120
  </div>
121
  <?php
122
  //jitm is being viewed, track it
123
  $jetpack = Jetpack::init();
124
+ $jetpack->stat( 'jitm', 'photon-viewed-' . JETPACK__VERSION );
125
  $jetpack->do_stats( 'server_side' );
126
  }
127
  }
128
+
129
+ /**
130
+ * Display message prompting user to enable auto-updates in WordPress.com.
131
+ *
132
+ * @since 3.8.2
133
+ */
134
+ function manage_pi_msg() {
135
+ if ( current_user_can( 'jetpack_manage_modules' ) ) {
136
+ $normalized_site_url = Jetpack::build_raw_urls( get_home_url() );
137
+ $manage_active = Jetpack::is_module_active( 'manage' );
138
+ $manage_pi_dismissed = isset( self::$jetpack_hide_jitm['manage-pi'] );
139
+
140
+ if ( ! $manage_active || ! $manage_pi_dismissed ) :
141
+ ?>
142
+ <div class="jp-jitm">
143
+ <a href="#" data-module="manage-pi" class="dismiss"><span class="genericon genericon-close"></span></a>
144
+ <div class="jp-emblem">
145
+ <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">
146
+ <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"/>
147
+ </svg>
148
+ </div>
149
+ <?php if ( ! $manage_active ) : ?>
150
+ <p class="msg">
151
+ <?php _e( 'Save time with automated plugin updates.', 'jetpack' ); ?>
152
+ </p>
153
+ <p>
154
+ <img class="j-spinner hide" src="<?php echo esc_url( includes_url( 'images/spinner-2x.gif' ) ); ?>" alt="<?php echo esc_attr__( 'Loading...', 'jetpack' ); ?>" /><a href="#" data-module="manage" data-module-success="<?php esc_attr_e( 'Success!', 'jetpack' ); ?>" class="activate button"><?php esc_html_e( 'Activate remote management', 'jetpack' ); ?></a>
155
+ </p>
156
+ <?php elseif ( $manage_active ) : ?>
157
+ <p>
158
+ <?php esc_html_e( 'Save time with auto updates on WordPress.com', 'jetpack' ); ?>
159
+ </p>
160
+ <?php endif; // manage inactive ?>
161
+ <?php if ( ! $manage_pi_dismissed ) : ?>
162
+ <p class="show-after-enable <?php echo $manage_active ? '' : 'hide' ; ?>">
163
+ <a href="<?php echo esc_url( 'https://wordpress.com/plugins/' . $normalized_site_url ); ?>" target="_blank" title="<?php esc_attr_e( 'Go to WordPress.com to enable auto-updates for plugins', 'jetpack' ); ?>" data-module="manage-pi" class="button button-jetpack launch show-after-enable"><?php esc_html_e( 'Enable auto-updates on WordPress.com', 'jetpack' ); ?></a>
164
+ </p>
165
+ <?php endif; // manage-pi inactive ?>
166
+ </div>
167
+ <?php
168
+ //jitm is being viewed, track it
169
+ $jetpack = Jetpack::init();
170
+ $jetpack->stat( 'jitm', 'manage-pi-viewed-' . JETPACK__VERSION );
171
+ $jetpack->do_stats( 'server_side' );
172
+ endif; // manage or manage-pi inactive
173
+ }
174
+ }
175
+
176
+ /**
177
+ * Display message in editor prompting user to compose entry in WordPress.com.
178
+ *
179
+ * @since 3.8.2
180
+ */
181
+ function editor_msg() {
182
+ global $typenow;
183
+ if ( current_user_can( 'jetpack_manage_modules' ) && current_user_can( 'manage_options' ) ) {
184
+ $normalized_site_url = Jetpack::build_raw_urls( get_home_url() );
185
+ $editor_dismissed = isset( self::$jetpack_hide_jitm['editor'] );
186
+ if ( ! $editor_dismissed ) :
187
+ ?>
188
+ <div class="jp-jitm">
189
+ <a href="#" data-module="editor" class="dismiss"><span class="genericon genericon-close"></span></a>
190
+ <div class="jp-emblem">
191
+ <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">
192
+ <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"/>
193
+ </svg>
194
+ </div>
195
+ <p class="msg">
196
+ <?php esc_html_e( 'Try the brand new editor.', 'jetpack' ); ?>
197
+ </p>
198
+ <p>
199
+ <a href="<?php echo esc_url( 'https://wordpress.com/' . $typenow . '/' . $normalized_site_url ); ?>" target="_blank" title="<?php esc_attr_e( 'Write on WordPress.com', 'jetpack' ); ?>" data-module="editor" class="button button-jetpack launch show-after-enable"><?php esc_html_e( 'Write on WordPress.com', 'jetpack' ); ?></a>
200
+ </p>
201
+ </div>
202
+ <?php
203
+ //jitm is being viewed, track it
204
+ $jetpack = Jetpack::init();
205
+ $jetpack->stat( 'jitm', 'editor-viewed-' . JETPACK__VERSION );
206
+ $jetpack->do_stats( 'server_side' );
207
+ endif; // manage or editor inactive
208
+ }
209
+ }
210
+
211
  /*
212
  * Function to enqueue jitm css and js
213
  */
215
 
216
  $wp_styles = new WP_Styles();
217
  $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
218
+ wp_enqueue_style( 'jetpack-jitm-css', plugins_url( "css/jetpack-admin-jitm{$min}.css", JETPACK__PLUGIN_FILE ), false, JETPACK__VERSION . '-201243242' );
219
  $wp_styles->add_data( 'jetpack-jitm-css', 'rtl', true );
220
 
221
+ //Build stats url for tracking manage button
222
+ $jitm_stats_url = Jetpack::build_stats_url( array( 'x_jetpack-jitm' => 'wordpresstools' ) );
223
+
224
  // Enqueue javascript to handle jitm notice events
225
  wp_enqueue_script( 'jetpack-jitm-js', plugins_url( '_inc/jetpack-jitm.js', JETPACK__PLUGIN_FILE ),
226
  array( 'jquery' ), JETPACK__VERSION, true );
233
  'photon_msgs' => array(
234
  'success' => __( 'Success! Photon is now actively optimizing and serving your images for free.', 'jetpack' ),
235
  'fail' => __( 'We are sorry but unfortunately Photon did not activate.', 'jetpack' )
236
+ ),
237
+ 'manage_msgs' => array(
238
+ 'success' => __( 'Success! WordPress.com tools are now active.', 'jetpack' ),
239
+ 'fail' => __( 'We are sorry but unfortunately Manage did not activate.', 'jetpack' )
240
+ ),
241
+ 'jitm_stats_url' => $jitm_stats_url
242
  )
243
  );
244
  }
class.jetpack-network.php CHANGED
@@ -356,9 +356,9 @@ class Jetpack_Network {
356
 
357
  public function show_jetpack_notice() {
358
  if ( isset( $_GET['action'] ) && 'connected' == $_GET['action'] ) {
359
- $notice = 'Blog successfully connected';
360
  } else if ( isset( $_GET['action'] ) && 'connection_failed' == $_GET['action'] ) {
361
- $notice = 'Blog connection <strong>failed</strong>';
362
  }
363
 
364
  Jetpack::init()->load_view( 'admin/network-admin-alert.php', array( 'notice' => $notice ) );
@@ -392,6 +392,10 @@ class Jetpack_Network {
392
  return;
393
  }
394
 
 
 
 
 
395
  $jp = Jetpack::init();
396
 
397
  // Figure out what site we are working on
356
 
357
  public function show_jetpack_notice() {
358
  if ( isset( $_GET['action'] ) && 'connected' == $_GET['action'] ) {
359
+ $notice = __( 'Site successfully connected.', 'jetpack' );
360
  } else if ( isset( $_GET['action'] ) && 'connection_failed' == $_GET['action'] ) {
361
+ $notice = __( 'Site connection <strong>failed</strong>', 'jetpack' );
362
  }
363
 
364
  Jetpack::init()->load_view( 'admin/network-admin-alert.php', array( 'notice' => $notice ) );
392
  return;
393
  }
394
 
395
+ if ( Jetpack::is_development_mode() ) {
396
+ return;
397
+ }
398
+
399
  $jp = Jetpack::init();
400
 
401
  // Figure out what site we are working on
class.jetpack-options.php CHANGED
@@ -137,7 +137,6 @@ class Jetpack_Options {
137
  * @param string $autoload If not compact option, allows specifying whether to autoload or not.
138
  */
139
  public static function update_option( $name, $value, $autoload = null ) {
140
-
141
  /**
142
  * Fires before Jetpack updates a specific option.
143
  *
137
  * @param string $autoload If not compact option, allows specifying whether to autoload or not.
138
  */
139
  public static function update_option( $name, $value, $autoload = null ) {
 
140
  /**
141
  * Fires before Jetpack updates a specific option.
142
  *
class.jetpack-post-images.php CHANGED
@@ -85,64 +85,28 @@ class Jetpack_PostImages {
85
  $images = array();
86
 
87
  $post = get_post( $post_id );
88
- if ( !empty( $post->post_password ) )
89
  return $images;
90
-
91
- if ( false === has_shortcode( $post->post_content, 'gallery' ) ) {
92
- return false; // no gallery - bail
93
  }
94
 
95
  $permalink = get_permalink( $post->ID );
96
 
97
- // CATS: All your base are belong to us
98
- $old_post = $GLOBALS['post'];
99
- $GLOBALS['post'] = $post;
100
- $old_shortcodes = $GLOBALS['shortcode_tags'];
101
- $GLOBALS['shortcode_tags'] = array( 'gallery' => $old_shortcodes['gallery'] );
102
-
103
- // Find all the galleries
104
- preg_match_all( '/' . get_shortcode_regex() . '/s', $post->post_content, $gallery_matches, PREG_SET_ORDER );
105
-
106
- foreach ( $gallery_matches as $gallery_match ) {
107
- $gallery = do_shortcode_tag( $gallery_match );
108
-
109
- // Um... no images in the gallery - bail
110
- if ( false === $pos = stripos( $gallery, '<img' ) )
111
- continue;
112
-
113
- preg_match_all( '/<img\s+[^>]*src=([\'"])([^\'"]*)\\1/', $gallery, $image_match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE );
114
 
115
- $a_pos = 0;
116
- foreach ( $image_match[2] as $src ) {
117
- list( $raw_src ) = explode( '?', $src[0] ); // pull off any Query string (?w=250)
118
  $raw_src = wp_specialchars_decode( $raw_src ); // rawify it
119
  $raw_src = esc_url_raw( $raw_src ); // clean it
120
-
121
- $a_pos = strrpos( substr( $gallery, 0, $src[1] ), '<a', $a_pos ); // is there surrounding <a>?
122
-
123
- if ( false !== $a_pos && preg_match( '/<a\s+[^>]*href=([\'"])([^\'"]*)\\1/', $gallery, $href_match, 0, $a_pos ) ) {
124
- $href = wp_specialchars_decode( $href_match[2] );
125
- $href = esc_url_raw( $href );
126
- } else {
127
- // CATS: You have no chance to survive make your time
128
- $href = $raw_src;
129
- }
130
-
131
- $a_pos = $src[1];
132
-
133
  $images[] = array(
134
  'type' => 'image',
135
  'from' => 'gallery',
136
  'src' => $raw_src,
137
- 'href' => $permalink, // $href,
138
  );
139
  }
140
  }
141
 
142
- // Captain: For great justice
143
- $GLOBALS['shortcode_tags'] = $old_shortcodes;
144
- $GLOBALS['post'] = $old_post;
145
-
146
  return $images;
147
  }
148
 
@@ -245,7 +209,13 @@ class Jetpack_PostImages {
245
 
246
  $too_big = ( ( ! empty( $meta['width'] ) && $meta['width'] > 1200 ) || ( ! empty( $meta['height'] ) && $meta['height'] > 1200 ) );
247
 
248
- if ( $too_big ) {
 
 
 
 
 
 
249
  $img_src = wp_get_attachment_image_src( $thumb, array( 1200, 1200 ) );
250
  } else {
251
  $img_src = wp_get_attachment_image_src( $thumb, 'full' );
85
  $images = array();
86
 
87
  $post = get_post( $post_id );
88
+ if ( ! empty( $post->post_password ) ) {
89
  return $images;
 
 
 
90
  }
91
 
92
  $permalink = get_permalink( $post->ID );
93
 
94
+ $gallery_images = get_post_galleries_images( $post->ID, false );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
+ foreach ( $gallery_images as $galleries ) {
97
+ foreach ( $galleries as $src ) {
98
+ list( $raw_src ) = explode( '?', $src ); // pull off any Query string (?w=250)
99
  $raw_src = wp_specialchars_decode( $raw_src ); // rawify it
100
  $raw_src = esc_url_raw( $raw_src ); // clean it
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  $images[] = array(
102
  'type' => 'image',
103
  'from' => 'gallery',
104
  'src' => $raw_src,
105
+ 'href' => $permalink,
106
  );
107
  }
108
  }
109
 
 
 
 
 
110
  return $images;
111
  }
112
 
209
 
210
  $too_big = ( ( ! empty( $meta['width'] ) && $meta['width'] > 1200 ) || ( ! empty( $meta['height'] ) && $meta['height'] > 1200 ) );
211
 
212
+ if (
213
+ $too_big &&
214
+ (
215
+ ( method_exists( 'Jetpack', 'is_module_active' ) && Jetpack::is_module_active( 'photon' ) ) ||
216
+ ( defined( 'WPCOM' ) && IS_WPCOM )
217
+ )
218
+ ) {
219
  $img_src = wp_get_attachment_image_src( $thumb, array( 1200, 1200 ) );
220
  } else {
221
  $img_src = wp_get_attachment_image_src( $thumb, 'full' );
class.jetpack-sync.php CHANGED
@@ -26,6 +26,7 @@ class Jetpack_Sync {
26
  add_action( 'jetpack_heartbeat', array( $this, 'sync_all_registered_options' ) );
27
 
28
  // Sync constants on heartbeat and plugin upgrade and connects
 
29
  add_action( 'jetpack_sync_all_registered_options', array( $this, 'sync_all_constants' ) );
30
  add_action( 'jetpack_heartbeat', array( $this, 'sync_all_constants' ) );
31
 
@@ -760,7 +761,7 @@ class Jetpack_Sync {
760
  $this->register( 'delete_option', $option );
761
  }
762
 
763
- function updated_option_action( $old_value ) {
764
  // The value of $option isn't passed to the filter
765
  // Calculate it
766
  $option = current_filter();
@@ -787,7 +788,7 @@ class Jetpack_Sync {
787
  }
788
  }
789
 
790
- function sync_all_registered_options( $options = array() ) {
791
  if ( 'jetpack_sync_all_registered_options' == current_filter() ) {
792
  add_action( 'shutdown', array( $this, 'register_all_options' ), 8 );
793
  } else {
@@ -808,12 +809,10 @@ class Jetpack_Sync {
808
 
809
  /* Constants Sync */
810
 
811
- function sync_all_constants() {
812
- // list of contants to sync needed by Jetpack
813
- $constants = array(
814
  'EMPTY_TRASH_DAYS',
815
  'WP_POST_REVISIONS',
816
- 'UPDATER_DISABLED',
817
  'AUTOMATIC_UPDATER_DISABLED',
818
  'ABSPATH',
819
  'WP_CONTENT_DIR',
@@ -821,18 +820,41 @@ class Jetpack_Sync {
821
  'DISALLOW_FILE_EDIT',
822
  'DISALLOW_FILE_MODS',
823
  'WP_AUTO_UPDATE_CORE',
824
- 'AUTOMATIC_UPDATER_DISABLED',
825
  'WP_HTTP_BLOCK_EXTERNAL',
826
  'WP_ACCESSIBLE_HOSTS',
827
  );
 
 
 
 
 
 
 
 
 
 
828
 
 
829
  // add the constant to sync.
830
- foreach( $constants as $contant ) {
831
- $this->register_constant( $contant );
832
  }
833
-
834
  add_action( 'shutdown', array( $this, 'register_all_module_constants' ), 8 );
 
835
 
 
 
 
 
 
 
 
 
 
 
 
 
 
836
  }
837
 
838
  function register_all_module_constants() {
@@ -1012,7 +1034,6 @@ EOT;
1012
  * @param string or array $callback
1013
  */
1014
  function mock_option( $option , $callback ) {
1015
-
1016
  add_filter( 'pre_option_jetpack_'. $option, $callback );
1017
  // This shouldn't happen but if it does we return the same as before.
1018
  add_filter( 'option_jetpack_'. $option, $callback );
@@ -1030,6 +1051,20 @@ EOT;
1030
  function register_constant( $constant ) {
1031
  $this->register( 'constant', $constant );
1032
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1033
  /**
1034
  * Simular to $this->options() function.
1035
  * Add the constant to be synced to .com when we activate the module.
26
  add_action( 'jetpack_heartbeat', array( $this, 'sync_all_registered_options' ) );
27
 
28
  // Sync constants on heartbeat and plugin upgrade and connects
29
+ add_action( 'init', array( $this, 'register_constants_as_options' ) );
30
  add_action( 'jetpack_sync_all_registered_options', array( $this, 'sync_all_constants' ) );
31
  add_action( 'jetpack_heartbeat', array( $this, 'sync_all_constants' ) );
32
 
761
  $this->register( 'delete_option', $option );
762
  }
763
 
764
+ function updated_option_action() {
765
  // The value of $option isn't passed to the filter
766
  // Calculate it
767
  $option = current_filter();
788
  }
789
  }
790
 
791
+ function sync_all_registered_options() {
792
  if ( 'jetpack_sync_all_registered_options' == current_filter() ) {
793
  add_action( 'shutdown', array( $this, 'register_all_options' ), 8 );
794
  } else {
809
 
810
  /* Constants Sync */
811
 
812
+ function get_all_constants() {
813
+ return array(
 
814
  'EMPTY_TRASH_DAYS',
815
  'WP_POST_REVISIONS',
 
816
  'AUTOMATIC_UPDATER_DISABLED',
817
  'ABSPATH',
818
  'WP_CONTENT_DIR',
820
  'DISALLOW_FILE_EDIT',
821
  'DISALLOW_FILE_MODS',
822
  'WP_AUTO_UPDATE_CORE',
 
823
  'WP_HTTP_BLOCK_EXTERNAL',
824
  'WP_ACCESSIBLE_HOSTS',
825
  );
826
+ }
827
+ /**
828
+ * This lets us get the constant value like get_option( 'jetpack_constant_CONSTANT' );
829
+ * Not the best way to get the constant value but necessery in some cases like in the API.
830
+ */
831
+ function register_constants_as_options() {
832
+ foreach( $this->get_all_constants() as $constant ) {
833
+ add_filter( 'pre_option_jetpack_constant_'. $constant, array( $this, 'get_default_constant' ) );
834
+ }
835
+ }
836
 
837
+ function sync_all_constants() {
838
  // add the constant to sync.
839
+ foreach( $this->get_all_constants() as $constant ) {
840
+ $this->register_constant( $constant );
841
  }
 
842
  add_action( 'shutdown', array( $this, 'register_all_module_constants' ), 8 );
843
+ }
844
 
845
+ /**
846
+ * Returns default values of Constants
847
+ */
848
+ function default_constant( $constant ) {
849
+ switch( $constant ) {
850
+ case 'WP_AUTO_UPDATE_CORE':
851
+ return 'minor';
852
+ break;
853
+
854
+ default:
855
+ return null;
856
+ break;
857
+ }
858
  }
859
 
860
  function register_all_module_constants() {
1034
  * @param string or array $callback
1035
  */
1036
  function mock_option( $option , $callback ) {
 
1037
  add_filter( 'pre_option_jetpack_'. $option, $callback );
1038
  // This shouldn't happen but if it does we return the same as before.
1039
  add_filter( 'option_jetpack_'. $option, $callback );
1051
  function register_constant( $constant ) {
1052
  $this->register( 'constant', $constant );
1053
  }
1054
+
1055
+ function get_default_constant() {
1056
+ $filter = current_filter();
1057
+ // We don't know what the constant is so we get it from the current filter.
1058
+ if ( 'pre_option_jetpack_constant_' === substr( $filter, 0, 28 ) ) {
1059
+ $constant = substr( $filter, 28 );
1060
+ if ( defined( $constant ) ) {
1061
+ // If constant is set to false we will not shortcut the get_option function and will return the default value.
1062
+ // Hance we set it to null. Which in most cases would produce the same result.
1063
+ return false === constant( $constant ) ? null : constant( $constant );
1064
+ }
1065
+ return $this->default_constant( $constant );
1066
+ }
1067
+ }
1068
  /**
1069
  * Simular to $this->options() function.
1070
  * Add the constant to be synced to .com when we activate the module.
class.jetpack-user-agent.php CHANGED
@@ -1193,45 +1193,47 @@ class Jetpack_User_Agent_Info {
1193
  if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
1194
  return false;
1195
 
1196
- if ( self::is_blackberry_10() )
1197
  return 'blackberry-10';
 
1198
 
1199
  $agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1200
 
1201
  $pos_blackberry = stripos( $agent, 'blackberry' );
1202
  if ( $pos_blackberry === false ) {
1203
- //not a blackberry device
1204
  return false;
1205
  }
1206
 
1207
- //blackberry devices OS 6.0 or higher
1208
- //Mozilla/5.0 (BlackBerry; U; BlackBerry 9670; en) AppleWebKit/534.3+ (KHTML, like Gecko) Version/6.0.0.286 Mobile Safari/534.3+
1209
- //Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en) AppleWebKit/534.1+ (KHTML, Like Gecko) Version/6.0.0.141 Mobile Safari/534.1+
1210
- //Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0 Mobile Safari/534.11+
1211
  $pos_webkit = stripos( $agent, 'webkit' );
1212
  if ( $pos_webkit !== false ) {
1213
- //detected blackberry webkit browser
1214
  $pos_torch = stripos( $agent, 'BlackBerry 9800' );
1215
  if ( $pos_torch !== false ) {
1216
- return 'blackberry-torch'; //match the torch first edition. the 2nd edition should use the OS7 and doesn't need any special rule
1217
  } else {
1218
- //detecting the BB OS version for devices running OS 6.0 or higher
1219
  if ( preg_match( '#Version\/([\d\.]+)#i', $agent, $matches ) ) {
1220
  $version = $matches[1];
1221
  $version_num = explode( '.', $version );
1222
- if( is_array( $version_num ) === false || count( $version_num ) <= 1 )
1223
- return 'blackberry-6'; //not a BB device that match our rule.
1224
- else
1225
- return 'blackberry-'.$version_num[0];
 
1226
  } else {
1227
- //if doesn't match returns the minimun version with a webkit browser. we should never fall here.
1228
- return 'blackberry-6'; //not a BB device that match our rule.
1229
  }
1230
  }
1231
  }
1232
 
1233
- //blackberry devices <= 5.XX
1234
- //BlackBerry9000/5.0.0.93 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/179
1235
  if ( preg_match( '#BlackBerry\w+\/([\d\.]+)#i', $agent, $matches ) ) {
1236
  $version = $matches[1];
1237
  } else {
@@ -1240,8 +1242,9 @@ class Jetpack_User_Agent_Info {
1240
 
1241
  $version_num = explode( '.', $version );
1242
 
1243
- if( is_array( $version_num ) === false || count( $version_num ) <= 1 )
1244
  return false;
 
1245
  if ( $version_num[0] == 5 ) {
1246
  return 'blackberry-5';
1247
  } elseif ( $version_num[0] == 4 && $version_num[1] == 7 ) {
@@ -1254,7 +1257,6 @@ class Jetpack_User_Agent_Info {
1254
  return false;
1255
  }
1256
 
1257
- return false;
1258
  }
1259
 
1260
  /**
@@ -1272,17 +1274,19 @@ class Jetpack_User_Agent_Info {
1272
  */
1273
  static function detect_blackberry_browser_version() {
1274
 
1275
- if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
1276
- return false;
 
1277
 
1278
  $agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1279
 
1280
- if ( self::is_blackberry_10() )
1281
  return 'blackberry-10';
 
1282
 
1283
  $pos_blackberry = strpos( $agent, 'blackberry' );
1284
  if ( $pos_blackberry === false ) {
1285
- //not a blackberry device
1286
  return false;
1287
  }
1288
 
@@ -1294,13 +1298,14 @@ class Jetpack_User_Agent_Info {
1294
  if ( preg_match( '#BlackBerry\w+\/([\d\.]+)#i', $agent, $matches ) ) {
1295
  $version = $matches[1];
1296
  } else {
1297
- return false; //not a BB device that match our rule.
1298
  }
1299
 
1300
  $version_num = explode( '.', $version );
1301
 
1302
- if( is_array( $version_num ) === false || count( $version_num ) <= 1 )
1303
- return false;
 
1304
 
1305
  if ( $version_num[0] == 5 ) {
1306
  return 'blackberry-5';
@@ -1309,14 +1314,14 @@ class Jetpack_User_Agent_Info {
1309
  } elseif ( $version_num[0] == 4 && $version_num[1] == 6 ) {
1310
  return 'blackberry-4.6';
1311
  } else {
1312
- //A very old BB device is found or this is a BB device that doesn't match our rules.
1313
  return false;
1314
  }
1315
  }
1316
- return false;
1317
  }
1318
 
1319
- //Checks if a visitor is coming from one of the WordPress mobile apps
1320
  static function is_mobile_app() {
1321
 
1322
  if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
1193
  if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
1194
  return false;
1195
 
1196
+ if ( self::is_blackberry_10() ) {
1197
  return 'blackberry-10';
1198
+ }
1199
 
1200
  $agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1201
 
1202
  $pos_blackberry = stripos( $agent, 'blackberry' );
1203
  if ( $pos_blackberry === false ) {
1204
+ // not a blackberry device
1205
  return false;
1206
  }
1207
 
1208
+ // blackberry devices OS 6.0 or higher
1209
+ // Mozilla/5.0 (BlackBerry; U; BlackBerry 9670; en) AppleWebKit/534.3+ (KHTML, like Gecko) Version/6.0.0.286 Mobile Safari/534.3+
1210
+ // Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en) AppleWebKit/534.1+ (KHTML, Like Gecko) Version/6.0.0.141 Mobile Safari/534.1+
1211
+ // Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0 Mobile Safari/534.11+
1212
  $pos_webkit = stripos( $agent, 'webkit' );
1213
  if ( $pos_webkit !== false ) {
1214
+ // detected blackberry webkit browser
1215
  $pos_torch = stripos( $agent, 'BlackBerry 9800' );
1216
  if ( $pos_torch !== false ) {
1217
+ return 'blackberry-torch'; // match the torch first edition. the 2nd edition should use the OS7 and doesn't need any special rule
1218
  } else {
1219
+ // detecting the BB OS version for devices running OS 6.0 or higher
1220
  if ( preg_match( '#Version\/([\d\.]+)#i', $agent, $matches ) ) {
1221
  $version = $matches[1];
1222
  $version_num = explode( '.', $version );
1223
+ if ( is_array( $version_num ) === false || count( $version_num ) <= 1 ) {
1224
+ return 'blackberry-6'; // not a BB device that match our rule.
1225
+ } else {
1226
+ return 'blackberry-' . $version_num[0];
1227
+ }
1228
  } else {
1229
+ // if doesn't match returns the minimun version with a webkit browser. we should never fall here.
1230
+ return 'blackberry-6'; // not a BB device that match our rule.
1231
  }
1232
  }
1233
  }
1234
 
1235
+ // blackberry devices <= 5.XX
1236
+ // BlackBerry9000/5.0.0.93 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/179
1237
  if ( preg_match( '#BlackBerry\w+\/([\d\.]+)#i', $agent, $matches ) ) {
1238
  $version = $matches[1];
1239
  } else {
1242
 
1243
  $version_num = explode( '.', $version );
1244
 
1245
+ if ( is_array( $version_num ) === false || count( $version_num ) <= 1 ) {
1246
  return false;
1247
+ }
1248
  if ( $version_num[0] == 5 ) {
1249
  return 'blackberry-5';
1250
  } elseif ( $version_num[0] == 4 && $version_num[1] == 7 ) {
1257
  return false;
1258
  }
1259
 
 
1260
  }
1261
 
1262
  /**
1274
  */
1275
  static function detect_blackberry_browser_version() {
1276
 
1277
+ if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
1278
+ return false;
1279
+ }
1280
 
1281
  $agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1282
 
1283
+ if ( self::is_blackberry_10() ) {
1284
  return 'blackberry-10';
1285
+ }
1286
 
1287
  $pos_blackberry = strpos( $agent, 'blackberry' );
1288
  if ( $pos_blackberry === false ) {
1289
+ // not a blackberry device
1290
  return false;
1291
  }
1292
 
1298
  if ( preg_match( '#BlackBerry\w+\/([\d\.]+)#i', $agent, $matches ) ) {
1299
  $version = $matches[1];
1300
  } else {
1301
+ return false; // not a BB device that match our rule.
1302
  }
1303
 
1304
  $version_num = explode( '.', $version );
1305
 
1306
+ if ( is_array( $version_num ) === false || count( $version_num ) <= 1 ) {
1307
+ return false;
1308
+ }
1309
 
1310
  if ( $version_num[0] == 5 ) {
1311
  return 'blackberry-5';
1314
  } elseif ( $version_num[0] == 4 && $version_num[1] == 6 ) {
1315
  return 'blackberry-4.6';
1316
  } else {
1317
+ // A very old BB device is found or this is a BB device that doesn't match our rules.
1318
  return false;
1319
  }
1320
  }
1321
+
1322
  }
1323
 
1324
+ // Checks if a visitor is coming from one of the WordPress mobile apps
1325
  static function is_mobile_app() {
1326
 
1327
  if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
class.jetpack-xmlrpc-server.php CHANGED
@@ -339,7 +339,6 @@ class Jetpack_XMLRPC_Server {
339
  $method = (string) $json_api_args[0];
340
  $url = (string) $json_api_args[1];
341
  $post_body = is_null( $json_api_args[2] ) ? null : (string) $json_api_args[2];
342
- $my_id = (int) $json_api_args[3];
343
  $user_details = (array) $json_api_args[4];
344
  $locale = (string) $json_api_args[5];
345
 
@@ -365,7 +364,6 @@ class Jetpack_XMLRPC_Server {
365
  error_log( "METHOD: $method" );
366
  error_log( "URL: $url" );
367
  error_log( "POST BODY: $post_body" );
368
- error_log( "MY JETPACK ID: $my_id" );
369
  error_log( "VERIFY_ARGS: " . print_r( $verify_api_user_args, 1 ) );
370
  error_log( "VERIFIED USER_ID: " . (int) $user_id );
371
  error_log( "-- end json api via jetpack debugging -- " );
339
  $method = (string) $json_api_args[0];
340
  $url = (string) $json_api_args[1];
341
  $post_body = is_null( $json_api_args[2] ) ? null : (string) $json_api_args[2];
 
342
  $user_details = (array) $json_api_args[4];
343
  $locale = (string) $json_api_args[5];
344
 
364
  error_log( "METHOD: $method" );
365
  error_log( "URL: $url" );
366
  error_log( "POST BODY: $post_body" );
 
367
  error_log( "VERIFY_ARGS: " . print_r( $verify_api_user_args, 1 ) );
368
  error_log( "VERIFIED USER_ID: " . (int) $user_id );
369
  error_log( "-- end json api via jetpack debugging -- " );
class.jetpack.php CHANGED
@@ -217,6 +217,7 @@ class Jetpack {
217
  'wp-facebook-open-graph-protocol/wp-facebook-ogp.php', // WP Facebook Open Graph protocol
218
  'wp-ogp/wp-ogp.php', // WP-OGP
219
  'zoltonorg-social-plugin/zosp.php', // Zolton.org Social Plugin
 
220
  );
221
 
222
  /**
@@ -389,6 +390,7 @@ class Jetpack {
389
  */
390
  do_action( 'jetpack_sync_all_registered_options' );
391
  }
 
392
  //if Jetpack is connected check if jetpack_unique_connection exists and if not then set it
393
  $jetpack_unique_connection = get_option( 'jetpack_unique_connection' );
394
  $is_unique_connection = $jetpack_unique_connection && array_key_exists( 'version', $jetpack_unique_connection );
@@ -432,7 +434,7 @@ class Jetpack {
432
  * Do things that should run even in the network admin
433
  * here, before we potentially fail out.
434
  */
435
- add_filter( 'jetpack_require_lib_dir', array( $this, 'require_lib_dir' ) );
436
 
437
  /**
438
  * We need sync object even in Multisite mode
@@ -446,6 +448,7 @@ class Jetpack {
446
  $this->sync->mock_option( 'wp_version', array( 'Jetpack', 'get_wp_version' ) );
447
 
448
  add_action( 'init', array( $this, 'sync_update_data') );
 
449
 
450
  /*
451
  * Load things that should only be in Network Admin.
@@ -491,7 +494,17 @@ class Jetpack {
491
  "theme_mods_{$theme_slug}",
492
  'jetpack_sync_non_public_post_stati',
493
  'jetpack_options',
494
- 'site_icon' // (int) - ID of core's Site Icon attachment ID
 
 
 
 
 
 
 
 
 
 
495
  );
496
 
497
  foreach( Jetpack_Options::get_option_names( 'non-compact' ) as $option ) {
@@ -506,9 +519,12 @@ class Jetpack {
506
  $this->sync->mock_option( 'is_multi_site', array( $this, 'is_multisite' ) );
507
  $this->sync->mock_option( 'main_network_site', array( $this, 'jetpack_main_network_site_option' ) );
508
  $this->sync->mock_option( 'single_user_site', array( 'Jetpack', 'is_single_user_site' ) );
 
509
 
510
  $this->sync->mock_option( 'has_file_system_write_access', array( 'Jetpack', 'file_system_write_access' ) );
511
  $this->sync->mock_option( 'is_version_controlled', array( 'Jetpack', 'is_version_controlled' ) );
 
 
512
 
513
  /**
514
  * Trigger an update to the main_network_site when we update the blogname of a site.
@@ -825,7 +841,7 @@ class Jetpack {
825
  Jetpack::state( 'message', 'no_message' );
826
 
827
  //A Jetpack module is being activated through a JITM, track it
828
- $this->stat( 'jitm', $module_slug.'-activated' );
829
  $this->do_stats( 'server_side' );
830
 
831
  wp_send_json_success();
@@ -846,7 +862,16 @@ class Jetpack {
846
  Jetpack_Options::update_option( 'hide_jitm', $jetpack_hide_jitm );
847
 
848
  //jitm is being dismissed forever, track it
849