PluginProbe
Jetpack Search / 5.0.0
Jetpack Search v5.0.0
7.1.0 trunk 1.0.0 1.1.0 1.1.0-beta 1.2.0 1.2.0-beta 1.3.0 1.3.1 1.4.0 1.4.1 2.0.0 2.1.0 3.0.0 3.0.1 4.0.0 4.1.0 5.0.0 5.1.0 5.2.0 5.2.2 6.0.0 7.0.0 7.0.1
jetpack-search / jetpack-search.php

jetpack-search.php in Jetpack Search 5.0.0, at jetpack-search.php

121 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 * Plugin Name: Jetpack Search
5 * Plugin URI: https://jetpack.com/search/
6 * Description: Easily add cloud-powered instant search and filters to your website or WooCommerce store with advanced algorithms that boost your search results based on traffic to your site.
7 * Version: 5.0.0
8 * Author: Automattic - Jetpack Search team
9 * Author URI: https://jetpack.com/
10 * License: GPLv2 or later
11 * Text Domain: jetpack-search
12 *
13 * @package automattic/jetpack-search-plugin
14 */
15
16 namespace Automattic\Jetpack\Search_Plugin;
17
18 use Automattic\Jetpack\Assets;
19
20 if ( ! defined( 'ABSPATH' ) ) {
21 exit( 0 );
22 }
23
24 // Constant definitions.
25 define( 'JETPACK_SEARCH_PLUGIN__DIR', plugin_dir_path( __FILE__ ) );
26 define( 'JETPACK_SEARCH_PLUGIN__FILE', __FILE__ );
27 define( 'JETPACK_SEARCH_PLUGIN__FILE_RELATIVE_PATH', plugin_basename( __FILE__ ) );
28 define( 'JETPACK_SEARCH_PLUGIN__SLUG', 'jetpack-search' );
29 define( 'JETPACK_SEARCH_PLUGIN__VERSION', '5.0.0' );
30 defined( 'JETPACK_CLIENT__AUTH_LOCATION' ) || define( 'JETPACK_CLIENT__AUTH_LOCATION', 'header' );
31
32 defined( 'JETPACK__API_BASE' ) || define( 'JETPACK__API_BASE', 'https://jetpack.wordpress.com/jetpack.' );
33 defined( 'JETPACK__WPCOM_JSON_API_BASE' ) || define( 'JETPACK__WPCOM_JSON_API_BASE', 'https://public-api.wordpress.com' );
34
35 defined( 'JETPACK__SANDBOX_DOMAIN' ) || define( 'JETPACK__SANDBOX_DOMAIN', '' );
36
37 /*
38 * These constants can be set in wp-config.php to ensure sites behind proxies will still work.
39 * Setting these constants, though, is *not* the preferred method. It's better to configure
40 * the proxy to send the X-Forwarded-Port header.
41 */
42 defined( 'JETPACK_SIGNATURE__HTTP_PORT' ) || define( 'JETPACK_SIGNATURE__HTTP_PORT', 80 );
43 defined( 'JETPACK_SIGNATURE__HTTPS_PORT' ) || define( 'JETPACK_SIGNATURE__HTTPS_PORT', 443 );
44
45 $autoload_packages_path = JETPACK_SEARCH_PLUGIN__DIR . '/vendor/autoload_packages.php';
46 if ( ! is_readable( $autoload_packages_path ) ) {
47 if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
48 error_log( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
49 sprintf(
50 /* translators: Placeholder is a link to a support document. */
51 __( 'Your installation of Jetpack Search is incomplete. If you installed Jetpack Search from GitHub, please refer to this document to set up your development environment: %1$s', 'jetpack-search' ),
52 'https://github.com/Automattic/jetpack/blob/trunk/docs/development-environment.md'
53 )
54 );
55 }
56
57 // Add a red bubble notification to My Jetpack if the installation is bad.
58 add_filter(
59 'my_jetpack_red_bubble_notification_slugs',
60 function ( $slugs ) {
61 $slugs['jetpack-search-plugin-bad-installation'] = array(
62 'data' => array(
63 'plugin' => 'Jetpack Search',
64 ),
65 );
66
67 return $slugs;
68 }
69 );
70
71 /**
72 * Outputs an admin notice for folks running Jetpack Search without having run composer install.
73 *
74 * @since 1.2.0
75 */
76 function jetpack_search_admin_missing_files() {
77 if ( get_current_screen()->id !== 'plugins' ) {
78 return;
79 }
80
81 $message = sprintf(
82 wp_kses(
83 /* translators: Placeholder is a link to a support document. */
84 __( 'Your installation of Jetpack Search is incomplete. If you installed Jetpack Search from GitHub, please refer to <a href="%1$s" target="_blank" rel="noopener noreferrer">this document</a> to set up your development environment. Jetpack Search must have Composer dependencies installed and built via the build command.', 'jetpack-search' ),
85 array(
86 'a' => array(
87 'href' => array(),
88 'target' => array(),
89 'rel' => array(),
90 ),
91 )
92 ),
93 'https://github.com/Automattic/jetpack/blob/trunk/docs/development-environment.md#building-your-project'
94 );
95 wp_admin_notice(
96 $message,
97 array(
98 'type' => 'error',
99 'dismissible' => true,
100 )
101 );
102 }
103
104 add_action( 'admin_notices', __NAMESPACE__ . '\jetpack_search_admin_missing_files' );
105 return;
106 }
107
108 /**
109 * Setup autoloading
110 */
111 require_once $autoload_packages_path;
112
113 /**
114 * Load jetpack packages i18n map.
115 */
116 if ( method_exists( Assets::class, 'alias_textdomains_from_file' ) ) {
117 Assets::alias_textdomains_from_file( JETPACK_SEARCH_PLUGIN__DIR . '/jetpack_vendor/i18n-map.php' );
118 }
119
120 Jetpack_Search_Plugin::bootstrap();
121