Skip to content

Instantly share code, notes, and snippets.

@hissy
Created December 14, 2014 02:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hissy/fe0aa2582b78394a3a82 to your computer and use it in GitHub Desktop.
Save hissy/fe0aa2582b78394a3a82 to your computer and use it in GitHub Desktop.
Really Simple CSV Importer Action add-on
<?php
/*
Plugin Name: Really Simple CSV Importer Action add-on
Description: Run the additional action after importing the post data
Author: Takuro Hishikawa
Version: 0.1
*/
class rscsvimporter_action {
// singleton instance
private static $instance;
public static function instance() {
if ( isset( self::$instance ) )
return self::$instance;
self::$instance = new rscsvimporter_action;
self::$instance->run_init();
return self::$instance;
}
private function __construct() {
/** Do nothing **/
}
protected function run_init() {
add_action( 'init', array( $this, 'add_action' ) );
}
public function add_action() {
add_filter( 'really_simple_csv_importer_post_saved', array( $this, 'add_comment'), 50 );
}
public function add_comment($post) {
$commentdata = array(
'comment_post_ID' => $post->ID,
'comment_content' => 'Imported comment.'
);
wp_new_comment( $commentdata );
}
}
$rscsvimporter_action = rscsvimporter_action::instance();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment