Last active
August 29, 2015 14:08
-
-
Save hissy/ed0f5d2b57213ceffab3 to your computer and use it in GitHub Desktop.
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 add-on: Comma | |
Version: 0.1 | |
*/ | |
class rscsvimporter_comma { | |
// singleton instance | |
private static $instance; | |
public static function instance() { | |
if ( isset( self::$instance ) ) | |
return self::$instance; | |
self::$instance = new rscsvimporter_comma; | |
self::$instance->run_init(); | |
return self::$instance; | |
} | |
private function __construct() { | |
/** Do nothing **/ | |
} | |
protected function run_init() { | |
add_action( 'init', array( $this, 'add_filter' ) ); | |
} | |
public function add_filter() { | |
add_filter( 'really_simple_csv_importer_save_tax', array( $this, 'replace_comma'), 10, 3 ); | |
} | |
public function replace_comma($tax, $post, $is_update) { | |
$_tax = array(); | |
foreach ($tax as $tax_name => $terms) { | |
$_term = array(); | |
foreach ($terms as $term) { | |
$_term[] = str_replace('..', ',', $term); | |
} | |
$_tax[$tax_name] = $_term; | |
} | |
return $_tax; | |
} | |
} | |
$rscsvimporter_comma = rscsvimporter_comma::instance(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment