| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name:WP ULike |
| 4 |
Plugin URI: http://preview.alimir.ir/developer/wp-ulike/ |
| 5 |
Description: WP ULike plugin allows to integrate a beautiful Ajax Like Button into your wordPress website to allow your visitors to like and unlike pages, posts, comments AND buddypress activities. Its very simple to use and supports many options. |
| 6 |
Version: 2.2 |
| 7 |
Author: Ali Mirzaei |
| 8 |
Author URI: http://about.alimir.ir |
| 9 |
Text Domain: alimir |
| 10 |
Domain Path: /lang/ |
| 11 |
License: GPL2 |
| 12 |
*/ |
| 13 |
|
| 14 |
//Load Translations |
| 15 |
load_plugin_textdomain( 'alimir', false, dirname( plugin_basename( __FILE__ ) ) .'/lang/' ); |
| 16 |
|
| 17 |
//Do not change this value |
| 18 |
define( 'WP_ULIKE_DB_VERSION', '1.3' ); |
| 19 |
|
| 20 |
/** |
| 21 |
* When the plugin is activated, This function will install wp_ulike tables in database (If not exist table) |
| 22 |
* |
| 23 |
* @author Alimir |
| 24 |
* @since 1.1 |
| 25 |
* @updated 1.7 |
| 26 |
* @return Void |
| 27 |
*/ |
| 28 |
register_activation_hook( __FILE__, 'wp_ulike_install' ); |
| 29 |
function wp_ulike_install() { |
| 30 |
global $wpdb; |
| 31 |
|
| 32 |
$table_name = $wpdb->prefix . "ulike"; |
| 33 |
if ( $wpdb->get_var( "show tables like '$table_name'" ) != $table_name ) { |
| 34 |
$sql = "CREATE TABLE " . $table_name . " ( |
| 35 |
`id` bigint(11) NOT NULL AUTO_INCREMENT, |
| 36 |
`post_id` int(11) NOT NULL, |
| 37 |
`date_time` datetime NOT NULL, |
| 38 |
`ip` varchar(30) NOT NULL, |
| 39 |
`user_id` int(11) NOT NULL, |
| 40 |
`status` varchar(15) NOT NULL, |
| 41 |
PRIMARY KEY (`id`) |
| 42 |
);"; |
| 43 |
|
| 44 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
| 45 |
dbDelta( $sql ); |
| 46 |
|
| 47 |
add_option( 'wp_ulike_dbVersion', WP_ULIKE_DB_VERSION ); |
| 48 |
} |
| 49 |
|
| 50 |
$table_name_2 = $wpdb->prefix . "ulike_comments"; |
| 51 |
if ( $wpdb->get_var( "show tables like '$table_name_2'" ) != $table_name_2 ) { |
| 52 |
$sql = "CREATE TABLE " . $table_name_2 . " ( |
| 53 |
`id` bigint(11) NOT NULL AUTO_INCREMENT, |
| 54 |
`comment_id` int(11) NOT NULL, |
| 55 |
`date_time` datetime NOT NULL, |
| 56 |
`ip` varchar(30) NOT NULL, |
| 57 |
`user_id` int(11) NOT NULL, |
| 58 |
`status` varchar(15) NOT NULL, |
| 59 |
PRIMARY KEY (`id`) |
| 60 |
);"; |
| 61 |
|
| 62 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
| 63 |
dbDelta( $sql ); |
| 64 |
|
| 65 |
update_option( 'wp_ulike_dbVersion', WP_ULIKE_DB_VERSION ); |
| 66 |
} |
| 67 |
|
| 68 |
$table_name_3 = $wpdb->prefix . "ulike_activities"; |
| 69 |
if ( $wpdb->get_var( "show tables like '$table_name_3'" ) != $table_name_3 ) { |
| 70 |
$sql = "CREATE TABLE " . $table_name_3 . " ( |
| 71 |
`id` bigint(11) NOT NULL AUTO_INCREMENT, |
| 72 |
`activity_id` int(11) NOT NULL, |
| 73 |
`date_time` datetime NOT NULL, |
| 74 |
`ip` varchar(30) NOT NULL, |
| 75 |
`user_id` int(11) NOT NULL, |
| 76 |
`status` varchar(15) NOT NULL, |
| 77 |
PRIMARY KEY (`id`) |
| 78 |
);"; |
| 79 |
|
| 80 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
| 81 |
dbDelta( $sql ); |
| 82 |
|
| 83 |
update_option( 'wp_ulike_dbVersion', WP_ULIKE_DB_VERSION ); |
| 84 |
} |
| 85 |
|
| 86 |
$table_name_4 = $wpdb->prefix . "ulike_forums"; |
| 87 |
if ( $wpdb->get_var( "show tables like '$table_name_4'" ) != $table_name_4 ) { |
| 88 |
$sql = "CREATE TABLE " . $table_name_4 . " ( |
| 89 |
`id` bigint(11) NOT NULL AUTO_INCREMENT, |
| 90 |
`topic_id` int(11) NOT NULL, |
| 91 |
`date_time` datetime NOT NULL, |
| 92 |
`ip` varchar(30) NOT NULL, |
| 93 |
`user_id` int(11) NOT NULL, |
| 94 |
`status` varchar(15) NOT NULL, |
| 95 |
PRIMARY KEY (`id`) |
| 96 |
);"; |
| 97 |
|
| 98 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
| 99 |
dbDelta( $sql ); |
| 100 |
|
| 101 |
update_option( 'wp_ulike_dbVersion', WP_ULIKE_DB_VERSION ); |
| 102 |
} |
| 103 |
|
| 104 |
} |
| 105 |
|
| 106 |
/** |
| 107 |
* This hook is called once any activated plugins have been loaded. |
| 108 |
* |
| 109 |
* @author Alimir |
| 110 |
* @since 1.7 |
| 111 |
* @return Void |
| 112 |
*/ |
| 113 |
add_action( 'plugins_loaded', 'wp_ulike_update_db_check' ); |
| 114 |
function wp_ulike_update_db_check() { |
| 115 |
if ( get_site_option( 'wp_ulike_dbVersion' ) != WP_ULIKE_DB_VERSION ) { |
| 116 |
wp_ulike_install(); |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
/** |
| 121 |
* This function is getting the plugin version |
| 122 |
* |
| 123 |
* @author Alimir |
| 124 |
* @since 1.8 |
| 125 |
* @return String |
| 126 |
*/ |
| 127 |
function wp_ulike_get_version() { |
| 128 |
$plugin_data = get_plugin_data( __FILE__ ); |
| 129 |
$plugin_version = $plugin_data['Version']; |
| 130 |
return $plugin_version; |
| 131 |
} |
| 132 |
|
| 133 |
//Include plugin setting file |
| 134 |
include plugin_dir_path( __FILE__ ) . 'admin/admin.php'; |
| 135 |
|
| 136 |
//Include general functions |
| 137 |
include plugin_dir_path( __FILE__ ) . 'inc/wp-functions.php'; |
| 138 |
|
| 139 |
//Include plugin scripts |
| 140 |
include plugin_dir_path( __FILE__ ) . 'inc/wp-script.php'; |
| 141 |
|
| 142 |
//Load WP ULike functions |
| 143 |
include plugin_dir_path( __FILE__ ) . 'inc/wp-ulike.php'; |
| 144 |
|