Jetpack by WordPress.com - Version 5.1.1

Version Description

Download this release

Release Info

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

Code changes from version 7.9 to 5.1.1

3rd-party/3rd-party.php CHANGED
@@ -1,31 +1,16 @@
1
  <?php
2
- /**
3
- * Compatibility files for third-party plugins.
4
- * This is used to improve compatibility of specific Jetpack features with third-party plugins.
5
- *
6
- * @package Jetpack
7
  */
8
 
9
- // Array of third-party compat files to always require.
10
- $compat_files = array(
11
- 'bbpress.php',
12
- 'beaverbuilder.php',
13
- 'bitly.php',
14
- 'buddypress.php',
15
- 'class.jetpack-amp-support.php',
16
- 'class.jetpack-modules-overrides.php', // Special case. Tools to be used to override module settings.
17
- 'debug-bar.php',
18
- 'domain-mapping.php',
19
- 'polldaddy.php',
20
- 'qtranslate-x.php',
21
- 'vaultpress.php',
22
- 'wpml.php',
23
- 'woocommerce.php',
24
- 'woocommerce-services.php',
25
- );
26
 
27
- foreach ( $compat_files as $file ) {
28
- if ( file_exists( JETPACK__PLUGIN_DIR . '/3rd-party/' . $file ) ) {
29
- require_once JETPACK__PLUGIN_DIR . '/3rd-party/' . $file;
30
- }
31
- }
1
  <?php
2
+
3
+ /*
4
+ * Placeholder to load 3rd party plugin tweaks until a legit system
5
+ * is architected
 
6
  */
7
 
8
+ require_once( JETPACK__PLUGIN_DIR . '3rd-party/buddypress.php' );
9
+ require_once( JETPACK__PLUGIN_DIR . '3rd-party/wpml.php' );
10
+ require_once( JETPACK__PLUGIN_DIR . '3rd-party/bitly.php' );
11
+ require_once( JETPACK__PLUGIN_DIR . '3rd-party/bbpress.php' );
12
+ require_once( JETPACK__PLUGIN_DIR . '3rd-party/woocommerce.php' );
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
+ // We can't load this conditionally since polldaddy add the call in class constuctor.
15
+ require_once( JETPACK__PLUGIN_DIR . '3rd-party/polldaddy.php' );
16
+ require_once( JETPACK__PLUGIN_DIR . '3rd-party/woocommerce-services.php' );
 
 
3rd-party/bbpress.php CHANGED
@@ -14,18 +14,6 @@ function jetpack_bbpress_compat() {
14
  add_action( 'bbp_template_after_single_topic', 'jetpack_sharing_bbpress' );
15
  }
16
 
17
- /**
18
- * Enable Markdown support for bbpress post types.
19
- *
20
- * @author Brandon Kraft
21
- * @since 6.0.0
22
- */
23
- if ( function_exists( 'bbp_get_topic_post_type' ) ) {
24
- add_post_type_support( bbp_get_topic_post_type(), 'wpcom-markdown' );
25
- add_post_type_support( bbp_get_reply_post_type(), 'wpcom-markdown' );
26
- add_post_type_support( bbp_get_forum_post_type(), 'wpcom-markdown' );
27
- }
28
-
29
  /**
30
  * Use Photon for all images in Topics and replies.
31
  *
14
  add_action( 'bbp_template_after_single_topic', 'jetpack_sharing_bbpress' );
15
  }
16
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  /**
18
  * Use Photon for all images in Topics and replies.
19
  *
3rd-party/beaverbuilder.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- /**
3
- * Beaverbuilder Compatibility.
4
- */
5
- class Jetpack_BeaverBuilderCompat {
6
-
7
- function __construct() {
8
- add_action( 'init', array( $this, 'beaverbuilder_refresh' ) );
9
- }
10
-
11
- /**
12
- * If masterbar module is active force BeaverBuilder to refresh when publishing a layout.
13
- */
14
- function beaverbuilder_refresh() {
15
- if ( Jetpack::is_module_active( 'masterbar' ) ) {
16
- add_filter( 'fl_builder_should_refresh_on_publish', '__return_true' );
17
- }
18
- }
19
- }
20
- new Jetpack_BeaverBuilderCompat();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3rd-party/class.jetpack-amp-support.php DELETED
@@ -1,443 +0,0 @@
1
- <?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2
-
3
- use Automattic\Jetpack\Sync\Functions;
4
-
5
- /**
6
- * Manages compatibility with the amp-wp plugin
7
- *
8
- * @see https://github.com/Automattic/amp-wp
9
- */
10
- class Jetpack_AMP_Support {
11
-
12
- /**
13
- * Apply custom AMP changes onthe frontend.
14
- */
15
- public static function init() {
16
-
17
- // Add Stats tracking pixel on Jetpack sites when the Stats module is active.
18
- if (
19
- Jetpack::is_module_active( 'stats' )
20
- && ! ( defined( 'IS_WPCOM' ) && IS_WPCOM )
21
- ) {
22
- add_action( 'amp_post_template_footer', array( 'Jetpack_AMP_Support', 'add_stats_pixel' ) );
23
- }
24
-
25
- // Sharing.
26
- add_filter( 'jetpack_sharing_display_markup', array( 'Jetpack_AMP_Support', 'render_sharing_html' ), 10, 2 );
27
- add_filter( 'sharing_enqueue_scripts', array( 'Jetpack_AMP_Support', 'amp_disable_sharedaddy_css' ) );
28
-
29
- // enforce freedom mode for videopress.
30
- add_filter( 'videopress_shortcode_options', array( 'Jetpack_AMP_Support', 'videopress_enable_freedom_mode' ) );
31
-
32
- // include Jetpack og tags when rendering native AMP head.
33
- add_action( 'amp_post_template_head', array( 'Jetpack_AMP_Support', 'amp_post_jetpack_og_tags' ) );
34
-
35
- // Post rendering changes for legacy AMP.
36
- add_action( 'pre_amp_render_post', array( 'Jetpack_AMP_Support', 'amp_disable_the_content_filters' ) );
37
-
38
- // Add post template metadata for legacy AMP.
39
- add_filter( 'amp_post_template_metadata', array( 'Jetpack_AMP_Support', 'amp_post_template_metadata' ), 10, 2 );
40
-
41
- // Filter photon image args for AMP Stories.
42
- add_filter( 'jetpack_photon_post_image_args', array( 'Jetpack_AMP_Support', 'filter_photon_post_image_args_for_stories' ), 10, 2 );
43
- }
44
-
45
- /**
46
- * Apply custom AMP changes in wp-admin.
47
- */
48
- public static function admin_init() {
49
- // disable Likes metabox for post editor if AMP canonical disabled.
50
- add_filter( 'post_flair_disable', array( 'Jetpack_AMP_Support', 'is_amp_canonical' ), 99 );
51
- }
52
-
53
- /**
54
- * Is the page in AMP 'canonical mode'.
55
- * Used when themes register support for AMP with `add_theme_support( 'amp' )`.
56
- *
57
- * @return bool is_amp_canonical
58
- */
59
- public static function is_amp_canonical() {
60
- return function_exists( 'amp_is_canonical' ) && amp_is_canonical();
61
- }
62
-
63
- /**
64
- * Does the page return AMP content.
65
- *
66
- * @return bool $is_amp_request Are we on am AMP view.
67
- */
68
- public static function is_amp_request() {
69
- $is_amp_request = ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() );
70
-
71
- /**
72
- * Returns true if the current request should return valid AMP content.
73
- *
74
- * @since 6.2.0
75
- *
76
- * @param boolean $is_amp_request Is this request supposed to return valid AMP content?
77
- */
78
- return apply_filters( 'jetpack_is_amp_request', $is_amp_request );
79
- }
80
-
81
- /**
82
- * Remove content filters added by Jetpack.
83
- */
84
- public static function amp_disable_the_content_filters() {
85
- if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
86
- add_filter( 'videopress_show_2015_player', '__return_true' );
87
- add_filter( 'protected_embeds_use_form_post', '__return_false' );
88
- remove_filter( 'the_title', 'widont' );
89
- }
90
-
91
- remove_filter( 'pre_kses', array( 'Filter_Embedded_HTML_Objects', 'filter' ), 11 );
92
- remove_filter( 'pre_kses', array( 'Filter_Embedded_HTML_Objects', 'maybe_create_links' ), 100 );
93
- }
94
-
95
- /**
96
- * Add Jetpack stats pixel.
97
- *
98
- * @since 6.2.1
99
- */
100
- public static function add_stats_pixel() {
101
- if ( ! has_action( 'wp_footer', 'stats_footer' ) ) {
102
- return;
103
- }
104
- stats_render_amp_footer( stats_build_view_data() );
105
- }
106
-
107
- /**
108
- * Add publisher and image metadata to legacy AMP post.
109
- *
110
- * @since 6.2.0
111
- *
112
- * @param array $metadata Metadata array.
113
- * @param WP_Post $post Post.
114
- * @return array Modified metadata array.
115
- */
116
- public static function amp_post_template_metadata( $metadata, $post ) {
117
- if ( isset( $metadata['publisher'] ) && ! isset( $metadata['publisher']['logo'] ) ) {
118
- $metadata = self::add_site_icon_to_metadata( $metadata );
119
- }
120
-
121
- if ( ! isset( $metadata['image'] ) ) {
122
- $metadata = self::add_image_to_metadata( $metadata, $post );
123
- }
124
-
125
- return $metadata;
126
- }
127
-
128
- /**
129
- * Add blavatar to legacy AMP post metadata.
130
- *
131
- * @since 6.2.0
132
- *
133
- * @param array $metadata Metadata.
134
- *
135
- * @return array Metadata.
136
- */
137
- private static function add_site_icon_to_metadata( $metadata ) {
138
- $size = 60;
139
- $site_icon_url = class_exists( 'Automattic\\Jetpack\\Sync\\Functions' ) ? Functions::site_icon_url( $size ) : '';
140
-
141
- if ( function_exists( 'blavatar_domain' ) ) {
142
- $metadata['publisher']['logo'] = array(
143
- '@type' => 'ImageObject',
144
- 'url' => blavatar_url( blavatar_domain( site_url() ), 'img', $size, self::staticize_subdomain( 'https://wordpress.com/i/favicons/apple-touch-icon-60x60.png' ) ),
145
- 'width' => $size,
146
- 'height' => $size,
147
- );
148
- } elseif ( $site_icon_url ) {
149
- $metadata['publisher']['logo'] = array(
150
- '@type' => 'ImageObject',
151
- 'url' => $site_icon_url,
152
- 'width' => $size,
153
- 'height' => $size,
154
- );
155
- }
156
-
157
- return $metadata;
158
- }
159
-
160
- /**
161
- * Add image to legacy AMP post metadata.
162
- *
163
- * @since 6.2.0
164
- *
165
- * @param array $metadata Metadata.
166
- * @param WP_Post $post Post.
167
- * @return array Metadata.
168
- */
169
- private static function add_image_to_metadata( $metadata, $post ) {
170
- $image = Jetpack_PostImages::get_image(
171
- $post->ID,
172
- array(
173
- 'fallback_to_avatars' => true,
174
- 'avatar_size' => 200,
175
- // AMP already attempts these.
176
- 'from_thumbnail' => false,
177
- 'from_attachment' => false,
178
- )
179
- );
180
-
181
- if ( empty( $image ) ) {
182
- return self::add_fallback_image_to_metadata( $metadata );
183
- }
184
-
185
- if ( ! isset( $image['src_width'] ) ) {
186
- $dimensions = self::extract_image_dimensions_from_getimagesize(
187
- array(
188
- $image['src'] => false,
189
- )
190
- );
191
-
192
- if ( false !== $dimensions[ $image['src'] ] ) {
193
- $image['src_width'] = $dimensions['width'];
194
- $image['src_height'] = $dimensions['height'];
195
- }
196
- }
197
-
198
- $metadata['image'] = array(
199
- '@type' => 'ImageObject',
200
- 'url' => $image['src'],
201
- );
202
- if ( isset( $image['src_width'] ) ) {
203
- $metadata['image']['width'] = $image['src_width'];
204
- }
205
- if ( isset( $image['src_width'] ) ) {
206
- $metadata['image']['height'] = $image['src_height'];
207
- }
208
-
209
- return $metadata;
210
- }
211
-
212
- /**
213
- * Add fallback image to legacy AMP post metadata.
214
- *
215
- * @since 6.2.0
216
- *
217
- * @param array $metadata Metadata.
218
- * @return array Metadata.
219
- */
220
- private static function add_fallback_image_to_metadata( $metadata ) {
221
- /** This filter is documented in functions.opengraph.php */
222
- $default_image = apply_filters( 'jetpack_open_graph_image_default', 'https://wordpress.com/i/blank.jpg' );
223
-
224
- $metadata['image'] = array(
225
- '@type' => 'ImageObject',
226
- 'url' => self::staticize_subdomain( $default_image ),
227
- 'width' => 200,
228
- 'height' => 200,
229
- );
230
-
231
- return $metadata;
232
- }
233
-
234
- /**
235
- * Return static WordPress.com domain to use to load resources from WordPress.com.
236
- *
237
- * @param string $domain Asset URL.
238
- */
239
- private static function staticize_subdomain( $domain ) {
240
- // deal with WPCOM vs Jetpack.
241
- if ( function_exists( 'staticize_subdomain' ) ) {
242
- return staticize_subdomain( $domain );
243
- } else {
244
- return Jetpack::staticize_subdomain( $domain );
245
- }
246
- }
247
-
248
- /**
249
- * Extract image dimensions via wpcom/imagesize, only on WPCOM
250
- *
251
- * @since 6.2.0
252
- *
253
- * @param array $dimensions Dimensions.
254
- * @return array Dimensions.
255
- */
256
- private static function extract_image_dimensions_from_getimagesize( $dimensions ) {
257
- if ( ! ( defined( 'IS_WPCOM' ) && IS_WPCOM && function_exists( 'require_lib' ) ) ) {
258
- return $dimensions;
259
- }
260
- require_lib( 'wpcom/imagesize' );
261
-
262
- foreach ( $dimensions as $url => $value ) {
263
- if ( is_array( $value ) ) {
264
- continue;
265
- }
266
- $result = wpcom_getimagesize( $url );
267
- if ( is_array( $result ) ) {
268
- $dimensions[ $url ] = array(
269
- 'width' => $result[0],
270
- 'height' => $result[1],
271
- );
272
- }
273
- }
274
-
275
- return $dimensions;
276
- }
277
-
278
- /**
279
- * Display Open Graph Meta tags in AMP views.
280
- */
281
- public static function amp_post_jetpack_og_tags() {
282
- if ( ! ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ) {
283
- Jetpack::init()->check_open_graph();
284
- }
285
-
286
- if ( function_exists( 'jetpack_og_tags' ) ) {
287
- jetpack_og_tags();
288
- }
289
- }
290
-
291
- /**
292
- * Force Freedom mode in VideoPress.
293
- *
294
- * @param array $options Array of VideoPress shortcode options.
295
- */
296
- public static function videopress_enable_freedom_mode( $options ) {
297
- if ( self::is_amp_request() ) {
298
- $options['freedom'] = true;
299
- }
300
- return $options;
301
- }
302
-
303
- /**
304
- * Display custom markup for the sharing buttons when in an AMP view.
305
- *
306
- * @param string $markup Content markup of the Jetpack sharing links.
307
- * @param array $sharing_enabled Array of Sharing Services currently enabled.
308
- */
309
- public static function render_sharing_html( $markup, $sharing_enabled ) {
310
- if ( ! self::is_amp_request() ) {
311
- return $markup;
312
- }
313
-
314
- remove_action( 'wp_footer', 'sharing_add_footer' );
315
- if ( empty( $sharing_enabled ) ) {
316
- return $markup;
317
- }
318
- $supported_services = array(
319
- 'facebook' => array(
320
- /** This filter is documented in modules/sharedaddy/sharing-sources.php */
321
- 'data-param-app_id' => apply_filters( 'jetpack_sharing_facebook_app_id', '249643311490' ),
322
- ),
323
- 'twitter' => array(),
324
- 'pinterest' => array(),
325
- 'whatsapp' => array(),
326
- 'tumblr' => array(),
327
- 'linkedin' => array(),
328
- );
329
- $sharing_links = array();
330
- foreach ( $sharing_enabled['visible'] as $id => $service ) {
331
- if ( ! isset( $supported_services[ $id ] ) ) {
332
- $sharing_links[] = "<!-- not supported: $id -->";
333
- continue;
334
- }
335
- $args = array_merge(
336
- array(
337
- 'type' => $id,
338
- ),
339
- $supported_services[ $id ]
340
- );
341
- $sharing_link = '<amp-social-share';
342
- foreach ( $args as $key => $value ) {
343
- $sharing_link .= sprintf( ' %s="%s"', sanitize_key( $key ), esc_attr( $value ) );
344
- }
345
- $sharing_link .= '></amp-social-share>';
346
- $sharing_links[] = $sharing_link;
347
- }
348
-
349
- // Wrap AMP sharing buttons in container.
350
- $markup = preg_replace( '#(?<=<div class="sd-content">).+?(?=</div>)#s', implode( '', $sharing_links ), $markup );
351
-
352
- // Remove any lingering share-end list items.
353
- $markup = str_replace( '<li class="share-end"></li>', '', $markup );
354
-
355
- return $markup;
356
- }
357
-
358
- /**
359
- * Tells Jetpack not to enqueue CSS for share buttons.
360
- *
361
- * @param bool $enqueue Whether or not to enqueue.
362
- * @return bool Whether or not to enqueue.
363
- */
364
- public static function amp_disable_sharedaddy_css( $enqueue ) {
365
- if ( self::is_amp_request() ) {
366
- $enqueue = false;
367
- }
368
-
369
- return $enqueue;
370
- }
371
-
372
- /**
373
- * Ensure proper Photon image dimensions for AMP Stories.
374
- *
375
- * @param array $args Array of Photon Arguments.
376
- * @param array $details {
377
- * Array of image details.
378
- *
379
- * @type string $tag Image tag (Image HTML output).
380
- * @type string $src Image URL.
381
- * @type string $src_orig Original Image URL.
382
- * @type int|false $width Image width.
383
- * @type int|false $height Image height.
384
- * @type int|false $width_orig Original image width before constrained by content_width.
385
- * @type int|false $height_orig Original Image height before constrained by content_width.
386
- * @type string $transform_orig Original transform before constrained by content_width.
387
- * }
388
- * @return array Args.
389
- */
390
- public static function filter_photon_post_image_args_for_stories( $args, $details ) {
391
- if ( ! is_singular( 'amp_story' ) ) {
392
- return $args;
393
- }
394
-
395
- // Percentage-based dimensions are not allowed in AMP, so this shouldn't happen, but short-circuit just in case.
396
- if ( false !== strpos( $details['width_orig'], '%' ) || false !== strpos( $details['height_orig'], '%' ) ) {
397
- return $args;
398
- }
399
-
400
- $max_height = 1280; // See image size with the slug \AMP_Story_Post_Type::MAX_IMAGE_SIZE_SLUG.
401
- $transform = $details['transform_orig'];
402
- $width = $details['width_orig'];
403
- $height = $details['height_orig'];
404
-
405
- // If height is available, constrain to $max_height.
406
- if ( false !== $height ) {
407
- if ( $height > $max_height && false !== $height ) {
408
- $width = ( $max_height * $width ) / $height;
409
- $height = $max_height;
410
- } elseif ( $height > $max_height ) {
411
- $height = $max_height;
412
- }
413
- }
414
-
415
- /*
416
- * Set a height if none is found.
417
- * If height is set in this manner and height is available, use `fit` instead of `resize` to prevent skewing.
418
- */
419
- if ( false === $height ) {
420
- $height = $max_height;
421
- if ( false !== $width ) {
422
- $transform = 'fit';
423
- }
424
- }
425
-
426
- // Build array of Photon args and expose to filter before passing to Photon URL function.
427
- $args = array();
428
-
429
- if ( false !== $width && false !== $height ) {
430
- $args[ $transform ] = $width . ',' . $height;
431
- } elseif ( false !== $width ) {
432
- $args['w'] = $width;
433
- } elseif ( false !== $height ) {
434
- $args['h'] = $height;
435
- }
436
-
437
- return $args;
438
- }
439
- }
440
-
441
- add_action( 'init', array( 'Jetpack_AMP_Support', 'init' ), 1 );
442
-
443
- add_action( 'admin_init', array( 'Jetpack_AMP_Support', 'admin_init' ), 1 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3rd-party/class.jetpack-modules-overrides.php DELETED
@@ -1,143 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Provides methods for dealing with module overrides.
5
- *
6
- * @since 5.9.0
7
- */
8
- class Jetpack_Modules_Overrides {
9
- /**
10
- * Used to cache module overrides so that we minimize how many times we appy the
11
- * option_jetpack_active_modules filter.
12
- *
13
- * @var null|array
14
- */
15
- private $overrides = null;
16
-
17
- /**
18
- * Clears the $overrides member used for caching.
19
- *
20
- * Since get_overrides() can be passed a falsey value to skip caching, this is probably
21
- * most useful for clearing cache between tests.
22
- *
23
- * @return void
24
- */
25
- public function clear_cache() {
26
- $this->overrides = null;
27
- }
28
-
29
- /**
30
- * Returns true if there is a filter on the jetpack_active_modules option.
31
- *
32
- * @return bool Whether there is a filter on the jetpack_active_modules option.
33
- */
34
- public function do_overrides_exist() {
35
- return (bool) ( has_filter( 'option_jetpack_active_modules' ) || has_filter( 'jetpack_active_modules' ) );
36
- }
37
-
38
- /**
39
- * Gets the override for a given module.
40
- *
41
- * @param string $module_slug The module's slug.
42
- * @param boolean $use_cache Whether or not cached overrides should be used.
43
- *
44
- * @return bool|string False if no override for module. 'active' or 'inactive' if there is an override.
45
- */
46
- public function get_module_override( $module_slug, $use_cache = true ) {
47
- $overrides = $this->get_overrides( $use_cache );
48
-
49
- if ( ! isset( $overrides[ $module_slug ] ) ) {
50
- return false;
51
- }
52
-
53
- return $overrides[ $module_slug ];
54
- }
55
-
56
- /**
57
- * Returns an array of module overrides where the key is the module slug and the value
58
- * is true if the module is forced on and false if the module is forced off.
59
- *
60
- * @param bool $use_cache Whether or not cached overrides should be used.
61
- *
62
- * @return array The array of module overrides.
63
- */
64
- public function get_overrides( $use_cache = true ) {
65
- if ( $use_cache && ! is_null( $this->overrides ) ) {
66
- return $this->overrides;
67
- }
68
-
69
- if ( ! $this->do_overrides_exist() ) {
70
- return array();
71
- }
72
-
73
- $available_modules = Jetpack::get_available_modules();
74
-
75
- /**
76
- * First, let's get all modules that have been forced on.
77
- */
78
-
79
- /** This filter is documented in wp-includes/option.php */
80
- $filtered = apply_filters( 'option_jetpack_active_modules', array() );
81
-
82
- /** This filter is documented in class.jetpack.php */
83
- $filtered = apply_filters( 'jetpack_active_modules', $filtered );
84
-
85
- $forced_on = array_diff( $filtered, array() );
86
-
87
- /**
88
- * Second, let's get all modules forced off.
89
- */
90
-
91
- /** This filter is documented in wp-includes/option.php */
92
- $filtered = apply_filters( 'option_jetpack_active_modules', $available_modules );
93
-
94
- /** This filter is documented in class.jetpack.php */
95
- $filtered = apply_filters( 'jetpack_active_modules', $filtered );
96
-
97
- $forced_off = array_diff( $available_modules, $filtered );
98
-
99
- /**
100
- * Last, build the return value.
101
- */
102
- $return_value = array();
103
- foreach ( $forced_on as $on ) {
104
- $return_value[ $on ] = 'active';
105
- }
106
-
107
- foreach ( $forced_off as $off ) {
108
- $return_value[ $off ] = 'inactive';
109
- }
110
-
111
- $this->overrides = $return_value;
112
-
113
- return $return_value;
114
- }
115
-
116
- /**
117
- * A reference to an instance of this class.
118
- *
119
- * @var Jetpack_Modules_Overrides
120
- */
121
- private static $instance = null;
122
-
123
- /**
124
- * Returns the singleton instance of Jetpack_Modules_Overrides
125
- *
126
- * @return Jetpack_Modules_Overrides
127
- */
128
- public static function instance() {
129
- if ( is_null( self::$instance ) ) {
130
- self::$instance = new Jetpack_Modules_Overrides();
131
- }
132
-
133
- return self::$instance;
134
- }
135
-
136
- /**
137
- * Private construct to enforce singleton.
138
- */
139
- private function __construct() {
140
- }
141
- }
142
-
143
- Jetpack_Modules_Overrides::instance();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3rd-party/debug-bar.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Checks if the search module is active, and if so, will initialize the singleton instance
5
- * of Jetpack_Search_Debug_Bar and add it to the array of debug bar panels.
6
- *
7
- * @param array $panels The array of debug bar panels.
8
- * @return array $panel The array of debug bar panels with our added panel.
9
- */
10
- function init_jetpack_search_debug_bar( $panels ) {
11
- if ( ! Jetpack::is_module_active( 'search' ) ) {
12
- return $panels;
13
- }
14
-
15
- require_once dirname( __FILE__ ) . '/debug-bar/class.jetpack-search-debug-bar.php';
16
- $panels[] = Jetpack_Search_Debug_Bar::instance();
17
- return $panels;
18
- }
19
- add_filter( 'debug_bar_panels', 'init_jetpack_search_debug_bar' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3rd-party/debug-bar/class.jetpack-search-debug-bar.php DELETED
@@ -1,173 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Singleton class instantiated by Jetpack_Searc_Debug_Bar::instance() that handles
5
- * rendering the Jetpack Search debug bar menu item and panel.
6
- */
7
- class Jetpack_Search_Debug_Bar extends Debug_Bar_Panel {
8
- /**
9
- * Holds singleton instance
10
- *
11
- * @var Jetpack_Search_Debug_Bar
12
- */
13
- protected static $instance = null;
14
-
15
- /**
16
- * The title to use in the debug bar navigation
17
- *
18
- * @var string
19
- */
20
- public $title;
21
-
22
- /**
23
- * Constructor
24
- */
25
- public function __construct() {
26
- $this->title( esc_html__( 'Jetpack Search', 'jetpack' ) );
27
- add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
28
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
29
- add_action( 'login_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
30
- add_action( 'enqueue_embed_scripts', array( $this, 'enqueue_scripts' ) );
31
- }
32
-
33
- /**
34
- * Returns the singleton instance of Jetpack_Search_Debug_Bar
35
- *
36
- * @return Jetpack_Search_Debug_Bar
37
- */
38
- public static function instance() {
39
- if ( is_null( self::$instance ) ) {
40
- self::$instance = new Jetpack_Search_Debug_Bar();
41
- }
42
- return self::$instance;
43
- }
44
-
45
- /**
46
- * Enqueues styles for our panel in the debug bar
47
- *
48
- * @return void
49
- */
50
- public function enqueue_scripts() {
51
- // Do not enqueue scripts if we haven't already enqueued Debug Bar or Query Monitor styles.
52
- if ( ! wp_style_is( 'debug-bar' ) && ! wp_style_is( 'query-monitor' ) ) {
53
- return;
54
- }
55
-
56
- wp_enqueue_style(
57
- 'jetpack-search-debug-bar',
58
- plugins_url( '3rd-party/debug-bar/debug-bar.css', JETPACK__PLUGIN_FILE )
59
- );
60
- wp_enqueue_script(
61
- 'jetpack-search-debug-bar',
62
- plugins_url( '3rd-party/debug-bar/debug-bar.js', JETPACK__PLUGIN_FILE ),
63
- array( 'jquery' )
64
- );
65
- }
66
-
67
- /**
68
- * Should the Jetpack Search Debug Bar show?
69
- *
70
- * Since we've previously done a check for the search module being activated, let's just return true.
71
- * Later on, we can update this to only show when `is_search()` is true.
72
- *
73
- * @return boolean
74
- */
75
- public function is_visible() {
76
- return true;
77
- }
78
-
79
- /**
80
- * Renders the panel content
81
- *
82
- * @return void
83
- */
84
- public function render() {
85
- if ( ! class_exists( 'Jetpack_Search' ) ) {
86
- return;
87
- }
88
-
89
- $jetpack_search = Jetpack_Search::instance();
90
- $last_query_info = $jetpack_search->get_last_query_info();
91
-
92
- // If not empty, let's reshuffle the order of some things.
93
- if ( ! empty( $last_query_info ) ) {
94
- $args = $last_query_info['args'];
95
- $response = $last_query_info['response'];
96
- $response_code = $last_query_info['response_code'];
97
-
98
- unset( $last_query_info['args'] );
99
- unset( $last_query_info['response'] );
100
- unset( $last_query_info['response_code'] );
101
-
102
- if ( is_null( $last_query_info['es_time'] ) ) {
103
- $last_query_info['es_time'] = esc_html_x(
104
- 'cache hit',
105
- 'displayed in search results when results are cached',
106
- 'jetpack'
107
- );
108
- }
109
-
110
- $temp = array_merge(
111
- array( 'response_code' => $response_code ),
112
- array( 'args' => $args ),
113
- $last_query_info,
114
- array( 'response' => $response )
115
- );
116
-
117
- $last_query_info = $temp;
118
- }
119
- ?>
120
- <div class="jetpack-search-debug-bar">
121
- <h2><?php esc_html_e( 'Last query information:', 'jetpack' ); ?></h2>
122
- <?php if ( empty( $last_query_info ) ) : ?>
123
- <?php echo esc_html_x( 'None', 'Text displayed when there is no information', 'jetpack' ); ?>
124
- <?php
125
- else :
126
- foreach ( $last_query_info as $key => $info ) :
127
- ?>
128
- <h3><?php echo esc_html( $key ); ?></h3>
129
- <?php
130
- if ( 'response' !== $key && 'args' !== $key ) :
131
- ?>
132
- <pre><?php print_r( esc_html( $info ) ); ?></pre>
133
- <?php
134
- else :
135
- $this->render_json_toggle( $info );
136
- endif;
137
- ?>
138
- <?php
139
- endforeach;
140
- endif;
141
- ?>
142
- </div><!-- Closes .jetpack-search-debug-bar -->
143
- <?php
144
- }
145
-
146
- /**
147
- * Responsible for rendering the HTML necessary for the JSON toggle
148
- *
149
- * @param array $value The resonse from the API as an array.
150
- * @return void
151
- */
152
- public function render_json_toggle( $value ) {
153
- ?>
154
- <div class="json-toggle-wrap">
155
- <pre class="json"><?php
156
- // esc_html() will not double-encode entities (&amp; -> &amp;amp;).
157
- // If any entities are part of the JSON blob, we want to re-encoode them
158
- // (double-encode them) so that they are displayed correctly in the debug
159
- // bar.
160
- // Use _wp_specialchars() "manually" to ensure entities are encoded correctly.
161
- echo _wp_specialchars(
162
- wp_json_encode( $value ),
163
- ENT_NOQUOTES, // Don't need to encode quotes (output is for a text node).
164
- 'UTF-8', // wp_json_encode() outputs UTF-8 (really just ASCII), not the blog's charset.
165
- true // Do "double-encode" existing HTML entities
166
- );
167
- ?></pre>
168
- <span class="pretty toggle"><?php echo esc_html_x( 'Pretty', 'label for formatting JSON', 'jetpack' ); ?></span>
169
- <span class="ugly toggle"><?php echo esc_html_x( 'Minify', 'label for formatting JSON', 'jetpack' ); ?></span>
170
- </div>
171
- <?php
172
- }
173
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3rd-party/debug-bar/debug-bar.css DELETED
@@ -1,56 +0,0 @@
1
- .jetpack-search-debug-bar h2,
2
- .qm-debug-bar-output .jetpack-search-debug-bar h2 {
3
- float: none !important;
4
- padding: 0 !important;
5
- text-align: left !important;
6
- }
7
-
8
- .qm-debug-bar-output .jetpack-search-debug-bar h2 {
9
- margin-top: 1em !important;
10
- }
11
-
12
- .qm-debug-bar-output .jetpack-search-debug-bar h2:first-child {
13
- margin-top: .5em !important;
14
- }
15
-
16
- .debug-menu-target h3 {
17
- padding-top: 0
18
- }
19
-
20
- .jetpack-search-debug-output-toggle .print-r {
21
- display: none;
22
- }
23
-
24
- .json-toggle-wrap {
25
- position: relative;
26
- }
27
-
28
- .json-toggle-wrap .toggle {
29
- position: absolute;
30
- bottom: 10px;
31
- right: 10px;
32
- background: #fff;
33
- border: 1px solid #000;
34
- cursor: pointer;
35
- padding: 2px 4px;
36
- }
37
-
38
- .json-toggle-wrap .ugly {
39
- display: none;
40
- }
41
-
42
- .json-toggle-wrap.pretty .pretty {
43
- display: none;
44
- }
45
-
46
- .json-toggle-wrap.pretty .ugly {
47
- display: inline;
48
- }
49
-
50
- .jetpack-search-debug-bar pre {
51
- white-space: pre-wrap;
52
- white-space: -moz-pre-wrap;
53
- white-space: -pre-wrap;
54
- white-space: -o-pre-wrap;
55
- word-wrap: break-word;
56
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3rd-party/debug-bar/debug-bar.js DELETED
@@ -1,22 +0,0 @@
1
- /* global jQuery, JSON */
2
-
3
- ( function( $ ) {
4
- $( document ).ready( function() {
5
- $( '.jetpack-search-debug-bar .json-toggle-wrap .toggle' ).click( function() {
6
- var t = $( this ),
7
- wrap = t.closest( '.json-toggle-wrap' ),
8
- pre = wrap.find( 'pre' ),
9
- content = pre.text(),
10
- isPretty = wrap.hasClass( 'pretty' );
11
-
12
- if ( ! isPretty ) {
13
- pre.text( JSON.stringify( JSON.parse( content ), null, 2 ) );
14
- } else {
15
- content.replace( '\t', '' ).replace( '\n', '' ).replace( ' ', '' );
16
- pre.text( JSON.stringify( JSON.parse( content ) ) );
17
- }
18
-
19
- wrap.toggleClass( 'pretty' );
20
- } );
21
- } );
22
- } )( jQuery );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3rd-party/domain-mapping.php DELETED
@@ -1,115 +0,0 @@
1
- <?php
2
-
3
- use Automattic\Jetpack\Constants;
4
-
5
- /**
6
- * Class Jetpack_3rd_Party_Domain_Mapping
7
- *
8
- * This class contains methods that are used to provide compatibility between Jetpack sync and domain mapping plugins.
9
- */
10
- class Jetpack_3rd_Party_Domain_Mapping {
11
-
12
- /**
13
- * @var Jetpack_3rd_Party_Domain_Mapping
14
- **/
15
- private static $instance = null;
16
-
17
- /**
18
- * An array of methods that are used to hook the Jetpack sync filters for home_url and site_url to a mapping plugin.
19
- *
20
- * @var array
21
- */
22
- static $test_methods = array(
23
- 'hook_wordpress_mu_domain_mapping',
24
- 'hook_wpmu_dev_domain_mapping'
25
- );
26
-
27
- static function init() {
28
- if ( is_null( self::$instance ) ) {
29
- self::$instance = new Jetpack_3rd_Party_Domain_Mapping;
30
- }
31
-
32
- return self::$instance;
33
- }
34
-
35
- private function __construct() {
36
- add_action( 'plugins_loaded', array( $this, 'attempt_to_hook_domain_mapping_plugins' ) );
37
- }
38
-
39
- /**
40
- * This function is called on the plugins_loaded action and will loop through the $test_methods
41
- * to try and hook a domain mapping plugin to the Jetpack sync filters for the home_url and site_url callables.
42
- */
43
- function attempt_to_hook_domain_mapping_plugins() {
44
- if ( ! Constants::is_defined( 'SUNRISE' ) ) {
45
- return;
46
- }
47
-
48
- $hooked = false;
49
- $count = count( self::$test_methods );
50
- for ( $i = 0; $i < $count && ! $hooked; $i++ ) {
51
- $hooked = call_user_func( array( $this, self::$test_methods[ $i ] ) );
52
- }
53
- }
54
-
55
- /**
56
- * This method will test for a constant and function that are known to be used with Donncha's WordPress MU
57
- * Domain Mapping plugin. If conditions are met, we hook the domain_mapping_siteurl() function to Jetpack sync
58
- * filters for home_url and site_url callables.
59
- *
60
- * @return bool
61
- */
62
- function hook_wordpress_mu_domain_mapping() {
63
- if ( ! Constants::is_defined( 'SUNRISE_LOADED' ) || ! $this->function_exists( 'domain_mapping_siteurl' ) ) {
64
- return false;
65
- }
66
-
67
- add_filter( 'jetpack_sync_home_url', 'domain_mapping_siteurl' );
68
- add_filter( 'jetpack_sync_site_url', 'domain_mapping_siteurl' );
69
-
70
- return true;
71
- }
72
-
73
- /**
74
- * This method will test for a class and method known to be used in WPMU Dev's domain mapping plugin. If the
75
- * method exists, then we'll hook the swap_to_mapped_url() to our Jetpack sync filters for home_url and site_url.
76
- *
77
- * @return bool
78
- */
79
- function hook_wpmu_dev_domain_mapping() {
80
- if ( ! $this->class_exists( 'domain_map' ) || ! $this->method_exists( 'domain_map', 'utils' ) ) {
81
- return false;
82
- }
83
-
84
- $utils = $this->get_domain_mapping_utils_instance();
85
- add_filter( 'jetpack_sync_home_url', array( $utils, 'swap_to_mapped_url' ) );
86
- add_filter( 'jetpack_sync_site_url', array( $utils, 'swap_to_mapped_url' ) );
87
-
88
- return true;
89
- }
90
-
91
- /*
92
- * Utility Methods
93
- *
94
- * These methods are very minimal, and in most cases, simply pass on arguments. Why create them you ask?
95
- * So that we can test.
96
- */
97
-
98
- public function method_exists( $class, $method ) {
99
- return method_exists( $class, $method );
100
- }
101
-
102
- public function class_exists( $class ) {
103
- return class_exists( $class );
104
- }
105
-
106
- public function function_exists( $function ) {
107
- return function_exists( $function );
108
- }
109
-
110
- public function get_domain_mapping_utils_instance() {
111
- return domain_map::utils();
112
- }
113
- }
114
-
115
- Jetpack_3rd_Party_Domain_Mapping::init();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3rd-party/qtranslate-x.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
- /**
3
- * Prevent qTranslate X from redirecting REST calls.
4
- *
5
- * @since 5.3
6
- *
7
- * @param string $url_lang Language URL to redirect to.
8
- * @param string $url_orig Original URL.
9
- * @param array $url_info Pieces of original URL.
10
- *
11
- * @return bool
12
- */
13
- function jetpack_no_qtranslate_rest_url_redirect( $url_lang, $url_orig, $url_info ) {
14
- if ( false !== strpos( $url_info['wp-path'], 'wp-json/jetpack' ) ) {
15
- return false;
16
- }
17
- return $url_lang;
18
- }
19
- add_filter( 'qtranslate_language_detect_redirect', 'jetpack_no_qtranslate_rest_url_redirect', 10, 3 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3rd-party/vaultpress.php DELETED
@@ -1,60 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Notify user that VaultPress has been disabled. Hide VaultPress notice that requested attention.
5
- *
6
- * @since 5.8
7
- */
8
- function jetpack_vaultpress_rewind_enabled_notice() {
9
- // The deactivation is performed here because there may be pages that admin_init runs on,
10
- // such as admin_ajax, that could deactivate the plugin without showing this notification.
11
- deactivate_plugins( 'vaultpress/vaultpress.php' );
12
-
13
- // Remove WP core notice that says that the plugin was activated.
14
- if ( isset( $_GET['activate'] ) ) {
15
- unset( $_GET['activate'] );
16
- }
17
- ?>
18
- <div class="notice notice-success is-dismissible vp-deactivated">
19
- <p style="margin-bottom: 0.25em;"><strong><?php esc_html_e( 'Jetpack is now handling your backups.', 'jetpack' ); ?></strong></p>
20
- <p>
21
- <?php esc_html_e( 'VaultPress is no longer needed and has been deactivated.', 'jetpack' ); ?>
22
- <?php
23
- echo sprintf(
24
- wp_kses(
25
- /* Translators: first variable is the URL of the web site without the protocol, e.g. mysite.com */
26
- __( 'You can access your backups on your site\'s <a href="https://wordpress.com/activity-log/%s" target="_blank" rel="noopener noreferrer">Activity</a> page.', 'jetpack' ),
27
- array(
28
- 'a' => array(
29
- 'href' => array(),
30
- 'target' => array(),
31
- 'rel' => array(),
32
- ),
33
- )
34
- ),
35
- esc_attr( Jetpack::build_raw_urls( get_home_url() ) )
36
- );
37
- ?>
38
- </p>
39
- </div>
40
- <style>#vp-notice{display:none;}</style>
41
- <?php
42
- }
43
-
44
- /**
45
- * If Backup & Scan is enabled, remove its entry in sidebar, deactivate VaultPress, and show a notification.
46
- *
47
- * @since 5.8
48
- */
49
- function jetpack_vaultpress_rewind_check() {
50
- if ( Jetpack::is_active() &&
51
- Jetpack::is_plugin_active( 'vaultpress/vaultpress.php' ) &&
52
- Jetpack::is_rewind_enabled()
53
- ) {
54
- remove_submenu_page( 'jetpack', 'vaultpress' );
55
-
56
- add_action( 'admin_notices', 'jetpack_vaultpress_rewind_enabled_notice' );
57
- }
58
- }
59
-
60
- add_action( 'admin_init', 'jetpack_vaultpress_rewind_check', 11 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3rd-party/woocommerce-services.php CHANGED
@@ -1,43 +1,28 @@
1
- <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2
 
3
  if ( ! defined( 'ABSPATH' ) ) {
4
  exit;
5
  }
6
 
7
- /**
8
- * Installs and activates the WooCommerce Services plugin.
9
- */
10
  class WC_Services_Installer {
11
 
12
  /**
13
- * The instance of the Jetpack class.
14
- *
15
  * @var Jetpack
16
- */
17
  private $jetpack;
18
 
19
  /**
20
- * The singleton instance of this class.
21
- *
22
  * @var WC_Services_Installer
23
- */
24
  private static $instance = null;
25
 
26
- /**
27
- * Returns the singleton instance of this class.
28
- *
29
- * @return object The WC_Services_Installer object.
30
- */
31
- public static function init() {
32
  if ( is_null( self::$instance ) ) {
33
  self::$instance = new WC_Services_Installer();
34
  }
35
  return self::$instance;
36
  }
37
 
38
- /**
39
- * Constructor
40
- */
41
  public function __construct() {
42
  $this->jetpack = Jetpack::init();
43
 
@@ -75,11 +60,7 @@ class WC_Services_Installer {
75
  break;
76
  }
77
 
78
- if ( isset( $_GET['redirect'] ) ) {
79
- $redirect = home_url( esc_url_raw( wp_unslash( $_GET['redirect'] ) ) );
80
- } else {
81
- $redirect = admin_url();
82
- }
83
 
84
  if ( $result ) {
85
  $this->jetpack->stat( 'jitm', 'wooservices-activated-' . JETPACK__VERSION );
@@ -96,7 +77,7 @@ class WC_Services_Installer {
96
  * Set up installation error admin notice.
97
  */
98
  public function add_error_notice() {
99
- if ( ! empty( $_GET['wc-services-install-error'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
100
  add_action( 'admin_notices', array( $this, 'error_notice' ) );
101
  }
102
  }
@@ -107,7 +88,7 @@ class WC_Services_Installer {
107
  public function error_notice() {
108
  ?>
109
  <div class="notice notice-error is-dismissible">
110
- <p><?php esc_html_e( 'There was an error installing WooCommerce Services.', 'jetpack' ); ?></p>
111
  </div>
112
  <?php
113
  }
@@ -118,11 +99,11 @@ class WC_Services_Installer {
118
  * @return bool result of installation
119
  */
120
  private function install() {
121
- include_once ABSPATH . '/wp-admin/includes/admin.php';
122
- include_once ABSPATH . '/wp-admin/includes/plugin-install.php';
123
- include_once ABSPATH . '/wp-admin/includes/plugin.php';
124
- include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
125
- include_once ABSPATH . '/wp-admin/includes/class-plugin-upgrader.php';
126
 
127
  $api = plugins_api( 'plugin_information', array( 'slug' => 'woocommerce-services' ) );
128
 
@@ -144,7 +125,7 @@ class WC_Services_Installer {
144
  private function activate() {
145
  $result = activate_plugin( 'woocommerce-services/woocommerce-services.php' );
146
 
147
- // Activate_plugin() returns null on success.
148
  return is_null( $result );
149
  }
150
  }
1
+ <?php
2
 
3
  if ( ! defined( 'ABSPATH' ) ) {
4
  exit;
5
  }
6
 
 
 
 
7
  class WC_Services_Installer {
8
 
9
  /**
 
 
10
  * @var Jetpack
11
+ **/
12
  private $jetpack;
13
 
14
  /**
 
 
15
  * @var WC_Services_Installer
16
+ **/
17
  private static $instance = null;
18
 
19
+ static function init() {
 
 
 
 
 
20
  if ( is_null( self::$instance ) ) {
21
  self::$instance = new WC_Services_Installer();
22
  }
23
  return self::$instance;
24
  }
25
 
 
 
 
26
  public function __construct() {
27
  $this->jetpack = Jetpack::init();
28
 
60
  break;
61
  }
62
 
63
+ $redirect = wp_get_referer();
 
 
 
 
64
 
65
  if ( $result ) {
66
  $this->jetpack->stat( 'jitm', 'wooservices-activated-' . JETPACK__VERSION );
77
  * Set up installation error admin notice.
78
  */
79
  public function add_error_notice() {
80
+ if ( ! empty( $_GET['wc-services-install-error'] ) ) {
81
  add_action( 'admin_notices', array( $this, 'error_notice' ) );
82
  }
83
  }
88
  public function error_notice() {
89
  ?>
90
  <div class="notice notice-error is-dismissible">
91
+ <p><?php _e( 'There was an error installing WooCommerce Services.', 'jetpack' ); ?></p>
92
  </div>
93
  <?php
94
  }
99
  * @return bool result of installation
100
  */
101
  private function install() {
102
+ include_once( ABSPATH . '/wp-admin/includes/admin.php' );
103
+ include_once( ABSPATH . '/wp-admin/includes/plugin-install.php' );
104
+ include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
105
+ include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' );
106
+ include_once( ABSPATH . '/wp-admin/includes/class-plugin-upgrader.php' );
107
 
108
  $api = plugins_api( 'plugin_information', array( 'slug' => 'woocommerce-services' ) );
109
 
125
  private function activate() {
126
  $result = activate_plugin( 'woocommerce-services/woocommerce-services.php' );
127
 
128
+ // activate_plugin() returns null on success
129
  return is_null( $result );
130
  }
131
  }
3rd-party/woocommerce.php CHANGED
@@ -1,27 +1,6 @@
1
  <?php
2
- /**
3
- * This file contains compatibility functions for WooCommerce to improve Jetpack feature support.
4
- */
5
- add_action( 'woocommerce_init', 'jetpack_woocommerce_integration' );
6
-
7
- function jetpack_woocommerce_integration() {
8
- /**
9
- * Double check WooCommerce exists - unlikely to fail due to the hook being used but better safe than sorry.
10
- */
11
- if ( ! class_exists( 'WooCommerce' ) ) {
12
- return;
13
- }
14
-
15
- add_action( 'woocommerce_share', 'jetpack_woocommerce_social_share_icons', 10 );
16
 
17
- /**
18
- * Wrap in function exists check since this requires WooCommerce 3.3+.
19
- */
20
- if ( function_exists( 'wc_get_default_products_per_row' ) ) {
21
- add_filter( 'infinite_scroll_render_callbacks', 'jetpack_woocommerce_infinite_scroll_render_callback', 10 );
22
- add_action( 'wp_enqueue_scripts', 'jetpack_woocommerce_infinite_scroll_style', 10 );
23
- }
24
- }
25
 
26
  /*
27
  * Make sure the social sharing icons show up under the product's short description
@@ -33,73 +12,3 @@ function jetpack_woocommerce_social_share_icons() {
33
  echo sharing_display();
34
  }
35
  }
36
-
37
- /**
38
- * Remove sharing display from account, cart, and checkout pages in WooCommerce.
39
- */
40
- function jetpack_woocommerce_remove_share() {
41
- /**
42
- * Double check WooCommerce exists - unlikely to fail due to the hook being used but better safe than sorry.
43
- */
44
- if ( ! class_exists( 'WooCommerce' ) ) {
45
- return;
46
- }
47
-
48
- if ( is_cart() || is_checkout() || is_account_page() ) {
49
- remove_filter( 'the_content', 'sharing_display', 19 );
50
- if ( class_exists( 'Jetpack_Likes' ) ) {
51
- remove_filter( 'the_content', array( Jetpack_Likes::init(), 'post_likes' ), 30, 1 );
52
- }
53
- }
54
- }
55
- add_action( 'loop_start', 'jetpack_woocommerce_remove_share' );
56
-
57
- /**
58
- * Add a callback for WooCommerce product rendering in infinite scroll.
59
- *
60
- * @param array $callbacks
61
- * @return array
62
- */
63
- function jetpack_woocommerce_infinite_scroll_render_callback( $callbacks ) {
64
- $callbacks[] = 'jetpack_woocommerce_infinite_scroll_render';
65
- return $callbacks;
66
- }
67
-
68
- /**
69
- * Add a default renderer for WooCommerce products within infinite scroll.
70
- */
71
- function jetpack_woocommerce_infinite_scroll_render() {
72
- if ( ! is_shop() && ! is_product_taxonomy() && ! is_product_category() && ! is_product_tag() ) {
73
- return;
74
- }
75
-
76
- woocommerce_product_loop_start();
77
-
78
- while ( have_posts() ) {
79
- the_post();
80
- wc_get_template_part( 'content', 'product' );
81
- }
82
-
83
- woocommerce_product_loop_end();
84
- }
85
-
86
- /**
87
- * Basic styling when infinite scroll is active only.
88
- */
89
- function jetpack_woocommerce_infinite_scroll_style() {
90
- $custom_css = "
91
- .infinite-scroll .woocommerce-pagination {
92
- display: none;
93
- }";
94
- wp_add_inline_style( 'woocommerce-layout', $custom_css );
95
- }
96
-
97
- function jetpack_woocommerce_lazy_images_compat() {
98
- wp_add_inline_script( 'wc-cart-fragments', "
99
- jQuery( 'body' ).bind( 'wc_fragments_refreshed', function() {
100
- jQuery( 'body' ).trigger( 'jetpack-lazy-images-load' );
101
- } );
102
- " );
103
- }
104
-
105
- add_action( 'wp_enqueue_scripts', 'jetpack_woocommerce_lazy_images_compat', 11 );
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ add_action( 'woocommerce_share', 'jetpack_woocommerce_social_share_icons', 10 );
 
 
 
 
 
 
 
4
 
5
  /*
6
  * Make sure the social sharing icons show up under the product's short description
12
  echo sharing_display();
13
  }
14
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3rd-party/wpml.php CHANGED
@@ -28,11 +28,9 @@ function wpml_jetpack_widget_get_top_posts( $posts, $post_ids, $count ) {
28
 
29
  foreach ( $posts as $k => $post ) {
30
  $lang_information = wpml_get_language_information( $post['post_id'] );
31
- if ( ! is_wp_error( $lang_information ) ) {
32
- $post_language = substr( $lang_information['locale'], 0, 2 );
33
- if ( $post_language !== $sitepress->get_current_language() ) {
34
- unset( $posts[ $k ] );
35
- }
36
  }
37
  }
38
 
@@ -59,4 +57,4 @@ function grunion_contact_form_field_html_filter( $r, $field_label, $id ){
59
  }
60
 
61
  return $r;
62
- }
28
 
29
  foreach ( $posts as $k => $post ) {
30
  $lang_information = wpml_get_language_information( $post['post_id'] );
31
+ $post_language = substr( $lang_information['locale'], 0, 2 );
32
+ if ( $post_language !== $sitepress->get_current_language() ) {
33
+ unset( $posts[ $k ] );
 
 
34
  }
35
  }
36
 
57
  }
58
 
59
  return $r;
60
+ }
_inc/blocks/business-hours/view.css DELETED
@@ -1 +0,0 @@
1
- @media (min-width:480px){.jetpack-business-hours dd,.jetpack-business-hours dt{display:inline-block}}.jetpack-business-hours dt{font-weight:700;margin-right:.5em;min-width:30%;vertical-align:top}.jetpack-business-hours dd{margin:0}@media (min-width:480px){.jetpack-business-hours dd{max-width:calc(70% - .5em)}}.jetpack-business-hours__item{margin-bottom:.5em}
 
_inc/blocks/business-hours/view.deps.json DELETED
@@ -1 +0,0 @@
1
- ["wp-polyfill"]