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?', 'share_trivia_email_subject' => '{{title}}', 'share_trivia_email_body' => '{{url}}', 'warning_on_exit' => false, 'mailchimp_apikey' => '', 'lazy_load' => true, 'facebook_app_id' => '', 'facebook_load_sdk' => true, 'share_buttons' => array( 'facebook', 'twitter', 'gplus' ), 'clean_uninstall' => false, 'shortcode_quiz_hide_title' => false, 'shortcode_quiz_column_count' => 2, 'lockout_answers' => true, 'mailerlite_apikey' => '', 'add_meta_tags' => true, 'disable_script_optimization' => false, ); public static function init() { register_setting( ARISTREAMQUIZ_SETTINGS_GROUP, ARISTREAMQUIZ_SETTINGS_NAME, array( __CLASS__, 'sanitize' ) ); add_settings_section( ARISTREAMQUIZ_SETTINGS_SHORTCODE_SECTION, '', // Title array( __CLASS__, 'render_shortcode_section_info' ), ARISTREAMQUIZ_SETTINGS_GENERAL_PAGE ); 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_MAILERLITE_SECTION, '', // Title array( __CLASS__, 'render_mailerlite_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( 'shortcode_quiz_hide_title', self::format_option_name( __( 'Hide title', 'ari-stream-quiz' ), __( 'If the parameter is enabled, title of the quizzes which are embedded via shortcode will be hidden. Can be changed directly into shortcode via hide_title shortcode parameter.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_shortcode_quiz_hide_title' ), ARISTREAMQUIZ_SETTINGS_GENERAL_PAGE, ARISTREAMQUIZ_SETTINGS_SHORTCODE_SECTION ); add_settings_field( 'shortcode_quiz_column_count', self::format_option_name( __( 'Image answers per row', 'ari-stream-quiz' ), __( 'It is used to specify how many image-based answers will be shown per row. Can be changed directly into shortcode via col shortcode parameter.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_shortcode_quiz_col_count' ), ARISTREAMQUIZ_SETTINGS_GENERAL_PAGE, ARISTREAMQUIZ_SETTINGS_SHORTCODE_SECTION ); 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 ); add_settings_field( 'lockout_answers', self::format_option_name( __( 'Lockout single answers', 'ari-stream-quiz' ), __( 'If the parameter is activated, answers will be disabled when a user selected an answer otherwise users can change their answers.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_triviaquiz_lockout_answers' ), 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 ); // MailerLite parameters add_settings_field( 'mailerlite_apikey', self::format_option_name( __( 'API key', 'ari-stream-quiz' ), __( 'API key is required for integration with MailerLite service. Login to your MailerLite account, generate API key, copy it and populate the parameter with it.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_mailerlite_api_key' ), ARISTREAMQUIZ_SETTINGS_GENERAL_PAGE, ARISTREAMQUIZ_SETTINGS_MAILERLITE_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 specify 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 ); add_settings_field( 'share_trivia_email_subject', __( 'Mail subject', 'ari-stream-quiz' ), array( __CLASS__, 'render_share_triviaquiz_email_subject' ), ARISTREAMQUIZ_SETTINGS_SHARING_PAGE, ARISTREAMQUIZ_SETTINGS_SHARING_TRIVIACONTENT_SECTION ); add_settings_field( 'share_trivia_email_body', __( 'Mail body', 'ari-stream-quiz' ), array( __CLASS__, 'render_share_triviaquiz_email_body' ), ARISTREAMQUIZ_SETTINGS_SHARING_PAGE, ARISTREAMQUIZ_SETTINGS_SHARING_TRIVIACONTENT_SECTION ); // Advanced parameters add_settings_field( 'clean_uninstall', self::format_option_name( __( 'Clean uninstall', 'ari-stream-quiz' ), __( 'If the parameter is enabled, plugin\'s settings and data will be removed when the plugin is uninstalled. Don\'t enable this option if want to upgrade the plugin and keep quizzes.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_advanced_clean_uninstall' ), ARISTREAMQUIZ_SETTINGS_ADVANCED_PAGE, ARISTREAMQUIZ_SETTINGS_ADVANCED_SECTION ); add_settings_field( 'disable_script_optimization', self::format_option_name( __( 'Disable script optimization', 'ari-stream-quiz' ), __( 'If the parameter is enabled, the plugin will try to avoid optimization of script loading by 3rd party plugins.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_advanced_disable_script_optimization' ), ARISTREAMQUIZ_SETTINGS_ADVANCED_PAGE, ARISTREAMQUIZ_SETTINGS_ADVANCED_SECTION ); 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( 'add_meta_tags', self::format_option_name( __( 'Add meta tags', 'ari-stream-quiz' ), __( 'If the parameter is enabled, the plugin will add Open Graph and Twitter meta tags for current quiz.', 'ari-stream-quiz' ) ), array( __CLASS__, 'render_advanced_add_meta_tags' ), 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( '