
in this tutorial you will lean how to create a wordpress review plugin that works
how does this plugin works? it adds a filter for comment-text , when a user post a comment he can include in the comment the text 1star,2stars,3stars,4stars,5stars and once he leave the comment rating stars will be included in his comment as seen in the picture above.
Download The Review Plugin
our first lines of php in our review/star rating plugin

review plugin information.
every wordpress plugin must have the following information , plugin name , plugin url plugin description, plugin version and autor name , these information will appear after uploading the plugin at the plugin page where you activate/disable a plugin
/* Plugin Name: ModyReview Plugin URI: http://the plugin url here Description: plugin description - Allows Commenter to add stars Rating with their comment by typing 1star or 2stars , 3stars, 4stars, 5stars Author: your name here Version: 1.0 Author URI: http://tutorialsbay.com */
Now we need to define the plugins directory
we need to define the plugins directory to locate our review plugin and grab the stars images from there to show it in the comment content
if (!defined('WP_CONTENT_DIR')) {
define( 'WP_CONTENT_DIR', ABSPATH.'wp-content');
}
if (!defined('WP_CONTENT_URL')) {
define('WP_CONTENT_URL', get_option('siteurl').'/wp-content');
}
if (!defined('WP_PLUGIN_DIR')) {
define('WP_PLUGIN_DIR', WP_CONTENT_DIR.'/plugins');
}
if (!defined('WP_PLUGIN_URL')) {
define('WP_PLUGIN_URL', WP_CONTENT_URL.'/plugins');
}
Creating The Function
We need to create the php functions that will do the job , replacing 1star 2stars 3tars ect. with the stars images , actually this could be done in one function but i think 5 small functions are easier for those who are very new to php , the 5 functions are the same , with different variables names. these php functions will look where in the comment there is 1star , 2stars, 3stars, 4stars, 5stars and replace them with the star image
what makes the functions apply on the comment-text?
if you noticed that below each of the functions above there is
add_filter('comment-text' , 'function name');
and that’s a wordpress filter, Filters are the hooks that WordPress launches to modify text of various types before adding it to the database or sending it to the browser screen. Plug-ins can specify that one or more of its PHP functions is executed to modify specific types of text at these times, using the Filter API. to learn more about wordpress Action, Filter, and Plug-in Functions visit the following page
http://codex.wordpress.org/Function_Reference/
Hello admin , This is good posting for my homework from school Do u have twitter account ?? i want to follow your twitt . bye
- spam
- offensive
- disagree
- off topic
Like