'string', 'default' => self::DEFAULT_VALUE, ] ); add_settings_field( 'beyondwords-integration-method', __('Integration method', 'speechkit'), [self::class, 'render'], 'beyondwords_content', 'content' ); } /** * Render setting field. * * @since 6.0.0 Introduced. * * @return void **/ public static function render() { $options = self::getOptions(); $current = get_option(self::OPTION_NAME, self::DEFAULT_VALUE); ?>

%s', // phpcs:ignore Generic.Files.LineLength.TooLong esc_html__('Client-Side integration', 'speechkit') ) ); ?>

[ 'value' => self::REST_API, 'label' => __('REST API', 'speechkit'), ], self::CLIENT_SIDE => [ 'value' => self::CLIENT_SIDE, 'label' => __('Magic Embed', 'speechkit'), ], ]; } /** * Get integration method. Tries the post meta if a post is passed, and falls back * to the option. * * @since 6.0.0 Introduced. * * @param \WP_Post|false $post WordPress Post object (optional). * * @return string Integration method - either self::REST_API or self::CLIENT_SIDE. **/ public static function getIntegrationMethod(\WP_Post|false $post = false): string { $method = ''; if ($post) { $method = get_post_meta($post->ID, 'beyondwords_integration_method', true); } if (empty($method)) { $method = get_option(self::OPTION_NAME, self::DEFAULT_VALUE); } if (! in_array($method, [self::REST_API, self::CLIENT_SIDE], true)) { $method = self::DEFAULT_VALUE; } return $method; } }