# Class EDD_Reviews

EDD_Reviews Class

Final
Package: EDD\Reviews
Author: Sunny Ratilal
Version: 1.1
Since: 1.0
Located at edd-reviews.php

## Methods summary

`public static object` | # `get_instance( )` Get the instance and store the class inside it. This plugin utilises the PHP singleton design pattern. Get the instance and store the class inside it. This plugin utilises the PHP singleton design pattern. #### Returns `object` self::$instance Instance #### Since 1.0 #### See edd_reviews(); #### Uses EDD_Reviews::setup_globals() Setup the globals needed EDD_Reviews::load_classes() Loads all the classes ``EDD_Reviews::hooks()`` Setup hooks and actions
`public` | # `__construct( )` Constructor Function Constructor Function #### Since 1.0 #### See ``EDD_Reviews::init()`` ``EDD_Reviews::activation()``
`public` | # `__clone( )` Throw error on object clone Throw error on object clone The whole idea of the singleton design pattern is that there is a single object therefore, we don't want the object to be cloned. #### Since 1.0
`public` | # `__wakeup( )` Disable unserializing of the class Disable unserializing of the class #### Since 1.0
`public` | # `__isset( mixed $key )` Magic method for checking if custom variables have been set Magic method for checking if custom variables have been set #### Since 1.0
`public` | # `__get( mixed $key )` Magic method for getting variables Magic method for getting variables #### Since 1.0
`public` | # `__set( mixed $key, mixed $value )` Magic method for setting variables Magic method for setting variables #### Since 1.0
`public` | # `__unset( mixed $key )` Magic method for unsetting variables Magic method for unsetting variables #### Since 1.0
`public` | # `__call( string $name = '', array $args = array() )` Magic method to prevent notices and errors from invalid method calls Magic method to prevent notices and errors from invalid method calls #### Parameters $name `string` $name $args `array` $args #### Since 1.0
`public static` | # `reset( )` Reset the instance of the class Reset the instance of the class #### Since 1.0
`public` | # `init( )` Function fired on init Function fired on init This function is called on WordPress 'init'. It's triggered from the constructor function. #### Since 1.0 #### Uses ``EDD_Reviews::load_plugin_textdomain()`` ``EDD_Reviews::add_shortcodes()``
`public boolean` | # `load_plugin_textdomain( )` Load Plugin Text Domain Load Plugin Text Domain Looks for the plugin translation files in certain directories and loads them to allow the plugin to be localised #### Returns `boolean` True on success, false on failure #### Since 1.0 #### Used by ``EDD_Reviews::init()``
`public` | # `activation( )` Activation function fires when the plugin is activated. Activation function fires when the plugin is activated. This function is fired when the activation hook is called by WordPress, it flushes the rewrite rules and disables the plugin if EDD isn't active and throws an error. #### Since 1.0
`public` | # `add_shortcodes( )` Adds all the shortcodes Adds all the shortcodes #### Since 1.0 #### Used by ``EDD_Reviews::init()``
`public` | # `hooks( )` Adds all the hooks/filters Adds all the hooks/filters The plugin relies heavily on the use of hooks and filters and modifies default WordPress behaviour by the use of actions and filters which are provided by WordPress. Actions are provided to hook on this function, before the hooks and filters are added and after they are added. The class object is passed via the action. #### Since 1.0 #### Used by ``EDD_Reviews::get_instance()`` Setup hooks and actions
`public` | # `register_widgets( )` Register Widgets Register Widgets #### Since 1.0
`public string` | # `comments_template( mixed $template )` Comments Template Comments Template Override the default comments template for the download post type #### Returns `string` Path to the review template #### Since 1.0
`public` | # `reviews_form( )` Reviews form Reviews form This function is called by the reviews template and overrides the default comments form by replacing the fields in order for reviews to be placed. #### Since 1.0
`public object|boolean` | # `check_author( array $commentdata )` Checks if multiple reviews have been disabled and then verifies if the author has already posted a review for this download (product). This function queries the database for any reviews by taking the comment_post_ID and comment_author_email and if anything is returned, execution of the comment addition will fail with wp_die(). Checks if multiple reviews have been disabled and then verifies if the author has already posted a review for this download (product). This function queries the database for any reviews by taking the comment_post_ID and comment_author_email and if anything is returned, execution of the comment addition will fail with wp_die(). #### Parameters $commentdata `array` $commentdata All the comment data sent via $_POST #### Returns `object|boolean` Returns an instance of wp_die() or the comment data #### Since 1.2
`public array` | # `check_review_title( array $commentdata )` Checks if a review title has been entered otherwise dies with an error Checks if a review title has been entered otherwise dies with an error #### Parameters $commentdata `array` $commentdata All the comment data sent via $_POST #### Returns `array` $commentdata All the comment data sent via $_POST #### Since 1.0
`public array` | # `check_rating( array $commentdata )` Checks if a rating has been made otherwise dies with an error Checks if a rating has been made otherwise dies with an error #### Parameters $commentdata `array` $commentdata All the comment data sent via $_POST #### Returns `array` $commentdata All the comment data sent via $_POST #### Since 1.0
`public array` | # `remove_url( array $fields )` Remove URL field from Comments (Review) Form only on the Download page Remove URL field from Comments (Review) Form only on the Download page #### Parameters $fields `array` $fields All the comment fields #### Returns `array` $fields Updated list of comment fields without the URL #### Since 1.0
`public` | # `save_review_meta( integer $comment_id )` Save the Review Meta Data Save the Review Meta Data #### Parameters $comment_id `integer` $comment_id Comment ID #### Since 1.0
`public string` | # `microdata( string $content )` Microdata Microdata #### Parameters $content `string` $content Content of the post #### Returns `string` $content Content of the post with the microdata #### Since 1.0 #### Uses ``EDD_Reviews::average_rating()``
`public string` | # `average_rating( boolean $echo = true )` Get Average Rating Get Average Rating #### Parameters $echo `boolean` $echo Whether to echo the result or return it #### Returns `string` $average Returns the average rating #### Since 1.0 #### Used by ``EDD_Reviews::microdata()``
`public array` | # `enable_comments( array $supports )` Enable Reviews on all Downloads Enable Reviews on all Downloads #### Parameters $supports `array` $support What the Downloads post type supports (e.g. title) #### Returns `array` Merged array with comments support enabled for downloads #### Since 1.0
`public` | # `disable_trackbacks( )` Disable Trackbacks Disable Trackbacks This function removes the Trackbacks meta box from the Add/Edit Download screen as it's not the sole purpose of this plugin and if any were to be made, they wouldn't render correctly as the plugin doesn't provide support for trackbacks. #### Since 1.0
`public` | # `change_meta_boxes( )` Edit Meta Boxes Edit Meta Boxes The Comments meta box on the Add/Edit Download screen is renamed here and the callback function for the comments meta box is also changed. #### Since 1.0
`public` | # `post_comment_status_meta_box( object $post )` Override the default comment status meta box Override the default comment status meta box #### Parameters $post `object` $post Post Object #### Since 1.0
`public` | # `post_comment_meta_box( object $post )` Override the default comments meta box on Add/Edit screen Override the default comments meta box on Add/Edit screen #### Parameters $post `object` $post Current Post #### Since 1.0
`public` | # `load_styles( )` Load Styles Load Styles #### Since 1.0
`public` | # `load_scripts( )` Load Scripts Load Scripts #### Since 1.0
`public` | # `admin_scripts( )` Load Admin Scripts/Styles Load Admin Scripts/Styles #### Since 1.0
`public array` | # `custom_columns( array $columns )` Shows Review Meta on Comments List Table Shows Review Meta on Comments List Table #### Parameters $columns `array` $columns All the columns on the list table #### Returns `array` $columns New columns with Review Title and Rating added #### Since 1.0
`public` | # `custom_column_data( string $column, integer $comment_ID )` Display Custom Column Data Display Custom Column Data #### Parameters $column `string` $column Current column $comment_ID `integer` $comment_ID Comment ID #### Since 1.0
`public boolean` | # `open_all_comments( boolean $open, string $post_id )` Open Comments for all Downloads Open Comments for all Downloads #### Parameters $open `boolean` $open Whether the comments are open or not $post_id `string` $post_id Post ID #### Returns `boolean` $open Whether the comments are open or not #### Since 1.0
`public array` | # `misc_settings( array $settings )` Register Misc Settings Register Misc Settings #### Parameters $settings `array` $settings Existing registered settings #### Returns `array` Merged array with new settings added #### Since 1.0
`public array` | # `styles_settings( array $settings )` Register Misc Settings Register Misc Settings #### Parameters $settings `array` $settings Existing registered settings #### Returns `array` Merged array with new settings added #### Since 1.0
`public` | # `admin_bar_menu( )` Adds "View Reviews" Link to Admin Bar Adds "View Reviews" Link to Admin Bar #### Since 1.0
`public` | # `admin_notices( )` Handles the displaying of any notices in the admin area Handles the displaying of any notices in the admin area #### Since 1.0
`public string` | # `count_reviews( )` Count the number of reviews from the database Count the number of reviews from the database #### Returns `string` $count Number of reviews #### Since 1.0 #### Used by ``EDD_Reviews::reviews_title()`` ``EDD_Reviews::display_total_reviews_count()`` ``EDD_Reviews::display_review_counts()``
`public string` | # `count_ratings( )` Count the number of ratings from the database Count the number of ratings from the database #### Returns `string` $count Number of reviews #### Since 1.0
`public integer` | # `get_review_count_by_rating( integer $rating )` Gets the number of the reviews by a rating Gets the number of the reviews by a rating #### Parameters $rating `integer` $rating Rating (1 - 5) #### Returns `integer` $number Number of reviews #### Since 1.0 #### Used by ``EDD_Reviews::display_review_counts()``
`public` | # `reviews_title( integer $average = null )` Build Reviews (comments) title Build Reviews (comments) title #### Parameters $average `integer` $average Average ratings for reviews #### Since 1.0 #### Uses ``EDD_Reviews::count_reviews()``
`public boolean` | # `reviewer_has_purchased_download( )` Checks if the reviewer has purchased the download Checks if the reviewer has purchased the download #### Returns `boolean` Whether reviews has purchased download or not #### Since 1.0
`public array` | # `review_classes( array $classes )` Add Classes to the Reviews Add Classes to the Reviews #### Parameters $classes `array` $classes Comment classes #### Returns `array` $classes Comment (reviews) classes with 'review' added #### Since 1.0
`public` | # `review( object $comment, array $args, string $depth )` Template for displaying reviews Template for displaying reviews This function just executes the hooks to display the review. #### Parameters $comment `object` $comment $args `array` $args $depth `string` $depth #### Since 1.0
`public` | # `render_review( object $comment, array $args, string $depth )` Renders each review Renders each review NOTE: Closing tags have been left out deliberately because WordPress will supply the closing tag automatically. See here: http://codex.wordpress.org/Function_Reference/wp_list_comments #### Parameters $comment `object` $comment $args `array` $args $depth `string` $depth #### Since 1.0 #### Uses ``EDD_Reviews::voting_info()``
`public` | # `voting_info( )` Display Voting Info Display Voting Info Example output: 2 of 8 people found this review helpful #### Since 1.0 #### Used by ``EDD_Reviews::render_review()``
`public` | # `maybe_show_review_breakdown( )` Conditional whether or not to display review breakdown Conditional whether or not to display review breakdown #### Since 1.0 #### Uses ``EDD_Reviews::review_breakdown()``
`public` | # `review_breakdown( )` Reviews Breakdown Reviews Breakdown Shows a breakdown of all the reviews and the number of people that given each rating for each download Example: 8 people gave a 5 star rating; 10 people have a 2 star rating #### Since 1.0 #### Uses ``EDD_Reviews::display_total_reviews_count()`` ``EDD_Reviews::display_review_counts()`` #### Used by ``EDD_Reviews::maybe_show_review_breakdown()``
`public` | # `display_total_reviews_count( )` Displays the total reviews count Displays the total reviews count #### Since 1.0 #### Uses ``EDD_Reviews::count_reviews()`` #### Used by ``EDD_Reviews::review_breakdown()``
`public` | # `display_review_counts( )` Displays reviews count for each rating by looping through 1 - 5 Displays reviews count for each rating by looping through 1 - 5 #### Since 1.0 #### Uses ``EDD_Reviews::get_review_count_by_rating()`` ``EDD_Reviews::count_reviews()`` #### Used by ``EDD_Reviews::review_breakdown()``
`public` | # `process_vote( )` Process Vote from Review Process Vote from Review This function is called if a JavaScript isn't enabled #### Since 1.0
`public` | # `add_comment_vote_meta( integer $comment_id, string $vote )` Add Comment Vote Add Comment Vote #### Parameters $comment_id `integer` $comment_id Comment ID $vote `string` $vote Whether the vote was yes or no #### Since 1.0
`public boolean` | # `is_ajax_request( )` Checks whether an AJAX request has been sent Checks whether an AJAX request has been sent #### Returns `boolean` Whether or not AJAX $_GET header has been passed #### Since 1.0 #### Used by ``EDD_Reviews::process_ajax_vote()``
`public mixed` | # `process_ajax_vote( )` Process Voting for the Reviews via AJAX Process Voting for the Reviews via AJAX Processes the voting button appended to the bottom of each review by adding or updating the comment meta via AJAX. #### Returns `mixed` returns if AJAX check fails #### Since 1.0 #### Uses ``EDD_Reviews::is_ajax_request()``
`public` | # `dashboard_widgets( )` Register Dashboard Widgets Register Dashboard Widgets #### Since 1.0
`public` | # `render_dashboard_widget( )` Render the Dashboard Widget Render the Dashboard Widget #### Since 1.0
`public` | # `add_meta_boxes( )` Add the Meta Boxes Add the Meta Boxes #### Since 1.0
`public` | # `review_meta_box( object $comment )` Render the Review Meta Box Render the Review Meta Box Outputs the Review Information meta box on the Edit Comment screen. This meta box displays the review title and the star rating. It also allows for it to be edited. #### Parameters $comment `object` $comment Comment information #### Since 1.0
`public` | # `update_review_meta( integer $comment_id )` Save the Meta Data from the Meta Box on the Edit Comment Screen Save the Meta Data from the Meta Box on the Edit Comment Screen #### Parameters $comment_id `integer` $comment_id Comment ID #### Since 1.0
`public array` | # `register_api_mode( array $modes )` Register API Query Mode Register API Query Mode #### Parameters $modes `array` $modes Whitelisted query modes #### Returns `array` $modes Updated list of query modes #### Since 1.0
`public array` | # `query_vars( array $vars )` Add 'review_id' Query Var into WordPress Whitelisted Query Vars Add 'review_id' Query Var into WordPress Whitelisted Query Vars #### Parameters $vars `array` $vars Array of WordPress allowed query vars #### Returns `array` $vars Updated array of WordPress query vars to allow Reviews to integrate with the EDD API #### Since 1.0
`public array` | # `api_output( array $data, array $query_mode, object $api_object )` Processes the Data Outputted when an API Call for Reviews is Triggered Processes the Data Outputted when an API Call for Reviews is Triggered #### Parameters $data `array` $data Array to hold the output $query_mode `array` $query_mode Query mode (i.e. reviews) $api_object `object` $api_object EDD_API Object #### Returns `array` $data All the data for when the API call for reviews is fired #### Since 1.0
`public boolean` | # `user_can_see_tinymce( )` Is the User Allowed to See TinyMCE? Is the User Allowed to See TinyMCE? #### Returns `boolean` Whether the user can see TinyMCE or not #### Since 1.0 #### Used by ``EDD_Reviews::tinymce_button()``
`public` | # `tinymce_button( )` Add TinyMCE Button Add TinyMCE Button Adds a button to the TinyMCE editor to easily embed reviews into posts and pages #### Since 1.0 #### Uses ``EDD_Reviews::user_can_see_tinymce()``
`public array` | # `add_plugin( array $plugin_array )` Register TinyMCE Plugin Register TinyMCE Plugin #### Parameters $plugin_array `array` $plugin_array Array of TinyMCE Plugins #### Returns `array` $plugin_array Array of TinyMCE Plugins #### Since 1.0
`public array` | # `register_button( array $buttons )` Register TinyMCE Button Register TinyMCE Button #### Parameters $buttons `array` $buttons Array of TinyMCE Button #### Returns `array` $buttons Array of TinyMCE Button #### Since 1.0
`public` | # `process_mce_dialog( )` Process the TinyMCE Modal Dialog Process the TinyMCE Modal Dialog #### Since 1.0
`public array` | # `plugin_links( array $links, mixed $file )` Plugin Action Links Plugin Action Links This function adds a link to the plugin action links bar on the Plugins Administrati on page to for the API documentation and to Easy Digital Downloads Support Forum. #### Parameters $links `array` $links Plugin Action Links $file #### Returns `array` $links Plugin Action Links #### Since 1.0
`public` | # `updater( )` Loads the Updater Loads the Updater Instantiates the Software Licensing Plugin Updater and passes the plugin data to the class. #### Since 1.0

### Magic methods summary

## Properties summary

`public static boolean` | $testing | # Boolean whether or not to use the singleton, comes in handy when doing testing Boolean whether or not to use the singleton, comes in handy when doing testing #### Since 1.0
`public string` | $version | # Holds the version number Holds the version number #### Since 1.0