Say what? - Version 1.6

Version Description

Introduce filters that allows back compatibility for plugins that change their text-domain. Props Pippin Williamson

Download this release

Release Info

Developer leewillis77
Plugin Icon 128x128 Say what?
Version 1.6
Comparing to
See all releases

Code changes from version 1.5 to 1.6

Files changed (3) hide show
  1. readme.txt +4 -1
  2. say-what-frontend.php +19 -1
  3. say-what.php +2 -2
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.leewillis.co.uk/wordpress-plugins/?utm_source=wordpress&
4
  Tags: string, change, translation
5
  Requires at least: 3.5
6
  Tested up to: 4.3
7
- Stable tag: 1.5
8
 
9
  == Description ==
10
  An easy-to-use plugin that allows you to alter strings on your site without editing WordPress core, or plugin code. Simply enter the current string, and what you want to replace it with and the plugin will automatically do the rest!
@@ -48,6 +48,9 @@ See the [GitHub homepage](https://github.com/leewillis77/say-what) for examples.
48
 
49
  == Changelog ==
50
 
 
 
 
51
  = 1.5 =
52
  Avoid warnings on initial activation.
53
  Avoid issues where strings contain HTML / entities
4
  Tags: string, change, translation
5
  Requires at least: 3.5
6
  Tested up to: 4.3
7
+ Stable tag: 1.6
8
 
9
  == Description ==
10
  An easy-to-use plugin that allows you to alter strings on your site without editing WordPress core, or plugin code. Simply enter the current string, and what you want to replace it with and the plugin will automatically do the rest!
48
 
49
  == Changelog ==
50
 
51
+ = 1.6 =
52
+ Introduce filters that allows back compatibility for plugins that change their text-domain. Props Pippin Williamson
53
+
54
  = 1.5 =
55
  Avoid warnings on initial activation.
56
  Avoid issues where strings contain HTML / entities
say-what-frontend.php CHANGED
@@ -37,10 +37,28 @@ class SayWhatFrontend {
37
 
38
  /**
39
  * Perform a string replacement with context.
 
 
 
 
 
 
 
40
  */
41
  public function gettext_with_context( $translated, $original, $context, $domain ) {
42
- if ( isset ( $this->replacements[ $domain ][ $original ][ $context ] ) ) {
 
 
 
 
43
  return $this->replacements[ $domain ][ $original ][ $context ];
 
 
 
 
 
 
 
44
  } else {
45
  return $translated;
46
  }
37
 
38
  /**
39
  * Perform a string replacement with context.
40
+ *
41
+ * Plugins can use the say_what_domain_aliases filter to return an alias for their domain
42
+ * if for any reason they change their text domain and want existing replacements to continue
43
+ * working. The filter should return an array keyed on the current text domain with the value
44
+ * set to an array of alternative domains to search for replacements. E.g
45
+ * $aliases['easy-digital-downloads'][] = 'edd';
46
+ * return $aliases;
47
  */
48
  public function gettext_with_context( $translated, $original, $context, $domain ) {
49
+ static $domain_aliases = null;
50
+ if ( $domain_aliases === null ) {
51
+ $domain_aliases = apply_filters( 'say_what_domain_aliases', array() );
52
+ }
53
+ if ( isset( $this->replacements[ $domain ][ $original ][ $context ] ) ) {
54
  return $this->replacements[ $domain ][ $original ][ $context ];
55
+ } elseif ( isset( $domain_aliases[ $domain ] ) ) {
56
+ foreach ( $domain_aliases[ $domain ] as $alias ) {
57
+ if ( isset( $this->replacements[ $alias ][ $original ][ $context ] ) ) {
58
+ return $this->replacements[ $alias ][ $original ][ $context ];
59
+ }
60
+ }
61
+ return $translated;
62
  } else {
63
  return $translated;
64
  }
say-what.php CHANGED
@@ -4,13 +4,13 @@
4
  Plugin Name: Say What?
5
  Plugin URI: https://github.com/leewillis77/say-what
6
  Description: An easy-to-use plugin that allows you to alter strings on your site without editing WordPress core, or plugin code
7
- Version: 1.5
8
  Author: Lee Willis
9
  Author URI: http://www.leewillis.co.uk/
10
  */
11
 
12
  /**
13
- * Copyright (c) 2013-2014 Lee Willis. All rights reserved.
14
  *
15
  * Released under the GPL license
16
  * http://www.opensource.org/licenses/gpl-license.php
4
  Plugin Name: Say What?
5
  Plugin URI: https://github.com/leewillis77/say-what
6
  Description: An easy-to-use plugin that allows you to alter strings on your site without editing WordPress core, or plugin code
7
+ Version: 1.6
8
  Author: Lee Willis
9
  Author URI: http://www.leewillis.co.uk/
10
  */
11
 
12
  /**
13
+ * Copyright (c) 2013-2015 Lee Willis. All rights reserved.
14
  *
15
  * Released under the GPL license
16
  * http://www.opensource.org/licenses/gpl-license.php