function wordbooker_status_update($post_id, $access_token, $post_date, $target_id, $dummy, $target_name) { global $wordbooker_post_options, $user_ID; wordbooker_debugger("Setting status_text" . $wordbooker_post_options['wordbooker_status_update_text'], " ", $post_id); if (isset($dummy)) { wordbooker_debugger("Status update to " . $target_name . " Test Only", 'No Post Made', $post_id, 90); return; } $status_text = parse_wordbooker_attributes(stripslashes($wordbooker_post_options['wordbooker_status_update_text']), $post_id, strtotime($post_date)); $status_text = wordbooker_post_excerpt($status_text, 420); $data = array('access_token' => $access_token, 'message' => $status_text); try { $result = wordbooker_fb_status_update($data, $target_id); wordbooker_store_post_result($post_id, $result->id); wordbooker_debugger("Status update to " . $target_name . " suceeded result : ", $result->id, $post_id, 90); } catch (Exception $e) { $error_code = $e->getCode(); $error_msg = $e->getMessage(); wordbooker_append_to_errorlogs($method, $error_code, $error_msg, $post_id, $user_ID); wordbooker_debugger("Status Update to " . $target_name . " failed : " . $error_msg, $post_id, 99); } }
function wordbooker_og_tags() { global $post; $bname = get_bloginfo('name'); $bdesc = get_bloginfo('description'); $wplang = wordbooker_get_language(); $wordbooker_settings = wordbooker_options(); # Always put out the tags because even if they are not using like/share it gives Facebook stuff to work with. $wordbooker_post_options = get_post_meta($post->ID, '_wordbooker_options', true); $wpuserid = $post->post_author; if (is_array($wordbooker_post_options)) { if ($wordbooker_post_options["wordbooker_default_author"] > 0) { $wpuserid = $wordbooker_post_options["wordbooker_default_author"]; } } $blog_name = get_bloginfo('name'); echo '<!-- Wordbooker generated tags -->'; echo '<meta property="og:locale" content="' . $wplang . '"/> '; echo '<meta property="og:site_name" content="' . $bname . ' - ' . $bdesc . '"/> '; if (strlen($wordbooker_settings["fb_comment_app_id"]) < 6) { if ($wordbooker_settings['wordbooker_fb_comments_admin']) { $xxx = wordbooker_get_cache(-99, facebook_id, 1); if (!is_null($xxx)) { echo '<meta property="fb:admins" content="' . $xxx . '"/> '; } } else { $xxx = wordbooker_get_cache($wpuserid, facebook_id, 1); if (!is_null($xxx->facebook_id)) { echo '<meta property="fb:admins" content="' . $xxx->facebook_id . '"/> '; } } } if (strlen($wordbooker_settings["fb_comment_app_id"]) > 6) { echo '<meta property = "fb:app_id" content = "' . $wordbooker_settings["fb_comment_app_id"] . '" /> '; } if (defined('WORDBOOKER_PREMIUM')) { echo '<meta property = "fb:app_id" content = "' . WORDBOOKER_FB_ID . '" /> '; } if ((is_single() || is_page()) && !is_front_page() && !is_category() && !is_home()) { $post_link = get_permalink($post->ID); $post_title = $post->post_title; echo '<meta property="og:title" content="' . htmlspecialchars(strip_tags($post_title), ENT_QUOTES) . '"/> '; echo '<meta property="og:url" content="' . $post_link . '"/> '; echo '<meta property="og:type" content="article"/> '; $ogimage = get_post_meta($post->ID, '_wordbooker_thumb', TRUE); if (strlen($ogimage) < 4 && strlen($wordbooker_settings['wb_wordbooker_default_image']) > 4) { $ogimage = $wordbooker_settings['wb_wordbooker_default_image']; } if (strlen($ogimage) < 4) { $ogimage = get_bloginfo('wpurl') . '/wp-content/plugins/wordbooker/includes/wordbooker_blank.jpg'; } if (strlen($ogimage) > 4) { echo '<meta property="og:image" content="' . $ogimage . '"/> '; } } else { # Not a single post so we only need the og:type tag echo '<meta property="og:type" content="blog"/> '; echo '<meta property="og:type" content="' . get_bloginfo('description') . '"/> '; } if ($meta_length = wordbooker_get_option('wordbooker_description_meta_length')) { if (is_single() || is_page()) { $excerpt = get_post_meta($post->ID, '_wordbooker_extract', TRUE); if (strlen($excerpt) < 5) { $excerpt = wordbooker_post_excerpt($post->post_content, $wordbooker_settings['wordbooker_extract_length']); update_post_meta($post->ID, '_wordbooker_extract', $excerpt); } # If we've got an excerpt use that instead if (strlen($post->post_excerpt) > 3 && strlen($excerpt) <= 5) { $excerpt = $post->post_excerpt; $description = str_replace('"', '"', $post->post_content); $excerpt = wordbooker_post_excerpt($description, $meta_length); $excerpt = preg_replace('/(\\r|\\n)+/', ' ', $excerpt); $excerpt = preg_replace('/\\s\\s+/', ' ', $excerpt); update_post_meta($post->ID, '_wordbooker_extract', $excerpt); } # Now if we've got something put the meta tag out. if (isset($excerpt)) { $meta_string = sprintf("<meta name=\"description\" content=\"%s\"/> ", htmlspecialchars($excerpt, ENT_QUOTES)); $meta_string .= sprintf("<meta property=\"og:description\" content=\"%s\"/> ", htmlspecialchars($excerpt, ENT_QUOTES)); echo $meta_string; } } else { $meta_string = sprintf("<meta name=\"description\" content=\"%s\"/> ", get_bloginfo('description')); $meta_string .= sprintf("<meta property=\"og:description\" content=\"%s\"/> ", htmlspecialchars($excerpt, ENT_QUOTES)); echo $meta_string; } } echo '<!-- End Wordbooker og tags -->'; }