[glotpress-updates] [GlotPress] #481: Add actions after Translations & Originals are created/updated

GlotPress noreply at wordpress.org
Sun Aug 9 04:40:08 UTC 2015


#481: Add actions after Translations & Originals are created/updated
----------------------+-----------------------
  Reporter:  dd32     |      Owner:
      Type:  defect   |     Status:  new
  Priority:  normal   |  Milestone:  1.0
 Component:  General  |    Version:
Resolution:           |   Keywords:  has-patch
----------------------+-----------------------

Comment (by dd32):

 [attachment:481.diff] is a basic attempt at this, by using the
 `GP_Thing::after_create()` and `GP_Thing::after_update()`.

 `GP_Translation` has been updated to use the `save()` method rather than
 the direct DB write `update()` method to be able to use the above methods,
 I can't see any issue with that.

 `GP_Original` doesn't have a `save` hook, only a `create` hook, the main
 reason is that it currently makes use of the `update( data.., array( 'id'
 => ..) )` syntax, which means we don't have a `GP_Original` object of that
 original available (and creating one would be wasteful performance wise).
 `GP_Original::after_save()` should probably be added for consistency, but
 I'm not seeing the real need for it. Realistically, my use-case for
 `original_created` could probably be replaced by using the
 `originals_imported` hook.. I'd like to hear others thoughts here.

 I've only tested this on the basic UI interactions, and haven't looked
 into the import process yet.

 My use-case: We need a plugin that can keep track of users submitted
 translations (well, the counts of them) and also to keep track of project
 translation status (# originals, # translated, # waiting, etc) in a
 separate table (Can't generate it on-the-fly for this use-case), and these
 hooks are the only way I can see to achieve it.

--
Ticket URL: <https://glotpress.trac.wordpress.org/ticket/481#comment:1>
GlotPress <https://glotpress.trac.wordpress.org>
Easy comin', easy goin'


More information about the glotpress-updates mailing list