diff --git a/assets/css/admin.css b/assets/css/admin.css index 469bc5a..cca8243 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -14,8 +14,11 @@ table.entries th#id, table.ratingitems th#rating_item_id, table.ratingresults th table.ratingitems th#description { width: 20em; } -table.ratingitems td.description .view { - font-weight: bold; +table.ratingitems td.description input { + width: 100%; +} +table.ratingitems td input.small-text { + padding: 3px 5px; } form#add-new-rating-item-form select#type,table.ratingitems td.type select { width: 6em; @@ -25,7 +28,7 @@ table.ratingresults th#entries_count, table.ratingresults th#action { } /* Reports */ -#reports-form p.description { +#reports-form p.description { margin-top: 4px; } @@ -79,7 +82,94 @@ li#toplevel_page_mr_rating_results .wp-submenu li a.wp-first-item { } -.about-wrap .mr-badge { float: right; border-radius: 4px; margin: 0 0 15px 15px; max-width: 120px; } +.about-wrap .mr-badge { float: right; border-radius: 4px; margin: 0 0 15px 15px; max-width: 120px; background-color: #37587b; padding-top: 10px; padding-bottom: 10px; } .about-wrap #mr-header { margin-bottom: 15px; } .about-wrap #mr-header h1 { margin-bottom: 15px !important; } -.about-wrap #mr-header .about-text { margin: 0 0 15px; max-width: 670px; } \ No newline at end of file +.about-wrap #mr-header .about-text { margin: 0 0 15px; max-width: 670px; } + + +/* Settings Page */ +#mr-settings-main { + max-width: 748px; + min-height: 872px; + position: relative; + padding-top: 10px; +} +#mr-settings-content { + width: 100%; + min-width: 463px; + float: left; + margin-bottom: 20px; +} +#mr-settings-sidebar { + width: 292px; + position: absolute; + right: -312px; +} +#mr-settings-sidebar a { + text-decoration: none; + color: #37587b; +} +#mr-upgrade-logo { + background-color: #37587b; /*#37587b; */ + padding: 20px; + padding-top: 10px; + padding-bottom: 10px; +} +#mr-upgrade-content ul { + margin-left: 30px; +} +#mr-upgrade-content ul li { + margin: 5px 0 10px 0; + font-size: 16px; +} +#mr-upgrade-content ul li span { + margin-left: -31px; + font-size: 22px; + margin-right: 6px; +} +#mr-upgrade-content { + background: #fff; + padding: 20px; + padding-top: 10px; + padding-bottom: 10px; +} + +/* About Page */ +.mr-about .changelog, .mr-about .feature-section { + padding-bottom: 0px; +} +.mr-about .about-section { + text-align: center; + color: #555d66; + font-size: 30px; + line-height: 1.9em; + font-weight: 400; + margin-bottom: 0px; +} +.mr-about .nav-tab .dashicons { + line-height: 24px; + font-size: 90%; +} +.mr-about .tab-upgrade-to-pro { + color: #0073aa; +} + +span.mr-star-rating .dashicons { + font-size: 1.3em; + width: 0.9em; + height: 1em; +} + + +#ui-datepicker-div {display: none;} + +/* Gutenberg */ +.mr-plugin-sidebar .components-base-control__help { + margin-top: 0px; + font-style: italic; +} +.mr-help { + margin-top: -8px; + font-style: italic; +} \ No newline at end of file diff --git a/assets/css/frontend-min.css b/assets/css/frontend-min.css deleted file mode 100644 index 6d6b494..0000000 --- a/assets/css/frontend-min.css +++ /dev/null @@ -1 +0,0 @@ -div.rating-form form{margin:15px 0 30px;width:auto;max-width:100%;display:table}div.rating-form input[type=button]{display:inline-block}div.rating-form form table{width:100%;text-align:left}div.rating-form form h4{font-weight:700}div.rating-form form table td{vertical-align:top}div.rating-form form table label{font-weight:400;vertical-align:text-top}div.rating-form form table .value{padding-bottom:10px;text-align:right}div.rating-form form table .value select{min-width:50px}div.rating-form form table input,div.rating-form form table textarea{min-weight:100%;width:100%}div.rating-form form table input[type=radio]{width:auto;margin-right:2px;margin-left:10px}div.rating-form form table input[type=button]{width:auto}div.rating-form form .delete-rating{margin-right:10px}div.rating-form form table label.input-label,div.rating-form form table label.textarea-label{display:block;padding-bottom:0}div.rating-form div.radio-option{display:inline-block}div.rating-form form table .action{text-align:right}.rating-form textarea{width:100%;max-width:100%}.rating-item .radio-option label{display:inline-block!important}.rating-item .radio-option{margin-right:10px;display:inline-block}.rating-item .radio-option input{margin-right:2px;display:inline-block}label.description input,label.description+select{margin-left:5px}.rating-item label.description+.radio-option{margin-right:10px}.before_title,.mr-star-rating-select .mr-minus{margin-right:5px}label.description{display:inline-block!important}.mr-star-rating-select i,.mr-star-rating-select span{cursor:pointer}.mr-star-rating+.star-result,.mr-star-rating+.stat-result,.rating-result a+*,.rating-result>.count{margin-left:3px}.rating-result-summary{display:inline-block;margin-left:5px}.rating-result,.rating-result .count,.rating-result .mr-star-rating,.rating-result .star-result{display:inline-block}.after_title,.before_title{font-size:65%;text-transform:none;font-weight:400;display:inline-block;margin-left:5px;text-align:left;vertical-align:top}.rating-results-list .count,.rating-results-list .star-result,.rating-results-list table tbody tr td{vertical-align:middle}.rating-results-list tr td label,p.mr label{margin-bottom:0}.rating-results-list tr td{padding:0 0 10px!important}.rating-results-list table{margin-top:10px!important;width:auto!important}.rating-results-list table tbody tr td,.rating-results-list-widget .rating-results-list table tbody tr td{display:table-cell}.rating-results-list table tbody tr+tr td{margin-top:2px}.after_content,.rating-form,.rating-results-list{margin-top:1em;margin-bottom:1em}.rating-results-list .rank,.rating-results-list .rating-result{margin-right:10px;line-height:1.4em}.rating-results-list .title{margin-right:3px}.rating-results-list .mr-featured-img{text-align:center;padding-right:10px!important}.rating-results-list .rating-result-row+.star-result{margin-left:5px}.before_content{margin-bottom:1em}form.mr-filter{display:block;margin-bottom:10px}form.mr-filter label{font-weight:400}form.mr-filter select{margin-left:5px;margin-right:5px}form.mr-filter input[type=submit]{margin-top:5px}p.mr label.description{margin-right:10px}.rating-results-list table,.rating-results-list td,.rating-results-list th,.rating-results-list tr{border:none;border-width:0;border-spacing:0;width:auto;padding-left:0;padding-right:0;max-width:100%}.rating-form .rating-item .mr-star-rating-select{margin-right:5px} \ No newline at end of file diff --git a/assets/css/frontend.css b/assets/css/frontend.css index 2714894..25d090d 100644 --- a/assets/css/frontend.css +++ b/assets/css/frontend.css @@ -1,11 +1,10 @@ /* Rating Form */ div.rating-form form { - margin: 0px; + padding: 0px; + padding-bottom: 1em; width : auto; max-width: 100%; display: table; - margin-bottom: 30px; - margin-top: 15px; } div.rating-form input[type="button"] { display: inline-block; @@ -25,7 +24,7 @@ div.rating-form form table label { vertical-align: text-top; } div.rating-form form table .value { - padding-bottom: 10px; + padding-bottom: 1em; text-align: right; } div.rating-form form table .value select { @@ -42,9 +41,6 @@ div.rating-form form table input[type=radio] { } div.rating-form form table input[type=button] { width: auto; -} -div.rating-form form .save-rating { - } div.rating-form form .delete-rating { margin-right: 10px; @@ -90,20 +86,20 @@ label.description { .mr-star-rating-select i, .mr-star-rating-select span { cursor: pointer; } - +/* .mr-star-rating + .stat-result, .rating-result > .count, .rating-result a + *, .mr-star-rating + .star-result { margin-left: 3px; -} +}*/ /* Rating Results */ .rating-result-summary { display: inline-block; margin-left: 5px; } - +/* .rating-result .mr-star-rating, .rating-result .star-result, .rating-result .count, .rating-result { display: inline-block; -} +}*/ .after_title { margin-left: 5px; @@ -125,13 +121,6 @@ p.mr label, .rating-results-list tr td label { margin-bottom: 0px; } -.rating-results-list tr td { - padding: 0 0 10px !important; -} -.rating-results-list table { - margin-top: 10px !important; -} - /* Rating Results List */ .rating-results-list table { width: auto !important; @@ -143,9 +132,6 @@ p.mr label, .rating-results-list tr td label { .rating-results-list table tbody tr td, .rating-results-list-widget .rating-results-list table tbody tr td { display: table-cell; } -.rating-results-list table tbody tr + tr td { - margin-top: 2px; -} .rating-results-list .rank, .rating-results-list .rating-result { margin-right: 10px; line-height: 1.4em; @@ -167,10 +153,6 @@ p.mr label, .rating-results-list tr td label { /** * Common */ -.rating-results-list, .rating-form { - margin-bottom: 1em; - margin-top: 1em; -} .before_content { margin-bottom: 1em; } @@ -180,7 +162,7 @@ p.mr label, .rating-results-list tr td label { } form.mr-filter { display: block; - margin-bottom: 10px; + margin-bottom: 1em; } form.mr-filter label { font-weight: normal; @@ -210,4 +192,20 @@ p.mr label.description { .rating-form .rating-item .mr-star-rating-select { margin-right: 5px; +} + +/* Blocks */ +.rating-form .wp-block-button { + margin-top: 1em; + display: inline-block; +} +.rating-results-list .wp-block-button { + display: inline-block; +} +.wp-block-button .mr-error { + margin-bottom: 1em; +} +.wp-block-button .mr-spinner { + color: inherit; + display: inline-block; } \ No newline at end of file diff --git a/assets/img/auto-placement.png b/assets/img/auto-placement.png index 6bc27f7..c9faa1a 100644 Binary files a/assets/img/auto-placement.png and b/assets/img/auto-placement.png differ diff --git a/assets/img/gutenberg-blocks.PNG b/assets/img/gutenberg-blocks.PNG new file mode 100644 index 0000000..c57d4a2 Binary files /dev/null and b/assets/img/gutenberg-blocks.PNG differ diff --git a/assets/img/pro_hori_coloured_white(border).svg b/assets/img/pro_hori_coloured_white(border).svg new file mode 100644 index 0000000..ce0f57b --- /dev/null +++ b/assets/img/pro_hori_coloured_white(border).svg @@ -0,0 +1 @@ +pro_hori_coloured_white(border) \ No newline at end of file diff --git a/assets/img/rating-form.PNG b/assets/img/rating-form.PNG new file mode 100644 index 0000000..80c9dcc Binary files /dev/null and b/assets/img/rating-form.PNG differ diff --git a/assets/img/rating-items.png b/assets/img/rating-items.png new file mode 100644 index 0000000..b8c2153 Binary files /dev/null and b/assets/img/rating-items.png differ diff --git a/assets/img/shortcodes.png b/assets/img/shortcodes.png index abb5fb6..5671b89 100644 Binary files a/assets/img/shortcodes.png and b/assets/img/shortcodes.png differ diff --git a/assets/img/structured-data.PNG b/assets/img/structured-data.PNG new file mode 100644 index 0000000..3dae3bc Binary files /dev/null and b/assets/img/structured-data.PNG differ diff --git a/assets/img/vert_coloured white(border).svg b/assets/img/vert_coloured white(border).svg new file mode 100644 index 0000000..600b358 --- /dev/null +++ b/assets/img/vert_coloured white(border).svg @@ -0,0 +1,173 @@ + + + + + + image/svg+xml + + vert_coloured(border) + + + + + + + + vert_coloured(border) + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/js/admin.js b/assets/js/admin.js index e097705..1e019db 100644 --- a/assets/js/admin.js +++ b/assets/js/admin.js @@ -1,28 +1,27 @@ -jQuery(document).ready(function() { +jQuery(document).ready(function() { jQuery("#add-new-rating-item-btn").click(function() { jQuery("#form-submitted").val("true"); }); - jQuery("#clear-database-btn").live('click',function(e) { - + jQuery("#clear-database-btn").click(function() { var result = confirm(mr_admin_data.confirm_clear_db_message); if (result == true) { jQuery("#clear-database").val("true"); } else { event.preventDefault(); } - + }); - + jQuery("#export-btn").click(function(event) { jQuery("#export-rating-results").val("true"); }); - + jQuery("#clear-cache-btn").click(function(event) { jQuery("#clear-cache").val("true"); }); - + jQuery(document).on('widget-updated', function(e, widget) { // save widget unbinds events... jQuery(".widget .mr-rating-results-widget-taxonomy, .widget .mr-user-rating-results-widget-taxonomy").change(function(e) { handle_taxonomy_change(this.id); @@ -31,29 +30,29 @@ jQuery(document).ready(function() { jQuery(".widget .mr-rating-results-widget-taxonomy, .widget .mr-user-rating-results-widget-taxonomy").change(function(e) { handle_taxonomy_change(this.id); }); - + /** * Handles taxonomy change in the Rating Results List Widget - * + * * @returns */ function handle_taxonomy_change(elementId) { // retrieve widget instance - var parts = elementId.split("-"); + var parts = elementId.split("-"); var instance = parts[2]; var name = parts[1]; - + // retrieve selected taxonomy var taxonomy = jQuery("#" + elementId).val(); - + if (taxonomy == "") { var termSelect = jQuery("#widget-" + name + "-" + instance + "-term_id"); termSelect.empty(); termSelect.prepend(""); return; } - - // ajax call to retrieve new terms + + // ajax call to retrieve new terms var data = { action : "get_terms_by_taxonomy", nonce : mr_admin_data.ajax_nonce, @@ -62,31 +61,31 @@ jQuery(document).ready(function() { jQuery.post(mr_admin_data.ajax_url, data, function(response) { var jsonResponse = jQuery.parseJSON(response); - + var termSelect = jQuery("#widget-" + name + "-" + instance + "-term_id"); termSelect.empty(); - + var index = jsonResponse.length-1; for (index; index>=0; index--) { termSelect.prepend(""); } }); } - - var rowActions = jQuery("#rating-item-table-form .row-actions > a"); + + var rowActions = jQuery("#rating-item-table-form .row-actions span a"); jQuery.each(rowActions, function(index, element) { - jQuery(element).click(function(event) { + jQuery(element).click(function(event) { var btnId = this.id; - var parts = btnId.split("-"); + var parts = btnId.split("-"); var action = parts[0]; var column = parts[1]; - var rowId = parts[2]; + var rowId = parts[2]; if (action === "edit") { // change state jQuery("#view-section-" + column + "-" + rowId).css("display", "none"); jQuery("#edit-section-" + column + "-" + rowId).css("display", "block"); } else if (action === "save") { - + var field_id = "#field-" + column + "-" + rowId; var value = null; if (jQuery(field_id).is(":checkbox")) { @@ -94,9 +93,9 @@ jQuery(document).ready(function() { } else { value = jQuery(field_id).val(); } - - var data = { - + + var data = { + action : "save_rating_item_table_column", nonce : mr_admin_data.ajax_nonce, column : column, @@ -108,20 +107,24 @@ jQuery(document).ready(function() { if (jsonResponse.error_message && jsonResponse.error_message.length > 0) { alert(jsonResponse.error_message); } else { - jQuery("#text-" + column + "-" + rowId).html(jsonResponse.value); + var innerHTML = jsonResponse.value; + if (column == 'description') { + innerHTML = '' + innerHTML + ''; + } + jQuery("#text-" + column + "-" + rowId).html(innerHTML); jQuery("#view-section-" + column + "-" + rowId).css("display", "block"); jQuery("#edit-section-" + column + "-" + rowId).css("display", "none"); } }); } - + // stop event event.preventDefault(); }); }); - + jQuery(document).ready(function() { - + jQuery('.color-picker').wpColorPicker({ defaultColor: false, change: function(event, ui){}, @@ -129,22 +132,22 @@ jQuery(document).ready(function() { hide: true, palettes: true }); - + jQuery('.date-picker').datepicker({ dateFormat : 'yy-mm-dd' }); - + }); - + /** * Displays the media uploader for selecting an image. - * + * * @param starImage star image name for media uploader */ function renderMediaUploader(starImage) { - + var file_frame, image_data; - + /** * If an instance of file_frame already exists, then we can open it * rather than creating a new instance. @@ -153,7 +156,7 @@ jQuery(document).ready(function() { file_frame.open(); return; } - + /** * If we're this far, then an instance does not exist, so we need to * create our own. @@ -170,7 +173,7 @@ jQuery(document).ready(function() { state: "insert", multiple: false }); - + /** * Setup an event handler for what to do when an image has been * selected. @@ -180,29 +183,29 @@ jQuery(document).ready(function() { * to the insert event. */ file_frame.on("insert", function() { - + // Read the JSON data returned from the Media Uploader var json = file_frame.state().get("selection").first().toJSON(); - + // After that, set the properties of the image and display it jQuery("#" + starImage + "-preview").attr("src", json.url).css("display", "block"); - + // Store the image's information into the meta data fields jQuery("#" + starImage).val(json.url); }); - + // Now display the actual file_frame file_frame.open(); - + } - + /** * Custom images */ jQuery("#custom-full-star-img-upload-btn, #custom-half-star-img-upload-btn, #custom-empty-star-img-upload-btn, #custom-hover-star-img-upload-btn").on("click", function(evt) { // Stop the anchor's default behavior evt.preventDefault(); - + var btnId = this.id; var index = btnId.indexOf("-upload-btn"); var starImage = btnId.substring(0, index); @@ -210,8 +213,8 @@ jQuery(document).ready(function() { // Display the media uploader renderMediaUploader(starImage); }); - - + + jQuery("#use-custom-star-images").change(function() { if (this.checked) { jQuery("#custom-star-images-details").show("slow", function() {}); @@ -219,5 +222,5 @@ jQuery(document).ready(function() { jQuery("#custom-star-images-details").hide("slow", function() {}); } }); - -}); \ No newline at end of file + +}); diff --git a/assets/js/blocks.js b/assets/js/blocks.js new file mode 100644 index 0000000..f49ed18 --- /dev/null +++ b/assets/js/blocks.js @@ -0,0 +1,262 @@ +( function() { // local scope + + const { registerBlockType } = wp.blocks; // Blocks API + const el = wp.element.createElement; // React.createElement + const { __ } = wp.i18n; // translation functions + const { InspectorControls } = wp.editor; + const { PanelBody, PanelRow, Panel, TextControl, ToggleControl } = wp.components; + const { serverSideRender } = wp; + + /* + * Rating form block + */ + registerBlockType( 'multi-rating/rating-form', { + + // Built-in attributes + title: __( 'Rating Form', 'multi-rating' ), + description: __( 'Adds a rating form for a post.', 'multi-rating' ), + icon: 'star-filled', + category: 'common', + + // Custom attributes - server side + + // Built-in functions + edit: function( props ) { + + var className = props.className; + var setAttributes = props.setAttributes; + + return el('div', {}, [ + + // Preview + el( serverSideRender, { + block: 'multi-rating/rating-form', + attributes: props.attributes, + className : className + } ), + + // Block inspector + el( InspectorControls, { className : props.className }, [ + el( + PanelBody, + {}, + el( + PanelRow, + {}, + el( TextControl, { + value: props.attributes.title, + label: __( 'Title', 'multi-rating' ), + onChange: ( value ) => { + props.setAttributes( { title: value } ); + }, + type: 'string' + }) + ), + el( + PanelRow, + {}, + el( TextControl, { + value: props.attributes.submit_button_text, + label: __( 'Submit Button Text', 'multi-rating' ), + onChange: ( value ) => { + props.setAttributes( { submit_button_text: value } ); + } + }) + ) + ) + ]) + ]); + }, + + save: function( props ) { + return null; + } + + } ); + + + + /* + * Rating result block + */ + registerBlockType( 'multi-rating/rating-result', { + + // Built-in attributes + title: __( 'Rating Result', 'multi-rating' ), + description: __( 'Displays an average rating result for a post.', 'multi-rating' ), + icon: 'star-filled', + category: 'common', + + // Custom attributes - set server side + + // Built-in functions + edit: function( props) { + + var className = props.className; + var setAttributes = props.setAttributes; + + return el('div', {}, [ + + // Preview + el( serverSideRender, { + block: 'multi-rating/rating-result', + attributes: props.attributes, + className : className + } ), + + // Block inspector + el( InspectorControls, {}, [ + el( + PanelBody, + {}, + el( + PanelRow, + {}, + el(ToggleControl, { + checked: props.attributes.show_title, + label: __( 'Show Title', 'multi-rating' ), + onChange: ( value ) => { + props.setAttributes( { show_title: value } ); + }, + }) + ), + el( + PanelRow, + {}, + el(ToggleControl, { + checked: props.attributes.show_count, + label: __( 'Show Count', 'multi-rating' ), + onChange: ( value ) => { + props.setAttributes( { show_count: value } ); + }, + }) + ) + ) + ]) + ]); + }, + + save: function( props ) { + return null; + } + + } ); + + + + + /* + * Rating result block + */ + registerBlockType( 'multi-rating/rating-results-list', { + + // Built-in attributes + title: __( 'Rating Results List', 'multi-rating' ), + description: __( 'Displays a list of the highest average rating results for posts.', 'multi-rating' ), + icon: 'star-filled', + category: 'common', + + // Custom attributes - set server side + + // Built-in functions + edit: function( props) { + + var className = props.className; + var setAttributes = props.setAttributes; + + return el('div', {}, [ + + // Preview + el( serverSideRender, { + block: 'multi-rating/rating-results-list', + attributes: props.attributes, + className : className + } ), + + // Block inspector + el( InspectorControls, {}, [ + el( + PanelBody, + {}, + el( + PanelRow, + {}, + el( TextControl, { + value: props.attributes.title, + label: __( 'Title', 'multi-rating' ), + onChange: ( value ) => { + props.setAttributes( { title: value } ); + }, + type: 'string' + }) + ), + el( + PanelRow, + {}, + el( TextControl, { + value: props.attributes.limit, + label: __( 'Limit', 'multi-rating' ), + onChange: ( value ) => { + props.setAttributes( { limit: parseInt(value) } ); + }, + min: 1, + max: 50, + type: 'number' + }) + ), + el( + PanelRow, + {}, + el(ToggleControl, { + checked: props.attributes.show_count, + label: __( 'Show Count', 'multi-rating' ), + onChange: ( value ) => { + props.setAttributes( { show_count: value } ); + }, + }) + ), + el( + PanelRow, + {}, + el(ToggleControl, { + checked: props.attributes.show_filter, + label: __( 'Show Filter', 'multi-rating' ), + onChange: ( value ) => { + props.setAttributes( { show_filter: value } ); + } + }) + ), + el( + PanelRow, + {}, + el(ToggleControl, { + checked: props.attributes.show_rank, + label: __( 'Show Rank', 'multi-rating' ), + onChange: ( value ) => { + props.setAttributes( { show_rank: value } ); + } + }) + ), + el( + PanelRow, + {}, + el(ToggleControl, { + checked: props.attributes.show_featured_img, + label: __( 'Show Featured Image', 'multi-rating' ), + onChange: ( value ) => { + props.setAttributes( { show_featured_img: value } ); + } + }) + ) + ) + ]) + ]); + }, + + save: function( props ) { + return null; + } + + } ); + +} )( ) \ No newline at end of file diff --git a/assets/js/frontend-min.js b/assets/js/frontend-min.js deleted file mode 100644 index 4bc5323..0000000 --- a/assets/js/frontend-min.js +++ /dev/null @@ -1 +0,0 @@ -jQuery(document).ready(function(){function r(r){var t=jQuery.parseJSON(r),s=t.data.post_id+"-"+t.data.sequence,e=jQuery("#rating-form-"+s);if("success"==t.status){var a=jQuery(".rating-result-"+t.data.post_id).filter(".mr-filter");a&&a.replaceWith(t.data.html)}if(jQuery("#rating-form-"+s+" .rating-item .mr-error").html(""),t.validation_results&&t.validation_results.length>0||t.message){var m="";if(t.validation_results){var l=0;for(l;l'+t.validation_results[l].message+"

"}t.message&&(m+='

'+t.message+"

"),e&&e.parent().find(".message")&&e.parent().find(".message").remove(),e&&e.parent()&&("success"==t.status&&t.data.hide_rating_form?e.parent().after(m):e.find(".save-rating").before(m))}"success"==t.status&&1==t.data.hide_rating_form&&e&&e.remove();var u="mr-spinner-"+s;jQuery("#"+u).remove()}function t(r,t){var e=s(r);null!=e&&(m[e]=t)}function s(r){var t=r.split("-"),s=t[4],e=t[5],a="rating-item-"+s+"-"+e;return a}function e(r){var t=r.id,s=t.split("-"),e=s[1],a=s[4],m=s[5],l="#rating-item-"+a+"-"+m;jQuery(l).val(e)}var a=jQuery.parseJSON(mr_frontend_data.icon_classes);jQuery(".rating-form :button").click(function(t){var s=[],e=t.currentTarget.id,m=e.split("-"),l=m[1],u=m[2];jQuery('.rating-form input[type="hidden"].rating-item-'+l+"-"+u).each(function(r){var t=jQuery(this).val(),e=jQuery('[name="rating-item-'+t+"-"+u+'"]'),a=null;a=jQuery(e).is(":radio")?jQuery('input[type="radio"][name="rating-item-'+t+"-"+u+'"]:checked').val():jQuery(e).is("select")?jQuery('select[name="rating-item-'+t+"-"+u+'"] :selected').val():jQuery('input[type="hidden"][name="rating-item-'+t+"-"+u+'"]').val();var m={id:t,value:a};s[r]=m});var o={action:"save_rating",nonce:mr_frontend_data.ajax_nonce,ratingItems:s,postId:l,sequence:u},n=l+"-"+u,i="mr-spinner-"+n;jQuery('').insertAfter("input#"+e),jQuery.post(mr_frontend_data.ajax_url,o,function(t){r(t)})});var m={},l=jQuery.parseJSON(mr_frontend_data.use_custom_star_images);jQuery(".mr-star-rating-select .mr-star-empty, .mr-star-rating-select .mr-star-full").on("click",function(r){t(this.id,"clicked"),1==l?(jQuery(this).not(".mr-minus").removeClass("mr-custom-empty-star mr-star-empty mr-custom-hover-star mr-star-hover").addClass("mr-custom-full-star mr-star-full"),jQuery(this).prevAll().not(".mr-minus").removeClass("mr-custom-empty-star mr-star-empty mr-custom-hover-star mr-star-hover").addClass("mr-custom-full-star mr-star-full"),jQuery(this).nextAll().not(".mr-minus").removeClass("mr-custom-full-star mr-star-full mr-custom-hover-star mr-star-hover").addClass("mr-custom-empty-star mr-star-empty")):(jQuery(this).not(".mr-minus").removeClass(a.star_empty+" "+a.star_hover).addClass(a.star_full),jQuery(this).prevAll().not(".mr-minus").removeClass(a.star_empty+" "+a.star_hover).addClass(a.star_full),jQuery(this).nextAll().not(".mr-minus").removeClass(a.star_full+" "+a.star_hover).addClass(a.star_empty)),e(this)}),jQuery(".mr-star-rating-select .mr-minus").on("click",function(r){t(this.id,""),1==l?(jQuery(this).not(".mr-minus").removeClass("mr-custom-empty-star mr-star-empty mr-custom-hover-star mr-star-hover").addClass("mr-custom-full-star mr-star-full"),jQuery(this).prevAll().not(".mr-minus").removeClass("mr-custom-empty-star mr-star-empty mr-custom-hover-star mr-star-hover").addClass("mr-custom-full-star mr-star-full"),jQuery(this).nextAll().not(".mr-minus").removeClass("mr-custom-full-star mr-star-full mr-custom-hover-star mr-star-hover").addClass("mr-custom-empty-star mr-star-empty")):(jQuery(this).not(".mr-minus").removeClass(a.star_empty+" "+a.star_hover).addClass(a.star_full),jQuery(this).prevAll().not(".mr-minus").removeClass(a.star_empty+" "+a.star_hover).addClass(a.star_full),jQuery(this).nextAll().not(".mr-minus").removeClass(a.star_full+" "+a.star_hover).addClass(a.star_empty)),e(this)}),jQuery(".mr-star-rating-select .mr-minus, .mr-star-rating-select .mr-star-empty, .mr-star-rating-select .mr-star-full").on("mouseenter mouseleave",function(r){var e=this.id,u=s(e);(0==jQuery("#"+u).val()||"clicked"!=m[u]&&void 0!=m[u])&&(t(this.id,"hovered"),1==l?(jQuery(this).not(".mr-minus").removeClass("mr-custom-empty-star mr-star-empty").addClass("mr-custom-hover-star mr-star-hover"),jQuery(this).prevAll().not(".mr-minus").removeClass("mr-custom-empty-star mr-star-empty").addClass("mr-custom-hover-star mr-star-hover"),jQuery(this).nextAll().not(".mr-minus").removeClass("mr-custom-hover-star mr-star-hover mr-custom-full-star mr-star-full").addClass("mr-custom-empty-star mr-star-empty")):(jQuery(this).not(".mr-minus").removeClass(a.star_empty).addClass(a.star_hover),jQuery(this).prevAll().not(".mr-minus").removeClass(a.star_empty).addClass(a.star_hover),jQuery(this).nextAll().not(".mr-minus").removeClass(a.star_hover+" "+a.star_full).addClass(a.star_empty)))});var u={started:null,currrentX:0,yCoord:0,previousXCoord:0,previousYCoord:0,touch:null};jQuery(".mr-star-rating-select .mr-star-empty, .mr-star-rating-select .mr-star-full, .mr-star-rating-select .mr-minus").on("touchstart",function(r){u.started=(new Date).getTime();var t=r.originalEvent.touches[0];u.previousXCoord=t.pageX,u.previousYCoord=t.pageY,u.touch=t}),jQuery(".mr-star-rating-select .mr-star-empty, .mr-star-rating-select .mr-star-full, .mr-star-rating-select .mr-minus").on("touchend touchcancel",function(r){var t=(new Date).getTime();if(null!==u.started&&t-u.started<200&&null!==u.touch){var s=u.touch,m=s.pageX,o=s.pageY;u.previousXCoord===m&&u.previousYCoord===o&&(1==l?(jQuery(this).not(".mr-minus").removeClass("mr-custom-empty-star mr-star-empty").addClass("mr-custom-full-star mr-star-full"),jQuery(this).prevAll().not(".mr-minus").removeClass("mr-custom-empty-star mr-star-empty").addClass("mr-custom-full-star mr-star-full"),jQuery(this).nextAll().not(".mr-minus").removeClass("mr-custom-full-star mr-star-full").addClass("mr-custom-empty-star mr-star-empty")):(jQuery(this).not(".mr-minus").removeClass(a.star_empty).addClass(a.star_full),jQuery(this).prevAll().not(".mr-minus").removeClass(a.star_empty).addClass(a.star_full),jQuery(this).nextAll().not(".mr-minus").removeClass(a.star_full).addClass(a.star_empty)),e(this))}u.started=null,u.touch=null})}); \ No newline at end of file diff --git a/assets/js/frontend.js b/assets/js/frontend.js index b21b305..86ed9e1 100644 --- a/assets/js/frontend.js +++ b/assets/js/frontend.js @@ -1,9 +1,14 @@ jQuery(document).ready(function() { // supporting different versions of Font Awesome icons - var icon_classes = jQuery.parseJSON(mr_frontend_data.icon_classes); + var icon_classes = mr_frontend_data.icon_classes; + if (typeof icon_classes === 'string') { + icon_classes = jQuery.parseJSON(icon_classes); + } - jQuery(".rating-form :button").click(function(e) { + jQuery(".rating-form :submit").click(function(e) { + + e.preventDefault(); var ratingItems = []; var customFields = []; @@ -44,7 +49,7 @@ jQuery(document).ready(function() { var temp = postId +'-' + sequence; var spinnerId = 'mr-spinner-' + temp; - jQuery('').insertAfter('input#' + btnId); + jQuery('').insertAfter(jQuery('input#' + btnId).parent()); jQuery.post(mr_frontend_data.ajax_url, data, function(response) { handle_rating_form_submit_response(response); @@ -123,7 +128,10 @@ jQuery(document).ready(function() { */ var ratingItemStatus = {}; - var useCustomStarImages = jQuery.parseJSON(mr_frontend_data.use_custom_star_images); + var useCustomStarImages = mr_frontend_data.use_custom_star_images; + if (typeof useCustomStarImages === 'string') { + useCustomStarImages = jQuery.parseJSON(useCustomStarImages); + } jQuery(".mr-star-rating-select .mr-star-empty, .mr-star-rating-select .mr-star-full").on("click", function(e) { diff --git a/assets/js/plugin.js b/assets/js/plugin.js new file mode 100644 index 0000000..02cf467 --- /dev/null +++ b/assets/js/plugin.js @@ -0,0 +1,215 @@ +( function() { // local scope + + const el = wp.element.createElement; // React.createElement + const { __ } = wp.i18n; // translation functions + const { SelectControl, PanelBody, PanelRow, Panel } = wp.components; //Block inspector wrapper + const { Fragment } = wp.element; + const { registerPlugin } = wp.plugins; + const { PluginSidebar, PluginSidebarMoreMenuItem } = wp.editPost; + const { withSelect, withDispatch, dispatch, select } = wp.data; + const { compose } = wp.compose; + + + /** + * Rating form position select control + */ + var ratingFormPositionSelect = compose( + withDispatch( function( dispatch, props ) { + return { + setRatingFormPosition: function( metaValue ) { + dispatch( 'core/editor' ).editPost( + { meta: { [ 'rating_form_position' ]: metaValue } } + ); + } + } + } ), + withSelect( function( select, props ) { + return { + ratingFormPosition: select( 'core/editor' ).getEditedPostAttribute( 'meta' )[ 'rating_form_position' ], + } + } ) )( function( props ) { + return el( SelectControl, { + label: __( 'Rating Form Position', 'multi-rating' ), + description: __( 'Add the rating form to the post.', 'multi-rating' ), + options: [ + { value: 'do_not_show', label: __( 'Do not show', 'multi-rating' ) }, + { value: '', label: __( 'Use default settings', 'multi-rating' ) }, + { value: 'before_content', label: __( 'Before content', 'multi-rating' ) }, + { value: 'after_content', label: __( 'After content', 'multi-rating' ) } + ], + help : __( 'Auto placement position for the rating form on the post.', 'multi-rating' ), + value: props.ratingFormPosition, + onChange: function( value ) { + props.setRatingFormPosition( value ); + }, + }); + } + ); + + /** + * Rating result position select control + */ + var ratingResultPositionSelect = compose( + withDispatch( function( dispatch, props ) { + return { + setRatingResultPosition: function( metaValue ) { + dispatch( 'core/editor' ).editPost( + { meta: { [ 'rating_results_position' ]: metaValue } } + ); + } + } + } ), + withSelect( function( select, props ) { + return { + ratingResultPosition: select( 'core/editor' ).getEditedPostAttribute( 'meta' )[ 'rating_results_position' ], + } + } ) )( function( props ) { + return el( SelectControl, { + label: __( 'Rating Result Position', 'multi-rating' ), + description: __( 'Add the rating result to the post.', 'multi-rating' ), + options: [ + { value: 'do_not_show', label: __( 'Do not show', 'multi-rating' ) }, + { value: '', label: __( 'Use default settings', 'multi-rating' ) }, + { value: 'before_title', label: __( 'Before title', 'multi-rating' ) }, + { value: 'after_title', label: __( 'After title', 'multi-rating' ) }, + { value: 'before_content', label: __( 'Before content', 'multi-rating' ) }, + { value: 'after_content', label: __( 'After content', 'multi-rating' ) } + ], + help : __( 'Auto placement position for the rating result on the post.', 'multi-rating' ), + value: props.ratingResultPosition, + onChange: function( value ) { + props.setRatingResultPosition( value ); + }, + }); + } + ); + + + /** + * Structured data type select + */ + var structuredDataTypeSelect = compose( + withDispatch( function( dispatch, props ) { + return { + setStruturedDataType: function( metaValue ) { + dispatch( 'core/editor' ).editPost( + { meta: { [ 'mr_structured_data_type' ]: metaValue } } + ); + } + } + } ), + withSelect( function( select, props ) { + return { + structuredDataType: select( 'core/editor' ).getEditedPostAttribute( 'meta' )[ 'mr_structured_data_type' ], + } + } ) )( function( props ) { + + return el( SelectControl, { + label: 'Create New Type', + description: __( 'Schema.org item type for post.', 'multi-rating' ), + options: [ + { value: '', label: '' }, + { value: 'Book', label: __( 'Book', 'multi-rating' ) }, + { value: 'Course', label: __( 'Course', 'multi-rating' ) }, + { value: 'CreativeWorkSeason', label: __( 'CreativeWorkSeason', 'multi-rating' ) }, + { value: 'CreativeWorkSeries', label: __( 'CreativeWorkSeries', 'multi-rating' ) }, + { value: 'Episode', label: __( 'Episode', 'multi-rating' ) }, + { value: 'Event', label: __( 'Event', 'multi-rating' ) }, + { value: 'Game', label: __( 'Game', 'multi-rating' ) }, + { value: 'HowTo', label: __( 'HowTo', 'multi-rating' ) }, + { value: 'LocalBusiness', label: __( 'LocalBusiness', 'multi-rating' ) }, + { value: 'MediaObject', label: __( 'MediaObject', 'multi-rating' ) }, + { value: 'Movie', label: __( 'Movie', 'multi-rating' ) }, + { value: 'MusicPlaylist', label: __( 'MusicPlaylist', 'multi-rating' ) }, + { value: 'MusicRecording', label: __( 'MusicRecording', 'multi-rating' ) }, + { value: 'Organization', label: __( 'Organization', 'multi-rating' ) }, + { value: 'Product', label: __( 'Product', 'multi-rating' ) }, + { value: 'Recipe', label: __( 'Recipe', 'multi-rating' ) }, + { value: 'SoftwareApplication', label: __( 'SoftwareApplication', 'multi-rating' ) } + ], + help : __( '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.', 'multi-rating' ), + value: props.structuredDataType, + onChange: function( value ) { + props.setStruturedDataType( value ); + }, + }); + + } + ); + + + /** + * Adds to the plugin post settings to the Gutenberg plugin and sidebar menus + */ + registerPlugin( 'multi-rating', { + + icon: 'star-filled', + + render: function () { + return el( + Fragment, + {}, + el( + PluginSidebarMoreMenuItem, + { + target: 'multi-rating', + icon: 'star-filled' + }, + __( 'Multi Rating', 'multi-rating' ) + ), + el( + PluginSidebar, + { + name: 'multi-rating', + icon: 'star-filled', + title: __( 'Multi Rating', 'multi-rating' ), + className: 'mr-plugin-sidebar' + }, + el( + Panel, + {}, + el( + PanelBody, + { + title: __( 'Auto Placement', 'multi-rating' ), + initialOpen: false + }, + el( + PanelRow, + {}, + el( ratingFormPositionSelect ) + ), + el( + PanelRow, + {}, + el( ratingResultPositionSelect ) + ) + ), + el( + PanelBody, + { + title: __( 'Structured Data', 'multi-rating' ), + initialOpen: false + }, + el( + PanelRow, + {}, + el( + 'div', + {}, + __( 'Supports rich snippets with aggregate ratings for the post in search engine results pages (SERP).', 'multi-rating' ) + ) + ), + el( + PanelRow, + {}, + el( structuredDataTypeSelect ) + ) + ) + ) + ) + ) + } + } ); + +} )( ) \ No newline at end of file diff --git a/includes/admin/about.php b/includes/admin/about.php index 0840949..2d28595 100644 --- a/includes/admin/about.php +++ b/includes/admin/about.php @@ -3,228 +3,243 @@ * Shows the about screen */ function mr_about_screen() { - - // if version is less than 3.8 then manually add the necessary css missing from about.css - if ( ! version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { - ?> - - - -
- + +
+
- <?php _e( 'Multi Rating', 'multi-rating-pro' ); ?> + <?php _e( 'Multi Rating', 'multi-rating-pro' ); ?>

- +

- + - - - -
- -

+ + + +
+ +
+ + +
+
+ +

+

adding new rating items.', 'multi-rating' ), Multi_Rating::RATING_ITEMS_PAGE_SLUG . '&rating-item-id=' ); ?>

+
+
+ +

+

automatic placement settings to display the rating form and or rating results on posts or pages (e.g. after the post content).', 'multi-rating' ), Multi_Rating::SETTINGS_PAGE_SLUG ); ?>

+
+
+ +

-
-
- -

-

adding new rating items.', 'multi-rating' ), Multi_Rating::RATING_ITEMS_PAGE_SLUG . '&rating-item-id=' ); ?>

-
-
- -

-

automatic placement settings to set the rating form and rating results to display on every post or page in default positions.', 'multi-rating' ), Multi_Rating::SETTINGS_PAGE_SLUG ); ?>

-
-
- -

-

-
-
- -
-
- -

-

.', 'multi-rating' ); ?>
-
-

-

documentation for more information on the attributes available.', 'multi-rating' ), 'http://multiratingpro.com/demo-page-free?utm_source=about&utm_medium=free-plugin&utm_campaign=wp-admin&utm_content=documentation"' ); ?>

-
-
- -

-

rating results and entries from the WP-admin.', 'multi-rating' ), Multi_Rating::RATING_RESULTS_PAGE_SLUG ); ?>

-
-
+

+ +

+ +
+
+ +
+ +
+ +
+ +

+

[mr_rating_form] - displays the rating form.', 'multi-rating' ), 'http://multiratingpro.com/demo-page-free#mr_rating_form?utm_source=about&utm_medium=free-plugin&utm_campaign=wp-admin&utm_content=documentation"' ); ?>
+ [mr_rating_result] - displays the rating result.', 'multi-rating' ), 'http://multiratingpro.com/demo-page-free#mr_rating_result?utm_source=about&utm_medium=free-plugin&utm_campaign=wp-admin&utm_content=documentation"' ); ?>
+ [mr_rating_results_list] - displays a list of rating results.', 'multi-rating' ), 'http://multiratingpro.com/demo-page-free#mr_rating_results_list?utm_source=about&utm_medium=free-plugin&utm_campaign=wp-admin&utm_content=documentation"' ); ?>

+ +

+

+ +

+

+ +

+

+
- -
-
-
-

-

- -

-

- -

-

- -

-

- -
-
- -

-

schema.org structured markup can be be added to every page which allows search engines to display the aggregated rating results as rich snippets.', 'multi-rating' ); ?>

- - -

-

- -

-

upload your own custom star images to use instead of the using icon fonts.', 'multi-rating' ); ?>

- -

-

- -

-

- -
-
- -

-

- - -

-

- -

-

- -

-

- -

-

GitHub. Contributions welcome.', 'multi-rating' ), 'https://github.com/danielpowney/multi-rating' ); ?>

- -
+ +
+

+

+ +

+

+ +

+

+ +

+

+ +

+

+
+ +
+ +

+

+ +

+

+ +

+

+

+

-
- -

WordPress.org support forum.', 'multi-rating' ), 'https://wordpress.org/support/plugin/multi-rating' ); ?>

-

contact form to send translation files or to contact me directly.', 'multi-rating' ), 'http://danielpowney.com/contact/' ); ?>

-

rate this plugin on WordPress.org.', 'multi-rating' ), 'http://wordpress.org/support/view/plugin-reviews/multi-rating?filter=5#postform' ); ?>

- - -

Multi Rating Pro version provides a significant additional feature set, including:', 'multi-rating' ), 'http://multiratingpro.com?utm_source=about&utm_medium=free-plugin&utm_campaign=wp-admin&utm_content=top' ); ?>

- -

-
    -
  1. -
  2. -
  3. -
  4. -
  5. -
  6. -
  7. -
  8. -
  9. -
  10. -
  11. -
  12. -
  13. -
  14. -
  15. -
  16. -
  17. -
- -

Check out Multi Rating Pro.

- + ' . __( 'No valid changelog was found.', 'my-chatbot' ) . '

'; + } else { + $readme = file_get_contents( $file ); + $readme = nl2br( esc_html( $readme ) ); + $readme = explode( '== Changelog ==', $readme ); + $readme = end( $readme ); + + $readme = preg_replace( '/`(.*?)`/', '\\1', $readme ); + $readme = preg_replace( '/[\040]\*\*(.*?)\*\*/', ' \\1', $readme ); + $readme = preg_replace( '/[\040]\*(.*?)\*/', ' \\1', $readme ); + $readme = preg_replace( '/= (.*?) =/', '

\\1

', $readme ); + $readme = preg_replace( '/\[(.*?)\]\((.*?)\)/', '\\1', $readme ); } -} \ No newline at end of file + + return $readme; +} + + +/** + * Render Contributors List + * + * @return string $contributor_list HTML formatted list of all the contributors for MYC + */ +function mr_contributors() { + $contributors = mr_get_contributors(); + + if ( empty( $contributors ) ) + return ''; + + $contributor_list = ''; + + return $contributor_list; +} + +/** + * Retreive list of contributors from GitHub. + + * @return array $contributors List of contributors + */ +function mr_get_contributors() { + $contributors = get_transient( 'mr_contributors' ); + + if ( false !== $contributors ) + return $contributors; + + $response = wp_remote_get( 'https://api.github.com/repos/danielpowney/multi-rating/contributors?per_page=999', array( 'sslverify' => false ) ); + + if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) + return array(); + + $contributors = json_decode( wp_remote_retrieve_body( $response ) ); + + if ( ! is_array( $contributors ) ) + return array(); + + set_transient( 'mr_contributors', $contributors, 3600 ); + + return $contributors; +} diff --git a/includes/admin/class-post-metabox.php b/includes/admin/class-post-metabox.php index 80e30d4..1b27b50 100644 --- a/includes/admin/class-post-metabox.php +++ b/includes/admin/class-post-metabox.php @@ -21,15 +21,12 @@ public function __construct() { */ public function add_meta_box( $post_type ) { - $general_settings = (array) get_option( Multi_Rating::GENERAL_SETTINGS ); - $post_types = $general_settings[Multi_Rating::POST_TYPES_OPTION]; - - if ( ! is_array( $post_types ) && is_string( $post_types ) ) { - $post_types = array( $post_types ); - } - if ( $post_types != null && in_array( $post_type, $post_types )) { - add_meta_box( 'mr_meta_box', __('Multi Rating', 'multi-rating'), array( $this, 'display_meta_box_content' ), $post_type, 'side', 'default'); + $current_screen = get_current_screen(); + if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() || method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) { + return; } + + add_meta_box( 'mr_meta_box', __('Multi Rating', 'multi-rating'), array( $this, 'display_meta_box_content' ), $post_type, 'side', 'default'); } /** @@ -38,6 +35,14 @@ public function add_meta_box( $post_type ) { * @param int $post_id The ID of the post being saved. */ public function save_post_meta( $post_id ) { + + if ( ! function_exists('get_current_screen')) { + return; + } + $current_screen = get_current_screen(); + if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() || method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) { + return; + } if ( ! isset( $_POST['meta_box_nonce_action'] ) ) return $post_id; @@ -61,10 +66,12 @@ public function save_post_meta( $post_id ) { $rating_form_position = $_POST['rating-form-position']; $rating_results_position = $_POST['rating-results-position']; + $structured_data_type = $_POST['mr-structured-data-type']; // Update the meta field. update_post_meta( $post_id, Multi_Rating::RATING_FORM_POSITION_POST_META, $rating_form_position ); update_post_meta( $post_id, Multi_Rating::RATING_RESULTS_POSITION_POST_META, $rating_results_position ); + update_post_meta( $post_id, Multi_Rating::STRUCTURED_DATA_TYPE_POST_META, $structured_data_type ); } @@ -79,20 +86,23 @@ public function display_meta_box_content( $post ) { $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 ); + $structured_data_type = get_post_meta( $post->ID, Multi_Rating::STRUCTURED_DATA_TYPE_POST_META, true ); ?> +

+

- +

+

- +

+

+
+

+

+

+ +

__( 'Rating Result', 'multi-rating' ), 'plural' => __( 'Rating Results', 'multi-rating' ), 'ajax' => false ) ); - + } /** @@ -40,73 +39,67 @@ function __construct() { * @see WP_List_Table::extra_tablenav() */ function extra_tablenav( $which ) { - + if ( $which == "top" ) { - + $post_id = ''; if ( isset( $_REQUEST['post-id'] ) ) { $post_id = $_REQUEST['post-id']; } - $username = ''; - if (isset( $_REQUEST['username'] ) ) { - $username = $_REQUEST['username']; - } - $to_date = ''; if (isset( $_REQUEST['to-date'] ) ) { $to_date = $_REQUEST['to-date']; } - + $from_date = ''; if (isset( $_REQUEST['from-date'] ) ) { $from_date = $_REQUEST['from-date']; } - + global $wpdb; ?> - +
- - + - +
'', MR_Rating_Entry_Table::RATING_ITEM_ENTRY_ID_COLUMN =>__( 'ID', 'multi-rating' ), MR_Rating_Entry_Table::POST_ID_COLUMN => __( 'Post', 'multi-rating' ), MR_Rating_Entry_Table::ENTRY_DATE_COLUMN =>__( 'Date', 'multi-rating' ), - MR_Rating_Entry_Table::IP_ADDRESS_COLUMN =>__( 'IP Address', 'multi-rating' ), MR_Rating_Entry_Table::USER_ID_COLUMN => __( 'User ID', 'multi-rating' ), - MR_Rating_Entry_Table::RATING_RESULT_COLUMN => __( 'Rating Details', 'multi-rating' ), - MR_Rating_Entry_Table::ACTION_COLUMN => __( 'Action', 'multi-rating' ) + MR_Rating_Entry_Table::RATING_RESULT_COLUMN => __( 'Rating Details', 'multi-rating' ) ); } @@ -132,30 +123,29 @@ function get_columns() { * @see WP_List_Table::prepare_items() */ function prepare_items() { - + global $wpdb; - + // Process any bulk actions first $this->process_bulk_action(); // Register the columns $columns = $this->get_columns(); - $hidden = array( MR_Rating_Entry_Table::USER_ID_COLUMN, MR_Rating_Entry_Table::IP_ADDRESS_COLUMN ); + $hidden = array( MR_Rating_Entry_Table::USER_ID_COLUMN ); $sortable = $this->get_sortable_columns(); $this->_column_headers = array( $columns, $hidden, $sortable ); - $username = isset( $_REQUEST['username'] ) ? $_REQUEST['username'] : null; $from_date = isset( $_REQUEST['from-date'] ) ? $_REQUEST['from-date'] : null; $to_date = isset( $_REQUEST['to-date'] ) ? $_REQUEST['to-date'] : null; $post_id = isset( $_REQUEST['post-id'] ) ? $_REQUEST['post-id'] : null; - + 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 )) { $from_date = null; } } - + 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 ) ) { @@ -167,61 +157,46 @@ function prepare_items() { $query = 'SELECT * FROM ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME . ' as rie'; $query_args = array(); $added_to_query = false; - if ( $post_id || $username || $from_date || $to_date ) { - - if ( $username ) { - $query .= ', ' . $wpdb->users . ' as u'; - } - + if ( $post_id || $from_date || $to_date ) { $query .= ' WHERE'; } - + if ( $post_id ) { if ( $added_to_query ) { $query .= ' AND'; } - + $query .= ' rie.post_id = %d'; array_push( $query_args, $post_id ); $added_to_query = true; } - - if ( $username ) { - if ( $added_to_query ) { - $query .= ' AND'; - } - - $query .= ' u.user_login = %s AND rie.user_id = u.ID'; - array_push( $query_args, $username ); - $added_to_query = true; - } - + if ( $from_date ) { if ( $added_to_query ) { $query .= ' AND'; } - + $query .= ' rie.entry_date >= %s'; array_push( $query_args, $from_date ); $added_to_query = true; } - + if ( $to_date ) { if ( $added_to_query ) { $query .= ' AND'; } - + $query .= ' rie.entry_date <= %s'; array_push( $query_args, $to_date ); $added_to_query = true; } - + $query .= ' ORDER BY rie.entry_date DESC'; - + if ( count( $query_args ) > 0 ) { $query = $wpdb->prepare( $query, $query_args ); } - + // pagination $item_count = $wpdb->query( $query ); //return the total number of affected rows $items_per_page = 10; @@ -236,152 +211,176 @@ function prepare_items() { $query .= ' LIMIT ' .(int) $offset. ',' . (int) $items_per_page; } $this->set_pagination_args( array( "total_items" => $item_count, "total_pages" => $total_pages, "per_page" => $items_per_page ) ); - + $this->items = $wpdb->get_results( $query, ARRAY_A ); - + } /** * Column default - * + * * @param $item * @param $column_name - * @return + * @return */ function column_default( $item, $column_name ) { - + switch( $column_name ) { - + case MR_Rating_Entry_Table::ENTRY_DATE_COLUMN : - echo date( 'F j, Y, g:i a', strtotime( $item[ $column_name ] ) ); + echo date( 'F j, Y, g:i A', strtotime( $item[ $column_name ] ) ); break; - + case MR_Rating_Entry_Table::CHECKBOX_COLUMN : return $item[ $column_name ]; break; - + case MR_Rating_Results_Table::POST_ID_COLUMN : { $post_id = $item[ MR_Rating_Entry_Table::POST_ID_COLUMN]; $temp_post_id = $post_id; - + // WPML get adjusted post id for active language, just for the string translation if ( function_exists( 'icl_object_id' ) ) { $temp_post_id = icl_object_id ( $post_id , get_post_type( $post_id ), true, ICL_LANGUAGE_CODE ); } - - $post_link = esc_html( get_the_title( $temp_post_id ) ); - if ( current_user_can( 'edit_post', $temp_post_id ) ) { - $post_link = ""; - $post_link .= esc_html( get_the_title( $temp_post_id ) ) . ''; - } - echo $post_link .' (Id=' . $post_id . ')'; + + ?> + +
+ | + + + +
+ ' . round( $rating_result['adjusted_star_result'], 2 ) . '/5
' - . __( 'Score: ', 'multi-rating' ) . '' . round( $rating_result['adjusted_score_result'], 2) . '/' . $rating_result['total_max_option_value'] . '
' - . __( 'Percentage: ', 'multi-rating' ) . '' . round( $rating_result['adjusted_percentage_result'], 2) . '%'; - break; - - case MR_Rating_Entry_Table::ACTION_COLUMN : - + + + echo ''; + + $icon_classes = MR_Utils::get_icon_classes( 'dashicons' ); // dashicons for admin + + ob_start(); + mr_get_template_part( 'rating-result', 'star-rating', true, array( + 'icon_classes' => $icon_classes, + 'max_stars' => 5, + 'star_result' => $rating_result['adjusted_star_result'] + ) ); + $overall_rating = ob_get_contents(); + ob_end_clean(); + + printf( __( 'Overall Rating: %s', 'multi-rating'), $overall_rating ); + echo ''; + // do not need to pass post id and rating form id - $url = '?page=mr_edit_rating&entry-id=' . $item[ MR_Rating_Entry_Table::RATING_ITEM_ENTRY_ID_COLUMN ]; + $edit_rating_url = '?page=mr_edit_rating&entry-id=' . $item[ MR_Rating_Entry_Table::RATING_ITEM_ENTRY_ID_COLUMN ]; if ( isset( $_REQUEST['post-id'] ) ) { - $url .= '&post-id=' . $_REQUEST['post-id']; - } - if ( isset( $_REQUEST['username'] ) ) { - $url .= '&username=' . $_REQUEST['username']; + $edit_rating_url .= '&post-id=' . $_REQUEST['post-id']; } if ( isset( $_REQUEST['to-date'] ) ) { - $url .= '&to-date=' . $_REQUEST['to-date']; + $edit_rating_url .= '&to-date=' . $_REQUEST['to-date']; } if ( isset( $_REQUEST['from-date'] ) ) { - $url .= '&from-date=' . $_REQUEST['from-date']; + $edit_rating_url .= '&from-date=' . $_REQUEST['from-date']; } if ( isset( $_REQUEST['paged'] ) ) { - $url .= '&paged=' . $_REQUEST['paged']; - } ?> - - - + $edit_rating_url .= '&paged=' . $_REQUEST['paged']; + } + + ?> +
+ + + + + +
', $item[ MR_Rating_Entry_Table::RATING_ITEM_ENTRY_ID_COLUMN ] ); - + } - + /** * (non-PHPdoc) * @see WP_List_Table::get_bulk_actions() */ function get_bulk_actions() { - - $bulk_actions = array(); - + + $bulk_actions = array(); + if ( current_user_can( 'manage_options' ) ) { $bulk_actions = array_merge( array( 'delete' => __( 'Delete', 'multi-rating' ) ), $bulk_actions); } - + return $bulk_actions; - + } /** * Handles bulk actions */ function process_bulk_action() { - + if ( ! current_user_can( 'manage_options' ) ) { return; // should not get here } - + if ( $this->current_action() === 'delete') { - + global $wpdb; - + $checked = ( is_array( $_REQUEST[ 'delete' ] ) ) ? $_REQUEST[ 'delete' ] : array( $_REQUEST[ 'delete' ] ); - + foreach( $checked as $rating_entry_id ) { - - $query = 'SELECT post_id FROM ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME . ' WHERE ' + + $query = 'SELECT post_id FROM ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME . ' WHERE ' . MR_Rating_Entry_Table::RATING_ITEM_ENTRY_ID_COLUMN . ' = %d'; $row = $wpdb->get_row( $wpdb->prepare( $query, $rating_entry_id ) ); - + // rating results cache will be refreshed next time it's needed delete_post_meta( $row->post_id, Multi_Rating::RATING_RESULTS_POST_META_KEY ); delete_post_meta( $row->post_id, Multi_Rating::RATING_RESULTS_POST_META_KEY . '_star_rating' ); delete_post_meta( $row->post_id, Multi_Rating::RATING_RESULTS_POST_META_KEY . '_count_entries' ); - + $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' ) ); } - + echo '

' . __( 'Entries deleted successfully', 'multi-rating' ) . '

'; } } - -} \ No newline at end of file + +} diff --git a/includes/admin/class-rating-item-table.php b/includes/admin/class-rating-item-table.php index 9a0f9ce..99013f2 100644 --- a/includes/admin/class-rating-item-table.php +++ b/includes/admin/class-rating-item-table.php @@ -21,12 +21,12 @@ class MR_Rating_Item_Table extends WP_List_Table { WEIGHT_COLUMN = 'weight', TYPE_COLUMN = 'type', DELETE_CHECKBOX = 'delete[]'; - + /** * Constructor */ function __construct() { - + parent::__construct( array( 'singular' => __( 'Rating Item', 'multi-rating' ), 'plural' => __( 'Rating Items', 'multi-rating' ), @@ -39,11 +39,11 @@ function __construct() { * @see WP_List_Table::extra_tablenav() */ function extra_tablenav( $which ) { - + if ( $which == "top" ){ echo ""; } - + if ( $which == "bottom" ){ echo ""; } @@ -54,7 +54,7 @@ function extra_tablenav( $which ) { * @see WP_List_Table::get_columns() */ function get_columns() { - + return array( MR_Rating_Item_Table::CHECKBOX_COLUMN => '', MR_Rating_Item_Table::DESCRIPTION_COLUMN =>__( 'Label' , 'multi-rating' ), @@ -73,20 +73,20 @@ function get_columns() { * @see WP_List_Table::prepare_items() */ function prepare_items() { - + global $wpdb; - + // Process any bulk actions first $this->process_bulk_action(); // Register the columns $columns = $this->get_columns(); - $hidden = array( MR_Rating_Item_Table::RATING_ID_COLUMN ); + $hidden = array( MR_Rating_Item_Table::RATING_ID_COLUMN, MR_Rating_Item_Table::RATING_ITEM_ID_COLUMN ); $sortable = $this->get_sortable_columns(); $this->_column_headers = array( $columns, $hidden, $sortable ); $query = 'SELECT * FROM ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_TBL_NAME; - + $this->items = $wpdb->get_results( $query, ARRAY_A ); } @@ -97,7 +97,7 @@ function prepare_items() { * @return unknown|mixed */ function column_default( $item, $column_name ) { - + switch( $column_name ) { case MR_Rating_Item_Table::CHECKBOX_COLUMN : case MR_Rating_Item_Table::RATING_ITEM_ID_COLUMN : @@ -105,25 +105,25 @@ function column_default( $item, $column_name ) { case MR_Rating_Item_Table::TYPE_COLUMN: return $item[ $column_name ]; break; - + case MR_Rating_Item_Table::WEIGHT_COLUMN: case MR_Rating_Item_Table::DESCRIPTION_COLUMN : case MR_Rating_Item_Table::DEFAULT_OPTION_VALUE_COLUMN: case MR_Rating_Item_Table::MAX_OPTION_VALUE_COLUMN: $this->column_actions( $item, $column_name ); break; - + case MR_Rating_Item_Table::FIELD_REQUIRED_COLUMN: $this->column_checkbox( $item, $column_name ); break; - + default: return print_r( $item, true ) ; } } - + function column_type( $item ) { - + $column_name = MR_Rating_Item_Table::TYPE_COLUMN; $row_id = $item[MR_Rating_Item_Table::RATING_ITEM_ID_COLUMN]; $row_value = stripslashes( $item[$column_name] ); @@ -131,32 +131,32 @@ function column_type( $item ) { $save_btn_id = 'save-'.$column_name.'-'.$row_id; $view_section_id = 'view-section-'. $column_name . '-'. $row_id; $edit_section_id = 'edit-section-'. $column_name . '-'. $row_id; - + // if column is type, use a select $field_id = 'field-'. $column_name . '-'. $row_id; $text_id = 'text-'. $column_name . '-'. $row_id; - + $type_options = array( 'select' => __( 'Select', 'multi-rating' ), 'radio' => __( 'Radio', 'multi-rating' ), 'star_rating' => __( 'Stars', 'multi-rating' ) ); - + $text_value = isset( $type_options[$row_value] ) ? $type_options[$row_value] : $row_value; - - echo ''; + + echo ''; echo ''; + + echo '
'; } - + /** * checkbox column * @param unknown_type $item @@ -169,72 +169,89 @@ function column_cb( $item ) { } function column_actions( $item, $column_name ) { - + $row_id = $item[MR_Rating_Item_Table::RATING_ITEM_ID_COLUMN]; - + $row_value = stripslashes( $item[$column_name] ); - + // WPML translate string - if ( $column_name == MR_Rating_Item_Table::DESCRIPTION_COLUMN + if ( $column_name == MR_Rating_Item_Table::DESCRIPTION_COLUMN && function_exists( 'icl_translate' ) && strlen( $row_value ) > 0 ) { $row_value = icl_translate( 'multi-rating', 'rating-item-' . $row_id . '-description', $row_value ); } - + $edit_btn_id = 'edit-'.$column_name.'-'.$row_id; $save_btn_id = 'save-'.$column_name.'-'.$row_id; $view_section_id = 'view-section-'. $column_name . '-'. $row_id; $edit_section_id = 'edit-section-'. $column_name . '-'. $row_id; - + // if column is type, use a select $field_id = 'field-'. $column_name . '-'. $row_id; $text_id = 'text-'. $column_name . '-'. $row_id; - - echo ''; + + $text = $row_value; + $class = 'small-text'; + if ( $column_name == MR_Rating_Item_Table::DESCRIPTION_COLUMN ) { + $text = '' . $text . ''; + $class = ''; + } + + echo '
'; + echo '
' . $text . '
'; + echo '
'; + if ( $column_name == MR_Rating_Item_Table::DESCRIPTION_COLUMN ) { + echo '' . printf( __( 'ID: %d', 'multi-rating' ), $row_id ) . ' | '; + } + echo '' . __( 'Edit', 'multi-rating' ) . ''; + echo '
'; + echo '
'; + echo ''; + echo ''; + echo ''; + echo '
'; } - + /** * Checkbox column * @param $item * @param $column_name */ function column_checkbox( $item, $column_name ) { - + $row_id = $item[MR_Rating_Item_Table::RATING_ITEM_ID_COLUMN]; $row_value = stripslashes( $item[$column_name] ); $edit_btn_id = 'edit-' . $column_name . '-' . $row_id; $save_btn_id = 'save-' . $column_name . '-' . $row_id; $view_section_id = 'view-section-' . $column_name . '-' . $row_id; $edit_section_id = 'edit-section-' . $column_name . '-' . $row_id; - + // if column is type, use a select $field_id = 'field-' . $column_name . '-' . $row_id; $text_id = 'text-' . $column_name . '-'. $row_id; - - echo '
' . ($row_value == true ? __( 'Yes', 'multi-rating' ) : __( 'No', 'multi-rating' ) ) . '
'; + + echo '
' . ($row_value == true ? __( 'Yes', 'multi-rating' ) : __( 'No', 'multi-rating' ) ) . '
'; echo ''; + + echo '
'; } - + /** * (non-PHPdoc) * @see WP_List_Table::get_bulk_actions() */ function get_bulk_actions() { - + $bulk_actions = array( 'delete' => __( 'Delete', 'multi-rating' ) ); - + return $bulk_actions; } @@ -242,79 +259,79 @@ function get_bulk_actions() { * Handles bulk actions */ function process_bulk_action() { - + if ( $this->current_action() ==='delete' ) { - + global $wpdb; - + $checked = ( is_array( $_REQUEST['delete'] ) ) ? $_REQUEST['delete'] : array( $_REQUEST['delete'] ); - + foreach( $checked as $rating_item_id ) { // TODO set active column to 0 instead of deleting row $wpdb->delete( $wpdb->prefix . Multi_Rating::RATING_ITEM_TBL_NAME, array( 'rating_item_id' => $rating_item_id ), array( '%d' ) ); } - + echo '

' . __( 'Delete rating items bulk action processed successfully', 'multi-rating' ) . '

'; } } - + /** * Saves column edit in rating item table - * + * * @since 1.0 */ public static function save_rating_item_table_column() { - + global $wpdb; - + $ajax_nonce = $_POST['nonce']; if ( wp_verify_nonce( $ajax_nonce, Multi_Rating::ID.'-nonce' ) ) { - + $column = $_POST['column']; - + // prevent SQL injection if (! ( $column == MR_Rating_Item_Table::DESCRIPTION_COLUMN || $column == MR_Rating_Item_Table::MAX_OPTION_VALUE_COLUMN - || $column == MR_Rating_Item_Table::DEFAULT_OPTION_VALUE_COLUMN || $column == MR_Rating_Item_Table::WEIGHT_COLUMN + || $column == MR_Rating_Item_Table::DEFAULT_OPTION_VALUE_COLUMN || $column == MR_Rating_Item_Table::WEIGHT_COLUMN || $column == MR_Rating_Item_Table::FIELD_REQUIRED_COLUMN || $column == MR_Rating_Item_Table::TYPE_COLUMN ) ) { - + echo __( 'An error occured', 'multi-rating' ); - + die(); } - + // validate each column - $error_message = ''; - + $error_message = ''; + $value = isset( $_POST['value'] ) ? addslashes( $_POST['value'] ) : ''; $rating_item_id = isset( $_POST['ratingItemId'] ) ? $_POST['ratingItemId'] : ''; - + if ( $column == MR_Rating_Item_Table::FIELD_REQUIRED_COLUMN ) { $value = false; if ( isset($_POST['value'] ) && $_POST['value'] == 'true' ) { $value = true; } } - + // get current values for validation $query = 'SELECT * FROM ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_TBL_NAME . ' WHERE rating_item_id = %d'; $row = $wpdb->get_row( $wpdb->prepare( $query, $rating_item_id ), ARRAY_A, 0 ); - + $max_option_value = intval($row['max_option_value']); $default_option_value = intval($row['default_option_value']); - + $data_format = array( '%d' ); - + if ( $column == MR_Rating_Item_Table::DESCRIPTION_COLUMN ) { if ( strlen( trim( $value ) ) == 0 ) { $error_message .= __( 'Description cannot be empty. ', 'multi-rating' ); } $data_format = array( '%s' ); - + } else if ( $column == MR_Rating_Item_Table::MAX_OPTION_VALUE_COLUMN ) { if ( is_numeric( $value ) == false) { $error_message .= __( 'Max option value cannot be empty and must be a whole number. ', 'multi-rating' ); } - + if ( $default_option_value > intval( $value ) ) { $error_message .= __( 'Default option value cannot be greater than the max option value. ', 'multi-rating' ); } @@ -322,7 +339,7 @@ public static function save_rating_item_table_column() { if ( is_numeric( $value ) == false ) { $error_message .= __( 'Default option value cannot be empty and must be a whole number. ', 'multi-rating' ); } - + if ( intval( $value ) > $max_option_value ) { $error_message .= __( 'Default option value cannot be greater than the max option value. ', 'multi-rating' ); } @@ -334,14 +351,14 @@ public static function save_rating_item_table_column() { } else if ( $column == MR_Rating_Item_Table::TYPE_COLUMN ) { $data_format = array( '%s' ); } - + if ( strlen( $error_message ) == 0 ) { $wpdb->update( $wpdb->prefix . Multi_Rating::RATING_ITEM_TBL_NAME, array( $column => $value ), array( 'rating_item_id' => $rating_item_id ), $data_format, array( '%d' ) ); - + if ( $result === FALSE ) { $error_message = __( 'An error occured.', 'multi-rating' ); } - + // WPML update string if ( function_exists( 'icl_register_string' ) && $column == MR_Rating_Item_Table::DESCRIPTION_COLUMN ) { icl_register_string( 'multi-rating', 'rating-item-' . $rating_item_id . '-description', $value ); @@ -354,10 +371,10 @@ public static function save_rating_item_table_column() { } else if ( $column == MR_Rating_Item_Table::FIELD_REQUIRED_COLUMN ) { $value = ( $value == true ) ? __( 'Yes', 'multi-rating' ) : __( 'No', 'multi-rating' ); } - + echo json_encode( array ('value' => $value, 'error_message' => $error_message ) ); } - + die(); } -} \ No newline at end of file +} diff --git a/includes/admin/class-rating-results-table.php b/includes/admin/class-rating-results-table.php index 5773c42..4f583ed 100644 --- a/includes/admin/class-rating-results-table.php +++ b/includes/admin/class-rating-results-table.php @@ -5,7 +5,7 @@ /** * MR_Rating_Results_Table class - * + * * @author dpowney * */ @@ -25,7 +25,7 @@ class MR_Rating_Results_Table extends WP_List_Table { * Constructor */ function __construct() { - + parent::__construct( array( 'singular'=> __( 'Rating Results', 'multi-rating' ), 'plural' => __( 'Rating Results', 'multi-rating' ), @@ -38,50 +38,50 @@ function __construct() { * @see WP_List_Table::extra_tablenav() */ function extra_tablenav( $which ) { - + if ( $which == "top" ){ - + $post_id = ''; if ( isset( $_REQUEST['post-id'] ) ) { $post_id = $_REQUEST['post-id']; } - + $sort_by = ''; if ( isset( $_REQUEST['sort-by'] ) ) { $sort_by = $_REQUEST['sort-by']; } - + global $wpdb; ?> - -
+ +
- + - +
- + __( 'Post', 'multi-rating' ), MR_Rating_Results_Table::RATING_RESULT_COLUMN => __( 'Overall Rating', 'multi-rating' ), - MR_Rating_Results_Table::ENTRIES_COUNT_COLUMN => __( 'Entries', 'multi-rating' ), - MR_Rating_Results_Table::ACTION_COLUMN => __( 'Action', 'multi-rating' ), MR_Rating_Results_Table::SHORTCODE_COLUMN => __( 'Shortcode', 'multi-rating' ) ); - + if ( current_user_can( 'manage_options' ) ) { $columns = array_merge( array( MR_Rating_Results_Table::CHECKBOX_COLUMN => '' ), $columns ); } - + return $columns; } @@ -129,69 +127,69 @@ function get_columns() { */ function prepare_items() { global $wpdb; - + // Process any bulk actions first if ( current_user_can( 'manage_options' ) ) { $this->process_bulk_action(); } - + // Register the columns $columns = $this->get_columns(); $hidden = array( ); $sortable = $this->get_sortable_columns(); $this->_column_headers = array($columns, $hidden, $sortable); - + $post_id = isset( $_REQUEST['post-id'] ) ? $_REQUEST['post-id'] : null; $sort_by = isset( $_REQUEST['sort-by'] ) ? $_REQUEST['sort-by'] : null; - + // get table data $query = 'SELECT rie.post_id AS post_id'; if ( $sort_by == 'post_title_asc' || $sort_by == 'post_title_desc' ) { $query .= ', p.post_title AS post_title'; } - + $query .= ' FROM ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME . ' as rie'; if ( $sort_by == 'post_title_asc' || $sort_by == 'post_title_desc' ) { $query .= ', ' . $wpdb->posts . ' as p'; } - + $query_args = array(); $added_to_query = false; if ( $post_id || $sort_by == 'post_title_asc' || $sort_by == 'post_title_desc' ) { $query .= ' WHERE'; } - + if ( $post_id ) { if ($added_to_query) { $query .= ' AND'; } - + $query .= ' rie.post_id = %d'; array_push( $query_args, $post_id ); $added_to_query = true; } - + if ( $sort_by == 'post_title_asc' || $sort_by == 'post_title_desc' ) { if ($added_to_query) { $query .= ' AND'; } - + $query .= ' rie.post_id = p.ID'; $added_to_query = true; } - + $query .= ' GROUP BY rie.post_id'; - + if ( $sort_by == 'post_title_asc' ) { $query .= ' ORDER BY post_title ASC'; } else if ( $sort_by == 'post_title_desc' ) { $query .= ' ORDER BY post_title DESC'; } - + if ( count( $query_args ) > 0 ) { $query = $wpdb->prepare( $query, $query_args ); } - + // pagination $item_count = $wpdb->query( $query ); //return the total number of affected rows $items_per_page = 10; @@ -205,22 +203,22 @@ function prepare_items() { $offset = ( $page_num -1 ) * $items_per_page; $query .= ' LIMIT ' . ( int ) $offset. ',' . ( int ) $items_per_page; } - - $this->set_pagination_args( array( + + $this->set_pagination_args( array( 'total_items' => $item_count, 'total_pages' => $total_pages, 'per_page' => $items_per_page ) ); - + $results = $wpdb->get_results( $query, ARRAY_A ); - + if ( $sort_by == 'top_rating_results' ) { - + $this->items = array(); foreach ( $results as $row ) { $post_id = $row['post_id']; - + $rating_items = Multi_Rating_API::get_rating_items( array( 'post_id' => $post_id ) ); @@ -228,35 +226,35 @@ function prepare_items() { 'post_id' => $post_id, 'rating_items' => $rating_items ) ); - + $row['rating_result'] = $rating_result; - + array_push( $this->items, $row ); } - + uasort( $this->items, array( 'MR_Rating_Results_Table' , 'sort_top_rating_results' ) ); } else if ( $sort_by == 'most_entries' ) { - + $this->items = array(); - + foreach ( $results as $row ) { $post_id = $row['post_id']; - + global $wpdb; $query = 'SELECT COUNT(*) FROM ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME . ' WHERE post_id = %d'; $count = $wpdb->get_col( $wpdb->prepare( $query, $post_id ), 0 ); - + $row['entries_count'] = $count[0]; - + array_push( $this->items, $row); } - + uasort( $this->items, array( 'MR_Rating_Results_Table' , 'sort_most_entries' ) ); } else { $this->items = $results; } } - + /** * Helper to sort by top rating results * @@ -264,17 +262,17 @@ function prepare_items() { * @param unknown_type $b */ private static function sort_top_rating_results( $a, $b ) { - + $rating_result_a = $a['rating_result']; $rating_result_b = $b['rating_result']; - + if ( $rating_result_a['adjusted_percentage_result'] == $rating_result_b['adjusted_percentage_result'] ) { return 0; } - + return ( $rating_result_a['adjusted_percentage_result'] > $rating_result_b['adjusted_percentage_result'] ) ? -1 : 1; } - + /** * Helper to sort by most entries * @@ -282,11 +280,11 @@ private static function sort_top_rating_results( $a, $b ) { * @param unknown_type $b */ private static function sort_most_entries( $a, $b ) { - + if ( $a['entries_count'] == $b['entries_count'] ) { return 0; } - + return ( $a['entries_count'] > $b['entries_count'] ) ? -1 : 1; } @@ -297,73 +295,73 @@ private static function sort_most_entries( $a, $b ) { * @return unknown|mixed */ function column_default( $item, $column_name ) { - + $post_id = $item[MR_Rating_Results_Table::POST_ID_COLUMN]; - + switch( $column_name ) { case MR_Rating_Results_Table::SHORTCODE_COLUMN : { - + echo '[mr_rating_result post_id="' . $post_id . '"]'; break; } - + case MR_Rating_Results_Table::POST_ID_COLUMN : { $temp_post_id = $post_id; - + // WPML get adjusted post id for active language, just for the string translation if ( function_exists( 'icl_object_id' ) ) { $temp_post_id = icl_object_id ( $post_id , get_post_type( $post_id ), true, ICL_LANGUAGE_CODE ); - } - - $post_link = esc_html( get_the_title( $temp_post_id ) ); - if ( current_user_can( 'edit_post', $temp_post_id ) ) { - $post_link = ""; - $post_link .= esc_html( get_the_title( $temp_post_id ) ) . ''; } - echo $post_link .' (Id=' . $post_id . ')'; - break; - } - - case MR_Rating_Results_Table::ACTION_COLUMN : { - ?> - + +
+ | + + + +
prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME . ' WHERE post_id = %d'; - $rows = $wpdb->get_col( $wpdb->prepare( $query, $post_id ), 0 ); - - echo $rows[0]; - - break; - } - + case MR_Rating_Results_Table::RATING_RESULT_COLUMN : { - - $rating_items = Multi_Rating_API::get_rating_items( array( + + $rating_items = Multi_Rating_API::get_rating_items( array( 'post_id' => $post_id ) ); $rating_result = Multi_Rating_API::calculate_rating_result( array( 'post_id' => $post_id, 'rating_items' => $rating_items ) ); - - $entries = $rating_result['count']; - if ($entries != 0) { - echo __( 'Star: ', 'multi-rating' ) . '' . round( $rating_result['adjusted_star_result'], 2 ) . '/5
' - . __( 'Score: ', 'multi-rating' ) . '' . round( $rating_result['adjusted_score_result'], 2) . '/' . $rating_result['total_max_option_value'] . '
' - . __( 'Percentage: ', 'multi-rating' ) . '' . round( $rating_result['adjusted_percentage_result'], 2) . '%'; + + if ( $rating_result['count'] > 0 ) { + $icon_classes = MR_Utils::get_icon_classes( 'dashicons' ); // dashicons for admin + + mr_get_template_part( 'rating-result', 'star-rating', true, array( + 'icon_classes' => $icon_classes, + 'max_stars' => 5, + 'star_result' => $rating_result['adjusted_star_result'] + ) ); + + echo ' (' . $rating_result['count'] . ')'; + } else { - _e( 'None', 'multi-rating' ); + _e( 'None', 'multi-rating' ); } + + ?> +
+ +
+ + ', $item[MR_Rating_Results_Table::POST_ID_COLUMN] ); } - + /** * (non-PHPdoc) * @see WP_List_Table::get_bulk_actions() */ function get_bulk_actions() { - + $bulk_actions = array(); - + if ( current_user_can( 'manage_options' ) ) { $bulk_actions = array( 'delete' => __( 'Delete', 'multi-rating' ) ); } - + return $bulk_actions; } - + /** * Handles bulk actions */ function process_bulk_action() { - + if ( ! current_user_can( 'manage_options' ) ) { return; // should not get here } - + if ( $this->current_action() ==='delete' ) { global $wpdb; - + $checked = ( is_array( $_REQUEST['delete'] ) ) ? $_REQUEST['delete'] : array( $_REQUEST['delete'] ); - + foreach( $checked as $post_id ) { - + /* * delete rating item entry values as well - */ - $entries = Multi_Rating_API::get_rating_item_entries( array( + */ + $entries = Multi_Rating_API::get_rating_item_entries( array( 'post_id' => $post_id ) ); - + foreach ( $entries as $entry ) { $rating_entry_id = $entry['rating_item_entry_id']; - + $wpdb->delete( $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_VALUE_TBL_NAME, array( 'rating_item_entry_id' => $rating_entry_id ), array( '%d' ) ); $wpdb->delete( $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME, array( 'rating_item_entry_id' => $rating_entry_id ), array( '%d' ) ); } - - /* + + /* * delete rating results cache in WordPress postmeta table */ delete_post_meta( $post_id, Multi_Rating::RATING_RESULTS_POST_META_KEY ); delete_post_meta( $post_id, Multi_Rating::RATING_RESULTS_POST_META_KEY . '_star_rating' ); delete_post_meta( $post_id, Multi_Rating::RATING_RESULTS_POST_META_KEY . '_count_entries' ); } - + echo '

' . __( 'Rating results deleted successfully.', 'multi-rating' ) . '

'; } } -} \ No newline at end of file +} diff --git a/includes/admin/edit-rating.php b/includes/admin/edit-rating.php index 3f4dff3..579c7d6 100644 --- a/includes/admin/edit-rating.php +++ b/includes/admin/edit-rating.php @@ -1,4 +1,4 @@ -
-

- -

' . __( 'An error has occured.', 'multi-rating' ) . '

'; + return; + } + // get the entry id $rating_entry_id = null; if ( isset( $_GET['entry-id'] ) ) { @@ -16,61 +20,65 @@ function mr_edit_rating_screen() { } else if ( isset ( $_POST['entry-id'] ) ) { $rating_entry_id = $_POST['entry-id']; } - + if ( $rating_entry_id == null ) { - echo '

' . __( 'Invalid rating entry id', 'multi-rating' ) . '

'; + echo '

' . __( 'An error has occured', 'multi-rating' ) . '

'; echo '
'; return; } - + + ?> +

+ $rating_entry_id ) ); - + global $wpdb; - + // get the rating entry values $rating_entry_values = array(); if ( $rating_entry_id != null ) { - $query = 'SELECT riev.value AS value, riev.rating_item_entry_id AS rating_item_entry_id, riev.rating_item_id AS rating_item_id FROM ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_VALUE_TBL_NAME . ' AS riev WHERE riev.rating_item_entry_id = %d'; + $query = 'SELECT riev.value AS value, riev.rating_item_entry_id AS rating_item_entry_id, riev.rating_item_id AS rating_item_id FROM ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_VALUE_TBL_NAME . ' AS riev WHERE riev.rating_item_entry_id = %d'; $rating_entry_values = $wpdb->get_results( $wpdb->prepare( $query, $rating_entry_id ) ); } - + if ( count( $rating_entry_values ) == 0 ) { - echo '

' . sprintf( __( 'No rating exists for rating entry id %d', 'multi-rating' ), $rating_entry_id ) . '

'; + echo '

' . sprintf( __( 'An error has occured', 'multi-rating' ), $rating_entry_id ) . '

'; } else { - + $selected_option_lookup = array(); foreach ( $rating_entry_values as $entry_value ) { $selected_option_lookup[$entry_value->rating_item_id] = $entry_value->value; } - + ?> - +
- + - 0 ) { $description = icl_translate( 'multi-rating', 'rating-item-' . $rating_item_id . '-description', $description ); } - + ?> - +
- '; - - $index = 0; + + $index = 0; for ( $index; $index <= $rating_item['max_option_value']; $index++ ) { $is_selected = false; if ( $selected_option_lookup[$rating_item_id] == $index ) { @@ -83,22 +91,22 @@ function mr_edit_rating_screen() { } echo '>' . $index . ''; } - + echo ''; ?>
- + -
-
+
$rating_entry_id ) ); @@ -130,32 +138,32 @@ function mr_edit_rating() { echo '

' . __( 'An error occured', 'multi-rating' ) . '

'; return; } - + foreach ( $rating_items as $rating_item ) { $rating_item_id = $rating_item['rating_item_id']; $rating_item_value = isset( $_POST['rating-item-' . $rating_item_id] ) ? $_POST['rating-item-' . $rating_item_id] : null; - + if ( $rating_item_value != null ) { - + $query = 'SELECT COUNT(*) FROM ' . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_VALUE_TBL_NAME . ' WHERE rating_item_entry_id = %d AND rating_item_id = %d'; $rows = $wpdb->get_col( $wpdb->prepare( $query, $rating_entry_id, $rating_item_id ) ); if ( $rows[0] == 0) { - + $wpdb->insert( $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_VALUE_TBL_NAME, array( 'rating_item_entry_id' => $rating_entry_id, 'rating_item_id' => $rating_item_id, 'value' => $rating_item_value ), array('%d', '%d', '%d') ); - + } else { - $wpdb->update( $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_VALUE_TBL_NAME, - array( 'value' => $rating_item_value ), + $wpdb->update( $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_VALUE_TBL_NAME, + array( 'value' => $rating_item_value ), array( 'rating_item_entry_id' => $rating_entry_id, 'rating_item_id' => $rating_item_id ), array( '%d' ), array( '%d', '%d' ) ); - + } } } @@ -163,14 +171,14 @@ function mr_edit_rating() { $general_settings = (array) get_option( Multi_Rating::GENERAL_SETTINGS ); $rating_results_cache = $general_settings[Multi_Rating::RATING_RESULTS_CACHE_OPTION]; if ($rating_results_cache == true) { - + // delete rating results cache delete_post_meta( $post_id, Multi_Rating::RATING_RESULTS_POST_META_KEY ); delete_post_meta( $post_id, Multi_Rating::RATING_RESULTS_POST_META_KEY . '_star_rating' ); delete_post_meta( $post_id, Multi_Rating::RATING_RESULTS_POST_META_KEY . '_count_entries' ); - + } - + // redirect back to entries page $entries_page = 'admin.php?page=' . Multi_Rating::RATING_ENTRIES_PAGE_SLUG; @@ -200,4 +208,4 @@ function mr_edit_rating() { add_action( 'admin_init', 'mr_edit_rating' ); } -?> \ No newline at end of file +?> diff --git a/includes/admin/rating-entries.php b/includes/admin/rating-entries.php index 43eb949..99d5841 100644 --- a/includes/admin/rating-entries.php +++ b/includes/admin/rating-entries.php @@ -1,4 +1,4 @@ -
-

+

- prepare_items(); $rating_entry_table->views(); @@ -20,4 +20,4 @@ function mr_rating_entries_screen() {

- +
@@ -38,7 +38,7 @@ function mr_rating_items_screen() { @@ -58,16 +58,16 @@ function mr_rating_items_screen() { ?>

- prepare_items(); $rating_item_table->display(); ?> - - + - $max_option_value ) { array_push( $error_messages, __( 'Default option cannot be greater than max option.', 'multi-rating' ) ); } else { - - $results = $wpdb->insert( $wpdb->prefix.Multi_Rating::RATING_ITEM_TBL_NAME, + + $results = $wpdb->insert( $wpdb->prefix.Multi_Rating::RATING_ITEM_TBL_NAME, array( 'description' => $description, 'max_option_value' => $max_option_value, 'default_option_value' => $default_option_value, 'weight' => $weight, 'type' => $type ), array( '%s', '%d', '%d', '%f', '%s' ) ); - + $rating_item_id = intval( $wpdb->insert_id ); - + // WPML register string if ( function_exists( 'icl_register_string' ) ) { icl_register_string( 'multi-rating', 'rating-item-' . $rating_item_id . '-description', $description); - } + } } - + } } else { array_push( $error_messages, __( 'An error occured. Rating item could not be added.', 'multi-rating' ) ); @@ -132,19 +132,19 @@ function mr_save_rating_item() { if ( count( $error_messages ) > 0) { echo '
'; - + foreach ( $error_messages as $error_message ) { echo '

' . $error_message . '

'; } echo '
'; - + return; } - + wp_redirect( 'admin.php?page=' . Multi_Rating::RATING_ITEMS_PAGE_SLUG ); exit(); } if ( isset( $_POST['add-rating-item-form-submitted'] ) && $_POST['add-rating-item-form-submitted'] == 'true' ) { add_action( 'admin_init', 'mr_save_rating_item' ); } -?> \ No newline at end of file +?> diff --git a/includes/admin/reports.php b/includes/admin/reports.php index 657e393..b2f4b21 100644 --- a/includes/admin/reports.php +++ b/includes/admin/reports.php @@ -1,4 +1,4 @@ -
- - - - -

- -
- - -

- - - - - - - -

- - - 0 ) { - list( $year, $month, $day ) = explode( '-', $from_date ); // default yyyy-mm-dd format - if ( ! checkdate( $month , $day , $year )) { - $from_date = null; - } - } - - 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 )) { - $to_date = null; - } - } - - $query = 'SELECT DISTINCT DATE(entry_date) AS day, count(*) as count FROM ' - . $wpdb->prefix . Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME . ' as rie'; - $query_args = array(); - - $added_to_query = false; - if ( $post_id || $from_date || $to_date ) { - $query .= ' WHERE'; - } - - if ( $post_id ) { - if ( $added_to_query ) { - $query .= ' AND'; - } - - $query .= ' rie.post_id = %d'; - array_push( $query_args, $post_id ); - $added_to_query = true; - } - - if ( $from_date ) { - if ( $added_to_query ) { - $query .= ' AND'; - } - - $query .= ' rie.entry_date >= %s'; - array_push( $query_args, $from_date ); - $added_to_query = true; - } - - if ( $to_date ) { - if ( $added_to_query ) { - $query .= ' AND'; - } - - $query .= ' rie.entry_date <= %s'; - array_push( $query_args, $to_date ); - $added_to_query = true; - } - - $query .= ' GROUP BY day ORDER BY rie.entry_date DESC'; - - if ( count( $query_args ) > 0 ) { - $query = $wpdb->prepare( $query, $query_args ); - } - - $rows = $wpdb->get_results( $query ); - - $time_data = array(); - foreach ( $rows as $row ) { - $day = $row->day; - $count = $row->count; - - // TODO if a day has no data, then make it 0 visitors. Otherwise, it is not plotted on the graph as 0. - array_push( $time_data, array( ( strtotime( $day ) * 1000 ), intval( $count ) ) ); - } - ?> - -
-
-
-
-
- -
-
-
-
-
- - - + + jQuery("#entry-count-placeholder").bind("plotselected", function (event, ranges) { + // do the zooming + + plot = jQuery.plot("#entry-count-placeholder", [], jQuery.extend(true, {}, options, { + xaxis: { + min: ranges.xaxis.from, + max: ranges.xaxis.to + } + })); + + // don't fire event on the overview to prevent eternal loop + overview.setSelection(ranges, true); + }); + + jQuery("#entry-count-overview-placeholder").bind("plotselected", function (event, ranges) { + plot.setSelection(ranges); + }); + jQuery("#entry-count-placeholder").bind("plothover", function (event, pos, item) { + if (item) { + jQuery("#flot-tooltip").remove(); + var x = item.datapoint[0].toFixed(2), + y = item.datapoint[1].toFixed(2); + flot_tooltip( item.pageX - 30, item.pageY - 20, item.datapoint[1] ); + } else { + jQuery("#flot-tooltip").remove(); + } + }); + }); + +
+ + - \ No newline at end of file +?> diff --git a/includes/admin/settings.php b/includes/admin/settings.php index d1e1bff..4ebfcce 100644 --- a/includes/admin/settings.php +++ b/includes/admin/settings.php @@ -1,4 +1,4 @@ -
- +

- - -
- - - -
- - - -
- - - -
- - - -
- - + +
+ +
+ +
+ + + +
+ + + +
+ + + +
+ + + +
+ + +
+ + + +
- \ No newline at end of file +?> diff --git a/includes/admin/tools.php b/includes/admin/tools.php index ee958f4..53efb28 100644 --- a/includes/admin/tools.php +++ b/includes/admin/tools.php @@ -1,4 +1,4 @@ -

- +
-

+

-

- +

+

- + -

- -

+ -

- - - +
-

+

-

- +

+

- + -

- -

+ -

- +
-

+

-

- +

+

-

- -

+ -

@@ -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 ' /> 
'; } + ?>

+

 

+ +

+ +

/>

-   -

- />

+ +

/>

+ 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 ) {

- /> -

@@ -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 @@
- -
- - +
+ +
@@ -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-list.php b/templates/rating-result-list.php index 7333711..ad54ebd 100644 --- a/templates/rating-result-list.php +++ b/templates/rating-result-list.php @@ -44,8 +44,10 @@ } ?> - - + +
+ +
- +
@@ -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';