WordPress.org

Forums

Post To Facebook
[resolved] Better use way to use enqueue (1 post)

  1. Paul Phillips
    Member
    Posted 3 years ago #

    New version to fall in-line with latest WordPress enqueue rules

    `<?php
    /*
    Plugin Name: Post-to-Facebook
    Version: 1.0.7
    Plugin URI: http://blog.yeticode.co.uk/post-to-facebook
    Description: Provides the ability to quickly post a blog item to your facebook mini feed.
    Author: John Tindell
    Author URI: http://blog.yeticode.co.uk/
    */

    // Modded enqueue method for styles and js for WordPress 3.3+

    function post_to_facebook_gui()
    {
    $options = get_option('P2FB_Options',"");
    if($options != '')
    {
    ?>
    <script type="text/javascript">
    jQuery(document).ready(function(){
    p2fb_init("<?php print $options ?>");
    });
    </script>
    <?php
    // clear the session value that was
    update_option('P2FB_Options','');
    }
    ?>
    <div id="publishing-action">
    <input type="submit" value="Post to Facebook" id="post-to-facebook" class="button-primary" name="post-to-facebok"/>
    </div>
    <?php
    }
    function post_to_facebook($post_id) {
    if($_POST['post-to-facebok']){
    $permalink = get_permalink($post_id);
    // is there a better way to do this? what about multiple posting?
    update_option('P2FB_Options',$permalink);
    }
    }
    function p2fb_css() {
    wp_register_style( 'post-to-facebook_css', get_bloginfo('wpurl') .'/wp-content/plugins/post-to-facebook/post-to-facebook.css', false, '1.0.0' );
    wp_enqueue_style( 'post-to-facebook_css' );
    }
    function p2fb_scripts(){
    wp_register_script( 'post-to-facebook_js',get_bloginfo('wpurl').'/wp-content/plugins/post-to-facebook/post-to-facebook.js',array( 'jquery' ), '');
    wp_enqueue_script( 'post-to-facebook_js' );
    }
    add_action('admin_enqueue_scripts','p2fb_scripts');
    add_action('post_submitbox_start','post_to_facebook_gui');
    add_action('save_post','post_to_facebook',10,2);
    add_action('admin_enqueue_scripts', 'p2fb_css');

    http://wordpress.org/extend/plugins/post-to-facebook/

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Post To Facebook
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic