*/ private function get_product_info( $plugin ) { if ( empty( $plugin ) ) { return ''; } $product_info = \sprintf( 'Expiration date %1$s', $plugin->expiry_date ); return $product_info; } /** * Returns the WordPress version + a suffix about the multisite status. * * @return string The WordPress version string. */ private function get_wordpress_version() { global $wp_version; $wordpress_version = $wp_version; if ( \is_multisite() ) { $wordpress_version .= ' (multisite: yes)'; } else { $wordpress_version .= ' (multisite: no)'; } return $wordpress_version; } /** * Returns information about the current theme. * * @return string The theme info as string. */ private function get_theme_info() { $theme = \wp_get_theme(); $theme_info = \sprintf( '%1$s (Version %2$s, %3$s)', \esc_html( $theme->display( 'Name' ) ), \esc_html( $theme->display( 'Version' ) ), \esc_attr( $theme->display( 'ThemeURI' ) ) ); if ( \is_child_theme() ) { $theme_info .= \sprintf( ', this is a child theme of: %1$s', \esc_html( $theme->display( 'Template' ) ) ); } return $theme_info; } /** * Returns a stringified list of all active plugins, separated by a pipe. * * @return string The active plugins. */ private function get_active_plugins() { $updates_available = \get_site_transient( 'update_plugins' ); $active_plugins = ''; foreach ( \wp_get_active_and_valid_plugins() as $plugin ) { $plugin_data = \get_plugin_data( $plugin ); $plugin_file = \str_replace( \trailingslashit( \WP_PLUGIN_DIR ), '', $plugin ); $plugin_update_available = ''; if ( isset( $updates_available->response[ $plugin_file ] ) ) { $plugin_update_available = ' [update available]'; } $active_plugins .= \sprintf( '%1$s (Version %2$s%3$s, %4$s) | ', \esc_html( $plugin_data['Name'] ), \esc_html( $plugin_data['Version'] ), $plugin_update_available, \esc_attr( $plugin_data['PluginURI'] ) ); } return $active_plugins; } /** * Returns a CSV list of all must-use and drop-in plugins. * * @return string The active plugins. */ private function get_mustuse_and_dropins() { $dropins = \get_dropins(); $mustuse_plugins = \get_mu_plugins(); if ( ! \is_array( $dropins ) ) { $dropins = []; } if ( ! \is_array( $mustuse_plugins ) ) { $mustuse_plugins = []; } return \sprintf( 'Must-Use plugins: %1$d, Drop-ins: %2$d', \count( $mustuse_plugins ), \count( $dropins ) ); } /** * Return the indexables status details. * * @return string The indexables status in a string. */ private function get_indexables_status() { $indexables_status = 'Indexing completed: '; $indexing_completed = $this->options->get( 'indexables_indexing_completed' ); $indexing_reason = $this->options->get( 'indexing_reason' ); $indexables_status .= ( $indexing_completed ) ? 'yes' : 'no'; $indexables_status .= ( $indexing_reason ) ? ', latest indexing reason: ' . \esc_html( $indexing_reason ) : ''; foreach ( [ 'free', 'premium' ] as $migration_name ) { $current_status = $this->migration_status->get_error( $migration_name ); if ( \is_array( $current_status ) && isset( $current_status['message'] ) ) { $indexables_status .= ', migration error: ' . \esc_html( $current_status['message'] ); } } return $indexables_status; } /** * Returns language settings for the website and the current user. * * @return string The locale settings of the site and user. */ private function get_language_settings() { $site_locale = \get_locale(); $user_locale = \get_user_locale(); $language_settings = \sprintf( 'Site locale: %1$s, user locale: %2$s', ( \is_string( $site_locale ) ) ? \esc_html( $site_locale ) : 'unknown', ( \is_string( $user_locale ) ) ? \esc_html( $user_locale ) : 'unknown' ); return $language_settings; } /** * Returns the conditionals based on which this integration should be active. * * @return array The array of conditionals. */ public static function get_conditionals() { return [ Admin_Conditional::class ]; } /** * Allows filtering of the HelpScout settings. Hooked to admin_head to prevent timing issues, not too early, not too late. * * @return void */ protected function filter_settings() { $filterable_helpscout_setting = [ 'products' => $this->products, 'pages_ids' => $this->pages_ids, ]; /** * Filter: 'wpseo_helpscout_beacon_settings' - Allows overriding the HelpScout beacon settings. * * @param string $beacon_settings The HelpScout beacon settings. */ $helpscout_settings = \apply_filters( 'wpseo_helpscout_beacon_settings', $filterable_helpscout_setting ); $this->products = $helpscout_settings['products']; $this->pages_ids = $helpscout_settings['pages_ids']; } }