WordPress.org

Plugin Directory

Changeset 451433


Ignore:
Timestamp:
10/15/11 20:18:50 (3 years ago)
Author:
SteveAtty
Message:

Version 2.0.2

Location:
wordbooker
Files:
4 added
13 edited
10 copied

Legend:

Unmodified
Added
Removed
  • wordbooker/tags/2.0.2/includes/wordbooker_cron.php

    r449609 r451433  
    200200        $all_pages_groups=array_merge($all_pages,$all_groups); 
    201201        $encoded_names=str_replace('\\','\\\\',serialize($all_pages_groups)); 
    202  
     202/* 
    203203 
    204204        try { 
     
    245245            } 
    246246        } 
     247*/ 
    247248 
    248249        wordbooker_debugger("Setting name as  : ",mysql_real_escape_string($fb_profile_info->name),0) ; 
  • wordbooker/tags/2.0.2/includes/wordbooker_facebook_curl.php

    r450021 r451433  
    7878        curl_setopt($ch, CURLOPT_URL, $url); 
    7979        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
     80    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
     81    curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/fb_ca_chain_bundle.crt'); 
    8082        $response = curl_exec($ch); 
    8183    $err_no=curl_errno($ch); 
     
    9597        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    9698    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
     99    curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/fb_ca_chain_bundle.crt'); 
    97100     curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
    98101        $response = curl_exec($ch); 
  • wordbooker/tags/2.0.2/includes/wordbooker_facebook_fopen.php

    r449609 r451433  
    2828global $wp_version; 
    2929 
    30 function wordbooker_make_fopen_call($url) { 
    31     $ch = curl_init(); 
    32         curl_setopt($ch, CURLOPT_URL, $url); 
    33         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    34         $response = curl_exec($ch); 
    35     $err_no=curl_errno($ch); 
    36         curl_close($ch); 
    37     $x=json_decode($response); 
    38     if (isset($x->error_code)) {  
    39         throw new Exception ($x->error_msg); 
    40     } 
    41      return($x); 
     30function wordbooker_make_fopen_post_call($url, $data, $optional_headers = null) { 
     31      $params = array('http' => array( 
     32              'method' => 'POST', 
     33              'content' => $data 
     34            )); 
     35      if ($optional_headers !== null) { 
     36        $params['http']['header'] = $optional_headers; 
     37      } 
     38      $ctx = stream_context_create($params); 
     39      $fp = @fopen($url, 'rb', false, $ctx); 
     40      if (!$fp) { 
     41        throw new Exception("Problem with $url, $php_errormsg"); 
     42      } 
     43      $response = @stream_get_contents($fp); 
     44      if ($response === false) { 
     45        throw new Exception("Problem reading data from $url, $php_errormsg"); 
     46      } 
     47      return $response; 
    4248} 
    4349 
    4450 
    4551 
    46 function wordbooker_make_fopen_post_call($url, $params, $ch=null) { 
    47      
    48     $content = ""; 
    49     foreach ($params as $key => $param) { 
    50         $content .= "{$key}=" . urlencode($param) . "&"; 
    51     } 
    52     substr($post, 0, strlen($post) - 1); 
    53      
    54     $user_agent = 'Wordbooker Version 2 (non-curl) ' . phpversion(); 
    55     $content_type = 'application/x-www-form-urlencoded'; 
    56      
    57     $content_length = strlen($content); 
    58     $context = 
    59       array('http' => 
    60               array('method' => 'POST', 
    61                     'user_agent' => $user_agent, 
    62                     'header' => 'Content-Type: ' . $content_type . "\r\n" . 
    63                                 'Content-Length: ' . $content_length, 
    64                     'content' => $content)); 
    65     $context_id = stream_context_create($context); 
    66     $sock = @fopen($url, 'r', false, $context_id); 
    67  
    68     $result = ''; 
    69     if ($sock) { 
    70       while (!feof($sock)) { 
    71         $result .= fgets($sock, 4096); 
    72       } 
    73       fclose($sock); 
    74     } 
    75  
    76     //error_log("MAKE REQUEST RESULT : " . $result); 
    77  
    78     return $result;     
    79      
    80   } 
     52function wordbooker_make_fopen_call($url, $params, $optional_headers = null) { 
     53      $params = array('http' => array( 
     54              'content' => $data 
     55            )); 
     56      if ($optional_headers !== null) { 
     57        $params['http']['header'] = $optional_headers; 
     58      } 
     59      $ctx = stream_context_create($params); 
     60      $fp = @fopen($url, 'rb', false, $ctx); 
     61      if (!$fp) { 
     62        throw new Exception("Problem with $url, $php_errormsg"); 
     63      } 
     64      $response = @stream_get_contents($fp); 
     65      if ($response === false) { 
     66        throw new Exception("Problem reading data from $url, $php_errormsg"); 
     67      } 
     68      return $response; 
     69} 
    8170?> 
  • wordbooker/tags/2.0.2/includes/wordbooker_options.php

    r449609 r451433  
    9393    // If no default author set, lets set it 
    9494    if (! isset($wordbooker_settings["wordbooker_default_author"])){ $wordbooker_settings["wordbooker_default_author"]=0;} 
    95     // If no default republish time frame set, then set it. 
    96     if (! isset($wordbooker_settings["wordbooker_republish_time_frame"])){ $wordbooker_settings["wordbooker_republish_time_frame"]=10;} 
    9795    // If no attribute set, then set it. 
    9896    if (! isset($wordbooker_settings["wordbooker_attribute"])){ $wordbooker_settings["wordbooker_attribute"]= __("Posted a new post on their blog");} 
     
    10199    // No Share link set, then set it 
    102100    if (! isset($wordbooker_settings["wordbooker_actionlink"])){ $wordbooker_settings["wordbooker_actionlink"]=300;} 
    103     // No andor set, then set it 
    104     if (! isset($wordbooker_settings['wordbooker_orandpage'])){ $wordbooker_settings['wordbooker_orandpage']=2;} 
    105101    // No extract length 
    106102    if (! isset($wordbooker_settings['wordbooker_extract_length'])) {$wordbooker_settings['wordbooker_extract_length']=256;} 
     
    243239        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_publish_no_user]" '.$checked_flag[$wordbooker_settings["wordbooker_publish_no_user"]].' ><br />'; 
    244240 
     241        echo '<label for="wb_publish_user_publish">'.__("Allow non Wordbooker users to chose to publish a post"). ' : </label>'; 
     242        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_allow_publish_select]" '.$checked_flag[$wordbooker_settings["wordbooker_allow_publish_select"]].' ><br />'; 
     243 
    245244                echo '<label for="wb_extract_length">'.__('Length of Extract').' :</label> <select id="wordbooker_extract_length" name="wordbooker_settings[wordbooker_extract_length]"  >'; 
    246245            $arr = array(10=> "10",20=> "20",50=> "50",100=> "100",120=> "120",150=> "150",175=> "175",200=> "200",  250=> "250", 256=>__("256 (Default) "), 270=>"270", 300=>"300", 350 => "350",400 => "400",500 => "500",600 => "600",700 => "700",800 => "800",900 => "900"); 
     
    299298        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_like_button_post]" '.$checked_flag[$wordbooker_settings["wordbooker_like_button_post"]].' ><br />'; 
    300299 
     300        echo '<label for="wb_facebook_like">&nbsp;'.__("Don't show Facebook Like / Send Button on Sticky Posts"). ' : </label>'; 
     301        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_no_like_stick]" '.$checked_flag[$wordbooker_settings["wordbooker_no_like_stick"]].' ><br />'; 
     302 
     303 
    301304            if (!is_numeric($wordbooker_settings['wordbooker_like_width']) || $wordbooker_settings['wordbooker_like_width'] <0) {$wordbooker_settings['wordbooker_like_width']=250;} 
    302305        echo '<label for="wb_facebook_like_width">&nbsp;'.__("Width of Facebook Like box"). ' : </label>'; 
     
    340343 
    341344 
    342         echo '<label for="wb_fblike_send_combi">&nbsp;'.__('Combine Send with Like').' :</label> <select id="wordbook_fblike_send_combi" name="wordbooker_settings[wordbooker_fblike_send_combi]"  >'; 
     345        echo '<label for="wb_fblike_send_combi">&nbsp;'.__('Combine Send with Like').' :</label> <select id="wordbooker_fblike_send_combi" name="wordbooker_settings[wordbooker_fblike_send_combi]"  >'; 
    343346        foreach ($fblike_send_combi as $i => $value) { 
    344347            if ($i==$wordbooker_settings['wordbooker_fblike_send_combi']){ print '<option selected="yes" value="'.$i.'" >'.$fblike_send_combi[$i].'</option>';} 
     
    346349        echo "</select><br/> "; 
    347350 
    348         echo '<label for="wb_fblike_send">&nbsp;'.__('Facebook Send - Display Button').' :</label> <select id="wordbook_fblike_send" name="wordbooker_settings[wordbooker_fblike_send]"  >'; 
     351        echo '<label for="wb_fblike_send">&nbsp;'.__('Facebook Send - Display Button').' :</label> <select id="wordbooker_fblike_send" name="wordbooker_settings[wordbooker_fblike_send]"  >'; 
    349352        foreach ($fblike_send as $i => $value) { 
    350353            if ($i==$wordbooker_settings['wordbooker_fblike_send']){ print '<option selected="yes" value="'.$i.'" >'.$fblike_send[$i].'</option>';} 
     
    374377        echo '<label for="wb_facebook_share_post">&nbsp;'.__("Show Facebook Share button in each post"). ' : </label>'; 
    375378        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_share_button_post]" '.$checked_flag[$wordbooker_settings["wordbooker_share_button_post"]].' ><br />'; 
    376  
     379        echo '<label for="wb_facebook_like">&nbsp;'.__("Don't show Facebook Share button on Sticky Posts"). ' : </label>'; 
     380        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_no_share_stick]" '.$checked_flag[$wordbooker_settings["wordbooker_no_share_stick"]].' ><br />'; 
    377381 
    378382} 
  • wordbooker/tags/2.0.2/includes/wordbooker_posting_options.php

    r449609 r451433  
    6060        $wordbooker_settings=$post_meta; 
    6161    } 
     62#var_dump($wordbooker_settings["wordbooker_post_edited"]); 
     63    $post_pub_prompt=__("Publish this post to Facebook"); 
     64    if($post->post_type=='page'){ 
     65        $publish=$wordbooker_settings["wordbooker_publish_page_default"];        
     66        $post_pub_prompt=__("Publish this page to Facebook"); 
     67    } 
     68    else { 
     69        $publish=$wordbooker_settings["wordbooker_publish_post_default"]; 
     70            $post_pub_prompt=__("Publish this post to Facebook"); 
     71    } 
     72 
     73    #var_dump($post->post_status); 
     74    if($wordbooker_settings["wordbooker_post_edited"]!='yes') {$wordbooker_settings["wordbooker_publish_default"]=$publish;} 
     75    if ($post->post_status=="publish") {$wordbooker_settings["wordbooker_publish_default"]='';} 
    6276    if (wordbooker_get_userdata($user_ID)) { 
    63         if (! isset($wordbooker_settings['wordbooker_page_post'])) { $wordbooker_settings['wordbooker_page_post']=-100;} 
    64         if (! isset($wordbooker_settings['wordbooker_orandpage'])) { $wordbooker_settings['wordbooker_orandpage']= 2; } 
    65         echo '<input type="hidden" name="wordbooker_page_post" value="-100" />'; 
    66         echo '<input type="hidden" name="wordbooker_orandpage" value="2" />'; 
     77 
    6778        echo __("The following options override the defaults set on the options page")."<br /><br />"; 
    6879        $sql="select wpu.ID,wpu.display_name,facebook_id from $wpdb->users wpu,".WORDBOOKER_USERDATA." wud where wpu.ID=wud.user_id;"; 
     
    7485        $fanpages[]=array( 'id'=>'PW:'.$wb_users[0]->facebook_id, 'name'=>"Personal Wall"); 
    7586        $have_fan_pages=0; 
    76         $post_pub_prompt=__("Publish this post to Facebook"); 
    77         if($post->post_type=='page'){ 
    78             $wordbooker_settings["wordbooker_publish_default"]=$wordbooker_settings["wordbooker_publish_page_default"];      
    79             $post_pub_prompt=__("Publish this page to Facebook"); 
    80         } 
    81         if($post->post_type=='post'){ 
    82             $wordbooker_settings["wordbooker_publish_default"]=$wordbooker_settings["wordbooker_publish_post_default"]; 
    83                 $post_pub_prompt=__("Publish this post to Facebook"); 
    84         } 
     87 
    8588        # If the post has already been published then we uncheck the publish option  
    86         if ($post->post_status=='publish') {$wordbooker_settings["wordbooker_publish_default"]='';} 
     89         
    8790        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_publish_default" '.$checked_flag[$wordbooker_settings["wordbooker_publish_default"]].' > '.$post_pub_prompt.'<br />'; 
    8891 
     
    133136 
    134137        echo __('Length of Extract').' : <select id="wordbooker_extract_length" name="wordbooker_extract_length"  >'; 
    135         $arr = array( 10=> "10",20=> "20",50=> "50",100=> "100",120=> "120",150=> "150",175=> "175", 200=> "200",  250=> "250", 256=>"256", 270=>"270", 300=>"300", 350 => "350",400 => "400"); 
     138            $arr = array(10=> "10",20=> "20",50=> "50",100=> "100",120=> "120",150=> "150",175=> "175",200=> "200",  250=> "250", 256=>__("256 (Default) "), 270=>"270", 300=>"300", 350 => "350",400 => "400",500 => "500",600 => "600",700 => "700",800 => "800",900 => "900"); 
    136139            foreach ($arr as $i => $value) { 
    137140                    if ($i==$wordbooker_settings['wordbooker_extract_length']){ print '<option selected="yes" value="'.$i.'" >'.$arr[$i].'</option>';} 
     
    149152        echo '<input type="hidden" name="soupy" value="twist" />'; 
    150153 
    151     #   var_dump($post->post_type); 
    152     #   var_dump($post->post_status); 
    153     #   if ($wordbooker_settings["wordbooker_publish_default"]=='published') {$wordbooker_settings["wordbooker_publish_default"]='';} 
    154  
    155  
    156154    #   echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_publish_override" '.$checked_flag[$wordbooker_settings["wordbooker_publish_override"]].' >'.__('Force Re-Publish Post to Facebook on Edit (overrides republish window)').'<br />'; 
    157155        if ( function_exists( 'get_the_post_thumbnail' ) ) { 
     
    162160        echo 'Facebook Post Attribute line: <INPUT NAME="wordbooker_attribute" size=80 maxlength=240 value="'.stripslashes($wordbooker_settings["wordbooker_attribute"]).'"><br />';     
    163161        echo __('Facebook Status Update text').' : <INPUT NAME="wordbooker_status_update_text" size=60 maxlength=240 value="'.stripslashes($wordbooker_settings["wordbooker_status_update_text"]).'"><br />'; 
    164  
    165         if($post->post_type=='post'){ 
    166  
    167             if(!isset($wordbooker_settings['wordbooker_like_button_post'])) {$wordbooker_settings['wordbooker_like_button_post']=1;} 
    168             if(!isset($wordbooker_settings['wordbooker_share_button_post'])) {$wordbooker_settings['wordbooker_share_button_post']=1;} 
    169             echo __('Show Facebook Like/Send for this Post').' : <select id="wordbooker_like_button_post" name="wordbooker_like_button_post"  >'; 
    170             $arr = array(1=> __("Yes"),  2=> __("No") ); 
    171                 foreach ($arr as $i => $value) { 
    172                     if ($i==$wordbooker_settings['wordbooker_like_button_post']){ print '<option selected="yes" value="'.$i.'" >'.$arr[$i].'</option>';} 
    173                        else {print '<option value="'.$i.'" >'.$arr[$i].'</option>';} 
    174                 } 
    175                 echo "</select><br />"; 
    176          
    177             echo __('Show Facebook Share for this Post').' : <select id="wordbooker_share_button_post" name="wordbooker_share_button_post"  >'; 
    178             $arr = array(1=> __("Yes"),  2=> __("No") ); 
    179                 foreach ($arr as $i => $value) { 
    180                     if ($i==$wordbooker_settings['wordbooker_share_button_post']){ print '<option selected="yes" value="'.$i.'" >'.$arr[$i].'</option>';} 
    181                        else {print '<option value="'.$i.'" >'.$arr[$i].'</option>';} 
    182                 } 
    183                 echo "</select><br />"; 
    184         } 
    185162 
    186163        if($post->post_type=='page'){ 
     
    203180            echo "</select><br />"; 
    204181        } 
     182        else { 
     183 
     184            if(!isset($wordbooker_settings['wordbooker_like_button_post'])) {$wordbooker_settings['wordbooker_like_button_post']=1;} 
     185            if(!isset($wordbooker_settings['wordbooker_share_button_post'])) {$wordbooker_settings['wordbooker_share_button_post']=1;} 
     186            echo __('Show Facebook Like/Send for this Post').' : <select id="wordbooker_like_button_post" name="wordbooker_like_button_post"  >'; 
     187            $arr = array(1=> __("Yes"),  2=> __("No") ); 
     188                foreach ($arr as $i => $value) { 
     189                    if ($i==$wordbooker_settings['wordbooker_like_button_post']){ print '<option selected="yes" value="'.$i.'" >'.$arr[$i].'</option>';} 
     190                       else {print '<option value="'.$i.'" >'.$arr[$i].'</option>';} 
     191                } 
     192                echo "</select><br />"; 
     193         
     194            echo __('Show Facebook Share for this Post').' : <select id="wordbooker_share_button_post" name="wordbooker_share_button_post"  >'; 
     195            $arr = array(1=> __("Yes"),  2=> __("No") ); 
     196                foreach ($arr as $i => $value) { 
     197                    if ($i==$wordbooker_settings['wordbooker_share_button_post']){ print '<option selected="yes" value="'.$i.'" >'.$arr[$i].'</option>';} 
     198                       else {print '<option value="'.$i.'" >'.$arr[$i].'</option>';} 
     199                } 
     200                echo "</select><br />"; 
     201        } 
     202 
     203 
    205204        if ($wordbooker_global_settings['wordbooker_comment_handling']=="1"){ 
    206205        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_comment_get" '.$checked_flag[$wordbooker_settings["wordbooker_comment_get"]].' > '.__('Fetch comments from Facebook for this post').'<br />';} 
    207206        if ($wordbooker_global_settings['wordbooker_comment_handling']=="2"){ 
    208207        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_use_facebook_comments" '.$checked_flag[$wordbooker_settings["wordbooker_use_facebook_comments"]].' > '.__('Enable Facebook Comments for this post').'<br />';} 
    209     } else { 
    210         echo "Wordbooker Blog level settings are in force";  
    211         } 
    212  
     208    }  else { 
     209echo "<p>Wordbooker Blog level settings are in force<br /></p>"; 
     210 
     211if ( isset($wordbooker_settings['wordbooker_allow_publish_select'])) {  
     212echo '<input type="hidden" name="crabstick" value="stairwell" />'; 
     213echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_publish_default" '.$checked_flag[$wordbooker_settings["wordbooker_publish_default"]].' > '.__('Publish This Post to Facebook').'<br />'; 
     214#echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_publish_override" '.$checked_flag[$wordbooker_settings["wordbooker_publish_override"]].' >'.__('Force Re-Publish Post to Facebook on Edit (overrides republish window)').'<br />'; 
     215} else { echo '<input type="hidden" name="wordbooker_publish_default" value="'.$wordbooker_settings["wordbooker_publish_default"].'" />';} 
     216} 
     217 
     218echo '<input type="hidden" name="wordbooker_publish_page_default" value="'.$wordbooker_settings["wordbooker_publish_page_default"].'" />'; 
     219echo '<input type="hidden" name="wordbooker_publish_post_default" value="'.$wordbooker_settings["wordbooker_publish_post_default"].'" />'; 
     220echo '<input type="hidden" name="wordbooker_post_edited" value="yes" />'; 
    213221} 
    214222 
  • wordbooker/tags/2.0.2/includes/wordbooker_wb_widget.php

    r449609 r451433  
    104104        $ds12=date('D M j, g:i a'); 
    105105        $dl12=date('l F j, g:i a'); 
    106         $dl24=date('l F j, h:i'); 
    107         $ds24=date('D M j, h:i'); 
     106        $dl24=date('l F j, G:i'); 
     107        $ds24=date('D M j, G:i'); 
    108108        $drfc=date('r'); 
    109         $arr = array('D M j, g:i a'=> $ds12,  'l F j, g:i a'=> $dl12, 'D M j, h:i'=>$ds24, 'l F j, h:i'=>$dl24,fbt=>__("Facebook Text style",'wordbooker'), r =>$drfc); 
     109        $arr = array('D M j, g:i a'=> $ds12,  'l F j, g:i a'=> $dl12, 'D M j, G:i'=>$ds24, 'l F j, G:i'=>$dl24,fbt=>__("Facebook Text style",'wordbooker'), r =>$drfc); 
    110110        foreach ($arr as $i => $value) { 
    111111        if ($i==attribute_escape( $instance['df'])){ print '<option selected="yes" value="'.$i.'" >'.$arr[$i].'</option>';} 
     
    115115    } 
    116116} 
    117  
    118  
    119117 
    120118/* register widget when loading the WP core */ 
     
    126124    register_widget('WordbookWidget'); 
    127125} 
    128  
    129  
    130126 
    131127 
  • wordbooker/tags/2.0.2/readme.txt

    r450021 r451433  
    55Requires at least: 2.9 
    66Tested up to: 3.2.1 
    7 Stable tag: 2.0.1 
     7Stable tag: 2.0.2 
    88 
    99This plugin allows you to cross-post your blog posts to your Facebook Wall and to any Facebook Fan Page / Group that you are an administrator for. The base release of Version 2 DOES NOT support comment handling - this is because V2 had to be pushed out to meet deadlines imposed by Facebook concerning application authorisation. Comment handling will be added in the first major 2.x release. 
     
    119119== Changelog == 
    120120 
     121= Version 2.0.2 15/10/2011 = 
     122- Fixed a bug with app-id/fb:admins which made comment moderation go wrong. 
     123- Fixed a bug in the target handling code where a variable was not being set correctly leading to confusing error message 
     124- Changed Curl calls to supress errors (for sites where curl is blocked/broken and craps the code out) 
     125- Changed FB comment code to supress comment boxes on anything but single post pages (as it seems to upset Facebook). 
     126- Fixed a bug concerning "Publish As" which meant it wasn't working properly. 
     127- Restored an option to allow Non Wordbooker users to chose if a post should be published or not. 
     128- Restored the option to supress like/share/send on Sticky Posts 
     129- Fixed a bug with the og: description tag not being populated. 
     130- Changed logic so og:tags are put out all the time unless you've checked the option to disable them all. 
     131- Fixed a bug where an array was parsed for data even if it didn't exist. 
     132- Fixed a bug where "post attribute" was missing. 
     133- Fixed a bug where when extract length was set to more than 400 it got reset to either 10 or 256 
     134- Added a check so that if a post has no images a blank is loaded to stop Facebook from scraping the page. 
     135- Changed logic so that Posting Options checks if a post is to a page and if not defaults to a post. This should provide a short term work round for custom post types. 
     136- Fixed a bug where the diagnostics reporting which target was active or not didn't show the right target. 
     137- Fixed a bug where the new publish options were being lost when you scheduled a post or saved a draft and then exited and edited the post later. 
     138- Fixed a bug where if you set the "Deactivate Wordbooker functionality" then it crashed out with a fatal error 
     139- 24 hour time formats on the FB Status Widget weren't set correctly 
     140- Added the X509 cert bundle for Curl installs without it properly installed. 
     141 
     142 
    121143= Version 2.0.1 11/10/2011 = 
    122144- Fixed a logic mistake concerning Share on Pages/Front pages 
     
    124146- Fixed a bug where Like counts didn't work because the url was missing. 
    125147- Put an extra option into the Curl Call which might fix issues with certificate bundles. 
     148- Fixed a bug with app-id/fb:admins which made comment moderation go wrong. 
    126149 
    127150 
  • wordbooker/tags/2.0.2/wordbooker.php

    r450021 r451433  
    22/* 
    33Plugin Name: Wordbooker 
    4 Plugin URI: http://worbooker.tty.org.uk 
     4Plugin URI: http://wordbooker.tty.org.uk 
    55Description: Provides integration between your blog and your Facebook account. Navigate to <a href="options-general.php?page=wordbooker">Settings &rarr; Wordbooker</a> for configuration. 
    66Author: Steve Atty  
    77Author URI: http://wordbooker.tty.org.uk 
    8 Version: 2.0.1 
     8Version: 2.0.2 
    99*/ 
    1010 
     
    4343define('WORDBOOKER_DEBUG', false); 
    4444define('WORDBOOKER_TESTING', false); 
    45 define('WORDBOOKER_CODE_RELEASE','2.0.1 - Letters To A Young Rose '); 
     45define('WORDBOOKER_CODE_RELEASE','2.0.2 - Jugglers in Obsidian '); 
    4646 
    4747# For Troubleshooting  
     
    6565define('WORDBOOKER_FB_APIVERSION', '1.0'); 
    6666define('WORDBOOKER_FB_DOCPREFIX','http://wiki.developers.facebook.com/index.php/'); 
    67 #define('WORDBOOKER_FB_MAXACTIONLEN', 60); 
    6867define('WORDBOOKER_FB_PUBLISH_STREAM', 'publish_stream'); 
    6968define('WORDBOOKER_FB_READ_STREAM', 'read_stream'); 
     
    350349        if ($result === false) 
    351350            $errors[] = __('Failed to create ') . WORDBOOKER_PROCESS_QUEUE ; 
    352  
    353  
    354351 
    355352    if ($errors) { 
     
    532529    wordbooker_debugger("Post modified : ",$rows[0]->post_modified,$post_id) ; 
    533530    wordbooker_debugger("Post status : ",$rows[0]->post_status,$post_id) ; 
    534     wordbooker_debugger("Post status flag : ",$wbo['wordbook_new_post'],$post_id) ; 
    535     wordbooker_debugger("Scheduled Post: ",$wbo['wordbook_scheduled_post'],$post_id) ; 
     531    wordbooker_debugger("Post status flag : ",$wbo['wordbooker_new_post'],$post_id) ; 
     532    wordbooker_debugger("Scheduled Post: ",$wbo['wordbooker_scheduled_post'],$post_id) ; 
    536533         
    537534    if ($tstamp==1 && !isset($_POST['original_post_status']) && !isset($_POST['screen'])) {return 0;} 
     
    541538    # If the post is new then return false 
    542539    if ($rows[0]->post_date == $rows[0]->post_modified) {return false;} 
    543     if ($wbo['wordbook_scheduled_post']!=0) { 
    544         $wbo['wordbook_scheduled_post']=0; 
     540    if ($wbo['wordbooker_scheduled_post']!=0) { 
     541        $wbo['wordbooker_scheduled_post']=0; 
    545542        $y=update_post_meta($post_id, '_wordbooker_options', $wbo);  
    546543        return false; 
    547544    } 
    548     if ($wbo['wordbook_new_post']!=0) {  
    549         $wbo['wordbook_new_post']=0; 
     545    if ($wbo['wordbooker_new_post']!=0) {  
     546        $wbo['wordbooker_new_post']=0; 
    550547        $y=update_post_meta($post_id, '_wordbooker_options', $wbo);  
    551548        return false; 
     
    839836    $errormsg = null; 
    840837    if (!function_exists('curl_init')) { 
    841     #$errormsg .=  'Wordbooker needs the CURL PHP extension to work. Please install / enable it and try again <br />'; 
     838        $errormsg .=  'Wordbooker needs the CURL PHP extension to work. Please install / enable it and try again <br />'; 
    842839    } 
    843840    if (!function_exists('json_decode')) { 
     
    11041101       curl_setopt($ch, CURLOPT_HEADER, 0); 
    11051102       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
     1103       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
     1104       curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/includes/fb_ca_chain_bundle.crt'); 
    11061105       curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0'); 
    1107        $curlcontent = curl_exec($ch); 
     1106       $curlcontent = @curl_exec($ch); 
    11081107       $x=json_decode($curlcontent); 
    11091108    #var_dump($x->name); 
    1110        $curlstatus="Curl is available but cannot access Facebook - This is a problem (".curl_errno($ch)." )"; 
     1109       $curlstatus="Curl is available but cannot access Facebook - This is a problem (".curl_errno($ch)." - ". curl_error($ch) ." )"; 
    11111110       if ($x->name=="Facebook Platform") {$curlstatus="Curl is available and can access Facebook - All is OK";} 
    1112   curl_close($ch); 
     1111    curl_close($ch); 
    11131112    } 
    11141113 
     
    12221221function wordbooker_fbclient_publishaction($wbuser,$post_id)  
    12231222{    
    1224     global $wordbooker_post_options; 
     1223    global $wordbooker_post_options,$wpdb; 
    12251224    $wordbooker_settings =wordbooker_options();  
    12261225    $post = get_post($post_id); 
     
    13371336    } 
    13381337 
    1339     # Strip images from various plugins 
    1340     $images=array_filter($images, "wordbooker_strip_images"); 
    1341     # And limit it to 5 pictures to keep Facebook happy. 
    1342     $images = array_slice($images, 0, 5); 
    1343  
    1344     if (is_array($images)){ 
     1338    if (count($images)>0){ 
     1339        # Strip images from various plugins 
     1340        $images=array_filter($images, "wordbooker_strip_images"); 
     1341        # And limit it to 5 pictures to keep Facebook happy. 
     1342        $images = array_slice($images, 0, 5); 
    13451343        foreach ($images as $key){ 
    13461344            wordbooker_debugger("Post Images : ".$key['src'],'',$post->ID) ; 
    13471345        } 
    1348     } 
     1346    } else {  
     1347        $images[]=get_bloginfo('wpurl').'wp-contents/plugins/wordbooker/includes/wordbooker_blank.jpg'; 
     1348        wordbooker_debugger("No Post images found so loading blank to keep Facebook happy ",'',$post->ID) ; } 
    13491349 
    13501350    $wordbooker_settings =wordbooker_options();  
     
    13551355        $post_content=$post->post_excerpt; } 
    13561356    else {  $post_content=wordbooker_post_excerpt($post_content,$wordbooker_post_options['wordbooker_extract_length']);} 
    1357  
     1357    update_post_meta($post->ID,'_wordbooker_extract',$post_content); 
    13581358    # this is getting and setting the post attributes 
    13591359    $post_attribute=parse_wordbooker_attributes(stripslashes($wordbooker_post_options["wordbooker_attribute"]),$post_id,strtotime($post->post_date)); 
     
    13801380    } 
    13811381    $post_id=$post->ID; 
    1382 #   $attachment =  array( 
    1383 #     'name' => $post_data['post_title'], 
    1384 #     'href' => $post_data['post_link'], 
    1385 #     'description' => $post_data['post_excerpt'], 
    1386 #     'media' => $post_data['media'] 
    1387 #   ); 
     1382 
    13881383    $wordbooker_fb_post = array( 
    13891384      'name' => $post_data['post_title'], 
    13901385      'link' => $post_data['post_link'], 
     1386      'message'=> $post_data['post_attribute'], 
    13911387      'description' => $post_data['post_excerpt'], 
    13921388      'media' => json_encode($images) 
     
    14121408    } 
    14131409 
    1414 # All of this needs totally re-writing. What we need to do is loop through the two post targets and process each target and target type in turn.  
    1415  
    14161410    $posting_array[] = array('target'=>$wordbooker_post_options['wordbooker_primary_target'],  
    14171411                 'target_type'=>$wordbooker_post_options['wordbooker_primary_type'], 
     
    14221416 
    14231417    foreach($posting_array as $posting_target) { 
    1424         if (isset($posting_target['target_active'])) { 
    1425             $access_token='dummy access token'; 
     1418    $access_token='dummy access token'; 
     1419        if(count($wbuser->pages)>0){ 
    14261420            foreach ($wbuser->pages as $pager) { 
    14271421                if ($pager['id']==$posting_target['target']) { 
    1428                 $target_name=$pager['name']; 
    1429                 $access_token=$pager['access_token'];} 
    1430             } 
     1422                    $target_name=$pager['name']; 
     1423                    $access_token=$pager['access_token']; 
     1424                } 
     1425            } 
     1426        } 
     1427        if (isset($posting_target['target_active'])) { 
     1428 
     1429            wordbooker_debugger("Posting to target ".$target_name,"",$post_id,99) ;  
    14311430            if ($access_token=='dummy access token') {$access_token=$wbuser->access_token;} 
    14321431            $target=substr($posting_target['target'],3); 
     
    15711570    $bdesc=get_bloginfo('description'); 
    15721571    $wordbooker_settings = wordbooker_options();     
    1573     if ( (isset($wordbooker_settings['wordbooker_like_button_show']) || isset($wordbooker_settings['wordbooker_like_share_too']))) { 
     1572    # Always put out the tags because even if they are not using like/share it gives Facebook stuff to work with. 
    15741573        $wordbooker_post_options= get_post_meta($post->ID, '_wordbooker_options', true);  
    15751574        $wpuserid=$post->post_author; 
     
    15801579        $blog_name=get_bloginfo('name'); 
    15811580        echo '<meta property="og:site_name" content="'.$bname.' - '.$bdesc.'"/> '; 
    1582  
     1581        if (strlen($wordbooker_settings["fb_comment_app_id"])<6) { 
    15831582        if ($wordbooker_settings['wordbooker_fb_comments_admin']) { 
    15841583            $xxx=wordbooker_get_cache(-99,facebook_id,1); 
     
    15931592            } 
    15941593         } 
    1595     #var_dump($wordbooker_settings); 
     1594        } 
    15961595        if (strlen($wordbooker_settings["fb_comment_app_id"])>6) { 
    15971596            echo '<meta property = "fb:app_id" content = "'.$wordbooker_settings["fb_comment_app_id"].'" /> '; 
     
    16201619            echo '<meta property="og:type" content="blog"/> '; 
    16211620        } 
    1622     }        
    1623  
    1624         #wordbooker_get_option('wordbook_description_meta_length') 
     1621        #wordbooker_get_option('wordbooker_description_meta_length') 
    16251622    if ($meta_length = wordbooker_get_option('wordbooker_description_meta_length')) { 
    16261623        if (is_single() || is_page()) { 
    16271624            $excerpt=get_post_meta($post->ID, '_wordbooker_extract', TRUE); 
     1625            if(strlen($excerpt) < 3 ) { 
     1626                $excerpt=wordbooker_post_excerpt($post->post_content,$wordbooker_post_options['wordbooker_extract_length']); 
     1627                update_post_meta($post->ID, '_wordbooker_extract', $excerpt); 
     1628            } 
    16281629            # If we've got an excerpt use that instead 
    16291630            if ((strlen($post->post_excerpt)>3) && (strlen($excerpt) <=3)) {  
     
    16611662    return $blah; 
    16621663} 
    1663 /* 
    1664 function wordbooker_fb_tags_insert($content) { 
    1665  
    1666      if(strpos($content, '[[WB_FB_LIKE]]') > 0)  
    1667         { 
    1668           $content = str_replace('[[WB_FB_LIKE]]',wordbooker_fb_like(true),$content); 
    1669         } 
    1670  
    1671      if(strpos($content, '[[WB_FB_SEND]]') > 0)  
    1672         { 
    1673           $content = str_replace('[[WB_FB_SEND]]',wordbooker_fb_send(true),$content); 
    1674         } 
    1675  
    1676      if(strpos($content, '[[WB_FB_SHARE]]') > 0)  
    1677         { 
    1678           $content = str_replace('[[WB_FB_SHARE]]',wordbooker_fb_share(true),$content); 
    1679         } 
    1680       return $content; 
    1681  
    1682      if(strpos($content, '[[WB_FB_COMMENT]]') > 0)  
    1683         { 
    1684           $content = str_replace('[[WB_FB_COMMENT]]',wordbooker_fb_comment(true),$content); 
    1685         } 
    1686       return $content; 
    1687  
    1688 } 
    1689 */ 
     1664 
    16901665function display_wordbooker_fb_comment() { 
    16911666    global $post; 
     1667    if(!is_single()){return;} 
    16921668    $wordbooker_settings = wordbooker_options();  
    16931669    $wordbooker_post_options= get_post_meta($post->ID, '_wordbooker_options', true);   
     
    17021678function wordbooker_fb_comment_inline() { 
    17031679    global $post; 
     1680    if(!is_single()){return;} 
    17041681    $wordbooker_settings = wordbooker_options();  
    17051682    $wordbooker_post_options= get_post_meta($post->ID, '_wordbooker_options', true);   
     
    17241701    if (isset($wordbooker_settings['wordbooker_share_button_frontpage'])  && is_front_page() ) {$do_share=1;} 
    17251702    if (isset($wordbooker_settings['wordbooker_share_button_category']) &&  is_category()  ) {$do_share=1;} 
     1703    if (isset($wordbooker_settings['wordbooker_no_share_stick']) &&  is_sticky()  ) {$do_share=0; } 
    17261704    if ( $do_share==1  && 
    17271705    ((isset($wordbooker_settings['wordbooker_share_button_post']) && is_single()  ) 
     
    17591737    if (isset($wordbooker_settings['wordbooker_share_button_frontpage'])  && is_front_page() ) {$do_share=1;} 
    17601738    if (isset($wordbooker_settings['wordbooker_share_button_category']) &&  is_category()  ) {$do_share=1;} 
     1739    if (isset($wordbooker_settings['wordbooker_no_share_stick']) &&  is_sticky()  ) {$do_share=0; } 
    17611740    if ( $do_share==1  && 
    17621741    ((isset($wordbooker_settings['wordbooker_share_button_post']) && is_single()  ) 
     
    17941773    if (isset($wordbooker_settings['wordbooker_like_button_frontpage'])  && is_front_page() ) {$do_like=1;} 
    17951774    if (isset($wordbooker_settings['wordbooker_like_button_category']) &&  is_category() && !is_front_page() ) {$do_like=1;} 
    1796  
     1775    if (isset($wordbooker_settings['wordbooker_no_like_stick']) &&  is_sticky()  ) { $do_like=0;} 
    17971776    if ( $do_like==1  && 
    17981777        ((isset($wordbooker_settings['wordbooker_like_button_post']) && is_single()  ) 
     
    18321811    if (isset($wordbooker_settings['wordbooker_like_button_frontpage'])  && is_front_page() ) {$do_like=1;} 
    18331812    if (isset($wordbooker_settings['wordbooker_like_button_category']) &&  is_category() && !is_front_page() ) {$do_like=1;} 
     1813    if (isset($wordbooker_settings['wordbooker_no_like_stick']) &&  is_sticky()  ) { $do_like=0;} 
    18341814 
    18351815    if ( $do_like==1  && 
     
    18711851    if (isset($wordbooker_settings['wordbooker_like_button_frontpage'])  && is_front_page() ) {$do_like=1;} 
    18721852    if (isset($wordbooker_settings['wordbooker_like_button_category']) &&  is_category() && !is_front_page() ) {$do_like=1;} 
    1873  
     1853    if (isset($wordbooker_settings['wordbooker_no_like_stick']) &&  is_sticky()  ) { $do_like=0;} 
    18741854    if ( $do_like==1  && 
    18751855        ((isset($wordbooker_settings['wordbooker_like_button_post']) && is_single()  ) 
     
    19121892    if (isset($wordbooker_settings['wordbooker_like_button_frontpage'])  && is_front_page() ) {$do_like=1;} 
    19131893    if (isset($wordbooker_settings['wordbooker_like_button_category']) &&  is_category() && !is_front_page() ) {$do_like=1;} 
    1914  
     1894    if (isset($wordbooker_settings['wordbooker_no_like_stick']) &&  is_sticky()  ) { $do_like=0;} 
    19151895    if ( $do_like==1  && 
    19161896        ((isset($wordbooker_settings['wordbooker_like_button_post']) && is_single()  ) 
     
    20101990    $tname=WORDBOOKER_USERSTATUS; 
    20111991    $query_fields='facebook_id,name,url,pic,status,updated,facebook_id'; 
    2012     if ($table==1) {$tname=WORDBOOKER_USERDATA;$query_fields='facebook_id,name,url,pic,status,updated,auths_needed,use_facebook';} 
     1992    $blog_lim=' and blog_id='.$blog_id; 
     1993    if ($table==1) {$tname=WORDBOOKER_USERDATA;$query_fields='facebook_id,name,url,pic,status,updated,auths_needed,use_facebook';$blog_lim='';} 
    20131994    if (isset($field)) {$query_fields=$field;} 
    20141995    if ($user_id==-99){  
     
    20202001    } 
    20212002    else { 
    2022     $query="select ".$query_fields." from ".$tname."  where user_ID=".$user_id." and blog_id = ".$blog_id; 
     2003    $query="select ".$query_fields." from ".$tname."  where user_ID=".$user_id.$blog_lim; 
    20232004#   var_dump($query); 
    20242005    $result = $wpdb->get_row($query); } 
    20252006    return $result; 
    20262007} 
     2008 
    20272009 
    20282010 
     
    22572239    global $wpdb,$blog_id; 
    22582240    # We need to get the lowest post_id from the post_queue which has the lowest priority ID 
    2259  
    22602241} 
    22612242 
     
    22632244    global $user_ID, $user_identity, $user_login, $wpdb, $blog_id; 
    22642245    # If this is an autosave then we give up and return as otherwise we lose user settings. 
    2265     #var_dump($post->post_author); 
    22662246    if ($_POST['action']=='autosave') { return;} 
    22672247 
     
    22742254 
    22752255    $wb_params = get_post_meta($post->ID, '_wordbooker_options', true);  
    2276 #   var_dump($wb_params); 
    2277     #wordbooker_debugger("Author data : ".$post->post_author." - ".$user_ID,' ',$post->ID,99) ; 
    2278     #wordbooker_debugger("Status Change from ".$oldstatus." to ".$newstatus,' ',$post->ID,99) ; 
    2279     # If the user isn't a wordbooker user and the blog admin hasn't allowed non wordbooker users to publish then we go home. 
    2280     #if ((! wordbooker_get_userdata($user_ID))  && ( !isset($wordbooker_settings['wordbook_publish_no_user'])))  { return;} 
    2281     # If we dont have and Wordbooker settings for this user then we need to get some from the stsete, 
    2282     if (! wordbooker_get_userdata($post->post_author)) { $wb_user_id=$wordbooker_settings["wordbook_default_author"];} 
    2283     if  ($wordbooker_settings["wordbook_default_author"] == 0 ) {$wb_user_id=$post->post_author;} else {$wb_user_id=$wordbooker_settings["wordbook_default_author"];} 
     2256    if (! wordbooker_get_userdata($post->post_author)) { $wb_user_id=$wordbooker_settings["wordbooker_default_author"];} 
     2257    if  ($wordbooker_settings["wordbooker_default_author"] == 0 ) {$wb_user_id=$post->post_author;} else {$wb_user_id=$wordbooker_settings["wordbooker_default_author"];} 
    22842258    if (! isset($_POST['soupy'])) { 
    22852259        wordbooker_debugger("Need to get options from the Meta and not the POST  "," ",$post->ID) ; 
     
    22882262            $wordbooker_settings = wordbooker_options(); 
    22892263            wordbooker_debugger("Getting settings for user : ",$wb_user_id,$post->ID) ;  
    2290             if (! wordbooker_get_userdata($wb_user_id)) { $wb_user_id=$wordbooker_settings["wordbook_default_author"];} 
     2264            if (! wordbooker_get_userdata($wb_user_id)) { $wb_user_id=$wordbooker_settings["wordbooker_default_author"];} 
    22912265            // then get the user level settings and override the blog level settings. 
    22922266 
    2293             $wordbook_user_settings_id="wordbookuser".$blog_id; 
    2294             $wordbookuser=get_usermeta($wb_user_id,$wordbook_user_settings_id); 
     2267            $wordbooker_user_settings_id="wordbookuser".$blog_id; 
     2268            $wordbookuser=get_usermeta($wb_user_id,$wordbooker_user_settings_id); 
    22952269            # If we have user settings then lets go through and override the blog level defaults. 
    22962270            if(is_array($wordbookuser)) { 
     
    23052279            # Need to put all the primary / secondary stuff in here. 
    23062280            $wordbooker_settings['wordbooker_publish_default']=$_POST['wordbooker_publish_default']; 
    2307             $wordbooker_settings['wordbooker_publish_override']=$_POST['wordbooker_publish_override']; 
     2281            $wordbooker_settings['wordbooker_publish_page_default']=$_POST['wordbooker_publish_page_default']; 
     2282            $wordbooker_settings['wordbooker_publish_post_default']=$_POST['wordbooker_publish_post_default']; 
     2283 
    23082284            } 
    23092285            #Now push these into the $_POST array. 
     
    23432319        wordbooker_debugger("Inside the press this / quick press block "," ",$post->ID) ; 
    23442320        # New get the user level settings from the DB 
    2345         $wordbook_user_settings_id="wordbookuser".$blog_id; 
    2346         $wordbookuser=get_usermeta($wb_user_id,$wordbook_user_settings_id); 
     2321        $wordbooker_user_settings_id="wordbookuser".$blog_id; 
     2322        $wordbookuser=get_usermeta($wb_user_id,$wordbooker_user_settings_id); 
    23472323        # If we have user settings then lets go through and override the blog level defaults. 
    23482324        if(is_array($wordbookuser)) { 
     
    23682344    if ( !wordbooker_get_userdata($user_ID)) { 
    23692345         
    2370         $wb_user_id=$wordbooker_settings["wordbook_default_author"]; 
     2346        $wb_user_id=$wordbooker_settings["wordbooker_default_author"]; 
    23712347        # New get the user level settings from the DB 
    2372         $wordbook_user_settings_id="wordbookuser".$blog_id; 
    2373         $wordbookuser=get_usermeta($wb_user_id,$wordbook_user_settings_id); 
     2348        $wordbooker_user_settings_id="wordbookuser".$blog_id; 
     2349        $wordbookuser=get_usermeta($wb_user_id,$wordbooker_user_settings_id); 
    23742350        # If we have user settings then lets go through and override the blog level defaults. 
    23752351        if(is_array($wordbookuser)) { 
     
    23932369    foreach (array_keys($_POST) as $key ) { 
    23942370        if (substr($key,0,8)=='wordbook') { 
    2395             #wordbooker_debugger("Saving $key ",$_POST[$key],$post->ID,99) ; 
    23962371            $wb_params[$key]=str_replace(array('&','"','\'','<','>',"\t",), array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),$_POST[$key]); 
    23972372        } 
    23982373    } 
    2399 #   $encoded_wb_params=str_replace('\\','\\\\',serialize($wb_params)); 
    24002374    if ($newstatus=="future") {  
    2401         $wb_params['wordbook_scheduled_post']=1; 
     2375        $wb_params['wordbooker_scheduled_post']=1; 
    24022376        wordbooker_debugger("This looks like a post that is scheduled for future publishing",$newstatus,$post->ID,99); 
    2403         wordbooker_debugger("Saving Options to Post Meta",' ',$post->ID,99) ; 
    2404         #update_post_meta($post->ID, '_wordbooker_options', $wb_params); 
    24052377    }    
    24062378    if ($newstatus=="publish" && (!isset($oldstatus) || $oldstatus!="publish") ) {  
    24072379        wordbooker_debugger("This looks like a new post being published ",$newstatus,$post->ID,99) ; 
    2408         $wb_params['wordbook_new_post']=1; 
    2409         wordbooker_debugger("Saving Options to Post Meta",' ',$post->ID,99) ; 
    2410         #update_post_meta($post->ID, '_wordbooker_options', $wb_params); 
    2411     } 
    2412  
    2413     #foreach (array_keys($wb_params) as $key){ 
    2414     #   wordbooker_debugger("Saved Post option : ".$key,$wb_params[$key],$post->ID) ; 
    2415     #}   
     2380        $wb_params['wordbooker_new_post']=1; 
     2381 
     2382    } 
     2383     
    24162384    update_post_meta($post->ID, '_wordbooker_options', $wb_params);  
    24172385#   var_dump($wb_params); 
     
    24372405    $wordbooker_settings = wordbooker_options(); 
    24382406    # If there is no user row for this user then set the user id to the default author. If the default author is set to 0 (i.e current logged in user) then only blog level settings apply. 
    2439     if (! wordbooker_get_userdata($post->post_author)) { $wb_user_id=$wordbooker_settings["wordbook_default_author"];} 
    2440     if  ($wordbooker_settings["wordbook_default_author"] == 0 ) {$wb_user_id=$post->post_author;} else {$wb_user_id=$wordbooker_settings["wordbook_default_author"];} 
     2407    if (! wordbooker_get_userdata($post->post_author)) { $wb_user_id=$wordbooker_settings["wordbooker_default_author"];} 
     2408    if  ($wordbooker_settings["wordbooker_default_author"] == 0 ) {$wb_user_id=$post->post_author;} else {$wb_user_id=$wordbooker_settings["wordbooker_default_author"];} 
    24412409    # If we've no FB user associated with this ID and the blog owner hasn't overridden then we give up. 
    2442     # If the referer is press-this then the user hasn't used the full edit post form so we need to get the blog/user level settings. 
    2443     # Also check for a missing user_id (i,e, user is not a wordbooker user), or if the extract_length is empty (wp-o-matic does that) 
    2444  
    2445     #else  
    2446     #{   
    2447     if ((! wordbooker_get_userdata($post->post_author))  && ( !isset($wordbooker_settings['wordbook_publish_no_user'])))  { wordbooker_debugger("Not a WB user (".$post->post_author.") and no overide - give up "," ",$post->ID,99) ; return;} 
    2448             if ((! wordbooker_get_userdata($wb_user_id))  && ( !isset($wordbooker_settings['wordbook_publish_no_user'])))  {wordbooker_debugger("Author (".$post->post_author.") not a WB user and no overide- give up "," ",$post->ID,99) ;  return;} 
     2410 
     2411    if ((! wordbooker_get_userdata($post->post_author))  && ( !isset($wordbooker_settings['wordbooker_publish_no_user'])))  { wordbooker_debugger("Not a WB user (".$post->post_author.") and no overide - give up "," ",$post->ID,99) ; return;} 
     2412    if ((! wordbooker_get_userdata($wb_user_id))  && ( !isset($wordbooker_settings['wordbooker_publish_no_user'])))  {wordbooker_debugger("Author (".$post->post_author.") not a WB user and no overide- give up "," ",$post->ID,99) ;  return;} 
    24492413        #} 
    24502414 
    2451     if ($_POST["wordbook_default_author"]== 0 ) { wordbooker_debugger("Author of this post is the Post Author"," ",$post->ID);  $_POST["wordbook_default_author"]=$post->post_author; } 
     2415    if ($_POST["wordbooker_default_author"]== 0 ) { wordbooker_debugger("Author of this post is the Post Author"," ",$post->ID);  $_POST["wordbooker_default_author"]=$post->post_author; } 
    24522416     
    24532417    // If soupy isn't set then its either a future post or a post inherting another users options so we need to get the meta data rather than rely on post data 
     
    25122476}  
    25132477 
    2514 function wordbooker_future_post($newstatus, $oldstatus=null, $post=null) { 
    2515     # This handles option saving for future posting and also fires when auto save fires. 
    2516     global $user_ID, $user_identity, $user_login, $wpdb, $blog_id,$post; 
    2517     #fts_shorturl 
    2518     # If this is an autosave then we give up and return as otherwise we lose user settings. 
    2519     if ($_POST['action']=='autosave') { return;} 
    2520     $wordbooker_settings = wordbooker_options(); 
    2521     $wordbooker_settings['wordbooker_scheduled_post']=0; 
    2522     if ($newstatus=="future") { $wordbooker_settings['wordbooker_scheduled_post']=1; } 
    2523     $wb_params=$wordbooker_settings; 
    2524 #   if ($newstatus=="future") { 
    2525         if (!current_user_can(WORDBOOKER_MINIMUM_ADMIN_LEVEL)) { wordbooker_debugger("This user doesn\'t have enough rights"," ",$post->ID) ; return;} 
    2526         # If the user isn't a wordbooker user and the blog admin hasn't allowed non wordbooker users to publish then we go home. 
    2527         if ((! wordbooker_get_userdata($user_ID))  && ( !isset($wordbooker_settings['wordbooker_publish_no_user'])))  {  wordbooker_debugger("Not a WB user"," ",$post->ID); return;} 
    2528         # If we dont have and Wordbooker settings for this user then we need to get some from the stsete, 
    2529         if ( !wordbooker_get_userdata($user_ID)) { 
    2530             $wb_user_id=$wordbooker_settings["wordbooker_default_author"]; 
    2531             # New get the user level settings from the DB 
    2532             $wordbooker_user_settings_id="wordbookuser".$blog_id; 
    2533             $wordbookuser=get_user_meta($wb_user_id,$wordbooker_user_settings_id); 
    2534             # If we have user settings then lets go through and override the blog level defaults. 
    2535             if(is_array($wordbookuser)) { 
    2536                 foreach (array_keys($wordbookuser) as $key) { 
    2537                     if ((strlen($wordbookuser[$key])>0) && ($wordbookuser[$key]!="0") ) { 
    2538                         $wordbooker_settings[$key]=$wordbookuser[$key]; 
    2539                     }  
    2540                 } 
    2541  
    2542             } 
    2543             # Then populate the post array. 
    2544                 if(is_array($wordbooker_settings)) { 
    2545                 foreach (array_keys($wordbooker_settings) as $key ) { 
    2546                     if (substr($key,0,8)=='wordbook') { 
    2547                         $_POST[$key]=str_replace( array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),array('&','"','\'','<','>',"\t"),$wordbooker_settings[$key]); 
    2548                     } 
    2549                 } 
    2550             } 
    2551         } 
    2552         # OK now lets get the settings from the POST array 
    2553         foreach (array_keys($_POST) as $key ) { 
    2554             if (substr($key,0,8)=='wordbook') { 
    2555                 $wb_params[$key]=str_replace(array('&','"','\'','<','>',"\t",), array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),$_POST[$key]); 
    2556             } 
    2557         } 
    2558         $encoded_wb_params=str_replace('\\','\\\\',serialize($wb_params)); 
    2559         update_post_meta($post->ID, '_wordbooker_options', $wb_params);  
    2560 #   } 
    2561 }  
    25622478 
    25632479 
     
    26302546 
    26312547function wordbooker_debugger($method,$error_msg,$post_id,$level=10) { 
    2632     #echo $method." - ".$error_msg."<br>"; 
    26332548    $diaglevel=wordbooker_get_option('wordbooker_advanced_diagnostics_level'); 
    26342549    if (!isset($diaglevel)) {$diglevel=-100;} 
     
    26772592/* Plugin maintenance. */ 
    26782593register_activation_hook(__FILE__, 'wordbooker_activate'); 
    2679 #register_deactivation_hook(__FILE__, 'wordbooker_deactivate'); 
    26802594add_action('delete_user', 'wordbooker_delete_user'); 
    26812595 
     
    27032617/* Post/page maintenance and publishing hooks. */ 
    27042618$wordbooker_disabled=wordbooker_get_option('wordbooker_disabled'); 
    2705 # If they've disabled Worbooker then we don't need any of these 
     2619# If they've disabled Wordbooker then we don't need any of these 
    27062620if (!isset($wordbooker_disabled)){ 
    27072621    add_action('transition_post_status', 'wordbooker_process_post_data',20,3); 
     
    27152629    add_action('wp_head', 'wordbooker_header'); 
    27162630    add_action('wp_footer', 'wordbooker_footer'); 
    2717     #add_action('transition_post_status', 'wordbooker_future_post'); 
    27182631    add_filter('language_attributes', 'wordbooker_schema'); 
    27192632    #add_filter('get_avatar','wordbooker_get_avatar'); 
     
    27312644# Includes - trying to keep my code base tidy. 
    27322645include("includes/wordbooker_options.php"); 
    2733 # If they've disabled Worbooker then we don't need to load any of these. 
     2646# If they've disabled Wordbooker then we don't need to load any of these. 
    27342647if (!isset($wordbooker_disabled)){ 
    27352648    include("includes/wordbooker_wb_widget.php"); 
     
    27382651    include("includes/wordbooker_posting.php"); 
    27392652    #include("includes/wordbooker_get_friend.php"); 
    2740     # This is for support for alternative posting processes. Only Curl is supported right now 
    2741     #if (wordbooker_get_option('wordbooker_fopen_curl')=='fopen'){ 
     2653} 
     2654# This is for support for alternative posting processes. Only Curl is supported right now 
     2655#if (wordbooker_get_option('wordbooker_fopen_curl')=='fopen'){ 
    27422656    #   include("includes/wordbooker_facebook_fopen.php"); 
    27432657    #}   
     
    27452659    include("includes/wordbooker_facebook_curl.php"); 
    27462660#   } 
    2747 } 
    2748  
    2749  
    27502661 
    27512662?> 
  • wordbooker/trunk/includes/wordbooker_cron.php

    r449609 r451433  
    200200        $all_pages_groups=array_merge($all_pages,$all_groups); 
    201201        $encoded_names=str_replace('\\','\\\\',serialize($all_pages_groups)); 
    202  
     202/* 
    203203 
    204204        try { 
     
    245245            } 
    246246        } 
     247*/ 
    247248 
    248249        wordbooker_debugger("Setting name as  : ",mysql_real_escape_string($fb_profile_info->name),0) ; 
  • wordbooker/trunk/includes/wordbooker_facebook_curl.php

    r450021 r451433  
    7878        curl_setopt($ch, CURLOPT_URL, $url); 
    7979        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
     80    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
     81    curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/fb_ca_chain_bundle.crt'); 
    8082        $response = curl_exec($ch); 
    8183    $err_no=curl_errno($ch); 
     
    9597        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    9698    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
     99    curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/fb_ca_chain_bundle.crt'); 
    97100     curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
    98101        $response = curl_exec($ch); 
  • wordbooker/trunk/includes/wordbooker_facebook_fopen.php

    r449609 r451433  
    2828global $wp_version; 
    2929 
    30 function wordbooker_make_fopen_call($url) { 
    31     $ch = curl_init(); 
    32         curl_setopt($ch, CURLOPT_URL, $url); 
    33         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    34         $response = curl_exec($ch); 
    35     $err_no=curl_errno($ch); 
    36         curl_close($ch); 
    37     $x=json_decode($response); 
    38     if (isset($x->error_code)) {  
    39         throw new Exception ($x->error_msg); 
    40     } 
    41      return($x); 
     30function wordbooker_make_fopen_post_call($url, $data, $optional_headers = null) { 
     31      $params = array('http' => array( 
     32              'method' => 'POST', 
     33              'content' => $data 
     34            )); 
     35      if ($optional_headers !== null) { 
     36        $params['http']['header'] = $optional_headers; 
     37      } 
     38      $ctx = stream_context_create($params); 
     39      $fp = @fopen($url, 'rb', false, $ctx); 
     40      if (!$fp) { 
     41        throw new Exception("Problem with $url, $php_errormsg"); 
     42      } 
     43      $response = @stream_get_contents($fp); 
     44      if ($response === false) { 
     45        throw new Exception("Problem reading data from $url, $php_errormsg"); 
     46      } 
     47      return $response; 
    4248} 
    4349 
    4450 
    4551 
    46 function wordbooker_make_fopen_post_call($url, $params, $ch=null) { 
    47      
    48     $content = ""; 
    49     foreach ($params as $key => $param) { 
    50         $content .= "{$key}=" . urlencode($param) . "&"; 
    51     } 
    52     substr($post, 0, strlen($post) - 1); 
    53      
    54     $user_agent = 'Wordbooker Version 2 (non-curl) ' . phpversion(); 
    55     $content_type = 'application/x-www-form-urlencoded'; 
    56      
    57     $content_length = strlen($content); 
    58     $context = 
    59       array('http' => 
    60               array('method' => 'POST', 
    61                     'user_agent' => $user_agent, 
    62                     'header' => 'Content-Type: ' . $content_type . "\r\n" . 
    63                                 'Content-Length: ' . $content_length, 
    64                     'content' => $content)); 
    65     $context_id = stream_context_create($context); 
    66     $sock = @fopen($url, 'r', false, $context_id); 
    67  
    68     $result = ''; 
    69     if ($sock) { 
    70       while (!feof($sock)) { 
    71         $result .= fgets($sock, 4096); 
    72       } 
    73       fclose($sock); 
    74     } 
    75  
    76     //error_log("MAKE REQUEST RESULT : " . $result); 
    77  
    78     return $result;     
    79      
    80   } 
     52function wordbooker_make_fopen_call($url, $params, $optional_headers = null) { 
     53      $params = array('http' => array( 
     54              'content' => $data 
     55            )); 
     56      if ($optional_headers !== null) { 
     57        $params['http']['header'] = $optional_headers; 
     58      } 
     59      $ctx = stream_context_create($params); 
     60      $fp = @fopen($url, 'rb', false, $ctx); 
     61      if (!$fp) { 
     62        throw new Exception("Problem with $url, $php_errormsg"); 
     63      } 
     64      $response = @stream_get_contents($fp); 
     65      if ($response === false) { 
     66        throw new Exception("Problem reading data from $url, $php_errormsg"); 
     67      } 
     68      return $response; 
     69} 
    8170?> 
  • wordbooker/trunk/includes/wordbooker_options.php

    r449609 r451433  
    9393    // If no default author set, lets set it 
    9494    if (! isset($wordbooker_settings["wordbooker_default_author"])){ $wordbooker_settings["wordbooker_default_author"]=0;} 
    95     // If no default republish time frame set, then set it. 
    96     if (! isset($wordbooker_settings["wordbooker_republish_time_frame"])){ $wordbooker_settings["wordbooker_republish_time_frame"]=10;} 
    9795    // If no attribute set, then set it. 
    9896    if (! isset($wordbooker_settings["wordbooker_attribute"])){ $wordbooker_settings["wordbooker_attribute"]= __("Posted a new post on their blog");} 
     
    10199    // No Share link set, then set it 
    102100    if (! isset($wordbooker_settings["wordbooker_actionlink"])){ $wordbooker_settings["wordbooker_actionlink"]=300;} 
    103     // No andor set, then set it 
    104     if (! isset($wordbooker_settings['wordbooker_orandpage'])){ $wordbooker_settings['wordbooker_orandpage']=2;} 
    105101    // No extract length 
    106102    if (! isset($wordbooker_settings['wordbooker_extract_length'])) {$wordbooker_settings['wordbooker_extract_length']=256;} 
     
    243239        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_publish_no_user]" '.$checked_flag[$wordbooker_settings["wordbooker_publish_no_user"]].' ><br />'; 
    244240 
     241        echo '<label for="wb_publish_user_publish">'.__("Allow non Wordbooker users to chose to publish a post"). ' : </label>'; 
     242        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_allow_publish_select]" '.$checked_flag[$wordbooker_settings["wordbooker_allow_publish_select"]].' ><br />'; 
     243 
    245244                echo '<label for="wb_extract_length">'.__('Length of Extract').' :</label> <select id="wordbooker_extract_length" name="wordbooker_settings[wordbooker_extract_length]"  >'; 
    246245            $arr = array(10=> "10",20=> "20",50=> "50",100=> "100",120=> "120",150=> "150",175=> "175",200=> "200",  250=> "250", 256=>__("256 (Default) "), 270=>"270", 300=>"300", 350 => "350",400 => "400",500 => "500",600 => "600",700 => "700",800 => "800",900 => "900"); 
     
    299298        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_like_button_post]" '.$checked_flag[$wordbooker_settings["wordbooker_like_button_post"]].' ><br />'; 
    300299 
     300        echo '<label for="wb_facebook_like">&nbsp;'.__("Don't show Facebook Like / Send Button on Sticky Posts"). ' : </label>'; 
     301        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_no_like_stick]" '.$checked_flag[$wordbooker_settings["wordbooker_no_like_stick"]].' ><br />'; 
     302 
     303 
    301304            if (!is_numeric($wordbooker_settings['wordbooker_like_width']) || $wordbooker_settings['wordbooker_like_width'] <0) {$wordbooker_settings['wordbooker_like_width']=250;} 
    302305        echo '<label for="wb_facebook_like_width">&nbsp;'.__("Width of Facebook Like box"). ' : </label>'; 
     
    340343 
    341344 
    342         echo '<label for="wb_fblike_send_combi">&nbsp;'.__('Combine Send with Like').' :</label> <select id="wordbook_fblike_send_combi" name="wordbooker_settings[wordbooker_fblike_send_combi]"  >'; 
     345        echo '<label for="wb_fblike_send_combi">&nbsp;'.__('Combine Send with Like').' :</label> <select id="wordbooker_fblike_send_combi" name="wordbooker_settings[wordbooker_fblike_send_combi]"  >'; 
    343346        foreach ($fblike_send_combi as $i => $value) { 
    344347            if ($i==$wordbooker_settings['wordbooker_fblike_send_combi']){ print '<option selected="yes" value="'.$i.'" >'.$fblike_send_combi[$i].'</option>';} 
     
    346349        echo "</select><br/> "; 
    347350 
    348         echo '<label for="wb_fblike_send">&nbsp;'.__('Facebook Send - Display Button').' :</label> <select id="wordbook_fblike_send" name="wordbooker_settings[wordbooker_fblike_send]"  >'; 
     351        echo '<label for="wb_fblike_send">&nbsp;'.__('Facebook Send - Display Button').' :</label> <select id="wordbooker_fblike_send" name="wordbooker_settings[wordbooker_fblike_send]"  >'; 
    349352        foreach ($fblike_send as $i => $value) { 
    350353            if ($i==$wordbooker_settings['wordbooker_fblike_send']){ print '<option selected="yes" value="'.$i.'" >'.$fblike_send[$i].'</option>';} 
     
    374377        echo '<label for="wb_facebook_share_post">&nbsp;'.__("Show Facebook Share button in each post"). ' : </label>'; 
    375378        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_share_button_post]" '.$checked_flag[$wordbooker_settings["wordbooker_share_button_post"]].' ><br />'; 
    376  
     379        echo '<label for="wb_facebook_like">&nbsp;'.__("Don't show Facebook Share button on Sticky Posts"). ' : </label>'; 
     380        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_no_share_stick]" '.$checked_flag[$wordbooker_settings["wordbooker_no_share_stick"]].' ><br />'; 
    377381 
    378382} 
  • wordbooker/trunk/includes/wordbooker_posting_options.php

    r449609 r451433  
    6060        $wordbooker_settings=$post_meta; 
    6161    } 
     62#var_dump($wordbooker_settings["wordbooker_post_edited"]); 
     63    $post_pub_prompt=__("Publish this post to Facebook"); 
     64    if($post->post_type=='page'){ 
     65        $publish=$wordbooker_settings["wordbooker_publish_page_default"];        
     66        $post_pub_prompt=__("Publish this page to Facebook"); 
     67    } 
     68    else { 
     69        $publish=$wordbooker_settings["wordbooker_publish_post_default"]; 
     70            $post_pub_prompt=__("Publish this post to Facebook"); 
     71    } 
     72 
     73    #var_dump($post->post_status); 
     74    if($wordbooker_settings["wordbooker_post_edited"]!='yes') {$wordbooker_settings["wordbooker_publish_default"]=$publish;} 
     75    if ($post->post_status=="publish") {$wordbooker_settings["wordbooker_publish_default"]='';} 
    6276    if (wordbooker_get_userdata($user_ID)) { 
    63         if (! isset($wordbooker_settings['wordbooker_page_post'])) { $wordbooker_settings['wordbooker_page_post']=-100;} 
    64         if (! isset($wordbooker_settings['wordbooker_orandpage'])) { $wordbooker_settings['wordbooker_orandpage']= 2; } 
    65         echo '<input type="hidden" name="wordbooker_page_post" value="-100" />'; 
    66         echo '<input type="hidden" name="wordbooker_orandpage" value="2" />'; 
     77 
    6778        echo __("The following options override the defaults set on the options page")."<br /><br />"; 
    6879        $sql="select wpu.ID,wpu.display_name,facebook_id from $wpdb->users wpu,".WORDBOOKER_USERDATA." wud where wpu.ID=wud.user_id;"; 
     
    7485        $fanpages[]=array( 'id'=>'PW:'.$wb_users[0]->facebook_id, 'name'=>"Personal Wall"); 
    7586        $have_fan_pages=0; 
    76         $post_pub_prompt=__("Publish this post to Facebook"); 
    77         if($post->post_type=='page'){ 
    78             $wordbooker_settings["wordbooker_publish_default"]=$wordbooker_settings["wordbooker_publish_page_default"];      
    79             $post_pub_prompt=__("Publish this page to Facebook"); 
    80         } 
    81         if($post->post_type=='post'){ 
    82             $wordbooker_settings["wordbooker_publish_default"]=$wordbooker_settings["wordbooker_publish_post_default"]; 
    83                 $post_pub_prompt=__("Publish this post to Facebook"); 
    84         } 
     87 
    8588        # If the post has already been published then we uncheck the publish option  
    86         if ($post->post_status=='publish') {$wordbooker_settings["wordbooker_publish_default"]='';} 
     89         
    8790        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_publish_default" '.$checked_flag[$wordbooker_settings["wordbooker_publish_default"]].' > '.$post_pub_prompt.'<br />'; 
    8891 
     
    133136 
    134137        echo __('Length of Extract').' : <select id="wordbooker_extract_length" name="wordbooker_extract_length"  >'; 
    135         $arr = array( 10=> "10",20=> "20",50=> "50",100=> "100",120=> "120",150=> "150",175=> "175", 200=> "200",  250=> "250", 256=>"256", 270=>"270", 300=>"300", 350 => "350",400 => "400"); 
     138            $arr = array(10=> "10",20=> "20",50=> "50",100=> "100",120=> "120",150=> "150",175=> "175",200=> "200",  250=> "250", 256=>__("256 (Default) "), 270=>"270", 300=>"300", 350 => "350",400 => "400",500 => "500",600 => "600",700 => "700",800 => "800",900 => "900"); 
    136139            foreach ($arr as $i => $value) { 
    137140                    if ($i==$wordbooker_settings['wordbooker_extract_length']){ print '<option selected="yes" value="'.$i.'" >'.$arr[$i].'</option>';} 
     
    149152        echo '<input type="hidden" name="soupy" value="twist" />'; 
    150153 
    151     #   var_dump($post->post_type); 
    152     #   var_dump($post->post_status); 
    153     #   if ($wordbooker_settings["wordbooker_publish_default"]=='published') {$wordbooker_settings["wordbooker_publish_default"]='';} 
    154  
    155  
    156154    #   echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_publish_override" '.$checked_flag[$wordbooker_settings["wordbooker_publish_override"]].' >'.__('Force Re-Publish Post to Facebook on Edit (overrides republish window)').'<br />'; 
    157155        if ( function_exists( 'get_the_post_thumbnail' ) ) { 
     
    162160        echo 'Facebook Post Attribute line: <INPUT NAME="wordbooker_attribute" size=80 maxlength=240 value="'.stripslashes($wordbooker_settings["wordbooker_attribute"]).'"><br />';     
    163161        echo __('Facebook Status Update text').' : <INPUT NAME="wordbooker_status_update_text" size=60 maxlength=240 value="'.stripslashes($wordbooker_settings["wordbooker_status_update_text"]).'"><br />'; 
    164  
    165         if($post->post_type=='post'){ 
    166  
    167             if(!isset($wordbooker_settings['wordbooker_like_button_post'])) {$wordbooker_settings['wordbooker_like_button_post']=1;} 
    168             if(!isset($wordbooker_settings['wordbooker_share_button_post'])) {$wordbooker_settings['wordbooker_share_button_post']=1;} 
    169             echo __('Show Facebook Like/Send for this Post').' : <select id="wordbooker_like_button_post" name="wordbooker_like_button_post"  >'; 
    170             $arr = array(1=> __("Yes"),  2=> __("No") ); 
    171                 foreach ($arr as $i => $value) { 
    172                     if ($i==$wordbooker_settings['wordbooker_like_button_post']){ print '<option selected="yes" value="'.$i.'" >'.$arr[$i].'</option>';} 
    173                        else {print '<option value="'.$i.'" >'.$arr[$i].'</option>';} 
    174                 } 
    175                 echo "</select><br />"; 
    176          
    177             echo __('Show Facebook Share for this Post').' : <select id="wordbooker_share_button_post" name="wordbooker_share_button_post"  >'; 
    178             $arr = array(1=> __("Yes"),  2=> __("No") ); 
    179                 foreach ($arr as $i => $value) { 
    180                     if ($i==$wordbooker_settings['wordbooker_share_button_post']){ print '<option selected="yes" value="'.$i.'" >'.$arr[$i].'</option>';} 
    181                        else {print '<option value="'.$i.'" >'.$arr[$i].'</option>';} 
    182                 } 
    183                 echo "</select><br />"; 
    184         } 
    185162 
    186163        if($post->post_type=='page'){ 
     
    203180            echo "</select><br />"; 
    204181        } 
     182        else { 
     183 
     184            if(!isset($wordbooker_settings['wordbooker_like_button_post'])) {$wordbooker_settings['wordbooker_like_button_post']=1;} 
     185            if(!isset($wordbooker_settings['wordbooker_share_button_post'])) {$wordbooker_settings['wordbooker_share_button_post']=1;} 
     186            echo __('Show Facebook Like/Send for this Post').' : <select id="wordbooker_like_button_post" name="wordbooker_like_button_post"  >'; 
     187            $arr = array(1=> __("Yes"),  2=> __("No") ); 
     188                foreach ($arr as $i => $value) { 
     189                    if ($i==$wordbooker_settings['wordbooker_like_button_post']){ print '<option selected="yes" value="'.$i.'" >'.$arr[$i].'</option>';} 
     190                       else {print '<option value="'.$i.'" >'.$arr[$i].'</option>';} 
     191                } 
     192                echo "</select><br />"; 
     193         
     194            echo __('Show Facebook Share for this Post').' : <select id="wordbooker_share_button_post" name="wordbooker_share_button_post"  >'; 
     195            $arr = array(1=> __("Yes"),  2=> __("No") ); 
     196                foreach ($arr as $i => $value) { 
     197                    if ($i==$wordbooker_settings['wordbooker_share_button_post']){ print '<option selected="yes" value="'.$i.'" >'.$arr[$i].'</option>';} 
     198                       else {print '<option value="'.$i.'" >'.$arr[$i].'</option>';} 
     199                } 
     200                echo "</select><br />"; 
     201        } 
     202 
     203 
    205204        if ($wordbooker_global_settings['wordbooker_comment_handling']=="1"){ 
    206205        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_comment_get" '.$checked_flag[$wordbooker_settings["wordbooker_comment_get"]].' > '.__('Fetch comments from Facebook for this post').'<br />';} 
    207206        if ($wordbooker_global_settings['wordbooker_comment_handling']=="2"){ 
    208207        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_use_facebook_comments" '.$checked_flag[$wordbooker_settings["wordbooker_use_facebook_comments"]].' > '.__('Enable Facebook Comments for this post').'<br />';} 
    209     } else { 
    210         echo "Wordbooker Blog level settings are in force";  
    211         } 
    212  
     208    }  else { 
     209echo "<p>Wordbooker Blog level settings are in force<br /></p>"; 
     210 
     211if ( isset($wordbooker_settings['wordbooker_allow_publish_select'])) {  
     212echo '<input type="hidden" name="crabstick" value="stairwell" />'; 
     213echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_publish_default" '.$checked_flag[$wordbooker_settings["wordbooker_publish_default"]].' > '.__('Publish This Post to Facebook').'<br />'; 
     214#echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_publish_override" '.$checked_flag[$wordbooker_settings["wordbooker_publish_override"]].' >'.__('Force Re-Publish Post to Facebook on Edit (overrides republish window)').'<br />'; 
     215} else { echo '<input type="hidden" name="wordbooker_publish_default" value="'.$wordbooker_settings["wordbooker_publish_default"].'" />';} 
     216} 
     217 
     218echo '<input type="hidden" name="wordbooker_publish_page_default" value="'.$wordbooker_settings["wordbooker_publish_page_default"].'" />'; 
     219echo '<input type="hidden" name="wordbooker_publish_post_default" value="'.$wordbooker_settings["wordbooker_publish_post_default"].'" />'; 
     220echo '<input type="hidden" name="wordbooker_post_edited" value="yes" />'; 
    213221} 
    214222 
  • wordbooker/trunk/includes/wordbooker_wb_widget.php

    r449609 r451433  
    104104        $ds12=date('D M j, g:i a'); 
    105105        $dl12=date('l F j, g:i a'); 
    106         $dl24=date('l F j, h:i'); 
    107         $ds24=date('D M j, h:i'); 
     106        $dl24=date('l F j, G:i'); 
     107        $ds24=date('D M j, G:i'); 
    108108        $drfc=date('r'); 
    109         $arr = array('D M j, g:i a'=> $ds12,  'l F j, g:i a'=> $dl12, 'D M j, h:i'=>$ds24, 'l F j, h:i'=>$dl24,fbt=>__("Facebook Text style",'wordbooker'), r =>$drfc); 
     109        $arr = array('D M j, g:i a'=> $ds12,  'l F j, g:i a'=> $dl12, 'D M j, G:i'=>$ds24, 'l F j, G:i'=>$dl24,fbt=>__("Facebook Text style",'wordbooker'), r =>$drfc); 
    110110        foreach ($arr as $i => $value) { 
    111111        if ($i==attribute_escape( $instance['df'])){ print '<option selected="yes" value="'.$i.'" >'.$arr[$i].'</option>';} 
     
    115115    } 
    116116} 
    117  
    118  
    119117 
    120118/* register widget when loading the WP core */ 
     
    126124    register_widget('WordbookWidget'); 
    127125} 
    128  
    129  
    130126 
    131127 
  • wordbooker/trunk/readme.txt

    r450021 r451433  
    55Requires at least: 2.9 
    66Tested up to: 3.2.1 
    7 Stable tag: 2.0.1 
     7Stable tag: 2.0.2 
    88 
    99This plugin allows you to cross-post your blog posts to your Facebook Wall and to any Facebook Fan Page / Group that you are an administrator for. The base release of Version 2 DOES NOT support comment handling - this is because V2 had to be pushed out to meet deadlines imposed by Facebook concerning application authorisation. Comment handling will be added in the first major 2.x release. 
     
    119119== Changelog == 
    120120 
     121= Version 2.0.2 15/10/2011 = 
     122- Fixed a bug with app-id/fb:admins which made comment moderation go wrong. 
     123- Fixed a bug in the target handling code where a variable was not being set correctly leading to confusing error message 
     124- Changed Curl calls to supress errors (for sites where curl is blocked/broken and craps the code out) 
     125- Changed FB comment code to supress comment boxes on anything but single post pages (as it seems to upset Facebook). 
     126- Fixed a bug concerning "Publish As" which meant it wasn't working properly. 
     127- Restored an option to allow Non Wordbooker users to chose if a post should be published or not. 
     128- Restored the option to supress like/share/send on Sticky Posts 
     129- Fixed a bug with the og: description tag not being populated. 
     130- Changed logic so og:tags are put out all the time unless you've checked the option to disable them all. 
     131- Fixed a bug where an array was parsed for data even if it didn't exist. 
     132- Fixed a bug where "post attribute" was missing. 
     133- Fixed a bug where when extract length was set to more than 400 it got reset to either 10 or 256 
     134- Added a check so that if a post has no images a blank is loaded to stop Facebook from scraping the page. 
     135- Changed logic so that Posting Options checks if a post is to a page and if not defaults to a post. This should provide a short term work round for custom post types. 
     136- Fixed a bug where the diagnostics reporting which target was active or not didn't show the right target. 
     137- Fixed a bug where the new publish options were being lost when you scheduled a post or saved a draft and then exited and edited the post later. 
     138- Fixed a bug where if you set the "Deactivate Wordbooker functionality" then it crashed out with a fatal error 
     139- 24 hour time formats on the FB Status Widget weren't set correctly 
     140- Added the X509 cert bundle for Curl installs without it properly installed. 
     141 
     142 
    121143= Version 2.0.1 11/10/2011 = 
    122144- Fixed a logic mistake concerning Share on Pages/Front pages 
     
    124146- Fixed a bug where Like counts didn't work because the url was missing. 
    125147- Put an extra option into the Curl Call which might fix issues with certificate bundles. 
     148- Fixed a bug with app-id/fb:admins which made comment moderation go wrong. 
    126149 
    127150 
  • wordbooker/trunk/wordbooker.php

    r450021 r451433  
    22/* 
    33Plugin Name: Wordbooker 
    4 Plugin URI: http://worbooker.tty.org.uk 
     4Plugin URI: http://wordbooker.tty.org.uk 
    55Description: Provides integration between your blog and your Facebook account. Navigate to <a href="options-general.php?page=wordbooker">Settings &rarr; Wordbooker</a> for configuration. 
    66Author: Steve Atty  
    77Author URI: http://wordbooker.tty.org.uk 
    8 Version: 2.0.1 
     8Version: 2.0.2 
    99*/ 
    1010 
     
    4343define('WORDBOOKER_DEBUG', false); 
    4444define('WORDBOOKER_TESTING', false); 
    45 define('WORDBOOKER_CODE_RELEASE','2.0.1 - Letters To A Young Rose '); 
     45define('WORDBOOKER_CODE_RELEASE','2.0.2 - Jugglers in Obsidian '); 
    4646 
    4747# For Troubleshooting  
     
    6565define('WORDBOOKER_FB_APIVERSION', '1.0'); 
    6666define('WORDBOOKER_FB_DOCPREFIX','http://wiki.developers.facebook.com/index.php/'); 
    67 #define('WORDBOOKER_FB_MAXACTIONLEN', 60); 
    6867define('WORDBOOKER_FB_PUBLISH_STREAM', 'publish_stream'); 
    6968define('WORDBOOKER_FB_READ_STREAM', 'read_stream'); 
     
    350349        if ($result === false) 
    351350            $errors[] = __('Failed to create ') . WORDBOOKER_PROCESS_QUEUE ; 
    352  
    353  
    354351 
    355352    if ($errors) { 
     
    532529    wordbooker_debugger("Post modified : ",$rows[0]->post_modified,$post_id) ; 
    533530    wordbooker_debugger("Post status : ",$rows[0]->post_status,$post_id) ; 
    534     wordbooker_debugger("Post status flag : ",$wbo['wordbook_new_post'],$post_id) ; 
    535     wordbooker_debugger("Scheduled Post: ",$wbo['wordbook_scheduled_post'],$post_id) ; 
     531    wordbooker_debugger("Post status flag : ",$wbo['wordbooker_new_post'],$post_id) ; 
     532    wordbooker_debugger("Scheduled Post: ",$wbo['wordbooker_scheduled_post'],$post_id) ; 
    536533         
    537534    if ($tstamp==1 && !isset($_POST['original_post_status']) && !isset($_POST['screen'])) {return 0;} 
     
    541538    # If the post is new then return false 
    542539    if ($rows[0]->post_date == $rows[0]->post_modified) {return false;} 
    543     if ($wbo['wordbook_scheduled_post']!=0) { 
    544         $wbo['wordbook_scheduled_post']=0; 
     540    if ($wbo['wordbooker_scheduled_post']!=0) { 
     541        $wbo['wordbooker_scheduled_post']=0; 
    545542        $y=update_post_meta($post_id, '_wordbooker_options', $wbo);  
    546543        return false; 
    547544    } 
    548     if ($wbo['wordbook_new_post']!=0) {  
    549         $wbo['wordbook_new_post']=0; 
     545    if ($wbo['wordbooker_new_post']!=0) {  
     546        $wbo['wordbooker_new_post']=0; 
    550547        $y=update_post_meta($post_id, '_wordbooker_options', $wbo);  
    551548        return false; 
     
    839836    $errormsg = null; 
    840837    if (!function_exists('curl_init')) { 
    841     #$errormsg .=  'Wordbooker needs the CURL PHP extension to work. Please install / enable it and try again <br />'; 
     838        $errormsg .=  'Wordbooker needs the CURL PHP extension to work. Please install / enable it and try again <br />'; 
    842839    } 
    843840    if (!function_exists('json_decode')) { 
     
    11041101       curl_setopt($ch, CURLOPT_HEADER, 0); 
    11051102       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
     1103       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
     1104       curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/includes/fb_ca_chain_bundle.crt'); 
    11061105       curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0'); 
    1107        $curlcontent = curl_exec($ch); 
     1106       $curlcontent = @curl_exec($ch); 
    11081107       $x=json_decode($curlcontent); 
    11091108    #var_dump($x->name); 
    1110        $curlstatus="Curl is available but cannot access Facebook - This is a problem (".curl_errno($ch)." )"; 
     1109       $curlstatus="Curl is available but cannot access Facebook - This is a problem (".curl_errno($ch)." - ". curl_error($ch) ." )"; 
    11111110       if ($x->name=="Facebook Platform") {$curlstatus="Curl is available and can access Facebook - All is OK";} 
    1112   curl_close($ch); 
     1111    curl_close($ch); 
    11131112    } 
    11141113 
     
    12221221function wordbooker_fbclient_publishaction($wbuser,$post_id)  
    12231222{    
    1224     global $wordbooker_post_options; 
     1223    global $wordbooker_post_options,$wpdb; 
    12251224    $wordbooker_settings =wordbooker_options();  
    12261225    $post = get_post($post_id); 
     
    13371336    } 
    13381337 
    1339     # Strip images from various plugins 
    1340     $images=array_filter($images, "wordbooker_strip_images"); 
    1341     # And limit it to 5 pictures to keep Facebook happy. 
    1342     $images = array_slice($images, 0, 5); 
    1343  
    1344     if (is_array($images)){ 
     1338    if (count($images)>0){ 
     1339        # Strip images from various plugins 
     1340        $images=array_filter($images, "wordbooker_strip_images"); 
     1341        # And limit it to 5 pictures to keep Facebook happy. 
     1342        $images = array_slice($images, 0, 5); 
    13451343        foreach ($images as $key){ 
    13461344            wordbooker_debugger("Post Images : ".$key['src'],'',$post->ID) ; 
    13471345        } 
    1348     } 
     1346    } else {  
     1347        $images[]=get_bloginfo('wpurl').'wp-contents/plugins/wordbooker/includes/wordbooker_blank.jpg'; 
     1348        wordbooker_debugger("No Post images found so loading blank to keep Facebook happy ",'',$post->ID) ; } 
    13491349 
    13501350    $wordbooker_settings =wordbooker_options();  
     
    13551355        $post_content=$post->post_excerpt; } 
    13561356    else {  $post_content=wordbooker_post_excerpt($post_content,$wordbooker_post_options['wordbooker_extract_length']);} 
    1357  
     1357    update_post_meta($post->ID,'_wordbooker_extract',$post_content); 
    13581358    # this is getting and setting the post attributes 
    13591359    $post_attribute=parse_wordbooker_attributes(stripslashes($wordbooker_post_options["wordbooker_attribute"]),$post_id,strtotime($post->post_date)); 
     
    13801380    } 
    13811381    $post_id=$post->ID; 
    1382 #   $attachment =  array( 
    1383 #     'name' => $post_data['post_title'], 
    1384 #     'href' => $post_data['post_link'], 
    1385 #     'description' => $post_data['post_excerpt'], 
    1386 #     'media' => $post_data['media'] 
    1387 #   ); 
     1382 
    13881383    $wordbooker_fb_post = array( 
    13891384      'name' => $post_data['post_title'], 
    13901385      'link' => $post_data['post_link'], 
     1386      'message'=> $post_data['post_attribute'], 
    13911387      'description' => $post_data['post_excerpt'], 
    13921388      'media' => json_encode($images) 
     
    14121408    } 
    14131409 
    1414 # All of this needs totally re-writing. What we need to do is loop through the two post targets and process each target and target type in turn.  
    1415  
    14161410    $posting_array[] = array('target'=>$wordbooker_post_options['wordbooker_primary_target'],  
    14171411                 'target_type'=>$wordbooker_post_options['wordbooker_primary_type'], 
     
    14221416 
    14231417    foreach($posting_array as $posting_target) { 
    1424         if (isset($posting_target['target_active'])) { 
    1425             $access_token='dummy access token'; 
     1418    $access_token='dummy access token'; 
     1419        if(count($wbuser->pages)>0){ 
    14261420            foreach ($wbuser->pages as $pager) { 
    14271421                if ($pager['id']==$posting_target['target']) { 
    1428                 $target_name=$pager['name']; 
    1429                 $access_token=$pager['access_token'];} 
    1430             } 
     1422                    $target_name=$pager['name']; 
     1423                    $access_token=$pager['access_token']; 
     1424                } 
     1425            } 
     1426        } 
     1427        if (isset($posting_target['target_active'])) { 
     1428 
     1429            wordbooker_debugger("Posting to target ".$target_name,"",$post_id,99) ;  
    14311430            if ($access_token=='dummy access token') {$access_token=$wbuser->access_token;} 
    14321431            $target=substr($posting_target['target'],3); 
     
    15711570    $bdesc=get_bloginfo('description'); 
    15721571    $wordbooker_settings = wordbooker_options();     
    1573     if ( (isset($wordbooker_settings['wordbooker_like_button_show']) || isset($wordbooker_settings['wordbooker_like_share_too']))) { 
     1572    # Always put out the tags because even if they are not using like/share it gives Facebook stuff to work with. 
    15741573        $wordbooker_post_options= get_post_meta($post->ID, '_wordbooker_options', true);  
    15751574        $wpuserid=$post->post_author; 
     
    15801579        $blog_name=get_bloginfo('name'); 
    15811580        echo '<meta property="og:site_name" content="'.$bname.' - '.$bdesc.'"/> '; 
    1582  
     1581        if (strlen($wordbooker_settings["fb_comment_app_id"])<6) { 
    15831582        if ($wordbooker_settings['wordbooker_fb_comments_admin']) { 
    15841583            $xxx=wordbooker_get_cache(-99,facebook_id,1); 
     
    15931592            } 
    15941593         } 
    1595     #var_dump($wordbooker_settings); 
     1594        } 
    15961595        if (strlen($wordbooker_settings["fb_comment_app_id"])>6) { 
    15971596            echo '<meta property = "fb:app_id" content = "'.$wordbooker_settings["fb_comment_app_id"].'" /> '; 
     
    16201619            echo '<meta property="og:type" content="blog"/> '; 
    16211620        } 
    1622     }        
    1623  
    1624         #wordbooker_get_option('wordbook_description_meta_length') 
     1621        #wordbooker_get_option('wordbooker_description_meta_length') 
    16251622    if ($meta_length = wordbooker_get_option('wordbooker_description_meta_length')) { 
    16261623        if (is_single() || is_page()) { 
    16271624            $excerpt=get_post_meta($post->ID, '_wordbooker_extract', TRUE); 
     1625            if(strlen($excerpt) < 3 ) { 
     1626                $excerpt=wordbooker_post_excerpt($post->post_content,$wordbooker_post_options['wordbooker_extract_length']); 
     1627                update_post_meta($post->ID, '_wordbooker_extract', $excerpt); 
     1628            } 
    16281629            # If we've got an excerpt use that instead 
    16291630            if ((strlen($post->post_excerpt)>3) && (strlen($excerpt) <=3)) {  
     
    16611662    return $blah; 
    16621663} 
    1663 /* 
    1664 function wordbooker_fb_tags_insert($content) { 
    1665  
    1666      if(strpos($content, '[[WB_FB_LIKE]]') > 0)  
    1667         { 
    1668           $content = str_replace('[[WB_FB_LIKE]]',wordbooker_fb_like(true),$content); 
    1669         } 
    1670  
    1671      if(strpos($content, '[[WB_FB_SEND]]') > 0)  
    1672         { 
    1673           $content = str_replace('[[WB_FB_SEND]]',wordbooker_fb_send(true),$content); 
    1674         } 
    1675  
    1676      if(strpos($content, '[[WB_FB_SHARE]]') > 0)  
    1677         { 
    1678           $content = str_replace('[[WB_FB_SHARE]]',wordbooker_fb_share(true),$content); 
    1679         } 
    1680       return $content; 
    1681  
    1682      if(strpos($content, '[[WB_FB_COMMENT]]') > 0)  
    1683         { 
    1684           $content = str_replace('[[WB_FB_COMMENT]]',wordbooker_fb_comment(true),$content); 
    1685         } 
    1686       return $content; 
    1687  
    1688 } 
    1689 */ 
     1664 
    16901665function display_wordbooker_fb_comment() { 
    16911666    global $post; 
     1667    if(!is_single()){return;} 
    16921668    $wordbooker_settings = wordbooker_options();  
    16931669    $wordbooker_post_options= get_post_meta($post->ID, '_wordbooker_options', true);   
     
    17021678function wordbooker_fb_comment_inline() { 
    17031679    global $post; 
     1680    if(!is_single()){return;} 
    17041681    $wordbooker_settings = wordbooker_options();  
    17051682    $wordbooker_post_options= get_post_meta($post->ID, '_wordbooker_options', true);   
     
    17241701    if (isset($wordbooker_settings['wordbooker_share_button_frontpage'])  && is_front_page() ) {$do_share=1;} 
    17251702    if (isset($wordbooker_settings['wordbooker_share_button_category']) &&  is_category()  ) {$do_share=1;} 
     1703    if (isset($wordbooker_settings['wordbooker_no_share_stick']) &&  is_sticky()  ) {$do_share=0; } 
    17261704    if ( $do_share==1  && 
    17271705    ((isset($wordbooker_settings['wordbooker_share_button_post']) && is_single()  ) 
     
    17591737    if (isset($wordbooker_settings['wordbooker_share_button_frontpage'])  && is_front_page() ) {$do_share=1;} 
    17601738    if (isset($wordbooker_settings['wordbooker_share_button_category']) &&  is_category()  ) {$do_share=1;} 
     1739    if (isset($wordbooker_settings['wordbooker_no_share_stick']) &&  is_sticky()  ) {$do_share=0; } 
    17611740    if ( $do_share==1  && 
    17621741    ((isset($wordbooker_settings['wordbooker_share_button_post']) && is_single()  ) 
     
    17941773    if (isset($wordbooker_settings['wordbooker_like_button_frontpage'])  && is_front_page() ) {$do_like=1;} 
    17951774    if (isset($wordbooker_settings['wordbooker_like_button_category']) &&  is_category() && !is_front_page() ) {$do_like=1;} 
    1796  
     1775    if (isset($wordbooker_settings['wordbooker_no_like_stick']) &&  is_sticky()  ) { $do_like=0;} 
    17971776    if ( $do_like==1  && 
    17981777        ((isset($wordbooker_settings['wordbooker_like_button_post']) && is_single()  ) 
     
    18321811    if (isset($wordbooker_settings['wordbooker_like_button_frontpage'])  && is_front_page() ) {$do_like=1;} 
    18331812    if (isset($wordbooker_settings['wordbooker_like_button_category']) &&  is_category() && !is_front_page() ) {$do_like=1;} 
     1813    if (isset($wordbooker_settings['wordbooker_no_like_stick']) &&  is_sticky()  ) { $do_like=0;} 
    18341814 
    18351815    if ( $do_like==1  && 
     
    18711851    if (isset($wordbooker_settings['wordbooker_like_button_frontpage'])  && is_front_page() ) {$do_like=1;} 
    18721852    if (isset($wordbooker_settings['wordbooker_like_button_category']) &&  is_category() && !is_front_page() ) {$do_like=1;} 
    1873  
     1853    if (isset($wordbooker_settings['wordbooker_no_like_stick']) &&  is_sticky()  ) { $do_like=0;} 
    18741854    if ( $do_like==1  && 
    18751855        ((isset($wordbooker_settings['wordbooker_like_button_post']) && is_single()  ) 
     
    19121892    if (isset($wordbooker_settings['wordbooker_like_button_frontpage'])  && is_front_page() ) {$do_like=1;} 
    19131893    if (isset($wordbooker_settings['wordbooker_like_button_category']) &&  is_category() && !is_front_page() ) {$do_like=1;} 
    1914  
     1894    if (isset($wordbooker_settings['wordbooker_no_like_stick']) &&  is_sticky()  ) { $do_like=0;} 
    19151895    if ( $do_like==1  && 
    19161896        ((isset($wordbooker_settings['wordbooker_like_button_post']) && is_single()  ) 
     
    20101990    $tname=WORDBOOKER_USERSTATUS; 
    20111991    $query_fields='facebook_id,name,url,pic,status,updated,facebook_id'; 
    2012     if ($table==1) {$tname=WORDBOOKER_USERDATA;$query_fields='facebook_id,name,url,pic,status,updated,auths_needed,use_facebook';} 
     1992    $blog_lim=' and blog_id='.$blog_id; 
     1993    if ($table==1) {$tname=WORDBOOKER_USERDATA;$query_fields='facebook_id,name,url,pic,status,updated,auths_needed,use_facebook';$blog_lim='';} 
    20131994    if (isset($field)) {$query_fields=$field;} 
    20141995    if ($user_id==-99){  
     
    20202001    } 
    20212002    else { 
    2022     $query="select ".$query_fields." from ".$tname."  where user_ID=".$user_id." and blog_id = ".$blog_id; 
     2003    $query="select ".$query_fields." from ".$tname."  where user_ID=".$user_id.$blog_lim; 
    20232004#   var_dump($query); 
    20242005    $result = $wpdb->get_row($query); } 
    20252006    return $result; 
    20262007} 
     2008 
    20272009 
    20282010 
     
    22572239    global $wpdb,$blog_id; 
    22582240    # We need to get the lowest post_id from the post_queue which has the lowest priority ID 
    2259  
    22602241} 
    22612242 
     
    22632244    global $user_ID, $user_identity, $user_login, $wpdb, $blog_id; 
    22642245    # If this is an autosave then we give up and return as otherwise we lose user settings. 
    2265     #var_dump($post->post_author); 
    22662246    if ($_POST['action']=='autosave') { return;} 
    22672247 
     
    22742254 
    22752255    $wb_params = get_post_meta($post->ID, '_wordbooker_options', true);  
    2276 #   var_dump($wb_params); 
    2277     #wordbooker_debugger("Author data : ".$post->post_author." - ".$user_ID,' ',$post->ID,99) ; 
    2278     #wordbooker_debugger("Status Change from ".$oldstatus." to ".$newstatus,' ',$post->ID,99) ; 
    2279     # If the user isn't a wordbooker user and the blog admin hasn't allowed non wordbooker users to publish then we go home. 
    2280     #if ((! wordbooker_get_userdata($user_ID))  && ( !isset($wordbooker_settings['wordbook_publish_no_user'])))  { return;} 
    2281     # If we dont have and Wordbooker settings for this user then we need to get some from the stsete, 
    2282     if (! wordbooker_get_userdata($post->post_author)) { $wb_user_id=$wordbooker_settings["wordbook_default_author"];} 
    2283     if  ($wordbooker_settings["wordbook_default_author"] == 0 ) {$wb_user_id=$post->post_author;} else {$wb_user_id=$wordbooker_settings["wordbook_default_author"];} 
     2256    if (! wordbooker_get_userdata($post->post_author)) { $wb_user_id=$wordbooker_settings["wordbooker_default_author"];} 
     2257    if  ($wordbooker_settings["wordbooker_default_author"] == 0 ) {$wb_user_id=$post->post_author;} else {$wb_user_id=$wordbooker_settings["wordbooker_default_author"];} 
    22842258    if (! isset($_POST['soupy'])) { 
    22852259        wordbooker_debugger("Need to get options from the Meta and not the POST  "," ",$post->ID) ; 
     
    22882262            $wordbooker_settings = wordbooker_options(); 
    22892263            wordbooker_debugger("Getting settings for user : ",$wb_user_id,$post->ID) ;  
    2290             if (! wordbooker_get_userdata($wb_user_id)) { $wb_user_id=$wordbooker_settings["wordbook_default_author"];} 
     2264            if (! wordbooker_get_userdata($wb_user_id)) { $wb_user_id=$wordbooker_settings["wordbooker_default_author"];} 
    22912265            // then get the user level settings and override the blog level settings. 
    22922266 
    2293             $wordbook_user_settings_id="wordbookuser".$blog_id; 
    2294             $wordbookuser=get_usermeta($wb_user_id,$wordbook_user_settings_id); 
     2267            $wordbooker_user_settings_id="wordbookuser".$blog_id; 
     2268            $wordbookuser=get_usermeta($wb_user_id,$wordbooker_user_settings_id); 
    22952269            # If we have user settings then lets go through and override the blog level defaults. 
    22962270            if(is_array($wordbookuser)) { 
     
    23052279            # Need to put all the primary / secondary stuff in here. 
    23062280            $wordbooker_settings['wordbooker_publish_default']=$_POST['wordbooker_publish_default']; 
    2307             $wordbooker_settings['wordbooker_publish_override']=$_POST['wordbooker_publish_override']; 
     2281            $wordbooker_settings['wordbooker_publish_page_default']=$_POST['wordbooker_publish_page_default']; 
     2282            $wordbooker_settings['wordbooker_publish_post_default']=$_POST['wordbooker_publish_post_default']; 
     2283 
    23082284            } 
    23092285            #Now push these into the $_POST array. 
     
    23432319        wordbooker_debugger("Inside the press this / quick press block "," ",$post->ID) ; 
    23442320        # New get the user level settings from the DB 
    2345         $wordbook_user_settings_id="wordbookuser".$blog_id; 
    2346         $wordbookuser=get_usermeta($wb_user_id,$wordbook_user_settings_id); 
     2321        $wordbooker_user_settings_id="wordbookuser".$blog_id; 
     2322        $wordbookuser=get_usermeta($wb_user_id,$wordbooker_user_settings_id); 
    23472323        # If we have user settings then lets go through and override the blog level defaults. 
    23482324        if(is_array($wordbookuser)) { 
     
    23682344    if ( !wordbooker_get_userdata($user_ID)) { 
    23692345         
    2370         $wb_user_id=$wordbooker_settings["wordbook_default_author"]; 
     2346        $wb_user_id=$wordbooker_settings["wordbooker_default_author"]; 
    23712347        # New get the user level settings from the DB 
    2372         $wordbook_user_settings_id="wordbookuser".$blog_id; 
    2373         $wordbookuser=get_usermeta($wb_user_id,$wordbook_user_settings_id); 
     2348        $wordbooker_user_settings_id="wordbookuser".$blog_id; 
     2349        $wordbookuser=get_usermeta($wb_user_id,$wordbooker_user_settings_id); 
    23742350        # If we have user settings then lets go through and override the blog level defaults. 
    23752351        if(is_array($wordbookuser)) { 
     
    23932369    foreach (array_keys($_POST) as $key ) { 
    23942370        if (substr($key,0,8)=='wordbook') { 
    2395             #wordbooker_debugger("Saving $key ",$_POST[$key],$post->ID,99) ; 
    23962371            $wb_params[$key]=str_replace(array('&','"','\'','<','>',"\t",), array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),$_POST[$key]); 
    23972372        } 
    23982373    } 
    2399 #   $encoded_wb_params=str_replace('\\','\\\\',serialize($wb_params)); 
    24002374    if ($newstatus=="future") {  
    2401         $wb_params['wordbook_scheduled_post']=1; 
     2375        $wb_params['wordbooker_scheduled_post']=1; 
    24022376        wordbooker_debugger("This looks like a post that is scheduled for future publishing",$newstatus,$post->ID,99); 
    2403         wordbooker_debugger("Saving Options to Post Meta",' ',$post->ID,99) ; 
    2404         #update_post_meta($post->ID, '_wordbooker_options', $wb_params); 
    24052377    }    
    24062378    if ($newstatus=="publish" && (!isset($oldstatus) || $oldstatus!="publish") ) {  
    24072379        wordbooker_debugger("This looks like a new post being published ",$newstatus,$post->ID,99) ; 
    2408         $wb_params['wordbook_new_post']=1; 
    2409         wordbooker_debugger("Saving Options to Post Meta",' ',$post->ID,99) ; 
    2410         #update_post_meta($post->ID, '_wordbooker_options', $wb_params); 
    2411     } 
    2412  
    2413     #foreach (array_keys($wb_params) as $key){ 
    2414     #   wordbooker_debugger("Saved Post option : ".$key,$wb_params[$key],$post->ID) ; 
    2415     #}   
     2380        $wb_params['wordbooker_new_post']=1; 
     2381 
     2382    } 
     2383     
    24162384    update_post_meta($post->ID, '_wordbooker_options', $wb_params);  
    24172385#   var_dump($wb_params); 
     
    24372405    $wordbooker_settings = wordbooker_options(); 
    24382406    # If there is no user row for this user then set the user id to the default author. If the default author is set to 0 (i.e current logged in user) then only blog level settings apply. 
    2439     if (! wordbooker_get_userdata($post->post_author)) { $wb_user_id=$wordbooker_settings["wordbook_default_author"];} 
    2440     if  ($wordbooker_settings["wordbook_default_author"] == 0 ) {$wb_user_id=$post->post_author;} else {$wb_user_id=$wordbooker_settings["wordbook_default_author"];} 
     2407    if (! wordbooker_get_userdata($post->post_author)) { $wb_user_id=$wordbooker_settings["wordbooker_default_author"];} 
     2408    if  ($wordbooker_settings["wordbooker_default_author"] == 0 ) {$wb_user_id=$post->post_author;} else {$wb_user_id=$wordbooker_settings["wordbooker_default_author"];} 
    24412409    # If we've no FB user associated with this ID and the blog owner hasn't overridden then we give up. 
    2442     # If the referer is press-this then the user hasn't used the full edit post form so we need to get the blog/user level settings. 
    2443     # Also check for a missing user_id (i,e, user is not a wordbooker user), or if the extract_length is empty (wp-o-matic does that) 
    2444  
    2445     #else  
    2446     #{   
    2447     if ((! wordbooker_get_userdata($post->post_author))  && ( !isset($wordbooker_settings['wordbook_publish_no_user'])))  { wordbooker_debugger("Not a WB user (".$post->post_author.") and no overide - give up "," ",$post->ID,99) ; return;} 
    2448             if ((! wordbooker_get_userdata($wb_user_id))  && ( !isset($wordbooker_settings['wordbook_publish_no_user'])))  {wordbooker_debugger("Author (".$post->post_author.") not a WB user and no overide- give up "," ",$post->ID,99) ;  return;} 
     2410 
     2411    if ((! wordbooker_get_userdata($post->post_author))  && ( !isset($wordbooker_settings['wordbooker_publish_no_user'])))  { wordbooker_debugger("Not a WB user (".$post->post_author.") and no overide - give up "," ",$post->ID,99) ; return;} 
     2412    if ((! wordbooker_get_userdata($wb_user_id))  && ( !isset($wordbooker_settings['wordbooker_publish_no_user'])))  {wordbooker_debugger("Author (".$post->post_author.") not a WB user and no overide- give up "," ",$post->ID,99) ;  return;} 
    24492413        #} 
    24502414 
    2451     if ($_POST["wordbook_default_author"]== 0 ) { wordbooker_debugger("Author of this post is the Post Author"," ",$post->ID);  $_POST["wordbook_default_author"]=$post->post_author; } 
     2415    if ($_POST["wordbooker_default_author"]== 0 ) { wordbooker_debugger("Author of this post is the Post Author"," ",$post->ID);  $_POST["wordbooker_default_author"]=$post->post_author; } 
    24522416     
    24532417    // If soupy isn't set then its either a future post or a post inherting another users options so we need to get the meta data rather than rely on post data 
     
    25122476}  
    25132477 
    2514 function wordbooker_future_post($newstatus, $oldstatus=null, $post=null) { 
    2515     # This handles option saving for future posting and also fires when auto save fires. 
    2516     global $user_ID, $user_identity, $user_login, $wpdb, $blog_id,$post; 
    2517     #fts_shorturl 
    2518     # If this is an autosave then we give up and return as otherwise we lose user settings. 
    2519     if ($_POST['action']=='autosave') { return;} 
    2520     $wordbooker_settings = wordbooker_options(); 
    2521     $wordbooker_settings['wordbooker_scheduled_post']=0; 
    2522     if ($newstatus=="future") { $wordbooker_settings['wordbooker_scheduled_post']=1; } 
    2523     $wb_params=$wordbooker_settings; 
    2524 #   if ($newstatus=="future") { 
    2525         if (!current_user_can(WORDBOOKER_MINIMUM_ADMIN_LEVEL)) { wordbooker_debugger("This user doesn\'t have enough rights"," ",$post->ID) ; return;} 
    2526         # If the user isn't a wordbooker user and the blog admin hasn't allowed non wordbooker users to publish then we go home. 
    2527         if ((! wordbooker_get_userdata($user_ID))  && ( !isset($wordbooker_settings['wordbooker_publish_no_user'])))  {  wordbooker_debugger("Not a WB user"," ",$post->ID); return;} 
    2528         # If we dont have and Wordbooker settings for this user then we need to get some from the stsete, 
    2529         if ( !wordbooker_get_userdata($user_ID)) { 
    2530             $wb_user_id=$wordbooker_settings["wordbooker_default_author"]; 
    2531             # New get the user level settings from the DB 
    2532             $wordbooker_user_settings_id="wordbookuser".$blog_id; 
    2533             $wordbookuser=get_user_meta($wb_user_id,$wordbooker_user_settings_id); 
    2534             # If we have user settings then lets go through and override the blog level defaults. 
    2535             if(is_array($wordbookuser)) { 
    2536                 foreach (array_keys($wordbookuser) as $key) { 
    2537                     if ((strlen($wordbookuser[$key])>0) && ($wordbookuser[$key]!="0") ) { 
    2538                         $wordbooker_settings[$key]=$wordbookuser[$key]; 
    2539                     }  
    2540                 } 
    2541  
    2542             } 
    2543             # Then populate the post array. 
    2544                 if(is_array($wordbooker_settings)) { 
    2545                 foreach (array_keys($wordbooker_settings) as $key ) { 
    2546                     if (substr($key,0,8)=='wordbook') { 
    2547                         $_POST[$key]=str_replace( array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),array('&','"','\'','<','>',"\t"),$wordbooker_settings[$key]); 
    2548                     } 
    2549                 } 
    2550             } 
    2551         } 
    2552         # OK now lets get the settings from the POST array 
    2553         foreach (array_keys($_POST) as $key ) { 
    2554             if (substr($key,0,8)=='wordbook') { 
    2555                 $wb_params[$key]=str_replace(array('&','"','\'','<','>',"\t",), array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),$_POST[$key]); 
    2556             } 
    2557         } 
    2558         $encoded_wb_params=str_replace('\\','\\\\',serialize($wb_params)); 
    2559         update_post_meta($post->ID, '_wordbooker_options', $wb_params);  
    2560 #   } 
    2561 }  
    25622478 
    25632479 
     
    26302546 
    26312547function wordbooker_debugger($method,$error_msg,$post_id,$level=10) { 
    2632     #echo $method." - ".$error_msg."<br>"; 
    26332548    $diaglevel=wordbooker_get_option('wordbooker_advanced_diagnostics_level'); 
    26342549    if (!isset($diaglevel)) {$diglevel=-100;} 
     
    26772592/* Plugin maintenance. */ 
    26782593register_activation_hook(__FILE__, 'wordbooker_activate'); 
    2679 #register_deactivation_hook(__FILE__, 'wordbooker_deactivate'); 
    26802594add_action('delete_user', 'wordbooker_delete_user'); 
    26812595 
     
    27032617/* Post/page maintenance and publishing hooks. */ 
    27042618$wordbooker_disabled=wordbooker_get_option('wordbooker_disabled'); 
    2705 # If they've disabled Worbooker then we don't need any of these 
     2619# If they've disabled Wordbooker then we don't need any of these 
    27062620if (!isset($wordbooker_disabled)){ 
    27072621    add_action('transition_post_status', 'wordbooker_process_post_data',20,3); 
     
    27152629    add_action('wp_head', 'wordbooker_header'); 
    27162630    add_action('wp_footer', 'wordbooker_footer'); 
    2717     #add_action('transition_post_status', 'wordbooker_future_post'); 
    27182631    add_filter('language_attributes', 'wordbooker_schema'); 
    27192632    #add_filter('get_avatar','wordbooker_get_avatar'); 
     
    27312644# Includes - trying to keep my code base tidy. 
    27322645include("includes/wordbooker_options.php"); 
    2733 # If they've disabled Worbooker then we don't need to load any of these. 
     2646# If they've disabled Wordbooker then we don't need to load any of these. 
    27342647if (!isset($wordbooker_disabled)){ 
    27352648    include("includes/wordbooker_wb_widget.php"); 
     
    27382651    include("includes/wordbooker_posting.php"); 
    27392652    #include("includes/wordbooker_get_friend.php"); 
    2740     # This is for support for alternative posting processes. Only Curl is supported right now 
    2741     #if (wordbooker_get_option('wordbooker_fopen_curl')=='fopen'){ 
     2653} 
     2654# This is for support for alternative posting processes. Only Curl is supported right now 
     2655#if (wordbooker_get_option('wordbooker_fopen_curl')=='fopen'){ 
    27422656    #   include("includes/wordbooker_facebook_fopen.php"); 
    27432657    #}   
     
    27452659    include("includes/wordbooker_facebook_curl.php"); 
    27462660#   } 
    2747 } 
    2748  
    2749  
    27502661 
    27512662?> 
Note: See TracChangeset for help on using the changeset viewer.