ARISTREAMQUIZ_THEME_DEFAULT, 'smart_scroll' => true, 'scroll_duration' => 600, 'scroll_offset' => 0, 'custom_styles' => '', 'show_results' => '', // empty, 'immediately', 'on_complete' 'show_questions_oncomplete' => true, 'share_trivia_title' => 'You got {{userScore}} out of {{maxScore}} correct', ); public static function init() { register_setting( ARISTREAMQUIZ_SETTINGS_GROUP, ARISTREAMQUIZ_SETTINGS_NAME, array( __CLASS__, 'sanitize' ) ); add_settings_section( ARISTREAMQUIZ_SETTINGS_GENERAL_SECTION, '', // Title array( __CLASS__, 'render_general_section_info' ), ARISTREAMQUIZ_SETTINGS_GENERAL_PAGE ); add_settings_section( ARISTREAMQUIZ_SETTINGS_SHARING_TRIVIACONTENT_SECTION, '', // Title array( __CLASS__, 'render_sharing_triviacontent_section_info' ), ARISTREAMQUIZ_SETTINGS_SHARING_PAGE ); add_settings_section( ARISTREAMQUIZ_SETTINGS_ADVANCED_SECTION, '', // Title array( __CLASS__, 'render_advanced_section_info' ), ARISTREAMQUIZ_SETTINGS_ADVANCED_PAGE ); add_settings_field( 'theme', self::format_option_name( __( 'Default theme', 'ari-stream-quiz' ), __( 'The selected theme will be used for all quizzes by default if it is not overridden in quiz settings.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_general_theme' ), ARISTREAMQUIZ_SETTINGS_GENERAL_PAGE, ARISTREAMQUIZ_SETTINGS_GENERAL_SECTION ); add_settings_field( 'smart_scroll', self::format_option_name( __( 'Smart scroll', 'ari-stream-quiz' ), __( 'If the parameter is enabled, the extension will automatically scroll to next element (question, quiz result and etc.) during quiz session.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_general_smart_scroll' ), ARISTREAMQUIZ_SETTINGS_GENERAL_PAGE, ARISTREAMQUIZ_SETTINGS_GENERAL_SECTION ); add_settings_field( 'scroll_duration', self::format_option_name( __( 'Scroll duration', 'ari-stream-quiz' ), __( 'The duration in milliseconds of scrolling animation.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_general_scroll_duration' ), ARISTREAMQUIZ_SETTINGS_GENERAL_PAGE, ARISTREAMQUIZ_SETTINGS_GENERAL_SECTION ); add_settings_field( 'scroll_offset', self::format_option_name( __( 'Scroll offset', 'ari-stream-quiz' ), __( 'The defined offset in pixels will be added to final top position, useful if template contains fixed elements. Possible to use negative values.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_general_scroll_offset' ), ARISTREAMQUIZ_SETTINGS_GENERAL_PAGE, ARISTREAMQUIZ_SETTINGS_GENERAL_SECTION ); add_settings_field( 'show_questions_oncomplete', self::format_option_name( __( 'Show questions at the end', 'ari-stream-quiz' ), __( 'If it is enabled, all questions will be shown on quiz final page otherwise questions will be hidden.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_general_show_questions_oncomplete' ), ARISTREAMQUIZ_SETTINGS_GENERAL_PAGE, ARISTREAMQUIZ_SETTINGS_GENERAL_SECTION ); // Trivia quiz parameters add_settings_field( 'show_results', self::format_option_name( __( 'Show result per question', 'ari-stream-quiz' ), __( 'Specify should quiz takers see correct answers or not.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_triviaquiz_show_results' ), ARISTREAMQUIZ_SETTINGS_GENERAL_PAGE, ARISTREAMQUIZ_SETTINGS_GENERAL_SECTION ); // Sharing content - trivia quiz add_settings_field( 'share_trivia_description', '', array( __CLASS__, 'render_share_triviaquiz_description' ), ARISTREAMQUIZ_SETTINGS_SHARING_PAGE, ARISTREAMQUIZ_SETTINGS_SHARING_TRIVIACONTENT_SECTION ); add_settings_field( 'share_trivia_title', __( 'Title on result page', 'ari-stream-quiz' ), array( __CLASS__, 'render_share_triviaquiz_title' ), ARISTREAMQUIZ_SETTINGS_SHARING_PAGE, ARISTREAMQUIZ_SETTINGS_SHARING_TRIVIACONTENT_SECTION ); // Advanced parameters add_settings_field( 'custom_styles', self::format_option_name( __( 'Custom CSS styles', 'ari-stream-quiz' ), __( 'The defined CSS rules will be added on frontend pages with quizzes. Can be used to resolve style conflicts or for customization.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_advanced_custom_styles' ), ARISTREAMQUIZ_SETTINGS_ADVANCED_PAGE, ARISTREAMQUIZ_SETTINGS_ADVANCED_SECTION ); } public static function options() { if ( ! is_null( self::$options ) ) return self::$options; self::$options = get_option( ARISTREAMQUIZ_SETTINGS_NAME ); return self::$options; } public static function get_option( $name, $default = null ) { $options = self::options(); $val = $default; if ( isset( $options[$name] ) ) { $val = $options[$name]; } else if ( is_null( $default) && isset( self::$default_settings[$name] ) ) { $val = self::$default_settings[$name]; } return $val; } public static function format_option_name( $title, $tooltip = '' ) { $html = $title; if ( $tooltip ) { $html = sprintf( '%1$s', $title, esc_attr( $tooltip ) ); } return $html; } public static function render_header( $message, $class = '' ) { printf( '