parsely->site_id_is_set() && $this->parsely->api_secret_is_set(); // Inject Content Intelligence permissions. $permissions_json = Permissions::get_pch_permissions_json( $this->parsely->get_options()['content_helper'] ); wp_add_inline_script( static::get_script_id(), "window.wpParselyContentHelperPermissions = '$permissions_json';", 'before' ); // Inject a message if the required credentials are not set. if ( ! $are_credentials_set ) { $message = $this->get_credentials_not_set_message(); wp_add_inline_script( static::get_script_id(), "window.wpParselyEmptyCredentialsMessage = '{$message}';", 'before' ); } // If the feature has settings, inject them. if ( null !== $settings_route ) { $settings = ''; if ( ! defined( 'INTEGRATION_TESTS_RUNNING' ) ) { $settings = rest_do_request( new WP_REST_Request( 'GET', '/wp-parsely/v2/settings/' . $settings_route ) )->get_data(); } if ( ! is_array( $settings ) ) { $settings = array(); } $settings = wp_json_encode( $settings ); wp_add_inline_script( static::get_script_id(), "window.wpParselyContentHelperSettings = '$settings';", 'before' ); } } /** * Returns the message to be shown when required credentials are not set. * * HTML is allowed within the message. The message can be overridden using * the wp_parsely_message_credentials_not_set filter. * * @since 3.9.0 * * @return string The sanitized message. */ protected function get_credentials_not_set_message(): string { $default_message = '

' . __( 'Contact us', 'wp-parsely' ) . '' . __( ' about advanced plugin features and the Parse.ly dashboard.', 'wp-parsely' ) . '

' . __( 'Existing Parse.ly customers can enable this feature by setting their Site ID and API Secret in ', 'wp-parsely' ) . ' ' . __( 'wp-parsely options.', 'wp-parsely' ) . '

'; // Override default message if the respective filter is set. $message = apply_filters( 'wp_parsely_message_credentials_not_set', $default_message ); // Remove unnecessary whitespace to avoid broken output. $message = str_replace( array( "\r", "\n", "\t" ), '', $message ); return wp_kses_post( $message ); } }