google-site-kit
Last commit date
bin
6 years ago
dist
6 years ago
includes
6 years ago
third-party
6 years ago
google-site-kit.php
6 years ago
readme.txt
6 years ago
google-site-kit.php
109 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Plugin main file. |
| 4 | * |
| 5 | * @package Google\Site_Kit |
| 6 | * @copyright 2019 Google LLC |
| 7 | * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 |
| 8 | * @link https://sitekit.withgoogle.com |
| 9 | * |
| 10 | * @wordpress-plugin |
| 11 | * Plugin Name: Site Kit by Google |
| 12 | * Plugin URI: https://sitekit.withgoogle.com |
| 13 | * Description: Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web. |
| 14 | * Version: 1.3.0 |
| 15 | * Author: Google |
| 16 | * Author URI: https://opensource.google.com |
| 17 | * License: Apache License 2.0 |
| 18 | * License URI: https://www.apache.org/licenses/LICENSE-2.0 |
| 19 | * Text Domain: google-site-kit |
| 20 | */ |
| 21 | |
| 22 | if ( ! defined( 'ABSPATH' ) ) { |
| 23 | exit; // Exit if accessed directly. |
| 24 | } |
| 25 | |
| 26 | // Define most essential constants. |
| 27 | define( 'GOOGLESITEKIT_VERSION', '1.3.0' ); |
| 28 | define( 'GOOGLESITEKIT_PLUGIN_MAIN_FILE', __FILE__ ); |
| 29 | define( 'GOOGLESITEKIT_PHP_MINIMUM', '5.6.0' ); |
| 30 | |
| 31 | /** |
| 32 | * Handles plugin activation. |
| 33 | * |
| 34 | * Throws an error if the plugin is activated on an older version than PHP 5.4. |
| 35 | * |
| 36 | * @since 1.0.0 |
| 37 | * @since 1.3.0 Minimum required version of PHP raised to 5.6 |
| 38 | * @access private |
| 39 | * |
| 40 | * @param bool $network_wide Whether to activate network-wide. |
| 41 | */ |
| 42 | function googlesitekit_activate_plugin( $network_wide ) { |
| 43 | if ( version_compare( PHP_VERSION, GOOGLESITEKIT_PHP_MINIMUM, '<' ) ) { |
| 44 | wp_die( |
| 45 | /* translators: %s: version number */ |
| 46 | esc_html( sprintf( __( 'Site Kit requires PHP version %s', 'google-site-kit' ), GOOGLESITEKIT_PHP_MINIMUM ) ), |
| 47 | esc_html__( 'Error Activating', 'google-site-kit' ) |
| 48 | ); |
| 49 | } |
| 50 | |
| 51 | if ( $network_wide ) { |
| 52 | return; |
| 53 | } |
| 54 | |
| 55 | do_action( 'googlesitekit_activation', $network_wide ); |
| 56 | } |
| 57 | |
| 58 | register_activation_hook( __FILE__, 'googlesitekit_activate_plugin' ); |
| 59 | |
| 60 | /** |
| 61 | * Handles plugin deactivation. |
| 62 | * |
| 63 | * @since 1.0.0 |
| 64 | * @access private |
| 65 | * |
| 66 | * @param bool $network_wide Whether to deactivate network-wide. |
| 67 | */ |
| 68 | function googlesitekit_deactivate_plugin( $network_wide ) { |
| 69 | if ( version_compare( PHP_VERSION, GOOGLESITEKIT_PHP_MINIMUM, '<' ) ) { |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | if ( $network_wide ) { |
| 74 | return; |
| 75 | } |
| 76 | |
| 77 | do_action( 'googlesitekit_deactivation', $network_wide ); |
| 78 | } |
| 79 | |
| 80 | register_deactivation_hook( __FILE__, 'googlesitekit_deactivate_plugin' ); |
| 81 | |
| 82 | /** |
| 83 | * Resets opcache if possible. |
| 84 | * |
| 85 | * @since 1.3.0 |
| 86 | * @access private |
| 87 | */ |
| 88 | function googlesitekit_opcache_reset() { |
| 89 | if ( version_compare( PHP_VERSION, GOOGLESITEKIT_PHP_MINIMUM, '<' ) ) { |
| 90 | return; |
| 91 | } |
| 92 | |
| 93 | if ( ! empty( ini_get( 'opcache.restrict_api' ) ) && strpos( __FILE__, ini_get( 'opcache.restrict_api' ) ) !== 0 ) { |
| 94 | return; |
| 95 | } |
| 96 | |
| 97 | // `opcache_reset` is prohibited on the WordPress VIP platform due to memory corruption. |
| 98 | if ( defined( 'WPCOM_IS_VIP_ENV' ) && WPCOM_IS_VIP_ENV ) { |
| 99 | return; |
| 100 | } |
| 101 | |
| 102 | opcache_reset(); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.opcache_opcache_reset |
| 103 | } |
| 104 | add_action( 'upgrader_process_complete', 'googlesitekit_opcache_reset' ); |
| 105 | |
| 106 | if ( version_compare( PHP_VERSION, GOOGLESITEKIT_PHP_MINIMUM, '>=' ) ) { |
| 107 | require_once plugin_dir_path( __FILE__ ) . 'includes/loader.php'; |
| 108 | } |
| 109 |