[wp-trac] [WordPress Trac] #38098: Use common naming for context switching functions / classes

WordPress Trac noreply at wordpress.org
Mon Sep 19 17:38:51 UTC 2016


#38098: Use common naming for context switching functions / classes
--------------------------+------------------------------
 Reporter:  swissspidy    |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by flixos90):

 Ah, now it makes sense to me! :)

 I like the idea of adding such an interface. About the existing function
 names, on the one hand I think we should try to align with them as we
 can't change them. Since the only functions that already exist (of those
 that you mentioned) are `switch_to_blog()` and `restore_current_blog()`, I
 think we should use those prefixes for the method names of such an
 interface. On the other hand `restore_previous()` really would be more
 accurate than `restore_current()`.

 Regarding the interface you suggested:
 * I would prefer not to use `clear()` as method name. Think about wrapping
 functions like `clear_blog()`, that sounds more like a destructive action.
 Instead I'd propose to use `restore_original()`, and the method you called
 `restore()` could become `restore_current()` or `restore_previous()`
 (depending on what we decide, see above).
 * I think the suffix in `switch_to()` is unnecessary, we could also call
 the method `switch()` (also, I assume you simply missed that in the above
 snippet, but let's keep in mind that we need a parameter there :) ).

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38098#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list