/** * Updating all post like, unlike, total meta counts * @param no-param * @return json data */ function WtiLikePostUpdateMeta() { // Check for valid access if (!wp_verify_nonce($_REQUEST['nonce'], "wti_like_post_update_nonce")) { $error = 1; $msg = __('Invalid access', 'wti-like-post'); $result = array('msg' => $msg, 'error' => $error); } else { $count = WtiUpdateLikeMetaData(); $result = array('msg' => $count . __(' like/unlike/total post metadata updated successfully', 'wti-like-post'), 'error' => 0); } // Check for method of processing the data if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { header('content-type: application/json; charset=utf-8'); header('access-control-allow-origin: *'); echo json_encode($result); } else { header("location:" . $_SERVER["HTTP_REFERER"]); } exit; }
/** * Create table and set the options for this plugin * @param no-param * @return no-return */ function SetAllOptionsWtiLikePost() { global $wpdb, $wti_like_post_db_version; //creating the like post table on activating the plugin $wti_like_post_table_name = $wpdb->prefix . "wti_like_post"; add_option("wti_like_post_db_version", $wti_like_post_db_version); if ($wpdb->get_var("show tables like '{$wti_like_post_table_name}'") != $wti_like_post_table_name) { $sql = "CREATE TABLE " . $wti_like_post_table_name . " (\n\t\t\t`id` bigint(11) NOT NULL AUTO_INCREMENT,\n\t\t\t`post_id` int(11) NOT NULL,\n\t\t\t`value` int(2) NOT NULL,\n\t\t\t`date_time` datetime NOT NULL,\n\t\t\t`ip` varchar(40) NOT NULL,\n\t\t\t`user_id` int(11) NOT NULL DEFAULT '0',\n\t\t\t`cookie_value` varchar(22) NOT NULL,\n\t\t\tPRIMARY KEY (`id`)\n\t\t)"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); } // Set all post/page like, unlike, total meta data WtiUpdateLikeMetaData(); //adding options for the like post plugin add_option('wti_like_post_use_plugin_css', '1', '', 'yes'); add_option('wti_like_post_drop_settings_table', '0', '', 'yes'); add_option('wti_like_post_disable_auto_load', '0', '', 'yes'); add_option('wti_like_post_use_on_excerpt', '1', '', 'yes'); add_option('wti_like_post_voting_period', '0', '', 'yes'); add_option('wti_like_post_voting_style', 'style1', '', 'yes'); add_option('wti_like_post_alignment', 'left', '', 'yes'); add_option('wti_like_post_position', 'bottom', '', 'yes'); add_option('wti_like_post_login_required', '0', '', 'yes'); add_option('wti_like_post_default_message', __('Be the 1st to vote.', 'wti-like-post'), '', 'yes'); add_option('wti_like_post_login_message', __('Please login to vote.', 'wti-like-post'), '', 'yes'); add_option('wti_like_post_thank_message', __('Thanks for your vote.', 'wti-like-post'), '', 'yes'); add_option('wti_like_post_voted_message', __('You have already voted.', 'wti-like-post'), '', 'yes'); add_option('wti_like_post_min_like', '', '', 'yes'); add_option('wti_like_post_max_like', '', '', 'yes'); add_option('wti_like_post_apply_existing', '0', '', 'yes'); add_option('wti_like_post_post_types', 'post', '', 'yes'); add_option('wti_like_post_bp_like_activity', '0', '', 'yes'); add_option('wti_like_post_disallow_author_voting', '1', '', 'yes'); add_option('wti_like_post_author_disallowed_message', __('You can not vote your own post.', 'wti-like-post'), '', 'yes'); add_option('wti_like_post_allowed_posts', '', '', 'yes'); add_option('wti_like_post_excluded_posts', '', '', 'yes'); add_option('wti_like_post_allowed_categories', '', '', 'yes'); add_option('wti_like_post_excluded_categories', '', '', 'yes'); add_option('wti_like_post_excluded_sections', '', '', 'yes'); add_option('wti_like_post_show_on_pages', '0', '', 'yes'); add_option('wti_like_post_show_on_widget', '1', '', 'yes'); add_option('wti_like_post_show_symbols', '1', '', 'yes'); add_option('wti_like_post_show_dislike', '1', '', 'yes'); add_option('wti_like_post_title_text', 'Like/Unlike', '', 'yes'); add_option('wti_like_post_redirect_url', '', '', 'yes'); add_option('wti_like_post_like_text', 'Click to like it', '', 'yes'); add_option('wti_like_post_unlike_text', 'Click to unlike it', '', 'yes'); add_option('wti_like_post_show_like_unlike_text', '0', '', 'yes'); add_option('wti_like_post_show_user_likes', '0', '', 'yes'); add_option('wti_like_post_check_option', '0', '', 'yes'); add_option('wti_like_post_db_version', $wti_like_post_db_version, '', 'yes'); }