PluginProbe
WPIDE – File Manager & Code Editor / 3.5.10
WPIDE – File Manager & Code Editor v3.5.10
3.5.10 3.5.9 3.5.8 3.5.7 2.0.14 2.0.15 2.0.16 2.0.2 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1 2.2 2.3 2.3.1 2.3.2 2.4.0 2.5 2.6 3.0 3.1 3.2 All 56 releases
wpide / freemius / patches / wp-pot+1.10.2.patch

wp-pot+1.10.2.patch in WPIDE – File Manager & Code Editor 3.5.10, at freemius/patches/wp-pot+1.10.2.patch

49 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 diff --git a/node_modules/wp-pot/src/parsers/php-parser.js b/node_modules/wp-pot/src/parsers/php-parser.js
2 index c8f411d..319a5da 100644
3 --- a/node_modules/wp-pot/src/parsers/php-parser.js
4 +++ b/node_modules/wp-pot/src/parsers/php-parser.js
5 @@ -220,6 +220,32 @@ class PHPParser {
6 return comment;
7 }
8
9 + /**
10 + * Get method name from property lookup, going as deep as necessary.
11 + * Example: $this->plugin->text_domain->translate
12 + *
13 + * @param {object} what
14 + * @return {string}
15 + * @private
16 + */
17 + _getMethodNameFromPropertyLookup(what) {
18 + let methodName = [];
19 +
20 + while(what) {
21 + if (what.kind === 'propertylookup') {
22 + methodName.push(what.offset.name);
23 + what = what.what;
24 + } else if (what.kind === 'variable') {
25 + methodName.push(what.name);
26 + what = null;
27 + } else {
28 + what = null;
29 + }
30 + }
31 +
32 + return `\$${methodName.reverse().join('->')}`;
33 + }
34 +
35 /**
36 * Check if ast is a valid function call
37 *
38 @@ -231,8 +257,8 @@ class PHPParser {
39 if (ast.kind === 'call') {
40 let methodName = ast.what.name;
41
42 - if (ast.what.kind === 'propertylookup' && ast.what.what.kind === 'variable') {
43 - methodName = ['$', ast.what.what.name, '->', ast.what.offset.name].join('');
44 + if (ast.what.kind === 'propertylookup') {
45 + methodName = this._getMethodNameFromPropertyLookup(ast.what);
46 } else if (ast.what.kind === 'name' && ast.what.resolution === 'fqn') {
47 methodName = ast.what.name.replace(/^\\/, '');
48 }
49