add suffix to log title when Importing #261
This commit is contained in:
parent
4b382f84b4
commit
1ab013d6f8
|
@ -145,7 +145,7 @@ class Log extends Entity {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function set_title( $value ) {
|
public function set_title( $value ) {
|
||||||
$this->set_mapped_property( 'title', $value );
|
$this->set_mapped_property( 'title', apply_filters('tainacan-log-set-title', $value) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,6 +41,8 @@ class Logs extends Repository {
|
||||||
add_action( 'add_attachment', array( $this, 'insert_attachment' ) );
|
add_action( 'add_attachment', array( $this, 'insert_attachment' ) );
|
||||||
add_action( 'delete_attachment', array( $this, 'pre_delete_attachment' ) );
|
add_action( 'delete_attachment', array( $this, 'pre_delete_attachment' ) );
|
||||||
add_action( 'delete_post', array( $this, 'delete_attachment' ) );
|
add_action( 'delete_post', array( $this, 'delete_attachment' ) );
|
||||||
|
|
||||||
|
add_filter('tainacan-log-set-title', [$this, 'filter_log_title']);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _get_map() {
|
protected function _get_map() {
|
||||||
|
@ -412,6 +414,7 @@ class Logs extends Repository {
|
||||||
|
|
||||||
if ( $creating ) {
|
if ( $creating ) {
|
||||||
$diff['new'] = $unsaved->_toArray();
|
$diff['new'] = $unsaved->_toArray();
|
||||||
|
$has_diff = true;
|
||||||
} else {
|
} else {
|
||||||
$map = $unsaved->get_repository()->get_map();
|
$map = $unsaved->get_repository()->get_map();
|
||||||
|
|
||||||
|
@ -754,5 +757,13 @@ class Logs extends Repository {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function filter_log_title($title) {
|
||||||
|
if (defined('TAINACAN_DOING_IMPORT') && true === TAINACAN_DOING_IMPORT) {
|
||||||
|
$_title = __('Importer', 'tainacan');
|
||||||
|
$title .= " ($_title)";
|
||||||
|
}
|
||||||
|
return $title;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -31,6 +31,8 @@ class Background_Importer extends Background_Process {
|
||||||
$data = $batch->data;
|
$data = $batch->data;
|
||||||
$key = $batch->key;
|
$key = $batch->key;
|
||||||
|
|
||||||
|
define('TAINACAN_DOING_IMPORT', true);
|
||||||
|
|
||||||
$className = $data['class_name'];
|
$className = $data['class_name'];
|
||||||
if (class_exists($className)) {
|
if (class_exists($className)) {
|
||||||
$object = new $className($data);
|
$object = new $className($data);
|
||||||
|
|
|
@ -159,24 +159,8 @@ abstract class Importer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add_filter('tainacan-entity-set-property', [$this, 'filter_log_title']);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function filter_log_title($title, $prop, $entity) {
|
|
||||||
// if ($entity instanceof Entities\Log && $prop == 'title') {
|
|
||||||
// global $Tainacan_Importer_Handler;
|
|
||||||
// $importer = $Tainacan_Importer_Handler->get_importer_by_object($this);
|
|
||||||
// if ($importer && isset($importer['name'])) {
|
|
||||||
// // translators: %s is the name of the importer. Ex: CSV Importer
|
|
||||||
// $_title = sprintf( __('%s Importer'), $importer['name'] );
|
|
||||||
// } else {
|
|
||||||
// $_title = __('Importer');
|
|
||||||
// }
|
|
||||||
// $title .= " ($_title)";
|
|
||||||
// }
|
|
||||||
// return $title;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public function _to_Array($short = false) {
|
public function _to_Array($short = false) {
|
||||||
$return = ['id' => $this->get_id()];
|
$return = ['id' => $this->get_id()];
|
||||||
|
|
Loading…
Reference in New Issue