state ) && 'unavailable' !== $rewind_data->state; } /** * Checks if a plugin is installed. * * @param string $plugin_file The plugin filename. * @return boolean */ private static function is_plugin_installed( $plugin_file ) { $plugins = Plugins_Installer::get_plugins(); return isset( $plugins[ $plugin_file ] ); } /** * Checks if a plugin is active. * * @param string $plugin_file The plugin filename. * @return boolean */ private static function is_plugin_active( $plugin_file ) { $plugins = Plugins_Installer::get_plugins(); return isset( $plugins[ $plugin_file ] ) && isset( $plugins[ $plugin_file ]['active'] ) && $plugins[ $plugin_file ]['active']; } /** * Determines whether Scan is active * * @return boolean */ private static function is_scan_active() { $scan_data = Jetpack_Core_Json_Api_Endpoints::scan_state(); return is_object( $scan_data ) && isset( $scan_data->state ) && 'unavailable' !== $scan_data->state; } /** * Determines whether Search module is active * * @return boolean */ private static function is_search_active() { return Jetpack::is_module_active( 'search' ); } /** * Determines whether the Site is on a Security Plan. It will also return true if site has backup, scan and akismet. * * @return boolean */ private static function has_security_plan() { $plan_data = Jetpack_Plan::get(); if ( is_array( $plan_data ) && isset( $plan_data['product_slug'] ) ) { $has_plan = wp_startswith( $plan_data['product_slug'], 'jetpack_security' ); return ( $has_plan || ( self::is_backup_active() && self::is_scan_active() && self::is_akismet_active() ) ); } return false; } /** * Determines whether the Site is on the Complete Plan. * * @return boolean */ private static function has_complete_plan() { $plan_data = Jetpack_Plan::get(); if ( is_array( $plan_data ) && isset( $plan_data['product_slug'] ) ) { return wp_startswith( $plan_data['product_slug'], 'jetpack_complete' ); } return false; } /** * Determines whether the Site has a specific product. * * @param string $target_product_slug The product slug we are looking for. * * @return boolean */ private static function has_product( $target_product_slug ) { $site_products_slugs = array_column( Jetpack_Plan::get_products(), 'product_slug' ); foreach ( $site_products_slugs as $product_slug ) { if ( wp_startswith( $product_slug, $target_product_slug ) ) { return true; } } return false; } /** * Determines whether Akismet is active * * @return boolean */ private static function is_akismet_active() { return Jetpack::is_akismet_active(); } /** * Outputs the header of the Upgrade Secion * * @return void */ private static function print_header() { if ( self::has_security_plan() ) { // translators: %s is the Site Name. $title = __( 'Performance and growth tools for %s', 'jetpack' ); } else { // translators: %s is the Site Name. $title = __( 'Security, performance, and growth tools for %s', 'jetpack' ); } $title = sprintf( $title, get_bloginfo( 'site_name' ) ); $aria_expanded = 'true'; $postbox_closed = ''; $stats_options = get_option( 'stats_options' ); if ( isset( $stats_options['collapse_nudges'] ) && $stats_options['collapse_nudges'] ) { $aria_expanded = 'false'; $postbox_closed = ' closed'; } ?>
has_connected_owner() ) { $args['query'] = 'unlinked=1'; } return Redirect::get_url( $source, $args ); } /** * Gets the product description link. * * @param string $product_key The product key of the product we wish to display. * @return string */ private static function get_product_description_link( $product_key ) { return Jetpack::admin_url( array( 'page' => sprintf( 'jetpack#/product/%s', $product_key ) ) ); } /** * Tracks an event in Tracks * * @param string $event_name The event name. * @return void */ private static function track_event( $event_name ) { $connection_manager = new Manager( 'jetpack' ); $tracking = new Tracking( 'jetpack', $connection_manager ); $tracking->record_user_event( $event_name, array( 'has_connected_owner' => $connection_manager->has_connected_owner(), ) ); } /** * Outputs one Upgrade item * * @param string $title The title of the item. * @param string $text The description of the item. * @param string $icon The path of the icon, relative to Jetpack images folder. * @param string $link The link of the button. * @param string $tracks_id The id used to identify the tracks events. Automatically prefixed with "jetpack_stats_nudges_{view|click|learn_more}_". * @param string $learn_more_link The target of the "Learn more" link. * @param boolean $subitem Whether it is a subitem or not. * @param string $button_label The button label. * @return void */ private static function print_item( $title, $text, $icon, $link, $tracks_id, $learn_more_link, $subitem = false, $button_label = null ) { $additional_classes = $subitem ? 'jp-stats-report-upgrade-subitem' : ''; $button_class = $subitem ? 'is-secondary' : 'is-primary'; $icon_url = plugins_url( '', JETPACK__PLUGIN_FILE ) . '/images/products/' . $icon; $button_label = $button_label === null ? _x( 'Upgrade', 'Call to action to buy a new plan', 'jetpack' ) : $button_label; $view_event = "stats_nudges_view_$tracks_id"; $click_event = "stats_nudges_click_$tracks_id"; $learn_more_event = "stats_nudges_learn_more_$tracks_id"; self::track_event( $view_event ); ?>