Created
December 14, 2014 02:01
-
-
Save hissy/fe0aa2582b78394a3a82 to your computer and use it in GitHub Desktop.
Really Simple CSV Importer Action add-on
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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