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', 'share_trivia_facebook_title' => 'I got {{userScore}} out of {{maxScore}}. What about you?', 'share_trivia_facebook_content' => '{{content}}', 'share_trivia_twitter_content' => 'I got {{userScore}} out of {{maxScore}}. What about you?', 'warning_on_exit' => false, 'mailchimp_apikey' => '', 'lazy_load' => true, 'facebook_app_id' => '', 'facebook_load_sdk' => true, 'share_buttons' => array( 'facebook', 'twitter', 'gplus' ), ); 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_MAILCHIMP_SECTION, '', // Title array( __CLASS__, 'render_mailchimp_section_info' ), ARISTREAMQUIZ_SETTINGS_GENERAL_PAGE ); add_settings_section( ARISTREAMQUIZ_SETTINGS_SHARING_SECTION, '', // Title array( __CLASS__, 'render_sharing_section_info' ), ARISTREAMQUIZ_SETTINGS_SHARING_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 ); add_settings_field( 'warning_on_exit', self::format_option_name( __( 'Warning on exit', 'ari-stream-quiz' ), __( 'Warning message will be shown if a user leaves non-completed quiz.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_general_warning_on_exit' ), 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 ); // MailChimp parameters add_settings_field( 'mailchimp_apikey', self::format_option_name( __( 'API key', 'ari-stream-quiz' ), __( 'API key is required for integration with MailChimp service. Login to your MailChimp account, generate API key, copy it and populate the parameter with it.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_mailchimp_api_key' ), ARISTREAMQUIZ_SETTINGS_GENERAL_PAGE, ARISTREAMQUIZ_SETTINGS_MAILCHIMP_SECTION ); // Sharing parameters add_settings_field( 'facebook_app_id', self::format_option_name( __( 'Facebook App ID', 'ari-stream-quiz' ), __( 'App ID is required to use "Facebook" share button. If App ID is not defined, it will not be possible to possible to title, description and image for sharing content.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_share_facebook_app_id' ), ARISTREAMQUIZ_SETTINGS_SHARING_PAGE, ARISTREAMQUIZ_SETTINGS_SHARING_SECTION ); add_settings_field( 'share_buttons', self::format_option_name( __( 'Share buttons', 'ari-stream-quiz' ), __( 'The selected share buttons will be shown on quiz final page.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_share_share_buttons' ), ARISTREAMQUIZ_SETTINGS_SHARING_PAGE, ARISTREAMQUIZ_SETTINGS_SHARING_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 ); add_settings_field( 'share_trivia_facebook_title', __( 'Title of Facebook post', 'ari-stream-quiz' ), array( __CLASS__, 'render_share_triviaquiz_facebook_title' ), ARISTREAMQUIZ_SETTINGS_SHARING_PAGE, ARISTREAMQUIZ_SETTINGS_SHARING_TRIVIACONTENT_SECTION ); add_settings_field( 'share_trivia_facebook_content', __( 'Content of Facebook post', 'ari-stream-quiz' ), array( __CLASS__, 'render_share_triviaquiz_facebook_content' ), ARISTREAMQUIZ_SETTINGS_SHARING_PAGE, ARISTREAMQUIZ_SETTINGS_SHARING_TRIVIACONTENT_SECTION ); add_settings_field( 'share_trivia_twitter_content', __( 'Content of Twitter post', 'ari-stream-quiz' ), array( __CLASS__, 'render_share_triviaquiz_twitter_content' ), ARISTREAMQUIZ_SETTINGS_SHARING_PAGE, ARISTREAMQUIZ_SETTINGS_SHARING_TRIVIACONTENT_SECTION ); // Advanced parameters add_settings_field( 'facebook_load_sdk', self::format_option_name( __( 'Load Facebook SDK', 'ari-stream-quiz' ), __( 'If template or another plugin also loads Facebook JS SDK, it is possible to disabled SDK loading by the plugin to avoid conflicts.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_advanced_facebook_load_sdk' ), ARISTREAMQUIZ_SETTINGS_ADVANCED_PAGE, ARISTREAMQUIZ_SETTINGS_ADVANCED_SECTION ); add_settings_field( 'lazy_load', self::format_option_name( __( 'Images lazy loading', 'ari-stream-quiz' ), __( 'If the parameter is enabled, images in questions and answers will be loaded only when quiz is started (if "Start quiz" button is used) to increase page speed and a loading icon will be shown until images are loaded.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_advanced_lazy_load' ), ARISTREAMQUIZ_SETTINGS_ADVANCED_PAGE, ARISTREAMQUIZ_SETTINGS_ADVANCED_SECTION ); 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( '