@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | // autoload_namespaces.php @generated by Composer |
4 | 4 | |
5 | -$vendorDir = dirname( ( __DIR__ ) ); |
|
6 | -$baseDir = dirname( $vendorDir ); |
|
5 | +$vendorDir = dirname((__DIR__)); |
|
6 | +$baseDir = dirname($vendorDir); |
|
7 | 7 | |
8 | 8 | return array(); |
@@ -1,30 +1,30 @@ |
||
1 | 1 | <?php return array( |
2 | - 'root' => |
|
3 | - array( |
|
4 | - 'pretty_version' => 'dev-develop', |
|
5 | - 'version' => 'dev-develop', |
|
6 | - 'aliases' => |
|
7 | - array(), |
|
8 | - 'reference' => '2b5035defcc45dcd4370a5865ba4fe5e91035435', |
|
9 | - 'name' => '__root__', |
|
10 | - ), |
|
11 | - 'versions' => |
|
12 | - array( |
|
13 | - '__root__' => |
|
14 | - array( |
|
15 | - 'pretty_version' => 'dev-develop', |
|
16 | - 'version' => 'dev-develop', |
|
17 | - 'aliases' => |
|
18 | - array(), |
|
19 | - 'reference' => '2b5035defcc45dcd4370a5865ba4fe5e91035435', |
|
20 | - ), |
|
21 | - 'deliciousbrains/wp-background-processing' => |
|
22 | - array( |
|
23 | - 'pretty_version' => '1.0.2', |
|
24 | - 'version' => '1.0.2.0', |
|
25 | - 'aliases' => |
|
26 | - array(), |
|
27 | - 'reference' => '2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800', |
|
28 | - ), |
|
29 | - ), |
|
2 | + 'root' => |
|
3 | + array( |
|
4 | + 'pretty_version' => 'dev-develop', |
|
5 | + 'version' => 'dev-develop', |
|
6 | + 'aliases' => |
|
7 | + array(), |
|
8 | + 'reference' => '2b5035defcc45dcd4370a5865ba4fe5e91035435', |
|
9 | + 'name' => '__root__', |
|
10 | + ), |
|
11 | + 'versions' => |
|
12 | + array( |
|
13 | + '__root__' => |
|
14 | + array( |
|
15 | + 'pretty_version' => 'dev-develop', |
|
16 | + 'version' => 'dev-develop', |
|
17 | + 'aliases' => |
|
18 | + array(), |
|
19 | + 'reference' => '2b5035defcc45dcd4370a5865ba4fe5e91035435', |
|
20 | + ), |
|
21 | + 'deliciousbrains/wp-background-processing' => |
|
22 | + array( |
|
23 | + 'pretty_version' => '1.0.2', |
|
24 | + 'version' => '1.0.2.0', |
|
25 | + 'aliases' => |
|
26 | + array(), |
|
27 | + 'reference' => '2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800', |
|
28 | + ), |
|
29 | + ), |
|
30 | 30 | ); |
@@ -6,119 +6,119 @@ |
||
6 | 6 | |
7 | 7 | class InstalledVersions { |
8 | 8 | |
9 | - private static $installed = array( |
|
10 | - 'root' => |
|
11 | - array( |
|
12 | - 'pretty_version' => 'dev-develop', |
|
13 | - 'version' => 'dev-develop', |
|
14 | - 'aliases' => |
|
15 | - array(), |
|
16 | - 'reference' => '2b5035defcc45dcd4370a5865ba4fe5e91035435', |
|
17 | - 'name' => '__root__', |
|
18 | - ), |
|
19 | - 'versions' => |
|
20 | - array( |
|
21 | - '__root__' => |
|
22 | - array( |
|
23 | - 'pretty_version' => 'dev-develop', |
|
24 | - 'version' => 'dev-develop', |
|
25 | - 'aliases' => |
|
26 | - array(), |
|
27 | - 'reference' => '2b5035defcc45dcd4370a5865ba4fe5e91035435', |
|
28 | - ), |
|
29 | - 'deliciousbrains/wp-background-processing' => |
|
30 | - array( |
|
31 | - 'pretty_version' => '1.0.2', |
|
32 | - 'version' => '1.0.2.0', |
|
33 | - 'aliases' => |
|
34 | - array(), |
|
35 | - 'reference' => '2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800', |
|
36 | - ), |
|
37 | - ), |
|
38 | - ); |
|
39 | - |
|
40 | - public static function getInstalledPackages() { |
|
41 | - return array_keys( self::$installed['versions'] ); |
|
42 | - } |
|
43 | - |
|
44 | - public static function isInstalled( $packageName ) { |
|
45 | - return isset( self::$installed['versions'][ $packageName ] ); |
|
46 | - } |
|
47 | - |
|
48 | - public static function satisfies( VersionParser $parser, $packageName, $constraint ) { |
|
49 | - $constraint = $parser->parseConstraints( $constraint ); |
|
50 | - $provided = $parser->parseConstraints( self::getVersionRanges( $packageName ) ); |
|
51 | - |
|
52 | - return $provided->matches( $constraint ); |
|
53 | - } |
|
54 | - |
|
55 | - public static function getVersionRanges( $packageName ) { |
|
56 | - if ( ! isset( self::$installed['versions'][ $packageName ] ) ) { |
|
57 | - throw new \OutOfBoundsException( 'Package "' . $packageName . '" is not installed' ); |
|
58 | - } |
|
59 | - |
|
60 | - $ranges = array(); |
|
61 | - if ( isset( self::$installed['versions'][ $packageName ]['pretty_version'] ) ) { |
|
62 | - $ranges[] = self::$installed['versions'][ $packageName ]['pretty_version']; |
|
63 | - } |
|
64 | - if ( array_key_exists( 'aliases', self::$installed['versions'][ $packageName ] ) ) { |
|
65 | - $ranges = array_merge( $ranges, self::$installed['versions'][ $packageName ]['aliases'] ); |
|
66 | - } |
|
67 | - if ( array_key_exists( 'replaced', self::$installed['versions'][ $packageName ] ) ) { |
|
68 | - $ranges = array_merge( $ranges, self::$installed['versions'][ $packageName ]['replaced'] ); |
|
69 | - } |
|
70 | - if ( array_key_exists( 'provided', self::$installed['versions'][ $packageName ] ) ) { |
|
71 | - $ranges = array_merge( $ranges, self::$installed['versions'][ $packageName ]['provided'] ); |
|
72 | - } |
|
73 | - |
|
74 | - return implode( ' || ', $ranges ); |
|
75 | - } |
|
76 | - |
|
77 | - public static function getVersion( $packageName ) { |
|
78 | - if ( ! isset( self::$installed['versions'][ $packageName ] ) ) { |
|
79 | - throw new \OutOfBoundsException( 'Package "' . $packageName . '" is not installed' ); |
|
80 | - } |
|
81 | - |
|
82 | - if ( ! isset( self::$installed['versions'][ $packageName ]['version'] ) ) { |
|
83 | - return null; |
|
84 | - } |
|
85 | - |
|
86 | - return self::$installed['versions'][ $packageName ]['version']; |
|
87 | - } |
|
88 | - |
|
89 | - public static function getPrettyVersion( $packageName ) { |
|
90 | - if ( ! isset( self::$installed['versions'][ $packageName ] ) ) { |
|
91 | - throw new \OutOfBoundsException( 'Package "' . $packageName . '" is not installed' ); |
|
92 | - } |
|
93 | - |
|
94 | - if ( ! isset( self::$installed['versions'][ $packageName ]['pretty_version'] ) ) { |
|
95 | - return null; |
|
96 | - } |
|
97 | - |
|
98 | - return self::$installed['versions'][ $packageName ]['pretty_version']; |
|
99 | - } |
|
100 | - |
|
101 | - public static function getReference( $packageName ) { |
|
102 | - if ( ! isset( self::$installed['versions'][ $packageName ] ) ) { |
|
103 | - throw new \OutOfBoundsException( 'Package "' . $packageName . '" is not installed' ); |
|
104 | - } |
|
105 | - |
|
106 | - if ( ! isset( self::$installed['versions'][ $packageName ]['reference'] ) ) { |
|
107 | - return null; |
|
108 | - } |
|
109 | - |
|
110 | - return self::$installed['versions'][ $packageName ]['reference']; |
|
111 | - } |
|
112 | - |
|
113 | - public static function getRootPackage() { |
|
114 | - return self::$installed['root']; |
|
115 | - } |
|
116 | - |
|
117 | - public static function getRawData() { |
|
118 | - return self::$installed; |
|
119 | - } |
|
120 | - |
|
121 | - public static function reload( $data ) { |
|
122 | - self::$installed = $data; |
|
123 | - } |
|
9 | + private static $installed = array( |
|
10 | + 'root' => |
|
11 | + array( |
|
12 | + 'pretty_version' => 'dev-develop', |
|
13 | + 'version' => 'dev-develop', |
|
14 | + 'aliases' => |
|
15 | + array(), |
|
16 | + 'reference' => '2b5035defcc45dcd4370a5865ba4fe5e91035435', |
|
17 | + 'name' => '__root__', |
|
18 | + ), |
|
19 | + 'versions' => |
|
20 | + array( |
|
21 | + '__root__' => |
|
22 | + array( |
|
23 | + 'pretty_version' => 'dev-develop', |
|
24 | + 'version' => 'dev-develop', |
|
25 | + 'aliases' => |
|
26 | + array(), |
|
27 | + 'reference' => '2b5035defcc45dcd4370a5865ba4fe5e91035435', |
|
28 | + ), |
|
29 | + 'deliciousbrains/wp-background-processing' => |
|
30 | + array( |
|
31 | + 'pretty_version' => '1.0.2', |
|
32 | + 'version' => '1.0.2.0', |
|
33 | + 'aliases' => |
|
34 | + array(), |
|
35 | + 'reference' => '2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800', |
|
36 | + ), |
|
37 | + ), |
|
38 | + ); |
|
39 | + |
|
40 | + public static function getInstalledPackages() { |
|
41 | + return array_keys( self::$installed['versions'] ); |
|
42 | + } |
|
43 | + |
|
44 | + public static function isInstalled( $packageName ) { |
|
45 | + return isset( self::$installed['versions'][ $packageName ] ); |
|
46 | + } |
|
47 | + |
|
48 | + public static function satisfies( VersionParser $parser, $packageName, $constraint ) { |
|
49 | + $constraint = $parser->parseConstraints( $constraint ); |
|
50 | + $provided = $parser->parseConstraints( self::getVersionRanges( $packageName ) ); |
|
51 | + |
|
52 | + return $provided->matches( $constraint ); |
|
53 | + } |
|
54 | + |
|
55 | + public static function getVersionRanges( $packageName ) { |
|
56 | + if ( ! isset( self::$installed['versions'][ $packageName ] ) ) { |
|
57 | + throw new \OutOfBoundsException( 'Package "' . $packageName . '" is not installed' ); |
|
58 | + } |
|
59 | + |
|
60 | + $ranges = array(); |
|
61 | + if ( isset( self::$installed['versions'][ $packageName ]['pretty_version'] ) ) { |
|
62 | + $ranges[] = self::$installed['versions'][ $packageName ]['pretty_version']; |
|
63 | + } |
|
64 | + if ( array_key_exists( 'aliases', self::$installed['versions'][ $packageName ] ) ) { |
|
65 | + $ranges = array_merge( $ranges, self::$installed['versions'][ $packageName ]['aliases'] ); |
|
66 | + } |
|
67 | + if ( array_key_exists( 'replaced', self::$installed['versions'][ $packageName ] ) ) { |
|
68 | + $ranges = array_merge( $ranges, self::$installed['versions'][ $packageName ]['replaced'] ); |
|
69 | + } |
|
70 | + if ( array_key_exists( 'provided', self::$installed['versions'][ $packageName ] ) ) { |
|
71 | + $ranges = array_merge( $ranges, self::$installed['versions'][ $packageName ]['provided'] ); |
|
72 | + } |
|
73 | + |
|
74 | + return implode( ' || ', $ranges ); |
|
75 | + } |
|
76 | + |
|
77 | + public static function getVersion( $packageName ) { |
|
78 | + if ( ! isset( self::$installed['versions'][ $packageName ] ) ) { |
|
79 | + throw new \OutOfBoundsException( 'Package "' . $packageName . '" is not installed' ); |
|
80 | + } |
|
81 | + |
|
82 | + if ( ! isset( self::$installed['versions'][ $packageName ]['version'] ) ) { |
|
83 | + return null; |
|
84 | + } |
|
85 | + |
|
86 | + return self::$installed['versions'][ $packageName ]['version']; |
|
87 | + } |
|
88 | + |
|
89 | + public static function getPrettyVersion( $packageName ) { |
|
90 | + if ( ! isset( self::$installed['versions'][ $packageName ] ) ) { |
|
91 | + throw new \OutOfBoundsException( 'Package "' . $packageName . '" is not installed' ); |
|
92 | + } |
|
93 | + |
|
94 | + if ( ! isset( self::$installed['versions'][ $packageName ]['pretty_version'] ) ) { |
|
95 | + return null; |
|
96 | + } |
|
97 | + |
|
98 | + return self::$installed['versions'][ $packageName ]['pretty_version']; |
|
99 | + } |
|
100 | + |
|
101 | + public static function getReference( $packageName ) { |
|
102 | + if ( ! isset( self::$installed['versions'][ $packageName ] ) ) { |
|
103 | + throw new \OutOfBoundsException( 'Package "' . $packageName . '" is not installed' ); |
|
104 | + } |
|
105 | + |
|
106 | + if ( ! isset( self::$installed['versions'][ $packageName ]['reference'] ) ) { |
|
107 | + return null; |
|
108 | + } |
|
109 | + |
|
110 | + return self::$installed['versions'][ $packageName ]['reference']; |
|
111 | + } |
|
112 | + |
|
113 | + public static function getRootPackage() { |
|
114 | + return self::$installed['root']; |
|
115 | + } |
|
116 | + |
|
117 | + public static function getRawData() { |
|
118 | + return self::$installed; |
|
119 | + } |
|
120 | + |
|
121 | + public static function reload( $data ) { |
|
122 | + self::$installed = $data; |
|
123 | + } |
|
124 | 124 | } |
@@ -38,76 +38,76 @@ discard block |
||
38 | 38 | ); |
39 | 39 | |
40 | 40 | public static function getInstalledPackages() { |
41 | - return array_keys( self::$installed['versions'] ); |
|
41 | + return array_keys(self::$installed['versions']); |
|
42 | 42 | } |
43 | 43 | |
44 | - public static function isInstalled( $packageName ) { |
|
45 | - return isset( self::$installed['versions'][ $packageName ] ); |
|
44 | + public static function isInstalled($packageName) { |
|
45 | + return isset(self::$installed['versions'][$packageName]); |
|
46 | 46 | } |
47 | 47 | |
48 | - public static function satisfies( VersionParser $parser, $packageName, $constraint ) { |
|
49 | - $constraint = $parser->parseConstraints( $constraint ); |
|
50 | - $provided = $parser->parseConstraints( self::getVersionRanges( $packageName ) ); |
|
48 | + public static function satisfies(VersionParser $parser, $packageName, $constraint) { |
|
49 | + $constraint = $parser->parseConstraints($constraint); |
|
50 | + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); |
|
51 | 51 | |
52 | - return $provided->matches( $constraint ); |
|
52 | + return $provided->matches($constraint); |
|
53 | 53 | } |
54 | 54 | |
55 | - public static function getVersionRanges( $packageName ) { |
|
56 | - if ( ! isset( self::$installed['versions'][ $packageName ] ) ) { |
|
57 | - throw new \OutOfBoundsException( 'Package "' . $packageName . '" is not installed' ); |
|
55 | + public static function getVersionRanges($packageName) { |
|
56 | + if ( ! isset(self::$installed['versions'][$packageName])) { |
|
57 | + throw new \OutOfBoundsException('Package "'.$packageName.'" is not installed'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | $ranges = array(); |
61 | - if ( isset( self::$installed['versions'][ $packageName ]['pretty_version'] ) ) { |
|
62 | - $ranges[] = self::$installed['versions'][ $packageName ]['pretty_version']; |
|
61 | + if (isset(self::$installed['versions'][$packageName]['pretty_version'])) { |
|
62 | + $ranges[] = self::$installed['versions'][$packageName]['pretty_version']; |
|
63 | 63 | } |
64 | - if ( array_key_exists( 'aliases', self::$installed['versions'][ $packageName ] ) ) { |
|
65 | - $ranges = array_merge( $ranges, self::$installed['versions'][ $packageName ]['aliases'] ); |
|
64 | + if (array_key_exists('aliases', self::$installed['versions'][$packageName])) { |
|
65 | + $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['aliases']); |
|
66 | 66 | } |
67 | - if ( array_key_exists( 'replaced', self::$installed['versions'][ $packageName ] ) ) { |
|
68 | - $ranges = array_merge( $ranges, self::$installed['versions'][ $packageName ]['replaced'] ); |
|
67 | + if (array_key_exists('replaced', self::$installed['versions'][$packageName])) { |
|
68 | + $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['replaced']); |
|
69 | 69 | } |
70 | - if ( array_key_exists( 'provided', self::$installed['versions'][ $packageName ] ) ) { |
|
71 | - $ranges = array_merge( $ranges, self::$installed['versions'][ $packageName ]['provided'] ); |
|
70 | + if (array_key_exists('provided', self::$installed['versions'][$packageName])) { |
|
71 | + $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['provided']); |
|
72 | 72 | } |
73 | 73 | |
74 | - return implode( ' || ', $ranges ); |
|
74 | + return implode(' || ', $ranges); |
|
75 | 75 | } |
76 | 76 | |
77 | - public static function getVersion( $packageName ) { |
|
78 | - if ( ! isset( self::$installed['versions'][ $packageName ] ) ) { |
|
79 | - throw new \OutOfBoundsException( 'Package "' . $packageName . '" is not installed' ); |
|
77 | + public static function getVersion($packageName) { |
|
78 | + if ( ! isset(self::$installed['versions'][$packageName])) { |
|
79 | + throw new \OutOfBoundsException('Package "'.$packageName.'" is not installed'); |
|
80 | 80 | } |
81 | 81 | |
82 | - if ( ! isset( self::$installed['versions'][ $packageName ]['version'] ) ) { |
|
82 | + if ( ! isset(self::$installed['versions'][$packageName]['version'])) { |
|
83 | 83 | return null; |
84 | 84 | } |
85 | 85 | |
86 | - return self::$installed['versions'][ $packageName ]['version']; |
|
86 | + return self::$installed['versions'][$packageName]['version']; |
|
87 | 87 | } |
88 | 88 | |
89 | - public static function getPrettyVersion( $packageName ) { |
|
90 | - if ( ! isset( self::$installed['versions'][ $packageName ] ) ) { |
|
91 | - throw new \OutOfBoundsException( 'Package "' . $packageName . '" is not installed' ); |
|
89 | + public static function getPrettyVersion($packageName) { |
|
90 | + if ( ! isset(self::$installed['versions'][$packageName])) { |
|
91 | + throw new \OutOfBoundsException('Package "'.$packageName.'" is not installed'); |
|
92 | 92 | } |
93 | 93 | |
94 | - if ( ! isset( self::$installed['versions'][ $packageName ]['pretty_version'] ) ) { |
|
94 | + if ( ! isset(self::$installed['versions'][$packageName]['pretty_version'])) { |
|
95 | 95 | return null; |
96 | 96 | } |
97 | 97 | |
98 | - return self::$installed['versions'][ $packageName ]['pretty_version']; |
|
98 | + return self::$installed['versions'][$packageName]['pretty_version']; |
|
99 | 99 | } |
100 | 100 | |
101 | - public static function getReference( $packageName ) { |
|
102 | - if ( ! isset( self::$installed['versions'][ $packageName ] ) ) { |
|
103 | - throw new \OutOfBoundsException( 'Package "' . $packageName . '" is not installed' ); |
|
101 | + public static function getReference($packageName) { |
|
102 | + if ( ! isset(self::$installed['versions'][$packageName])) { |
|
103 | + throw new \OutOfBoundsException('Package "'.$packageName.'" is not installed'); |
|
104 | 104 | } |
105 | 105 | |
106 | - if ( ! isset( self::$installed['versions'][ $packageName ]['reference'] ) ) { |
|
106 | + if ( ! isset(self::$installed['versions'][$packageName]['reference'])) { |
|
107 | 107 | return null; |
108 | 108 | } |
109 | 109 | |
110 | - return self::$installed['versions'][ $packageName ]['reference']; |
|
110 | + return self::$installed['versions'][$packageName]['reference']; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | public static function getRootPackage() { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | return self::$installed; |
119 | 119 | } |
120 | 120 | |
121 | - public static function reload( $data ) { |
|
121 | + public static function reload($data) { |
|
122 | 122 | self::$installed = $data; |
123 | 123 | } |
124 | 124 | } |
@@ -6,9 +6,9 @@ |
||
6 | 6 | $baseDir = dirname( $vendorDir ); |
7 | 7 | |
8 | 8 | return array( |
9 | - 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', |
|
10 | - 'WP_Async_Request' => $vendorDir . '/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
11 | - 'WP_Background_Process' => $vendorDir . '/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
12 | - 'Wordlift_Plugin_WP_Async_Request' => $baseDir . '/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
13 | - 'Wordlift_Plugin_WP_Background_Process' => $baseDir . '/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
9 | + 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', |
|
10 | + 'WP_Async_Request' => $vendorDir . '/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
11 | + 'WP_Background_Process' => $vendorDir . '/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
12 | + 'Wordlift_Plugin_WP_Async_Request' => $baseDir . '/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
13 | + 'Wordlift_Plugin_WP_Background_Process' => $baseDir . '/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
14 | 14 | ); |
@@ -2,13 +2,13 @@ |
||
2 | 2 | |
3 | 3 | // autoload_classmap.php @generated by Composer |
4 | 4 | |
5 | -$vendorDir = dirname( ( __DIR__ ) ); |
|
6 | -$baseDir = dirname( $vendorDir ); |
|
5 | +$vendorDir = dirname((__DIR__)); |
|
6 | +$baseDir = dirname($vendorDir); |
|
7 | 7 | |
8 | 8 | return array( |
9 | - 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', |
|
10 | - 'WP_Async_Request' => $vendorDir . '/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
11 | - 'WP_Background_Process' => $vendorDir . '/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
12 | - 'Wordlift_Plugin_WP_Async_Request' => $baseDir . '/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
13 | - 'Wordlift_Plugin_WP_Background_Process' => $baseDir . '/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
9 | + 'Composer\\InstalledVersions' => $vendorDir.'/composer/InstalledVersions.php', |
|
10 | + 'WP_Async_Request' => $vendorDir.'/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
11 | + 'WP_Background_Process' => $vendorDir.'/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
12 | + 'Wordlift_Plugin_WP_Async_Request' => $baseDir.'/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
13 | + 'Wordlift_Plugin_WP_Background_Process' => $baseDir.'/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
14 | 14 | ); |
@@ -6,22 +6,22 @@ |
||
6 | 6 | |
7 | 7 | class ComposerStaticInit30c84c47a44576eaa4b38cc478d5e11b { |
8 | 8 | |
9 | - public static $classMap = array( |
|
10 | - 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
|
11 | - 'WP_Async_Request' => __DIR__ . '/..' . '/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
12 | - 'WP_Background_Process' => __DIR__ . '/..' . '/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
13 | - 'Wordlift_Plugin_WP_Async_Request' => __DIR__ . '/../..' . '/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
14 | - 'Wordlift_Plugin_WP_Background_Process' => __DIR__ . '/../..' . '/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
15 | - ); |
|
9 | + public static $classMap = array( |
|
10 | + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
|
11 | + 'WP_Async_Request' => __DIR__ . '/..' . '/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
12 | + 'WP_Background_Process' => __DIR__ . '/..' . '/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
13 | + 'Wordlift_Plugin_WP_Async_Request' => __DIR__ . '/../..' . '/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
14 | + 'Wordlift_Plugin_WP_Background_Process' => __DIR__ . '/../..' . '/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
15 | + ); |
|
16 | 16 | |
17 | - public static function getInitializer( ClassLoader $loader ) { |
|
18 | - return \Closure::bind( |
|
19 | - function () use ( $loader ) { |
|
20 | - $loader->classMap = ComposerStaticInit30c84c47a44576eaa4b38cc478d5e11b::$classMap; |
|
17 | + public static function getInitializer( ClassLoader $loader ) { |
|
18 | + return \Closure::bind( |
|
19 | + function () use ( $loader ) { |
|
20 | + $loader->classMap = ComposerStaticInit30c84c47a44576eaa4b38cc478d5e11b::$classMap; |
|
21 | 21 | |
22 | - }, |
|
23 | - null, |
|
24 | - ClassLoader::class |
|
25 | - ); |
|
26 | - } |
|
22 | + }, |
|
23 | + null, |
|
24 | + ClassLoader::class |
|
25 | + ); |
|
26 | + } |
|
27 | 27 | } |
@@ -7,16 +7,16 @@ |
||
7 | 7 | class ComposerStaticInit30c84c47a44576eaa4b38cc478d5e11b { |
8 | 8 | |
9 | 9 | public static $classMap = array( |
10 | - 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
|
11 | - 'WP_Async_Request' => __DIR__ . '/..' . '/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
12 | - 'WP_Background_Process' => __DIR__ . '/..' . '/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
13 | - 'Wordlift_Plugin_WP_Async_Request' => __DIR__ . '/../..' . '/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
14 | - 'Wordlift_Plugin_WP_Background_Process' => __DIR__ . '/../..' . '/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
10 | + 'Composer\\InstalledVersions' => __DIR__.'/..'.'/composer/InstalledVersions.php', |
|
11 | + 'WP_Async_Request' => __DIR__.'/..'.'/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
12 | + 'WP_Background_Process' => __DIR__.'/..'.'/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
13 | + 'Wordlift_Plugin_WP_Async_Request' => __DIR__.'/../..'.'/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
14 | + 'Wordlift_Plugin_WP_Background_Process' => __DIR__.'/../..'.'/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
15 | 15 | ); |
16 | 16 | |
17 | - public static function getInitializer( ClassLoader $loader ) { |
|
17 | + public static function getInitializer(ClassLoader $loader) { |
|
18 | 18 | return \Closure::bind( |
19 | - function () use ( $loader ) { |
|
19 | + function() use ($loader) { |
|
20 | 20 | $loader->classMap = ComposerStaticInit30c84c47a44576eaa4b38cc478d5e11b::$classMap; |
21 | 21 | |
22 | 22 | }, |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | // autoload_psr4.php @generated by Composer |
4 | 4 | |
5 | -$vendorDir = dirname( ( __DIR__ ) ); |
|
6 | -$baseDir = dirname( $vendorDir ); |
|
5 | +$vendorDir = dirname((__DIR__)); |
|
6 | +$baseDir = dirname($vendorDir); |
|
7 | 7 | |
8 | 8 | return array(); |
@@ -4,52 +4,52 @@ |
||
4 | 4 | |
5 | 5 | class ComposerAutoloaderInit30c84c47a44576eaa4b38cc478d5e11b { |
6 | 6 | |
7 | - private static $loader; |
|
8 | - |
|
9 | - public static function loadClassLoader( $class ) { |
|
10 | - if ( 'Composer\Autoload\ClassLoader' === $class ) { |
|
11 | - require __DIR__ . '/ClassLoader.php'; |
|
12 | - } |
|
13 | - } |
|
14 | - |
|
15 | - /** |
|
16 | - * @return \Composer\Autoload\ClassLoader |
|
17 | - */ |
|
18 | - public static function getLoader() { |
|
19 | - if ( null !== self::$loader ) { |
|
20 | - return self::$loader; |
|
21 | - } |
|
22 | - |
|
23 | - require __DIR__ . '/platform_check.php'; |
|
24 | - |
|
25 | - spl_autoload_register( array( 'ComposerAutoloaderInit30c84c47a44576eaa4b38cc478d5e11b', 'loadClassLoader' ), true, true ); |
|
26 | - self::$loader = $loader = new \Composer\Autoload\ClassLoader(); |
|
27 | - spl_autoload_unregister( array( 'ComposerAutoloaderInit30c84c47a44576eaa4b38cc478d5e11b', 'loadClassLoader' ) ); |
|
28 | - |
|
29 | - $useStaticLoader = PHP_VERSION_ID >= 50600 && ! defined( 'HHVM_VERSION' ) && ( ! function_exists( 'zend_loader_file_encoded' ) || ! zend_loader_file_encoded() ); |
|
30 | - if ( $useStaticLoader ) { |
|
31 | - require __DIR__ . '/autoload_static.php'; |
|
32 | - |
|
33 | - call_user_func( \Composer\Autoload\ComposerStaticInit30c84c47a44576eaa4b38cc478d5e11b::getInitializer( $loader ) ); |
|
34 | - } else { |
|
35 | - $map = require __DIR__ . '/autoload_namespaces.php'; |
|
36 | - foreach ( $map as $namespace => $path ) { |
|
37 | - $loader->set( $namespace, $path ); |
|
38 | - } |
|
39 | - |
|
40 | - $map = require __DIR__ . '/autoload_psr4.php'; |
|
41 | - foreach ( $map as $namespace => $path ) { |
|
42 | - $loader->setPsr4( $namespace, $path ); |
|
43 | - } |
|
44 | - |
|
45 | - $classMap = require __DIR__ . '/autoload_classmap.php'; |
|
46 | - if ( $classMap ) { |
|
47 | - $loader->addClassMap( $classMap ); |
|
48 | - } |
|
49 | - } |
|
50 | - |
|
51 | - $loader->register( true ); |
|
52 | - |
|
53 | - return $loader; |
|
54 | - } |
|
7 | + private static $loader; |
|
8 | + |
|
9 | + public static function loadClassLoader( $class ) { |
|
10 | + if ( 'Composer\Autoload\ClassLoader' === $class ) { |
|
11 | + require __DIR__ . '/ClassLoader.php'; |
|
12 | + } |
|
13 | + } |
|
14 | + |
|
15 | + /** |
|
16 | + * @return \Composer\Autoload\ClassLoader |
|
17 | + */ |
|
18 | + public static function getLoader() { |
|
19 | + if ( null !== self::$loader ) { |
|
20 | + return self::$loader; |
|
21 | + } |
|
22 | + |
|
23 | + require __DIR__ . '/platform_check.php'; |
|
24 | + |
|
25 | + spl_autoload_register( array( 'ComposerAutoloaderInit30c84c47a44576eaa4b38cc478d5e11b', 'loadClassLoader' ), true, true ); |
|
26 | + self::$loader = $loader = new \Composer\Autoload\ClassLoader(); |
|
27 | + spl_autoload_unregister( array( 'ComposerAutoloaderInit30c84c47a44576eaa4b38cc478d5e11b', 'loadClassLoader' ) ); |
|
28 | + |
|
29 | + $useStaticLoader = PHP_VERSION_ID >= 50600 && ! defined( 'HHVM_VERSION' ) && ( ! function_exists( 'zend_loader_file_encoded' ) || ! zend_loader_file_encoded() ); |
|
30 | + if ( $useStaticLoader ) { |
|
31 | + require __DIR__ . '/autoload_static.php'; |
|
32 | + |
|
33 | + call_user_func( \Composer\Autoload\ComposerStaticInit30c84c47a44576eaa4b38cc478d5e11b::getInitializer( $loader ) ); |
|
34 | + } else { |
|
35 | + $map = require __DIR__ . '/autoload_namespaces.php'; |
|
36 | + foreach ( $map as $namespace => $path ) { |
|
37 | + $loader->set( $namespace, $path ); |
|
38 | + } |
|
39 | + |
|
40 | + $map = require __DIR__ . '/autoload_psr4.php'; |
|
41 | + foreach ( $map as $namespace => $path ) { |
|
42 | + $loader->setPsr4( $namespace, $path ); |
|
43 | + } |
|
44 | + |
|
45 | + $classMap = require __DIR__ . '/autoload_classmap.php'; |
|
46 | + if ( $classMap ) { |
|
47 | + $loader->addClassMap( $classMap ); |
|
48 | + } |
|
49 | + } |
|
50 | + |
|
51 | + $loader->register( true ); |
|
52 | + |
|
53 | + return $loader; |
|
54 | + } |
|
55 | 55 | } |
@@ -6,9 +6,9 @@ discard block |
||
6 | 6 | |
7 | 7 | private static $loader; |
8 | 8 | |
9 | - public static function loadClassLoader( $class ) { |
|
10 | - if ( 'Composer\Autoload\ClassLoader' === $class ) { |
|
11 | - require __DIR__ . '/ClassLoader.php'; |
|
9 | + public static function loadClassLoader($class) { |
|
10 | + if ('Composer\Autoload\ClassLoader' === $class) { |
|
11 | + require __DIR__.'/ClassLoader.php'; |
|
12 | 12 | } |
13 | 13 | } |
14 | 14 | |
@@ -16,39 +16,39 @@ discard block |
||
16 | 16 | * @return \Composer\Autoload\ClassLoader |
17 | 17 | */ |
18 | 18 | public static function getLoader() { |
19 | - if ( null !== self::$loader ) { |
|
19 | + if (null !== self::$loader) { |
|
20 | 20 | return self::$loader; |
21 | 21 | } |
22 | 22 | |
23 | - require __DIR__ . '/platform_check.php'; |
|
23 | + require __DIR__.'/platform_check.php'; |
|
24 | 24 | |
25 | - spl_autoload_register( array( 'ComposerAutoloaderInit30c84c47a44576eaa4b38cc478d5e11b', 'loadClassLoader' ), true, true ); |
|
25 | + spl_autoload_register(array('ComposerAutoloaderInit30c84c47a44576eaa4b38cc478d5e11b', 'loadClassLoader'), true, true); |
|
26 | 26 | self::$loader = $loader = new \Composer\Autoload\ClassLoader(); |
27 | - spl_autoload_unregister( array( 'ComposerAutoloaderInit30c84c47a44576eaa4b38cc478d5e11b', 'loadClassLoader' ) ); |
|
27 | + spl_autoload_unregister(array('ComposerAutoloaderInit30c84c47a44576eaa4b38cc478d5e11b', 'loadClassLoader')); |
|
28 | 28 | |
29 | - $useStaticLoader = PHP_VERSION_ID >= 50600 && ! defined( 'HHVM_VERSION' ) && ( ! function_exists( 'zend_loader_file_encoded' ) || ! zend_loader_file_encoded() ); |
|
30 | - if ( $useStaticLoader ) { |
|
31 | - require __DIR__ . '/autoload_static.php'; |
|
29 | + $useStaticLoader = PHP_VERSION_ID >= 50600 && ! defined('HHVM_VERSION') && ( ! function_exists('zend_loader_file_encoded') || ! zend_loader_file_encoded()); |
|
30 | + if ($useStaticLoader) { |
|
31 | + require __DIR__.'/autoload_static.php'; |
|
32 | 32 | |
33 | - call_user_func( \Composer\Autoload\ComposerStaticInit30c84c47a44576eaa4b38cc478d5e11b::getInitializer( $loader ) ); |
|
33 | + call_user_func(\Composer\Autoload\ComposerStaticInit30c84c47a44576eaa4b38cc478d5e11b::getInitializer($loader)); |
|
34 | 34 | } else { |
35 | - $map = require __DIR__ . '/autoload_namespaces.php'; |
|
36 | - foreach ( $map as $namespace => $path ) { |
|
37 | - $loader->set( $namespace, $path ); |
|
35 | + $map = require __DIR__.'/autoload_namespaces.php'; |
|
36 | + foreach ($map as $namespace => $path) { |
|
37 | + $loader->set($namespace, $path); |
|
38 | 38 | } |
39 | 39 | |
40 | - $map = require __DIR__ . '/autoload_psr4.php'; |
|
41 | - foreach ( $map as $namespace => $path ) { |
|
42 | - $loader->setPsr4( $namespace, $path ); |
|
40 | + $map = require __DIR__.'/autoload_psr4.php'; |
|
41 | + foreach ($map as $namespace => $path) { |
|
42 | + $loader->setPsr4($namespace, $path); |
|
43 | 43 | } |
44 | 44 | |
45 | - $classMap = require __DIR__ . '/autoload_classmap.php'; |
|
46 | - if ( $classMap ) { |
|
47 | - $loader->addClassMap( $classMap ); |
|
45 | + $classMap = require __DIR__.'/autoload_classmap.php'; |
|
46 | + if ($classMap) { |
|
47 | + $loader->addClassMap($classMap); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | - $loader->register( true ); |
|
51 | + $loader->register(true); |
|
52 | 52 | |
53 | 53 | return $loader; |
54 | 54 | } |
@@ -17,202 +17,202 @@ |
||
17 | 17 | */ |
18 | 18 | class Wordlift_Api_Service { |
19 | 19 | |
20 | - /** |
|
21 | - * The {@link Wordlift_Api_Service} singleton instance. |
|
22 | - * |
|
23 | - * @since 3.20.0 |
|
24 | - * @access private |
|
25 | - * @var \Wordlift_Api_Service $instance The singleton instance. |
|
26 | - */ |
|
27 | - private static $instance; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var Api_Headers_Service|null |
|
31 | - */ |
|
32 | - private $headers_service; |
|
33 | - |
|
34 | - /** |
|
35 | - * Create a {@link Wordlift_Api_Service} instance. |
|
36 | - * |
|
37 | - * @since 3.20.0 |
|
38 | - */ |
|
39 | - public function __construct() { |
|
40 | - self::$instance = $this; |
|
41 | - $this->headers_service = Api_Headers_Service::get_instance(); |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * Get the {@link Wordlift_Api_Service} singleton instance. |
|
46 | - * |
|
47 | - * @return \Wordlift_Api_Service The {@link Wordlift_Api_Service} singleton instance. |
|
48 | - * @since 3.20.0 |
|
49 | - */ |
|
50 | - public static function get_instance() { |
|
51 | - |
|
52 | - return self::$instance; |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * Perform a `GET` request towards the requested path. |
|
57 | - * |
|
58 | - * @param string $path The relative path. |
|
59 | - * |
|
60 | - * @return array|WP_Error |
|
61 | - * @since 3.20.0 |
|
62 | - */ |
|
63 | - public function get( $path ) { |
|
64 | - |
|
65 | - // Prepare the target URL. |
|
66 | - $url = Wordlift_Configuration_Service::get_instance()->get_api_url() . $path; |
|
67 | - |
|
68 | - // Get the response value. |
|
69 | - $response = wp_remote_get( |
|
70 | - $url, |
|
71 | - array( |
|
72 | - 'user-agent' => User_Agent::get_user_agent(), |
|
73 | - 'headers' => array( |
|
74 | - 'X-Authorization' => Wordlift_Configuration_Service::get_instance()->get_key(), |
|
75 | - ) + $this->headers_service->get_wp_headers(), |
|
76 | - /* |
|
20 | + /** |
|
21 | + * The {@link Wordlift_Api_Service} singleton instance. |
|
22 | + * |
|
23 | + * @since 3.20.0 |
|
24 | + * @access private |
|
25 | + * @var \Wordlift_Api_Service $instance The singleton instance. |
|
26 | + */ |
|
27 | + private static $instance; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var Api_Headers_Service|null |
|
31 | + */ |
|
32 | + private $headers_service; |
|
33 | + |
|
34 | + /** |
|
35 | + * Create a {@link Wordlift_Api_Service} instance. |
|
36 | + * |
|
37 | + * @since 3.20.0 |
|
38 | + */ |
|
39 | + public function __construct() { |
|
40 | + self::$instance = $this; |
|
41 | + $this->headers_service = Api_Headers_Service::get_instance(); |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * Get the {@link Wordlift_Api_Service} singleton instance. |
|
46 | + * |
|
47 | + * @return \Wordlift_Api_Service The {@link Wordlift_Api_Service} singleton instance. |
|
48 | + * @since 3.20.0 |
|
49 | + */ |
|
50 | + public static function get_instance() { |
|
51 | + |
|
52 | + return self::$instance; |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * Perform a `GET` request towards the requested path. |
|
57 | + * |
|
58 | + * @param string $path The relative path. |
|
59 | + * |
|
60 | + * @return array|WP_Error |
|
61 | + * @since 3.20.0 |
|
62 | + */ |
|
63 | + public function get( $path ) { |
|
64 | + |
|
65 | + // Prepare the target URL. |
|
66 | + $url = Wordlift_Configuration_Service::get_instance()->get_api_url() . $path; |
|
67 | + |
|
68 | + // Get the response value. |
|
69 | + $response = wp_remote_get( |
|
70 | + $url, |
|
71 | + array( |
|
72 | + 'user-agent' => User_Agent::get_user_agent(), |
|
73 | + 'headers' => array( |
|
74 | + 'X-Authorization' => Wordlift_Configuration_Service::get_instance()->get_key(), |
|
75 | + ) + $this->headers_service->get_wp_headers(), |
|
76 | + /* |
|
77 | 77 | * Increase the timeout from the default of 5 to 30 secs. |
78 | 78 | * |
79 | 79 | * @see https://github.com/insideout10/wordlift-plugin/issues/906 |
80 | 80 | * |
81 | 81 | * @since 3.20.1 |
82 | 82 | */ |
83 | - 'timeout' => 30, |
|
84 | - ) |
|
85 | - ); |
|
86 | - |
|
87 | - return self::get_message_or_error( $response ); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Perform a `POST` request towards the requested path. |
|
92 | - * |
|
93 | - * @param string $path The relative path. |
|
94 | - * @param array|object $body The request body (will be serialized to JSON). |
|
95 | - * |
|
96 | - * @return array|WP_Error |
|
97 | - * @since 3.20.0 |
|
98 | - */ |
|
99 | - public function post( $path, $body ) { |
|
100 | - |
|
101 | - return $this->post_custom_content_type( |
|
102 | - $path, |
|
103 | - wp_json_encode( $body ), |
|
104 | - 'application/json; ' . get_bloginfo( 'charset' ) |
|
105 | - ); |
|
106 | - } |
|
107 | - |
|
108 | - public function post_custom_content_type( $path, $body, $content_type ) { |
|
109 | - |
|
110 | - // Prepare the target URL. |
|
111 | - $url = apply_filters( 'wl_api_service_api_url_path', Wordlift_Configuration_Service::get_instance()->get_api_url() . $path ); |
|
112 | - |
|
113 | - // Give some time for the operation to complete, more than the time we give to the HTTP operation to complete. |
|
114 | - // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged |
|
115 | - @set_time_limit( 90 ); |
|
116 | - |
|
117 | - // Get the response value. |
|
118 | - $key = Wordlift_Configuration_Service::get_instance()->get_key(); |
|
119 | - $response = wp_remote_post( |
|
120 | - $url, |
|
121 | - array( |
|
122 | - 'timeout' => 60, |
|
123 | - 'user-agent' => User_Agent::get_user_agent(), |
|
124 | - 'headers' => array( |
|
125 | - 'Content-Type' => $content_type, |
|
126 | - 'X-Authorization' => $key, |
|
127 | - 'Authorization' => "Key $key", |
|
128 | - /* |
|
83 | + 'timeout' => 30, |
|
84 | + ) |
|
85 | + ); |
|
86 | + |
|
87 | + return self::get_message_or_error( $response ); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Perform a `POST` request towards the requested path. |
|
92 | + * |
|
93 | + * @param string $path The relative path. |
|
94 | + * @param array|object $body The request body (will be serialized to JSON). |
|
95 | + * |
|
96 | + * @return array|WP_Error |
|
97 | + * @since 3.20.0 |
|
98 | + */ |
|
99 | + public function post( $path, $body ) { |
|
100 | + |
|
101 | + return $this->post_custom_content_type( |
|
102 | + $path, |
|
103 | + wp_json_encode( $body ), |
|
104 | + 'application/json; ' . get_bloginfo( 'charset' ) |
|
105 | + ); |
|
106 | + } |
|
107 | + |
|
108 | + public function post_custom_content_type( $path, $body, $content_type ) { |
|
109 | + |
|
110 | + // Prepare the target URL. |
|
111 | + $url = apply_filters( 'wl_api_service_api_url_path', Wordlift_Configuration_Service::get_instance()->get_api_url() . $path ); |
|
112 | + |
|
113 | + // Give some time for the operation to complete, more than the time we give to the HTTP operation to complete. |
|
114 | + // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged |
|
115 | + @set_time_limit( 90 ); |
|
116 | + |
|
117 | + // Get the response value. |
|
118 | + $key = Wordlift_Configuration_Service::get_instance()->get_key(); |
|
119 | + $response = wp_remote_post( |
|
120 | + $url, |
|
121 | + array( |
|
122 | + 'timeout' => 60, |
|
123 | + 'user-agent' => User_Agent::get_user_agent(), |
|
124 | + 'headers' => array( |
|
125 | + 'Content-Type' => $content_type, |
|
126 | + 'X-Authorization' => $key, |
|
127 | + 'Authorization' => "Key $key", |
|
128 | + /* |
|
129 | 129 | * This is required to avoid CURL receiving 502 Bad Gateway errors. |
130 | 130 | * |
131 | 131 | * @see https://stackoverflow.com/questions/30601075/curl-to-google-compute-load-balancer-gets-error-502 |
132 | 132 | */ |
133 | - 'Expect' => '', |
|
134 | - ) + $this->headers_service->get_wp_headers(), |
|
135 | - 'body' => $body, |
|
136 | - ) |
|
137 | - ); |
|
138 | - |
|
139 | - return self::get_message_or_error( $response ); |
|
140 | - } |
|
141 | - |
|
142 | - public function delete( $path ) { |
|
143 | - |
|
144 | - // Prepare the target URL. |
|
145 | - $url = Wordlift_Configuration_Service::get_instance()->get_api_url() . $path; |
|
146 | - |
|
147 | - // Get the response value. |
|
148 | - $response = wp_remote_request( |
|
149 | - $url, |
|
150 | - array( |
|
151 | - 'method' => 'DELETE', |
|
152 | - 'user-agent' => User_Agent::get_user_agent(), |
|
153 | - 'headers' => array( |
|
154 | - 'X-Authorization' => Wordlift_Configuration_Service::get_instance()->get_key(), |
|
155 | - ) + $this->headers_service->get_wp_headers(), |
|
156 | - ) |
|
157 | - ); |
|
158 | - |
|
159 | - return self::get_message_or_error( $response ); |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * Return the {@link WP_Error} in case of error or the actual reply if successful. |
|
164 | - * |
|
165 | - * @param array|WP_Error $response The response of an http call. |
|
166 | - * |
|
167 | - * @return string|object|WP_Error A {@link WP_Error} instance or the actual response content. |
|
168 | - * @since 3.20.0 |
|
169 | - */ |
|
170 | - private static function get_message_or_error( $response ) { |
|
171 | - |
|
172 | - // Result is WP_Error. |
|
173 | - if ( is_wp_error( $response ) ) { |
|
174 | - return $response; |
|
175 | - } |
|
176 | - |
|
177 | - // `code` not set or not numeric. |
|
178 | - $code = wp_remote_retrieve_response_code( $response ); |
|
179 | - // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged |
|
180 | - $message = @wp_remote_retrieve_response_message( $response ); |
|
181 | - |
|
182 | - if ( empty( $code ) || ! is_numeric( $code ) ) { |
|
183 | - return new WP_Error( 0, $message ); |
|
184 | - } |
|
185 | - |
|
186 | - // Code not 2xx. |
|
187 | - if ( 2 !== intval( $code / 100 ) ) { |
|
188 | - return new WP_Error( $code, $message ); |
|
189 | - } |
|
190 | - |
|
191 | - // Everything's fine, return the message. |
|
192 | - return self::try_json_decode( $response ); |
|
193 | - } |
|
194 | - |
|
195 | - /** |
|
196 | - * Try to decode the json response |
|
197 | - * |
|
198 | - * @param array $response The response array. |
|
199 | - * |
|
200 | - * @return array|mixed|object The decoded response or the original response body. |
|
201 | - * @since 3.20.0 |
|
202 | - */ |
|
203 | - private static function try_json_decode( $response ) { |
|
204 | - |
|
205 | - // Get the headers. |
|
206 | - $content_type = wp_remote_retrieve_header( $response, 'content-type' ); |
|
207 | - $body = wp_remote_retrieve_body( $response ); |
|
208 | - |
|
209 | - // If it's not an `application/json` return the plain response body. |
|
210 | - if ( 0 !== strpos( strtolower( $content_type ), 'application/json' ) ) { |
|
211 | - return $body; |
|
212 | - } |
|
213 | - |
|
214 | - // Decode and return the structured result. |
|
215 | - return json_decode( $body ); |
|
216 | - } |
|
133 | + 'Expect' => '', |
|
134 | + ) + $this->headers_service->get_wp_headers(), |
|
135 | + 'body' => $body, |
|
136 | + ) |
|
137 | + ); |
|
138 | + |
|
139 | + return self::get_message_or_error( $response ); |
|
140 | + } |
|
141 | + |
|
142 | + public function delete( $path ) { |
|
143 | + |
|
144 | + // Prepare the target URL. |
|
145 | + $url = Wordlift_Configuration_Service::get_instance()->get_api_url() . $path; |
|
146 | + |
|
147 | + // Get the response value. |
|
148 | + $response = wp_remote_request( |
|
149 | + $url, |
|
150 | + array( |
|
151 | + 'method' => 'DELETE', |
|
152 | + 'user-agent' => User_Agent::get_user_agent(), |
|
153 | + 'headers' => array( |
|
154 | + 'X-Authorization' => Wordlift_Configuration_Service::get_instance()->get_key(), |
|
155 | + ) + $this->headers_service->get_wp_headers(), |
|
156 | + ) |
|
157 | + ); |
|
158 | + |
|
159 | + return self::get_message_or_error( $response ); |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * Return the {@link WP_Error} in case of error or the actual reply if successful. |
|
164 | + * |
|
165 | + * @param array|WP_Error $response The response of an http call. |
|
166 | + * |
|
167 | + * @return string|object|WP_Error A {@link WP_Error} instance or the actual response content. |
|
168 | + * @since 3.20.0 |
|
169 | + */ |
|
170 | + private static function get_message_or_error( $response ) { |
|
171 | + |
|
172 | + // Result is WP_Error. |
|
173 | + if ( is_wp_error( $response ) ) { |
|
174 | + return $response; |
|
175 | + } |
|
176 | + |
|
177 | + // `code` not set or not numeric. |
|
178 | + $code = wp_remote_retrieve_response_code( $response ); |
|
179 | + // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged |
|
180 | + $message = @wp_remote_retrieve_response_message( $response ); |
|
181 | + |
|
182 | + if ( empty( $code ) || ! is_numeric( $code ) ) { |
|
183 | + return new WP_Error( 0, $message ); |
|
184 | + } |
|
185 | + |
|
186 | + // Code not 2xx. |
|
187 | + if ( 2 !== intval( $code / 100 ) ) { |
|
188 | + return new WP_Error( $code, $message ); |
|
189 | + } |
|
190 | + |
|
191 | + // Everything's fine, return the message. |
|
192 | + return self::try_json_decode( $response ); |
|
193 | + } |
|
194 | + |
|
195 | + /** |
|
196 | + * Try to decode the json response |
|
197 | + * |
|
198 | + * @param array $response The response array. |
|
199 | + * |
|
200 | + * @return array|mixed|object The decoded response or the original response body. |
|
201 | + * @since 3.20.0 |
|
202 | + */ |
|
203 | + private static function try_json_decode( $response ) { |
|
204 | + |
|
205 | + // Get the headers. |
|
206 | + $content_type = wp_remote_retrieve_header( $response, 'content-type' ); |
|
207 | + $body = wp_remote_retrieve_body( $response ); |
|
208 | + |
|
209 | + // If it's not an `application/json` return the plain response body. |
|
210 | + if ( 0 !== strpos( strtolower( $content_type ), 'application/json' ) ) { |
|
211 | + return $body; |
|
212 | + } |
|
213 | + |
|
214 | + // Decode and return the structured result. |
|
215 | + return json_decode( $body ); |
|
216 | + } |
|
217 | 217 | |
218 | 218 | } |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | * @return array|WP_Error |
61 | 61 | * @since 3.20.0 |
62 | 62 | */ |
63 | - public function get( $path ) { |
|
63 | + public function get($path) { |
|
64 | 64 | |
65 | 65 | // Prepare the target URL. |
66 | - $url = Wordlift_Configuration_Service::get_instance()->get_api_url() . $path; |
|
66 | + $url = Wordlift_Configuration_Service::get_instance()->get_api_url().$path; |
|
67 | 67 | |
68 | 68 | // Get the response value. |
69 | 69 | $response = wp_remote_get( |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | ) |
85 | 85 | ); |
86 | 86 | |
87 | - return self::get_message_or_error( $response ); |
|
87 | + return self::get_message_or_error($response); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -96,23 +96,23 @@ discard block |
||
96 | 96 | * @return array|WP_Error |
97 | 97 | * @since 3.20.0 |
98 | 98 | */ |
99 | - public function post( $path, $body ) { |
|
99 | + public function post($path, $body) { |
|
100 | 100 | |
101 | 101 | return $this->post_custom_content_type( |
102 | 102 | $path, |
103 | - wp_json_encode( $body ), |
|
104 | - 'application/json; ' . get_bloginfo( 'charset' ) |
|
103 | + wp_json_encode($body), |
|
104 | + 'application/json; '.get_bloginfo('charset') |
|
105 | 105 | ); |
106 | 106 | } |
107 | 107 | |
108 | - public function post_custom_content_type( $path, $body, $content_type ) { |
|
108 | + public function post_custom_content_type($path, $body, $content_type) { |
|
109 | 109 | |
110 | 110 | // Prepare the target URL. |
111 | - $url = apply_filters( 'wl_api_service_api_url_path', Wordlift_Configuration_Service::get_instance()->get_api_url() . $path ); |
|
111 | + $url = apply_filters('wl_api_service_api_url_path', Wordlift_Configuration_Service::get_instance()->get_api_url().$path); |
|
112 | 112 | |
113 | 113 | // Give some time for the operation to complete, more than the time we give to the HTTP operation to complete. |
114 | 114 | // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged |
115 | - @set_time_limit( 90 ); |
|
115 | + @set_time_limit(90); |
|
116 | 116 | |
117 | 117 | // Get the response value. |
118 | 118 | $key = Wordlift_Configuration_Service::get_instance()->get_key(); |
@@ -136,13 +136,13 @@ discard block |
||
136 | 136 | ) |
137 | 137 | ); |
138 | 138 | |
139 | - return self::get_message_or_error( $response ); |
|
139 | + return self::get_message_or_error($response); |
|
140 | 140 | } |
141 | 141 | |
142 | - public function delete( $path ) { |
|
142 | + public function delete($path) { |
|
143 | 143 | |
144 | 144 | // Prepare the target URL. |
145 | - $url = Wordlift_Configuration_Service::get_instance()->get_api_url() . $path; |
|
145 | + $url = Wordlift_Configuration_Service::get_instance()->get_api_url().$path; |
|
146 | 146 | |
147 | 147 | // Get the response value. |
148 | 148 | $response = wp_remote_request( |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | ) |
157 | 157 | ); |
158 | 158 | |
159 | - return self::get_message_or_error( $response ); |
|
159 | + return self::get_message_or_error($response); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -167,29 +167,29 @@ discard block |
||
167 | 167 | * @return string|object|WP_Error A {@link WP_Error} instance or the actual response content. |
168 | 168 | * @since 3.20.0 |
169 | 169 | */ |
170 | - private static function get_message_or_error( $response ) { |
|
170 | + private static function get_message_or_error($response) { |
|
171 | 171 | |
172 | 172 | // Result is WP_Error. |
173 | - if ( is_wp_error( $response ) ) { |
|
173 | + if (is_wp_error($response)) { |
|
174 | 174 | return $response; |
175 | 175 | } |
176 | 176 | |
177 | 177 | // `code` not set or not numeric. |
178 | - $code = wp_remote_retrieve_response_code( $response ); |
|
178 | + $code = wp_remote_retrieve_response_code($response); |
|
179 | 179 | // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged |
180 | - $message = @wp_remote_retrieve_response_message( $response ); |
|
180 | + $message = @wp_remote_retrieve_response_message($response); |
|
181 | 181 | |
182 | - if ( empty( $code ) || ! is_numeric( $code ) ) { |
|
183 | - return new WP_Error( 0, $message ); |
|
182 | + if (empty($code) || ! is_numeric($code)) { |
|
183 | + return new WP_Error(0, $message); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | // Code not 2xx. |
187 | - if ( 2 !== intval( $code / 100 ) ) { |
|
188 | - return new WP_Error( $code, $message ); |
|
187 | + if (2 !== intval($code / 100)) { |
|
188 | + return new WP_Error($code, $message); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | // Everything's fine, return the message. |
192 | - return self::try_json_decode( $response ); |
|
192 | + return self::try_json_decode($response); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -200,19 +200,19 @@ discard block |
||
200 | 200 | * @return array|mixed|object The decoded response or the original response body. |
201 | 201 | * @since 3.20.0 |
202 | 202 | */ |
203 | - private static function try_json_decode( $response ) { |
|
203 | + private static function try_json_decode($response) { |
|
204 | 204 | |
205 | 205 | // Get the headers. |
206 | - $content_type = wp_remote_retrieve_header( $response, 'content-type' ); |
|
207 | - $body = wp_remote_retrieve_body( $response ); |
|
206 | + $content_type = wp_remote_retrieve_header($response, 'content-type'); |
|
207 | + $body = wp_remote_retrieve_body($response); |
|
208 | 208 | |
209 | 209 | // If it's not an `application/json` return the plain response body. |
210 | - if ( 0 !== strpos( strtolower( $content_type ), 'application/json' ) ) { |
|
210 | + if (0 !== strpos(strtolower($content_type), 'application/json')) { |
|
211 | 211 | return $body; |
212 | 212 | } |
213 | 213 | |
214 | 214 | // Decode and return the structured result. |
215 | - return json_decode( $body ); |
|
215 | + return json_decode($body); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | } |
@@ -18,103 +18,103 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class Wordlift_Google_Analytics_Export_Service { |
20 | 20 | |
21 | - /** |
|
22 | - * Export the site data that could be imported in Google Analytics. |
|
23 | - * It will works only when permalink structure is set to "Postname". |
|
24 | - * |
|
25 | - * @since 3.16.0 |
|
26 | - * |
|
27 | - * @return void |
|
28 | - */ |
|
29 | - public function export() { |
|
30 | - // Bail if the permalink structure is different from "Post name". |
|
31 | - if ( ! $this->is_postname_permalink_structure() ) { |
|
32 | - wp_die( 'The current permalink structure do not allow to export your data. Please change the permalink structure to "Post name".' ); |
|
33 | - } |
|
34 | - |
|
35 | - // Output the file data. @codingStandardsIgnoreLine |
|
36 | - @ob_end_clean(); |
|
37 | - |
|
38 | - // Generate unique filename using current timestamp. |
|
39 | - $filename = 'wl-ga-export-' . gmdate( 'Y-m-d-H-i-s' ) . '.csv'; |
|
40 | - |
|
41 | - // Add proper file headers. |
|
42 | - header( "Content-Disposition: attachment; filename=$filename" ); |
|
43 | - header( 'Content-Type: text/csv; charset=' . get_bloginfo( 'charset' ) ); |
|
44 | - |
|
45 | - // Do not cache the file. |
|
46 | - header( 'Pragma: no-cache' ); |
|
47 | - header( 'Expires: 0' ); |
|
48 | - |
|
49 | - // Build the CSV file. |
|
50 | - $this->create_csv(); |
|
51 | - |
|
52 | - wp_die(); |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * Return site path. Some installations are in subdirectories |
|
57 | - * and we need add them to expported permalinks. |
|
58 | - * |
|
59 | - * @since 3.16.0 |
|
60 | - * |
|
61 | - * @return string The site path. |
|
62 | - */ |
|
63 | - public function get_site_path() { |
|
64 | - // Get home url from database. |
|
65 | - $home_url = home_url( '/' ); |
|
66 | - |
|
67 | - // Parse the url. |
|
68 | - $parsed = wp_parse_url( $home_url ); |
|
69 | - |
|
70 | - // Return the path. |
|
71 | - return $parsed['path']; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Check if the current permalink structure is set to "Post name". |
|
76 | - * |
|
77 | - * @since 3.16.0 |
|
78 | - * |
|
79 | - * @return bool whether the structure is "Post name" or not. |
|
80 | - */ |
|
81 | - public static function is_postname_permalink_structure() { |
|
82 | - // Get current permalink structure. |
|
83 | - $structure = get_option( 'permalink_structure' ); |
|
84 | - |
|
85 | - // The regular expression. It will check if the site structure contains postname. |
|
86 | - $regex = '~^/\%postname\%/$~'; |
|
87 | - |
|
88 | - // Check if the site structure match the rquired one. |
|
89 | - preg_match( $regex, $structure, $matches ); |
|
90 | - |
|
91 | - // Bail if the site have different structure. |
|
92 | - if ( empty( $matches ) ) { |
|
93 | - return false; |
|
94 | - } |
|
95 | - |
|
96 | - return true; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Generate array data, that should be exported as csv. |
|
101 | - * The data contains the post/page title, entity name and type. |
|
102 | - * |
|
103 | - * @since 3.16.0 |
|
104 | - * |
|
105 | - * @return array $items Content data. |
|
106 | - */ |
|
107 | - public function get_content_data() { |
|
108 | - // Get the global $wpdb. |
|
109 | - global $wpdb; |
|
110 | - |
|
111 | - // Site path (optional). |
|
112 | - $path = $this->get_site_path(); |
|
113 | - |
|
114 | - // Get the data. |
|
115 | - $items = $wpdb->get_results( |
|
116 | - $wpdb->prepare( |
|
117 | - "SELECT |
|
21 | + /** |
|
22 | + * Export the site data that could be imported in Google Analytics. |
|
23 | + * It will works only when permalink structure is set to "Postname". |
|
24 | + * |
|
25 | + * @since 3.16.0 |
|
26 | + * |
|
27 | + * @return void |
|
28 | + */ |
|
29 | + public function export() { |
|
30 | + // Bail if the permalink structure is different from "Post name". |
|
31 | + if ( ! $this->is_postname_permalink_structure() ) { |
|
32 | + wp_die( 'The current permalink structure do not allow to export your data. Please change the permalink structure to "Post name".' ); |
|
33 | + } |
|
34 | + |
|
35 | + // Output the file data. @codingStandardsIgnoreLine |
|
36 | + @ob_end_clean(); |
|
37 | + |
|
38 | + // Generate unique filename using current timestamp. |
|
39 | + $filename = 'wl-ga-export-' . gmdate( 'Y-m-d-H-i-s' ) . '.csv'; |
|
40 | + |
|
41 | + // Add proper file headers. |
|
42 | + header( "Content-Disposition: attachment; filename=$filename" ); |
|
43 | + header( 'Content-Type: text/csv; charset=' . get_bloginfo( 'charset' ) ); |
|
44 | + |
|
45 | + // Do not cache the file. |
|
46 | + header( 'Pragma: no-cache' ); |
|
47 | + header( 'Expires: 0' ); |
|
48 | + |
|
49 | + // Build the CSV file. |
|
50 | + $this->create_csv(); |
|
51 | + |
|
52 | + wp_die(); |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * Return site path. Some installations are in subdirectories |
|
57 | + * and we need add them to expported permalinks. |
|
58 | + * |
|
59 | + * @since 3.16.0 |
|
60 | + * |
|
61 | + * @return string The site path. |
|
62 | + */ |
|
63 | + public function get_site_path() { |
|
64 | + // Get home url from database. |
|
65 | + $home_url = home_url( '/' ); |
|
66 | + |
|
67 | + // Parse the url. |
|
68 | + $parsed = wp_parse_url( $home_url ); |
|
69 | + |
|
70 | + // Return the path. |
|
71 | + return $parsed['path']; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * Check if the current permalink structure is set to "Post name". |
|
76 | + * |
|
77 | + * @since 3.16.0 |
|
78 | + * |
|
79 | + * @return bool whether the structure is "Post name" or not. |
|
80 | + */ |
|
81 | + public static function is_postname_permalink_structure() { |
|
82 | + // Get current permalink structure. |
|
83 | + $structure = get_option( 'permalink_structure' ); |
|
84 | + |
|
85 | + // The regular expression. It will check if the site structure contains postname. |
|
86 | + $regex = '~^/\%postname\%/$~'; |
|
87 | + |
|
88 | + // Check if the site structure match the rquired one. |
|
89 | + preg_match( $regex, $structure, $matches ); |
|
90 | + |
|
91 | + // Bail if the site have different structure. |
|
92 | + if ( empty( $matches ) ) { |
|
93 | + return false; |
|
94 | + } |
|
95 | + |
|
96 | + return true; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Generate array data, that should be exported as csv. |
|
101 | + * The data contains the post/page title, entity name and type. |
|
102 | + * |
|
103 | + * @since 3.16.0 |
|
104 | + * |
|
105 | + * @return array $items Content data. |
|
106 | + */ |
|
107 | + public function get_content_data() { |
|
108 | + // Get the global $wpdb. |
|
109 | + global $wpdb; |
|
110 | + |
|
111 | + // Site path (optional). |
|
112 | + $path = $this->get_site_path(); |
|
113 | + |
|
114 | + // Get the data. |
|
115 | + $items = $wpdb->get_results( |
|
116 | + $wpdb->prepare( |
|
117 | + "SELECT |
|
118 | 118 | CONCAT( %s, p.post_name, '/' ) AS 'post_name', |
119 | 119 | p1.post_name AS 'entity_name', |
120 | 120 | t.slug AS 'entity_type' |
@@ -131,43 +131,43 @@ discard block |
||
131 | 131 | INNER JOIN {$wpdb->prefix}terms t |
132 | 132 | ON t.term_id = tt.term_id |
133 | 133 | WHERE p.post_type IN ( 'page', 'post' );", |
134 | - $path |
|
135 | - ) |
|
136 | - ); // db call ok; no-cache ok. |
|
137 | - |
|
138 | - return $items; |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * Create the CSV file that will be downloaded. |
|
143 | - * |
|
144 | - * @since 3.16.0 |
|
145 | - * |
|
146 | - * @return void |
|
147 | - */ |
|
148 | - public function create_csv() { |
|
149 | - // Create a file pointer connected to the output stream. |
|
150 | - // Ignoring linter notices below that complain about file output which do not actually happen. |
|
151 | - $file = fopen( 'php://output', 'w' ); |
|
152 | - |
|
153 | - // Add the column headers. @codingStandardsIgnoreLine |
|
154 | - fputcsv( |
|
155 | - $file, |
|
156 | - array( |
|
157 | - 'ga:pagePath', |
|
158 | - 'ga:dimension1', |
|
159 | - 'ga:dimension2', |
|
160 | - ) |
|
161 | - ); |
|
162 | - |
|
163 | - // Cycle through items and add each item data to the file. |
|
164 | - foreach ( $this->get_content_data() as $row ) { |
|
165 | - // Add new line in the file. @codingStandardsIgnoreLine |
|
166 | - fputcsv( |
|
167 | - $file, |
|
168 | - (array) $row // convert the object to array. |
|
169 | - ); |
|
170 | - } |
|
171 | - } |
|
134 | + $path |
|
135 | + ) |
|
136 | + ); // db call ok; no-cache ok. |
|
137 | + |
|
138 | + return $items; |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * Create the CSV file that will be downloaded. |
|
143 | + * |
|
144 | + * @since 3.16.0 |
|
145 | + * |
|
146 | + * @return void |
|
147 | + */ |
|
148 | + public function create_csv() { |
|
149 | + // Create a file pointer connected to the output stream. |
|
150 | + // Ignoring linter notices below that complain about file output which do not actually happen. |
|
151 | + $file = fopen( 'php://output', 'w' ); |
|
152 | + |
|
153 | + // Add the column headers. @codingStandardsIgnoreLine |
|
154 | + fputcsv( |
|
155 | + $file, |
|
156 | + array( |
|
157 | + 'ga:pagePath', |
|
158 | + 'ga:dimension1', |
|
159 | + 'ga:dimension2', |
|
160 | + ) |
|
161 | + ); |
|
162 | + |
|
163 | + // Cycle through items and add each item data to the file. |
|
164 | + foreach ( $this->get_content_data() as $row ) { |
|
165 | + // Add new line in the file. @codingStandardsIgnoreLine |
|
166 | + fputcsv( |
|
167 | + $file, |
|
168 | + (array) $row // convert the object to array. |
|
169 | + ); |
|
170 | + } |
|
171 | + } |
|
172 | 172 | |
173 | 173 | } |
@@ -28,23 +28,23 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function export() { |
30 | 30 | // Bail if the permalink structure is different from "Post name". |
31 | - if ( ! $this->is_postname_permalink_structure() ) { |
|
32 | - wp_die( 'The current permalink structure do not allow to export your data. Please change the permalink structure to "Post name".' ); |
|
31 | + if ( ! $this->is_postname_permalink_structure()) { |
|
32 | + wp_die('The current permalink structure do not allow to export your data. Please change the permalink structure to "Post name".'); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | // Output the file data. @codingStandardsIgnoreLine |
36 | 36 | @ob_end_clean(); |
37 | 37 | |
38 | 38 | // Generate unique filename using current timestamp. |
39 | - $filename = 'wl-ga-export-' . gmdate( 'Y-m-d-H-i-s' ) . '.csv'; |
|
39 | + $filename = 'wl-ga-export-'.gmdate('Y-m-d-H-i-s').'.csv'; |
|
40 | 40 | |
41 | 41 | // Add proper file headers. |
42 | - header( "Content-Disposition: attachment; filename=$filename" ); |
|
43 | - header( 'Content-Type: text/csv; charset=' . get_bloginfo( 'charset' ) ); |
|
42 | + header("Content-Disposition: attachment; filename=$filename"); |
|
43 | + header('Content-Type: text/csv; charset='.get_bloginfo('charset')); |
|
44 | 44 | |
45 | 45 | // Do not cache the file. |
46 | - header( 'Pragma: no-cache' ); |
|
47 | - header( 'Expires: 0' ); |
|
46 | + header('Pragma: no-cache'); |
|
47 | + header('Expires: 0'); |
|
48 | 48 | |
49 | 49 | // Build the CSV file. |
50 | 50 | $this->create_csv(); |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function get_site_path() { |
64 | 64 | // Get home url from database. |
65 | - $home_url = home_url( '/' ); |
|
65 | + $home_url = home_url('/'); |
|
66 | 66 | |
67 | 67 | // Parse the url. |
68 | - $parsed = wp_parse_url( $home_url ); |
|
68 | + $parsed = wp_parse_url($home_url); |
|
69 | 69 | |
70 | 70 | // Return the path. |
71 | 71 | return $parsed['path']; |
@@ -80,16 +80,16 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public static function is_postname_permalink_structure() { |
82 | 82 | // Get current permalink structure. |
83 | - $structure = get_option( 'permalink_structure' ); |
|
83 | + $structure = get_option('permalink_structure'); |
|
84 | 84 | |
85 | 85 | // The regular expression. It will check if the site structure contains postname. |
86 | 86 | $regex = '~^/\%postname\%/$~'; |
87 | 87 | |
88 | 88 | // Check if the site structure match the rquired one. |
89 | - preg_match( $regex, $structure, $matches ); |
|
89 | + preg_match($regex, $structure, $matches); |
|
90 | 90 | |
91 | 91 | // Bail if the site have different structure. |
92 | - if ( empty( $matches ) ) { |
|
92 | + if (empty($matches)) { |
|
93 | 93 | return false; |
94 | 94 | } |
95 | 95 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | public function create_csv() { |
149 | 149 | // Create a file pointer connected to the output stream. |
150 | 150 | // Ignoring linter notices below that complain about file output which do not actually happen. |
151 | - $file = fopen( 'php://output', 'w' ); |
|
151 | + $file = fopen('php://output', 'w'); |
|
152 | 152 | |
153 | 153 | // Add the column headers. @codingStandardsIgnoreLine |
154 | 154 | fputcsv( |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | ); |
162 | 162 | |
163 | 163 | // Cycle through items and add each item data to the file. |
164 | - foreach ( $this->get_content_data() as $row ) { |
|
164 | + foreach ($this->get_content_data() as $row) { |
|
165 | 165 | // Add new line in the file. @codingStandardsIgnoreLine |
166 | 166 | fputcsv( |
167 | 167 | $file, |