/**
* Auto post to facebook from wordpress/website
* Author -> Nasir Uddin Nobin
*/
function fb_update($ID, $post)
{
    /**
     * download facebook php sdk https://github.com/facebookarchive/facebook-php-sdk
     * upload it to your directory and include it
     * if you paste this code to plugin file use (plugin_dir_path(__FILE__) 
     */
    require_once get_template_directory_uri() . '/facebook-php-sdk/autoload.php';
    // cleaning html tags and bbcodes
    $content = strip_tags($post->post_content);
    $content = preg_replace("/\\[.+\\](.+)|\\s\\s+\\[\\/.+\\]/i", "\$1", $content);
    // getting $permalink from id
    $permalink = get_permalink($ID);
    $fb = new Facebook\Facebook(['app_id' => '{your-ap-id}', 'app_secret' => '{app-secret}', 'default_graph_version' => 'v2.2']);
    /**
     * generate your page long live access token 
     * you may use https://developers.facebook.com/tools/explorer
     * Permissions: manage_pages, publish_pages
     */
    $accessToken = '{give-your-long-live-page-access-token}';
    $linkData = ['link' => $permalink, 'message' => short_content($content, $num = 35) . "\n  \t\n  \tRead more: {$permalink}\n  \t\n  \t"];
    try {
        $response = $fb->post('/me/feed', $linkData, $accessToken);
    } catch (Facebook\Exceptions\FacebookResponseException $e) {
    } catch (Facebook\Exceptions\FacebookSDKException $e) {
    }
}
Пример #2
0
	<?php 
if (is_singular()) {
    ?>
		<div class="widget-container">
			<div class="box-author">
				<a href="<?php 
    the_author_url();
    ?>
" target="_blank"><?php 
    echo get_avatar(get_the_author_ID(), 70);
    ?>
</a>
				<div class="info">
					<span>About the author:</span>
					<p><?php 
    echo short_content(get_the_author_meta('description'), 70, '(...)');
    ?>
</p>
				</div>
			</div>
		</div>
	<?php 
}
?>
	<?php 
if (!dynamic_sidebar()) {
    ?>

	<?php 
}
?>
Пример #3
0
            }
            ?>
				 <a href="<?php 
            comments_link();
            ?>
"><?php 
            comments_number('No comments', '1 Comment', '% Comments');
            ?>
</a></span>
			<?php 
            echo $GLOBALS['socialshare']->getSocials(get_permalink(), 'mini', get_the_title(get_the_ID()));
            ?>
	
			<div class="entry-content">
			<?php 
            $cont = short_content(get_the_content());
            echo '<p><a href="' . get_permalink() . '" class="content-link">' . $cont . '</a></p>';
            ?>
			</div>
			<a href="<?php 
            the_permalink();
            ?>
" class="link-more">more</a>
		</div>
		<?php 
            comments_template('', true);
            ?>
	</article>	
	<?php 
        }
    }