diff --git a/includes/mlw_quiz.php b/includes/mlw_quiz.php
index c93c692be..b3d657162 100644
--- a/includes/mlw_quiz.php
+++ b/includes/mlw_quiz.php
@@ -33,12 +33,16 @@ function mlw_quiz_shortcode($atts)
break;
}
+ $mlw_qmn_quiz_options_array = array(
+ 'quiz_name' => $mlw_quiz_options->quiz_name,
+ 'quiz_id' => $mlw_quiz_options->quiz_id
+ );
+
//Check if user is required to be checked in
if ( $mlw_quiz_options->require_log_in == 1 && !is_user_logged_in() )
{
$mlw_message = htmlspecialchars_decode($mlw_quiz_options->require_log_in_text, ENT_QUOTES);
- $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
- $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message, $mlw_qmn_quiz_options_array);
$mlw_display = $mlw_message;
$mlw_display .= wp_login_form( array('echo' => false) );
return $mlw_display;
@@ -187,8 +191,7 @@ function mlw_quiz_shortcode($atts)
if ($mlw_qmn_entries_count >= $mlw_quiz_options->limit_total_entries)
{
$mlw_message = htmlspecialchars_decode($mlw_quiz_options->limit_total_entries_text, ENT_QUOTES);
- $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
- $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message, $mlw_qmn_quiz_options_array);
$mlw_display = $mlw_message;
return $mlw_display;
$mlw_qmn_isAllowed = false;
@@ -356,17 +359,47 @@ function timer()
}
function minToSec(amount)
{
- var minutes = Math.floor(amount/60);
- var seconds = amount - (minutes * 60);
- if (seconds == '0')
- {
- seconds = "00";
- }
- else if (seconds < 10)
- {
- seconds = '0' + seconds;
- }
- return minutes+":"+seconds;
+ var timer_display = '';
+ var hours = Math.floor(amount/3600);
+ if (hours == '0')
+ {
+ timer_display = timer_display +"00:";
+ }
+ else if (hours < 10)
+ {
+ timer_display = timer_display + '0' + hours + ":";
+ }
+ else
+ {
+ timer_display = timer_display + hours + ":";
+ }
+ var minutes = Math.floor((amount % 3600)/60);
+ if (minutes == '0')
+ {
+ timer_display = timer_display +"00:";
+ }
+ else if (minutes < 10)
+ {
+ timer_display = timer_display + '0' + minutes + ":";
+ }
+ else
+ {
+ timer_display = timer_display + minutes + ":";
+ }
+ var seconds = Math.floor(amount % 60);
+ if (seconds == '0')
+ {
+ timer_display = timer_display +"00";
+ }
+ else if (seconds < 10)
+ {
+ timer_display = timer_display +'0' + seconds;
+ }
+ else
+ {
+ timer_display = timer_display + seconds;
+ }
+ return timer_display;
}
";
$mlw_display .= "
";
$mlw_message_before = htmlspecialchars_decode($mlw_quiz_options->message_before, ENT_QUOTES);
- $mlw_message_before = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_before);
- $mlw_message_before = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_before);
+ $mlw_message_before = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message_before, $mlw_qmn_quiz_options_array);
$mlw_display .= "
".$mlw_message_before."";
$mlw_display .= "
";
@@ -806,8 +838,7 @@ function mlw_validateForm()
$mlw_qmn_section_count = $mlw_qmn_section_count + 1;
$mlw_display .= "
";
$mlw_message_comments = htmlspecialchars_decode($mlw_quiz_options->message_comment, ENT_QUOTES);
- $mlw_message_comments = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_comments);
- $mlw_message_comments = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_comments);
+ $mlw_message_comments = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message_comments, $mlw_qmn_quiz_options_array);
$mlw_display .= "
";
$mlw_display .= "";
$mlw_display .= "
";
@@ -819,8 +850,7 @@ function mlw_validateForm()
if ($mlw_quiz_options->message_end_template != '')
{
$mlw_message_end = htmlspecialchars_decode($mlw_quiz_options->message_end_template, ENT_QUOTES);
- $mlw_message_end = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_end);
- $mlw_message_end = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_end);
+ $mlw_message_end = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message_end, $mlw_qmn_quiz_options_array);
$mlw_display .= "
".$mlw_message_end."";
$mlw_display .= "
";
}
@@ -1043,6 +1073,25 @@ function mlw_validateForm()
$mlw_qm_quiz_comments = "";
}
+ $mlw_qmn_result_array = array(
+ 'quiz_id' => $mlw_quiz_id,
+ 'quiz_name' => $mlw_quiz_options->quiz_name,
+ 'quiz_system' => $mlw_quiz_options->system,
+ 'total_points' => $mlw_points,
+ 'total_score' => $mlw_total_score,
+ 'total_correct' => $mlw_correct,
+ 'total_questions' => $mlw_total_questions,
+ 'user_name' => $mlw_user_name,
+ 'user_business' => $mlw_user_comp,
+ 'user_email' => $mlw_user_email,
+ 'user_phone' => $mlw_user_phone,
+ 'user_id' => get_current_user_id(),
+ 'question_answers_display' => $mlw_question_answers,
+ 'question_answers_array' => $mlw_qmn_answer_array,
+ 'timer' => $mlw_qmn_timer,
+ 'comments' => $mlw_qm_quiz_comments,
+ 'certificate_link' => ''
+ );
//Prepare Certificate
$mlw_certificate_link = "";
@@ -1054,20 +1103,7 @@ function mlw_validateForm()
if ($mlw_certificate_options[4] == 0)
{
$mlw_message_certificate = $mlw_certificate_options[1];
- $mlw_message_certificate = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_certificate);
- $mlw_message_certificate = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_certificate);
- $mlw_message_certificate = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_certificate);
- $mlw_message_certificate = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_certificate);
- $mlw_message_certificate = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_certificate);
- $mlw_message_certificate = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_certificate);
- $mlw_message_certificate = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_certificate);
- $mlw_message_certificate = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_certificate);
- $mlw_message_certificate = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_certificate);
- $mlw_message_certificate = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_certificate);
- $mlw_message_certificate = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_certificate);
- $mlw_message_certificate = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_certificate);
- $mlw_message_certificate = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_certificate);
- $mlw_message_certificate = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_certificate);
+ $mlw_message_certificate = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message_certificate, $mlw_qmn_result_array);
$mlw_message_certificate = str_replace( "\n" , "
", $mlw_message_certificate);
$mlw_plugindirpath = plugin_dir_path( __FILE__ );
$plugindirpath=plugin_dir_path( __FILE__ );
@@ -1094,7 +1130,7 @@ function mlw_validateForm()
$mlw_qmn_certificate_filename = str_replace(home_url()."/", '', plugin_dir_url( __FILE__ ))."certificates/mlw_qmn_quiz".date("YmdHis").$mlw_qmn_timer.".php";
file_put_contents($mlw_qmn_certificate_filename, $mlw_qmn_certificate_file);
$mlw_qmn_certificate_filename = plugin_dir_url( __FILE__ )."certificates/mlw_qmn_quiz".date("YmdHis").$mlw_qmn_timer.".php";
- $mlw_certificate_link = "
Download Certificate";
+ $mlw_qmn_result_array["certificate_link"] = "
Download Certificate";
}
/*
@@ -1113,21 +1149,7 @@ function mlw_validateForm()
if ($mlw_each[0] == 0 && $mlw_each[1] == 0)
{
$mlw_message_after = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
- $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
- $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
- $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
- $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
- $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
- $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
- $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
- $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
- $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
- $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
- $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
- $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
- $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
- $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
- $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
+ $mlw_message_after = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message_after, $mlw_qmn_result_array);
$mlw_message_after = str_replace( "\n" , "
", $mlw_message_after);
$mlw_display .= $mlw_message_after;
break;
@@ -1138,21 +1160,7 @@ function mlw_validateForm()
if ($mlw_quiz_options->system == 1 && $mlw_points >= $mlw_each[0] && $mlw_points <= $mlw_each[1])
{
$mlw_message_after = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
- $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
- $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
- $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
- $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
- $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
- $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
- $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
- $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
- $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
- $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
- $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
- $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
- $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
- $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
- $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
+ $mlw_message_after = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message_after, $mlw_qmn_result_array);
$mlw_message_after = str_replace( "\n" , "
", $mlw_message_after);
$mlw_display .= $mlw_message_after;
break;
@@ -1161,21 +1169,7 @@ function mlw_validateForm()
if ($mlw_quiz_options->system == 0 && $mlw_total_score >= $mlw_each[0] && $mlw_total_score <= $mlw_each[1])
{
$mlw_message_after = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
- $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
- $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
- $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
- $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
- $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
- $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
- $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
- $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
- $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
- $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
- $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
- $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
- $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
- $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
- $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
+ $mlw_message_after = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message_after, $mlw_qmn_result_array);
$mlw_message_after = str_replace( "\n" , "
", $mlw_message_after);
$mlw_display .= $mlw_message_after;
break;
@@ -1187,21 +1181,7 @@ function mlw_validateForm()
{
//Prepare the after quiz message
$mlw_message_after = htmlspecialchars_decode($mlw_quiz_options->message_after, ENT_QUOTES);
- $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
- $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
- $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
- $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
- $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
- $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
- $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
- $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
- $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
- $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
- $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
- $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
- $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
- $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
- $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
+ $mlw_message_after = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message_after, $mlw_qmn_result_array);
$mlw_message_after = str_replace( "\n" , "
", $mlw_message_after);
$mlw_display .= $mlw_message_after;
}
@@ -1217,7 +1197,7 @@ function mlw_qmn_share(network, mlw_qmn_social_text, mlw_qmn_title)
var sqShareOptions = "height=400,width=580,toolbar=0,status=0,location=0,menubar=0,directories=0,scrollbars=0,top=" + sTop + ",left=" + sLeft;
var pageUrl = window.location.href;
var pageUrlEncoded = encodeURIComponent(pageUrl);
- if (network == 1)
+ if (network == 'facebook')
{
var Url = "https://www.facebook.com/dialog/feed?"
+ "display=popup&"
@@ -1227,7 +1207,7 @@ function mlw_qmn_share(network, mlw_qmn_social_text, mlw_qmn_title)
+ "description= &"
+ "redirect_uri=http://www.mylocalwebstop.com/mlw_qmn_close.html";
}
- if (network == 2)
+ if (network == 'twitter')
{
var Url = "https://twitter.com/intent/tweet?text=" + encodeURIComponent(mlw_qmn_social_text);
}
@@ -1236,17 +1216,20 @@ function mlw_qmn_share(network, mlw_qmn_social_text, mlw_qmn_title)
}
social_media_text);
- $mlw_social_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_social_message);
- $mlw_social_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_social_message);
- $mlw_social_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_social_message);
- $mlw_social_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_social_message);
- $mlw_social_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_social_message);
- $mlw_social_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_social_message);
- $mlw_social_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_social_message);
+ //Load Social Media Text
+ $qmn_social_media_text = "";
+ $qmn_social_media_text = @unserialize($mlw_quiz_options->social_media_text);
+ if (!is_array($qmn_social_media_text)) {
+ $qmn_social_media_text = array(
+ 'twitter' => $mlw_quiz_options->social_media_text,
+ 'facebook' => $mlw_quiz_options->social_media_text
+ );
+ }
+ $qmn_social_media_text["twitter"] = apply_filters( 'mlw_qmn_template_variable_results_page', $qmn_social_media_text["twitter"], $mlw_qmn_result_array);
+ $qmn_social_media_text["facebook"] = apply_filters( 'mlw_qmn_template_variable_results_page', $qmn_social_media_text["facebook"], $mlw_qmn_result_array);
$mlw_display .= "
-
quiz_name)."');\">Facebook
-
quiz_name)."');\">Twitter
+
quiz_name)."');\">Facebook
+
quiz_name)."');\">Twitter
";
}
@@ -1275,39 +1258,13 @@ function mlw_qmn_share(network, mlw_qmn_social_text, mlw_qmn_title)
{
$mlw_each[3] = "Quiz Results For %QUIZ_NAME";
}
- $mlw_each[3] = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_each[3]);
- $mlw_each[3] = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_each[3]);
- $mlw_each[3] = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_each[3]);
- $mlw_each[3] = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_each[3]);
- $mlw_each[3] = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_each[3]);
- $mlw_each[3] = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_each[3]);
- $mlw_each[3] = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_each[3]);
- $mlw_each[3] = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_each[3]);
- $mlw_each[3] = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_each[3]);
- $mlw_each[3] = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_each[3]);
- $mlw_each[3] = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_each[3]);
- $mlw_each[3] = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_each[3]);
-
+ $mlw_each[3] = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_each[3], $mlw_qmn_result_array);
//Check to see if default
if ($mlw_each[0] == 0 && $mlw_each[1] == 0)
{
$mlw_message = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
- $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
- $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
- $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
- $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
- $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
- $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
- $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
- $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
- $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
- $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
- $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
- $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
- $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
- $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
- $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $mlw_qmn_result_array);
$mlw_message = str_replace( "\n" , "
", $mlw_message);
$mlw_message = str_replace( "
" , "
", $mlw_message);
$mlw_message = str_replace( "
" , "
", $mlw_message);
@@ -1321,21 +1278,7 @@ function mlw_qmn_share(network, mlw_qmn_social_text, mlw_qmn_title)
if ($mlw_quiz_options->system == 1 && $mlw_points >= $mlw_each[0] && $mlw_points <= $mlw_each[1])
{
$mlw_message = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
- $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
- $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
- $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
- $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
- $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
- $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
- $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
- $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
- $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
- $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
- $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
- $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
- $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
- $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
- $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $mlw_qmn_result_array);
$mlw_message = str_replace( "\n" , "
", $mlw_message);
$mlw_message = str_replace( "
" , "
", $mlw_message);
$mlw_message = str_replace( "
" , "
", $mlw_message);
@@ -1348,21 +1291,7 @@ function mlw_qmn_share(network, mlw_qmn_social_text, mlw_qmn_title)
if ($mlw_quiz_options->system == 0 && $mlw_total_score >= $mlw_each[0] && $mlw_total_score <= $mlw_each[1])
{
$mlw_message = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
- $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
- $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
- $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
- $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
- $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
- $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
- $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
- $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
- $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
- $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
- $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
- $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
- $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
- $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
- $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $mlw_qmn_result_array);
$mlw_message = str_replace( "\n" , "
", $mlw_message);
$mlw_message = str_replace( "
" , "
", $mlw_message);
$mlw_message = str_replace( "
" , "
", $mlw_message);
@@ -1376,21 +1305,7 @@ function mlw_qmn_share(network, mlw_qmn_social_text, mlw_qmn_title)
else
{
$mlw_message = htmlspecialchars_decode($mlw_quiz_options->user_email_template, ENT_QUOTES);
- $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
- $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
- $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
- $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
- $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
- $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
- $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
- $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
- $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
- $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
- $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
- $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
- $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
- $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
- $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $mlw_qmn_result_array);
$mlw_message = str_replace( "\n" , "
", $mlw_message);
$mlw_message = str_replace( "
" , "
", $mlw_message);
$mlw_message = str_replace( "
" , "
", $mlw_message);
@@ -1405,21 +1320,7 @@ function mlw_qmn_share(network, mlw_qmn_social_text, mlw_qmn_title)
if ($mlw_quiz_options->send_admin_email == "0")
{
$mlw_message = htmlspecialchars_decode($mlw_quiz_options->admin_email_template, ENT_QUOTES);
- $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
- $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
- $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
- $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
- $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
- $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
- $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
- $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
- $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
- $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
- $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
- $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
- $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
- $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
- $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $mlw_qmn_result_array);
if ( get_option('mlw_advert_shows') == 'true' ) {$mlw_message .= "
This email was generated by the Quiz Master Next script by Frank Corso";}
$mlw_message = str_replace( "\n" , "
", $mlw_message);
$mlw_message = str_replace( "
" , "
", $mlw_message);
@@ -1452,9 +1353,7 @@ function mlw_qmn_share(network, mlw_qmn_social_text, mlw_qmn_title)
{
$current_user = wp_get_current_user();
$mlw_message = htmlspecialchars_decode($mlw_quiz_options->total_user_tries_text, ENT_QUOTES);
- $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
- $mlw_message = str_replace( "%USER_NAME%" , $current_user->display_name, $mlw_message);
- $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message, $mlw_qmn_quiz_options_array);
$mlw_display .= $mlw_message;
}
elseif (isset($_POST["mlw_code_captcha"]) && $_POST["mlw_user_captcha"] != $_POST["mlw_code_captcha"])
diff --git a/includes/mlw_quiz_admin.php b/includes/mlw_quiz_admin.php
index ad97c2f48..e7f343e21 100644
--- a/includes/mlw_quiz_admin.php
+++ b/includes/mlw_quiz_admin.php
@@ -66,10 +66,113 @@ function mlw_generate_quiz_admin()
margin: auto;
}";
$mlw_question_answer_default = "%QUESTION%
Answer Provided: %USER_ANSWER%
Correct Answer: %CORRECT_ANSWER%
Comments Entered: %USER_COMMENTS%
";
- $insert = "INSERT INTO " . $table_name .
- "(quiz_id, quiz_name, message_before, message_after, message_comment, message_end_template, user_email_template, admin_email_template, submit_button_text, name_field_text, business_field_text, email_field_text, phone_field_text, comment_field_text, email_from_text, question_answer_template, leaderboard_template, system, randomness_order, loggedin_user_contact, show_score, send_user_email, send_admin_email, contact_info_location, user_name, user_comp, user_email, user_phone, admin_email, comment_section, question_from_total, total_user_tries, total_user_tries_text, certificate_template, social_media, social_media_text, pagination, pagination_text, timer_limit, quiz_stye, question_numbering, quiz_settings, theme_selected, last_activity, quiz_views, quiz_taken, deleted) " .
- "VALUES (NULL , '" . $quiz_name . "' , 'Enter your text here', 'Enter your text here', 'Enter your text here', '', 'Enter your text here', 'Enter your text here', 'Submit Quiz', 'Name', 'Business', 'Email', 'Phone Number', 'Comments', 'Wordpress', '".$mlw_question_answer_default."', '".$mlw_leaderboard_default."', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '".get_option( 'admin_email', 'Enter email' )."', 0, 0, 0, 'Enter Your Text Here', 'Enter Your Text Here!', 0, 'I just score a %CORRECT_SCORE%% on %QUIZ_NAME%!', 0, 'Next', 0, '".$mlw_style_default."', 0, '', 'default', '".date("Y-m-d H:i:s")."', 0, 0, 0)";
- $results = $wpdb->query( $insert );
+ $results = $wpdb->insert(
+ $wpdb->prefix . "mlw_quizzes",
+ array(
+ 'quiz_name' => $quiz_name,
+ 'message_before' => 'Enter your text here',
+ 'message_after' => 'Enter your text here',
+ 'message_comment' => 'Enter your text here',
+ 'message_end_template' => '',
+ 'user_email_template' => 'Enter your text here',
+ 'admin_email_template' => 'Enter your text here',
+ 'submit_button_text' => 'Submit Quiz',
+ 'name_field_text' => 'Name',
+ 'business_field_text' => 'Business',
+ 'email_field_text' => 'Email',
+ 'phone_field_text' => 'Phone Number',
+ 'comment_field_text' => 'Comments',
+ 'email_from_text' => 'Wordpress',
+ 'question_answer_template' => $mlw_question_answer_default,
+ 'leaderboard_template' => $mlw_leaderboard_default,
+ 'system' => 0,
+ 'randomness_order' => 0,
+ 'loggedin_user_contact' => 0,
+ 'show_score' => 0,
+ 'send_user_email' => 0,
+ 'send_admin_email' => 0,
+ 'contact_info_location' => 0,
+ 'user_name' => 0,
+ 'user_comp' => 0,
+ 'user_email' => 0,
+ 'user_phone' => 0,
+ 'admin_email' => get_option( 'admin_email', 'Enter email' ),
+ 'comment_section' => 0,
+ 'question_from_total' => 0,
+ 'total_user_tries' => 0,
+ 'total_user_tries_text' => 'Enter Your Text Here',
+ 'certificate_template' => 'Enter Your Text Here!',
+ 'social_media' => 0,
+ 'social_media_text' => 'I just scored %CORRECT_SCORE%% on %QUIZ_NAME%!',
+ 'pagination' => 0,
+ 'pagination_text' => 'Next',
+ 'timer_limit' => 0,
+ 'quiz_stye' => $mlw_style_default,
+ 'question_numbering' => 0,
+ 'quiz_settings' => '',
+ 'theme_selected' => 'default',
+ 'last_activity' => date("Y-m-d H:i:s"),
+ 'require_log_in' => 0,
+ 'require_log_in_text' => 'Enter Your Text Here',
+ 'limit_total_entries' => 0,
+ 'limit_total_entries_text' => 'Enter Your Text Here',
+ 'quiz_views' => 0,
+ 'quiz_taken' => 0,
+ 'deleted' => 0
+ ),
+ array(
+ '%s',
+ '%s',
+ '%s',
+ '%s',
+ '%s',
+ '%s',
+ '%s',
+ '%s',
+ '%s',
+ '%s',
+ '%s',
+ '%s',
+ '%s',
+ '%s',
+ '%s',
+ '%s',
+ '%d',
+ '%d',
+ '%d',
+ '%d',
+ '%d',
+ '%d',
+ '%d',
+ '%d',
+ '%d',
+ '%d',
+ '%d',
+ '%s',
+ '%d',
+ '%d',
+ '%d',
+ '%s',
+ '%s',
+ '%d',
+ '%s',
+ '%d',
+ '%s',
+ '%d',
+ '%s',
+ '%d',
+ '%s',
+ '%s',
+ '%s',
+ '%d',
+ '%s',
+ '%d',
+ '%s',
+ '%d',
+ '%d',
+ '%d'
+ )
+ );
if ($results != false)
{
$mlwQmnAlertManager->newAlert('Your new quiz has been created successfully. To begin editing your quiz, click the Edit link on the new quiz.', 'success');
diff --git a/includes/mlw_quiz_options.php b/includes/mlw_quiz_options.php
index 9e52b9a5a..b2bf9afce 100644
--- a/includes/mlw_quiz_options.php
+++ b/includes/mlw_quiz_options.php
@@ -923,7 +923,6 @@ function mlw_options_text_tab_content()
//Variables for save templates form
$mlw_before_message = htmlspecialchars($_POST["mlw_quiz_before_message"], ENT_QUOTES);
$mlw_qmn_message_end = htmlspecialchars($_POST["message_end_template"], ENT_QUOTES);
- $mlw_qmn_social_medi_text = htmlspecialchars($_POST["mlw_quiz_social_media_text_template"], ENT_QUOTES);
$mlw_user_tries_text = htmlspecialchars($_POST["mlw_quiz_total_user_tries_text"], ENT_QUOTES);
$mlw_submit_button_text = htmlspecialchars($_POST["mlw_submitText"], ENT_QUOTES);
$mlw_name_field_text = htmlspecialchars($_POST["mlw_nameText"], ENT_QUOTES);
@@ -935,11 +934,12 @@ function mlw_options_text_tab_content()
$mlw_require_log_in_text = htmlspecialchars($_POST["mlw_require_log_in_text"], ENT_QUOTES);
$mlw_limit_total_entries_text = htmlspecialchars($_POST["mlw_limit_total_entries_text"], ENT_QUOTES);
$mlw_qmn_pagination_field = serialize(array( $_POST["pagination_prev_text"], $_POST["pagination_next_text"] ));
+ $qmn_social_media_text = serialize(array('twitter' => $_POST["mlw_quiz_twitter_text_template"], 'facebook' => $_POST["mlw_quiz_facebook_text_template"]));
$mlw_email_from_text = $_POST["emailFromText"];
$mlw_question_answer_template = htmlspecialchars($_POST["mlw_quiz_question_answer_template"], ENT_QUOTES);
$quiz_id = $_POST["quiz_id"];
- $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET message_before='".$mlw_before_message."', message_comment='".$mlw_before_comments."', message_end_template='".$mlw_qmn_message_end."', comment_field_text='".$mlw_comment_field_text."', email_from_text='".$mlw_email_from_text."', question_answer_template='".$mlw_question_answer_template."', submit_button_text='".$mlw_submit_button_text."', name_field_text='".$mlw_name_field_text."', business_field_text='".$mlw_business_field_text."', email_field_text='".$mlw_email_field_text."', phone_field_text='".$mlw_phone_field_text."', total_user_tries_text='".$mlw_user_tries_text."', social_media_text='".$mlw_qmn_social_medi_text."', pagination_text='".$mlw_qmn_pagination_field."', require_log_in_text='".$mlw_require_log_in_text."', limit_total_entries_text='".$mlw_limit_total_entries_text."', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$quiz_id;
+ $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET message_before='".$mlw_before_message."', message_comment='".$mlw_before_comments."', message_end_template='".$mlw_qmn_message_end."', comment_field_text='".$mlw_comment_field_text."', email_from_text='".$mlw_email_from_text."', question_answer_template='".$mlw_question_answer_template."', submit_button_text='".$mlw_submit_button_text."', name_field_text='".$mlw_name_field_text."', business_field_text='".$mlw_business_field_text."', email_field_text='".$mlw_email_field_text."', phone_field_text='".$mlw_phone_field_text."', total_user_tries_text='".$mlw_user_tries_text."', social_media_text='".$qmn_social_media_text."', pagination_text='".$mlw_qmn_pagination_field."', require_log_in_text='".$mlw_require_log_in_text."', limit_total_entries_text='".$mlw_limit_total_entries_text."', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$quiz_id;
$results = $wpdb->query( $update );
if ($results != false)
{
@@ -967,11 +967,21 @@ function mlw_options_text_tab_content()
}
//Load Pagination Text
- $mlw_qmn_pagination_text = "";
+ $mlw_qmn_pagination_text = "";
$mlw_qmn_pagination_text = @unserialize($mlw_quiz_options->pagination_text);
if (!is_array($mlw_qmn_pagination_text)) {
- $mlw_qmn_pagination_text = array('Previous', $mlw_quiz_options->pagination_text);
- }
+ $mlw_qmn_pagination_text = array('Previous', $mlw_quiz_options->pagination_text);
+ }
+
+ //Load Social Media Text
+ $qmn_social_media_text = "";
+ $qmn_social_media_text = @unserialize($mlw_quiz_options->social_media_text);
+ if (!is_array($qmn_social_media_text)) {
+ $qmn_social_media_text = array(
+ 'twitter' => $mlw_quiz_options->social_media_text,
+ 'facebook' => $mlw_quiz_options->social_media_text
+ );
+ }
?>
Template Variables
@@ -1117,7 +1127,24 @@ function mlw_options_text_tab_content()
- Social Media Sharing Text
+ Twitter Sharing Text
+
+ Allowed Variables:
+ - %POINT_SCORE%
+ - %AVERAGE_POINT%
+ - %AMOUNT_CORRECT%
+ - %TOTAL_QUESTIONS%
+ - %CORRECT_SCORE%
+ - %QUIZ_NAME%
+ - %TIMER%
+ - %CURRENT_DATE%
+ |
+
+ |
+
+
+
+ Facebook Sharing Text
Allowed Variables:
- %POINT_SCORE%
@@ -1129,7 +1156,7 @@ function mlw_options_text_tab_content()
- %TIMER%
- %CURRENT_DATE%
|
-
+ |
|
diff --git a/includes/mlw_results.php b/includes/mlw_results.php
index d49248351..899cd104e 100644
--- a/includes/mlw_results.php
+++ b/includes/mlw_results.php
@@ -151,7 +151,12 @@ function deleteResults(id,quizName){
$mlw_qmn_results_array = @unserialize($mlw_quiz_info->quiz_results);
if (is_array($mlw_qmn_results_array))
{
- $mlw_complete_minutes = floor($mlw_qmn_results_array[0] / 60);
+ $mlw_complete_hours = floor($mlw_qmn_results_array[0] / 3600);
+ if ($mlw_complete_hours > 0)
+ {
+ $mlw_complete_time .= "$mlw_complete_hours hours ";
+ }
+ $mlw_complete_minutes = floor(($mlw_qmn_results_array[0] % 3600) / 60);
if ($mlw_complete_minutes > 0)
{
$mlw_complete_time .= "$mlw_complete_minutes minutes ";
@@ -246,4 +251,4 @@ function deleteResults(id,quizName){
\ No newline at end of file
+?>
diff --git a/includes/mlw_results_details.php b/includes/mlw_results_details.php
index c29091380..efdf405b8 100644
--- a/includes/mlw_results_details.php
+++ b/includes/mlw_results_details.php
@@ -186,7 +186,12 @@ function mlw_generate_result_details()
else
{
$mlw_complete_time = '';
- $mlw_complete_minutes = floor($mlw_qmn_results_array[0] / 60);
+ $mlw_complete_hours = floor($mlw_qmn_results_array[0] / 3600);
+ if ($mlw_complete_hours > 0)
+ {
+ $mlw_complete_time .= "$mlw_complete_hours hours ";
+ }
+ $mlw_complete_minutes = floor(($mlw_qmn_results_array[0] % 3600) / 60);
if ($mlw_complete_minutes > 0)
{
$mlw_complete_time .= "$mlw_complete_minutes minutes ";
@@ -310,4 +315,4 @@ function mlw_generate_result_details()
\ No newline at end of file
+?>
diff --git a/includes/mlw_template_variables.php b/includes/mlw_template_variables.php
new file mode 100644
index 000000000..2669835a6
--- /dev/null
+++ b/includes/mlw_template_variables.php
@@ -0,0 +1,128 @@
+ $mlw_quiz_id,
+ 'quiz_name' => $mlw_quiz_options->quiz_name,
+ 'quiz_system' => $mlw_quiz_options->system,
+ 'total_points' => $mlw_points,
+ 'total_score' => $mlw_total_score,
+ 'total_correct' => $mlw_correct,
+ 'total_questions' => $mlw_total_questions,
+ 'user_name' => $mlw_user_name,
+ 'user_business' => $mlw_user_comp,
+ 'user_email' => $mlw_user_email,
+ 'user_phone' => $mlw_user_phone,
+ 'user_id' => get_current_user_id(),
+ 'question_answers_display' => $mlw_question_answers,
+ 'question_answers_array' => $mlw_qmn_answer_array,
+ 'timer' => $mlw_qmn_timer,
+ 'comments' => $mlw_qm_quiz_comments,
+ 'certificate_link' => CERTIFICATE LINK
+ );
+
+*/
+add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_point_score',10,2);
+add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_average_point',10,2);
+add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_amount_correct',10,2);
+add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_total_questions',10,2);
+add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_correct_score',10,2);
+add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_quiz_name',10,2);
+add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_name',10,2);
+add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_business',10,2);
+add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_phone',10,2);
+add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_email',10,2);
+add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_question_answers',10,2);
+add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_comments',10,2);
+add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_timer',10,2);
+add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_date',10,2);
+add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_certificate_link',10,2);
+
+add_filter('mlw_qmn_template_variable_quiz_page', 'mlw_qmn_variable_quiz_name',10,2);
+add_filter('mlw_qmn_template_variable_quiz_page', 'mlw_qmn_variable_date',10,2);
+add_filter('mlw_qmn_template_variable_quiz_page', 'mlw_qmn_variable_current_user',10,2);
+function mlw_qmn_variable_point_score($content, $mlw_quiz_array)
+{
+ $content = str_replace( "%POINT_SCORE%" , $mlw_quiz_array["total_points"], $content);
+ return $content;
+}
+function mlw_qmn_variable_average_point($content, $mlw_quiz_array)
+{
+ $mlw_average_points = $mlw_quiz_array["total_points"]/$mlw_quiz_array["total_questions"];
+ $content = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $content);
+ return $content;
+}
+function mlw_qmn_variable_amount_correct($content, $mlw_quiz_array)
+{
+ $content = str_replace( "%AMOUNT_CORRECT%" , $mlw_quiz_array["total_correct"], $content);
+ return $content;
+}
+function mlw_qmn_variable_total_questions($content, $mlw_quiz_array)
+{
+ $content = str_replace( "%TOTAL_QUESTIONS%" , $mlw_quiz_array["total_questions"], $content);
+ return $content;
+}
+function mlw_qmn_variable_correct_score($content, $mlw_quiz_array)
+{
+ $content = str_replace( "%CORRECT_SCORE%" , $mlw_quiz_array["total_score"], $content);
+ return $content;
+}
+function mlw_qmn_variable_quiz_name($content, $mlw_quiz_array)
+{
+ $content = str_replace( "%QUIZ_NAME%" , $mlw_quiz_array["quiz_name"], $content);
+ return $content;
+}
+function mlw_qmn_variable_user_name($content, $mlw_quiz_array)
+{
+ $content = str_replace( "%USER_NAME%" , $mlw_quiz_array["user_name"], $content);
+ return $content;
+}
+function mlw_qmn_variable_current_user($content, $mlw_quiz_array)
+{
+ $current_user = wp_get_current_user();
+ $content = str_replace( "%USER_NAME%" , $current_user->display_name, $content);
+ return $content;
+}
+function mlw_qmn_variable_user_business($content, $mlw_quiz_array)
+{
+ $content = str_replace( "%USER_BUSINESS%" , $mlw_quiz_array["user_business"], $content);
+ return $content;
+}
+function mlw_qmn_variable_user_phone($content, $mlw_quiz_array)
+{
+ $content = str_replace( "%USER_PHONE%" , $mlw_quiz_array["user_phone"], $content);
+ return $content;
+}
+function mlw_qmn_variable_user_email($content, $mlw_quiz_array)
+{
+ $content = str_replace( "%USER_EMAIL%" , $mlw_quiz_array["user_email"], $content);
+ return $content;
+}
+function mlw_qmn_variable_question_answers($content, $mlw_quiz_array)
+{
+ $content = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_quiz_array["question_answers_display"], $content);
+ return $content;
+}
+function mlw_qmn_variable_comments($content, $mlw_quiz_array)
+{
+ $content = str_replace( "%COMMENT_SECTION%" , $mlw_quiz_array["comments"], $content);
+ return $content;
+}
+function mlw_qmn_variable_timer($content, $mlw_quiz_array)
+{
+ $content = str_replace( "%TIMER%" , $mlw_quiz_array["timer"], $content);
+ return $content;
+}
+function mlw_qmn_variable_date($content, $mlw_quiz_array)
+{
+ $content = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $content);
+ return $content;
+}
+function mlw_qmn_variable_certificate_link($content, $mlw_quiz_array)
+{
+ $content = str_replace( "%CERTIFICATE_LINK%" , $mlw_quiz_array["certificate_link"], $content);
+ return $content;
+}
+?>
diff --git a/includes/mlw_update.php b/includes/mlw_update.php
index 6322db5b1..74e793833 100644
--- a/includes/mlw_update.php
+++ b/includes/mlw_update.php
@@ -6,7 +6,7 @@ function mlw_quiz_update()
{
//Update this variable each update. This is what is checked when the plugin is deciding to run the upgrade script or not.
- $data = "3.5.2";
+ $data = "3.6.1";
if ( ! get_option('mlw_quiz_master_version'))
{
add_option('mlw_quiz_master_version' , $data);
diff --git a/mlw_quizmaster2.php b/mlw_quizmaster2.php
index 06388ca4f..96238fe81 100644
--- a/mlw_quizmaster2.php
+++ b/mlw_quizmaster2.php
@@ -3,7 +3,7 @@
/*
Plugin Name: Quiz Master Next
Description: Use this plugin to add multiple quizzes, tests, or surveys to your website.
-Version: 3.5.2
+Version: 3.6.1
Author: Frank Corso
Author URI: http://www.mylocalwebstop.com/
Plugin URI: http://www.mylocalwebstop.com/
@@ -20,175 +20,108 @@
You understand that you install, operate, and unistall the plugin at your own discretion and risk.
*/
-
-///Files to Include
-include("includes/mlw_alerts.php");
-include("includes/mlw_quiz.php");
-include("includes/mlw_dashboard.php");
-include("includes/mlw_quiz_admin.php");
-include("includes/mlw_quiz_options.php");
-include("includes/mlw_quiz_install.php");
-include("includes/mlw_results.php");
-include("includes/mlw_results_details.php");
-include("includes/mlw_tools.php");
-include("includes/mlw_leaderboard.php");
-include("includes/mlw_update.php");
-include("includes/mlw_qmn_widgets.php");
-include("includes/mlw_qmn_credits.php");
-
-
-///Activation Actions
-add_action('admin_menu', 'mlw_add_menu');
-add_action('admin_init', 'mlw_quiz_update');
-add_action('widgets_init', create_function('', 'return register_widget("Mlw_Qmn_Leaderboard_Widget");'));
-add_shortcode('mlw_quizmaster', 'mlw_quiz_shortcode');
-add_shortcode('mlw_quizmaster_leaderboard', 'mlw_quiz_leaderboard_shortcode');
-register_activation_hook( __FILE__, 'mlw_quiz_activate');
-register_deactivation_hook( __FILE__, 'mlw_quiz_deactivate');
-
-//Setup Translations
-function mlw_qmn_translation_setup() {
- load_plugin_textdomain( 'mlw_qmn_text_domain', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
-}
-add_action('plugins_loaded', 'mlw_qmn_translation_setup');
-
-
-///Create Admin Pages
-function mlw_add_menu()
+/**
+ * This class is the main class of the plugin
+ *
+ * When loaded, it loads the included plugin files and add functions to hooks or filters. The class also handles the admin menu
+ *
+ * @since 3.6.1
+ */
+class MLWQuizMasterNext
{
- if (function_exists('add_menu_page'))
+ /**
+ * Main Construct Function
+ *
+ * Call functions within class
+ *
+ * @since 3.6.1
+ * @uses MLWQuizMasterNext::load_dependencies() Loads required filed
+ * @uses MLWQuizMasterNext::add_hooks() Adds actions to hooks and filters
+ * @return void
+ */
+ public function __construct()
{
- add_menu_page('Quiz Master Next', 'Quiz Dashboard', 'moderate_comments', __FILE__, 'mlw_generate_quiz_dashboard', 'dashicons-feedback');
- add_submenu_page(__FILE__, 'Quizzes', 'Quizzes', 'moderate_comments', 'mlw_quiz_admin', 'mlw_generate_quiz_admin');
- add_submenu_page(__FILE__, 'Quiz Settings', 'Quiz Settings', 'moderate_comments', 'mlw_quiz_options', 'mlw_generate_quiz_options');
- add_submenu_page(__FILE__, 'Quiz Results', 'Quiz Results', 'moderate_comments', 'mlw_quiz_results', 'mlw_generate_quiz_results');
- add_submenu_page(__FILE__, 'Quiz Result Details', 'Quiz Result Details', 'moderate_comments', 'mlw_quiz_result_details', 'mlw_generate_result_details');
- add_submenu_page(__FILE__, 'Tools', 'Tools', 'manage_options', 'mlw_quiz_tools', 'mlw_generate_quiz_tools');
- add_submenu_page(__FILE__, 'QMN About', 'QMN About', 'manage_options', 'mlw_qmn_about', 'mlw_generate_about_page');
- }
-}
-
-
-//Admin Notice
-add_action('admin_notices', 'mlw_qmn_notice');
-function mlw_qmn_notice() {
- if ( get_option('mlw_qmn_review_notice') == 1 && current_user_can( 'manage_options' ) )
- {
- echo "
- ";
- echo '
';
- printf(__('You have been using the Quiz Master Next plugin for a while now! Thanks for choosing to use this plugin. If it has benefited your website, please consider purchasing an add-on, giving a review, or taking this survey. | Hide Notice'), '?page=quiz-master-next/mlw_quizmaster2.php&&mlw_qmn_ignore_notice=0');
- echo "
";
+ $this->load_dependencies();
+ $this->add_hooks();
}
-}
-//Check to see if notices should be shown or dismissed
-add_action('admin_init', 'mlw_qmn_notice_ignore');
-function mlw_qmn_notice_ignore() {
- global $wpdb;
- if ( ! get_option('mlw_qmn_review_notice'))
+
+ /**
+ * Load File Dependencies
+ *
+ * @since 3.6.1
+ * @return void
+ */
+ private function load_dependencies()
{
- add_option('mlw_qmn_review_notice' , '0');
+ include("includes/mlw_quiz.php");
+ include("includes/mlw_dashboard.php");
+ include("includes/mlw_quiz_admin.php");
+ include("includes/mlw_quiz_options.php");
+ include("includes/mlw_quiz_install.php");
+ include("includes/mlw_results.php");
+ include("includes/mlw_results_details.php");
+ include("includes/mlw_tools.php");
+ include("includes/mlw_leaderboard.php");
+ include("includes/mlw_update.php");
+ include("includes/mlw_qmn_widgets.php");
+ include("includes/mlw_qmn_credits.php");
+ include("includes/mlw_template_variables.php");
+ include("includes/mlw_adverts.php");
}
- if ($wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_results" ) >= 20 && get_option('mlw_qmn_review_notice') == 0)
+
+ /**
+ * Add Hooks
+ *
+ * Adds functions to relavent hooks and filters
+ *
+ * @since 3.6.1
+ * @return void
+ */
+ private function add_hooks()
{
- update_option('mlw_qmn_review_notice' , '1');
+ add_action('admin_menu', array( $this, 'setup_admin_menu'));
+ add_action('admin_init', 'mlw_quiz_update');
+ add_action('widgets_init', create_function('', 'return register_widget("Mlw_Qmn_Leaderboard_Widget");'));
+ add_shortcode('mlw_quizmaster', 'mlw_quiz_shortcode');
+ add_shortcode('mlw_quizmaster_leaderboard', 'mlw_quiz_leaderboard_shortcode');
+ add_action('plugins_loaded', array( $this, 'setup_translations'));
}
- if ( isset($_GET['mlw_qmn_ignore_notice']) && '0' == $_GET['mlw_qmn_ignore_notice'] ) {
- update_option('mlw_qmn_review_notice' , '2');
- }
-}
-function mlw_qmn_show_adverts()
-{
- $mlw_advert = "";
- $mlw_advert_text = "";
- if ( get_option('mlw_advert_shows') == 'true' )
+
+ /**
+ * Setup Admin Menu
+ *
+ * Creates the admin menu and pages for the plugin and attaches functions to them
+ *
+ * @since 3.6.1
+ * @return void
+ */
+ public function setup_admin_menu()
{
- $mlw_random_int = rand(0, 8);
- switch ($mlw_random_int) {
- case 0:
- $mlw_advert_text = "Need support or features? Check out our Premium Support options! Visit our
WordPress Store for details!";
- break;
- case 1:
- $mlw_advert_text = "Is Quiz Master Next beneficial to your website? Please help by giving us a review on WordPress.org by going
here!";
- break;
- case 2:
- $mlw_advert_text = "Want help installing and configuring one of our plugins? Check out our Plugin Installation services. Visit our
WordPress Store for details!";
- break;
- case 3:
- $mlw_advert_text = "Would you like to support this plugin but do not need or want premium support? Please consider our inexpensive 'Advertisements Be Gone' add-on which will get rid of these ads. Visit our
Plugin Add-On Store for details!";
- break;
- case 4:
- $mlw_advert_text = "Need to be able to export the results of your quizzes? Be sure to check out our new Export Results add-on in our
WordPress Store!";
- break;
- case 5:
- $mlw_advert_text = "Need help keeping your plugins, themes, and WordPress up to date? Want around the clock security monitoring and off-site back-ups? How about WordPress training videos, a monthly status report, and support/consultation? Check out our
WordPress Maintenance Services for more details!";
- break;
- case 6:
- $mlw_advert_text = "Setting up a new site? Let us take care of the set-up so you back to running your business. Check out our
WordPress Store for more details!";
- break;
- case 7:
- $mlw_advert_text = "Need a page so your users can see their results from all the quizzes they have taken? Try our new User Dashboard add-on. Check out our
WordPress Store for more details!";
- break;
- case 8:
- $mlw_advert_text = "Our new Popular Add-On Pack is now only $45 for 6 add-ons! Now is the time to save almost 50%! Visit our
WordPress Store for details.";
- break;
- default:
- $mlw_advert_text = "Need support or features? Check out our Premium Support options! Visit our
Plugin Add-On Store for details!";
+ if (function_exists('add_menu_page'))
+ {
+ add_menu_page('Quiz Master Next', 'Quiz Dashboard', 'moderate_comments', __FILE__, 'mlw_generate_quiz_dashboard', 'dashicons-feedback');
+ add_submenu_page(__FILE__, 'Quizzes', 'Quizzes', 'moderate_comments', 'mlw_quiz_admin', 'mlw_generate_quiz_admin');
+ add_submenu_page(__FILE__, 'Quiz Settings', 'Quiz Settings', 'moderate_comments', 'mlw_quiz_options', 'mlw_generate_quiz_options');
+ add_submenu_page(__FILE__, 'Quiz Results', 'Quiz Results', 'moderate_comments', 'mlw_quiz_results', 'mlw_generate_quiz_results');
+ add_submenu_page(__FILE__, 'Quiz Result Details', 'Quiz Result Details', 'moderate_comments', 'mlw_quiz_result_details', 'mlw_generate_result_details');
+ add_submenu_page(__FILE__, 'Tools', 'Tools', 'manage_options', 'mlw_quiz_tools', 'mlw_generate_quiz_tools');
+ add_submenu_page(__FILE__, 'QMN About', 'QMN About', 'manage_options', 'mlw_qmn_about', 'mlw_generate_about_page');
}
- $mlw_advert .= "
- ";
- $mlw_advert .= "
-
";
}
- return $mlw_advert;
+
+ /**
+ * Loads the plugin language files
+ *
+ * @since 3.6.1
+ * @return void
+ */
+ public function setup_translations()
+ {
+ load_plugin_textdomain( 'mlw_qmn_text_domain', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
+ }
}
-
-
-/*
-
-
-*/
+$mlwQuizMasterNext = new MLWQuizMasterNext();
+include("includes/mlw_alerts.php");
+register_activation_hook( __FILE__, 'mlw_quiz_activate');
?>
diff --git a/readme.txt b/readme.txt
index cc37279e1..d0a1f3266 100644
--- a/readme.txt
+++ b/readme.txt
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
Tags: quiz, test, score, exam, survey, contact, form, email, answer, question
Requires at least: 3.8.1
Tested up to: 4.0
-Stable tag: 3.5.2
+Stable tag: 3.6.1
License URI: http://www.gnu.org/licenses/gpl-2.0.html
The easiest and most flexible way to add multiple quizzes, tests, and surveys to your website.
@@ -109,6 +109,13 @@ Feel free to use the widget on the quiz dashboard within the plugin or from the
== Changelog ==
+= 3.6.1 (December 2, 2014) =
+ * Add Separate Social Network Text Templates
+ * Added Hours Field To Timer And Completion Time
+ * Converted Quizzes Page To Use wpdb->update And wpdb->insert Instead Of query
+ * Created New Filter For Creating New Variables For Quiz Page
+ * Created New Filter For Creating New Variables For Results Page
+
= 3.5.2 (November 26, 2014) =
* Bug Fix For Some Bugs Resulting In Error Code 0008
@@ -549,6 +556,9 @@ Feel free to use the widget on the quiz dashboard within the plugin or from the
== Upgrade Notice ==
+= 3.6.1 =
+Upgrade for many backend upgrades
+
= 3.5.2 =
Upgrade for minor bug fixes