--- a/hd-quiz/assets/block/render.php
+++ b/hd-quiz/assets/block/render.php
@@ -4,7 +4,7 @@
* @see https://github.com/WordPress/gutenberg/blob/trunk/docs/reference-guides/block-api/block-metadata.md#render
*/
-$quizId = intval($attributes["quizId"]);
+$quizId = intval($attributes["quizId"] ?? 0);
if ($quizId > 0) {
echo do_shortcode('[HDquiz quiz = "' . esc_attr($quizId) . '"]');
} else {
--- a/hd-quiz/classes/dashboard.php
+++ b/hd-quiz/classes/dashboard.php
@@ -5,7 +5,7 @@
public $fields = array();
public $settings = array();
- function __construct($flat = false)
+ function __construct()
{
$this->settings();
$this->fields();
--- a/hd-quiz/classes/question.php
+++ b/hd-quiz/classes/question.php
@@ -364,7 +364,7 @@
return $res;
}
- $res = $this->validateAccess($this->data);
+ $res = $this->validateAccess();
if ($res !== false) {
return $res;
@@ -396,7 +396,7 @@
return $res;
}
- $res = $this->validateAccess($this->data);
+ $res = $this->validateAccess();
if ($res !== false) {
return $res;
}
@@ -503,7 +503,7 @@
return $res;
}
- $res = $this->validateAccess($this->data);
+ $res = $this->validateAccess();
if ($res !== false) {
return $res;
}
--- a/hd-quiz/classes/quiz.php
+++ b/hd-quiz/classes/quiz.php
@@ -620,7 +620,7 @@
return $res;
}
- $res = $this->validateAccess($this->data);
+ $res = $this->validateAccess();
if ($res !== false) {
return $res;
@@ -857,7 +857,7 @@
$this->term = get_term($this->quiz_id, "quiz");
- $res = $this->validateAccess($this->data);
+ $res = $this->validateAccess();
if ($res !== false) {
return $res;
}
--- a/hd-quiz/hdfields/classes/fields.php
+++ b/hd-quiz/hdfields/classes/fields.php
@@ -189,7 +189,7 @@
}
$html .= '<div id = "hd_tab_content_' . esc_attr($tab["id"]) . '" class = "hd_tab_content_section ' . $active . '">';
$html .= '<h2 class="hd_tab_heading">' . esc_html($tab["label"]) . '</h2>';
- $html .= $this->render_fields($tab["children"], $tab["id"]);
+ $html .= $this->render_fields($tab["children"]);
$html .= '</div>';
$i++;
}
--- a/hd-quiz/includes/actions-ajax.php
+++ b/hd-quiz/includes/actions-ajax.php
@@ -118,6 +118,9 @@
function hdq_get_question_type()
{
+ if (!hdq_user_permission()) {
+ die();
+ }
$question_type = "";
if (isset($_POST["question_type"])) {
$question_type = sanitize_text_field($_POST["question_type"]);
@@ -127,7 +130,7 @@
if (isset($_POST["quiz_id"])) {
$quiz_id = intval($_POST["quiz_id"]);
}
-
+
$question_id = 0;
if (isset($_POST["question_id"])) {
$question_id = intval($_POST["question_id"]);
--- a/hd-quiz/includes/share-page.php
+++ b/hd-quiz/includes/share-page.php
@@ -1,160 +0,0 @@
-<?php
-/*
- Experimental template for Facebook sharing
- This template will show for any page that has a permalink structure of ./hd-quiz/*
-*/
-
-$quizId = 0;
-if (isset($_GET["quiz_id"])) {
- $quizId = intval($_GET["quiz_id"]);
-}
-
-if ($quizId === 0) {
- die("No quiz ID was provided for this share dialogue");
-}
-
-$permalink = null;
-if (isset($_GET["permalink"])) {
- $permalink = sanitize_url($_GET["permalink"]);
-}
-if ($permalink === null) {
- die("Incorrect share link does not contain permlaink of quiz");
-}
-
-$pageId = url_to_postid($permalink);
-$image = get_the_post_thumbnail_url($pageId);
-
-$score = "";
-
-// Get HDQ Settings
-$settings = new _hdq_settings();
-$settings = $settings->data;
-$share_text = $settings["share_text"]["value"];
-$share_text_personality = $settings["share_text_personality"]["value"];
-$quiz_start_text = $settings["translate_quiz_start"]["value"];
-
-// Get Quiz Settings
-$quiz = new _hdq_quiz($quizId);
-if ($quiz->term == "") {
- die("Quiz no longer exists");
-}
-$quiz_name = $quiz->quiz_name;
-$quiz_type = $quiz->quiz_type;
-
-$title = "";
-if ($quiz_type != "personality") {
- $title = $share_text;
- if (isset($_GET["score"])) {
- // I know this is extra, but doing it this way in case anyone ever
- // needs to modify how the score is presented and this forces clean data
- $score = array();
- $scoreStr = sanitize_text_field($_GET["score"]);
- $scoreArr = explode(",", $scoreStr);
- $scoreArr = array_map("intval", $scoreArr);
- array_push($score, $scoreArr[0]);
- array_push($score, $scoreArr[1]);
- $score = $score[0] . '/' . $score[1];
- }
-
- $title = str_replace("%score%", '<span>' . $score . '</span>', $title);
-} else {
- $title = $share_text_personality;
-
- if (isset($_GET["score"])) {
- $score = sanitize_text_field($_GET["score"]);
- }
- $title = str_replace("%score%", '<span>' . $score . '</span>', $title);
-}
-$title = str_replace("%quiz%", '<span>' . $quiz_name . '</span>', $title);
-
-
-?>
-<!DOCTYPE html>
-<html lang="en-US">
-
-<head>
- <meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1" />
- <meta name='robots' content='max-image-preview:large' />
- <title>HD Quiz Share Results</title>
- <meta name="generator" content="HD Quiz - Free WordPress quiz builder" />
- <meta property="og:type" content="website" />
- <meta property="og:title" content="<?php echo $quiz_name . ' | ' . get_bloginfo('name'); ?>" />
- <meta property="og:description" content="<?php echo esc_attr(sanitize_text_field($title)); ?> #hdquiz" />
- <meta property="og:image" content="<?php echo $image; ?>" />
-
- <style>
- html,
- body {
- margin: 0;
- padding: 0;
- background-color: #fefefe;
- color: #222;
- line-height: 1.2;
- font-size: 18px;
- }
-
- #hd_quiz_share_wrapper {
- max-width: 600px;
- margin-top: 4rem;
- margin-left: auto;
- margin-right: auto;
- border: 2px solid #eee;
- padding: 2rem;
- box-shadow: 0 0 22px #ddd, 0 0 22px #fff;
- }
-
- #hdq_view_quiz_button {
- text-align: center;
- display: inline-block;
- }
-
- #hd_quiz_share_wrapper>h1 {
- margin: 0 0 1em 0;
- padding: 0;
- color: #444;
- font-weight: normal;
- }
-
- #hd_quiz_share_wrapper>h1>span {
- color: #222;
- font-weight: bold;
- }
-
- #hd_quiz_share_wrapper>p {
- margin: 0
- }
-
- #hd_quiz_share_wrapper>p>a {
- text-decoration: none;
- color: #fff;
- background-color: #222;
- padding: 1em;
- line-height: 1;
- }
-
- #featured_image_wrapper>img {
- display: block;
- max-width: 100%;
- margin-bottom: 1rem;
- }
- </style>
-</head>
-
-<body>
- <main id="hd_quiz_share_wrapper">
- <?php
- if ($image) {
- ?>
- <div id="featured_image_wrapper">
- <img src="<?php echo $image; ?>" alt="HD Quiz featured image" />
- </div>
- <?php
- }
- ?>
- <h1><?php echo $title; ?></h1>
- <p><a href="<?php echo esc_attr($permalink); ?>" id="hdq_view_quiz_button"><?php echo esc_html($quiz_start_text); ?></a></p>
- </main>
-</body>
-
-</html>
No newline at end of file
--- a/hd-quiz/index.php
+++ b/hd-quiz/index.php
@@ -5,7 +5,7 @@
* Plugin URI: https://harmonicdesign.ca/hd-quiz/
* Author: Harmonic Design
* Author URI: https://harmonicdesign.ca
- * Version: 2.0.9
+ * Version: 2.0.10
* Text Domain: hd-quiz
* Domain Path: /languages
*/
@@ -23,7 +23,7 @@
die('Invalid request.');
}
if (!defined('HDQ_PLUGIN_VERSION')) {
- define('HDQ_PLUGIN_VERSION', '2.0.9');
+ define('HDQ_PLUGIN_VERSION', '2.0.10');
}
// Settings that a power user might want to change,
@@ -109,33 +109,34 @@
function hdq_create_settings_page()
{
if (hdq_user_permission()) {
- function hdq_register_quizzes_page()
- {
- $addon_text = "";
- $new_addon = get_transient("hdq_new_addon");
- if ($new_addon === false) {
- hdq_check_for_updates();
- } else {
- $new_addon["isNew"] = sanitize_text_field($new_addon["isNew"]);
- if ($new_addon["isNew"] === "yes") {
- $addon_text = ' <span class="awaiting-mod">NEW</span>';
- }
- }
-
- add_menu_page('HD Quiz', 'HD Quiz', 'publish_posts', 'hdq_quizzes', 'hdq_main_page', 'dashicons-clipboard', 5);
-
- add_submenu_page("hdq_quizzes", "HD Quiz Addons", __("Addons", "hd-quiz") . $addon_text, "delete_others_posts", "hdq_addons", "hdq_addons_page");
- add_submenu_page("hdq_quizzes", "HD Quiz Tools", __("Tools", "hd-quiz"), "manage_options", "hdq_tools", "hdq_tools_page");
- add_submenu_page("hdq_quizzes", "HD Quiz Settings", __("Settings", "hd-quiz"), "manage_options", 'hdq_options', 'hdq_about_settings_page');
-
- // tools, hidden pages
- add_submenu_page("", "CSV Importer", "CSV Importer", "manage_options", "hdq_importer", "hdq_tools_csv_importer");
- }
add_action('admin_menu', 'hdq_register_quizzes_page');
}
}
add_action('init', 'hdq_create_settings_page');
+function hdq_register_quizzes_page()
+{
+ $addon_text = "";
+ $new_addon = get_transient("hdq_new_addon");
+ if ($new_addon === false) {
+ hdq_check_for_updates();
+ } else {
+ $new_addon["isNew"] = sanitize_text_field($new_addon["isNew"]);
+ if ($new_addon["isNew"] === "yes") {
+ $addon_text = ' <span class="awaiting-mod">NEW</span>';
+ }
+ }
+
+ add_menu_page('HD Quiz', 'HD Quiz', 'publish_posts', 'hdq_quizzes', 'hdq_main_page', 'dashicons-clipboard', 5);
+
+ add_submenu_page("hdq_quizzes", "HD Quiz Addons", __("Addons", "hd-quiz") . $addon_text, "delete_others_posts", "hdq_addons", "hdq_addons_page");
+ add_submenu_page("hdq_quizzes", "HD Quiz Tools", __("Tools", "hd-quiz"), "manage_options", "hdq_tools", "hdq_tools_page");
+ add_submenu_page("hdq_quizzes", "HD Quiz Settings", __("Settings", "hd-quiz"), "manage_options", 'hdq_options', 'hdq_about_settings_page');
+
+ // tools, hidden pages
+ add_submenu_page("", "CSV Importer", "CSV Importer", "manage_options", "hdq_importer", "hdq_tools_csv_importer");
+}
+
/* Set custom plugin links on WP plugins page
------------------------------------------------------- */
function hdq_plugin_links($actions, $plugin_file, $plugin_data, $context)