Fala ai galera, seguinte .. nao sou muito bom em php.. conheco mais sobre java e recetemente peguei um script para o meu site que se chama like-locker. e um pluggin para wordpress que consiste em:
este pluggin serve para voce trancar um determinado texto para ser visalizado somente para pessoas que ja tenham curtido a pagina no facebook setada no script, no caso a minha pagina no facebook.
segue um exemplo deste pluggin no meu site: http://cyber9pictures.com/template-typograph-after-effects/
bom, o problema que venho tendo e o seguinte, se um usuario ja tiver curtido a pagina e ele entrar pela primeira vez em uma maquina ( sem registro de cooks ou qualquer outra coisa ja existentes ) ele identifica que voce ja curtiu a pagina mas nao mostra o link travado. Para solucionar o problema
tenho tido que clicar em curtir ( quando ele esta cinza indicando que voce ja curtiu para remover o curtir) e em seguida curtir novamente para destravar a pagina.
gostaria de ajuda para resolver este problema! alguem pode me ajudar?
segue o script do mesmo:
________________________________________________________
<?php
/*
Plugin Name: Wordpress Like Locker
Plugin URI: http://tyler.tc/wp-like-locker/
Description: A great new way to add Facebook Fans to your wordpress powered site by offering premium content for liking your posts!
Version: 1.2.0
Author: Tyler Colwell
Author URI: http://tyler.tc
---------------------------------------------------
Copyright © 2011 Tyler Colwell ALL RIGHTS RESERVED
---------------------------------------------------
LICENSE TERMS http://codecanyon.net/wiki/support/legal-terms/licensing-terms/
*/
/*********************** START HOOKS ***********************/
// Install database if needed
register_activation_hook(__FILE__,'wplikelockerinstall');
// Create settings menu item in Admin
add_action('admin_menu', 'wplikelocker_menu');
// Load the Facebook SDK
add_action('init', 'jsloader');
// Include CSS in header
add_action('wp_head', 'wplikelockercss');
// Run LikeLocker on the post
add_filter('the_content','lockPost');
// Run the FBML parser in the footer to make sure the Like button appears
add_action('wp_footer', 'parseFBML');
// Add AJAX callbacks for tracking user clicks
add_action('wp_ajax_fbjax', 'likelockerCB');
add_action('wp_ajax_nopriv_fbjax', 'likelockerCB');
// Add cutom button to TinyMCE
add_filter('mce_external_plugins', "wplikelocker_mce_register");
add_filter('mce_buttons', 'wplikelocker_add_button', 0);
/*********************** END HOOKS ***********************/
// Create options menu item and register the settings
function wplikelocker_menu() {
// Adds the tab into the options panel in WordPress Admin area
add_options_page("Wordpress Like Locker Settings", "Like Locker", 'administrator', __FILE__, "wplikelocker_settings");
//call register settings function
add_action( 'admin_init', 'regsettings_wplikelocker' );
} // end menu maker
// Register settings function
function regsettings_wplikelocker() {
// Register our settings
register_setting( 'wplikelocker-settings-group', 'wplikelocker-message' );
register_setting( 'wplikelocker-settings-group', 'wplikelocker-url' );
} // end register settings
// Function to add button to TinyMCE editor
function wplikelocker_add_button($buttons){
// Create button class and return it
array_push($buttons, "separator", "wplikelockerplugin");
return $buttons;
} // end add button
// Register TinyMCE Button
function wplikelocker_mce_register($plugin_array){
// Get URL of TinyMCE plugin
$url = get_bloginfo('wpurl')."/wp-content/plugins/".basename(dirname(__FILE__))."/mce_button.js";
// Set to array and return it
$plugin_array['wplikelockerplugin'] = $url;
return $plugin_array;
} // end register TinyMCE button
// Main function will check if the user's IP has already been logged, if not, it will lock the content in the post with a Like button.
function lockPost($content){
// Define database variables
global $wpdb;
$table_name = $wpdb->prefix . "wplikelocker";
// Get post id and user's IP
$postID = get_the_ID();
$postURL = get_permalink($postID);
$ip = $_SERVER['REMOTE_ADDR'];
// See if there is a cookie set before checking for IP
$wpll_cookie = $_COOKIE["wpll".$postID.""];
// If cookie is not set, see if IP is in database
if($wpll_cookie != "true"){
// Check if the user has liked this post already
$check = $wpdb->get_results("SELECT * FROM $table_name WHERE post_url = '$postURL' AND ips = '$ip'");
// Legacy check for IP address instead of URL
$check2 = $wpdb->get_results("SELECT * FROM $table_name WHERE post_url = '$postID' AND ips = '$ip'");
// If not, filter the content betweetn the tags and lock it down with a like button
if(!$check || !$check2){
// I <3 Regex - Replace the content between the tags with the like button
$content = preg_replace("/<wp-like-locker>(.*)<\/wp-like-locker>/s", generateLike(), $content);
$content = preg_replace("/\[wp-like-locker\](.*)\[\/wp-like-locker\]/s", generateLike(), $content);
}
} // end if cookie not set
// Strip the tags from the post so they do not show
$replace = array("[wp-like-locker]", "[/wp-like-locker]");
$content = str_replace($replace, "", $content);
// Allways return the content after being filtered
return $content;
} // End Lock Post Function
// Function to generate the like button FBML
function generateLike(){
// Get the current post ID
$postID = get_the_ID();
// Get plugin options from DB
$wpll_message = get_option('wplikelocker-message');
$wpll_url = get_option('wplikelocker-url');
// Define the current post permalink for Facebook
if($wpll_url == "CURRENT"){
// Use current post permalink if url set to CURRENT
$wpll_use_url = "http://www.facebook.com/Sr.Arts";
} else {
// Otherwise use the user defined URL
$wpll_use_url = $wpll_url;
} // end if else
// Create FBML
$fbml = '
<div class="like-locker">
'.$wpll_message.'
<fb:like id="fbLikeButton" href="'.$wpll_use_url.'" show_faces="false" width="450"></fb:like>
</div>
';
// Return the Like Button FBML
return $fbml;
} // End Generate Like Function
// Callback function to update database on like click via AJAX
function likelockerCB(){
// Define database vars
global $wpdb;
$table_name = $wpdb->prefix . "wplikelocker";
// Get post info and IP to store
$postID = $_POST['post'];
$postURL = get_permalink($postID);
$ip = $_SERVER['REMOTE_ADDR'];
// Insert them into our database to keep track of likes
$wpdb->insert($table_name, array('post_url' => $postURL, 'ips' => $ip));
// Add cookie to users browser
setcookie("wpll".$postID."", "true", time()+31556952, "/");
}
// Function to include required JS and CSS in header
function wplikelockercss() {
// Include the CSS
echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"".get_bloginfo('wpurl')."/wp-content/plugins/".basename(dirname(__FILE__))."/like-locker.css\"> \n";
// Echo our per page post ID callback from facebok, when the user clicks like this function will be triggerd and their IP will be stored in the databse with the post ID
echo "
<script type=\"text/javascript\">
FB.Event.subscribe('edge.create', function(href){
var data = { post: '".get_the_ID()."', action: 'fbjax' };
jQuery.post('".admin_url( 'admin-ajax.php' )."', data, function(response) {
location.reload();
});
});
</script> \n
";
}
// Added to fix jQuery.function errors
// This will make sure all of the JS is only called once!
function jsloader() {
// Make sure we are not in the admin section
if (!is_admin()) {
// Flush the JS
wp_deregister_script('jquery');
wp_deregister_script('fbsdk');
// Register them with fresh calls
wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js');
wp_register_script('fbsdk', 'http://connect.facebook.net/en_US/all.js#xfbml=1');
// Include them
wp_enqueue_script('jquery');
wp_enqueue_script('fbsdk');
} // End if admin
} // End jsloader function
// On activation of plugin, install the database needed to track likes
function wplikelockerinstall() {
// Database vars
global $wpdb;
$table_name = $wpdb->prefix . "wplikelocker";
// Check if table already exists
if($wpdb->get_var("show tables like '$table_name'") != $table_name) {
// If not, generate the SQL
$sql = "
CREATE TABLE " . $table_name . " (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`post_url` VARCHAR( 250 ) NOT NULL ,
`ips` TEXT NOT NULL
);
";
// Then run the query to make it
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
// Set default options
add_option( 'wplikelocker-message', 'Para ver o conteúdo bloqueado clique em Like!' );
add_option( 'wplikelocker-url', 'CURRENT' );
} // End if
} // End installer function
// Parse FBML from the footer to ensure Like button loads
function parseFBML(){
// Sometimes when loading the Facebook SDK and FBML it is rendered before Facebook can catch up, by running a FBML parse at the end of the page we can ensure that the like button will appear to all users reguardless of load times.
echo'<script type="text/javascript">FB.XFBML.parse();</script>';
} // End parser function
function wplikelocker_settings() {
// If the save button is pressed:
if( isset($_POST['saveS']) ) {
// Save the posted value in the database
update_option('wplikelocker-message', $_POST['wplikelocker-message']);
update_option('wplikelocker-url', $_POST['wplikelocker-url']);
// Now we can display the options page HTML:
?>
<div class="updated"><p><strong><?php _e('settings saved.', 'menu-test' ); ?></strong></p></div>
<?php } ?>
<div class="wrap">
<h2>Wordpress Like Locker Settings</h2>
<form method="post" action="options.php">
<?php settings_fields( 'wplikelocker-settings-group' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">Message to Display:</th>
<td><input name="wplikelocker-message" type="text" value="<?php echo get_option('wplikelocker-message'); ?>" size="60" /></td>
</tr>
<tr valign="top">
<th scope="row"> </th>
<td><small>This will be the message that appears above the Like Button when content in your post is locked.</small></td>
</tr>
<tr valign="top">
<th scope="row">URL To 'Like':</th>
<td><input name="wplikelocker-url" type="text" id="wplikelocker-url" value="<?php echo get_option('wplikelocker-url'); ?>" size="60" /></td>
</tr>
<tr valign="top">
<th scope="row"> </th>
<td>This is the URL that will be 'Liked' when someone clicks the like button. You can also set this to 'CURRENT' to use the current post url.</td>
</tr>
</table>
<hr />
<p class="submit">
<input id="saveS" name="saveS" type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
</p>
</form>
</div>
<?php } ?>
___________________________________________________________________________________
se alguem me ajudar eu vou ficar mt grato! este script so existe pago e cheio de bugs desse jeito
se alguem conseguir concerta se quiser eu passo o resto do pluggin =D