From 96cae03e41746235a150b3e8c637e326ee6a6078 Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Sat, 27 Feb 2021 11:22:44 -0300 Subject: [PATCH] fix: test if log is enabled #457 --- src/classes/repositories/class-tainacan-logs.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/classes/repositories/class-tainacan-logs.php b/src/classes/repositories/class-tainacan-logs.php index 55f3bc6af..075e0f973 100644 --- a/src/classes/repositories/class-tainacan-logs.php +++ b/src/classes/repositories/class-tainacan-logs.php @@ -260,6 +260,10 @@ class Logs extends Repository { $collection_id = method_exists($entity, 'get_collection_id') ? $entity->get_collection_id() : 'default'; + if ( method_exists($entity, 'get_repository') && !$entity->get_repository()->use_logs ) { + return; + } + if ( $entity instanceof Entities\Collection ) { $collection_id = $entity->get_id(); $log->set_title( sprintf( __( 'New file was attached to Collection "%s"', 'tainacan'), $entity->get_name() ) ); @@ -272,15 +276,11 @@ class Logs extends Repository { $object_type = get_class($entity); $object_id = $entity->get_id(); - $diff = []; - $log->set_collection_id($collection_id); $log->set_object_type($object_type); $log->set_object_id($object_id); $log->set_action('new-attachment'); - $title = __( sprintf('') , 'tainacan'); - $prepared = [ 'id' => $attachment->ID, 'title' => $attachment->post_title, @@ -313,7 +313,9 @@ class Logs extends Repository { $entity = Repository::get_entity_by_post( $entity_post ); if ( $entity ) { - + if ( method_exists($entity, 'get_repository') && !$entity->get_repository()->use_logs ) { + return; + } $collection_id = method_exists($entity, 'get_collection_id') ? $entity->get_collection_id() : 'default'; $log = new Entities\Log();