GithubHelp home page GithubHelp logo

awsmug / fanpage-import Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 11.0 512 KB

Import the Facebook Fanpage stream to WordPress with "Awesome Fanpage import"

PHP 97.51% CSS 0.24% JavaScript 1.31% Shell 0.94%

fanpage-import's People

Contributors

christianwach avatar heavybeard avatar kathlynns avatar mahype avatar ramen100 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fanpage-import's Issues

Missing Post keyword

Actually the plugin makes a new wp post with excerpt and description but it doesn't put a keyword so the seo is really low.
It would be nice to let the user set a default keyword or set it from the title.

Limit of 200 posts

Hi there.

I was checking your plugin and it works great, but verifying the code I could not understand why it doesn't work for more than 200 hundred posts.

Is it a limit from FB or something?

Thank you very much!

Make links in imported FB posts clickable.

Just a request to import links as...wait for it...links.

I'm using some hacky jquery to accomplish this now but the other major Twitter and Instagram importer plugins do this automatically.

Extend documentation

It would be nice to have an explanation in the docs, how one can customize the titles for the posts (when/while importing them) in the functions.php of your (child) theme - or an option to customize the titles in the plugin settings.

I'd prefere to have post titles like "Short news 02/07/2017" for example, instead of a shortened version of the posts text content... currently I changed it directly in the import-stream.php file, but this will be overwritten with plugin updates.

Add Facebook Post's link

I suggest to add a custom field on the Status Message CPT with the Facebook Post's link.

Maybe this is a good point to start, I added new functions on the FacebookFanpageImportAdmin class for creating a new Meta Box dedicated to all imported post's infos (now only the related facebook post URL).

File: ./components/admin/component.php

<?php
/**
 * Facebook Fanpage Import Showdata Component.
 * This class initializes the component.
 *
 * @author  mahype, awesome.ug <[email protected]>
 * @package Facebook Fanpage Import
 * @version 1.0.0-beta.7
 * @since   1.0.0
 * @license GPL 2
 *          Copyright 2016 Awesome UG ([email protected])
 *          This program is free software; you can redistribute it and/or modify
 *          it under the terms of the GNU General Public License, version 2, as
 *          published by the Free Software Foundation.
 *          This program is distributed in the hope that it will be useful,
 *          but WITHOUT ANY WARRANTY; without even the implied warranty of
 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *          GNU General Public License for more details.
 *          You should have received a copy of the GNU General Public License
 *          along with this program; if not, write to the Free Software
 *          Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class FacebookFanpageImportAdmin {
	var $name;

	/**
	 * Initializes the Component.
	 *
	 * @since 1.0.0
	 */
	function __construct() {
		$this->name = get_class( $this );
		$this->includes();

		if ( 'status' == get_option( 'fbfpi_insert_post_type' ) ) {
			add_action( 'init', array( $this, 'custom_post_types' ), 11 );
			add_action( 'add_meta_boxes', array( $this, 'custom_meta_box' ) );
			add_action( 'save_post', array( $this, 'custom_meta_box_save' ) );
		}
	}

	/**
	 * Including needed Files.
	 *
	 * @since 1.0.0
	 */
	private function includes() {
		require_once( dirname( __FILE__ ) . '/settings.php' );
	}

	/**
	 * Creates Custom Post Types
	 *
	 * @since 1.0.0
	 */
	public function custom_post_types() {
		$args_post_type = array(
			'labels'      => array(
				'name'          => __( 'Status Messages', 'fbfpi-locale' ),
				'singular_name' => __( 'Status Message', 'fbfpi-locale' )
			),
			'public'      => true,
			'has_archive' => true,
			'supports'    => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ),
			'rewrite'     => array(
				'slug'       => 'status-message',
				'with_front' => true
			)
		);

		register_post_type( 'status-message', $args_post_type );
	}

	/**
	 * Add Meta Box for Facebook Post infos
	 */
	public function custom_meta_box() {
		add_meta_box( 'facebook-post-info-meta-box', __( 'Facebook Post Infos', 'fbfpi-locale' ), array( $this, 'meta_box_output'), 'status-message', 'side', 'high' );
	}

	/**
	 * Output the Meta box on backoffice
	 */
	public function meta_box_output( $post ) {
		// create a nonce field
		wp_nonce_field( 'my_fbfpi_meta_box_nonce', 'fbfpi_meta_box_nonce' ); ?>

		<p>
			<label for="fbfpi_facebook_post_url"><?php _e( 'Post URL', 'fbfpi-locale' ); ?>:</label>
			<input type="text" name="fbfpi_facebook_post_url" id="fbfpi_facebook_post_url" value="<?php echo $this->get_custom_field( 'fbfpi_facebook_post_url' ); ?>" />
		</p>

		<?php
	}

	/**
	 * Save the Meta box value
	 */
	public function custom_meta_box_save( $post_id ) {
		// Stop the script when doing autosave
		if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;

		// Verify the nonce. If insn't there, stop the script
		if( !isset( $_POST['fbfpi_meta_box_nonce'] ) || !wp_verify_nonce( $_POST['fbfpi_meta_box_nonce'], 'my_fbfpi_meta_box_nonce' ) ) return;

		// Stop the script if the user does not have edit permissions
		if( !current_user_can( 'edit_post', get_the_id() ) ) return;

		// Save the textfield
		if( isset( $_POST['fbfpi_facebook_post_url'] ) )
			update_post_meta( $post_id, 'fbfpi_facebook_post_url', esc_attr( $_POST['fbfpi_facebook_post_url'] ) );
	}

	/**
	 * Return the custom field selected
	 */
	private function get_custom_field( $value ) {
		global $post;

		$custom_field = get_post_meta( $post->ID, $value, true );
		if ( !empty( $custom_field ) )
			return is_array( $custom_field ) ? stripslashes_deep( $custom_field ) : stripslashes( wp_kses_decode_entities( $custom_field ) );

		return false;
	}
}

$FacebookFanpageImportAdmin = new FacebookFanpageImportAdmin();

it is Import only one image multi time

Hello,
First thanks for nice plugin.

I have a one problem this plugin import only one image more then one time.
Only Image not other data.
check attachment images. it is load more then 10 same image daily. i need to delete manulrey other wise one day my server will full.

Need help from your side ASAP.

media library joma motorkleding wordpress 2016-05-25 19-12-29

After Activating the Plugin the site take to time to Load

When we activate this plugin the site take to time to load and many js is included when we check in some page speed tools. We are using digitalocean.com this server. And some time its take 2GB memory.
Whats the problem can you please solve it out?
screen shot 2016-05-25 at 13 41 52

Admin UI: add FB icon?

/**
* Creates Custom Post Types
*
* @since 1.0.0
*/
public function custom_post_types() {
$args_post_type = array(
'labels' => array(
'name' => __( 'Status Messages', 'fbfpi-locale' ),
'singular_name' => __( 'Status Message', 'fbfpi-locale' )
),
'public' => true,
'has_archive' => true,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ),
'rewrite' => array(
'slug' => 'status-message',
'with_front' => true
)
);
register_post_type( 'status-message', $args_post_type );
}

Just adding this to $args_post_type adds a nice FB icon in the admin menu:

'menu_icon' => 'dashicons-facebook'

FB admin menu icon

Would send PR if welcome. ๐Ÿ˜‰

Get rid of Skip

Removing Skip framework, because it's overloading CSS and JS. Not needed for these sum of options.

Rename template file

Currently (1.0.0. beta 7) there is a template file photo.php

Thanks to that file you can create your own template file in you theme or even child theme to overwrite the default html output.

But the name photo.php is very generic and possibly already used, e.g. by parent theme template files.

I suggest to change the filename an add a shortname for the plugin so it's clear what this template file belongs to in a customized child theme.

E.g. ffpi_photo.php or something like that

Cleaning up Classnames

For a better readability of classnames and analog to functions the classnames will get underscores between words.

no longer usable for private / non profit organisations

This plugin will no longe usable unless you adapt to new Facebook Developer Guidelines.

Facebook has deprecated the GraphAPI node "publish_pages" and "manage_pages" and replaced them with 6 new access nodes.
To be able to use the most important access nodes, especially "pages_read_enagement", you need to register your business account in Facebook and you will have to add your Facebook app to your business manager and thus need to verify your "business" by providing official documents and signing new contracts with Facebook.

This makes the use of this plugin at least impossible for private Fanpages or smaller non profit organisations (in my opinion).

Set post date as image date

When importing older facebook posts manually all the images are saved in the current month folder.

I'd suggest to change the fetch_picture function and add the post date.

So all imported images are saved in the correct year/month folder structure...

Application request limit reached | FB App

Full error:

FanPage {
  ["error"]=>
  object(stdClass)#6219 (5) {
    ["message"]=>
    string(38) "(#4) Application request limit reached"
    ["type"]=>
    string(14) "OAuthException"
    ["is_transient"]=>
    bool(true)
    ["code"]=>
    int(4)
    ["fbtrace_id"]=>
    string(11) "CarFGcD42Ls"
  }
}

Searching the error i found this question on stackoverflow, and seems that The Facebook API limit isn't really documented, but apparently it's something like: 600 calls per 600 seconds, per token & per IP.

So I've tried to disable the plugin for some days but this do not solve the issue, i think that could be helpful if you (@mahype ) check your app from the facebook developer dashboard.

KR

Add template files for other post types as well

Currently (1.0.0 beta 7) there is only a template file for the post type photo.

It would be nice to have template files for the other post types as well (link, video, event...)

That way it would be easily possible to overwrite the default html output with customized templates in the (child) themes... and these changes won't be overwritten when there is a plugin update available.

No Data retrieved from FB page

In get_posts() function | facebook.php the $url is correct, but the array of data retrieved is always empty.
Maybe is for the new GDPR or for a new fb graph policy, i don't know.
But i've tried on fb graph and works well.

Could you please check it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.