=== TT Like & Follow for WP-Multisite === Contributors: paoltaia, stiofan Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=payments@nomaddevs.com&item_name=Donation+for+WPLF Tags: multisite, network, follow button, like button, social network Requires at least: 3.0.1 Tested up to: 3.8.3 Stable tag: 1.1 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html TT Like & Follow for WP-Multisite gives you the chance to add basic Social Network features to your installation. == Description ==
ThemeTailors Like & Follow Plugin for Wordpress Multisite gives you the chance to add basic Social Network features to your WP multisite installation.
It include 2 features:
Site's admins will see in their dashboard the latest posts from people they are following.
The panel will display the latest 4 posts, from every followed user, in chronological order.
Every post will show the linked title of the post, the author's name, an excerpt of the post and the author's avatar.
TT Like & Follow Plugin comes with a handful sets of functions that you can insert in your theme.
These functions are called by a class that can be extended and improved.
Tailored by theme tailors == Installation == = Automatic installation =Automatic installation is the easiest option. To do an automatic install of TT Like & Follow for WP-Multisite, log in to your WordPress Multisite dashboard, navigate to the Plugins menu and click Add New.
In the search field type TT Like & Follow for WP-Multisite and click Search Plugins. Once you've found our plugin you install it by simply clicking Install Now.
= Manual installation =The manual installation method involves downloading TT Like & Follow for WP-Multisite plugin and uploading it to your webserver via your favourite FTP application.
The WordPress codex will tell you more [here](http://codex.wordpress.org/Managing_Plugins#Manual_Plugin_Installation).
= Updating =Automatic updates should seamlessly work. We always suggest to backup up your website before performing any automated update to avoid exceptions.
= Using TT WPLF in your own theme =Like & Follow Wordpress Plugin comes with a handful sets of functions that you can insert in your theme. These functions are called by a class that can be extended and improved.
Please find a list of the functions inside the WPLF class in the plugin FAQ.
== Frequently Asked Questions == = Q : How do I create an instance of WPLF class = = A : To create the instance of the WPLF class: =$foo = new WPLF( userID , blogID );
userID ( integer )
The ID of a desired user. If the value is null, the current user ID will be used with the help of the WP function get_current_user_id().
Default value: null
blogID ( integer )
The ID of a desired blog, If the value in null, the current blog ID will be used with the help of the global variable $blog_id.
Default value: null
= Q : Where can I find a list of functions in WPLF class = = A : Here's a list of the functions inside the WPLF class: = = 1) followButton =As its name says, this function creates the "Follow" button. You can call it everywhere in the code like this:
echo $foo->followButton( class );
class ( string )
custom classnames that you can insert in the button to modify its default style.
Default value: null
Return value: a string that contains the formatted HTML "Follow" button.
= 2) likeButton =this function creates the "Like" button.
echo $foo->likeButton( args );
args ( mixed values )
The function uses the same pattern used in WordPress to define the multiple variables inside. You can use arrays or a string to set the following variables:
blogID ( integer )
The ID of the blog you want to target the button.
Default value: the blogID set when the class's instance is created
postID ( integer )
The ID of the post you want to target.
Default value: $post->ID from global variable $post. Remember, if this value is set to default, you must use the function inside the loop.
class ( string )
The custom classnames that you can insert in the button to modify its style.
Defaul value: null
table ( string )
It refers to the table located in the WP database. It targets a specified table that contain the target post.
If you're using a custom type post, you don't need to modify this parameter.
Default value: ‘posts'
Return value: a string that contains the formatted HTML "Like" button.
= 3) insertFollower =This function insert the selected user into the "following" list of a target user. It's the function that is called when clicking on the "Follow" button.
$foo->insertFollower( follower );
follower ( integer )
The follower's ID. There's no default value, this variable is mandatory.
Return value: an associative array that contains the following values:
‘text' = "Unfollow"
‘check' = if the insertion fails, the value will be false
‘fn' = "unfollow"
= 4) insertLike =Insert a target post into the like list. It's the function called after you press on the "Like" button.
$foo->insertLike( comingString );
comingString ( string )
The string that's coming from the "Like" button. It's formed as follows:
blog_id-post_id-table
The string is split by the function and processed.
Return value: an associative array with the following values:
‘text' = the value set in the admin backend
‘check' = if the insertion fails, the value will be false
‘fn' = "unlike"
= 5) deleteFollower =Remove a selected user from the "following" list from the target user. It's called when you press the "Unfollow" button.
$foo->deleteFollower( follower );
follower ( string )
The user's slug name that will be removed from the list. It's a mandatory variable.
Return value: an associative array with the following values:
‘text' = "Follow [USERNAME]"
‘check' = if the deletion fails, the value will be false
‘fn' = "follow"
= 6) deleteLike =Remove a selected post ( or a custom type ) from the "Like" list of the target user. It's the function called when you press on the "Unlike" button.
$foo->deleteLike( deleteString );
deleteString ( string )
The string that's coming from the "Unlike" button. Like the insertLike function, it follows the same pattern:
blog_id-post_id-table
Return value: an associative array with the following values:
‘text' = the value set in the admin backend
‘check' = if the deletion fails, the value will be false
‘fn' = "follow"
= 7) checkFollow =This function checks if the user is already followed.
$foo->checkFollow( follower_id );
follower_id ( integer )
The ID of the target user. This variable is mandatory
Return value: ( boolean ) if the user is already followed, the function will return true
= 8) checkLike =Checks if the post is already liked by a target user.
$foo->checkLike( likeString );
likeString ( string )
String that will be processed by the function. Like insertLike and deleteLike functions, it uses the same pattern:
blog_id-post_id-table
Return value: ( boolean ) if the post is altready liked, the function will return true
= 9) getFollowers =Return an array that contains all the users that follows the target user.
$foo->getFollowers( args );
args ( mixed values )
the arguments used for the pagination and to define the output type. You can insert the values as an associative array or as a query string, just like the function get_results in the wpdb class.
page ( integer )
The current page defined fro the pagination.
Default value: 1
limit ( integer )
The number of results that will be displayed per page.
Default value: false
output_type ( string )
Sets the type of the resulting array. To set a different type of array, check the wpdb class on the WordPress Codex Page.
Default value: OBJECT
Return value: An array with the result of the query.
= 10) getLikes =Return an array that contains the likes got from the target user.
$foo->getLikes( args );
args ( mixed values )
The arguments used to filter and paginate the results. You can insert the values as an associative array or as a query string, just like the function get_results in the wpdb class.
blogID ( integer )
The ID of a target blog in the network. if the value is false the function will return all the likes of the target user.
Default value: false
postID ( integer )
The ID of the post. To target a post, you must also enter the blogID.
Default value: false
page ( integer )
The current page defined for pagination.
Default value: 1
limit ( integer )
The number of results that will be displayed per page.
Default value: false
table ( string )
It refers to the table located in the WP database. It targets a specified table that contain the target post.
Default value: ‘posts'
output_type ( string )
Sets the type of the resulting array. To set a different type of array, check the wpdb class on the WordPress Codex Page.
Default value: ‘OBJECT'
exclude ( boolean )
You can exclude the target user from the results. Setting true this parameter, the query will return only the likes that other user gave to the selected post.
Default value: false
Return value: an array with the result of the query.
= 11) getFollowing =Return the users that the target user is following.
$foo->getFollowing( args );
args ( mixed values )
Like the "getFollowers" function, the args used in this function are for the pagination and to define the output type on the resulting query.
page ( integer )
The current page defined fro the pagination.
Default value: 1
limit ( integer )
The number of results that will be displayed per page.
Default value: false
output_type ( string )
Sets the type of the resulting array. To set a different type of array, check the wpdb class on the WordPress Codex Page.
Default value: OBJECT
Return value: an array with the result of the query.
= 12) getLiked =Return the post liked from the target user.
$foo->getLiked( args );
args ( mixed values )
You can insert the values as an associative array or as a query string, just like the function get_results in the wpdb class.
blogID ( integer )
The ID of a target blog in the network. if the value is false the function will return all the likes of the target user.
Default value: false
page ( integer )
The current page defined for pagination.
Default value: 1
limit ( integer )
The number of results that will be displayed per page.
Default value: false
table ( string )
It refers to the table located in the WP database. It targets a specified table that contain the target post.
Default value: ‘posts'
output_type ( string )
Sets the type of the resulting array. To set a different type of array, check the wpdb class on the WordPress Codex Page.
Default value: ‘OBJECT'
Return value: an array with the result of the query.
= 13) getFollowingPosts =Return the posts from the users followed from the target user.
This function is compatible with the WPMUDEV Post Indexer plugin. If this plugin is installed, the function will use its class to get the posts from the index generated.
$foo->getFollowingPosts( page , limit );
page ( integer )
The current page defined for pagination.
Default value: 1
limit ( integer )
The number of results that will be displayed per page.
Default value: 10
Return value: an array filled with stdClass object arrays. The stdClass object contains the following data:
BLOG_ID
ID
post_author
post_author_name
post_date
post_date_gmt
post_content
post_title
post_excerpt
post_status
comment_status
ping_status
post_password
post_name
to_ping
pinged
post_modified
post_modified_gmt
post_content_filtered
post_parent
guid
permalink
menu_order
post_type
post_mime_type
comment_count
= 14) getActivity =Returns the follows and the likes that the target user receive. The results are sorted in chronological order.
This function uses getLikes and getFollowers to gather the data.
$foo->getActivity( page , limit );
page ( integer )
The current page defined for pagination.
Default value: 1
limit ( integer )
The number of results that will be displayed per page.
Default value: false
Return value: an object array.
= 15) saveUserOptions =Saves wplf-related usermeta values.
$foo->saveUserOptions( optionName , optionValue );
optionName ( string )
The name of the target option. NOTE: this function only accepts option's names that are previously declared in the $strictVals variable, inside the WPLF class.
The options accepted are:
email-follow-notification
email-like-notification
No default value. this variable is mandatory.
optionValue ( mixed values )
The value that will be saved.
No default value.
Return value: ( boolean ) if the saving is processed, the function will return true
= 16) getUserOptions =Gets wplf-related usermeta values.
$foo->getUserOptions( optionName );
optionName ( string )
The name of the target option. NOTE: this function only accepts option's names that are previously declared in the $strictVals variable, inside the WPLF class.
The options accepted are:
email-follow-notification
email-like-notification
No default value. this variable is mandatory.
Return value: the value from the usermeta selected.
= Private functions =There are also 3 private functions that you can use only inside the wplf class.
They are developed to ease the work inside the other functions.
= 1) backToObj =Transform nested arrays into objects. This is developed to merge the results used by getLikes and getFollowers in the getActivity function NOTE: works only with first level of array
Unlike other functions in the class, backToObj doesn't need to be declared inside a variable.
$array = array();
$foo->backToObj( $array );
//now $array is an object stdClass
Return value: No return value. This function modifies the target array.
= 2) notify =Sends an email to the target user and to the user that's followed or have his post liked. This function is used by insertFollower and insertLike. For now, it's developed to work only with these 2 public functions.
$foo->notify( userID , type );
userID ( integer )
The ID of the user that is followed or have his post liked by the target user. From this ID, the Display name and the email will be used to send the email to him.
No default value. This variable is mandatory.
type ( string )
Define the genre of the email that will be sent. For now, it has only 2 types:
follow
like
By selecting one of these type, the content of the email will change.
No default value. This variable is mandatory.
Return value: Because notify uses wp_mail to send the email, the function will return true if the mail is sent.
= 3) wplfPage =Used to ease the pagination. It's used by getFollowers, getLikes, getFollowing, getLiked and getFollowingPosts.
$foo->wplfPage( page , limit );
page ( integer )
The current page defined for pagination.
Default value: 1
limit ( integer )
The number of results that will be displayed per page.
Default value: 10
Return value: The function will return the right point to gather the data from the query.
== Screenshots == = Coming soon = == Changelog == = 1.0 = initial release == Upgrade Notice == = none =