-
-
+
+
@@ -160,14 +154,14 @@ function mr_tools_screen() {
function mr_export_rating_results() {
$file_name = 'rating-results-' . date( 'YmdHis' ) . '.csv';
-
+
$username = isset( $_POST['username'] ) ? $_POST['username'] : null;
$from_date = isset( $_POST['from-date1'] ) ? $_POST['from-date1'] : null;
$to_date = isset( $_POST['to-date1'] ) ? $_POST['to-date1'] : null;
$post_id = isset( $_POST['post-id'] ) ? $_POST['post-id'] : null;
-
+
$filters = array();
-
+
$filters['user_id'] = null;
if ( $username != null && strlen( $username ) > 0 ) {
// get user id
@@ -176,34 +170,34 @@ function mr_export_rating_results() {
$filters['user_id'] = $user->ID;
}
}
-
+
if ( $post_id != null && strlen( $post_id ) > 0 ) {
$filters['post_id'] = $post_id;
}
-
+
if ( $from_date != null && strlen( $from_date ) > 0 ) {
list( $year, $month, $day ) = explode( '-', $from_date ); // default yyyy-mm-dd format
if ( checkdate( $month , $day , $year )) {
$filters['from_date'] = $from_date;
}
}
-
+
if ( $to_date != null && strlen($to_date) > 0 ) {
list( $year, $month, $day ) = explode( '-', $to_date );// default yyyy-mm-dd format
if ( checkdate( $month , $day , $year )) {
$filters['to_date'] = $to_date;
}
}
-
+
if ( mr_generare_csv_report( $file_name, $filters ) ) {
-
+
header('Content-type: text/csv');
header('Content-Disposition: attachment; filename="' . $file_name . '"');
readfile($file_name);
// delete file
unlink($file_name);
}
-
+
die();
}
@@ -217,7 +211,7 @@ function mr_export_rating_results() {
function mr_generare_csv_report( $file_name, $filters ) {
$rating_item_entries = Multi_Rating_API::get_rating_item_entries( $filters );
-
+
$header_row = __('Entry Id', 'multi-rating') . ', '
. __('Entry Date', 'multi-rating') . ', '
. __('Post Id', 'multi-rating') . ', '
@@ -235,7 +229,7 @@ function mr_generare_csv_report( $file_name, $filters ) {
// iterate all found rating item entries and create row in report
if ( count( $rating_item_entries ) > 0 ) {
-
+
foreach ( $rating_item_entries as $rating_item_entry ) {
$post_id = $rating_item_entry['post_id'];
@@ -265,7 +259,7 @@ function mr_generare_csv_report( $file_name, $filters ) {
$file = null;
try {
$file = fopen( $file_name, 'w' );
-
+
foreach ( $export_data_rows as $row ) {
fputcsv( $file, explode(',', $row ) );
}
@@ -282,16 +276,16 @@ function mr_generare_csv_report( $file_name, $filters ) {
* Clears all rating results from the database
*/
function mr_clear_database() {
-
+
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
-
+
$username = isset( $_POST['username'] ) ? $_POST['username'] : null;
$from_date = isset( $_POST['from-date2'] ) ? $_POST['from-date2'] : null;
$to_date = isset( $_POST['to-date2'] ) ? $_POST['to-date2'] : null;
$post_id = isset( $_POST['post-id'] ) ? $_POST['post-id'] : null;
-
+
$user_id = null;
if ( $username ) {
$user = get_user_by( 'login', $username );
@@ -299,34 +293,34 @@ function mr_clear_database() {
$user_id = $user->ID;
}
}
-
+
$entries = Multi_Rating_API::get_rating_item_entries( array(
'user_id' => $user_id,
'from_date' => $from_date,
'to_date' => $to_date,
'post_id' => $post_id,
) );
-
+
if ( count( $entries) > 0 ) {
-
+
$rating_entry_ids = array();
foreach ( $entries as $entry ) {
array_push( $rating_entry_ids, $entry['rating_item_entry_id'] );
-
+
// rating results cache will be refreshed next time it's needed
delete_post_meta( $entry['post_id'], Multi_Rating::RATING_RESULTS_POST_META_KEY );
delete_post_meta( $entry['post_id'], Multi_Rating::RATING_RESULTS_POST_META_KEY . '_star_rating' );
delete_post_meta( $entry['post_id'], Multi_Rating::RATING_RESULTS_POST_META_KEY . '_count_entries' );
}
-
+
global $wpdb;
-
+
$entry_id_list = implode( ',', $rating_entry_ids );
-
+
try {
$rows = $wpdb->get_results( 'DELETE FROM ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME . ' WHERE rating_item_entry_id IN ( ' . $entry_id_list . ')' );
$rows = $wpdb->get_results( 'DELETE FROM ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_VALUE_TBL_NAME . ' WHERE rating_item_entry_id IN ( ' . $entry_id_list . ')' );
-
+
echo '
' . __( 'Database cleared successfully.', 'multi-rating' ) . '
';
} catch ( Exception $e ) {
echo '
' . sprintf( __('An error has occured. %s', 'multi-rating' ), $e->getMessage() ) . '
';
@@ -341,7 +335,7 @@ function mr_clear_database() {
* Clears rating results cache stored in the WordPress post meta table
*/
function mr_clear_cache() {
-
+
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
@@ -352,14 +346,14 @@ function mr_clear_cache() {
$query = 'SELECT post_id FROM ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME;
$query_args = array();
-
+
if ( $post_id != '' ) {
$query .= ' WHERE post_id = %d';
array_push( $query_args, $post_id );
}
$query .= ' GROUP BY post_id';
-
+
if ( count( $query_args ) > 0 ) {
$query = $wpdb->prepare( $query, $query_args );
}
@@ -386,4 +380,4 @@ function mr_clear_cache() {
if ( isset( $_POST['clear-cache'] ) && $_POST['clear-cache'] === "true" ) {
add_action( 'admin_init', 'mr_clear_cache' );
}
-?>
\ No newline at end of file
+?>
diff --git a/includes/admin/update-check.php b/includes/admin/update-check.php
index c92d7b3..0633224 100644
--- a/includes/admin/update-check.php
+++ b/includes/admin/update-check.php
@@ -7,6 +7,11 @@ function mr_update_check() {
// Check if we need to do an upgrade from a previous version
$previous_plugin_version = get_option( Multi_Rating::VERSION_OPTION );
+
+ if ( ! $previous_plugin_version ) { // not set
+ update_option( Multi_Rating::VERSION_OPTION, Multi_Rating::VERSION ); // latest version upgrade complete
+ return;
+ }
if ( $previous_plugin_version != Multi_Rating::VERSION && $previous_plugin_version < 3 ) {
mr_upgrade_to_3_0();
@@ -26,10 +31,74 @@ function mr_update_check() {
if ( $previous_plugin_version != Multi_Rating::VERSION && $previous_plugin_version < 4.2 ) {
mr_upgrade_to_4_2();
+ }
+
+ if ( $previous_plugin_version != Multi_Rating::VERSION && $previous_plugin_version < 4.3 ) {
+ mr_upgrade_to_4_3();
+ }
+
+ if ( $previous_plugin_version != Multi_Rating::VERSION && $previous_plugin_version < 5) {
+ mr_upgrade_to_5();
update_option( Multi_Rating::VERSION_OPTION, Multi_Rating::VERSION ); // latest version upgrade complete
}
}
+
+/**
+ * Make Font Awesome icons local and move post types option to auto placement settings
+ */
+function mr_upgrade_to_5() {
+
+ $styles_settings = (array) get_option( Multi_Rating::STYLE_SETTINGS );
+ $icon_font_library = $styles_settings[Multi_Rating::FONT_AWESOME_VERSION_OPTION];
+
+ if ( isset( $icon_font_library ) ) {
+
+ if ( $icon_font_library == 'font-awesome-4.0.3' || $icon_font_library == 'font-awesome-4.1.0'
+ || $icon_font_library == 'font-awesome-4.2.0' || $icon_font_library == 'font-awesome-4.3.0'
+ || $icon_font_library == 'font-awesome-4.5.0' || $icon_font_library == 'font-awesome-4.6.3'
+ || $icon_font_library == 'font-awesome-4.7.0' ) {
+ $styles_settings[Multi_Rating::FONT_AWESOME_VERSION_OPTION] = 'font-awesome-v4';
+ } else if ( $icon_font_library == 'font-awesome-3.2.1' ) {
+ $styles_settings[Multi_Rating::FONT_AWESOME_VERSION_OPTION] = 'font-awesome-v3';
+ }
+ }
+
+ update_option( Multi_Rating::STYLE_SETTINGS, $styles_settings );
+
+ $general_settings = (array) get_option( Multi_Rating::GENERAL_SETTINGS );
+ $auto_placement_settings = (array) get_option( Multi_Rating::POSITION_SETTINGS );
+
+ if ( isset( $general_settings[Multi_Rating::POST_TYPES_OPTION] ) ) {
+ $auto_placement_settings[Multi_Rating::POST_TYPES_OPTION] = $general_settings[Multi_Rating::POST_TYPES_OPTION];
+ unset( $general_settings[Multi_Rating::POST_TYPES_OPTION] );
+ }
+
+ update_option( Multi_Rating::GENERAL_SETTINGS, $general_settings);
+ update_option( Multi_Rating::POSITION_SETTINGS, $auto_placement_settings);
+
+}
+
+/**
+ * Remove IP address db column in rating entries table. This is no longer used for duplicate
+ * checks to ensure GDPR compliance.
+ */
+function mr_upgrade_to_4_3() {
+
+ global $wpdb;
+ $query = 'ALTER TABLE ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME . ' DROP COLUMN ip_address';
+ $wpdb->query( $query );
+
+ // if the duplicate checking currently uses IP addresses, change the option to use cookies instead
+ $general_settings = (array) get_option( Multi_Rating::GENERAL_SETTINGS );
+ $duplicate_check_methods = $general_settings[Multi_Rating::SAVE_RATING_RESTRICTION_TYPES_OPTION];
+ if ( in_array( 'ip_address', $duplicate_check_methods ) ) {
+ $general_settings[Multi_Rating::SAVE_RATING_RESTRICTION_TYPES_OPTION] = array( 'cookie' );
+ }
+
+ update_option( Multi_Rating::GENERAL_SETTINGS, $general_settings );
+}
+
/**
*
*/
diff --git a/includes/auto-placement.php b/includes/auto-placement.php
index 2ff35ad..54f595b 100644
--- a/includes/auto-placement.php
+++ b/includes/auto-placement.php
@@ -1,4 +1,4 @@
-ID;
} else if ( !isset($post) && !isset( $post_id ) ) {
return $content; // No post id available to display rating form
}
-
- $can_apply_filter = ! ( ! in_the_loop() || ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) );
+
+ $can_apply_filter = ! ( is_feed() || ! in_the_loop() || ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) );
if ( ! apply_filters( 'mr_can_apply_filter', $can_apply_filter, 'the_content', $content, $post_id ) ) {
return $content;
}
-
+
$position_settings = ( array ) get_option( Multi_Rating::POSITION_SETTINGS );
-
+
$rating_form_html = null;
$rating_results_html = null;
-
+
$rating_form_position = get_post_meta( $post->ID, Multi_Rating::RATING_FORM_POSITION_POST_META, true );
$rating_results_position = get_post_meta( $post->ID, Multi_Rating::RATING_RESULTS_POSITION_POST_META, true );
-
- if ( $rating_form_position != Multi_Rating::DO_NOT_SHOW ) {
-
+
+ if ( $rating_form_position != Multi_Rating::DO_NOT_SHOW && ! ( $rating_form_position == '' && ! MR_Utils::check_post_type_enabled( $post_id ) ) ) {
+
// use default rating form position
if ( $rating_form_position == '' ) {
$rating_form_position = $position_settings[ Multi_Rating::RATING_FORM_POSITION_OPTION ];
}
-
+
if ( $rating_form_position == 'before_content' || $rating_form_position == 'after_content' ) {
$rating_form_html = Multi_Rating_API::display_rating_form( array(
'post_id' => $post_id,
@@ -46,45 +46,44 @@ function mr_filter_the_content( $content ) {
) );
}
}
-
- if ( $rating_results_position != Multi_Rating::DO_NOT_SHOW ) {
-
+
+ if ( $rating_results_position != Multi_Rating::DO_NOT_SHOW && ! ( $rating_results_position == '' && ! MR_Utils::check_post_type_enabled( $post_id ) ) ) {
+
// use default rating results position
if ( $rating_results_position == '' ) {
$rating_results_position = $position_settings[ Multi_Rating::RATING_RESULTS_POSITION_OPTION ];
}
-
+
if ( $rating_results_position == 'before_content' || $rating_results_position == 'after_content' ) {
$rating_results_html = Multi_Rating_API::display_rating_result( array(
'post_id' => $post_id,
'echo' => false,
'show_date' => false,
- 'generate_microdata' => is_singular(),
'class' => $rating_results_position . ' mr-filter'
) );
}
}
-
+
$filtered_content = '';
-
+
if ( $rating_results_position == 'before_content' && $rating_results_html != null ) {
$filtered_content .= $rating_results_html;
}
-
+
if ( $rating_form_position == 'before_content' && $rating_form_html != null ) {
$filtered_content .= $rating_form_html;
}
-
+
$filtered_content .= $content;
-
+
if ( $rating_results_position == 'after_content' && $rating_results_html != null ) {
$filtered_content .= $rating_results_html;
}
-
+
if ( $rating_form_position == 'after_content' && $rating_form_html != null ) {
$filtered_content .= $rating_form_html;
}
-
+
do_action( 'mr_after_auto_placement', 'the_content', $post_id );
return $filtered_content;
@@ -101,44 +100,44 @@ function mr_filter_the_content( $content ) {
* @return filtered title
*/
function mr_filter_the_title( $title ) {
-
+
// get the post id
global $post;
-
+
$post_id = null;
if ( ! isset( $post_id ) && isset( $post ) ) {
$post_id = $post->ID;
} else if ( !isset( $post ) && ! isset( $post_id ) ) {
return $title; // No post id available to display rating result
}
-
- $can_apply_filter = ! ( ! in_the_loop() || ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) );
+
+ $can_apply_filter = ! ( is_feed() || ! in_the_loop() || ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) );
if ( ! apply_filters( 'mr_can_apply_filter', $can_apply_filter, 'the_title', $title, $post_id ) ) {
return $title;
}
-
+
$rating_results_position = get_post_meta( $post->ID, Multi_Rating::RATING_RESULTS_POSITION_POST_META, true );
- if ( $rating_results_position == Multi_Rating::DO_NOT_SHOW ) {
+ if ( $rating_results_position == Multi_Rating::DO_NOT_SHOW || ( $rating_results_position == '' && ! MR_Utils::check_post_type_enabled( $post_id ) ) ) {
return $title;
}
-
+
$position_settings = (array) get_option( Multi_Rating::POSITION_SETTINGS );
-
+
// use default rating results position
if ( $rating_results_position == '' ) {
$rating_results_position = $position_settings[ Multi_Rating::RATING_RESULTS_POSITION_OPTION ];
}
$rating_results_html = null;
-
+
if ( $rating_results_position == 'before_title' || $rating_results_position == 'after_title' ) {
$rating_results_html = Multi_Rating_API::display_rating_result( array(
'post_id' => $post_id,
'echo' => false,
'show_date' => false,
- 'generate_microdata' => is_singular(),
'class' => $rating_results_position . ' mr-filter'
) );
+
}
$filtered_title = '';
@@ -152,7 +151,7 @@ function mr_filter_the_title( $title ) {
if ( $rating_results_position == 'after_title' && $rating_results_html != null ) {
$filtered_title .= $rating_results_html;
}
-
+
do_action( 'mr_after_auto_placement', 'the_title', $post_id );
return $filtered_title;
@@ -171,10 +170,6 @@ function mr_filter_the_title( $title ) {
*/
function mr_can_apply_filter( $can_apply_filter, $filter_name, $value, $post_id ) {
- if ( $can_apply_filter ) {
- $can_apply_filter = MR_Utils::check_post_type_enabled( $post_id );
- }
-
return $can_apply_filter;
}
add_filter( 'mr_can_apply_filter', 'mr_can_apply_filter', 10, 4 );
@@ -193,4 +188,4 @@ function mr_check_auto_placement( $filter, $post_id ) {
remove_filter( $filter, 'mr_filter_' . $filter );
}
}
-add_action( 'mr_after_auto_placement', 'mr_check_auto_placement', 10, 3);
\ No newline at end of file
+add_action( 'mr_after_auto_placement', 'mr_check_auto_placement', 10, 3);
diff --git a/includes/class-api.php b/includes/class-api.php
index 095c9f2..bf6efd4 100644
--- a/includes/class-api.php
+++ b/includes/class-api.php
@@ -147,8 +147,8 @@ public static function get_rating_result( $post_id ) {
'post_id' => $post_id,
'rating_items' => $rating_items
) );
-
- if ( $rating_results_cache == true) {
+
+ if ( $rating_results_cache == true ) {
// update rating results cache
update_post_meta( $post_id, Multi_Rating::RATING_RESULTS_POST_META_KEY, $rating_result );
update_post_meta( $post_id, Multi_Rating::RATING_RESULTS_POST_META_KEY . '_star_rating', $rating_result['adjusted_star_result'] );
@@ -237,7 +237,7 @@ public static function calculate_rating_result( $params = array() ) {
if ($count_entries > 0) {
// calculate 5 star result
$score_result = round( doubleval($score_result_total ) / $count_entries, 2 );
- $adjusted_score_result =round(doubleval($adjusted_score_result_total ) / $count_entries, 2 );
+ $adjusted_score_result = round(doubleval($adjusted_score_result_total ) / $count_entries, 2 );
// calculate star result
$star_result = round( doubleval( $star_result_total ) / $count_entries, 2 );
@@ -685,24 +685,15 @@ public static function display_rating_result( $params = array()) {
extract( wp_parse_args( $params, array(
'post_id' => null,
'no_rating_results_text' => $custom_text_settings[Multi_Rating::NO_RATING_RESULTS_TEXT_OPTION],
- 'show_rich_snippets' => false, // @deprecated
'show_title' => false,
'show_count' => true,
'echo' => true,
'result_type' => Multi_Rating::STAR_RATING_RESULT_TYPE,
'class' => '',
'before_count' => '(',
- 'after_count' => ')',
- 'generate_microdata' => false
+ 'after_count' => ')'
) ) );
- if ( is_string( $show_rich_snippets ) ) {
- $show_rich_snippets = $show_rich_snippets == 'true' ? true : false;
- $generate_microdata = $show_rich_snippets;
- }
- if ( is_string( $generate_microdata ) ) {
- $generate_microdata = $generate_microdata == 'true' ? true : false;
- }
if ( is_string( $show_title ) ) {
$show_title = $show_title == 'true' ? true : false;
}
@@ -735,7 +726,6 @@ public static function display_rating_result( $params = array()) {
ob_start();
mr_get_template_part( 'rating-result', null, true, array(
'no_rating_results_text' => $no_rating_results_text,
- 'generate_microdata' => $generate_microdata,
'show_title' => $show_title,
'show_date' => false,
'show_count' => $show_count,
@@ -933,7 +923,6 @@ public static function display_rating_results_list( $params = array() ) {
'filter_label_text' => $filter_label_text,
'show_featured_img' => $show_featured_img,
'image_size' => $image_size,
- 'generate_microdata' => false,
'class' => $class . ' rating-results-list',
'rating_results' => $rating_results,
'before_count' => '(',
diff --git a/includes/class-gutenberg.php b/includes/class-gutenberg.php
new file mode 100644
index 0000000..7cb3d48
--- /dev/null
+++ b/includes/class-gutenberg.php
@@ -0,0 +1,200 @@
+settings->custom_text_settings;
+
+ register_block_type( 'multi-rating/rating-form', array(
+ 'editor_script' => 'mr-gutenberg-blocks-script',
+ 'render_callback' => array( $this, 'rating_form_block_render' ),
+ 'attributes' => [
+ 'title' => [
+ 'default' => $custom_text_settings[Multi_Rating::RATING_FORM_TITLE_TEXT_OPTION],
+ 'type' => 'string'
+ ],
+ 'submit_button_text' => [
+ 'type' => 'string',
+ 'default' => $custom_text_settings[Multi_Rating::SUBMIT_RATING_FORM_BUTTON_TEXT_OPTION],
+ ]
+ ]
+ ) );
+
+ register_block_type( 'multi-rating/rating-result', array(
+ 'editor_script' => 'mr-gutenberg-blocks-script',
+ 'render_callback' => array( $this, 'rating_result_block_render' ),
+ 'attributes' => [
+ 'show_title' => [
+ 'type' => 'boolean',
+ 'default' => false
+ ],
+ 'show_count' => [
+ 'type' => 'boolean',
+ 'default' => true
+ ]
+ ]
+ ) );
+
+ register_block_type( 'multi-rating/rating-results-list', array(
+ 'editor_script' => 'mr-gutenberg-blocks-script',
+ 'render_callback' => array( $this, 'rating_results_list_block_render' ),
+ 'attributes' => [
+ 'title' => [
+ 'default' => $custom_text_settings[Multi_Rating::RATING_RESULTS_LIST_TITLE_TEXT_OPTION],
+ 'type' => 'string'
+ ],
+ 'show_count' => [
+ 'type' => 'boolean',
+ 'default' => true
+ ],
+ 'show_filter' => [
+ 'type' => 'boolean',
+ 'default' => false
+ ],
+ 'limit' => [
+ 'type' => 'integer',
+ 'default' => 5
+ ],
+ 'show_rank' => [
+ 'type' => 'boolean',
+ 'default' => true
+ ],
+ 'show_featured_img' => [
+ 'type' => 'boolean',
+ 'default' => true
+ ]
+ ]
+ ) );
+
+ }
+
+ /**
+ * Renders the rating form block
+ */
+ public function rating_form_block_render( $attributes ) {
+
+ $shortcode_format = '[mr_rating_form title="%s" submit_button_text="%s"]';
+
+ $shortcode_text = sprintf( $shortcode_format, $attributes['title'], $attributes['submit_button_text'] );
+
+ return do_shortcode( $shortcode_text );
+ }
+
+ /**
+ * Renders the rating result block
+ */
+ public function rating_result_block_render( $attributes ) {
+
+ $show_count = $attributes['show_count'] === true ? 'true' : 'false';
+ $show_title = $attributes['show_title'] === true ? 'true' : 'false';
+
+ $shortcode_format = '[mr_rating_result show_title=%s show_count=%s]';
+ $shortcode_text = sprintf( $shortcode_format, $show_title, $show_count );
+
+ return do_shortcode( $shortcode_text );
+ }
+
+ /**
+ * Renders the rating results list block
+ */
+ public function rating_results_list_block_render( $attributes ) {
+
+ $show_count = $attributes['show_count'] === true ? 'true' : 'false';
+ $show_rank = $attributes['show_rank'] === true ? 'true' : 'false';
+ $show_featured_img = $attributes['show_featured_img'] === true ? 'true' : 'false';
+ $show_filter = $attributes['show_filter'] === true ? 'true' : 'false';
+
+ $shortcode_format = '[mr_rating_results_list title="%s" show_count="%s" show_rank="%s" show_featured_img="%s" limit=%d show_filter="%s"]';
+ $shortcode_text = sprintf( $shortcode_format, $attributes['title'], $show_count, $show_rank, $show_featured_img, $attributes['limit'], $show_filter );
+
+ return do_shortcode( $shortcode_text );
+ }
+
+ /*
+ * Registers post meta fields with REST API visibility
+ */
+ public function register_post_meta() {
+
+ $post_types = get_post_types( array( 'public' => true ) );
+
+ foreach ( $post_types as $post_type ) {
+
+ register_post_meta( $post_type, Multi_Rating::RATING_FORM_POSITION_POST_META, array(
+ 'show_in_rest' => true,
+ 'single' => true,
+ 'type' => 'string',
+ 'auth_callback' => function () { return current_user_can('edit_posts'); }
+ ));
+ register_post_meta( $post_type, Multi_Rating::RATING_RESULTS_POSITION_POST_META, array(
+ 'show_in_rest' => true,
+ 'single' => true,
+ 'type' => 'string',
+ 'auth_callback' => function () { return current_user_can('edit_posts'); }
+ ));
+ register_post_meta( $post_type, Multi_Rating::STRUCTURED_DATA_TYPE_POST_META, array(
+ 'show_in_rest' => true,
+ 'single' => true,
+ 'type' => 'string',
+ 'auth_callback' => function () { return current_user_can('edit_posts'); }
+ ));
+
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/includes/class-rating-form.php b/includes/class-rating-form.php
index 96471ab..247ded9 100644
--- a/includes/class-rating-form.php
+++ b/includes/class-rating-form.php
@@ -26,7 +26,6 @@ public static function save_rating() {
$rating_items = $_POST['ratingItems'];
$post_id = isset( $_POST['postId'] ) && is_numeric( $_POST['postId'] ) ? intval( $_POST['postId'] ) : null;
$sequence = isset( $_POST['sequence'] ) && is_numeric( $_POST['sequence'] ) ? intval( $_POST['sequence'] ) : null;
- $ip_address = MR_Utils::get_ip_address();
$entry_date_mysql = current_time( 'mysql' );
// WPML get original pst id for default language
@@ -79,9 +78,8 @@ public static function save_rating() {
$wpdb->insert( $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME, array(
'post_id' => $post_id,
'entry_date' => $entry_date_mysql,
- 'ip_address' => $ip_address,
'user_id' => $user_id,
- ), array( '%d', '%s', '%s', '%d' ) );
+ ), array( '%d', '%s', '%d' ) );
$rating_entry_id = $wpdb->insert_id;
@@ -135,7 +133,6 @@ public static function save_rating() {
ob_start();
mr_get_template_part( 'rating-result', null, true, array(
'no_rating_results_text' => '',
- 'generate_microdata' => false,
'show_title' => false,
'show_date' => false,
'show_count' => true,
diff --git a/includes/class-rest-api-common.php b/includes/class-rest-api-common.php
new file mode 100644
index 0000000..30c222e
--- /dev/null
+++ b/includes/class-rest-api-common.php
@@ -0,0 +1,285 @@
+register_routes();
+ }
+
+ /**
+ * Check if a given request has access to get items
+ *
+ * @param WP_REST_Request $request Full data about the request.
+ * @return WP_Error|bool
+ */
+ public function get_items_permissions_check( $request ) {
+ return true;
+ }
+
+ /**
+ * Check if a given request has access to get a specific item
+ *
+ * @param WP_REST_Request $request Full data about the request.
+ * @return WP_Error|bool
+ */
+ public function get_item_permissions_check( $request ) {
+ return true;
+ }
+
+ /**
+ * is_numeric()
+ *
+ * @param unknown $value
+ * @param unknown $param
+ * @param unknown $request
+ * @return boolean
+ */
+ public function is_numeric_value( $value, $param, $request ) {
+ return is_numeric( $value );
+ }
+
+ /**
+ * Checks date format
+ *
+ * @param unknown $value
+ * @param unknown $param
+ * @param unknown $request
+ * @return boolean
+ */
+ public function is_date_value( $value, $param, $request ) {
+
+ if ( ! $this->is_not_empty_value( $value ) ) {
+ return false;
+ }
+
+ if ( $value != null && strlen( $value ) > 0 ) {
+ list( $year, $month, $day ) = explode( '-', $value ); // default yyyy-mm-dd format
+ if ( ! checkdate( $month , $day , $year ) ) {
+ return false;
+ }
+ }
+
+ // if all passes
+ return true;
+ }
+
+ /**
+ * is_numeric() on array values
+ *
+ * @param unknown $value
+ * @param unknown $param
+ * @param unknown $request
+ * @return boolean
+ */
+ public function is_numeric_array_values( $values, $param, $request ) {
+
+ if ( empty( $values ) || ! is_array( $values ) ) {
+ return false;
+ }
+
+ foreach ( $values as $value ) {
+ if ( ! is_numeric( $value ) ) {
+ return false;
+ }
+ }
+
+ // if all passes
+ return true;
+ }
+
+
+ /**
+ * strlen > 0 on array values
+ *
+ * @param unknown $value
+ * @param unknown $param
+ * @param unknown $request
+ * @return boolean
+ */
+ public function is_string_array_values( $values, $param, $request ) {
+
+ if ( empty( $values ) || ! is_array( $values ) ) {
+ return false;
+ }
+
+ foreach ( $values as $value ) {
+ if ( strlen( trim( $value ) ) == 0 ) {
+ return false;
+ }
+ }
+
+ // if all passes
+ return true;
+ }
+
+ /**
+ * ! empty() and checks for whitespace string
+ *
+ * @param unknown $value
+ * @param unknown $param
+ * @param unknown $request
+ * @return boolean
+ */
+ public function is_not_empty_value( $value, $param, $request ) {
+
+ if ( empty( $value ) || strlen( trim( $value ) ) == 0 ) {
+ return false;
+ }
+
+ // if all passes
+ return true;
+ }
+
+ /**
+ * ! empty() and checks for whitespace string
+ *
+ * @param unknown $value
+ * @param unknown $param
+ * @param unknown $request
+ * @return boolean
+ */
+ public function is_entry_status_value( $value, $param, $request ) {
+
+ if ( $value != 'approved' && $value != 'pending' && ! ( empty( $value )
+ || strlen( trim( $value ) ) == 0 ) ) {
+ return false;
+ }
+
+ // if all passes
+ return true;
+ }
+
+ /**
+ * checks value is true or false
+ *
+ * @param unknown $value
+ * @param unknown $param
+ * @param unknown $request
+ * @return boolean
+ */
+ public function is_boolean_value( $value, $param, $request ) {
+
+ if ( ! ( ( is_string( $value ) && $value == 'true' || $value == 'false' )
+ || is_bool( $value ) ) ) {
+ return false;
+ }
+
+ // if all passes
+ return true;
+ }
+
+ /**
+ * Only keeps allowed parameters
+ *
+ * @param unknown $parameters
+ * @param unknown $allowed_parameters
+ * @return unknown
+ */
+ public function keep_allowed_parameters( $parameters, $allowed_parameters ) {
+
+ // limit to only allowed parameters
+ foreach ( $parameters as $name => $value ) {
+ if ( ! in_array( $name, $allowed_parameters ) ) {
+ unset( $parameters[$name] );
+ }
+ }
+
+ return $parameters;
+ }
+
+ /**
+ * Sanitize parameters before use
+ *
+ * @param array $parameters
+ * @param array $allowed_parameters
+ */
+ public function sanitize_parameters( $parameters, $allowed_parameters ) {
+
+ $default_parameter_values = array(
+ 'limit' => 10,
+ 'taxonomy' => null,
+ 'term_id' => null, // 0 = All
+ 'sort_by' => 'highest_rated',
+ 'to_date' => null,
+ 'from_date' => null,
+ 'offset' => 0,
+ 'post_ids' => null,
+ 'entry_status' => null,
+ 'published_posts_only' => true,
+ 'post_id' => null,
+ 'user_id' => null
+ );
+
+ $parameters = $this->keep_allowed_parameters( $parameters, $allowed_parameters );
+
+ // go through and sanitize each parameter, set default values if necessary
+
+ foreach ( $parameters as $param_name => $value ) {
+ if ( isset( $parameters[$param_name]) ) {
+
+ switch ( $param_name ) {
+ case 'taxonomy' :
+ if ( empty( $value ) || strlen( trim( $value ) ) == 0 ) {
+ $parameters[$param_name] = $default_parameter_values[$param_name];
+ }
+ break;
+ case 'term_id' :
+ case 'user_id' :
+ case 'limit' :
+ if ( empty( $value ) || $value == 0 || ! is_numeric( $value ) ) {
+ $parameters[$param_name] = $default_parameter_values[$param_name];
+ } else {
+ $parameters[$param_name] = intval( $value );
+ }
+ break;
+ case 'offset' :
+ if ( empty( $value ) || ! is_numeric( $value ) ) {
+ $parameters[$param_name] = $default_parameter_values[$param_name];
+ } else {
+ $parameters[$param_name] = intval( $value );
+ }
+ break;
+ case 'post_id' :
+ if ( empty( $value ) ) {
+ $parameters[$param_name] = $default_parameter_values[$param_name];
+ } else {
+ $parameters[$param_name] = intval( apply_filters( 'mr_object_id', $value, apply_filters( 'mr_default_language', null ) ) );
+ }
+ break;
+ case 'sort_by' :
+ if ( ! ( $value == 'highest_rated' || $value == 'most_recent' || $value == 'lowest_rated'
+ || $value == 'post_title_asc' || $value == 'post_title_desc' || $value == 'most_entries'
+ || $value == 'oldest' ) ) {
+ $parameters[$param_name] = $default_parameter_values[$param_name];
+ }
+ break;
+ case 'to_date' :
+ case 'from_date' :
+ if ( $value != null && strlen( $value ) > 0 ) {
+ list( $year, $month, $day ) = explode( '-', $value ); // default yyyy-mm-dd format
+ if ( ! checkdate( $month , $day , $year ) ) {
+ $parameters[$param_name] = $default_parameter_values[$param_name];
+ }
+ } else {
+ $parameters[$param_name] = $default_parameter_values[$param_name];
+ }
+ break;
+
+ // TODO terms
+
+ default;
+ break;
+ }
+ }
+ }
+
+ return $parameters;
+ }
+}
\ No newline at end of file
diff --git a/includes/class-rest-api-rating-items.php b/includes/class-rest-api-rating-items.php
new file mode 100644
index 0000000..ead6432
--- /dev/null
+++ b/includes/class-rest-api-rating-items.php
@@ -0,0 +1,102 @@
+register_routes();
+ }
+
+ /**
+ * Register the routes for the objects of the controller.
+ */
+ public function register_routes() {
+
+ $version = '1';
+ $namespace = 'mr/v' . $version;
+ $base = 'rating-items';
+
+ register_rest_route( $namespace, '/' . $base, array(
+ array(
+ 'methods' => WP_REST_Server::READABLE,
+ 'callback' => array( $this, 'get_items' ),
+ 'permission_callback' => array( $this, 'get_items_permissions_check' ),
+ 'args' => array(
+
+ ),
+ )
+ ) );
+ register_rest_route( $namespace, '/' . $base . '/(?P
[\d]+)', array(
+ array(
+ 'methods' => WP_REST_Server::READABLE,
+ 'callback' => array( $this, 'get_item' ),
+ 'permission_callback' => array( $this, 'get_item_permissions_check' ),
+ 'args' => array(
+ 'context' => array(
+ 'default' => 'view',
+ ),
+ ),
+ )
+ ));
+
+ }
+
+ /**
+ * Get a collection of items
+ *
+ * @param WP_REST_Request $request Full data about the request.
+ * @return WP_Error|WP_REST_Response
+ */
+ public function get_items( $request ) {
+
+ $rating_items = Multi_Rating_API::get_rating_items();
+
+ return new WP_REST_Response( $rating_items, 200 );
+ }
+
+ /**
+ * Get one item from the collection
+ *
+ * @param WP_REST_Request $request Full data about the request.
+ * @return WP_Error|WP_REST_Response
+ */
+ public function get_item( $request ) {
+
+ $parameters = $request->get_url_params();
+
+ $rating_items = Multi_Rating_API::get_rating_items();
+
+ $rating_item = isset( $rating_items[$parameters['id']] ) ? $rating_items[$parameters['id']] : null;
+
+ return new WP_REST_Response( $rating_item, 200 );
+ }
+
+ /**
+ * Check if a given request has access to get items
+ *
+ * @param WP_REST_Request $request Full data about the request.
+ * @return WP_Error|bool
+ */
+ public function get_items_permissions_check( $request ) {
+ return true;
+ }
+
+ /**
+ * Check if a given request has access to get a specific item
+ *
+ * @param WP_REST_Request $request Full data about the request.
+ * @return WP_Error|bool
+ */
+ public function get_item_permissions_check( $request ) {
+ return true;
+ }
+
+}
\ No newline at end of file
diff --git a/includes/class-rest-api-rating-results.php b/includes/class-rest-api-rating-results.php
new file mode 100644
index 0000000..8342956
--- /dev/null
+++ b/includes/class-rest-api-rating-results.php
@@ -0,0 +1,75 @@
+ WP_REST_Server::READABLE,
+ 'callback' => array( $this, 'get_items' ),
+ 'permission_callback' => array( $this, 'get_items_permissions_check' ),
+ 'args' => array(
+ 'limit' => array(
+ 'validate_callback' => array( $this, 'is_numeric_value' )
+ ),
+ 'taxonony' => array(
+ 'validate_callback' => array( $this, 'is_not_empty_value' )
+ ),
+ 'term_id' => array(
+ 'validate_callback' => array( $this, 'is_numeric_value' )
+ ),
+ 'sort_by' => array(
+ 'validate_callback' => array( $this, 'is_not_empty_value' )
+ ),
+ 'offset' => array(
+ 'validate_callback' => array( $this, 'is_numeric_value' )
+ ),
+ 'post_id' => array(
+ 'validate_callback' => array( $this, 'is_numeric_value' )
+ )
+ )
+ )
+ ) );
+
+ }
+
+ /**
+ * Get a collection of items
+ *
+ * @param WP_REST_Request $request Full data about the request.
+ * @return WP_Error|WP_REST_Response
+ */
+ public function get_items( $request ) {
+
+ $allowed_parameters = array( 'taxonomy', 'term_id', 'limit', 'sort_by', /* 'offset', */ 'post_id' );
+
+ $parameters = apply_filters( 'mr_rest_api_rating_results_sanitize_params', $request->get_query_params(), $allowed_parameters );
+
+ $rating_result_list = Multi_Rating_API::get_rating_results( $parameters );
+
+ return new WP_REST_Response( $rating_result_list, 200 );
+ }
+
+}
\ No newline at end of file
diff --git a/includes/class-settings.php b/includes/class-settings.php
index 1770123..bd78cc9 100644
--- a/includes/class-settings.php
+++ b/includes/class-settings.php
@@ -1,8 +1,8 @@
-load_settings();
}
-
+
/**
* Reisters settings
*/
function register_settings() {
-
+
$this->register_general_settings();
$this->register_position_settings();
$this->register_custom_text_settings();
$this->register_style_settings();
$this->register_custom_images_settings();
}
-
+
/**
* Retrieve settings and applies default option values if not set
*/
function load_settings() {
-
- $this->general_settings = (array) get_option( Multi_Rating::GENERAL_SETTINGS );
- $this->position_settings = (array) get_option( Multi_Rating::POSITION_SETTINGS );
- $this->custom_text_settings = (array) get_option( Multi_Rating::CUSTOM_TEXT_SETTINGS );
- $this->style_settings = (array) get_option( Multi_Rating::STYLE_SETTINGS );
- $this->custom_images_settings = (array) get_option( Multi_Rating::CUSTOM_IMAGES_SETTINGS );
-
+
+ $this->general_settings = (array) get_option( Multi_Rating::GENERAL_SETTINGS, array() );
+ $this->position_settings = (array) get_option( Multi_Rating::POSITION_SETTINGS, array() );
+ $this->custom_text_settings = (array) get_option( Multi_Rating::CUSTOM_TEXT_SETTINGS, array() );
+ $this->style_settings = (array) get_option( Multi_Rating::STYLE_SETTINGS, array() );
+ $this->custom_images_settings = (array) get_option( Multi_Rating::CUSTOM_IMAGES_SETTINGS, array() );
+
// Merge with defaults
-
+
$this->general_settings = array_merge( array(
- Multi_Rating::SAVE_RATING_RESTRICTION_TYPES_OPTION => array( 'ip_address' ),
+ Multi_Rating::SAVE_RATING_RESTRICTION_TYPES_OPTION => array( 'cookie' ),
Multi_Rating::SAVE_RATING_RESTRICTION_HOURS_OPTION => 24,
- Multi_Rating::POST_TYPES_OPTION => 'post',
+ Multi_Rating::ADD_STRUCTURED_DATA_OPTION => array( 'create_type', 'wpseo', 'woocommerce' ),
Multi_Rating::RATING_RESULTS_CACHE_OPTION => true,
Multi_Rating::HIDE_RATING_FORM_AFTER_SUBMIT_OPTION => true,
Multi_Rating::TEMPLATE_STRIP_NEWLINES_OPTION => true
), $this->general_settings );
-
+
$this->position_settings = array_merge( array(
+ Multi_Rating::POST_TYPES_OPTION => 'post',
Multi_Rating::RATING_RESULTS_POSITION_OPTION => 'after_title',
Multi_Rating::RATING_FORM_POSITION_OPTION => 'after_content'
), $this->position_settings );
-
+
$default_custom_text = array(
Multi_Rating::RATING_FORM_TITLE_TEXT_OPTION => __( 'Please rate this', 'multi-rating' ),
Multi_Rating::RATING_RESULTS_LIST_TITLE_TEXT_OPTION => __( 'Rating Results', 'multi-rating' ),
@@ -75,24 +76,23 @@ function load_settings() {
Multi_Rating::NO_RATING_RESULTS_TEXT_OPTION => __( 'No ratings yet.', 'multi-rating' ),
Multi_Rating::FIELD_REQUIRED_ERROR_MESSAGE_OPTION => __( 'Field is required.', 'multi-rating' )
);
-
+
$this->custom_text_settings = array_merge( $default_custom_text, $this->custom_text_settings );
-
+
// If custom text is disabled, always use defaults
if ( apply_filters( 'mr_disable_custom_text', false ) ) {
$this->custom_text_settings = $default_custom_text;
}
-
+
$this->style_settings = array_merge( array(
- Multi_Rating::CUSTOM_CSS_OPTION => '',
Multi_Rating::STAR_RATING_COLOUR_OPTION => '#ffd700',
Multi_Rating::STAR_RATING_HOVER_COLOUR_OPTION => '#ffba00',
Multi_Rating::INCLUDE_FONT_AWESOME_OPTION => true,
- Multi_Rating::FONT_AWESOME_VERSION_OPTION => 'font-awesome-4.7.0',
+ Multi_Rating::FONT_AWESOME_VERSION_OPTION => 'font-awesome-v5',
Multi_Rating::ERROR_MESSAGE_COLOUR_OPTION => '#EC6464',
Multi_Rating::DISABLE_STYLES_OPTION => false
), $this->style_settings );
-
+
$this->custom_images_settings = array_merge( array(
Multi_Rating::USE_CUSTOM_STAR_IMAGES => false,
Multi_Rating::CUSTOM_FULL_STAR_IMAGE => '',
@@ -101,8 +101,8 @@ function load_settings() {
Multi_Rating::CUSTOM_HOVER_STAR_IMAGE => '',
Multi_Rating::CUSTOM_STAR_IMAGE_WIDTH => 32,
Multi_Rating::CUSTOM_STAR_IMAGE_HEIGHT => 32,
- ), $this->custom_images_settings );
-
+ ), $this->custom_images_settings );
+
// TODO only update if different...
update_option( Multi_Rating::GENERAL_SETTINGS, $this->general_settings );
update_option( Multi_Rating::POSITION_SETTINGS, $this->position_settings );
@@ -115,56 +115,41 @@ function load_settings() {
* Register general settings
*/
function register_general_settings() {
-
+
register_setting( Multi_Rating::GENERAL_SETTINGS, Multi_Rating::GENERAL_SETTINGS, array( &$this, 'sanitize_general_settings' ) );
-
+
add_settings_section( 'section_general', __( 'General Settings', 'multi-rating' ), array( &$this, 'section_general_desc' ), Multi_Rating::SETTINGS_PAGE_SLUG . '&setting=' . Multi_Rating::GENERAL_SETTINGS);
- $post_types = $post_types = get_post_types( array(
- 'public' => true,
- 'show_ui' => true
- ), 'objects' );
-
- $post_type_checkboxes = array();
- foreach ( $post_types as $post_type ) {
- array_push( $post_type_checkboxes, array(
- 'name' => $post_type->name,
- 'label' => $post_type->labels->name
- ) );
- }
-
$setting_fields = array(
- Multi_Rating::POST_TYPES_OPTION => array(
- 'title' => __( 'Post Types', 'rating-pro' ),
- 'callback' => 'field_checkboxes',
- 'page' => Multi_Rating::SETTINGS_PAGE_SLUG . '&setting=' . Multi_Rating::GENERAL_SETTINGS,
- 'section' => 'section_general',
- 'args' => array(
- 'option_name' => Multi_Rating::GENERAL_SETTINGS,
- 'setting_id' => Multi_Rating::POST_TYPES_OPTION,
- 'description' => __( 'Enable post types for auto placement of the rating form and rating results.', 'multi-rating' ),
- 'checkboxes' => $post_type_checkboxes
- )
- ),
Multi_Rating::SAVE_RATING_RESTRICTION_TYPES_OPTION => array(
'title' => __( 'Duplicate Check Method', 'multi-rating' ),
'callback' => 'field_duplicate_check_method',
'page' => Multi_Rating::SETTINGS_PAGE_SLUG . '&setting=' . Multi_Rating::GENERAL_SETTINGS,
'section' => 'section_general'
),
+ Multi_Rating::ADD_STRUCTURED_DATA_OPTION => array(
+ 'title' => __( 'Structured Data', 'multi-rating' ),
+ 'callback' => 'field_add_structured_data',
+ 'page' => Multi_Rating::SETTINGS_PAGE_SLUG . '&setting=' . Multi_Rating::GENERAL_SETTINGS,
+ 'section' => 'section_general',
+ 'args' => array(
+ 'option_name' => Multi_Rating::GENERAL_SETTINGS,
+ 'setting_id' => Multi_Rating::ADD_STRUCTURED_DATA_OPTION
+ )
+ ),
Multi_Rating::RATING_RESULTS_CACHE_OPTION => array(
- 'title' => __( 'Store Ratings Cache', 'multi-rating' ),
+ 'title' => __( 'Store Calculated Ratings', 'multi-rating' ),
'callback' => 'field_checkbox',
'page' => Multi_Rating::SETTINGS_PAGE_SLUG . '&setting=' . Multi_Rating::GENERAL_SETTINGS,
'section' => 'section_general',
'args' => array(
'option_name' => Multi_Rating::GENERAL_SETTINGS,
'setting_id' => Multi_Rating::RATING_RESULTS_CACHE_OPTION,
- 'label' => __( 'Check this box if you want to store ratings in a database cache so that it does not need to be recalculated on each page load.', 'multi-rating' )
+ 'label' => __( 'Check this box if you want to store calculated ratings in the database instead of recalculating results on each page load.', 'multi-rating' )
)
),
Multi_Rating::HIDE_RATING_FORM_AFTER_SUBMIT_OPTION => array(
- 'title' => __( 'Hide Rating Form Submit', 'multi-rating' ),
+ 'title' => __( 'Hide Rating Form on Submit', 'multi-rating' ),
'callback' => 'field_checkbox',
'page' => Multi_Rating::SETTINGS_PAGE_SLUG . '&setting=' . Multi_Rating::GENERAL_SETTINGS,
'section' => 'section_general',
@@ -175,40 +160,43 @@ function register_general_settings() {
)
),
Multi_Rating::TEMPLATE_STRIP_NEWLINES_OPTION => array(
- 'title' => __( 'Template Strip Newlines?', 'multi-rating' ),
+ 'title' => __( 'Template Strip Newlines', 'multi-rating' ),
'callback' => 'field_checkbox',
'page' => Multi_Rating::SETTINGS_PAGE_SLUG . '&setting=' . Multi_Rating::GENERAL_SETTINGS,
'section' => 'section_general',
'args' => array(
'option_name' => Multi_Rating::GENERAL_SETTINGS,
'setting_id' => Multi_Rating::TEMPLATE_STRIP_NEWLINES_OPTION,
- 'label' => sprintf( __( 'Some plugins convert newlines to HTML paragraphs similar to wpautop (e.g. Visual Composer). Check this box if you want to prevent this from happening by stripping the newlines from the Multi Rating templates.', 'multi-rating' ), 'https://codex.wordpress.org/Function_Reference/wpautop' )
+ 'label' => sprintf( __( 'Some plugins convert newlines to HTML paragraphs similar to wpautop (e.g. Visual Composer). Check this box if you want to prevent this from happening by stripping the newlines from the templates.', 'multi-rating' ), 'https://codex.wordpress.org/Function_Reference/wpautop' )
)
)
);
-
- foreach ( $setting_fields as $setting_id => $setting_data ) {
+
+ foreach ( $setting_fields as $setting_id => $setting_data ) {
// $id, $title, $callback, $page, $section, $args
add_settings_field( $setting_id, $setting_data['title'], array( $this, $setting_data['callback'] ), $setting_data['page'], $setting_data['section'], isset( $setting_data['args'] ) ? $setting_data['args'] : array() );
- }
-
+ }
+
}
-
+
/**
* General section desciption
*/
function section_general_desc() {
}
-
-
+
+
/**
* Duplicate check method field
*/
function field_duplicate_check_method() {
-
+
+ ?>
+
+ __( 'IP Address', 'multi-rating' ),
+ /*'ip_address' => __( 'IP Address', 'multi-rating' ),*/
'cookie' => __( 'Cookie', 'multi-rating')
);
@@ -224,26 +212,41 @@ function field_duplicate_check_method() {
}
echo ' /> ' . $save_rating_restrictions_label . ' ';
}
+ ?>
+
+
+
+
+ />
-
-
- />
+
+ />
+ 0 ) {
if ( ! is_numeric( $input[Multi_Rating::SAVE_RATING_RESTRICTION_HOURS_OPTION] ) ) {
add_settings_error(Multi_Rating::GENERAL_SETTINGS, 'non_numeric_save_rating_restriction_hours', __( 'Save rating restriction hours must be numeric.', 'multi-rating' ) );
@@ -251,11 +254,11 @@ function sanitize_general_settings( $input ) {
add_settings_error(Multi_Rating::GENERAL_SETTINGS, 'invalid_save_rating_restriction_hours', __( 'Save rating restriction hours must be greater than 0.', 'multi-rating' ) );
}
}
-
- if ( ! isset( $input[Multi_Rating::POST_TYPES_OPTION] ) ) {
- $input[Multi_Rating::POST_TYPES_OPTION] = array();
+
+ if ( ! isset( $input[Multi_Rating::ADD_STRUCTURED_DATA_OPTION] ) ) {
+ $input[Multi_Rating::ADD_STRUCTURED_DATA_OPTION] = array();
}
-
+
// rating reulsts cache
if ( isset( $input[Multi_Rating::RATING_RESULTS_CACHE_OPTION] )
&& $input[Multi_Rating::RATING_RESULTS_CACHE_OPTION] == 'true' ) {
@@ -263,7 +266,7 @@ function sanitize_general_settings( $input ) {
} else {
$input[Multi_Rating::RATING_RESULTS_CACHE_OPTION] = false;
}
-
+
// shortcode strip newlines
if ( isset( $input[Multi_Rating::TEMPLATE_STRIP_NEWLINES_OPTION] )
&& $input[Multi_Rating::TEMPLATE_STRIP_NEWLINES_OPTION] == 'true' ) {
@@ -271,7 +274,7 @@ function sanitize_general_settings( $input ) {
} else {
$input[Multi_Rating::TEMPLATE_STRIP_NEWLINES_OPTION] = false;
}
-
+
// hide rating form after submit
if ( isset( $input[Multi_Rating::HIDE_RATING_FORM_AFTER_SUBMIT_OPTION] )
&& $input[Multi_Rating::HIDE_RATING_FORM_AFTER_SUBMIT_OPTION] == 'true' ) {
@@ -279,20 +282,46 @@ function sanitize_general_settings( $input ) {
} else {
$input[Multi_Rating::HIDE_RATING_FORM_AFTER_SUBMIT_OPTION] = false;
}
-
+
return $input;
}
-
+
/**
* Register position settings
*/
function register_position_settings() {
-
+
register_setting( Multi_Rating::POSITION_SETTINGS, Multi_Rating::POSITION_SETTINGS, array( &$this, 'sanitize_position_settings' ) );
-
+
add_settings_section( 'section_position', __( 'Auto Placement Settings', 'multi-rating' ), array( &$this, 'section_position_desc' ), Multi_Rating::SETTINGS_PAGE_SLUG . '&setting=' . Multi_Rating::POSITION_SETTINGS );
+ $post_types = $post_types = get_post_types( array(
+ 'public' => true,
+ 'show_ui' => true
+ ), 'objects' );
+
+ $post_type_checkboxes = array();
+
+ foreach ( $post_types as $post_type ) {
+ array_push( $post_type_checkboxes, array(
+ 'name' => $post_type->name,
+ 'label' => $post_type->labels->name
+ ) );
+ }
+
$setting_fields = array(
+ Multi_Rating::POST_TYPES_OPTION => array(
+ 'title' => __( 'Post Types', 'rating-pro' ),
+ 'callback' => 'field_checkboxes',
+ 'page' => Multi_Rating::SETTINGS_PAGE_SLUG . '&setting=' . Multi_Rating::POSITION_SETTINGS,
+ 'section' => 'section_position',
+ 'args' => array(
+ 'option_name' => Multi_Rating::POSITION_SETTINGS,
+ 'setting_id' => Multi_Rating::POST_TYPES_OPTION,
+ 'description' => __( 'Enabled post types for auto placement.', 'multi-rating' ),
+ 'checkboxes' => $post_type_checkboxes
+ )
+ ),
Multi_Rating::RATING_FORM_POSITION_OPTION => array(
'title' => __( 'Rating Form Position', 'multi-rating' ),
'callback' => 'field_select',
@@ -301,12 +330,11 @@ function register_position_settings() {
'args' => array(
'option_name' => Multi_Rating::POSITION_SETTINGS,
'setting_id' => Multi_Rating::RATING_FORM_POSITION_OPTION,
- 'label' => __( 'Default rating form position on a post. You can integrate ratings in the WordPress comment form.', 'multi-rating' ),
+ 'label' => __( 'Default rating form position on a post.', 'multi-rating' ),
'select_options' => array(
'do_not_show' => __( 'Do not show', 'multi-rating' ),
'before_content' => __( 'Before content', 'multi-rating' ),
- 'after_content' => __( 'After content', 'multi-rating' ),
- 'comment_form' => __( 'Comment form', 'multi-rating' )
+ 'after_content' => __( 'After content', 'multi-rating' )
)
)
),
@@ -329,53 +357,54 @@ function register_position_settings() {
)
)
);
-
+
foreach ( $setting_fields as $setting_id => $setting_data ) {
-
+
// $id, $title, $callback, $page, $section, $args
add_settings_field( $setting_id, $setting_data['title'], array( $this, $setting_data['callback'] ), $setting_data['page'], $setting_data['section'], $setting_data['args'] );
}
}
-
+
/**
* Position section description
*/
function section_position_desc() {
-
+ _e( 'Note you can override the default auto placement settings on each post.', 'multi-rating' );
+
}
-
+
/**
* Sanitize auto placement settings
- *
+ *
* @param $input
* @return unknown
*/
- function sanitize_position_settings( $input ) {
+ function sanitize_position_settings( $input ) {
+
+ if ( ! isset( $input[Multi_Rating::POST_TYPES_OPTION] ) ) {
+ $input[Multi_Rating::POST_TYPES_OPTION] = array();
+ }
+
return $input;
}
-
-
+
+
/**
* Register style settings
*/
function register_style_settings() {
register_setting( Multi_Rating::STYLE_SETTINGS, Multi_Rating::STYLE_SETTINGS, array( &$this, 'sanitize_style_settings' ) );
-
- add_settings_section( 'section_styles', __( 'Style Settings', 'multi-rating' ), array( &$this, 'section_style_desc' ), Multi_Rating::SETTINGS_PAGE_SLUG . '&setting=' . Multi_Rating::STYLE_SETTINGS );
+
+ add_settings_section( 'section_styles', __( 'Style Settings', 'multi-rating' ), array( &$this, 'section_style_desc' ), Multi_Rating::SETTINGS_PAGE_SLUG . '&setting=' . Multi_Rating::STYLE_SETTINGS );
$icon_font_library_options = array(
- 'font-awesome-4.7.0' => __( 'Font Awesome 4.7.0', 'multi-rating' ),
- 'font-awesome-4.6.3' => __( 'Font Awesome 4.6.3', 'multi-rating' ),
- 'font-awesome-4.5.0' => __( 'Font Awesome 4.5.0', 'multi-rating' ),
- 'font-awesome-4.3.0' => __( 'Font Awesome 4.3.0', 'multi-rating' ),
- 'font-awesome-4.2.0' => __( 'Font Awesome 4.2.0', 'multi-rating' ),
- 'font-awesome-4.1.0' => __( 'Font Awesome 4.1.0', 'multi-rating' ),
- 'font-awesome-4.0.3' => __( 'Font Awesome 4.0.3', 'multi-rating' ),
- 'font-awesome-3.2.1' => __( 'Font Awesome 3.2.1', 'multi-rating' ),
- 'dashicons' => __( 'Dashicons', 'multi-rating' )
+ 'font-awesome-v5' => __( 'Font Awesome v5', 'multi-rating' ),
+ 'font-awesome-v4' => __( 'Font Awesome v4', 'multi-rating' ),
+ 'font-awesome-v3' => __( 'Font Awesome v3', 'multi-rating' ),
+ 'dashicons' => __( 'WordPress Dashicons', 'multi-rating' )
);
$icon_font_library_options = apply_filters( 'mr_icon_font_library_options', $icon_font_library_options );
-
+
$setting_fields = array(
Multi_Rating::STAR_RATING_COLOUR_OPTION => array(
'title' => __( 'Primary Color', 'multi-rating' ),
@@ -411,7 +440,7 @@ function register_style_settings() {
)
),
Multi_Rating::FONT_AWESOME_VERSION_OPTION => array(
- 'title' => __( 'Icon Font Library', 'multi-rating' ),
+ 'title' => __( 'Icons', 'multi-rating' ),
'callback' => 'field_select',
'page' => Multi_Rating::SETTINGS_PAGE_SLUG . '&setting=' . Multi_Rating::STYLE_SETTINGS,
'section' => 'section_styles',
@@ -423,25 +452,14 @@ function register_style_settings() {
)
),
Multi_Rating::INCLUDE_FONT_AWESOME_OPTION => array(
- 'title' => __( 'Load Icon Font Library from CDN', 'multi-rating' ),
+ 'title' => __( 'Load Icons', 'multi-rating' ),
'callback' => 'field_checkbox',
'page' => Multi_Rating::SETTINGS_PAGE_SLUG . '&setting=' . Multi_Rating::STYLE_SETTINGS,
'section' => 'section_styles',
'args' => array(
'option_name' => Multi_Rating::STYLE_SETTINGS,
'setting_id' => Multi_Rating::INCLUDE_FONT_AWESOME_OPTION,
- 'label' => __( 'Check this box if you want to load the font icon library from a CDN.', 'multi-rating' )
- )
- ),
- Multi_Rating::CUSTOM_CSS_OPTION => array(
- 'title' => __( 'Custom CSS', 'multi-rating' ),
- 'callback' => 'field_textarea',
- 'page' => Multi_Rating::SETTINGS_PAGE_SLUG . '&setting=' . Multi_Rating::STYLE_SETTINGS,
- 'section' => 'section_styles',
- 'args' => array(
- 'option_name' => Multi_Rating::STYLE_SETTINGS,
- 'setting_id' => Multi_Rating::CUSTOM_CSS_OPTION,
- 'footer' => __( 'Enter custom CSS styles above.', 'multi-rating' )
+ 'label' => __( 'If your theme or another plugin is already loading these icons, you should uncheck this to avoid any conflicts. ', 'multi-rating' )
)
),
Multi_Rating::DISABLE_STYLES_OPTION => array(
@@ -456,21 +474,21 @@ function register_style_settings() {
)
),
);
-
+
foreach ( $setting_fields as $setting_id => $setting_data ) {
-
+
// $id, $title, $callback, $page, $section, $args
add_settings_field( $setting_id, $setting_data['title'], array( $this, $setting_data['callback'] ), $setting_data['page'], $setting_data['section'], $setting_data['args'] );
}
}
-
+
/**
* Style section description
*/
function section_style_desc() {
-
+
}
-
+
/**
* Sanitize style settings
*
@@ -478,32 +496,30 @@ function section_style_desc() {
* @return string
*/
function sanitize_style_settings( $input ) {
-
+
if ( isset( $input[Multi_Rating::INCLUDE_FONT_AWESOME_OPTION] ) && $input[Multi_Rating::INCLUDE_FONT_AWESOME_OPTION] == 'true' ) {
$input[Multi_Rating::INCLUDE_FONT_AWESOME_OPTION] = true;
} else {
$input[Multi_Rating::INCLUDE_FONT_AWESOME_OPTION] = false;
}
-
+
if ( isset( $input[Multi_Rating::DISABLE_STYLES_OPTION] ) && $input[Multi_Rating::DISABLE_STYLES_OPTION] == 'true' ) {
$input[Multi_Rating::DISABLE_STYLES_OPTION] = true;
} else {
$input[Multi_Rating::DISABLE_STYLES_OPTION] = false;
}
-
- $input[Multi_Rating::CUSTOM_CSS_OPTION] = addslashes($input[Multi_Rating::CUSTOM_CSS_OPTION]);
-
+
return $input;
}
-
+
/**
* Register custom images settings
*/
function register_custom_images_settings() {
-
+
register_setting( Multi_Rating::CUSTOM_IMAGES_SETTINGS, Multi_Rating::CUSTOM_IMAGES_SETTINGS, array( &$this, 'sanitize_custom_images_settings' ) );
-
+
add_settings_section( 'section_custom_images', __( 'Custom Images', 'multi-rating' ), array( &$this, 'section_custom_images_desc' ), Multi_Rating::SETTINGS_PAGE_SLUG . '&setting=' . Multi_Rating::CUSTOM_IMAGES_SETTINGS );
$setting_fields = array(
@@ -597,21 +613,21 @@ function register_custom_images_settings() {
)
)
);
-
+
foreach ( $setting_fields as $setting_id => $setting_data ) {
-
+
// $id, $title, $callback, $page, $section, $args
add_settings_field( $setting_id, $setting_data['title'], array( $this, $setting_data['callback'] ), $setting_data['page'], $setting_data['section'], $setting_data['args'] );
}
}
-
+
/**
* Custom images section description
*/
function section_custom_images_desc() {
-
+
}
-
+
/**
* Sanitize custom images settings
*
@@ -619,20 +635,20 @@ function section_custom_images_desc() {
* @return string
*/
function sanitize_custom_images_settings( $input ) {
-
+
if ( isset( $input[Multi_Rating::USE_CUSTOM_STAR_IMAGES] ) && $input[Multi_Rating::USE_CUSTOM_STAR_IMAGES] == 'true' ) {
$input[Multi_Rating::USE_CUSTOM_STAR_IMAGES] = true;
} else {
$input[Multi_Rating::USE_CUSTOM_STAR_IMAGES] = false;
}
-
+
// make sure at least full, half and empty star images exist and are valid URL's
if ( filter_var( $input[Multi_Rating::CUSTOM_FULL_STAR_IMAGE], FILTER_VALIDATE_URL ) === false ||
filter_var( $input[Multi_Rating::CUSTOM_HALF_STAR_IMAGE], FILTER_VALIDATE_URL ) === false ||
filter_var( $input[Multi_Rating::CUSTOM_EMPTY_STAR_IMAGE], FILTER_VALIDATE_URL ) === false ) {
add_settings_error( Multi_Rating::CUSTOM_IMAGES_SETTINGS, 'validation_error_custom_images', __( 'Full star, half star and empty star custom images are required.', 'multi-rating' ), 'error' );
}
-
+
// check file types
$valid_file_mime_types = array(
'image/jpeg',
@@ -642,31 +658,31 @@ function sanitize_custom_images_settings( $input ) {
'image/tiff',
'image/x-icon'
);
-
+
if ( isset( $input[Multi_Rating::CUSTOM_FULL_STAR_IMAGE] ) ) {
$file_mime_type = wp_check_filetype( $input[Multi_Rating::CUSTOM_FULL_STAR_IMAGE] );
-
+
if ( ! in_array( $file_mime_type['type'], $valid_file_mime_types) ) {
add_settings_error( Multi_Rating::CUSTOM_IMAGES_SETTINGS, 'invalid_mime_type', __( 'Invalid image format. Valid mime types: image/jpeg, image/png, image/bmp, image/tiff and image/x-icon', 'multi-rating' ), 'error' );
}
}
-
+
// check image height and width are valid numbers within 1 and 128
$custom_image_height = $input[Multi_Rating::CUSTOM_STAR_IMAGE_HEIGHT];
$custom_image_width = $input[Multi_Rating::CUSTOM_STAR_IMAGE_WIDTH];
-
+
if ( ! is_numeric( $custom_image_height) ) {
add_settings_error( Multi_Rating::CUSTOM_IMAGES_SETTINGS, 'non_numeric_custom_image_height', __( 'Custom image height must be numeric.', 'multi-rating' ), 'error' );
} else if ( intval( $custom_image_height ) < 1 || intval( $custom_image_height ) > 128 ) {
add_settings_error( Multi_Rating::CUSTOM_IMAGES_SETTINGS, 'range_error_custom_image_height', __( 'Custom image height cannot be less than 1 or greater than 128.', 'multi-rating' ), 'error' );
}
-
+
if ( ! is_numeric($custom_image_width) ) {
add_settings_error( Multi_Rating::CUSTOM_IMAGES_SETTINGS, 'non_numeric_custom_image_width', __( 'Custom image width must be numeric.', 'multi-rating' ), 'error' );
} else if ( $custom_image_width < 1 || $custom_image_width > 128 ) {
add_settings_error( Multi_Rating::CUSTOM_IMAGES_SETTINGS, 'range_error_custom_image_width', __( 'Custom image width cannot be less than 1 or greater than 128.', 'multi-rating' ), 'error' );
}
-
+
return $input;
}
@@ -674,11 +690,11 @@ function sanitize_custom_images_settings( $input ) {
* Register custom text settings
*/
function register_custom_text_settings() {
-
+
register_setting( Multi_Rating::CUSTOM_TEXT_SETTINGS, Multi_Rating::CUSTOM_TEXT_SETTINGS, array( &$this, 'sanitize_custom_text_settings' ) );
-
+
add_settings_section( 'section_custom_text', __( 'Custom Text Settings', 'multi-rating' ), array( &$this, 'section_custom_text_desc' ), Multi_Rating::SETTINGS_PAGE_SLUG . '&setting=' . Multi_Rating::CUSTOM_TEXT_SETTINGS );
-
+
$setting_fields = array(
Multi_Rating::RATING_FORM_TITLE_TEXT_OPTION => array(
'title' => __( 'Rating Form Title', 'multi-rating' ),
@@ -784,31 +800,31 @@ function register_custom_text_settings() {
)
)
);
-
+
foreach ( $setting_fields as $setting_id => $setting_data ) {
-
+
// $id, $title, $callback, $page, $section, $args
add_settings_field( $setting_id, $setting_data['title'], array( $this, $setting_data['callback'] ), $setting_data['page'], $setting_data['section'], $setting_data['args'] );
- }
+ }
}
-
+
/**
* Custom text section description
*/
public function section_custom_text_desc() {
-
- }
-
+
+ }
+
/**
* Sanitize custom text settings
- *
+ *
* @param $input
* @return unknown
*/
function sanitize_custom_text_settings( $input ) {
return $input;
}
-
+
/**
* Checkbox setting
@@ -817,12 +833,12 @@ function field_checkbox( $args ) {
$settings = (array) get_option( $args['option_name' ] );
?>
/>
-
-
+
/>
-
-
-
$args['option_name' ] . '[' . $args['setting_id'] . ']',
'editor_class' => ''
) );
-
+
echo ( ! empty( $args['footer'] ) ) ? '' . $args['footer'] . '
' : '';
}
-
+
/**
* Color picker field
- *
+ *
* @param unknown $args
*/
function field_color_picker( $args ) {
@@ -911,7 +927,7 @@ function field_color_picker( $args ) {
- $option_label ) {
$selected = '';
if ( $value == $option_value ) {
@@ -932,23 +948,23 @@ function field_select( $args ) {
}
?>
-
/>
-
@@ -971,4 +987,4 @@ function field_checkboxes( $args ) {
}
}
}
-?>
\ No newline at end of file
+?>
diff --git a/includes/class-structured-data.php b/includes/class-structured-data.php
new file mode 100644
index 0000000..895d182
--- /dev/null
+++ b/includes/class-structured-data.php
@@ -0,0 +1,194 @@
+ $piece ) {
+ $path = explode('\\', get_class( $piece) );
+ $className = array_pop( $path );
+ add_filter( 'wpseo_schema_' . strtolower( $className ), array( $this, 'wpseo_structured_data' ), 99, 1 );
+ }
+
+ return $pieces;
+ }
+
+
+ /**
+ * Creates new type on the post with AggregateRating structured data
+ */
+ public function create_new_type() {
+
+ if ( is_page() || is_single() ) {
+
+ $post_id = get_queried_object_id();
+ if ($post_id == null) {
+ return;
+ }
+
+ $structured_data_type = get_post_meta( $post_id, Multi_Rating::STRUCTURED_DATA_TYPE_POST_META, true );
+
+ $structured_data_type = apply_filters( 'mr_structured_data_item_type', $structured_data_type, $post_id );
+
+ if ( $structured_data_type == '' ) {
+ return;
+ }
+
+ /*
+ * Don't add piece if WooCommerce structured data is enabled
+ */
+ $general_settings = (array) get_option( Multi_Rating::GENERAL_SETTINGS );
+ $add_structured_data = $general_settings[ Multi_Rating::ADD_STRUCTURED_DATA_OPTION ];
+ if ( class_exists( 'woocommerce' ) && in_array( 'woocommerce', $add_structured_data )
+ && get_post_type( $post_id ) === 'product' ) {
+ return;
+ }
+
+ /*
+ * Get data to create aggregate rating structured data
+ */
+ $rating_result = Multi_Rating_API::get_rating_result( $post_id );
+
+ if ($rating_result == null
+ || ($rating_result !== null && $rating_result['count'] === 0)) {
+ return;
+ }
+
+ $post_title = get_the_title( $post_id );
+ $post_thumbnail_url = get_the_post_thumbnail_url( $post_id );
+ $post_excerpt = get_the_excerpt( $post_id );
+
+ ?>
+
+ "AggregateRating",
+ 'reviewCount' => $rating_result['count'],
+ 'ratingValue' => $rating_result['adjusted_star_result']
+ );
+
+ return $schema;
+ }
+
+
+ /**
+ * Adds AggregateRating structured data for WooCommerce products
+ *
+ * @parameter schema
+ * @parameter product
+ */
+ function woocommerce_product( $schema, $product ) {
+
+ $rating_result = Multi_Rating_API::get_rating_result( $product->get_id() );
+
+ if ($rating_result == null
+ || ($rating_result !== null && $rating_result['count'] === 0)) {
+ return $schema;
+ }
+
+ $schema['aggregateRating'] = array(
+ '@type' => "AggregateRating",
+ 'reviewCount' => $rating_result['count'],
+ 'ratingValue' => $rating_result['adjusted_star_result']
+ );
+
+ return $schema;
+ }
+
+}
diff --git a/includes/class-utils.php b/includes/class-utils.php
index 06be620..bc9ea2f 100644
--- a/includes/class-utils.php
+++ b/includes/class-utils.php
@@ -7,32 +7,6 @@
*/
class MR_Utils {
- /**
- * Gets the client ip address
- *
- * @return IP address
- */
- public static function get_ip_address() {
-
- $client_IP_address = '';
-
- if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
- $client_IP_address = $_SERVER['HTTP_CLIENT_IP'];
- } else if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
- $client_IP_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
- } else if ( isset( $_SERVER['HTTP_X_FORWARDED'] ) ) {
- $client_IP_address = $_SERVER['HTTP_X_FORWARDED'];
- } else if ( isset( $_SERVER['HTTP_FORWARDED_FOR'] ) ) {
- $client_IP_address = $_SERVER['HTTP_FORWARDED_FOR'];
- } else if ( isset( $_SERVER['HTTP_FORWARDED'] ) ) {
- $client_IP_address = $_SERVER['HTTP_FORWARDED'];
- } else if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
- $client_IP_address = $_SERVER['REMOTE_ADDR'];
- }
-
- return $client_IP_address;
- }
-
/**
* Gets the current URL
*
@@ -189,20 +163,23 @@ public static function remove_query_string_params( $url, $params ) {
* @return array icon classes
*/
public static function get_icon_classes( $icon_font_library ) {
-
$icon_classes = array();
-
- if ( $icon_font_library == 'font-awesome-4.0.3' || $icon_font_library == 'font-awesome-4.1.0'
- || $icon_font_library == 'font-awesome-4.2.0' || $icon_font_library == 'font-awesome-4.3.0'
- || $icon_font_library == 'font-awesome-4.5.0' || $icon_font_library == 'font-awesome-4.6.3'
- || $icon_font_library == 'font-awesome-4.7.0' ) {
+
+ if ( $icon_font_library == 'font-awesome-v5' ) {
+ $icon_classes['star_full'] = 'fas fa-star mr-star-full';
+ $icon_classes['star_hover'] = 'fas fa-star mr-star-hover';
+ $icon_classes['star_half'] = 'fas fa-star-half-alt mr-star-half';
+ $icon_classes['star_empty'] = 'far fa-star mr-star-empty';
+ $icon_classes['minus'] = 'fas fa-minus mr-minus';
+ $icon_classes['spinner'] = 'fas fa-spinner fa-spin mr-spinner';
+ } else if ( $icon_font_library == 'font-awesome-v4' ) {
$icon_classes['star_full'] = 'fa fa-star mr-star-full';
$icon_classes['star_hover'] = 'fa fa-star mr-star-hover';
$icon_classes['star_half'] = 'fa fa-star-half-o mr-star-half';
$icon_classes['star_empty'] = 'fa fa-star-o mr-star-empty';
$icon_classes['minus'] = 'fa fa-minus-circle mr-minus';
$icon_classes['spinner'] = 'fa fa-spinner fa-spin mr-spinner';
- } else if ( $icon_font_library == 'font-awesome-3.2.1' ) {
+ } else if ( $icon_font_library == 'font-awesome-v3' ) {
$icon_classes['star_full'] = 'icon-star mr-star-full';
$icon_classes['star_hover'] = 'icon-star mr-star-hover';
$icon_classes['star_half'] = 'icon-star-half-full mr-star-half';
@@ -225,7 +202,7 @@ public static function get_icon_classes( $icon_font_library ) {
* @param $post_id
*/
public static function check_post_type_enabled( $post_id ) {
- $general_settings = (array) get_option( Multi_Rating::GENERAL_SETTINGS );
+ $general_settings = (array) get_option( Multi_Rating::POSITION_SETTINGS );
$post_types = $general_settings[ Multi_Rating::POST_TYPES_OPTION ];
if ( ! isset( $post_types ) ) {
@@ -245,7 +222,7 @@ public static function check_post_type_enabled( $post_id ) {
}
/**
- * Perform cookie and IP address restriction type checks
+ * Perform save rating restriction type checks
*
* @param array validation_results
* @param int $post_id
@@ -255,13 +232,11 @@ public static function validate_save_rating_restricton( $validation_results, $po
$general_settings = (array) get_option( Multi_Rating::GENERAL_SETTINGS );
$hours = $general_settings[Multi_Rating::SAVE_RATING_RESTRICTION_HOURS_OPTION];
- $ip_address = MR_Utils::get_ip_address();
$save_rating_restriction_types = $general_settings[Multi_Rating::SAVE_RATING_RESTRICTION_TYPES_OPTION];
foreach ( $save_rating_restriction_types as $save_rating_restriction_type ) {
- if ( ( $save_rating_restriction_type == 'ip_address' && MR_Utils::ip_address_validation_check( $ip_address, $post_id, $hours ) == true )
- || ( $save_rating_restriction_type == 'cookie' && MR_Utils::cookie_validation_check( $post_id ) == true ) ) {
+ if ( $save_rating_restriction_type == 'cookie' && isset( $_COOKIE[Multi_Rating::POST_SAVE_RATING_COOKIE . '-' . $post_id] ) ) {
$custom_text_settings = (array) Multi_Rating::instance()->settings->custom_text_settings;
@@ -275,30 +250,7 @@ public static function validate_save_rating_restricton( $validation_results, $po
return $validation_results;
}
-
- /**
- * Checks whether save rating cookie exists for a post
- *
- * @param $post_id
- */
- public static function cookie_validation_check( $post_id ) {
- return isset( $_COOKIE[Multi_Rating::POST_SAVE_RATING_COOKIE . '-' . $post_id] );
- }
- /**
- * Check IP address has not saved a rating form with the post ID within specified hours
- */
- public static function ip_address_validation_check( $ip_address, $post_id, $hours ) {
- global $wpdb;
-
- $previous_day_date = date( 'Y-m-d H:i:s', strtotime( current_time('mysql') ) - ( 1 * 1 * 60 * 60 * $hours ) );
-
- $query = 'SELECT * FROM ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME
- . ' WHERE ip_address = %s AND post_id = %d AND entry_date >= %s';
- $rows = $wpdb->get_results( $wpdb->prepare( $query, $ip_address, $post_id, $previous_day_date ) );
-
- return ( count( $rows ) > 0 );
- }
/**
* Checks if any ratings items are required which means zero cannot be selected
diff --git a/includes/misc-functions.php b/includes/misc-functions.php
index d5427dd..d3134b4 100644
--- a/includes/misc-functions.php
+++ b/includes/misc-functions.php
@@ -59,7 +59,7 @@ function mr_template_html_strip_newlines( $html ) {
return $html;
}
add_filter( 'mr_template_html', 'mr_template_html_strip_newlines', 10, 1 );
-
+
/**
* add a link to the Pro version in the menu
@@ -67,8 +67,8 @@ function mr_template_html_strip_newlines( $html ) {
function mr_add_pro_menu_item() {
global $submenu;
- $submenu['mr_rating_results'][] = array( 'Pro version', 'manage_options', 'http://multiratingpro.com?utm_source=menu&utm_medium=free-plugin&utm_campaign=wp-admin' );
+ $submenu['mr_rating_results'][] = array( 'Upgrade to Pro', 'manage_options', 'http://multiratingpro.com?utm_source=menu&utm_medium=free-plugin&utm_campaign=wp-admin' );
}
add_action( 'admin_menu', 'mr_add_pro_menu_item' );
- ?>
\ No newline at end of file
+ ?>
diff --git a/includes/rest-api-custom-fields.php b/includes/rest-api-custom-fields.php
new file mode 100644
index 0000000..9f3390b
--- /dev/null
+++ b/includes/rest-api-custom-fields.php
@@ -0,0 +1,20 @@
+ $post_id,
'no_rating_results_text' => $custom_text_settings[Multi_Rating::NO_RATING_RESULTS_TEXT_OPTION],
- 'show_rich_snippets' => false, // @deprecated
'show_title' => false,
'show_count' => true,
'result_type' => Multi_Rating::STAR_RATING_RESULT_TYPE,
'class' => '',
'before_count' => '(',
- 'after_count' => ')',
- 'generate_microdata' => false
+ 'after_count' => ')'
), $atts ) );
if ( $post_id == null ) {
return; // No post Id available
}
- if ( is_string( $show_rich_snippets ) ) {
- $show_rich_snippets = $show_rich_snippets == 'true' ? true : false;
- $generate_microdata = $show_rich_snippets;
- }
- if ( is_string( $generate_microdata ) ) {
- $generate_microdata = $generate_microdata == 'true' ? true : false;
- }
if ( is_string( $show_title) ) {
$show_title = $show_title == 'true' ? true : false;
}
@@ -101,7 +92,6 @@ function mr_rating_result( $atts = array(), $content = null, $tag ) {
return Multi_Rating_API::display_rating_result( array(
'post_id' => $post_id,
'no_rating_results_text' => $no_rating_results_text,
- 'generate_microdata' => $generate_microdata,
'show_title' => $show_title,
'show_date' => false,
'show_count' => $show_count,
@@ -174,6 +164,9 @@ function mr_rating_results_list( $atts = array(), $content = null, $tag ) {
if ( is_string( $show_featured_img ) ) {
$show_featured_img = $show_featured_img == 'true' ? true : false;
}
+ if ( is_string( $show_rank ) ) {
+ $show_rank = $show_rank == 'true' ? true : false;
+ }
if ( $category_id != 0 ) {
$term_id = $category_id;
diff --git a/includes/template-functions.php b/includes/template-functions.php
index 071b02a..afcab1d 100644
--- a/includes/template-functions.php
+++ b/includes/template-functions.php
@@ -1,8 +1,8 @@
- $icon_classes,
'use_custom_star_images' => $use_custom_star_images,
'image_width' => $image_width,
'image_height' => $image_height,
'star_rating_colour' => $star_rating_colour
- ) );
+ ), $template_vars );
}
add_filter( 'mr_load_template_params', 'mr_load_star_rating_style_params' );
-?>
\ No newline at end of file
+?>
diff --git a/includes/widgets.php b/includes/widgets.php
index 13c8893..d0b4bfc 100644
--- a/includes/widgets.php
+++ b/includes/widgets.php
@@ -493,26 +493,6 @@ function form( $instance ) {
}
-/**
- * Checks filters settings to determine whether rating form or rating results widget can be applied
- *
- * @param boolean $can_apply_widget
- * @param string $filter_name
- * @param string $value
- * @param int $post_id
- * @return $can_apply_widget
- */
-function mr_can_apply_widget( $can_apply_widget, $post_id, $args, $instance ) {
-
- if ( $can_apply_widget ) {
- $can_apply_widget = MR_Utils::check_post_type_enabled( $post_id );
- }
-
- return $can_apply_widget;
-}
-add_filter( 'mr_can_apply_widget', 'mr_can_apply_widget', 10, 4 );
-
-
/**
* Gets terms by taxonomy and returns a JSON response
*/
diff --git a/languages/multi-rating.pot b/languages/multi-rating.pot
index 9be81bc..c48afa8 100644
--- a/languages/multi-rating.pot
+++ b/languages/multi-rating.pot
@@ -1,7 +1,8 @@
+#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: multi-rating\n"
-"POT-Creation-Date: 2017-02-10 21:45+1000\n"
+"POT-Creation-Date: 2020-09-21 08:51+1000\n"
"PO-Revision-Date: 2017-02-10 21:45+1000\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -9,481 +10,520 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"X-Generator: Poedit 1.7.5\n"
+"X-Generator: Poedit 2.0.6\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: __;_e\n"
"X-Poedit-SearchPath-0: ..\n"
-#: ../includes/admin/about.php:72 ../includes/admin/class-post-metabox.php:31
-#: ../multi-rating.php:394
-msgid "Multi Rating"
+#: ../assets/js/blocks.js:16 ../includes/widgets.php:386
+msgid "Rating Form"
msgstr ""
-#: ../includes/admin/about.php:73
-#, php-format
-msgid "Multi Rating v%s"
+#: ../assets/js/blocks.js:17
+msgid "Adds a rating form for a post."
msgstr ""
-#: ../includes/admin/about.php:75
-msgid ""
-"The best rating system plugin for WordPress. This is a simple plugin which "
-"allows users to rate posts based on multiple criteria and questions."
+#: ../assets/js/blocks.js:48 ../assets/js/blocks.js:186
+#: ../includes/widgets.php:153 ../includes/widgets.php:469
+msgid "Title"
msgstr ""
-#: ../includes/admin/about.php:84
-msgid "Getting Started"
+#: ../assets/js/blocks.js:60 ../includes/class-settings.php:722
+msgid "Submit Button Text"
msgstr ""
-#: ../includes/admin/about.php:85
-msgid "Support"
+#: ../assets/js/blocks.js:85 ../includes/admin/class-rating-entry-table.php:30
+#: ../includes/widgets.php:311
+msgid "Rating Result"
msgstr ""
-#: ../includes/admin/about.php:86
-msgid "Pro version available!"
+#: ../assets/js/blocks.js:86
+msgid "Displays an average rating result for a post."
msgstr ""
-#: ../includes/admin/about.php:101
-msgid "Use the tips below to help you get started."
+#: ../assets/js/blocks.js:117
+msgid "Show Title"
msgstr ""
-#: ../includes/admin/about.php:106
-msgid "Add New Rating Items"
+#: ../assets/js/blocks.js:128 ../assets/js/blocks.js:212
+msgid "Show Count"
msgstr ""
-#: ../includes/admin/about.php:107
-#, php-format
-msgid ""
-"Setup your criteria and questions by adding "
-"new rating items ."
+#: ../assets/js/blocks.js:154 ../includes/widgets.php:14
+msgid "Rating Results List"
msgstr ""
-#: ../includes/admin/about.php:111 ../includes/class-settings.php:293
-msgid "Auto Placement Settings"
+#: ../assets/js/blocks.js:155
+msgid "Displays a list of the highest average rating results for posts."
msgstr ""
-#: ../includes/admin/about.php:112
-#, php-format
-msgid ""
-"Use the automatic placement settings to "
-"set the rating form and rating results to display on every post or page in "
-"default positions."
+#: ../assets/js/blocks.js:198 ../includes/widgets.php:157
+msgid "Limit"
msgstr ""
-#: ../includes/admin/about.php:116
-msgid "View the Frontend"
+#: ../assets/js/blocks.js:223 ../includes/widgets.php:227
+msgid "Show Filter"
msgstr ""
-#: ../includes/admin/about.php:117
-msgid ""
-"If everything is setup correctly, the rating form and rating results should "
-"appear on your website!"
+#: ../assets/js/blocks.js:234 ../includes/widgets.php:239
+msgid "Show Rank"
msgstr ""
-#: ../includes/admin/about.php:124
-msgid "Shortcodes"
+#: ../assets/js/blocks.js:245 ../includes/widgets.php:235
+msgid "Show Featured Image"
msgstr ""
-#: ../includes/admin/about.php:125
-msgid "[mr_rating_form] - displays the rating form."
+#: ../assets/js/plugin.js:32 ../includes/admin/class-post-metabox.php:93
+#: ../includes/class-settings.php:326
+msgid "Rating Form Position"
msgstr ""
-#: ../includes/admin/about.php:126
-msgid "[mr_rating_results_list] - displays a list of rating results."
+#: ../assets/js/plugin.js:33
+msgid "Add the rating form to the post."
msgstr ""
-#: ../includes/admin/about.php:127
-msgid "[mr_rating_result] - displays the rating result"
+#: ../assets/js/plugin.js:35 ../assets/js/plugin.js:71
+#: ../includes/admin/class-post-metabox.php:96
+#: ../includes/admin/class-post-metabox.php:107
+#: ../includes/class-settings.php:335 ../includes/class-settings.php:351
+msgid "Do not show"
msgstr ""
-#: ../includes/admin/about.php:128
-#, php-format
-msgid ""
-"Refer to the documentation for more information on the "
-"attributes available."
+#: ../assets/js/plugin.js:36 ../assets/js/plugin.js:72
+#: ../includes/admin/class-post-metabox.php:97
+#: ../includes/admin/class-post-metabox.php:108
+msgid "Use default settings"
msgstr ""
-#: ../includes/admin/about.php:132
-msgid "View Rating Results"
+#: ../assets/js/plugin.js:37 ../assets/js/plugin.js:75
+#: ../includes/admin/class-post-metabox.php:98
+#: ../includes/admin/class-post-metabox.php:111
+#: ../includes/class-settings.php:336 ../includes/class-settings.php:354
+msgid "Before content"
msgstr ""
-#: ../includes/admin/about.php:133
-#, php-format
-msgid ""
-"View all rating results and entries from "
-"the WP-admin."
+#: ../assets/js/plugin.js:38 ../assets/js/plugin.js:76
+#: ../includes/admin/class-post-metabox.php:99
+#: ../includes/admin/class-post-metabox.php:112
+#: ../includes/class-settings.php:337 ../includes/class-settings.php:355
+msgid "After content"
msgstr ""
-#: ../includes/admin/about.php:141
-msgid "Custom Post Types"
+#: ../assets/js/plugin.js:40
+msgid "Auto placement position for the rating form on the post."
msgstr ""
-#: ../includes/admin/about.php:142
-msgid ""
-"If you want to use the plugin for pages and other post types you'll need to "
-"be enable them in the plugin settings."
+#: ../assets/js/plugin.js:68 ../includes/admin/class-post-metabox.php:104
+#: ../includes/class-settings.php:342
+msgid "Rating Result Position"
msgstr ""
-#: ../includes/admin/about.php:144
-msgid "Custom Taxonomy"
+#: ../assets/js/plugin.js:69
+msgid "Add the rating result to the post."
msgstr ""
-#: ../includes/admin/about.php:145
-msgid ""
-"Shortcodes and API support custom taxonomies e.g. [mr_rating_resultlist "
-"taxonomy=\"post_tag\" term_id=\"1\"]. The category_id attribute is a "
-"shortcut to taxonomy=\"category\" and term_id=\"category_id\"."
+#: ../assets/js/plugin.js:73 ../includes/admin/class-post-metabox.php:109
+#: ../includes/class-settings.php:352
+msgid "Before title"
msgstr ""
-#: ../includes/admin/about.php:147
-msgid "I18n, WPML & Custom Text"
+#: ../assets/js/plugin.js:74 ../includes/admin/class-post-metabox.php:110
+#: ../includes/class-settings.php:353
+msgid "After title"
msgstr ""
-#: ../includes/admin/about.php:148
-msgid ""
-"The plugin has been internationalized and is translation ready (.pot file in "
-"the languages directory). The plugin is fully WPML compatible. You can also "
-"modify the default text and messages."
+#: ../assets/js/plugin.js:78
+msgid "Auto placement position for the rating result on the post."
msgstr ""
-#: ../includes/admin/about.php:150
-msgid "Template System"
+#: ../assets/js/plugin.js:109
+msgid "Schema.org item type for post."
msgstr ""
-#: ../includes/admin/about.php:151
-msgid "The plugin has an in-built template system."
+#: ../assets/js/plugin.js:112 ../includes/admin/class-post-metabox.php:122
+msgid "Book"
msgstr ""
-#: ../includes/admin/about.php:156
-msgid "Rich Snippets"
+#: ../assets/js/plugin.js:113 ../includes/admin/class-post-metabox.php:123
+msgid "Course"
msgstr ""
-#: ../includes/admin/about.php:157
-msgid ""
-"schema.org structured markup can be be "
-"added to every page which allows search engines to display the aggregated "
-"rating results as rich snippets."
+#: ../assets/js/plugin.js:114 ../includes/admin/class-post-metabox.php:124
+msgid "CreativeWorkSeason"
msgstr ""
-#: ../includes/admin/about.php:160
-msgid "Icon Font Libraries"
+#: ../assets/js/plugin.js:115 ../includes/admin/class-post-metabox.php:125
+msgid "CreativeWorkSeries"
msgstr ""
-#: ../includes/admin/about.php:161
-msgid ""
-"Font Awesome and Dashicon icon font libraries are supported by the plugin."
+#: ../assets/js/plugin.js:116 ../includes/admin/class-post-metabox.php:126
+msgid "Episode"
msgstr ""
-#: ../includes/admin/about.php:163
-msgid "Upload Custom Star Images"
+#: ../assets/js/plugin.js:117 ../includes/admin/class-post-metabox.php:127
+msgid "Event"
msgstr ""
-#: ../includes/admin/about.php:164
-msgid ""
-"You can upload your own custom star images to "
-"use instead of the using icon fonts."
+#: ../assets/js/plugin.js:118 ../includes/admin/class-post-metabox.php:128
+msgid "Game"
msgstr ""
-#: ../includes/admin/about.php:166 ../includes/admin/tools.php:13
-msgid "Export Rating Results"
+#: ../assets/js/plugin.js:119 ../includes/admin/class-post-metabox.php:129
+msgid "HowTo"
msgstr ""
-#: ../includes/admin/about.php:167
-msgid "You can export the rating results to a CSV file."
+#: ../assets/js/plugin.js:120 ../includes/admin/class-post-metabox.php:130
+msgid "LocalBusiness"
msgstr ""
-#: ../includes/admin/about.php:169
-msgid "Edit Ratings"
+#: ../assets/js/plugin.js:121 ../includes/admin/class-post-metabox.php:131
+msgid "MediaObject"
msgstr ""
-#: ../includes/admin/about.php:170
-msgid ""
-"Administrator and Editor user roles have the capability to edit ratings."
+#: ../assets/js/plugin.js:122 ../includes/admin/class-post-metabox.php:132
+msgid "Movie"
+msgstr ""
+
+#: ../assets/js/plugin.js:123 ../includes/admin/class-post-metabox.php:133
+msgid "MusicPlaylist"
+msgstr ""
+
+#: ../assets/js/plugin.js:124 ../includes/admin/class-post-metabox.php:134
+msgid "MusicRecording"
+msgstr ""
+
+#: ../assets/js/plugin.js:125 ../includes/admin/class-post-metabox.php:135
+msgid "Organization"
msgstr ""
-#: ../includes/admin/about.php:175 ../multi-rating.php:400
-msgid "Reports"
+#: ../assets/js/plugin.js:126 ../includes/admin/class-post-metabox.php:136
+msgid "Product"
msgstr ""
-#: ../includes/admin/about.php:176
-msgid "You can view the number of rating entries per day over time."
+#: ../assets/js/plugin.js:127 ../includes/admin/class-post-metabox.php:137
+msgid "Recipe"
msgstr ""
-#: ../includes/admin/about.php:179
-msgid "Meta-box"
+#: ../assets/js/plugin.js:128 ../includes/admin/class-post-metabox.php:138
+msgid "SoftwareApplication"
msgstr ""
-#: ../includes/admin/about.php:180
+#: ../assets/js/plugin.js:130 ../includes/admin/class-post-metabox.php:140
msgid ""
-"There's a meta-box on the edit post page so that you can override the "
-"default settings (e.g. auto placement settings)."
+"Schema.org item type for post. If you have the WordPress SEO or WooCommerce "
+"plugins adding structured data for the type already, do not set. Note some "
+"types may require additional structured data."
+msgstr ""
+
+#: ../assets/js/plugin.js:158 ../assets/js/plugin.js:165
+#: ../includes/admin/about.php:27 ../includes/admin/class-post-metabox.php:29
+#: ../multi-rating.php:397
+msgid "Multi Rating"
msgstr ""
-#: ../includes/admin/about.php:182
-msgid "Developer API"
+#: ../assets/js/plugin.js:174
+msgid "Auto Placement"
msgstr ""
-#: ../includes/admin/about.php:183
+#: ../assets/js/plugin.js:191 ../includes/class-settings.php:131
+msgid "Structured Data"
+msgstr ""
+
+#: ../assets/js/plugin.js:200
msgid ""
-"The API functions are located in the class-api.php file which contains a "
-"static class called Multi_Rating_API."
+"Supports rich snippets with aggregate ratings for the post in search engine "
+"results pages (SERP)."
msgstr ""
-#: ../includes/admin/about.php:185
-msgid "Action Hooks & Filters"
+#: ../includes/admin/about.php:28
+#, php-format
+msgid "Multi Rating v%s"
msgstr ""
-#: ../includes/admin/about.php:186
+#: ../includes/admin/about.php:30
msgid ""
-"Developers can extend the plugin functionality using action hooks and "
-"filters."
+"A powerful rating system and review plugin for WordPress; with a niche of "
+"doing multi-ratings better than anyone else."
msgstr ""
-#: ../includes/admin/about.php:188
-msgid "GitHub"
+#: ../includes/admin/about.php:39
+msgid "Getting Started"
msgstr ""
-#: ../includes/admin/about.php:189
-#, php-format
-msgid "We're on GitHub . Contributions welcome."
+#: ../includes/admin/about.php:40
+msgid "Changelog"
msgstr ""
-#: ../includes/admin/about.php:197
+#: ../includes/admin/about.php:42
+msgid "Upgrade to Pro "
+msgstr ""
+
+#: ../includes/admin/about.php:85
+msgid "Add Rating Items"
+msgstr ""
+
+#: ../includes/admin/about.php:86
#, php-format
msgid ""
-"All support for the free Multi Rating plugin should use the WordPress.org support forum ."
+"Setup your criteria and questions by adding "
+"new rating items ."
msgstr ""
-#: ../includes/admin/about.php:198
+#: ../includes/admin/about.php:90 ../includes/admin/class-post-metabox.php:92
+#: ../includes/class-settings.php:296
+msgid "Auto Placement Settings"
+msgstr ""
+
+#: ../includes/admin/about.php:91
#, php-format
msgid ""
-"Please use the contact form to send translation files or "
-"to contact me directly."
+"Configure automatic placement settings to "
+"display the rating form and or rating results on posts or pages (e.g. after "
+"the post content)."
msgstr ""
-#: ../includes/admin/about.php:199
-#, php-format
+#: ../includes/admin/about.php:95
+msgid "Gutenberg Blocks"
+msgstr ""
+
+#: ../includes/admin/about.php:98
msgid ""
-"Please rate this plugin on WordPress."
-"org."
+"There's 3 Gutenberg Blocks to easily add the rating form to a post, and "
+"display the average rating result and a list of the highest rated posts."
+msgstr ""
+
+#: ../includes/admin/about.php:110
+msgid "Shortcodes"
+msgstr ""
+
+#: ../includes/admin/about.php:111
+#, php-format
+msgid "[mr_rating_form] - displays the rating form."
+msgstr ""
+
+#: ../includes/admin/about.php:112
+#, php-format
+msgid "[mr_rating_result] - displays the rating result."
msgstr ""
-#: ../includes/admin/about.php:204
+#: ../includes/admin/about.php:113
#, php-format
msgid ""
-"The Multi Rating Pro version provides a significant "
-"additional feature set, including:"
+"[mr_rating_results_list] - displays a list of rating "
+"results."
msgstr ""
-#: ../includes/admin/about.php:206
-msgid "The following key features are available in the Pro version:"
+#: ../includes/admin/about.php:115
+msgid "Google Rich Snippets"
msgstr ""
-#: ../includes/admin/about.php:208
-msgid "Ratings moderation (approve or unapprove rating entries)"
+#: ../includes/admin/about.php:116
+msgid ""
+"Enables rich snippets to appear in search engine results pages (SERP) with "
+"schema.org JSON-LD structured data added added to posts and pages."
msgstr ""
-#: ../includes/admin/about.php:209
-msgid "WordPress comment system integration"
+#: ../includes/admin/about.php:118
+msgid "WordPress Star Ratings"
+msgstr ""
+
+#: ../includes/admin/about.php:119
+msgid ""
+"You can change the icon font libaries used for star ratings (e.g. Font "
+"Awesome and Dashicons). Or you can upload custom star rating images to use "
+"instead of icon fonts."
msgstr ""
-#: ../includes/admin/about.php:210
-msgid "Logged in users can update or delete their existing ratings"
+#: ../includes/admin/about.php:121
+msgid "Edit Rating Entries"
msgstr ""
-#: ../includes/admin/about.php:211
-msgid "Bayesian average ratings"
+#: ../includes/admin/about.php:122
+msgid "You can edit selected rating item values for rating entries."
+msgstr ""
+
+#: ../includes/admin/about.php:127
+msgid "Custom Post Types"
msgstr ""
-#: ../includes/admin/about.php:212
+#: ../includes/admin/about.php:128
msgid ""
-"Add common review fields to the rating form including title, name, e-mail "
-"and comments"
+"Remember to enable custom post types under the automatic placement settings."
msgstr ""
-#: ../includes/admin/about.php:213
-msgid "Add custom fields to the rating form to collect additional information"
+#: ../includes/admin/about.php:130
+msgid "i18n Translation Ready"
msgstr ""
-#: ../includes/admin/about.php:214
-msgid "Show a list of rating entry details in a review layout"
+#: ../includes/admin/about.php:131
+msgid "The plugin is translation ready (.pot file in the languages directory)."
msgstr ""
-#: ../includes/admin/about.php:215
-msgid "Show a breakdown of rating item results in a poll layout"
+#: ../includes/admin/about.php:133
+msgid "In-built Template System"
msgstr ""
-#: ../includes/admin/about.php:216
-msgid "Show text labels for rating item options instead of numbers"
+#: ../includes/admin/about.php:134
+msgid "Customize the HTML presentation using the in-built template system."
msgstr ""
-#: ../includes/admin/about.php:217
-msgid ""
-"Extra shortcodes and widgets (e.g. reviews, user ratings dashboard and "
-"rating item results)"
+#: ../includes/admin/about.php:136
+msgid "Rating Item Types"
msgstr ""
-#: ../includes/admin/about.php:218
+#: ../includes/admin/about.php:137
msgid ""
-"Filters to set different rating forms and override auto placement settings "
-"for specific taxonomies, terms, post types, post id's and page URL's"
+"You can choose from select dropdown lists, star ratings and radio buttons."
msgstr ""
-#: ../includes/admin/about.php:219
-msgid ""
-"Options to exclude the home page, search page and archive pages (e.g. "
-"category)"
+#: ../includes/admin/about.php:139
+msgid "Export Rating to CSV"
msgstr ""
-#: ../includes/admin/about.php:220
-msgid "Thumbs up/down rating item type (e.g. like or dislike)"
+#: ../includes/admin/about.php:140
+msgid "There's a tool which allows you to export ratings to a CSV file."
msgstr ""
-#: ../includes/admin/about.php:221
-msgid "Option to disallow anonymous ratings"
+#: ../includes/admin/about.php:145
+msgid "Rating Result Types"
msgstr ""
-#: ../includes/admin/about.php:222
-msgid "Embed reCAPTCHA in the rating form (add-on)"
+#: ../includes/admin/about.php:146
+msgid ""
+"You can specify star ratings, a score (e.g. out of 100) or percentage result "
+"types e.g. [mr_rating_result result_type=\"percentage\"]."
msgstr ""
-#: ../includes/admin/about.php:223
-msgid "Gravity Forms integration (add-on)"
+#: ../includes/admin/about.php:148
+msgid "Weighted Rating Items"
msgstr ""
-#: ../includes/admin/about.php:224
-msgid "And much more."
+#: ../includes/admin/about.php:149
+msgid ""
+"You can assign different weights to rating items which are factored into "
+"rating calculations."
msgstr ""
-#: ../includes/admin/class-post-metabox.php:85
-msgid "Rating form position"
+#: ../includes/admin/about.php:151
+msgid "Developer Friendly"
msgstr ""
-#: ../includes/admin/class-post-metabox.php:87
-#: ../includes/admin/class-post-metabox.php:97
-#: ../includes/class-settings.php:306 ../includes/class-settings.php:323
-msgid "Do not show"
+#: ../includes/admin/about.php:152
+msgid ""
+"Excellent code quality, readonly REST API endpoints, API functions and "
+"extensible WordPress action hooks & filters."
msgstr ""
-#: ../includes/admin/class-post-metabox.php:88
-#: ../includes/admin/class-post-metabox.php:98
-msgid "Use default settings"
+#: ../includes/admin/about.php:153
+msgid "Duplicate Checks"
msgstr ""
-#: ../includes/admin/class-post-metabox.php:89
-#: ../includes/admin/class-post-metabox.php:101
-#: ../includes/class-settings.php:307 ../includes/class-settings.php:326
-msgid "Before content"
+#: ../includes/admin/about.php:154
+msgid ""
+"Perform duplicate checks using cookies to ensure users cannot rate the same "
+"post multiple times."
msgstr ""
-#: ../includes/admin/class-post-metabox.php:90
-#: ../includes/admin/class-post-metabox.php:102
-#: ../includes/class-settings.php:308 ../includes/class-settings.php:327
-msgid "After content"
+#: ../includes/admin/about.php:172
+msgid "No valid changelog was found."
msgstr ""
-#: ../includes/admin/class-post-metabox.php:95
-msgid "Rating result position"
+#: ../includes/admin/about.php:207
+#, php-format
+msgid "View %s"
msgstr ""
-#: ../includes/admin/class-post-metabox.php:99
-#: ../includes/class-settings.php:324
-msgid "Before title"
+#: ../includes/admin/class-post-metabox.php:101
+msgid "Auto placement position for the rating form on the post"
msgstr ""
-#: ../includes/admin/class-post-metabox.php:100
-#: ../includes/class-settings.php:325
-msgid "After title"
+#: ../includes/admin/class-post-metabox.php:114
+msgid "Auto placement position for the rating result on the post"
msgstr ""
-#: ../includes/admin/class-rating-entry-table.php:31
-#: ../includes/widgets.php:311
-msgid "Rating Result"
+#: ../includes/admin/class-post-metabox.php:117
+msgid "Structured Data Type"
msgstr ""
-#: ../includes/admin/class-rating-entry-table.php:32
+#: ../includes/admin/class-post-metabox.php:118
+msgid "Create New Type"
+msgstr ""
+
+#: ../includes/admin/class-rating-entry-table.php:31
#: ../includes/admin/class-rating-results-table.php:30
#: ../includes/admin/class-rating-results-table.php:31
-#: ../includes/class-settings.php:69
+#: ../includes/class-settings.php:70
msgid "Rating Results"
msgstr ""
-#: ../includes/admin/class-rating-entry-table.php:75
+#: ../includes/admin/class-rating-entry-table.php:68
#: ../includes/admin/class-rating-results-table.php:59
-#: ../includes/admin/reports.php:52 ../includes/admin/tools.php:24
-#: ../includes/admin/tools.php:76 ../includes/admin/tools.php:119
+#: ../includes/admin/reports.php:42 ../includes/admin/tools.php:24
+#: ../includes/admin/tools.php:74 ../includes/admin/tools.php:115
msgid "All posts / pages"
msgstr ""
-#: ../includes/admin/class-rating-entry-table.php:101
+#: ../includes/admin/class-rating-entry-table.php:94
#: ../includes/admin/class-rating-results-table.php:94
-#: ../includes/admin/reports.php:73 ../includes/class-settings.php:71
+#: ../includes/admin/reports.php:62 ../includes/class-settings.php:72
msgid "Filter"
msgstr ""
-#: ../includes/admin/class-rating-entry-table.php:120
+#: ../includes/admin/class-rating-entry-table.php:113
#: ../includes/admin/class-rating-item-table.php:61
msgid "ID"
msgstr ""
-#: ../includes/admin/class-rating-entry-table.php:121
+#: ../includes/admin/class-rating-entry-table.php:114
#: ../includes/admin/class-rating-results-table.php:112
msgid "Post"
msgstr ""
-#: ../includes/admin/class-rating-entry-table.php:122
+#: ../includes/admin/class-rating-entry-table.php:115
msgid "Date"
msgstr ""
-#: ../includes/admin/class-rating-entry-table.php:123
-#: ../includes/class-settings.php:211
-msgid "IP Address"
-msgstr ""
-
-#: ../includes/admin/class-rating-entry-table.php:124
+#: ../includes/admin/class-rating-entry-table.php:116
msgid "User ID"
msgstr ""
-#: ../includes/admin/class-rating-entry-table.php:125
+#: ../includes/admin/class-rating-entry-table.php:117
msgid "Rating Details"
msgstr ""
-#: ../includes/admin/class-rating-entry-table.php:126
-#: ../includes/admin/class-rating-results-table.php:115
-msgid "Action"
-msgstr ""
-
-#: ../includes/admin/class-rating-entry-table.php:290
-#: ../includes/admin/class-rating-results-table.php:358
-msgid "Star: "
+#: ../includes/admin/class-rating-entry-table.php:250
+#: ../includes/admin/class-rating-item-table.php:203
+#: ../includes/admin/class-rating-results-table.php:318
+#, php-format
+msgid "ID: %d"
msgstr ""
-#: ../includes/admin/class-rating-entry-table.php:291
-#: ../includes/admin/class-rating-results-table.php:359
-msgid "Score: "
+#: ../includes/admin/class-rating-entry-table.php:254
+#: ../includes/admin/class-rating-item-table.php:143
+#: ../includes/admin/class-rating-item-table.php:205
+#: ../includes/admin/class-rating-item-table.php:233
+#: ../includes/admin/class-rating-results-table.php:322
+msgid "Edit"
msgstr ""
-#: ../includes/admin/class-rating-entry-table.php:292
-#: ../includes/admin/class-rating-results-table.php:360
-msgid "Percentage: "
+#: ../includes/admin/class-rating-entry-table.php:285
+#, php-format
+msgid "Overall Rating: %s"
msgstr ""
-#: ../includes/admin/class-rating-entry-table.php:315
-#: ../includes/admin/edit-rating.php:9 ../multi-rating.php:403
+#: ../includes/admin/class-rating-entry-table.php:309 ../multi-rating.php:406
msgid "Edit Rating"
msgstr ""
-#: ../includes/admin/class-rating-entry-table.php:346
-#: ../includes/admin/class-rating-item-table.php:235
-#: ../includes/admin/class-rating-results-table.php:397
+#: ../includes/admin/class-rating-entry-table.php:345
+#: ../includes/admin/class-rating-item-table.php:252
+#: ../includes/admin/class-rating-results-table.php:395
msgid "Delete"
msgstr ""
-#: ../includes/admin/class-rating-entry-table.php:383
+#: ../includes/admin/class-rating-entry-table.php:382
msgid "Entries deleted successfully"
msgstr ""
@@ -492,7 +532,7 @@ msgid "Rating Item"
msgstr ""
#: ../includes/admin/class-rating-item-table.php:32
-#: ../includes/admin/rating-items.php:59 ../multi-rating.php:398
+#: ../includes/admin/rating-items.php:59 ../multi-rating.php:401
msgid "Rating Items"
msgstr ""
@@ -526,13 +566,13 @@ msgid "Weight"
msgstr ""
#: ../includes/admin/class-rating-item-table.php:139
-#: ../includes/admin/class-rating-item-table.php:351
+#: ../includes/admin/class-rating-item-table.php:369
#: ../includes/admin/rating-items.php:25
msgid "Select"
msgstr ""
#: ../includes/admin/class-rating-item-table.php:139
-#: ../includes/admin/class-rating-item-table.php:351
+#: ../includes/admin/class-rating-item-table.php:369
#: ../includes/admin/rating-items.php:26
msgid "Radio"
msgstr ""
@@ -542,69 +582,63 @@ msgstr ""
msgid "Stars"
msgstr ""
-#: ../includes/admin/class-rating-item-table.php:143
-#: ../includes/admin/class-rating-item-table.php:192
-#: ../includes/admin/class-rating-item-table.php:216
-msgid "Edit"
-msgstr ""
-
#: ../includes/admin/class-rating-item-table.php:157
-#: ../includes/admin/class-rating-item-table.php:195
-#: ../includes/admin/class-rating-item-table.php:225
+#: ../includes/admin/class-rating-item-table.php:211
+#: ../includes/admin/class-rating-item-table.php:242
msgid "Save"
msgstr ""
-#: ../includes/admin/class-rating-item-table.php:216
-#: ../includes/admin/class-rating-item-table.php:354
+#: ../includes/admin/class-rating-item-table.php:233
+#: ../includes/admin/class-rating-item-table.php:372
msgid "Yes"
msgstr ""
-#: ../includes/admin/class-rating-item-table.php:216
-#: ../includes/admin/class-rating-item-table.php:354
+#: ../includes/admin/class-rating-item-table.php:233
+#: ../includes/admin/class-rating-item-table.php:372
msgid "No"
msgstr ""
-#: ../includes/admin/class-rating-item-table.php:257
+#: ../includes/admin/class-rating-item-table.php:274
msgid "Delete rating items bulk action processed successfully"
msgstr ""
-#: ../includes/admin/class-rating-item-table.php:280
-#: ../includes/admin/edit-rating.php:130
+#: ../includes/admin/class-rating-item-table.php:297
+#: ../includes/admin/edit-rating.php:138
msgid "An error occured"
msgstr ""
-#: ../includes/admin/class-rating-item-table.php:309
+#: ../includes/admin/class-rating-item-table.php:326
#: ../includes/admin/rating-items.php:86
msgid "Description cannot be empty. "
msgstr ""
-#: ../includes/admin/class-rating-item-table.php:314
+#: ../includes/admin/class-rating-item-table.php:332
#: ../includes/admin/rating-items.php:95
msgid "Max option value cannot be empty and must be a whole number. "
msgstr ""
-#: ../includes/admin/class-rating-item-table.php:318
-#: ../includes/admin/class-rating-item-table.php:326
+#: ../includes/admin/class-rating-item-table.php:336
+#: ../includes/admin/class-rating-item-table.php:344
msgid "Default option value cannot be greater than the max option value. "
msgstr ""
-#: ../includes/admin/class-rating-item-table.php:322
+#: ../includes/admin/class-rating-item-table.php:340
#: ../includes/admin/rating-items.php:99
msgid "Default option value cannot be empty and must be a whole number. "
msgstr ""
-#: ../includes/admin/class-rating-item-table.php:330
+#: ../includes/admin/class-rating-item-table.php:348
msgid "Weight must be numeric."
msgstr ""
-#: ../includes/admin/class-rating-item-table.php:341
-#: ../includes/admin/update-check.php:125
-#: ../includes/admin/update-check.php:159
-#: ../includes/admin/update-check.php:221
+#: ../includes/admin/class-rating-item-table.php:359
+#: ../includes/admin/update-check.php:189
+#: ../includes/admin/update-check.php:223
+#: ../includes/admin/update-check.php:285
msgid "An error occured."
msgstr ""
-#: ../includes/admin/class-rating-item-table.php:351
+#: ../includes/admin/class-rating-item-table.php:369
#: ../includes/widgets.php:165
msgid "Star Rating"
msgstr ""
@@ -637,40 +671,42 @@ msgid "Overall Rating"
msgstr ""
#: ../includes/admin/class-rating-results-table.php:114
-#: ../includes/admin/rating-entries.php:11 ../includes/admin/reports.php:14
-#: ../multi-rating.php:397
-msgid "Entries"
+msgid "Shortcode"
msgstr ""
-#: ../includes/admin/class-rating-results-table.php:116
-msgid "Shortcode"
+#: ../includes/admin/class-rating-results-table.php:353
+msgid "None"
msgstr ""
-#: ../includes/admin/class-rating-results-table.php:330
+#: ../includes/admin/class-rating-results-table.php:358
msgid "View Entries"
msgstr ""
-#: ../includes/admin/class-rating-results-table.php:362
-msgid "None"
+#: ../includes/admin/class-rating-results-table.php:440
+msgid "Rating results deleted successfully."
msgstr ""
-#: ../includes/admin/class-rating-results-table.php:442
-msgid "Rating results deleted successfully."
+#: ../includes/admin/edit-rating.php:12 ../includes/class-rating-form.php:58
+msgid "An error has occured."
msgstr ""
-#: ../includes/admin/edit-rating.php:21
-msgid "Invalid rating entry id"
+#: ../includes/admin/edit-rating.php:25 ../includes/admin/edit-rating.php:48
+msgid "An error has occured"
msgstr ""
-#: ../includes/admin/edit-rating.php:40
+#: ../includes/admin/edit-rating.php:31
#, php-format
-msgid "No rating exists for rating entry id %d"
+msgid "Edit Rating Entry #%d"
msgstr ""
-#: ../includes/admin/edit-rating.php:97
+#: ../includes/admin/edit-rating.php:105
msgid "Update"
msgstr ""
+#: ../includes/admin/rating-entries.php:11
+msgid "Rating Entries"
+msgstr ""
+
#: ../includes/admin/rating-items.php:10
msgid "Add New Rating Item"
msgstr ""
@@ -679,7 +715,7 @@ msgstr ""
msgid "Enter a description..."
msgstr ""
-#: ../includes/admin/rating-items.php:18 ../multi-rating.php:337
+#: ../includes/admin/rating-items.php:18 ../multi-rating.php:340
msgid "Sample rating item"
msgstr ""
@@ -719,11 +755,7 @@ msgstr ""
msgid "Results"
msgstr ""
-#: ../includes/admin/reports.php:27
-msgid "Number of entries per day"
-msgstr ""
-
-#: ../includes/admin/settings.php:10 ../multi-rating.php:399
+#: ../includes/admin/settings.php:10 ../multi-rating.php:402
msgid "Settings"
msgstr ""
@@ -731,129 +763,166 @@ msgstr ""
msgid "Settings saved."
msgstr ""
-#: ../includes/admin/tools.php:9 ../multi-rating.php:401
+#: ../includes/admin/settings.php:80
+msgid "Unlimited rating forms"
+msgstr ""
+
+#: ../includes/admin/settings.php:81
+msgid "Common review fields (title, name, e-mail and comments)"
+msgstr ""
+
+#: ../includes/admin/settings.php:82
+msgid "Custom input or textarea fields"
+msgstr ""
+
+#: ../includes/admin/settings.php:83
+msgid "WordPress comment ratings integration"
+msgstr ""
+
+#: ../includes/admin/settings.php:84
+msgid "Moderate rating entries"
+msgstr ""
+
+#: ../includes/admin/settings.php:85
+msgid "E-mail notifications"
+msgstr ""
+
+#: ../includes/admin/settings.php:86
+msgid "Display rating item results in a poll layout"
+msgstr ""
+
+#: ../includes/admin/settings.php:87
+msgid "Display rating entries in a review layout"
+msgstr ""
+
+#: ../includes/admin/settings.php:88
+msgid "And much much more!"
+msgstr ""
+
+#: ../includes/admin/tools.php:9 ../multi-rating.php:404
msgid "Tools"
msgstr ""
+#: ../includes/admin/tools.php:13
+msgid "Export Rating Entries"
+msgstr ""
+
#: ../includes/admin/tools.php:15
-msgid "Export Rating Results to a CSV file."
+msgid "Download a CSV of rating entries."
msgstr ""
-#: ../includes/admin/tools.php:50
-msgid "Export"
+#: ../includes/admin/tools.php:48
+msgid "Generate CSV"
msgstr ""
-#: ../includes/admin/tools.php:65 ../includes/admin/tools.php:102
-msgid "Clear Database"
+#: ../includes/admin/tools.php:63 ../includes/admin/tools.php:98
+msgid "Delete Rating Entries"
msgstr ""
-#: ../includes/admin/tools.php:67
-msgid "Delete rating results from the database."
+#: ../includes/admin/tools.php:65
+msgid "Permanently delete rating entries from the database."
msgstr ""
-#: ../includes/admin/tools.php:112 ../includes/admin/tools.php:145
-msgid "Clear Cache"
+#: ../includes/admin/tools.php:108 ../includes/admin/tools.php:139
+msgid "Delete Calculated Ratings"
msgstr ""
-#: ../includes/admin/tools.php:114
+#: ../includes/admin/tools.php:110
msgid ""
-"Clear the cached rating results stored in the WordPress post meta table."
+"Ratings are calculated on page load if necessary and then stored in the "
+"database for performance."
msgstr ""
-#: ../includes/admin/tools.php:221
+#: ../includes/admin/tools.php:215
msgid "Entry Id"
msgstr ""
-#: ../includes/admin/tools.php:222
+#: ../includes/admin/tools.php:216
msgid "Entry Date"
msgstr ""
-#: ../includes/admin/tools.php:223
+#: ../includes/admin/tools.php:217
msgid "Post Id"
msgstr ""
-#: ../includes/admin/tools.php:224
+#: ../includes/admin/tools.php:218
msgid "Post Title"
msgstr ""
-#: ../includes/admin/tools.php:225
+#: ../includes/admin/tools.php:219
msgid "Score Rating Result"
msgstr ""
-#: ../includes/admin/tools.php:226
+#: ../includes/admin/tools.php:220
msgid "Adjusted Score Rating Result"
msgstr ""
-#: ../includes/admin/tools.php:227
+#: ../includes/admin/tools.php:221
msgid "Total Max Option Value"
msgstr ""
-#: ../includes/admin/tools.php:228
+#: ../includes/admin/tools.php:222
msgid "Percentage Rating Result"
msgstr ""
-#: ../includes/admin/tools.php:229
+#: ../includes/admin/tools.php:223
msgid "Adjusted Percentage Rating Result"
msgstr ""
-#: ../includes/admin/tools.php:230
+#: ../includes/admin/tools.php:224
msgid "Star Rating Result"
msgstr ""
-#: ../includes/admin/tools.php:231
+#: ../includes/admin/tools.php:225
msgid "Adjusted Star Rating Result"
msgstr ""
-#: ../includes/admin/tools.php:232
+#: ../includes/admin/tools.php:226
msgid "User Id"
msgstr ""
-#: ../includes/admin/tools.php:330
+#: ../includes/admin/tools.php:324
msgid "Database cleared successfully."
msgstr ""
-#: ../includes/admin/tools.php:332
+#: ../includes/admin/tools.php:326
#, php-format
msgid "An error has occured. %s"
msgstr ""
-#: ../includes/admin/tools.php:335
+#: ../includes/admin/tools.php:329
msgid "No entries found"
msgstr ""
-#: ../includes/admin/tools.php:374
+#: ../includes/admin/tools.php:368
msgid "Cache cleared successfully."
msgstr ""
-#: ../includes/class-rating-form.php:59
-msgid "An error has occured."
-msgstr ""
-
-#: ../includes/class-settings.php:68
+#: ../includes/class-settings.php:69
msgid "Please rate this"
msgstr ""
-#: ../includes/class-settings.php:70
+#: ../includes/class-settings.php:71
msgid "Submit Rating"
msgstr ""
-#: ../includes/class-settings.php:72
+#: ../includes/class-settings.php:73
msgid "Category"
msgstr ""
-#: ../includes/class-settings.php:73
+#: ../includes/class-settings.php:74
msgid "Your rating was %adjusted_star_result%/5."
msgstr ""
-#: ../includes/class-settings.php:74
+#: ../includes/class-settings.php:75
msgid "You cannot submit a rating for the same post multiple times."
msgstr ""
-#: ../includes/class-settings.php:75
+#: ../includes/class-settings.php:76
msgid "No ratings yet."
msgstr ""
-#: ../includes/class-settings.php:76
+#: ../includes/class-settings.php:77
msgid "Field is required."
msgstr ""
@@ -861,293 +930,279 @@ msgstr ""
msgid "General Settings"
msgstr ""
-#: ../includes/class-settings.php:138
-msgid "Post Types"
-msgstr ""
-
-#: ../includes/class-settings.php:145
-msgid ""
-"Enable post types for auto placement of the rating form and rating results."
-msgstr ""
-
-#: ../includes/class-settings.php:150
+#: ../includes/class-settings.php:125
msgid "Duplicate Check Method"
msgstr ""
-#: ../includes/class-settings.php:156
-msgid "Store Ratings Cache"
+#: ../includes/class-settings.php:141
+msgid "Store Calculated Ratings"
msgstr ""
-#: ../includes/class-settings.php:163
+#: ../includes/class-settings.php:148
msgid ""
-"Check this box if you want to store ratings in a database cache so that it "
-"does not need to be recalculated on each page load."
+"Check this box if you want to store calculated ratings in the database "
+"instead of recalculating results on each page load."
msgstr ""
-#: ../includes/class-settings.php:167
-msgid "Hide Rating Form Submit"
+#: ../includes/class-settings.php:152
+msgid "Hide Rating Form on Submit"
msgstr ""
-#: ../includes/class-settings.php:174
+#: ../includes/class-settings.php:159
msgid "Check this box if you want to hide the rating form on submit."
msgstr ""
-#: ../includes/class-settings.php:178
-msgid "Template Strip Newlines?"
+#: ../includes/class-settings.php:163
+msgid "Template Strip Newlines"
msgstr ""
-#: ../includes/class-settings.php:185
+#: ../includes/class-settings.php:170
#, php-format
msgid ""
"Some plugins convert newlines to HTML paragraphs similar to wpautop (e.g. Visual Composer). Check this box if you want to prevent "
-"this from happening by stripping the newlines from the Multi Rating "
-"templates."
+"this from happening by stripping the newlines from the templates."
+msgstr ""
+
+#: ../includes/class-settings.php:196
+msgid "Choose a method to prevent people rating the same post multiple times."
msgstr ""
-#: ../includes/class-settings.php:212
+#: ../includes/class-settings.php:200
msgid "Cookie"
msgstr ""
-#: ../includes/class-settings.php:229
+#: ../includes/class-settings.php:216
msgid "Hours"
msgstr ""
-#: ../includes/class-settings.php:230
+#: ../includes/class-settings.php:227
msgid ""
-"Choose a method to prevent ratings for the same post multiple times. This "
-"only applies for anonymous users."
+"Adds support for rich snippets with aggregate ratings for posts in search "
+"engine results pages (SERP)."
msgstr ""
-#: ../includes/class-settings.php:249
-msgid "Save rating restriction hours must be numeric."
+#: ../includes/class-settings.php:229
+msgid "Create new type"
msgstr ""
-#: ../includes/class-settings.php:251
-msgid "Save rating restriction hours must be greater than 0."
+#: ../includes/class-settings.php:229
+msgid "Adds a new piece for the type configured on each post."
msgstr ""
-#: ../includes/class-settings.php:297
-msgid "Rating Form Position"
+#: ../includes/class-settings.php:231
+msgid "WordPress SEO plugin integration"
msgstr ""
-#: ../includes/class-settings.php:304
-msgid ""
-"Default rating form position on a post. You can integrate ratings in the "
-"WordPress comment form."
+#: ../includes/class-settings.php:231
+msgid "Adds to main entity where possible."
msgstr ""
-#: ../includes/class-settings.php:309
-msgid "Comment form"
+#: ../includes/class-settings.php:233
+msgid "WooCommerce plugin integration"
msgstr ""
-#: ../includes/class-settings.php:314
-msgid "Rating Result Position"
+#: ../includes/class-settings.php:233
+msgid "Adds to existing Product type."
msgstr ""
-#: ../includes/class-settings.php:321
-msgid "Default rating results position on a post."
+#: ../includes/class-settings.php:252
+msgid "Save rating restriction hours must be numeric."
msgstr ""
-#: ../includes/class-settings.php:364
-msgid "Style Settings"
+#: ../includes/class-settings.php:254
+msgid "Save rating restriction hours must be greater than 0."
+msgstr ""
+
+#: ../includes/class-settings.php:314
+msgid "Post Types"
msgstr ""
-#: ../includes/class-settings.php:367
-msgid "Font Awesome 4.7.0"
+#: ../includes/class-settings.php:321
+msgid "Enabled post types for auto placement."
msgstr ""
-#: ../includes/class-settings.php:368
-msgid "Font Awesome 4.6.3"
+#: ../includes/class-settings.php:333
+msgid "Default rating form position on a post."
msgstr ""
-#: ../includes/class-settings.php:369
-msgid "Font Awesome 4.5.0"
+#: ../includes/class-settings.php:349
+msgid "Default rating results position on a post."
msgstr ""
-#: ../includes/class-settings.php:370
-msgid "Font Awesome 4.3.0"
+#: ../includes/class-settings.php:372
+msgid "Note you can override the default auto placement settings on each post."
msgstr ""
-#: ../includes/class-settings.php:371
-msgid "Font Awesome 4.2.0"
+#: ../includes/class-settings.php:398
+msgid "Style Settings"
msgstr ""
-#: ../includes/class-settings.php:372
-msgid "Font Awesome 4.1.0"
+#: ../includes/class-settings.php:401
+msgid "Font Awesome v5"
msgstr ""
-#: ../includes/class-settings.php:373
-msgid "Font Awesome 4.0.3"
+#: ../includes/class-settings.php:402
+msgid "Font Awesome v4"
msgstr ""
-#: ../includes/class-settings.php:374
-msgid "Font Awesome 3.2.1"
+#: ../includes/class-settings.php:403
+msgid "Font Awesome v3"
msgstr ""
-#: ../includes/class-settings.php:375
-msgid "Dashicons"
+#: ../includes/class-settings.php:404
+msgid "WordPress Dashicons"
msgstr ""
-#: ../includes/class-settings.php:381
+#: ../includes/class-settings.php:410
msgid "Primary Color"
msgstr ""
-#: ../includes/class-settings.php:388
+#: ../includes/class-settings.php:417
msgid "Choose a color for selection."
msgstr ""
-#: ../includes/class-settings.php:392
+#: ../includes/class-settings.php:421
msgid "Secondary Color"
msgstr ""
-#: ../includes/class-settings.php:399
+#: ../includes/class-settings.php:428
msgid "Choose a color for on hover."
msgstr ""
-#: ../includes/class-settings.php:403
+#: ../includes/class-settings.php:432
msgid "Error Color"
msgstr ""
-#: ../includes/class-settings.php:410
+#: ../includes/class-settings.php:439
msgid "Choose a color to highlight errors."
msgstr ""
-#: ../includes/class-settings.php:414
-msgid "Icon Font Library"
+#: ../includes/class-settings.php:443
+msgid "Icons"
msgstr ""
-#: ../includes/class-settings.php:426
-msgid "Load Icon Font Library from CDN"
-msgstr ""
-
-#: ../includes/class-settings.php:433
-msgid "Check this box if you want to load the font icon library from a CDN."
-msgstr ""
-
-#: ../includes/class-settings.php:437
-msgid "Custom CSS"
+#: ../includes/class-settings.php:455
+msgid "Load Icons"
msgstr ""
-#: ../includes/class-settings.php:444
-msgid "Enter custom CSS styles above."
+#: ../includes/class-settings.php:462
+msgid ""
+"If your theme or another plugin is already loading these icons, you should "
+"uncheck this to avoid any conflicts. "
msgstr ""
-#: ../includes/class-settings.php:448
+#: ../includes/class-settings.php:466
msgid "Disable Styles"
msgstr ""
-#: ../includes/class-settings.php:455
+#: ../includes/class-settings.php:473
msgid "Check this box to disable loading the plugin's CSS file."
msgstr ""
-#: ../includes/class-settings.php:507
+#: ../includes/class-settings.php:523
msgid "Custom Images"
msgstr ""
-#: ../includes/class-settings.php:511
+#: ../includes/class-settings.php:527
msgid "Enable Custom Images"
msgstr ""
-#: ../includes/class-settings.php:518
+#: ../includes/class-settings.php:534
msgid "Check this box if you want to enable custom images."
msgstr ""
-#: ../includes/class-settings.php:522
+#: ../includes/class-settings.php:538
msgid "Full Star Image"
msgstr ""
-#: ../includes/class-settings.php:535
+#: ../includes/class-settings.php:551
msgid "Half Star Image"
msgstr ""
-#: ../includes/class-settings.php:548
+#: ../includes/class-settings.php:564
msgid "Empty Star Image"
msgstr ""
-#: ../includes/class-settings.php:561
+#: ../includes/class-settings.php:577
msgid "Hover Star Image"
msgstr ""
-#: ../includes/class-settings.php:574
+#: ../includes/class-settings.php:590
msgid "Star Image Width"
msgstr ""
-#: ../includes/class-settings.php:581 ../includes/class-settings.php:594
+#: ../includes/class-settings.php:597 ../includes/class-settings.php:610
msgid "pixels"
msgstr ""
-#: ../includes/class-settings.php:587
+#: ../includes/class-settings.php:603
msgid "Star Image Height"
msgstr ""
-#: ../includes/class-settings.php:633
+#: ../includes/class-settings.php:649
msgid "Full star, half star and empty star custom images are required."
msgstr ""
-#: ../includes/class-settings.php:650
+#: ../includes/class-settings.php:666
msgid ""
"Invalid image format. Valid mime types: image/jpeg, image/png, image/bmp, "
"image/tiff and image/x-icon"
msgstr ""
-#: ../includes/class-settings.php:659
+#: ../includes/class-settings.php:675
msgid "Custom image height must be numeric."
msgstr ""
-#: ../includes/class-settings.php:661
+#: ../includes/class-settings.php:677
msgid "Custom image height cannot be less than 1 or greater than 128."
msgstr ""
-#: ../includes/class-settings.php:665
+#: ../includes/class-settings.php:681
msgid "Custom image width must be numeric."
msgstr ""
-#: ../includes/class-settings.php:667
+#: ../includes/class-settings.php:683
msgid "Custom image width cannot be less than 1 or greater than 128."
msgstr ""
-#: ../includes/class-settings.php:680
+#: ../includes/class-settings.php:696
msgid "Custom Text Settings"
msgstr ""
-#: ../includes/class-settings.php:684
+#: ../includes/class-settings.php:700
msgid "Rating Form Title"
msgstr ""
-#: ../includes/class-settings.php:695
+#: ../includes/class-settings.php:711
msgid "Ratings List Title"
msgstr ""
-#: ../includes/class-settings.php:706
-msgid "Submit Button Text"
-msgstr ""
-
-#: ../includes/class-settings.php:717
+#: ../includes/class-settings.php:733
msgid "Filter Button Text"
msgstr ""
-#: ../includes/class-settings.php:728
+#: ../includes/class-settings.php:744
msgid "Filter Label Text"
msgstr ""
-#: ../includes/class-settings.php:739
+#: ../includes/class-settings.php:755
msgid "Field Required Error Message"
msgstr ""
-#: ../includes/class-settings.php:751
+#: ../includes/class-settings.php:767
msgid "Duplicate Check Error Message"
msgstr ""
-#: ../includes/class-settings.php:763
+#: ../includes/class-settings.php:779
msgid "No Ratings Information Message"
msgstr ""
-#: ../includes/class-settings.php:775
+#: ../includes/class-settings.php:791
msgid "Submit Rating Success Message"
msgstr ""
-#: ../includes/class-settings.php:857
+#: ../includes/class-settings.php:873
msgid "Upload"
msgstr ""
@@ -1158,22 +1213,10 @@ msgid ""
"org | Check out Multi Rating Pro !"
msgstr ""
-#: ../includes/widgets.php:14
-msgid "Rating Results List"
-msgstr ""
-
#: ../includes/widgets.php:17
msgid "Displays a list of rating results."
msgstr ""
-#: ../includes/widgets.php:153 ../includes/widgets.php:469
-msgid "Title"
-msgstr ""
-
-#: ../includes/widgets.php:157
-msgid "Limit"
-msgstr ""
-
#: ../includes/widgets.php:161
msgid "Result Type"
msgstr ""
@@ -1194,27 +1237,15 @@ msgstr ""
msgid "Terms"
msgstr ""
-#: ../includes/widgets.php:212 ../includes/widgets.php:529
+#: ../includes/widgets.php:212 ../includes/widgets.php:509
#: ../templates/rating-result-list.php:31
msgid "All"
msgstr ""
-#: ../includes/widgets.php:227
-msgid "Show Filter"
-msgstr ""
-
#: ../includes/widgets.php:230
msgid "Filter Label"
msgstr ""
-#: ../includes/widgets.php:235
-msgid "Show Featured Image"
-msgstr ""
-
-#: ../includes/widgets.php:239
-msgid "Show Rank"
-msgstr ""
-
#: ../includes/widgets.php:242
msgid "Image Size"
msgstr ""
@@ -1246,22 +1277,22 @@ msgid ""
"is_single() ."
msgstr ""
-#: ../includes/widgets.php:386
-msgid "Rating Form"
-msgstr ""
-
#: ../includes/widgets.php:389
msgid "Displays the rating form."
msgstr ""
-#: ../multi-rating.php:396
+#: ../multi-rating.php:399
msgid "Ratings"
msgstr ""
-#: ../multi-rating.php:402
+#: ../multi-rating.php:400
+msgid "Entries"
+msgstr ""
+
+#: ../multi-rating.php:405
msgid "About"
msgstr ""
-#: ../multi-rating.php:420
+#: ../multi-rating.php:427
msgid "Are you sure you want to permanently delete ratings?"
msgstr ""
diff --git a/multi-rating.php b/multi-rating.php
index bdc0331..bbb0020 100644
--- a/multi-rating.php
+++ b/multi-rating.php
@@ -1,9 +1,9 @@
-includes();
self::$instance->settings = new MR_Settings();
-
- $disable_styles = self::instance()->settings->style_settings[Multi_Rating::DISABLE_STYLES_OPTION];
- if ( ! $disable_styles ) {
- add_action( 'wp_head', array( self::$instance, 'mr_head') );
- }
-
+
+ new MR_Structured_Data();
+ new MR_Gutenberg();
+
add_action( 'init', array( self::$instance, 'load_textdomain' ) );
-
+
if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
-
- self::$instance->post_metabox = new MR_Post_Metabox();
-
+ // classic editor
+ new MR_Post_Metabox();
+
add_action( 'delete_user', array( self::$instance, 'delete_user' ), 11, 2 );
add_action( 'deleted_post', array( self::$instance, 'deleted_post' ) );
}
-
+
+ add_action( 'rest_api_init', array( self::$instance, 'rest_api_init' ) );
+
self::$instance->add_ajax_callbacks();
}
-
+
return Multi_Rating::$instance;
}
-
+
/**
* Delete all associated ratings by user id
*
@@ -175,48 +171,48 @@ public static function instance() {
* @param $reassign user id
*/
public function delete_user( $user_id, $reassign ) {
-
+
global $wpdb;
-
- if ( $reassign == null ) {
- // do nothing now has an invalid user id associated to it - oh well... decided not to delete the
+
+ if ( $reassign == null ) {
+ // do nothing now has an invalid user id associated to it - oh well... decided not to delete the
// rating as the user id is not displayed or used
} else { // reassign ratings to a user
- $wpdb->update( $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME,
+ $wpdb->update( $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME,
array( 'user_id' => $reassign ),
- array( 'user_id' => $user_id ),
- array( '%d' ),
+ array( 'user_id' => $user_id ),
+ array( '%d' ),
array( '%d' ) );
}
}
-
+
/**
* Delete all associated ratings by post id
*
* @param $post_id
*/
public function deleted_post( $post_id ) {
-
+
global $wpdb;
$query = 'SELECT rating_item_entry_id AS rating_entry_id FROM ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME
. ' WHERE post_id = %d';
$entries = $wpdb->get_results( $wpdb->prepare( $query, $post_id ) );
-
+
$this->delete_entries( $entries );
}
-
+
/**
* Deletes entries from database including rating item values
- *
+ *
* @param $entries
*/
public function delete_entries( $entries ) {
-
+
global $wpdb;
-
+
foreach ( $entries as $entry_row ) {
$rating_entry_id = $entry_row->rating_entry_id;
-
+
$wpdb->delete( $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME, array( 'rating_item_entry_id' => $rating_entry_id ), array( '%d' ) );
$wpdb->delete( $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_VALUE_TBL_NAME, array( 'rating_item_entry_id' => $rating_entry_id ), array( '%d' ) );
}
@@ -226,7 +222,7 @@ public function delete_entries( $entries ) {
* Includes files
*/
function includes() {
-
+
require dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'shortcodes.php';
require dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'widgets.php';
require dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'class-utils.php';
@@ -238,9 +234,16 @@ function includes() {
require dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'actions.php';
require dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'legacy.php';
require dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'template-functions.php';
-
+ require dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'class-structured-data.php';
+ require dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'class-gutenberg.php';
+
+ require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'class-rest-api-common.php';
+ require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'class-rest-api-rating-items.php';
+ require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'class-rest-api-rating-results.php';
+ require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'rest-api-custom-fields.php';
+
if ( is_admin() ) {
-
+
require dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'class-rating-item-table.php';
require dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'class-rating-entry-table.php';
require dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'class-rating-results-table.php';
@@ -253,20 +256,21 @@ function includes() {
require dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'settings.php';
require dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'tools.php';
require dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'edit-rating.php';
+
}
}
-
+
/**
* Activates the plugin
*/
public static function activate_plugin() {
-
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
-
+
try {
-
+
global $wpdb, $charset_collate;
-
+
// subjects can be a post type
$sql_create_rating_subject_tbl = 'CREATE TABLE ' . $wpdb->prefix . Multi_Rating::RATING_SUBJECT_TBL_NAME . ' (
rating_id bigint(20) NOT NULL AUTO_INCREMENT,
@@ -274,7 +278,7 @@ public static function activate_plugin() {
PRIMARY KEY (rating_id)
) ' . $charset_collate;
dbDelta( $sql_create_rating_subject_tbl );
-
+
// subjects are rated by multiple rating items
$sql_create_rating_item_tbl = 'CREATE TABLE '. $wpdb->prefix . Multi_Rating::RATING_ITEM_TBL_NAME . ' (
rating_item_id bigint(20) NOT NULL AUTO_INCREMENT,
@@ -289,19 +293,18 @@ public static function activate_plugin() {
PRIMARY KEY (rating_item_id)
) ' . $charset_collate;
dbDelta( $sql_create_rating_item_tbl );
-
+
// rating item entries and results are saved
$sql_create_rating_item_entry_tbl = 'CREATE TABLE ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME . ' (
rating_item_entry_id bigint(20) NOT NULL AUTO_INCREMENT,
post_id bigint(20) NOT NULL,
entry_date datetime NOT NULL,
- ip_address varchar(100),
user_id bigint(20) DEFAULT 0,
PRIMARY KEY (rating_item_entry_id),
KEY ix_rating_entry (rating_item_entry_id,post_id)
) ' . $charset_collate;
dbDelta( $sql_create_rating_item_entry_tbl );
-
+
$sql_create_rating_item_entry_value_tbl = 'CREATE TABLE ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_VALUE_TBL_NAME . ' (
rating_item_entry_value_id bigint(20) NOT NULL AUTO_INCREMENT,
rating_item_entry_id bigint(20) NOT NULL,
@@ -311,27 +314,27 @@ public static function activate_plugin() {
KEY ix_rating_entry (rating_item_entry_id)
) ' . $charset_collate;
dbDelta( $sql_create_rating_item_entry_value_tbl );
-
+
} catch ( Exception $e ) {
// do nothing
}
-
+
// Adds mr_edit_ratings capability which allows the editor and administrator roles to be able to edit / moderate ratings
$editor_role = get_role( 'editor' );
$admin_role = get_role( 'administrator' );
-
+
if ( $editor_role ) {
$editor_role->add_cap( 'mr_edit_ratings' );
}
if ( $admin_role ) {
$admin_role->add_cap( 'mr_edit_ratings' );
}
-
+
// if no rating items exist, add a sample one :)
try {
-
+
$count = $wpdb->get_var( 'SELECT COUNT(rating_item_id) FROM ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_TBL_NAME );
-
+
if ( is_numeric( $count ) && $count == 0 ) {
$wpdb->insert( $wpdb->prefix . Multi_Rating::RATING_ITEM_TBL_NAME, array(
'description' => __( 'Sample rating item', 'multi-rating' ),
@@ -343,61 +346,61 @@ public static function activate_plugin() {
),
array( '%s', '%d', '%d', '%f', '%s', '%d' ) );
}
-
+
} catch ( Exception $e ) {
// do nothing
}
-
+
}
-
+
/**
* Uninstalls the plugin
*/
public static function uninstall_plugin() {
-
+
delete_option( Multi_Rating::GENERAL_SETTINGS );
delete_option( Multi_Rating::CUSTOM_TEXT_SETTINGS );
delete_option( Multi_Rating::POSITION_SETTINGS );
delete_option( Multi_Rating::STYLE_SETTINGS );
-
+
// Drop tables
global $wpdb;
-
+
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME );
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_VALUE_TBL_NAME );
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_TBL_NAME );
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . Multi_Rating::RATING_SUBJECT_TBL_NAME );
}
-
+
/**
* Redirects to about page on activation
*/
function redirect_about_page() {
- if ( get_option( MULTI_RATING::DO_ACTIVATION_REDIRECT_OPTION, false ) ) {
+ if ( ! is_network_admin() && get_option( MULTI_RATING::DO_ACTIVATION_REDIRECT_OPTION, false ) ) {
delete_option( MULTI_RATING::DO_ACTIVATION_REDIRECT_OPTION );
wp_redirect( 'admin.php?page=' . MULTI_RATING::ABOUT_PAGE_SLUG );
}
}
-
+
/**
* Loads plugin text domain
*/
public function load_textdomain() {
load_plugin_textdomain( 'multi-rating', false, dirname( plugin_basename( __FILE__) ) . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR );
}
-
+
/**
* Adds admin menus
*/
public function add_admin_menus() {
-
+
add_menu_page( __( 'Multi Rating', 'multi-rating' ), __( 'Multi Rating', 'multi-rating' ), 'mr_edit_ratings', Multi_Rating::RATING_RESULTS_PAGE_SLUG, 'mr_rating_results_screen', 'dashicons-star-filled', null );
add_submenu_page( Multi_Rating::RATING_RESULTS_PAGE_SLUG, '', '', 'mr_edit_ratings', Multi_Rating::RATING_RESULTS_PAGE_SLUG, 'mr_rating_results_screen' );
add_submenu_page( Multi_Rating::RATING_RESULTS_PAGE_SLUG, __( 'Ratings', 'multi-rating' ), __( 'Ratings', 'multi-rating' ), 'mr_edit_ratings', Multi_Rating::RATING_RESULTS_PAGE_SLUG, 'mr_rating_results_screen' );
add_submenu_page( Multi_Rating::RATING_RESULTS_PAGE_SLUG, __( 'Entries', 'multi-rating' ), __( 'Entries', 'multi-rating' ), 'mr_edit_ratings', Multi_Rating::RATING_ENTRIES_PAGE_SLUG, 'mr_rating_entries_screen' );
add_submenu_page( Multi_Rating::RATING_RESULTS_PAGE_SLUG, __( 'Rating Items', 'multi-rating' ), __( 'Rating Items', 'multi-rating' ), 'manage_options', Multi_Rating::RATING_ITEMS_PAGE_SLUG, 'mr_rating_items_screen' );
add_submenu_page( Multi_Rating::RATING_RESULTS_PAGE_SLUG, __( 'Settings', 'multi-rating' ), __( 'Settings', 'multi-rating' ), 'manage_options', Multi_Rating::SETTINGS_PAGE_SLUG, 'mr_settings_screen' );
- add_submenu_page( Multi_Rating::RATING_RESULTS_PAGE_SLUG, __( 'Reports', 'multi-rating' ), __( 'Reports', 'multi-rating' ), 'mr_edit_ratings', Multi_Rating::REPORTS_PAGE_SLUG, 'mr_reports_screen' );
+ //add_submenu_page( Multi_Rating::RATING_RESULTS_PAGE_SLUG, __( 'Reports', 'multi-rating' ), __( 'Reports', 'multi-rating' ), 'mr_edit_ratings', Multi_Rating::REPORTS_PAGE_SLUG, 'mr_reports_screen' );
add_submenu_page( Multi_Rating::RATING_RESULTS_PAGE_SLUG, __( 'Tools', 'multi-rating' ), __( 'Tools', 'multi-rating' ), 'mr_edit_ratings', Multi_Rating::TOOLS_PAGE_SLUG, 'mr_tools_screen' );
add_submenu_page( Multi_Rating::RATING_RESULTS_PAGE_SLUG, __( 'About', 'multi-rating' ), __( 'About', 'multi-rating' ), 'mr_edit_ratings', Multi_Rating::ABOUT_PAGE_SLUG, 'mr_about_screen' );
add_submenu_page( Multi_Rating::RATING_RESULTS_PAGE_SLUG, __( 'Edit Rating', 'multi-rating' ), '', 'mr_edit_ratings', Multi_Rating::EDIT_RATING_PAGE_SLUG, 'mr_edit_rating_screen' );
@@ -409,43 +412,50 @@ public function add_admin_menus() {
* @since 0.1
*/
public function admin_assets() {
-
+
$style_settings = (array) get_option( Multi_Rating::STYLE_SETTINGS );
-
+ $custom_images_settings = (array) get_option( Multi_Rating::CUSTOM_IMAGES_SETTINGS );
+
wp_enqueue_script( 'jquery' );
-
+
+ $icon_font_library = $style_settings[Multi_Rating::FONT_AWESOME_VERSION_OPTION];
+ $icon_classes = MR_Utils::get_icon_classes( $icon_font_library );
+
$config_array = array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'ajax_nonce' => wp_create_nonce( Multi_Rating::ID.'-nonce' ),
- 'confirm_clear_db_message' => __( 'Are you sure you want to permanently delete ratings?', 'multi-rating' )
+ 'confirm_clear_db_message' => __( 'Are you sure you want to permanently delete ratings?', 'multi-rating' ),
+ 'icon_classes' => json_encode( $icon_classes ),
+ 'use_custom_star_images' => ( $custom_images_settings[Multi_Rating::USE_CUSTOM_STAR_IMAGES] == true ) ? "true" : "false"
);
- wp_enqueue_script( 'mr-admin-script', plugins_url('assets' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'admin.js', __FILE__), array('jquery'), Multi_Rating::VERSION, true );
+ wp_enqueue_script( 'mr-admin-script', plugins_url( 'assets' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'admin.js', __FILE__), array('jquery'), Multi_Rating::VERSION, true );
wp_localize_script( 'mr-admin-script', 'mr_admin_data', $config_array );
- wp_enqueue_script( 'mr-frontend-script', plugins_url('assets' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'frontend-min.js', __FILE__), array('jquery'), Multi_Rating::VERSION, true );
+ wp_enqueue_script( 'mr-frontend-script', plugins_url('assets' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'frontend.js', __FILE__), array('jquery'), Multi_Rating::VERSION, true );
wp_localize_script( 'mr-frontend-script', 'mr_frontend_data', $config_array );
-
+
$disable_styles = self::instance()->settings->style_settings[Multi_Rating::DISABLE_STYLES_OPTION];
if ( ! $disable_styles ) {
- wp_enqueue_style( 'mr-frontend-style', plugins_url( 'assets' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'frontend-min.css', __FILE__ ) );
+ wp_enqueue_style( 'mr-frontend-style', plugins_url( 'assets' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'frontend.css', __FILE__ ) );
+ wp_add_inline_style( 'mr-frontend-style', self::instance()->inline_styles() );
}
wp_enqueue_style( 'mr-admin-style', plugins_url( 'assets' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'admin.css', __FILE__ ) );
-
+
// flot
wp_enqueue_script( 'flot', plugins_url( 'assets' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'flot' . DIRECTORY_SEPARATOR . 'jquery.flot.js', __FILE__ ), array( 'jquery' ) );
wp_enqueue_script( 'flot-categories', plugins_url( 'assets' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'flot' . DIRECTORY_SEPARATOR . 'jquery.flot.categories.js', __FILE__ ), array( 'jquery', 'flot' ) );
wp_enqueue_script( 'flot-time', plugins_url( 'assets' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'flot' . DIRECTORY_SEPARATOR . 'jquery.flot.time.js', __FILE__ ), array( 'jquery', 'flot' ) );
wp_enqueue_script( 'flot-selection', plugins_url( 'assets' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'flot' . DIRECTORY_SEPARATOR . 'jquery.flot.selection.js', __FILE__ ), array( 'jquery', 'flot', 'flot-time' ) );
-
+
// color picker
- wp_enqueue_style( 'wp-color-picker' );
+ wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'wp-color-picker' );
-
+
// date picker
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_style( 'jquery-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
-
+
wp_enqueue_media();
}
@@ -455,140 +465,154 @@ public function admin_assets() {
* @since 0.1
*/
public function assets() {
-
+
$style_settings = (array) get_option( Multi_Rating::STYLE_SETTINGS );
$custom_images_settings = (array) get_option( Multi_Rating::CUSTOM_IMAGES_SETTINGS );
-
+
wp_enqueue_script('jquery');
-
+
// Add simple table CSS for rating form
$disable_styles = self::instance()->settings->style_settings[Multi_Rating::DISABLE_STYLES_OPTION];
if ( ! $disable_styles ) {
- wp_enqueue_style( 'mr-frontend-style', plugins_url( 'assets' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'frontend-min.css', __FILE__ ) );
+ wp_enqueue_style( 'mr-frontend-style', plugins_url( 'assets' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'frontend.css', __FILE__ ) );
+ wp_add_inline_style( 'mr-frontend-style', self::instance()->inline_styles() );
}
-
- // Allow support for other versions of Font Awesome
+
$load_icon_font_library = $style_settings[Multi_Rating::INCLUDE_FONT_AWESOME_OPTION];
$icon_font_library = $style_settings[Multi_Rating::FONT_AWESOME_VERSION_OPTION];
-
$icon_classes = MR_Utils::get_icon_classes( $icon_font_library );
-
- $protocol = ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ) ? 'https' : 'http';
-
+
if ( $load_icon_font_library ) {
- if ( $icon_font_library == 'font-awesome-4.0.3' ) {
- wp_enqueue_style( 'font-awesome', $protocol . '://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css' );
- } else if ( $icon_font_library == 'font-awesome-3.2.1' ) {
+
+ $protocol = ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ) ? 'https' : 'http';
+
+ if ( $icon_font_library == 'font-awesome-v5' ) {
+ wp_enqueue_style( 'font-awesome', $protocol . '://use.fontawesome.com/releases/v5.13.0/css/all.css' );
+ } else if ( $icon_font_library == 'font-awesome-v4' ) {
+ wp_enqueue_style( 'font-awesome', $protocol . '://netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css' );
+ } else if ( $icon_font_library == 'font-awesome-v3' ) {
wp_enqueue_style( 'font-awesome', $protocol . '://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css' );
- } else if ( $icon_font_library == 'font-awesome-4.1.0' ) {
- wp_enqueue_style( 'font-awesome', $protocol . '://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css' );
- } else if ( $icon_font_library == 'font-awesome-4.2.0' ) {
- wp_enqueue_style( 'font-awesome', $protocol . '://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css' );
- } else if ( $icon_font_library == 'font-awesome-4.3.0' ) {
- wp_enqueue_style( 'font-awesome', $protocol . '://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css' );
- } else if ( $icon_font_library == 'font-awesome-4.5.0' ) {
- wp_enqueue_style( 'font-awesome', $protocol . '://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css' );
- } else if ( $icon_font_library == 'font-awesome-4.6.3' ) {
- wp_enqueue_style( 'font-awesome', $protocol . '://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css' );
- } else if ( $icon_font_library == 'font-awesome-4.7.0' ) {
- wp_enqueue_style( 'font-awesome', $protocol . '://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css' );
} else if ( $icon_font_library == 'dashicons' ) {
wp_enqueue_style( 'dashicons' );
}
+
}
-
+
$config_array = array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'ajax_nonce' => wp_create_nonce( Multi_Rating::ID.'-nonce' ),
'icon_classes' => json_encode( $icon_classes ),
'use_custom_star_images' => ( $custom_images_settings[Multi_Rating::USE_CUSTOM_STAR_IMAGES] == true ) ? "true" : "false"
);
-
- wp_enqueue_script( 'mr-frontend-script', plugins_url('assets' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'frontend-min.js', __FILE__), array('jquery'), Multi_Rating::VERSION, true );
+
+ wp_enqueue_script( 'mr-frontend-script', plugins_url( 'assets' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'frontend.js', __FILE__), array('jquery'), Multi_Rating::VERSION . 'a', true );
wp_localize_script( 'mr-frontend-script', 'mr_frontend_data', $config_array );
}
-
-
+
+
/**
* Register AJAX actions
*/
public function add_ajax_callbacks() {
-
+
add_action( 'wp_ajax_save_rating', array( 'MR_Rating_Form', 'save_rating' ) );
add_action( 'wp_ajax_nopriv_save_rating', array( 'MR_Rating_Form', 'save_rating' ) );
add_action( 'wp_ajax_save_rating_item_table_column', array( 'MR_Rating_Item_Table', 'save_rating_item_table_column' ) );
-
+
add_action( 'wp_ajax_nopriv_get_terms_by_taxonomy', 'mr_get_terms_by_taxonomy' );
add_action( 'wp_ajax_get_terms_by_taxonomy', 'mr_get_terms_by_taxonomy' );
-
+
}
+
+ /**
+ * Inline styles
+ */
+ public function inline_styles() {
+
+ $style_settings = (array) get_option( Multi_Rating::STYLE_SETTINGS );
+ $custom_images_settings = (array) get_option( Multi_Rating::CUSTOM_IMAGES_SETTINGS );
+ $star_rating_colour = $style_settings[Multi_Rating::STAR_RATING_COLOUR_OPTION];
+ $star_rating_hover_colour = $style_settings[Multi_Rating::STAR_RATING_HOVER_COLOUR_OPTION];
+ $error_message_colour = $style_settings[Multi_Rating::ERROR_MESSAGE_COLOUR_OPTION];
+
+ $image_width = $custom_images_settings[Multi_Rating::CUSTOM_STAR_IMAGE_WIDTH];
+ $image_height = $custom_images_settings[Multi_Rating::CUSTOM_STAR_IMAGE_HEIGHT];
+ $custom_images_enabled = $custom_images_settings[Multi_Rating::USE_CUSTOM_STAR_IMAGES];
+
+ ob_start();
+
+ if ($custom_images_enabled) {
+ ?>
+ .mr-custom-full-star {
+ background: url() no-repeat;
+ width: px;
+ height: px;
+ background-size: px px;
+ image-rendering: -moz-crisp-edges;
+ display: inline-block;
+ }
+ .mr-custom-half-star {
+ background: url() no-repeat;
+ width: px;
+ height: px;
+ background-size: px px;
+ image-rendering: -moz-crisp-edges;
+ display: inline-block;
+ }
+ .mr-custom-empty-star {
+ background: url() no-repeat;
+ width: px;
+ height: px;
+ background-size: px px;
+ image-rendering: -moz-crisp-edges;
+ display: inline-block;
+ }
+ .mr-custom-hover-star {
+ background: url() no-repeat;
+ width: px;
+ height: px;
+ background-size: px px;
+ image-rendering: -moz-crisp-edges;
+ display: inline-block;
+ }
+
+ .mr-star-hover {
+ color: !important;
+ }
+ .mr-star-full, .mr-star-half, .mr-star-empty {
+ color: ;
+ }
+ .mr-error {
+ color: ;
+ }
+
-
- true ) );
+
+ foreach ( $post_types as $post_type ) {
+
+ register_rest_field( $post_type,
+ 'multi-rating',
+ array(
+ 'get_callback' => 'mr_rest_api_custom_fields'
+ )
+ );
+
+ }
}
}
@@ -596,12 +620,14 @@ function mr_head() {
* Activate plugin
*/
function mr_activate_plugin() {
-
+
if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
- add_option(MULTI_RATING::DO_ACTIVATION_REDIRECT_OPTION, true);
+ if ( ! is_network_admin() ) { // is admin network request?
+ add_option(MULTI_RATING::DO_ACTIVATION_REDIRECT_OPTION, true);
+ }
Multi_Rating::activate_plugin();
}
-
+
}
register_activation_hook( __FILE__, 'mr_activate_plugin' );
@@ -610,7 +636,7 @@ function mr_activate_plugin() {
* Uninstall plugin
*/
function mr_uninstall_plugin() {
-
+
if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
Multi_Rating::uninstall_plugin();
}
@@ -635,4 +661,5 @@ function mr_multi_rating() {
do_action( 'mr_after_init' );
}
-add_action( 'plugins_loaded', 'mr_multi_rating' );
\ No newline at end of file
+// Note WPML is initialized in "plugins_loaded" with priority 10, so priority needs > 10
+add_action( 'plugins_loaded', 'mr_multi_rating', 11 );
diff --git a/readme.txt b/readme.txt
index 75d56ef..46f12fb 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,107 +1,149 @@
-=== Multi Rating ===
+=== Multi Rating ===
Contributors: dpowney
-Donate link: http://www.danielpowney.com/donate
-Tags: rating, multi-rating, post rating, star, multi, criteria, rich snippet, testimonial, review, microdata, feedback, question
+Tags: rating, review, post rating, star rating, seo, schema.org, json-ld
Requires at least: 4.0
-Tested up to: 4.7
+Tested up to: 5.7
Stable tag: trunk
License: GPLv2 or later
-License URI: http://www.gnu.org/licenses/gpl-2.0.html
+License URI: https://www.gnu.org/licenses/gpl-2.0.html
-A powerful rating / review system plugin for WordPress with a niche of doing multi ratings better than anyone else.
+A powerful post rating / review system plugin for WordPress.
== Description ==
-The best rating system plugin for WordPress. This is simple plugin for users to rate posts based on multiple criteria / questions.
-
-View [Demo](http://multiratingpro.com/demo-page-free?utm_source=view-demo&utm_medium=free-plugin&utm_campaign=readme).
-
-= Key Features =
-
-* 5 star ratings, percentage and score results
-* Multiple rating criteria and questions using star ratings, select drop-down lists and radio buttons to choose answers from
-* Font Awesome used for star icons or upload your own custom star images to use instead
-* Shortcodes and widgets to display the rating form and rating results
-* Shortcode and widget to display a list of rating results (sort by highest rated, lowest rated, most entries, post title ascending or post title descending)
-* Ability to add schema.org microdata to show the aggregate ratings in search engine results as rich snippets
-* View the rating results, entries and selected values in the WP-admin
-* Apply weights to rating items to adjust the overall rating results
-* Automatic placement settings to display the rating form and rating results on every post in different positions
-* Meta-box on the edit post page to override the default automatic placement settings
-* Settings to enable post types, turn on duplicate check validation, custom text and apply different styles etc...
-* Graphical reports on the number of entries per day
-* Tools to export ratings to a CSV file
-* Edit ratings in WP-admin (Editor & Administrator user roles only)
-* Developer friently
-* i18n translation ready and WPML support
-* In-built template system for customization
-* All data stored in your own WordPress database - no signup required!
-
-= Shortcode Examples =
-
-* [mr_rating_form]
+A powerful post rating / review system plugin for WordPress with a niche of doing multi ratings better than anyone else.
+
+Check out [the demo](https://multiratingpro.com/demo-page-free?utm_source=view-demo&utm_medium=free-plugin&utm_campaign=readme).
+
+= Features =
+
+* Rate posts based on different criteria with **star ratings**, select and radio buttons
+* Compatible with both the Classic editor and new **Gutenberg** editor
+* Adds **Google review snippets** to improve SEO (JSON-LD)
+* Integrates JSON-LD structured data with WordPress SEO (Yoast) and WooCommerce plugins
+* Use **Font Awesome** icons or upload custom images intead
+* Several **Gutenberg blocks**, shortcodes and widgets available
+* Can apply different **weights** to rating items to adjust results
+* Can **automatically add** the rating form and rating result to post content
+* **i18n translation ready** for multilingual sites
+* In-built **template system** to customize the HTML presentation
+* Access ratings through the WordPress **REST API**
+* Can export rating entries to CSV
+* Can edit rating details from WP-admin
+* Style options for stars icon colors
+
+= Shortcodes =
+
+* [mr_rating_form] - displays the rating form.
+* [mr_rating_result] - displays the overall rating result.
+* [mr_rating_results_list] - displays a list of post ratings.
+
+Shortcode examples:
+
* [mr_rating_form title="Please rate this" submit_button_text="Submit"]
-* [mr_rating_result]
-* [mr_rating_result post_id="100" no_rating_results_text="No rating result yet" show_rich_snippets="false"]
-* [mr_rating_results_list]
+* [mr_rating_result post_id="100" no_rating_results_text="No rating result yet"]
* [mr_rating_results_list title="Top Ratings" sort_by="highest_rated" limit="10"]
* [mr_rating_results_list title="Ratings" sort_by="most_entries" limit="5"]
-= Pro version available! =
+= Premium Version =
-The [Multi Rating Pro](http://multiratingpro.com?utm_source=pro-version&utm_medium=free-plugin&utm_campaign=readme&utm_content=top) version provides a significant additional feature set, including:
+Looking for some more advanced functionality? The [Multi Rating Pro](https://multiratingpro.com?utm_source=pro-version&utm_medium=free-plugin&utm_campaign=readme&utm_content=top) version provides a significant additional feature set, including:
-* Unlimited rating forms
+* Create multiple rating forms
* Ratings moderation (approve or unapprove rating entries)
-* WordPress comment system integration
-* Logged in users can update or delete their existing ratings
+* WordPress comment ratings
+* E-mail notifications for new rating entries
+* Show text labels for rating item options instead of numbers
* Bayesian average ratings
-* Add common review fields to the rating form including title, name, e-mail and comments
-* Add custom fields to the rating form to collect additional information
-* Show a list of rating entry details in a review layout
-* Show a breakdown of rating item results in a poll layout
-* Show text labels for rating item options instead of numbers
-* Extra shortcodes and widgets (i.e. reviews, user ratings dashboard and rating item results)
-* Filters to set different rating forms and override auto placement settings for specific taxonomies, terms, post types, post id's and page URL's
+* Add common review fields (title, name, e-mail and comments)
+* Add custom fields to collect additional information
+* Display rating entry details in a review layout
+* Display rating item results in a poll / bar chart layout
+* Extra shortcodes, widgets & Gutenerg blocks (i.e. reviews, dashboard of user ratings and detailed rating item results)
+* Logged in users can update or delete their existing ratings
+* Override the rating form to be used on specific posts, URLs, post types, post ids, taxonomies, terms etc…
* Options to exclude the home page, search page and archive pages (e.g. category)
-* Thumbs up/down rating item type (e.g. like or dislike)
-* Option to disallow anonymous ratings
-* Embed reCAPTCHA in the rating form (add-on)
+* Includes a thumbs up / thumbs down rating item type (e.g. like or dislike)
+* Option to only allow ratings from logged in users
+* Google reCAPTCHA validation (add-on)
* Gravity Forms integration (add-on)
-* And much more.
-
-Check out [Multi Rating Pro](http://multiratingpro.com?utm_source=pro-version&utm_medium=free-plugin&utm_campaign=readme&utm_content=bottom).
-
-== Installation ==
-
-1. Install plugin via the WordPress.org plugin directory. Unzip and place plugin folder in /wp-content/plugins/ directory for manual installation
-1. Activate the plugin through the 'Plugins' menu in WP-admin
-1. Go to Settings page in the 'Multi Rating' menu in WP-admin. The auto placement settings should be turned on with only the 'post' post type enabled by default.
-
-== Frequently Asked Questions ==
-
-Documentation can be found on the [demo page](http://multiratingpro.com/demo-page-free?utm_source=faq&utm_medium=free-plugin&utm_campaign=readme).
+* And much much more...
== Screenshots ==
-1. Auto placement of rating results after post title and rating form after post content. Twenty Fifteen theme.
-2. Rating Results List shortcode. [mr_rating_results_list show_filter="true" title="Top Ratings" sort_by="highest_rated"]
-3. Rating results in WP-admin for each post.
-4. Every rating entry can be viewed in WP-admin and edited
-5. Rating Results List widget options include displaying the post feature image, a rank, changing the result type (star rating out of 5, score or percentage), different sorting mechanisms (highest rated, lowest rated etc...), set widget title and much more.
-6. Rating items table.
-7. General settings.
-8. Style settings include star rating select and on hover colors, load Font Awesome library CDN, version of Font Awesome and the ability to set custom star rating images to use instead of Font Awesome icons.
-9. Custom text setting.
-10. Graphical report on the number of entries per day.
-11. The plugin has several tools including exporting rating results to a CSV file, clearing the rating results cache and deleting rating results in bulk.
-12. WP-admin plugin menu.
-13. Edit post page. Add shortcodes in the editor. The Multi Rating meta-box can set the auto placement settings per post to override the default settings.
-14. Rating Results List Widget. Twenty Fifteen theme.
+
+1. Rating form and rating results
+2. Gutenberg blocks 1
+3. Gutenberg blocks 2
+4. General settings
+5. Auto placement settings
+6. Style settings
+7. Post ratings in WP-admin
+8. Rating entries in WP-admin
+9. Rating items in WP-admin
+10. Widget options for list of rating results
== Upgrade Notice ==
== Changelog ==
+= 5.0.4 (07/03/2021) =
+* Fix: Tweak to JSON encoding for JSON-LD structured data
+
+= 5.0.4 (02/03/2021) =
+* New: Added mr_structured_data_item_type filter
+* Fix: Special characters causing invalid JSON-LD markup
+* Fix: Fresh install upgrade error
+
+= 5.0.3 (21/09/2020) =
+* Fix: Custom image settings undefined error in admin
+
+= 5.0.2 (14/08/2020) =
+* Fix: Console error in Gutenberg editor due to icon_classes missing
+* Fix: Deprecated jQuery function live() was used in admin JS
+
+= 5.0.1 (28/06/2020) =
+* Fix: Auto placement post type issue
+
+= 5.0 (27/06/2020) =
+* New: Added REST API readonly endpoints for rating results list, rating items and a custom field on posts with rating results
+* Tweak: Upgraded Font Awesome icons to latest v3 & v4 and added v5
+* Tweak: Fixed about page CSS and removed Credits tab.
+* Tweak: Removed custom CSS option. You should move this to the Customizer.
+* Tweak: Some minor CSS style changes. You may need to update your styles.
+* New: Added 3 Gutenberg blocks for the rating form, rating result and rating reslt list.
+* New: Migrated post meta settings to Gutenberg editor.
+* New: Added JSON-LD AggregateRatings structured data support for supported schema.org item types. Removed old microdata format which was previously added in the templates.
+* New: Added integration with WooCommerce Product structured data
+* New: Added integration with Wordpress SEO (Yoast) structured data graph
+* Tweak: Removed minified assets.
+* Tweak: Removed widget check for enabled post types.
+* Tweak: Moved enabled post types option to the auto placement settings.
+* Tweak: Changed classic editor post meta box styles.
+* Tweak: Removed post type check from the mr_can_apply_filter filter. This allows auto placement even when the post type is not enabled using post meta fields.
+
+= 4.3.1 =
+* Tweak: Removed WPML references
+
+= 4.3 (14/04/2018) =
+* Tweak: Removed IP address duplicate checking for GDPR compliance. Cookies will be the default option used instead.
+* Bug: Fixed PHP error when saving rating items due to typo...
+
+= 4.2.9 (22/12/2017) =
+* Tweak: Changed doubleval to floatval to avoid Wordfence and GravityScan false positive security alert for eval( $_POST string
+
+= 4.2.8 (05/12/2017) =
+* Bug: Upon plugin activation, do not redirect to about page if network admin
+* Bug: Fixed admin css not loading correctly
+* Tweak: Fixed visible date-picker div element in WP-admin
+* Tweak: Improved UI for Ratings, Entries, Rating Items and Reports screens in WP-admin
+* Tweak: Updated About page
+* Tweak: Added Upgrade to Pro advert in Settings screen in WP-admin
+* Tweak: Updated text in Tools screen in WP-admin
+* Bug: Removed comment form from appearing in the auto placement settings under the rating form position
+
+= 4.2.7 (25/07/2017) =
+* Tweak: Turned off auto placement in RSS feeds by checking the is_feed() function. Note a simple way to flush an RSS feed cache is to update a post.
+
= 4.2.6 (15/02/2017) =
* New: Font Awesome 4.7.0 support
* New: Added mr_disable_custom_text filter to turn off custom text settings allowing language translation of strings
@@ -130,7 +172,7 @@ Documentation can be found on the [demo page](http://multiratingpro.com/demo-pag
= 4.2.1 (09/07/2016) =
* Bug: Fixed fatal error missing rating-entries.php file
-= 4.2 (08/07/2016) =
+= 4.2 (08/07/2016) =
* New: Added Dashicon support
* New: Added Font Awesome 4.2.0, 4.5.0 and 4.6.3 support
* New: Added Pro version menu item
@@ -165,10 +207,10 @@ Documentation can be found on the [demo page](http://multiratingpro.com/demo-pag
* Tweak: Fixed plugin about page for WP 4.3
= 4.1.8 (14/08/2015) =
-* Tweak: Made it easier to add your own schema.org microdata and override the default "http://schema.org/Article" micordata using new filter mr_rating_result_microdata. The old filters mrp_rating_result_microdata_thing and mrp_rating_result_microdata_thing_properties are no longer supported.
+* Tweak: Made it easier to add your own schema.org microdata and override the default "https://schema.org/Article" micordata using new filter mr_rating_result_microdata. The old filters mrp_rating_result_microdata_thing and mrp_rating_result_microdata_thing_properties are no longer supported.
= 4.1.7 (08/07/2015) =
-* Bug: Fixed schema.org microdata for itemtype Article (the post) in rating-result.php template file missing required itemprops publishedDate, headline and image
+* Bug: Fixed schema.org microdata for itemtype Article (the post) in rating-result.php template file missing required itemprops publishedDate, headline and image
= 4.1.6 (02/08/2015) =
* Bug: Fixed dbdelta key spacing as per https://core.trac.wordpress.org/ticket/32314
@@ -184,7 +226,7 @@ Documentation can be found on the [demo page](http://multiratingpro.com/demo-pag
= 4.1.3 (06/07/2015) =
* Tweak: Changed post link in rating results and rating entries tables to the edit post page
-* Bug: Fixed touch event on minus icon with custom star images in rating form not working properly
+* Bug: Fixed touch event on minus icon with custom star images in rating form not working properly
= 4.1.2 (03/07/2015) =
* Bug: Fixed error creating db tables on activation caused by stray comma in SQL statement
@@ -372,7 +414,7 @@ Documentation can be found on the [demo page](http://multiratingpro.com/demo-pag
= 1.1.3 (14/12/2013) =
* Bug: Fixed post title on top rating results widget
-= 1.1.2 = (14/12/2013) =
+= 1.1.2 (14/12/2013) =
* Bug: Removed debugging comment accidentally left behind
= 1.1.1 (12/12/2013) =
@@ -394,4 +436,4 @@ Documentation can be found on the [demo page](http://multiratingpro.com/demo-pag
* New: Added check is_singular() to add rich snippets to rating results
= 1.0 =
-* Initial release
\ No newline at end of file
+* Initial release
diff --git a/templates/rating-form-custom-star-images.php b/templates/rating-form-custom-star-images.php
index 55d2b5b..f4709c0 100644
--- a/templates/rating-form-custom-star-images.php
+++ b/templates/rating-form-custom-star-images.php
@@ -41,4 +41,4 @@
-
+
\ No newline at end of file
diff --git a/templates/rating-form-rating-item.php b/templates/rating-form-rating-item.php
index fd14490..d1ae25d 100644
--- a/templates/rating-form-rating-item.php
+++ b/templates/rating-form-rating-item.php
@@ -4,7 +4,7 @@
* Rating form rating item template
*/
?>
->
+
>
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/templates/rating-form.php b/templates/rating-form.php
index 76bf29a..ab40de8 100644
--- a/templates/rating-form.php
+++ b/templates/rating-form.php
@@ -1,19 +1,16 @@
-
-
@@ -122,7 +124,6 @@
mr_get_template_part( 'rating-result', null, true, array(
'no_rating_results_text' => '',
'ignore_count' => true,
- 'generate_microdata' => false,
'show_title' => false,
'before_title' => $before_title,
'after_title' => $after_title,
diff --git a/templates/rating-result-percentage.php b/templates/rating-result-percentage.php
index 513f6b5..2b3826c 100644
--- a/templates/rating-result-percentage.php
+++ b/templates/rating-result-percentage.php
@@ -2,20 +2,10 @@
/**
* Rating result percentage rating template
*/
-$generate_microdata = isset( $generate_microdata ) && $generate_microdata;
?>
';
- }
echo $rating_result['adjusted_percentage_result'];
- if ( $generate_microdata ) {
- echo ' ';
- }
echo '%';
- if ( $generate_microdata ) {
- echo ' ';
- }
?>
\ No newline at end of file
diff --git a/templates/rating-result-score.php b/templates/rating-result-score.php
index c6e75d4..7f90f13 100644
--- a/templates/rating-result-score.php
+++ b/templates/rating-result-score.php
@@ -2,28 +2,12 @@
/**
* Rating result score rating template
*/
-$generate_microdata = isset( $generate_microdata ) && $generate_microdata;
?>
';
- }
echo $rating_result['adjusted_score_result'] ;
- if ( $generate_microdata ) {
- echo ' ';
- }
-
echo esc_html( $out_of_text );
-
- if ( $generate_microdata ) {
- echo '';
- }
echo $rating_result['total_max_option_value'];
- if ( $generate_microdata ) {
- echo ' ';
- }
?>
\ No newline at end of file
diff --git a/templates/rating-result-star-rating.php b/templates/rating-result-star-rating.php
index 130fe26..19de2ba 100644
--- a/templates/rating-result-star-rating.php
+++ b/templates/rating-result-star-rating.php
@@ -2,7 +2,6 @@
/**
* Rating result star rating template
*/
-$generate_microdata = isset( $generate_microdata ) && $generate_microdata;
?>
@@ -44,23 +43,8 @@
';
- }
echo $star_result;
- if ( $generate_microdata ) {
- echo ' ';
- }
-
echo esc_html( $out_of_text );
-
- if ( $generate_microdata ) {
- echo '';
- }
echo $max_stars;
- if ( $generate_microdata ) {
- echo ' ';
- }
?>
\ No newline at end of file
diff --git a/templates/rating-result.php b/templates/rating-result.php
index b9f765f..02e6f58 100644
--- a/templates/rating-result.php
+++ b/templates/rating-result.php
@@ -1,18 +1,8 @@
->
+
$rating_result,
- 'generate_microdata' => $generate_microdata
+ 'rating_result' => $rating_result
) );
} else if ( $result_type == Multi_Rating::PERCENTAGE_RESULT_TYPE ) {
mr_get_template_part( 'rating-result', 'percentage', true, array(
- 'rating_result' => $rating_result,
- 'generate_microdata' => $generate_microdata
+ 'rating_result' => $rating_result
) );
} else { // star rating
@@ -66,8 +54,7 @@
'star_result' => $star_result,
'icon_classes' => $icon_classes,
'image_height' => $image_height,
- 'image_width' => $image_width,
- 'generate_microdata' => $generate_microdata
+ 'image_width' => $image_width
) );
}
@@ -83,13 +70,7 @@
';
- }
echo number_format( $count );
- if ( $generate_microdata ) {
- echo ' ';
- }
echo $after_count;
?>
@@ -105,14 +86,6 @@
'
- . ' '
- . ' ';
- echo apply_filters( 'mr_microdata_rating_result_item_reviewed', $microdata, $post_id );
- }
-
}
?>
\ No newline at end of file
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 93446a7..01e4f6c 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -8,20 +8,20 @@
require_once $_tests_dir . '/includes/functions.php';
function _manually_load_plugin() {
-
- // Add your theme …
+
+ // Add your theme …
switch_theme('twentyfifteen');
// Update array with plugins to include ...
$plugins_to_active = array(
'multi-rating/multi-rating.php'
);
-
+
update_option( 'active_plugins', $plugins_to_active );
-
+
// uncomment this to create db tables
- //require dirname( dirname( __FILE__ ) ) . '/multi-rating.php';
- //Multi_Rating::activate_plugin();
+ require dirname( dirname( __FILE__ ) ) . '/multi-rating.php';
+ Multi_Rating::activate_plugin();
}
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
@@ -29,4 +29,4 @@ function _manually_load_plugin() {
'active_plugins' => array( 'multi-rating/multi-rating.php' )
);
-require $_tests_dir . '/includes/bootstrap.php';
\ No newline at end of file
+require $_tests_dir . '/includes/bootstrap.php';