All in One SEO Pack - Version 2.1

Version Description

Download this release

Release Info

Developer pbaylies
Plugin Icon 128x128 All in One SEO Pack
Version 2.1
Comparing to
See all releases

Code changes from version 2.0.4.1 to 2.1

OAuth.php ADDED
@@ -0,0 +1,939 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* OAuth PHP Library
3
+ * http://oauth.googlecode.com/svn/code/php/
4
+ *
5
+ * License: The MIT License
6
+ *
7
+ * Copyright (c) 2007 Andy Smith
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in
17
+ * all copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
+ * THE SOFTWARE.
26
+ *
27
+ */
28
+ // vim: foldmethod=marker
29
+
30
+ /* Generic exception class
31
+ */
32
+ if ( !class_exists( 'OAuthException' ) ) {
33
+ class OAuthException extends Exception {
34
+ // pass
35
+ }
36
+ }
37
+
38
+ if ( !class_exists( 'OAuthConsumer' ) ) {
39
+ class OAuthConsumer {
40
+ public $key;
41
+ public $secret;
42
+
43
+ function __construct($key, $secret, $callback_url=NULL) {
44
+ $this->key = $key;
45
+ $this->secret = $secret;
46
+ $this->callback_url = $callback_url;
47
+ }
48
+
49
+ function __toString() {
50
+ return "OAuthConsumer[key=$this->key,secret=$this->secret]";
51
+ }
52
+ }
53
+ }
54
+
55
+ if ( !class_exists( 'OAuthToken' ) ) {
56
+ class OAuthToken {
57
+ // access tokens and request tokens
58
+ public $key;
59
+ public $secret;
60
+
61
+ /**
62
+ * key = the token
63
+ * secret = the token secret
64
+ */
65
+ function __construct($key, $secret) {
66
+ $this->key = $key;
67
+ $this->secret = $secret;
68
+ }
69
+
70
+ /**
71
+ * generates the basic string serialization of a token that a server
72
+ * would respond to request_token and access_token calls with
73
+ */
74
+ function to_string() {
75
+ return "oauth_token=" .
76
+ OAuthUtil::urlencode_rfc3986($this->key) .
77
+ "&oauth_token_secret=" .
78
+ OAuthUtil::urlencode_rfc3986($this->secret);
79
+ }
80
+
81
+ function __toString() {
82
+ return $this->to_string();
83
+ }
84
+ }
85
+ }
86
+
87
+ if ( !class_exists('OAuthSignatureMethod') ) {
88
+ /**
89
+ * A class for implementing a Signature Method
90
+ * See section 9 ("Signing Requests") in the spec
91
+ */
92
+ abstract class OAuthSignatureMethod {
93
+ /**
94
+ * Needs to return the name of the Signature Method (ie HMAC-SHA1)
95
+ * @return string
96
+ */
97
+ abstract public function get_name();
98
+
99
+ /**
100
+ * Build up the signature
101
+ * NOTE: The output of this function MUST NOT be urlencoded.
102
+ * the encoding is handled in OAuthRequest when the final
103
+ * request is serialized
104
+ * @param OAuthRequest $request
105
+ * @param OAuthConsumer $consumer
106
+ * @param OAuthToken $token
107
+ * @return string
108
+ */
109
+ abstract public function build_signature($request, $consumer, $token);
110
+
111
+ /**
112
+ * Verifies that a given signature is correct
113
+ * @param OAuthRequest $request
114
+ * @param OAuthConsumer $consumer
115
+ * @param OAuthToken $token
116
+ * @param string $signature
117
+ * @return bool
118
+ */
119
+ public function check_signature($request, $consumer, $token, $signature) {
120
+ $built = $this->build_signature($request, $consumer, $token);
121
+
122
+ // Check for zero length, although unlikely here
123
+ if (strlen($built) == 0 || strlen($signature) == 0) {
124
+ return false;
125
+ }
126
+
127
+ if (strlen($built) != strlen($signature)) {
128
+ return false;
129
+ }
130
+
131
+ // Avoid a timing leak with a (hopefully) time insensitive compare
132
+ $result = 0;
133
+ for ($i = 0; $i < strlen($signature); $i++) {
134
+ $result |= ord($built{$i}) ^ ord($signature{$i});
135
+ }
136
+
137
+ return $result == 0;
138
+ }
139
+ }
140
+ }
141
+
142
+ if ( !class_exists('OAuthSignatureMethod_HMAC_SHA1') ) {
143
+ /**
144
+ * The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104]
145
+ * where the Signature Base String is the text and the key is the concatenated values (each first
146
+ * encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&'
147
+ * character (ASCII code 38) even if empty.
148
+ * - Chapter 9.2 ("HMAC-SHA1")
149
+ */
150
+ class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
151
+ function get_name() {
152
+ return "HMAC-SHA1";
153
+ }
154
+
155
+ public function build_signature($request, $consumer, $token) {
156
+ $base_string = $request->get_signature_base_string();
157
+ $request->base_string = $base_string;
158
+
159
+ $key_parts = array(
160
+ $consumer->secret,
161
+ ($token) ? $token->secret : ""
162
+ );
163
+
164
+ $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
165
+ $key = implode('&', $key_parts);
166
+
167
+ return base64_encode(hash_hmac('sha1', $base_string, $key, true));
168
+ }
169
+ }
170
+ }
171
+
172
+ if ( !class_exists('OAuthSignatureMethod_PLAINTEXT') ) {
173
+ /**
174
+ * The PLAINTEXT method does not provide any security protection and SHOULD only be used
175
+ * over a secure channel such as HTTPS. It does not use the Signature Base String.
176
+ * - Chapter 9.4 ("PLAINTEXT")
177
+ */
178
+ class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
179
+ public function get_name() {
180
+ return "PLAINTEXT";
181
+ }
182
+
183
+ /**
184
+ * oauth_signature is set to the concatenated encoded values of the Consumer Secret and
185
+ * Token Secret, separated by a '&' character (ASCII code 38), even if either secret is
186
+ * empty. The result MUST be encoded again.
187
+ * - Chapter 9.4.1 ("Generating Signatures")
188
+ *
189
+ * Please note that the second encoding MUST NOT happen in the SignatureMethod, as
190
+ * OAuthRequest handles this!
191
+ */
192
+ public function build_signature($request, $consumer, $token) {
193
+ $key_parts = array(
194
+ $consumer->secret,
195
+ ($token) ? $token->secret : ""
196
+ );
197
+
198
+ $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
199
+ $key = implode('&', $key_parts);
200
+ $request->base_string = $key;
201
+
202
+ return $key;
203
+ }
204
+ }
205
+ }
206
+
207
+
208
+ if ( !class_exists('OAuthSignatureMethod_RSA_SHA1') ) {
209
+ /**
210
+ * The RSA-SHA1 signature method uses the RSASSA-PKCS1-v1_5 signature algorithm as defined in
211
+ * [RFC3447] section 8.2 (more simply known as PKCS#1), using SHA-1 as the hash function for
212
+ * EMSA-PKCS1-v1_5. It is assumed that the Consumer has provided its RSA public key in a
213
+ * verified way to the Service Provider, in a manner which is beyond the scope of this
214
+ * specification.
215
+ * - Chapter 9.3 ("RSA-SHA1")
216
+ */
217
+ abstract class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
218
+ public function get_name() {
219
+ return "RSA-SHA1";
220
+ }
221
+
222
+ // Up to the SP to implement this lookup of keys. Possible ideas are:
223
+ // (1) do a lookup in a table of trusted certs keyed off of consumer
224
+ // (2) fetch via http using a url provided by the requester
225
+ // (3) some sort of specific discovery code based on request
226
+ //
227
+ // Either way should return a string representation of the certificate
228
+ protected abstract function fetch_public_cert(&$request);
229
+
230
+ // Up to the SP to implement this lookup of keys. Possible ideas are:
231
+ // (1) do a lookup in a table of trusted certs keyed off of consumer
232
+ //
233
+ // Either way should return a string representation of the certificate
234
+ protected abstract function fetch_private_cert(&$request);
235
+
236
+ public function build_signature($request, $consumer, $token) {
237
+ $base_string = $request->get_signature_base_string();
238
+ $request->base_string = $base_string;
239
+
240
+ // Fetch the private key cert based on the request
241
+ $cert = $this->fetch_private_cert($request);
242
+
243
+ // Pull the private key ID from the certificate
244
+ $privatekeyid = openssl_get_privatekey($cert);
245
+
246
+ // Sign using the key
247
+ $ok = openssl_sign($base_string, $signature, $privatekeyid);
248
+
249
+ // Release the key resource
250
+ openssl_free_key($privatekeyid);
251
+
252
+ return base64_encode($signature);
253
+ }
254
+
255
+ public function check_signature($request, $consumer, $token, $signature) {
256
+ $decoded_sig = base64_decode($signature);
257
+
258
+ $base_string = $request->get_signature_base_string();
259
+
260
+ // Fetch the public key cert based on the request
261
+ $cert = $this->fetch_public_cert($request);
262
+
263
+ // Pull the public key ID from the certificate
264
+ $publickeyid = openssl_get_publickey($cert);
265
+
266
+ // Check the computed signature against the one passed in the query
267
+ $ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
268
+
269
+ // Release the key resource
270
+ openssl_free_key($publickeyid);
271
+
272
+ return $ok == 1;
273
+ }
274
+ }
275
+ }
276
+
277
+ if ( !class_exists('OAuthRequest') ) {
278
+ class OAuthRequest {
279
+ protected $parameters;
280
+ protected $http_method;
281
+ protected $http_url;
282
+ // for debug purposes
283
+ public $base_string;
284
+ public static $version = '1.0';
285
+ public static $POST_INPUT = 'php://input';
286
+
287
+ function __construct($http_method, $http_url, $parameters=NULL) {
288
+ $parameters = ($parameters) ? $parameters : array();
289
+ $parameters = array_merge( OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
290
+ $this->parameters = $parameters;
291
+ $this->http_method = $http_method;
292
+ $this->http_url = $http_url;
293
+ }
294
+
295
+
296
+ /**
297
+ * attempt to build up a request from what was passed to the server
298
+ */
299
+ public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
300
+ $scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
301
+ ? 'http'
302
+ : 'https';
303
+ $http_url = ($http_url) ? $http_url : $scheme .
304
+ '://' . $_SERVER['SERVER_NAME'] .
305
+ ':' .
306
+ $_SERVER['SERVER_PORT'] .
307
+ $_SERVER['REQUEST_URI'];
308
+ $http_method = ($http_method) ? $http_method : $_SERVER['REQUEST_METHOD'];
309
+
310
+ // We weren't handed any parameters, so let's find the ones relevant to
311
+ // this request.
312
+ // If you run XML-RPC or similar you should use this to provide your own
313
+ // parsed parameter-list
314
+ if (!$parameters) {
315
+ // Find request headers
316
+ $request_headers = OAuthUtil::get_headers();
317
+
318
+ // Parse the query-string to find GET parameters
319
+ $parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
320
+
321
+ // It's a POST request of the proper content-type, so parse POST
322
+ // parameters and add those overriding any duplicates from GET
323
+ if ($http_method == "POST"
324
+ && isset($request_headers['Content-Type'])
325
+ && strstr($request_headers['Content-Type'],
326
+ 'application/x-www-form-urlencoded')
327
+ ) {
328
+ $post_data = OAuthUtil::parse_parameters(
329
+ file_get_contents(self::$POST_INPUT)
330
+ );
331
+ $parameters = array_merge($parameters, $post_data);
332
+ }
333
+
334
+ // We have a Authorization-header with OAuth data. Parse the header
335
+ // and add those overriding any duplicates from GET or POST
336
+ if (isset($request_headers['Authorization']) && substr($request_headers['Authorization'], 0, 6) == 'OAuth ') {
337
+ $header_parameters = OAuthUtil::split_header(
338
+ $request_headers['Authorization']
339
+ );
340
+ $parameters = array_merge($parameters, $header_parameters);
341
+ }
342
+
343
+ }
344
+
345
+ return new OAuthRequest($http_method, $http_url, $parameters);
346
+ }
347
+
348
+ /**
349
+ * pretty much a helper function to set up the request
350
+ */
351
+ public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
352
+ $parameters = ($parameters) ? $parameters : array();
353
+ $defaults = array("oauth_version" => OAuthRequest::$version,
354
+ "oauth_nonce" => OAuthRequest::generate_nonce(),
355
+ "oauth_timestamp" => OAuthRequest::generate_timestamp(),
356
+ "oauth_consumer_key" => $consumer->key);
357
+ if ($token)
358
+ $defaults['oauth_token'] = $token->key;
359
+
360
+ $parameters = array_merge($defaults, $parameters);
361
+
362
+ return new OAuthRequest($http_method, $http_url, $parameters);
363
+ }
364
+
365
+ public function set_parameter($name, $value, $allow_duplicates = true) {
366
+ if ($allow_duplicates && isset($this->parameters[$name])) {
367
+ // We have already added parameter(s) with this name, so add to the list
368
+ if (is_scalar($this->parameters[$name])) {
369
+ // This is the first duplicate, so transform scalar (string)
370
+ // into an array so we can add the duplicates
371
+ $this->parameters[$name] = array($this->parameters[$name]);
372
+ }
373
+
374
+ $this->parameters[$name][] = $value;
375
+ } else {
376
+ $this->parameters[$name] = $value;
377
+ }
378
+ }
379
+
380
+ public function get_parameter($name) {
381
+ return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
382
+ }
383
+
384
+ public function get_parameters() {
385
+ return $this->parameters;
386
+ }
387
+
388
+ public function unset_parameter($name) {
389
+ unset($this->parameters[$name]);
390
+ }
391
+
392
+ /**
393
+ * The request parameters, sorted and concatenated into a normalized string.
394
+ * @return string
395
+ */
396
+ public function get_signable_parameters() {
397
+ // Grab all parameters
398
+ $params = $this->parameters;
399
+
400
+ // Remove oauth_signature if present
401
+ // Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
402
+ if (isset($params['oauth_signature'])) {
403
+ unset($params['oauth_signature']);
404
+ }
405
+
406
+ return OAuthUtil::build_http_query($params);
407
+ }
408
+
409
+ /**
410
+ * Returns the base string of this request
411
+ *
412
+ * The base string defined as the method, the url
413
+ * and the parameters (normalized), each urlencoded
414
+ * and the concated with &.
415
+ */
416
+ public function get_signature_base_string() {
417
+ $parts = array(
418
+ $this->get_normalized_http_method(),
419
+ $this->get_normalized_http_url(),
420
+ $this->get_signable_parameters()
421
+ );
422
+
423
+ $parts = OAuthUtil::urlencode_rfc3986($parts);
424
+
425
+ return implode('&', $parts);
426
+ }
427
+
428
+ /**
429
+ * just uppercases the http method
430
+ */
431
+ public function get_normalized_http_method() {
432
+ return strtoupper($this->http_method);
433
+ }
434
+
435
+ /**
436
+ * parses the url and rebuilds it to be
437
+ * scheme://host/path
438
+ */
439
+ public function get_normalized_http_url() {
440
+ $parts = parse_url($this->http_url);
441
+
442
+ $scheme = (isset($parts['scheme'])) ? $parts['scheme'] : 'http';
443
+ $port = (isset($parts['port'])) ? $parts['port'] : (($scheme == 'https') ? '443' : '80');
444
+ $host = (isset($parts['host'])) ? strtolower($parts['host']) : '';
445
+ $path = (isset($parts['path'])) ? $parts['path'] : '';
446
+
447
+ if (($scheme == 'https' && $port != '443')
448
+ || ($scheme == 'http' && $port != '80')) {
449
+ $host = "$host:$port";
450
+ }
451
+ return "$scheme://$host$path";
452
+ }
453
+
454
+ /**
455
+ * builds a url usable for a GET request
456
+ */
457
+ public function to_url() {
458
+ $post_data = $this->to_postdata();
459
+ $out = $this->get_normalized_http_url();
460
+ if ($post_data) {
461
+ $out .= '?'.$post_data;
462
+ }
463
+ return $out;
464
+ }
465
+
466
+ /**
467
+ * builds the data one would send in a POST request
468
+ */
469
+ public function to_postdata() {
470
+ return OAuthUtil::build_http_query($this->parameters);
471
+ }
472
+
473
+ /**
474
+ * builds the Authorization: header
475
+ */
476
+ public function to_header($realm=null) {
477
+ $first = true;
478
+ if($realm) {
479
+ $out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"';
480
+ $first = false;
481
+ } else
482
+ $out = 'Authorization: OAuth';
483
+
484
+ $total = array();
485
+ foreach ($this->parameters as $k => $v) {
486
+ if (substr($k, 0, 5) != "oauth") continue;
487
+ if (is_array($v)) {
488
+ throw new OAuthException('Arrays not supported in headers');
489
+ }
490
+ $out .= ($first) ? ' ' : ',';
491
+ $out .= OAuthUtil::urlencode_rfc3986($k) .
492
+ '="' .
493
+ OAuthUtil::urlencode_rfc3986($v) .
494
+ '"';
495
+ $first = false;
496
+ }
497
+ return $out;
498
+ }
499
+
500
+ public function __toString() {
501
+ return $this->to_url();
502
+ }
503
+
504
+
505
+ public function sign_request($signature_method, $consumer, $token) {
506
+ $this->set_parameter(
507
+ "oauth_signature_method",
508
+ $signature_method->get_name(),
509
+ false
510
+ );
511
+ $signature = $this->build_signature($signature_method, $consumer, $token);
512
+ $this->set_parameter("oauth_signature", $signature, false);
513
+ }
514
+
515
+ public function build_signature($signature_method, $consumer, $token) {
516
+ $signature = $signature_method->build_signature($this, $consumer, $token);
517
+ return $signature;
518
+ }
519
+
520
+ /**
521
+ * util function: current timestamp
522
+ */
523
+ private static function generate_timestamp() {
524
+ return time();
525
+ }
526
+
527
+ /**
528
+ * util function: current nonce
529
+ */
530
+ private static function generate_nonce() {
531
+ $mt = microtime();
532
+ $rand = mt_rand();
533
+
534
+ return md5($mt . $rand); // md5s look nicer than numbers
535
+ }
536
+ }
537
+ }
538
+
539
+ if ( !class_exists('OAuthServer') ) {
540
+ class OAuthServer {
541
+ protected $timestamp_threshold = 300; // in seconds, five minutes
542
+ protected $version = '1.0'; // hi blaine
543
+ protected $signature_methods = array();
544
+
545
+ protected $data_store;
546
+
547
+ function __construct($data_store) {
548
+ $this->data_store = $data_store;
549
+ }
550
+
551
+ public function add_signature_method($signature_method) {
552
+ $this->signature_methods[$signature_method->get_name()] =
553
+ $signature_method;
554
+ }
555
+
556
+ // high level functions
557
+
558
+ /**
559
+ * process a request_token request
560
+ * returns the request token on success
561
+ */
562
+ public function fetch_request_token(&$request) {
563
+ $this->get_version($request);
564
+
565
+ $consumer = $this->get_consumer($request);
566
+
567
+ // no token required for the initial token request
568
+ $token = NULL;
569
+
570
+ $this->check_signature($request, $consumer, $token);
571
+
572
+ // Rev A change
573
+ $callback = $request->get_parameter('oauth_callback');
574
+ $new_token = $this->data_store->new_request_token($consumer, $callback);
575
+
576
+ return $new_token;
577
+ }
578
+
579
+ /**
580
+ * process an access_token request
581
+ * returns the access token on success
582
+ */
583
+ public function fetch_access_token(&$request) {
584
+ $this->get_version($request);
585
+
586
+ $consumer = $this->get_consumer($request);
587
+
588
+ // requires authorized request token
589
+ $token = $this->get_token($request, $consumer, "request");
590
+
591
+ $this->check_signature($request, $consumer, $token);
592
+
593
+ // Rev A change
594
+ $verifier = $request->get_parameter('oauth_verifier');
595
+ $new_token = $this->data_store->new_access_token($token, $consumer, $verifier);
596
+
597
+ return $new_token;
598
+ }
599
+
600
+ /**
601
+ * verify an api call, checks all the parameters
602
+ */
603
+ public function verify_request(&$request) {
604
+ $this->get_version($request);
605
+ $consumer = $this->get_consumer($request);
606
+ $token = $this->get_token($request, $consumer, "access");
607
+ $this->check_signature($request, $consumer, $token);
608
+ return array($consumer, $token);
609
+ }
610
+
611
+ // Internals from here
612
+ /**
613
+ * version 1
614
+ */
615
+ private function get_version(&$request) {
616
+ $version = $request->get_parameter("oauth_version");
617
+ if (!$version) {
618
+ // Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present.
619
+ // Chapter 7.0 ("Accessing Protected Ressources")
620
+ $version = '1.0';
621
+ }
622
+ if ($version !== $this->version) {
623
+ throw new OAuthException("OAuth version '$version' not supported");
624
+ }
625
+ return $version;
626
+ }
627
+
628
+ /**
629
+ * figure out the signature with some defaults
630
+ */
631
+ private function get_signature_method($request) {
632
+ $signature_method = $request instanceof OAuthRequest
633
+ ? $request->get_parameter("oauth_signature_method")
634
+ : NULL;
635
+
636
+ if (!$signature_method) {
637
+ // According to chapter 7 ("Accessing Protected Ressources") the signature-method
638
+ // parameter is required, and we can't just fallback to PLAINTEXT
639
+ throw new OAuthException('No signature method parameter. This parameter is required');
640
+ }
641
+
642
+ if (!in_array($signature_method,
643
+ array_keys($this->signature_methods))) {
644
+ throw new OAuthException(
645
+ "Signature method '$signature_method' not supported " .
646
+ "try one of the following: " .
647
+ implode(", ", array_keys($this->signature_methods))
648
+ );
649
+ }
650
+ return $this->signature_methods[$signature_method];
651
+ }
652
+
653
+ /**
654
+ * try to find the consumer for the provided request's consumer key
655
+ */
656
+ private function get_consumer($request) {
657
+ $consumer_key = $request instanceof OAuthRequest
658
+ ? $request->get_parameter("oauth_consumer_key")
659
+ : NULL;
660
+
661
+ if (!$consumer_key) {
662
+ throw new OAuthException("Invalid consumer key");
663
+ }
664
+
665
+ $consumer = $this->data_store->lookup_consumer($consumer_key);
666
+ if (!$consumer) {
667
+ throw new OAuthException("Invalid consumer");
668
+ }
669
+
670
+ return $consumer;
671
+ }
672
+
673
+ /**
674
+ * try to find the token for the provided request's token key
675
+ */
676
+ private function get_token($request, $consumer, $token_type="access") {
677
+ $token_field = $request instanceof OAuthRequest
678
+ ? $request->get_parameter('oauth_token')
679
+ : NULL;
680
+
681
+ $token = $this->data_store->lookup_token(
682
+ $consumer, $token_type, $token_field
683
+ );
684
+ if (!$token) {
685
+ throw new OAuthException("Invalid $token_type token: $token_field");
686
+ }
687
+ return $token;
688
+ }
689
+
690
+ /**
691
+ * all-in-one function to check the signature on a request
692
+ * should guess the signature method appropriately
693
+ */
694
+ private function check_signature($request, $consumer, $token) {
695
+ // this should probably be in a different method
696
+ $timestamp = $request instanceof OAuthRequest
697
+ ? $request->get_parameter('oauth_timestamp')
698
+ : NULL;
699
+ $nonce = $request instanceof OAuthRequest
700
+ ? $request->get_parameter('oauth_nonce')
701
+ : NULL;
702
+
703
+ $this->check_timestamp($timestamp);
704
+ $this->check_nonce($consumer, $token, $nonce, $timestamp);
705
+
706
+ $signature_method = $this->get_signature_method($request);
707
+
708
+ $signature = $request->get_parameter('oauth_signature');
709
+ $valid_sig = $signature_method->check_signature(
710
+ $request,
711
+ $consumer,
712
+ $token,
713
+ $signature
714
+ );
715
+
716
+ if (!$valid_sig) {
717
+ throw new OAuthException("Invalid signature");
718
+ }
719
+ }
720
+
721
+ /**
722
+ * check that the timestamp is new enough
723
+ */
724
+ private function check_timestamp($timestamp) {
725
+ if( ! $timestamp )
726
+ throw new OAuthException(
727
+ 'Missing timestamp parameter. The parameter is required'
728
+ );
729
+
730
+ // verify that timestamp is recentish
731
+ $now = time();
732
+ if (abs($now - $timestamp) > $this->timestamp_threshold) {
733
+ throw new OAuthException(
734
+ "Expired timestamp, yours $timestamp, ours $now"
735
+ );
736
+ }
737
+ }
738
+
739
+ /**
740
+ * check that the nonce is not repeated
741
+ */
742
+ private function check_nonce($consumer, $token, $nonce, $timestamp) {
743
+ if( ! $nonce )
744
+ throw new OAuthException(
745
+ 'Missing nonce parameter. The parameter is required'
746
+ );
747
+
748
+ // verify that the nonce is uniqueish
749
+ $found = $this->data_store->lookup_nonce(
750
+ $consumer,
751
+ $token,
752
+ $nonce,
753
+ $timestamp
754
+ );
755
+ if ($found) {
756
+ throw new OAuthException("Nonce already used: $nonce");
757
+ }
758
+ }
759
+ }
760
+ }
761
+
762
+ if ( !class_exists('OAuthDataStore') ) {
763
+ class OAuthDataStore {
764
+ function lookup_consumer($consumer_key) {
765
+ // implement me
766
+ }
767
+
768
+ function lookup_token($consumer, $token_type, $token) {
769
+ // implement me
770
+ }
771
+
772
+ function lookup_nonce($consumer, $token, $nonce, $timestamp) {
773
+ // implement me
774
+ }
775
+
776
+ function new_request_token($consumer, $callback = null) {
777
+ // return a new token attached to this consumer
778
+ }
779
+
780
+ function new_access_token($token, $consumer, $verifier = null) {
781
+ // return a new access token attached to this consumer
782
+ // for the user associated with this token if the request token
783
+ // is authorized
784
+ // should also invalidate the request token
785
+ }
786
+ }
787
+ }
788
+
789
+ if ( !class_exists('OAuthUtil') ) {
790
+ class OAuthUtil {
791
+ public static function urlencode_rfc3986($input) {
792
+ if (is_array($input)) {
793
+ return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input);
794
+ } else if (is_scalar($input)) {
795
+ return str_replace(
796
+ '+',
797
+ ' ',
798
+ str_replace('%7E', '~', rawurlencode($input))
799
+ );
800
+ } else {
801
+ return '';
802
+ }
803
+ }
804
+
805
+ // This decode function isn't taking into consideration the above
806
+ // modifications to the encoding process. However, this method doesn't
807
+ // seem to be used anywhere so leaving it as is.
808
+ public static function urldecode_rfc3986($string) {
809
+ return urldecode($string);
810
+ }
811
+
812
+ // Utility function for turning the Authorization: header into
813
+ // parameters, has to do some unescaping
814
+ // Can filter out any non-oauth parameters if needed (default behaviour)
815
+ // May 28th, 2010 - method updated to tjerk.meesters for a speed improvement.
816
+ // see http://code.google.com/p/oauth/issues/detail?id=163
817
+ public static function split_header($header, $only_allow_oauth_parameters = true) {
818
+ $params = array();
819
+ if (preg_match_all('/('.($only_allow_oauth_parameters ? 'oauth_' : '').'[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header, $matches)) {
820
+ foreach ($matches[1] as $i => $h) {
821
+ $params[$h] = OAuthUtil::urldecode_rfc3986(empty($matches[3][$i]) ? $matches[4][$i] : $matches[3][$i]);
822
+ }
823
+ if (isset($params['realm'])) {
824
+ unset($params['realm']);
825
+ }
826
+ }
827
+ return $params;
828
+ }
829
+
830
+ // helper to try to sort out headers for people who aren't running apache
831
+ public static function get_headers() {
832
+ if (function_exists('apache_request_headers')) {
833
+ // we need this to get the actual Authorization: header
834
+ // because apache tends to tell us it doesn't exist
835
+ $headers = apache_request_headers();
836
+
837
+ // sanitize the output of apache_request_headers because
838
+ // we always want the keys to be Cased-Like-This and arh()
839
+ // returns the headers in the same case as they are in the
840
+ // request
841
+ $out = array();
842
+ foreach ($headers AS $key => $value) {
843
+ $key = str_replace(
844
+ " ",
845
+ "-",
846
+ ucwords(strtolower(str_replace("-", " ", $key)))
847
+ );
848
+ $out[$key] = $value;
849
+ }
850
+ } else {
851
+ // otherwise we don't have apache and are just going to have to hope
852
+ // that $_SERVER actually contains what we need
853
+ $out = array();
854
+ if( isset($_SERVER['CONTENT_TYPE']) )
855
+ $out['Content-Type'] = $_SERVER['CONTENT_TYPE'];
856
+ if( isset($_ENV['CONTENT_TYPE']) )
857
+ $out['Content-Type'] = $_ENV['CONTENT_TYPE'];
858
+
859
+ foreach ($_SERVER as $key => $value) {
860
+ if (substr($key, 0, 5) == "HTTP_") {
861
+ // this is chaos, basically it is just there to capitalize the first
862
+ // letter of every word that is not an initial HTTP and strip HTTP
863
+ // code from przemek
864
+ $key = str_replace(
865
+ " ",
866
+ "-",
867
+ ucwords(strtolower(str_replace("_", " ", substr($key, 5))))
868
+ );
869
+ $out[$key] = $value;
870
+ }
871
+ }
872
+ }
873
+ return $out;
874
+ }
875
+
876
+ // This function takes a input like a=b&a=c&d=e and returns the parsed
877
+ // parameters like this
878
+ // array('a' => array('b','c'), 'd' => 'e')
879
+ public static function parse_parameters( $input ) {
880
+ if (!isset($input) || !$input) return array();
881
+
882
+ $pairs = explode('&', $input);
883
+
884
+ $parsed_parameters = array();
885
+ foreach ($pairs as $pair) {
886
+ $split = explode('=', $pair, 2);
887
+ $parameter = OAuthUtil::urldecode_rfc3986($split[0]);
888
+ $value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
889
+
890
+ if (isset($parsed_parameters[$parameter])) {
891
+ // We have already recieved parameter(s) with this name, so add to the list
892
+ // of parameters with this name
893
+
894
+ if (is_scalar($parsed_parameters[$parameter])) {
895
+ // This is the first duplicate, so transform scalar (string) into an array
896
+ // so we can add the duplicates
897
+ $parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
898
+ }
899
+
900
+ $parsed_parameters[$parameter][] = $value;
901
+ } else {
902
+ $parsed_parameters[$parameter] = $value;
903
+ }
904
+ }
905
+ return $parsed_parameters;
906
+ }
907
+
908
+ public static function build_http_query($params) {
909
+ if (!$params) return '';
910
+
911
+ // Urlencode both keys and values
912
+ $keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
913
+ $values = OAuthUtil::urlencode_rfc3986(array_values($params));
914
+ $params = array_combine($keys, $values);
915
+
916
+ // Parameters are sorted by name, using lexicographical byte value ordering.
917
+ // Ref: Spec: 9.1.1 (1)
918
+ uksort($params, 'strcmp');
919
+
920
+ $pairs = array();
921
+ foreach ($params as $parameter => $value) {
922
+ if (is_array($value)) {
923
+ // If two or more parameters share the same name, they are sorted by their value
924
+ // Ref: Spec: 9.1.1 (1)
925
+ // June 12th, 2010 - changed to sort because of issue 164 by hidetaka
926
+ sort($value, SORT_STRING);
927
+ foreach ($value as $duplicate_value) {
928
+ $pairs[] = $parameter . '=' . $duplicate_value;
929
+ }
930
+ } else {
931
+ $pairs[] = $parameter . '=' . $value;
932
+ }
933
+ }
934
+ // For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
935
+ // Each name-value pair is separated by an '&' character (ASCII code 38)
936
+ return implode('&', $pairs);
937
+ }
938
+ }
939
+ }
aioseop_class.php CHANGED
@@ -39,6 +39,13 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
39
 
40
  /** Flag whether there should be logging. */
41
  var $do_log;
 
 
 
 
 
 
 
42
 
43
  function All_in_One_SEO_Pack() {
44
  global $aioseop_options;
@@ -156,10 +163,12 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
156
  "pinterest_verify" => __( "Enter your verification code here to verify your site with Pinterest.<br /><a href='http://semperplugins.com/documentation/pinterest-site-verification/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
157
  "google_publisher" => __( "Enter your Google Plus Profile URL here to link your site to your Google Plus account for authorship.<br /><a href='http://semperplugins.com/documentation/google-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
158
  "google_disable_profile"=> __( "Check this to remove the Google Plus field from the user profile screen.<br /><a href='http://semperplugins.com/documentation/google-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
 
159
  "google_analytics_id" => __( "Enter your Google Analytics ID here to track visitor behavior on your site using Google Analytics.<br /><a href='http://semperplugins.com/documentation/google-analytics/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
160
  "ga_use_universal_analytics" => __( "Use the new Universal Analytics tracking code for Google Analytics; do this for new analytics accounts.", 'all_in_one_seo_pack' ),
161
  "ga_domain" => __( "Enter your domain name if you have enabled tracking of Subdomains in Google Analytics.<br /><a href='http://semperplugins.com/documentation/google-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
162
  "ga_multi_domain" => __( "Check this if you have enabled tracking of Multiple top-level domains in Google Analytics.<br /><a href='http://semperplugins.com/documentation/google-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
 
163
  "ga_track_outbound_links"=> __( "Check this if you want to track outbound links with Google Analytics.<br /><a href='http://semperplugins.com/documentation/google-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
164
  "cpostnoindex" => __( "Set the default NOINDEX setting for each Post Type.<br /><a href='http://semperplugins.com/documentation/noindex-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
165
  "cpostnofollow" => __( "Set the default NOFOLLOW setting for each Post Type.<br /><a href='http://semperplugins.com/documentation/noindex-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
@@ -342,6 +351,8 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
342
  "google_disable_profile"=> Array(
343
  'name' => __( 'Disable Google Plus Profile:', 'all_in_one_seo_pack' ), 'default' => 0, 'type' => 'checkbox'
344
  ),
 
 
345
  "google_analytics_id"=> Array(
346
  'name' => __( 'Google Analytics ID:', 'all_in_one_seo_pack' ),
347
  'default' => null, 'type' => 'text' ),
@@ -357,6 +368,10 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
357
  'name' => __( 'Track Multiple Domains:', 'all_in_one_seo_pack' ),
358
  'default' => 0,
359
  'condshow' => Array( 'aiosp_google_analytics_id' => Array( 'lhs' => 'aiosp_google_analytics_id', 'op' => '!=', 'rhs' => '' ) ) ),
 
 
 
 
360
  "ga_track_outbound_links"=> Array(
361
  'name' => __( 'Track Outbound Links:', 'all_in_one_seo_pack' ),
362
  'default' => 0,
@@ -504,7 +519,7 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
504
  'google' => Array(
505
  'name' => __( 'Google Settings', 'all_in_one_seo_pack' ),
506
  'help_link' => 'http://semperplugins.com/documentation/google-settings/',
507
- 'options' => Array( "google_publisher", "google_disable_profile", "google_analytics_id", "ga_use_universal_analytics", "ga_domain", "ga_multi_domain", "ga_track_outbound_links" )
508
  ),
509
  'noindex' => Array(
510
  'name' => __( 'Noindex Settings', 'all_in_one_seo_pack' ),
@@ -689,6 +704,7 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
689
  }
690
 
691
  function add_page_hooks() {
 
692
  $post_objs = get_post_types( '', 'objects' );
693
  $pt = array_keys( $post_objs );
694
  $rempost = array( 'revision', 'nav_menu_item' );
@@ -729,23 +745,30 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
729
  $this->layout['cpt']['options'][] = $field;
730
  }
731
  }
732
-
 
 
 
 
 
 
 
733
  $this->setting_options();
734
  add_filter( "{$this->prefix}display_options", Array( $this, 'filter_options' ), 10, 2 );
735
  parent::add_page_hooks();
736
  }
737
 
738
  function add_admin_pointers() {
739
- $this->pointers['aioseop_menu_204'] = Array( 'pointer_target' => '#toplevel_page_all-in-one-seo-pack-aioseop_class',
740
  'pointer_text' => '<h3>' . sprintf( __( 'Welcome to Version %s!', 'all_in_one_seo_pack' ), AIOSEOP_VERSION )
741
  . '</h3><p>' . __( 'Thank you for running the latest and greatest All in One SEO Pack ever! Please review your settings, as we\'re always adding new features for you!', 'all_in_one_seo_pack' ) . '</p>',
742
  'pointer_edge' => 'top',
743
  'pointer_align' => 'left',
744
  'pointer_scope' => 'global'
745
  );
746
- $this->pointers['aioseop_welcome_204'] = Array( 'pointer_target' => '#aioseop_top_button',
747
  'pointer_text' => '<h3>' . sprintf( __( 'Review Your Settings', 'all_in_one_seo_pack' ), AIOSEOP_VERSION )
748
- . '</h3><p>' . __( 'Thank you for running the latest and greatest All in One SEO Pack ever! New since 2.0.3: manage your sitemap with our XML Sitemap module; enable it from our Feature Manager! And please review your settings, we have added some new ones!', 'all_in_one_seo_pack' ) . '</p>',
749
  'pointer_edge' => 'bottom',
750
  'pointer_align' => 'left',
751
  'pointer_scope' => 'local'
@@ -1372,62 +1395,289 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
1372
  do_action( 'aioseop_modules_wp_head' );
1373
  echo "<!-- /all in one seo pack -->\n";
1374
  }
 
 
 
 
 
 
1375
 
1376
- function get_analytics_domain() {
1377
- global $aioseop_options;
1378
- $domain = '';
1379
- if ( !empty( $aioseop_options['aiosp_ga_domain'] ) ) {
1380
- $domain = $aioseop_options['aiosp_ga_domain'];
1381
- $domain = trim( $domain );
1382
- $domain = $this->strtolower( $domain );
1383
- if ( $this->strpos( $domain, "http://" ) === 0 ) $domain = $this->substr( $domain, 7 );
1384
- elseif ( $this->strpos( $domain, "https://" ) === 0 ) $domain = $this->substr( $domain, 8 );
1385
- $domain = untrailingslashit( $domain );
1386
- }
1387
- return $domain;
1388
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1389
 
1390
- function universal_analytics() {
1391
- global $aioseop_options;
1392
- $analytics = '';
1393
- if ( !empty( $aioseop_options['aiosp_ga_use_universal_analytics'] ) ) {
1394
- $allow_linker = '';
1395
- $cookie_domain = $this->get_analytics_domain();
1396
- if ( !empty( $cookie_domain ) ) {
1397
- $cookie_domain = esc_js( $cookie_domain );
1398
- $cookie_domain = "'cookieDomain': '{$cookie_domain}'";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1399
  }
1400
- if ( !empty( $aioseop_options['aiosp_ga_multi_domain'] ) ) {
1401
- $allow_linker = "'allowLinker': true";
 
 
 
 
1402
  }
1403
- $js_options = Array();
1404
- foreach( Array( 'cookie_domain', 'allow_linker' ) as $opts ) {
1405
- if ( !empty( $$opts ) ) $js_options[] = $$opts;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1406
  }
1407
- if ( !empty( $js_options ) ) {
1408
- $js_options = join( ',', $js_options );
1409
- $js_options = ', { ' . $js_options . ' } ';
1410
- } else $js_options = '';
1411
- $analytics_id = esc_js( $aioseop_options["aiosp_google_analytics_id"] );
1412
- $analytics =<<<EOF
1413
- <script>
1414
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
1415
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
1416
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
1417
- })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
1418
 
1419
- ga('create', '{$analytics_id}'{$js_options});
1420
- ga('send', 'pageview');
1421
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1422
 
1423
  EOF;
 
 
1424
  }
1425
- return $analytics;
1426
- }
1427
 
1428
  function aiosp_google_analytics() {
1429
  global $aioseop_options;
1430
  $analytics = '';
 
 
 
 
 
 
 
 
 
 
1431
  if ( !empty( $aioseop_options['aiosp_google_analytics_id'] ) ) {
1432
  ob_start();
1433
  $analytics = $this->universal_analytics();
@@ -1837,7 +2087,6 @@ function aiosp_google_analytics() {
1837
  }
1838
  if (empty( $title ) )
1839
  $title = $this->internationalize( get_option( 'blogname' ) ) . ' | ' . $this->internationalize( get_bloginfo( 'description' ) );
1840
- // $title = $this->internationalize( get_option( 'blogname' ) );
1841
  return $this->paged_title( $title );
1842
  } else if ( is_attachment() ) {
1843
  if ( $post === null ) return false;
@@ -2276,7 +2525,10 @@ function aiosp_google_analytics() {
2276
  $this->update_options( );
2277
 
2278
  $this->add_admin_pointers();
2279
-
 
 
 
2280
 
2281
  $donated = false;
2282
  if ( ( isset( $_POST ) ) && ( isset( $_POST['module'] ) ) && ( isset( $_POST['nonce-aioseop'] ) ) && ( $_POST['module'] == 'All_in_One_SEO_Pack' ) && ( wp_verify_nonce( $_POST['nonce-aioseop'], 'aioseop-nonce' ) ) ) {
@@ -2445,14 +2697,15 @@ function aiosp_google_analytics() {
2445
  // close postboxes that should be closed
2446
  $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
2447
  // postboxes setup
2448
- postboxes.add_postbox_toggles('<?php echo $this->pagehook; ?>');
 
2449
  $('.meta-box-sortables').removeClass('meta-box-sortables');
2450
  });
2451
  //]]>
2452
  </script>
2453
-
2454
  <!-- Headway Themes-->
2455
- <div class="aioseop_advert">
2456
  <div>
2457
  <h3>Drag and Drop WordPress Design</h3>
2458
  <p><a href="http://semperfiwebdesign.com/headwayaio/" target="_blank">Headway Themes</a> allows you to easily create your own stunning website designs! Stop using premade themes start making your own design with Headway's easy to use Drag and Drop interface. All in One SEO Pack users have an exclusive discount by using coupon code <strong>SEMPERFI30</strong> at checkout.</p>
39
 
40
  /** Flag whether there should be logging. */
41
  var $do_log;
42
+
43
+ var $token;
44
+ var $secret;
45
+ var $access_token;
46
+ var $ga_token;
47
+ var $account_cache;
48
+ var $profile_id;
49
 
50
  function All_in_One_SEO_Pack() {
51
  global $aioseop_options;
163
  "pinterest_verify" => __( "Enter your verification code here to verify your site with Pinterest.<br /><a href='http://semperplugins.com/documentation/pinterest-site-verification/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
164
  "google_publisher" => __( "Enter your Google Plus Profile URL here to link your site to your Google Plus account for authorship.<br /><a href='http://semperplugins.com/documentation/google-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
165
  "google_disable_profile"=> __( "Check this to remove the Google Plus field from the user profile screen.<br /><a href='http://semperplugins.com/documentation/google-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
166
+ "google_connect" => __( "Press the connect button to connect with Google Analytics; or if already connected, press the disconnect button to disable and remove any stored analytics credentials.", 'all_in_one_seo_pack' ),
167
  "google_analytics_id" => __( "Enter your Google Analytics ID here to track visitor behavior on your site using Google Analytics.<br /><a href='http://semperplugins.com/documentation/google-analytics/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
168
  "ga_use_universal_analytics" => __( "Use the new Universal Analytics tracking code for Google Analytics; do this for new analytics accounts.", 'all_in_one_seo_pack' ),
169
  "ga_domain" => __( "Enter your domain name if you have enabled tracking of Subdomains in Google Analytics.<br /><a href='http://semperplugins.com/documentation/google-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
170
  "ga_multi_domain" => __( "Check this if you have enabled tracking of Multiple top-level domains in Google Analytics.<br /><a href='http://semperplugins.com/documentation/google-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
171
+ "ga_exclude_users" => __( "Exclude logged-in users from Google Analytics tracking by role.", 'all_in_one_seo_pack' ),
172
  "ga_track_outbound_links"=> __( "Check this if you want to track outbound links with Google Analytics.<br /><a href='http://semperplugins.com/documentation/google-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
173
  "cpostnoindex" => __( "Set the default NOINDEX setting for each Post Type.<br /><a href='http://semperplugins.com/documentation/noindex-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
174
  "cpostnofollow" => __( "Set the default NOFOLLOW setting for each Post Type.<br /><a href='http://semperplugins.com/documentation/noindex-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
351
  "google_disable_profile"=> Array(
352
  'name' => __( 'Disable Google Plus Profile:', 'all_in_one_seo_pack' ), 'default' => 0, 'type' => 'checkbox'
353
  ),
354
+ "google_connect"=>Array( 'name' => __( 'Connect With Google Analytics', 'all_in_one_seo_pack' ),
355
+ ),
356
  "google_analytics_id"=> Array(
357
  'name' => __( 'Google Analytics ID:', 'all_in_one_seo_pack' ),
358
  'default' => null, 'type' => 'text' ),
368
  'name' => __( 'Track Multiple Domains:', 'all_in_one_seo_pack' ),
369
  'default' => 0,
370
  'condshow' => Array( 'aiosp_google_analytics_id' => Array( 'lhs' => 'aiosp_google_analytics_id', 'op' => '!=', 'rhs' => '' ) ) ),
371
+ "ga_exclude_users"=> Array(
372
+ 'name' => __( 'Exclude Users From Tracking:', 'all_in_one_seo_pack' ),
373
+ 'type' => 'multicheckbox',
374
+ 'condshow' => Array( 'aiosp_google_analytics_id' => Array( 'lhs' => 'aiosp_google_analytics_id', 'op' => '!=', 'rhs' => '' ) ) ),
375
  "ga_track_outbound_links"=> Array(
376
  'name' => __( 'Track Outbound Links:', 'all_in_one_seo_pack' ),
377
  'default' => 0,
519
  'google' => Array(
520
  'name' => __( 'Google Settings', 'all_in_one_seo_pack' ),
521
  'help_link' => 'http://semperplugins.com/documentation/google-settings/',
522
+ 'options' => Array( "google_publisher", "google_disable_profile", "google_connect", "google_analytics_id", "ga_use_universal_analytics", "ga_domain", "ga_multi_domain", "ga_exclude_users", "ga_track_outbound_links" )
523
  ),
524
  'noindex' => Array(
525
  'name' => __( 'Noindex Settings', 'all_in_one_seo_pack' ),
704
  }
705
 
706
  function add_page_hooks() {
707
+ $this->oauth_init();
708
  $post_objs = get_post_types( '', 'objects' );
709
  $pt = array_keys( $post_objs );
710
  $rempost = array( 'revision', 'nav_menu_item' );
745
  $this->layout['cpt']['options'][] = $field;
746
  }
747
  }
748
+ global $wp_roles;
749
+ if ( ! isset( $wp_roles ) ) {
750
+ $wp_roles = new WP_Roles();
751
+ }
752
+ $role_names = $wp_roles->get_names();
753
+ ksort( $role_names );
754
+ $this->default_options["ga_exclude_users"]['initial_options'] = $role_names;
755
+
756
  $this->setting_options();
757
  add_filter( "{$this->prefix}display_options", Array( $this, 'filter_options' ), 10, 2 );
758
  parent::add_page_hooks();
759
  }
760
 
761
  function add_admin_pointers() {
762
+ $this->pointers['aioseop_menu_210'] = Array( 'pointer_target' => '#toplevel_page_all-in-one-seo-pack-aioseop_class',
763
  'pointer_text' => '<h3>' . sprintf( __( 'Welcome to Version %s!', 'all_in_one_seo_pack' ), AIOSEOP_VERSION )
764
  . '</h3><p>' . __( 'Thank you for running the latest and greatest All in One SEO Pack ever! Please review your settings, as we\'re always adding new features for you!', 'all_in_one_seo_pack' ) . '</p>',
765
  'pointer_edge' => 'top',
766
  'pointer_align' => 'left',
767
  'pointer_scope' => 'global'
768
  );
769
+ $this->pointers['aioseop_welcome_210'] = Array( 'pointer_target' => '#aioseop_top_button',
770
  'pointer_text' => '<h3>' . sprintf( __( 'Review Your Settings', 'all_in_one_seo_pack' ), AIOSEOP_VERSION )
771
+ . '</h3><p>' . __( 'Thank you for running the latest and greatest All in One SEO Pack ever! NEW: Manage how your site appears on Facebook, Google+, and Twitter with our Social Meta module. Enable it from the Feature Manager. Remember to review your settings, we have added some new ones!', 'all_in_one_seo_pack' ) . '</p>',
772
  'pointer_edge' => 'bottom',
773
  'pointer_align' => 'left',
774
  'pointer_scope' => 'local'
1395
  do_action( 'aioseop_modules_wp_head' );
1396
  echo "<!-- /all in one seo pack -->\n";
1397
  }
1398
+
1399
+ function override_options( $options, $location, $settings ) {
1400
+ $opts = Array();
1401
+ $options['aiosp_google_connect'] = $settings['aiosp_google_connect']['default'];
1402
+ return $options;
1403
+ }
1404
 
1405
+ function oauth_init() {
1406
+ if ( !is_user_logged_in() || !current_user_can( 'manage_options' ) ) return false;
1407
+ $this->token = "anonymous";
1408
+ $this->secret = "anonymous";
1409
+ $preload = $this->get_class_option();
1410
+ $manual_ua = '';
1411
+ if ( !empty( $_POST ) ) {
1412
+ if ( !empty( $_POST["{$this->prefix}google_connect"] ) ) {
1413
+ $manual_ua = 1;
1414
+ }
1415
+ } elseif ( !empty( $preload["{$this->prefix}google_connect"] ) ) {
1416
+ $manual_ua = 1;
1417
+ }
1418
+ if ( !empty( $manual_ua ) ) {
1419
+ foreach ( Array( "token", "secret", "access_token", "ga_token", "account_cache" ) as $v ) {
1420
+ if ( !empty( $preload["{$this->prefix}{$v}"]) ) {
1421
+ unset( $preload["{$this->prefix}{$v}"] );
1422
+ unset( $this->$v );
1423
+ }
1424
+ }
1425
+ $this->update_class_option( $preload );
1426
+ $this->update_options( );
1427
+ // return;
1428
+ }
1429
+ foreach ( Array( "token", "secret", "access_token", "ga_token", "account_cache" ) as $v ) {
1430
+ if ( !empty( $preload["{$this->prefix}{$v}"]) ) {
1431
+ $this->$v = $preload["{$this->prefix}{$v}"];
1432
+ }
1433
+ }
1434
+ $callback_url = NULL;
1435
+ if ( !empty( $_REQUEST['oauth_verifier'] ) ) {
1436
+ $this->verifier = $_REQUEST['oauth_verifier'];
1437
+ if ( !empty( $_REQUEST['oauth_token'] ) ) {
1438
+ if ( isset( $this->token ) && $this->token == $_REQUEST['oauth_token'] ) {
1439
+ $this->access_token = $this->oauth_get_token( $this->verifier );
1440
+ if ( is_array( $this->access_token ) && !empty( $this->access_token['oauth_token'] ) ) {
1441
+ unset( $this->token );
1442
+ unset( $this->secret );
1443
+ $this->ga_token = $this->access_token['oauth_token'];
1444
+ foreach ( Array( "token", "secret", "access_token", "ga_token" ) as $v ) {
1445
+ if ( !empty( $this->$v) ) $preload["{$this->prefix}{$v}"] = $this->$v;
1446
+ }
1447
+ $this->update_class_option( $preload );
1448
+ }
1449
+ }
1450
+ wp_redirect( menu_page_url( plugin_basename( $this->file ), false ) );
1451
+ exit;
1452
+ }
1453
+ }
1454
+ if ( !empty( $this->ga_token ) ) {
1455
+ if ( !empty( $this->account_cache ) ) {
1456
+ $ua = $this->account_cache['ua'];
1457
+ $profiles = $this->account_cache['profiles'];
1458
+ } else {
1459
+ $this->token = $this->access_token['oauth_token'];
1460
+ $this->secret = $this->access_token['oauth_token_secret'];
1461
+
1462
+ $data = $this->oauth_get_data('https://www.googleapis.com/analytics/v2.4/management/accounts/~all/webproperties/~all/profiles' );
1463
+ $http_code = wp_remote_retrieve_response_code( $data );
1464
+ if( $http_code == 200 ) {
1465
+ $response = wp_remote_retrieve_body( $data );
1466
+ $xml = $this->xml_string_to_array( $response );
1467
+ $ua = Array();
1468
+ $profiles = Array();
1469
+ if ( !empty( $xml["entry"] ) ) {
1470
+ $rec = Array();
1471
+ $results = Array();
1472
+ if ( !empty( $xml["entry"][0] ) )
1473
+ $results = $xml["entry"];
1474
+ else
1475
+ $results[] = $xml["entry"];
1476
+ foreach( $results as $r ) {
1477
+ foreach( $r as $k => $v )
1478
+ switch( $k ) {
1479
+ case 'id': $rec['id'] = $v; break;
1480
+ case 'title': $rec['title'] = $v['@content']; break;
1481
+ case 'dxp:property':
1482
+ $attr = Array();
1483
+ foreach ( $v as $a => $f )
1484
+ if ( is_array($f) && !empty($f['@attributes'] ) )
1485
+ $rec[$f['@attributes']['name']] = $f['@attributes']['value'];
1486
+ break;
1487
+ }
1488
+ $ua[$rec['title']] = Array( $rec['ga:webPropertyId'] => $rec['ga:webPropertyId'] );
1489
+ $profiles[ $rec['ga:webPropertyId'] ] = $rec['ga:profileId'];
1490
+ }
1491
+ }
1492
+ $this->account_cache = Array();
1493
+ $this->account_cache['ua'] = $ua;
1494
+ $this->account_cache['profiles'] = $profiles;
1495
+ $preload["{$this->prefix}account_cache"] = $this->account_cache;
1496
+ } else {
1497
+ unset( $this->token );
1498
+ unset( $this->secret );
1499
+ unset( $this->ga_token );
1500
+ unset( $preload["{$this->prefix}ga_token"] ); // error condition here -- pdb
1501
+ $response = wp_remote_retrieve_body( $data );
1502
+ $xml = $this->xml_string_to_array( $response );
1503
+ if ( !empty( $xml ) && !empty( $xml["error"] ) ) {
1504
+ $error = 'Error: ';
1505
+ if ( !empty( $xml["error"]["internalReason"] ) ) {
1506
+ $error .= $xml["error"]["internalReason"];
1507
+ } else {
1508
+ foreach( $xml["error"] as $k => $v )
1509
+ $error .= "$k: $v\n";
1510
+ }
1511
+ $this->output_error( $error );
1512
+ }
1513
+ }
1514
+ }
1515
+ }
1516
+ if ( !empty( $this->ga_token ) ) {
1517
+ $this->default_options["google_analytics_id"]['type'] = 'select';
1518
+ $this->default_options["google_analytics_id"]['initial_options'] = $ua;
1519
+ $this->default_options["google_connect"]["type"] = 'html';
1520
+ $this->default_options["google_connect"]["nolabel"] = 1;
1521
+ $this->default_options["google_connect"]["save"] = true;
1522
+ $this->default_options["google_connect"]["name"] = __( 'Disconnect From Google Analytics', 'all_in_one_seo_pack' );
1523
+ $this->default_options["google_connect"]["default"] = "<input name='aiosp_google_connect' type=submit class='button-primary' value='" . __( 'Remove Stored Credentials', 'all_in_one_seo_pack' ) . "'>";
1524
+ add_filter( $this->prefix . 'override_options', Array( $this, 'override_options' ), 10, 3 );
1525
+ } else {
1526
+ $this->default_options["google_connect"]["type"] = 'html';
1527
+ $this->default_options["google_connect"]["nolabel"] = 1;
1528
+ $this->default_options["google_connect"]["save"] = false;
1529
+ $url = $this->oauth_connect();
1530
+ $this->default_options["google_connect"]["default"] = "<a href='{$url}' class='button-primary'>" . __( 'Connect With Google Analytics', 'all_in_one_seo_pack' ) . "</a>";
1531
+ foreach ( Array( "token", "secret", "access_token", "ga_token", "account_cache" ) as $v ) {
1532
+ if ( !empty( $this->$v) ) $preload["{$this->prefix}{$v}"] = $this->$v;
1533
+ }
1534
+ }
1535
+ $this->update_class_option( $preload );
1536
+ $this->update_options( );
1537
+ // $url = $this->report_query();
1538
+ if ( !empty( $this->account_cache ) && !empty( $this->options["{$this->prefix}google_analytics_id"] ) && !empty( $this->account_cache["profiles"][ $this->options["{$this->prefix}google_analytics_id"] ] ) ) {
1539
+ $this->profile_id = $this->account_cache["profiles"][ $this->options["{$this->prefix}google_analytics_id"] ];
1540
+ }
1541
+ }
1542
 
1543
+ function oauth_get_data( $oauth_url, $args = null ) {
1544
+ if ( !class_exists( 'OAuthConsumer' ) ) require_once( 'OAuth.php' );
1545
+ if ( $args === null ) $args = Array( 'scope' => 'https://www.googleapis.com/auth/analytics.readonly', 'xoauth_displayname' => AIOSEOP_PLUGIN_NAME . ' ' . __('Google Analytics', 'all_in_one_seo_pack' ) );
1546
+ $req_token = new OAuthConsumer( $this->token, $this->secret );
1547
+ $req = $this->oauth_get_creds( $oauth_url, $req_token, $args );
1548
+ return wp_remote_get( $req->to_url() );
1549
+ }
1550
+
1551
+ function oauth_get_creds( $oauth_url, $req_token = NULL, $args = Array(), $callback = null ) {
1552
+ if ( !class_exists( 'OAuthConsumer' ) ) require_once( 'OAuth.php' );
1553
+ if ( !empty( $callback ) ) $args['oauth_callback'] = $callback;
1554
+ if ( empty( $this->sig_method ) ) $this->sig_method = new OAuthSignatureMethod_HMAC_SHA1();
1555
+ if ( empty( $this->consumer ) ) $this->consumer = new OAuthCOnsumer( 'anonymous', 'anonymous' );
1556
+ $req_req = OAuthRequest::from_consumer_and_token( $this->consumer, $req_token, "GET", $oauth_url, $args );
1557
+ $req_req->sign_request( $this->sig_method, $this->consumer, $req_token );
1558
+ return $req_req;
1559
+ }
1560
+
1561
+ function oauth_get_token( $oauth_verifier ) {
1562
+ if ( !class_exists( 'OAuthConsumer' ) ) require_once( 'OAuth.php' );
1563
+ $args = Array( 'scope' => 'https://www.google.com/analytics/feeds/', 'xoauth_displayname' => AIOSEOP_PLUGIN_NAME . ' ' . __('Google Analytics', 'all_in_one_seo_pack' ) );
1564
+ $args['oauth_verifier'] = $oauth_verifier;
1565
+ $oauth_access_token = "https://www.google.com/accounts/OAuthGetAccessToken";
1566
+ $reqData = $this->oauth_get_data( $oauth_access_token, $args );
1567
+ $reqOAuthData = OAuthUtil::parse_parameters( wp_remote_retrieve_body( $reqData ) );
1568
+ return $reqOAuthData;
1569
+ }
1570
+
1571
+ function oauth_connect( $count = 0 ) {
1572
+ global $aiosp_activation;
1573
+ if ( !class_exists( 'OAuthConsumer' ) ) require_once( 'OAuth.php' );
1574
+ $callback_url = NULL;
1575
+ $consumer_key = "anonymous";
1576
+ $consumer_secret = "anonymous";
1577
+ $oauth_request_token = "https://www.google.com/accounts/OAuthGetRequestToken";
1578
+ $oauth_authorize = "https://www.google.com/accounts/OAuthAuthorizeToken";
1579
+ $oauth_access_token = "https://www.google.com/accounts/OAuthGetAccessToken";
1580
+ if ( $aiosp_activation ) {
1581
+ $oauth_current = false;
1582
+ } else {
1583
+ $oauth_current = get_transient( "aioseop_oauth_current" );
1584
  }
1585
+ if ( !empty( $this->token ) && ( $this->token != 'anonymous' ) && $oauth_current ) {
1586
+ return $oauth_authorize . '?oauth_token=' . $this->token;
1587
+ } else {
1588
+ set_transient( "aioseop_oauth_current", 1, 3600 );
1589
+ unset( $this->token );
1590
+ unset( $this->secret );
1591
  }
1592
+ $args = array(
1593
+ 'scope' => 'https://www.google.com/analytics/feeds/',
1594
+ 'xoauth_displayname' => AIOSEOP_PLUGIN_NAME . ' ' . __('Google Analytics', 'all_in_one_seo_pack')
1595
+ );
1596
+ $req_req = $this->oauth_get_creds( $oauth_request_token, NULL, $args, admin_url( "admin.php?page=all-in-one-seo-pack/aioseop_class.php" ) );
1597
+ $reqData = wp_remote_get( $req_req->to_url() );
1598
+ $reqOAuthData = OAuthUtil::parse_parameters( wp_remote_retrieve_body( $reqData ) );
1599
+ if ( !empty( $reqOAuthData['oauth_token'] ) ) $this->token = $reqOAuthData['oauth_token'];
1600
+ if ( !empty( $reqOAuthData['oauth_token_secret'] ) ) $this->secret = $reqOAuthData['oauth_token_secret'];
1601
+ if ( !empty( $this->token ) && ( $this->token != 'anonymous' ) && ( $oauth_current ) ) {
1602
+ $url = $oauth_authorize . "?oauth_token={$this->token}";
1603
+ } else {
1604
+ if ( !$count ) {
1605
+ return $this->oauth_connect( 1 );
1606
+ }
1607
+ /*
1608
+ $req_token = new OAuthConsumer($this->token, $this->secret, 1);
1609
+ $req_req = $this->oauth_get_creds( $oauth_authorize, $req_token, $args );
1610
+ $url = $req_req->to_url();
1611
+ */
1612
+ }
1613
+ return $url;
1614
+ }
1615
+
1616
+ function get_analytics_domain() {
1617
+ global $aioseop_options;
1618
+ $domain = '';
1619
+ if ( !empty( $aioseop_options['aiosp_ga_domain'] ) ) {
1620
+ $domain = $aioseop_options['aiosp_ga_domain'];
1621
+ $domain = trim( $domain );
1622
+ $domain = $this->strtolower( $domain );
1623
+ if ( $this->strpos( $domain, "http://" ) === 0 ) $domain = $this->substr( $domain, 7 );
1624
+ elseif ( $this->strpos( $domain, "https://" ) === 0 ) $domain = $this->substr( $domain, 8 );
1625
+ $domain = untrailingslashit( $domain );
1626
  }
1627
+ return $domain;
1628
+ }
 
 
 
 
 
 
 
 
 
1629
 
1630
+ function universal_analytics() {
1631
+ global $aioseop_options;
1632
+ $analytics = '';
1633
+ if ( !empty( $aioseop_options['aiosp_ga_use_universal_analytics'] ) ) {
1634
+ $allow_linker = '';
1635
+ $cookie_domain = $this->get_analytics_domain();
1636
+ if ( !empty( $cookie_domain ) ) {
1637
+ $cookie_domain = esc_js( $cookie_domain );
1638
+ $cookie_domain = "'cookieDomain': '{$cookie_domain}'";
1639
+ }
1640
+ if ( !empty( $aioseop_options['aiosp_ga_multi_domain'] ) ) {
1641
+ $allow_linker = "'allowLinker': true";
1642
+ }
1643
+ $js_options = Array();
1644
+ foreach( Array( 'cookie_domain', 'allow_linker' ) as $opts ) {
1645
+ if ( !empty( $$opts ) ) $js_options[] = $$opts;
1646
+ }
1647
+ if ( !empty( $js_options ) ) {
1648
+ $js_options = join( ',', $js_options );
1649
+ $js_options = ', { ' . $js_options . ' } ';
1650
+ } else $js_options = '';
1651
+ $analytics_id = esc_js( $aioseop_options["aiosp_google_analytics_id"] );
1652
+ $analytics =<<<EOF
1653
+ <script>
1654
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
1655
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
1656
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
1657
+ })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
1658
+
1659
+ ga('create', '{$analytics_id}'{$js_options});
1660
+ ga('send', 'pageview');
1661
+ </script>
1662
 
1663
  EOF;
1664
+ }
1665
+ return $analytics;
1666
  }
 
 
1667
 
1668
  function aiosp_google_analytics() {
1669
  global $aioseop_options;
1670
  $analytics = '';
1671
+ if ( !empty( $aioseop_options['aiosp_ga_exclude_users'] ) ) {
1672
+ if ( is_user_logged_in() ) {
1673
+ global $current_user;
1674
+ if ( empty( $current_user ) ) get_currentuserinfo();
1675
+ if ( !empty( $current_user ) ) {
1676
+ $intersect = array_intersect( $aioseop_options['aiosp_ga_exclude_users'], $current_user->roles );
1677
+ if ( !empty( $intersect ) ) return;
1678
+ }
1679
+ }
1680
+ }
1681
  if ( !empty( $aioseop_options['aiosp_google_analytics_id'] ) ) {
1682
  ob_start();
1683
  $analytics = $this->universal_analytics();
2087
  }
2088
  if (empty( $title ) )
2089
  $title = $this->internationalize( get_option( 'blogname' ) ) . ' | ' . $this->internationalize( get_bloginfo( 'description' ) );
 
2090
  return $this->paged_title( $title );
2091
  } else if ( is_attachment() ) {
2092
  if ( $post === null ) return false;
2525
  $this->update_options( );
2526
 
2527
  $this->add_admin_pointers();
2528
+ if ( !empty( $this->pointers ) )
2529
+ foreach( $this->pointers as $k => $p )
2530
+ if ( !empty( $p["pointer_scope"] ) && ( $p["pointer_scope"] == 'global' ) )
2531
+ unset( $this->pointers[$k] );
2532
 
2533
  $donated = false;
2534
  if ( ( isset( $_POST ) ) && ( isset( $_POST['module'] ) ) && ( isset( $_POST['nonce-aioseop'] ) ) && ( $_POST['module'] == 'All_in_One_SEO_Pack' ) && ( wp_verify_nonce( $_POST['nonce-aioseop'], 'aioseop-nonce' ) ) ) {
2697
  // close postboxes that should be closed
2698
  $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
2699
  // postboxes setup
2700
+ if ( typeof postboxes !== 'undefined' )
2701
+ postboxes.add_postbox_toggles('<?php echo $this->pagehook; ?>');
2702
  $('.meta-box-sortables').removeClass('meta-box-sortables');
2703
  });
2704
  //]]>
2705
  </script>
2706
+ <a href="http://open.ecwid.com/l8dt" target="_blank" style="margin-bottom: 15px;display: block;"><img src="<?php echo AIOSEOP_PLUGIN_IMAGES_URL; ?>ecwid_banner.png"></a>
2707
  <!-- Headway Themes-->
2708
+ <div class="aioseop_advert">
2709
  <div>
2710
  <h3>Drag and Drop WordPress Design</h3>
2711
  <p><a href="http://semperfiwebdesign.com/headwayaio/" target="_blank">Headway Themes</a> allows you to easily create your own stunning website designs! Stop using premade themes start making your own design with Headway's easy to use Drag and Drop interface. All in One SEO Pack users have an exclusive discount by using coupon code <strong>SEMPERFI30</strong> at checkout.</p>
aioseop_feature_manager.php CHANGED
@@ -16,13 +16,15 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Feature_Manager' ) ) {
16
  $this->file = __FILE__; // the current file
17
  parent::__construct();
18
  $this->module_info = Array(
19
- 'sitemap' => Array( 'name' => __( 'XML Sitemaps', 'all_in_one_seo_pack' ),
20
  'description' => __( 'Create and manage your XML Sitemaps using this feature and submit your XML Sitemap to Google, Bing/Yahoo and Ask.com.', 'all_in_one_seo_pack' ) ),
 
 
21
  'performance' => Array( 'name' => __( 'Performance', 'all_in_one_seo_pack' ),
22
  'description' => __( 'Optimize performance related to SEO and check your system status.', 'all_in_one_seo_pack' ),
23
  'default' => 'on' ),
24
  'coming_soon' => Array( 'name' => __( 'Coming Soon...', 'all_in_one_seo_pack' ),
25
- 'description' => __( 'Social Meta', 'all_in_one_seo_pack' ),
26
  'save' => false ) );
27
 
28
  // Set up default settings fields
16
  $this->file = __FILE__; // the current file
17
  parent::__construct();
18
  $this->module_info = Array(
19
+ 'sitemap' => Array( 'name' => __( 'XML Sitemaps', 'all_in_one_seo_pack' ),
20
  'description' => __( 'Create and manage your XML Sitemaps using this feature and submit your XML Sitemap to Google, Bing/Yahoo and Ask.com.', 'all_in_one_seo_pack' ) ),
21
+ 'opengraph' => Array( 'name' => __( 'Social Meta', 'all_in_one_seo_pack' ),
22
+ 'description' => __( 'Activate this feature to add Social Meta data to your site to deliver closer integration between your website/blog and Facebook, Twitter, and Google+.', 'all_in_one_seo_pack' ) ),
23
  'performance' => Array( 'name' => __( 'Performance', 'all_in_one_seo_pack' ),
24
  'description' => __( 'Optimize performance related to SEO and check your system status.', 'all_in_one_seo_pack' ),
25
  'default' => 'on' ),
26
  'coming_soon' => Array( 'name' => __( 'Coming Soon...', 'all_in_one_seo_pack' ),
27
+ 'description' => __( 'File Editor', 'all_in_one_seo_pack' ),
28
  'save' => false ) );
29
 
30
  // Set up default settings fields
aioseop_functions.php CHANGED
@@ -21,6 +21,7 @@ if ( !function_exists( 'aioseop_activate' ) ) {
21
  function aioseop_activate() {
22
  global $aiosp_activation;
23
  $aiosp_activation = true;
 
24
  }
25
  }
26
 
@@ -277,6 +278,89 @@ if ( !function_exists( 'aioseop_ajax_delete_url' ) ) {
277
  }
278
  }
279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  if (!function_exists('aioseop_ajax_save_settings')) {
281
  function aioseop_ajax_save_settings() {
282
  aioseop_ajax_init();
21
  function aioseop_activate() {
22
  global $aiosp_activation;
23
  $aiosp_activation = true;
24
+ delete_transient( "aioseop_oauth_current" );
25
  }
26
  }
27
 
278
  }
279
  }
280
 
281
+ if ( !function_exists( 'aioseop_ajax_scan_header' ) ) {
282
+
283
+ function aioseop_ajax_scan_header() {
284
+ $_POST["options"] = "foo";
285
+ aioseop_ajax_init();
286
+ $options = Array();
287
+ parse_str( $_POST['options'], $options );
288
+ foreach( $options as $k => $v ) $_POST[$k] = $v;
289
+ $_POST['action'] = 'aiosp_update_module';
290
+ $_POST['location'] = null;
291
+ $_POST['Submit'] = 'ajax';
292
+ ob_start();
293
+ do_action('wp');
294
+ global $aioseop_modules;
295
+ $module = $aioseop_modules->return_module( "All_in_One_SEO_Pack_Opengraph" );
296
+ if ( !empty( $module ) )
297
+ if ( $module->option_isset( 'disable_jetpack' ) )
298
+ remove_action( 'wp_head', 'jetpack_og_tags' );
299
+ wp_head();
300
+ $output = ob_get_clean();
301
+ global $aiosp;
302
+ $output = $aiosp->html_string_to_array( $output );
303
+ $meta = '';
304
+ $metatags = Array(
305
+ 'facebook' => Array( 'name' => 'property', 'value' => 'content' ),
306
+ 'twitter' => Array( 'name' => 'name', 'value' => 'value' ),
307
+ 'google+' => Array( 'name' => 'itemprop', 'value' => 'content' )
308
+ );
309
+ $metadata = Array(
310
+ 'facebook' => Array(
311
+ 'title' => 'og:title',
312
+ 'type' => 'og:type',
313
+ 'url' => 'og:url',
314
+ 'thumbnail' => 'og:image',
315
+ 'sitename' => 'og:site_name',
316
+ 'key' => 'fb:admins',
317
+ 'description' => 'og:description'
318
+ ),
319
+ 'google+' => Array(
320
+ 'thumbnail' => 'image',
321
+ 'title' => 'name',
322
+ 'description' => 'description'
323
+ ),
324
+ 'twitter' => Array(
325
+ 'card' => 'twitter:card',
326
+ 'url' => 'twitter:url',
327
+ 'title' => 'twitter:title',
328
+ 'description' => 'twitter:description',
329
+ 'thumbnail' => 'twitter:image'
330
+ )
331
+ );
332
+ if ( !empty( $output ) && !empty( $output['head'] ) && !empty( $output['head']['meta'] ) )
333
+ foreach( $output['head']['meta'] as $v )
334
+ if ( !empty( $v['@attributes'] ) ) {
335
+ $m = $v['@attributes'];
336
+ foreach( $metatags as $type => $tags )
337
+ if ( !empty( $m[$tags['name']] ) && !empty( $m[$tags['value']] ) )
338
+ foreach( $metadata[$type] as $tk => $tv )
339
+ if ( $m[$tags['name']] == $tv )
340
+ $meta .= "<tr><th style='color:red;'>" . sprintf( __( 'Duplicate %s Meta'), ucwords( $type ) ) . "</th><td>" . ucwords( $tk ) . "</td><td>{$m[$tags['name']]}</td><td>{$m[$tags['value']]}</td></tr>\n";
341
+ }
342
+ if ( empty( $meta ) ) $meta = '<span style="color:green;">' . __( 'No duplicate meta tags found.', 'all_in_one_seo_pack' ) . '</span>';
343
+ else {
344
+ $meta = "<table cellspacing=0 cellpadding=0 width=80% class='aioseop_table'><tr class='aioseop_table_header'><th>Meta For Site</th><th>Kind of Meta</th><th>Element Name</th><th>Element Value</th></tr>" . $meta . "</table>";
345
+ $meta .= "<p><div class='aioseop_meta_info'><h3 style='padding:5px;margin-bottom:0px;'>" . __( 'What Does This Mean?', 'all_in_one_seo_pack' ) . "</h3><div style='padding:5px;padding-top:0px;'>"
346
+ . "<p>" . __( 'All in One SEO Pack has detected that a plugin(s) or theme is also outputting social meta tags on your site.  You can view this social meta in the source code of your site (check your browser help for instructions on how to view source code).', 'all_in_one_seo_pack' )
347
+ . "</p><p>" . __( 'You may prefer to use the social meta tags that are being output by the other plugin(s) or theme.  If so, then you should deactivate this Social Meta feature in All in One SEO Pack Feature Manager.', 'all_in_one_seo_pack' )
348
+ . "</p><p>" . __( 'You should avoid duplicate social meta tags.  You can use these free tools from Facebook, Google and Twitter to validate your social meta and check for errors:', 'all_in_one_seo_pack' ) . "</p>";
349
+
350
+ foreach( Array( 'https://developers.facebook.com/tools/debug', 'http://www.google.com/webmasters/tools/richsnippets', 'https://dev.twitter.com/docs/cards/validation/validator' ) as $link ) {
351
+ $meta .= "<a href='{$link}' target='_blank'>{$link}</a><br />";
352
+ }
353
+ $meta .= "<p>" . __( 'Please refer to the document for each tool for help in using these to debug your social meta.', 'all_in_one_seo_pack' ) . "</div></div>";
354
+ }
355
+ $output = $meta;
356
+ $output = str_replace( "'", "\'", $output );
357
+ $output = str_replace( "\n", '\n', $output );
358
+ // $output = str_replace( "<", '&lt;', $output );
359
+ // $output = str_replace( ">", '&gt;', $output );
360
+ die( sprintf( AIOSEOP_AJAX_MSG_TMPL, $output ) );
361
+ }
362
+ }
363
+
364
  if (!function_exists('aioseop_ajax_save_settings')) {
365
  function aioseop_ajax_save_settings() {
366
  aioseop_ajax_init();
aioseop_module.css CHANGED
@@ -45,7 +45,7 @@
45
  text-align: left;
46
  }
47
  .aioseop_option_div {
48
- max-height: 150px;
49
  min-height: 34px;
50
  width: 95%;
51
  overflow-y: auto;
@@ -233,12 +233,6 @@
233
  background-color: #EEE;
234
  margin: 5px 0 5px 0 !important;
235
  }
236
- .aioseop input[type="button"] {
237
- border-radius: 5px;
238
- padding: 10px;
239
- font-size: 15px;
240
- }
241
-
242
  .aioseop_settings_left {
243
  float: left;
244
  padding: 0px;
@@ -292,6 +286,7 @@ div#aiosp_feature_manager_metabox .inside {
292
  div.aioseop_feature {
293
  position: relative;
294
  display: inline-block;
 
295
  vertical-align: top;
296
  width: 240px;
297
  height: 288px;
@@ -359,6 +354,12 @@ div.aioseop_feature#aioseop_sitemap .aioseop_featured_image {
359
  div.aioseop_feature#aioseop_sitemap .aioseop_featured_image.active {
360
  background-image: url(images/XMLSitemaps-Color-Standard.png);
361
  }
 
 
 
 
 
 
362
  div.aioseop_feature#aioseop_performance .aioseop_featured_image {
363
  background-image: url(images/Performance-BW-Standard.png);
364
  }
@@ -404,6 +405,24 @@ only screen and ( min-resolution: 1.5dppx) {
404
  div.aioseop_feature .aioseop_featured_image {
405
  background-image: url(images/Default-BW-Retina.png);
406
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
407
  div.aioseop_feature#aioseop_performance .aioseop_featured_image {
408
  background-image: url(images/Performance-BW-Retina.png);
409
  }
@@ -507,6 +526,54 @@ div#aioseop_snippet > div > span {
507
  table.aioseop_table tr:nth-child(odd) {
508
  background-color: #EEE;
509
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
510
  .aioseop_top_label .aioseop_option_input,
511
  .aioseop_no_label .aioseop_option_input {
512
  width: 100%;
@@ -553,7 +620,19 @@ table.aioseop_table tr:nth-child(odd) {
553
  padding: 5px 0px;
554
  margin: 0px 477px 15px 0px !important;
555
  }
556
-
 
 
 
 
 
 
 
 
 
 
 
 
557
  .aioseop_input input[type="checkbox"],
558
  .aioseop_input input[type="radio"] {
559
  vertical-align: text-bottom;
@@ -594,6 +673,9 @@ table.aioseop_table tr:nth-child(odd) {
594
  .aioseop_sidebar #side-sortables {
595
  width: 98%;
596
  }
 
 
 
597
  .aioseop_tabs {
598
  padding-top: 6px;
599
  }
45
  text-align: left;
46
  }
47
  .aioseop_option_div {
48
+ max-height: 160px;
49
  min-height: 34px;
50
  width: 95%;
51
  overflow-y: auto;
233
  background-color: #EEE;
234
  margin: 5px 0 5px 0 !important;
235
  }
 
 
 
 
 
 
236
  .aioseop_settings_left {
237
  float: left;
238
  padding: 0px;
286
  div.aioseop_feature {
287
  position: relative;
288
  display: inline-block;
289
+ float: left;
290
  vertical-align: top;
291
  width: 240px;
292
  height: 288px;
354
  div.aioseop_feature#aioseop_sitemap .aioseop_featured_image.active {
355
  background-image: url(images/XMLSitemaps-Color-Standard.png);
356
  }
357
+ div.aioseop_feature#aioseop_opengraph .aioseop_featured_image {
358
+ background-image: url(images/SocialMeta-BW-Standard.png);
359
+ }
360
+ div.aioseop_feature#aioseop_opengraph .aioseop_featured_image.active {
361
+ background-image: url(images/SocialMeta-Color-Standard.png);
362
+ }
363
  div.aioseop_feature#aioseop_performance .aioseop_featured_image {
364
  background-image: url(images/Performance-BW-Standard.png);
365
  }
405
  div.aioseop_feature .aioseop_featured_image {
406
  background-image: url(images/Default-BW-Retina.png);
407
  }
408
+ div.aioseop_feature#aioseop_sitemap .aioseop_featured_image {
409
+ background-image: url(images/XMLSitemaps-BW-Retina.png);
410
+ }
411
+ div.aioseop_feature#aioseop_sitemap .aioseop_featured_image.active {
412
+ background-image: url(images/XMLSitemaps-Color-Retina.png);
413
+ }
414
+ div.aioseop_feature#aioseop_opengraph .aioseop_featured_image {
415
+ background-image: url(images/SocialMeta-BW-Retina.png);
416
+ }
417
+ div.aioseop_feature#aioseop_opengraph .aioseop_featured_image.active {
418
+ background-image: url(images/SocialMeta-Color-Retina.png);
419
+ }
420
+ div.aioseop_feature#aioseop_importer_exporter .aioseop_featured_image {
421
+ background-image: url(images/ImporterExporter-BW-Retina.png);
422
+ }
423
+ div.aioseop_feature#aioseop_importer_exporter .aioseop_featured_image.active {
424
+ background-image: url(images/ImporterExporter-Color-Retina.png);
425
+ }
426
  div.aioseop_feature#aioseop_performance .aioseop_featured_image {
427
  background-image: url(images/Performance-BW-Retina.png);
428
  }
526
  table.aioseop_table tr:nth-child(odd) {
527
  background-color: #EEE;
528
  }
529
+ .All_in_One_SEO_Pack_Opengraph table.aioseop_table tr:nth-child(odd) {
530
+ background-color: rgba( 238, 238, 238, 0.5 );
531
+ }
532
+ table.aioseop_table td {
533
+ width: 23%;
534
+ }
535
+ .All_in_One_SEO_Pack_Opengraph table.aioseop_table {
536
+ width: 80%;
537
+ max-width: 800px;
538
+ display: block;
539
+ border-top: 1px solid #dfdfdf;
540
+ border-left: 1px solid #dfdfdf;
541
+ }
542
+ .All_in_One_SEO_Pack_Opengraph table.aioseop_table th {
543
+ width: 18%;
544
+ border-right: 1px solid #dfdfdf;
545
+ border-bottom: 1px solid #dfdfdf;
546
+ }
547
+ .All_in_One_SEO_Pack_Opengraph div.aioseop_meta_info {
548
+ margin-top:10px;
549
+ border: 1px solid #dfdfdf;
550
+ width:80%;
551
+ max-width:800px;
552
+ }
553
+ .All_in_One_SEO_Pack_Opengraph table.aioseop_table tr.aioseop_table_header th {
554
+ background: #f1f1f1;
555
+ background-image: -webkit-gradient(linear,left bottom,left top,from(#ececec),to(#f9f9f9));
556
+ background-image: -webkit-linear-gradient(bottom,#ececec,#f9f9f9);
557
+ background-image: -moz-linear-gradient(bottom,#ececec,#f9f9f9);
558
+ background-image: -o-linear-gradient(bottom,#ececec,#f9f9f9);
559
+ background-image: linear-gradient(to top,#ececec,#f9f9f9);
560
+ padding: 5px;
561
+ border-bottom-color: #dfdfdf;
562
+ text-shadow: #fff 0 1px 0;
563
+ -webkit-box-shadow: 0 1px 0 #fff;
564
+ box-shadow: 0 1px 0 #fff;
565
+ }
566
+ .All_in_One_SEO_Pack_Opengraph table.aioseop_table td {
567
+ border-right: 1px solid #dfdfdf;
568
+ border-bottom: 1px solid #dfdfdf;
569
+ }
570
+ #aiosp_sitemap_addl_pages_metabox table.aioseop_table td {
571
+ width: 25%;
572
+ padding-left: 5%;
573
+ }
574
+ table.aioseop_table td, table.aioseop_table th {
575
+ padding: 3px;
576
+ }
577
  .aioseop_top_label .aioseop_option_input,
578
  .aioseop_no_label .aioseop_option_input {
579
  width: 100%;
620
  padding: 5px 0px;
621
  margin: 0px 477px 15px 0px !important;
622
  }
623
+ #aioseop_opengraph_settings .inside {
624
+ margin: 0;
625
+ padding: 0;
626
+ }
627
+ #aioseop_opengraph_settings_image_wrapper img {
628
+ width: auto;
629
+ height: 75px;
630
+ }
631
+ #aioseop_opengraph_settings_image_wrapper .aioseop_option_setting_label {
632
+ max-width: 160px;
633
+ min-width: 100px;
634
+ width: 30%;
635
+ }
636
  .aioseop_input input[type="checkbox"],
637
  .aioseop_input input[type="radio"] {
638
  vertical-align: text-bottom;
673
  .aioseop_sidebar #side-sortables {
674
  width: 98%;
675
  }
676
+ #aioseop_opengraph_settings .aioseop_option_label {
677
+ width: 30%;
678
+ }
679
  .aioseop_tabs {
680
  padding-top: 6px;
681
  }
aioseop_module.js CHANGED
@@ -220,6 +220,27 @@ function aioseop_overflow_border( el ) {
220
  }
221
 
222
  jQuery(document).ready(function() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  if ( typeof aioseop_data.pointers != 'undefined' ) {
224
  jQuery.each(aioseop_data.pointers, function(index, value) {
225
  if ( value != 'undefined' && value.pointer_text != '' ) {
220
  }
221
 
222
  jQuery(document).ready(function() {
223
+ jQuery("#poststuff .aioseop_radio_type input[type='radio']").on( 'click', function() {
224
+ var previousValue = jQuery(this).attr('previousValue');
225
+ var name = jQuery(this).attr('name');
226
+ if ( typeof previousValue == 'undefined' ) {
227
+ if ( jQuery(this).prop( "checked" ) ) {
228
+ jQuery(this).prop( 'checked', true );
229
+ jQuery(this).attr('previousValue', 'checked' );
230
+ } else {
231
+ jQuery(this).prop( 'checked', false );
232
+ jQuery(this).attr('previousValue', false );
233
+ }
234
+ return;
235
+ }
236
+ if (previousValue == 'checked') {
237
+ jQuery(this).prop('checked', false);
238
+ jQuery(this).attr('previousValue', false);
239
+ } else {
240
+ jQuery("input[name="+name+"]:radio").attr('previousValue', false);
241
+ jQuery(this).attr('previousValue', 'checked');
242
+ }
243
+ });
244
  if ( typeof aioseop_data.pointers != 'undefined' ) {
245
  jQuery.each(aioseop_data.pointers, function(index, value) {
246
  if ( value != 'undefined' && value.pointer_text != '' ) {
aioseop_opengraph.php ADDED
@@ -0,0 +1,707 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package All-in-One-SEO-Pack
4
+ */
5
+ /**
6
+ * The Opengraph class.
7
+ */
8
+ if ( !class_exists( 'All_in_One_SEO_Pack_Opengraph' ) ) {
9
+ class All_in_One_SEO_Pack_Opengraph extends All_in_One_SEO_Pack_Module {
10
+ var $fb_object_types;
11
+
12
+ function All_in_One_SEO_Pack_Opengraph( ) {
13
+ $this->name = __('Social Meta', 'all_in_one_seo_pack'); // Human-readable name of the plugin
14
+ $this->prefix = 'aiosp_opengraph_'; // option prefix
15
+ $this->file = __FILE__; // the current file
16
+ $this->fb_object_types = Array(
17
+ 'Activities' => Array(
18
+ 'activity' => __( 'Activity', 'all_in_one_seo_pack' ),
19
+ 'sport' => __( 'Sport', 'all_in_one_seo_pack' )
20
+ ),
21
+ 'Businesses' => Array(
22
+ 'bar' => __( 'Bar', 'all_in_one_seo_pack' ),
23
+ 'company' => __( 'Company', 'all_in_one_seo_pack' ),
24
+ 'cafe' => __( 'Cafe', 'all_in_one_seo_pack' ),
25
+ 'hotel' => __( 'Hotel', 'all_in_one_seo_pack' ),
26
+ 'restaurant' => __( 'Restaurant', 'all_in_one_seo_pack' )
27
+ ),
28
+ 'Groups' => Array(
29
+ 'cause' => __( 'Cause', 'all_in_one_seo_pack' ),
30
+ 'sports_league' => __( 'Sports League', 'all_in_one_seo_pack' ),
31
+ 'sports_team' => __( 'Sports Team', 'all_in_one_seo_pack' )
32
+ ),
33
+ 'Organizations' => Array(
34
+ 'band' => __( 'Band', 'all_in_one_seo_pack' ),
35
+ 'government' => __( 'Government', 'all_in_one_seo_pack' ),
36
+ 'non_profit' => __( 'Non Profit', 'all_in_one_seo_pack' ),
37
+ 'school' => __( 'School', 'all_in_one_seo_pack' ),
38
+ 'university' => __( 'University', 'all_in_one_seo_pack' )
39
+ ),
40
+ 'People' => Array(
41
+ 'actor' => __( 'Actor', 'all_in_one_seo_pack' ),
42
+ 'athlete' => __( 'Athlete', 'all_in_one_seo_pack' ),
43
+ 'author' => __( 'Author', 'all_in_one_seo_pack' ),
44
+ 'director' => __( 'Director', 'all_in_one_seo_pack' ),
45
+ 'musician' => __( 'Musician', 'all_in_one_seo_pack' ),
46
+ 'politician' => __( 'Politician', 'all_in_one_seo_pack' ),
47
+ 'profile' => __( 'Profile', 'all_in_one_seo_pack' ),
48
+ 'public_figure' => __( 'Public Figure', 'all_in_one_seo_pack' )
49
+ ),
50
+ 'Places' => Array(
51
+ 'city' => __( 'City', 'all_in_one_seo_pack' ),
52
+ 'country' => __( 'Country', 'all_in_one_seo_pack' ),
53
+ 'landmark' => __( 'Landmark', 'all_in_one_seo_pack' ),
54
+ 'state_province' => __( 'State Province', 'all_in_one_seo_pack' )
55
+ ),
56
+ 'Products and Entertainment' => Array(
57
+ 'album' => __( 'Album', 'all_in_one_seo_pack' ),
58
+ 'book' => __( 'Book', 'all_in_one_seo_pack' ),
59
+ 'drink' => __( 'Drink', 'all_in_one_seo_pack' ),
60
+ 'food' => __( 'Food', 'all_in_one_seo_pack' ),
61
+ 'game' => __( 'Game', 'all_in_one_seo_pack' ),
62
+ 'movie' => __( 'Movie', 'all_in_one_seo_pack' ),
63
+ 'product' => __( 'Product', 'all_in_one_seo_pack' ),
64
+ 'song' => __( 'Song', 'all_in_one_seo_pack' ),
65
+ 'tv_show' => __( 'TV Show', 'all_in_one_seo_pack' )
66
+ ),'Websites' => Array(
67
+ 'article' => __( 'Article', 'all_in_one_seo_pack' ),
68
+ 'blog' => __( 'Blog', 'all_in_one_seo_pack' ),
69
+ 'website' => __( 'Website', 'all_in_one_seo_pack' )
70
+ )
71
+ );
72
+ parent::__construct();
73
+ $categories = Array( 'blog' => 'blog', 'website' => 'website' );
74
+
75
+ $help_text = Array(
76
+ "setmeta" => __( "Checking this box will use the Home Title and Home Description set in All in One SEO Pack, General Settings as the Open Graph title and description for your home page.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
77
+ "key" => __( "Your Profile Admin ID is your Facebook profile ID. You can find out your Facebook ID using the lookup tool here: https://graph.facebook.com/yourusername<br />NOTE: Replace 'yourusername' with your Facebook profile name.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
78
+ "sitename" => __( "The Site Name is the name that is used to identify your website.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
79
+ "hometitle" => __( "The Home Title is the Open Graph title for your home page.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
80
+ "description" => __( "The Home Description is the Open Graph description for your home page.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
81
+ "generate_descriptions" => __( "Check this and your Open Graph descriptions will be auto-generated from your excerpt or content.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
82
+ "disable_jetpack" => __( "Check this box to disable the Open Graph meta output by the Jetpack plugin.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
83
+ "defimg" => __( "This option lets you choose which image will be displayed by default for the Open Graph image. You may override this on individual posts.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
84
+ "dimg" => __( "This option sets a default image that can be used for the Open Graph image. You can upload an image, select an image from your Media Library or paste the URL of an image here.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
85
+ "meta_key" => __( "Enter the name of a custom field (or multiple field names separated by commas) to use that field to specify the Open Graph image on Pages or Posts.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
86
+ "categories" => __( "Set the Open Graph type for your website as either a blog or a website.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
87
+ "image" => __( "This option lets you select the Open Graph image that will be used for this Page or Post, overriding the default settings.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
88
+ "customimg" => __( "This option lets you upload an image to use as the Open Graph image for this Page or Post.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
89
+ "imagewidth" => __( "Enter the width for your Open Graph image in pixels (i.e. 600).<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
90
+ "imageheight" => __( "Enter the height for your Open Graph image in pixels (i.e. 600).<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
91
+ "types" => __( "Select which Post Types you want to use All in One SEO Pack to set Open Graph meta values for.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
92
+ "title" => __( "This is the Open Graph title of this Page or Post.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
93
+ "desc" => __( "This is the Open Graph description of this Page or Post.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
94
+ "category" => __( "Select the Open Graph type that best describes the content of this Page or Post.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' )
95
+ );
96
+ $count_desc = __( " characters. Open Graph allows up to a maximum of %s chars for the %s.", 'all_in_one_seo_pack' );
97
+ $this->default_options = array(
98
+ 'scan_header'=> Array( 'name' => __( 'Scan Header', 'all_in_one_seo_pack' ), 'type' => 'custom', 'save' => true ),
99
+ 'setmeta' => Array( 'name' => __( 'Use AIOSEO Title and Description', 'all_in_one_seo_pack'), 'type' => 'checkbox' ),
100
+ 'key' => Array( 'name' => __( 'Profile Admins ID', 'all_in_one_seo_pack'), 'default' => '', 'type' => 'text' ),
101
+ 'sitename' => Array( 'name' => __( 'Site Name', 'all_in_one_seo_pack' ), 'default' => get_bloginfo('name'), 'type' => 'text' ),
102
+ 'hometitle' => Array( 'name' => __( 'Home Title', 'all_in_one_seo_pack'),
103
+ 'default' => '', 'type' => 'textarea', 'condshow' => Array( 'aiosp_opengraph_setmeta' => Array( 'lhs' => "aiosp_opengraph_setmeta", 'op' => '!=', 'rhs' => 'on' ) ) ),
104
+ 'description' => Array( 'name' => __( 'Home Description', 'all_in_one_seo_pack'),
105
+ 'default' => '', 'type' => 'textarea', 'condshow' => Array( 'aiosp_opengraph_setmeta' => Array( 'lhs' => "aiosp_opengraph_setmeta", 'op' => '!=', 'rhs' => 'on' ) ) ),
106
+ 'generate_descriptions' => Array( 'name' => __( 'Autogenerate OG Descriptions', 'all_in_one_seo_pack' ), 'default' => 1 ),
107
+ 'disable_jetpack' => Array( 'name' => __( 'Disable Jetpack Tags', 'all_in_one_seo_pack' ), 'default' => 0 ),
108
+ 'defimg' => Array( 'name' => __( 'Select OG:Image Source', 'all_in_one_seo_pack' ), 'type' => 'select', 'initial_options' => Array( '' => __( 'Default Image' ), 'featured' => __( 'Featured Image' ), 'attach' => __( 'First Attached Image' ), 'content' => __( 'First Image In Content' ), 'custom' => __( 'Image From Custom Field' ), 'auto' => __( 'First Available Image' ) ) ),
109
+ 'dimg' => Array( 'name' => __( 'Default OG:Image', 'all_in_one_seo_pack' ), 'default' => AIOSEOP_PLUGIN_IMAGES_URL . 'default-user-image.png', 'type' => 'image' ),
110
+ 'meta_key' => Array( 'name' => __( 'Use Custom Field For Image', 'all_in_one_seo_pack' ), 'type' => 'text', 'default' => '' ),
111
+ 'categories' => Array( 'name' => __( 'Facebook Object Type', 'all_in_one_seo_pack'),
112
+ 'type' => 'radio', 'initial_options' => $categories, 'default' => 'blog' ),
113
+ 'image' => Array( 'name' => __( 'Image', 'all_in_one_seo_pack' ),
114
+ 'type' => 'radio', 'initial_options' => Array( 0 => '<img style="width:50px;height:auto;display:inline-block;vertical-align:bottom;" src="' . AIOSEOP_PLUGIN_IMAGES_URL . 'default-user-image.png' . '">' ) ),
115
+ 'customimg' => Array( 'name' => __( 'Custom Image', 'all_in_one_seo_pack' ),
116
+ 'type' => 'image' ),
117
+ 'imagewidth' => Array( 'name' => __( 'Specify Image Width', 'all_in_one_seo_pack' ),
118
+ 'type' => 'text', 'default' => '' ),
119
+ 'imageheight' => Array( 'name' => __( 'Specify Image Height', 'all_in_one_seo_pack' ),
120
+ 'type' => 'text', 'default' => '' ),
121
+ 'types' => Array( 'name' => __( 'Enable Facebook Meta for', 'all_in_one_seo_pack'),
122
+ 'type' => 'multicheckbox', 'initial_options' => $this->get_post_type_titles( Array( '_builtin' => false ) ),
123
+ 'default' => Array( 'post' => 'post', 'page' => 'page' ) ),
124
+ 'title' => Array( 'name' => __( 'Title', 'all_in_one_seo_pack'),
125
+ 'default' => '', 'type' => 'text', 'size' => 95, 'count' => 1, 'count_desc' => $count_desc ),
126
+ 'desc' => Array( 'name' => __( 'Description', 'all_in_one_seo_pack'),
127
+ 'default' => '', 'type' => 'textarea', 'cols' => 250, 'rows' => 4, 'count' => 1, 'count_desc' => $count_desc ),
128
+ 'category' => Array( 'name' => __( 'Facebook Object Type', 'all_in_one_seo_pack'),
129
+ 'type' => 'select', 'style' => '',
130
+ 'initial_options' => $this->fb_object_types,
131
+ 'default' => ''
132
+ )
133
+ );
134
+
135
+ if ( !empty( $help_text ) )
136
+ foreach( $help_text as $k => $v )
137
+ $this->default_options[$k]['help_text'] = $v;
138
+
139
+ // load initial options / set defaults
140
+ $this->update_options( );
141
+
142
+ $display = Array();
143
+ if ( isset( $this->options['aiosp_opengraph_types'] ) ) $display = $this->options['aiosp_opengraph_types'];
144
+
145
+ $this->locations = array(
146
+ 'opengraph' => Array( 'name' => $this->name, 'prefix' => 'aiosp_', 'type' => 'settings',
147
+ 'options' => Array('scan_header', 'setmeta', 'key', 'sitename', 'hometitle', 'description', 'disable_jetpack', 'generate_descriptions', 'defimg', 'dimg', 'meta_key', 'categories', 'types') ),
148
+ 'settings' => Array( 'name' => __('Social Settings', 'all_in_one_seo_pack'),
149
+ 'type' => 'metabox', 'help_link' => 'http://semperplugins.com/documentation/social-meta-module/#pagepost_settings',
150
+ 'options' => Array( 'title', 'desc', 'image', 'customimg', 'imagewidth', 'imageheight', 'category' ),
151
+ 'display' => $display, 'prefix' => 'aioseop_opengraph_'
152
+ )
153
+ );
154
+
155
+ $this->layout = Array(
156
+ 'default' => Array(
157
+ 'name' => __( 'Social Meta', 'all_in_one_seo_pack' ),
158
+ 'help_link' => 'http://semperplugins.com/documentation/social-meta-module/',
159
+ 'options' => Array() // this is set below, to the remaining options -- pdb
160
+ ),
161
+ 'scan_meta' => Array(
162
+ 'name' => __( 'Scan Social Meta', 'all_in_one_seo_pack' ),
163
+ 'help_link' => 'http://semperplugins.com/documentation/social-meta-module/#scan_meta',
164
+ 'options' => Array( 'scan_header' )
165
+ )
166
+ );
167
+
168
+ $other_options = Array();
169
+ foreach( $this->layout as $k => $v )
170
+ $other_options = array_merge( $other_options, $v['options'] );
171
+
172
+ $this->layout['default']['options'] = array_diff( array_keys( $this->default_options ), $other_options );
173
+
174
+ add_action( 'admin_init', Array( $this, 'debug_post_types' ), 5 );
175
+ if( !is_admin() || defined( 'DOING_AJAX' ) ){ $this->do_opengraph(); }
176
+ }
177
+
178
+ function settings_page_init() {
179
+ add_filter( 'aiosp_output_option', Array( $this, 'display_custom_options' ), 10, 2 );
180
+ $cat = $this->options["{$this->prefix}categories"];
181
+ if ( !empty( $cat ) ) {
182
+ if ( $cat == 'blog' ) {
183
+ $show_on_front = get_option( 'show_on_front' );
184
+ if ( ( $show_on_front == 'page' ) && ( get_option( 'page_on_front' ) ) ) {
185
+ $this->output_error( '<p>' . __( "Static front page detected, suggested Facebook Object Type is 'website'.", 'all_in_one_seo_pack' ) . '</p>' );
186
+ }
187
+ } elseif ( $cat == 'website' ) {
188
+ $show_on_front = get_option( 'show_on_front' );
189
+ if ( ( $show_on_front == 'posts' ) )
190
+ $this->output_error( '<p>' . __( "Blog on front page detected, suggested Facebook Object Type is 'blog'.", 'all_in_one_seo_pack' ) . '</p>' );
191
+ }
192
+ }
193
+ }
194
+
195
+ function filter_options( $options, $location ) {
196
+ if ( $location == 'settings' ) {
197
+ $prefix = $this->get_prefix( $location ) . $location . '_';
198
+ list( $legacy, $images ) = $this->get_all_images( $options );
199
+ if ( isset( $options ) && isset( $options["{$prefix}image"] ) ) {
200
+ $thumbnail = $options["{$prefix}image"];
201
+ if ( ctype_digit( (string)$thumbnail ) || ( $thumbnail == 'post' ) ) {
202
+ if ( $thumbnail == 'post' )
203
+ $thumbnail = $images['post1'];
204
+ else
205
+ if ( !empty( $legacy[$thumbnail] ) )
206
+ $thumbnail = $legacy[$thumbnail];
207
+ }
208
+ $options["{$prefix}image"] = $thumbnail;
209
+ }
210
+ if ( empty( $options[ $prefix . 'image' ] ) ) {
211
+ $img = array_keys( $images );
212
+ if ( !empty( $img ) && !empty( $img[1] ) )
213
+ $options[ $prefix . 'image' ] = $img[1];
214
+ }
215
+ }
216
+ return $options;
217
+ }
218
+
219
+ function filter_settings( $settings, $location, $current ) {
220
+ if ( $location == 'opengraph' || $location == 'settings' ) {
221
+ $prefix = $this->get_prefix( $location ) . $location . '_';
222
+ if ( $location == 'opengraph' ) return $settings;
223
+ if ( $location == 'settings' ) {
224
+ list( $legacy, $settings[ $prefix . 'image' ]['initial_options'] ) = $this->get_all_images( $current );
225
+ $opts = Array( 'title', 'desc' );
226
+ $current_post_type = get_post_type();
227
+ if ( isset( $this->options["aiosp_opengraph_{$current_post_type}_fb_object_type"] ) ) {
228
+ $settings[$prefix . 'category']['initial_options'] = array_merge( Array( '' => 'Default - ' . $this->options["aiosp_opengraph_{$current_post_type}_fb_object_type"] ), $settings[$prefix . 'category']['initial_options'] );
229
+ }
230
+ }
231
+ if ( isset( $current[ $prefix . 'setmeta' ] ) && $current[ $prefix . 'setmeta' ] )
232
+ foreach ( $opts as $opt )
233
+ if ( isset( $settings[ $prefix . $opt ] ) ) {
234
+ $settings[ $prefix . $opt ]['type'] = 'hidden';
235
+ $settings[ $prefix . $opt ]['label'] = 'none';
236
+ $settings[ $prefix . $opt ]['help_text'] = '';
237
+ unset( $settings[ $prefix . $opt ]['count'] );
238
+ }
239
+ }
240
+ return $settings;
241
+ }
242
+
243
+ function override_options( $options, $location, $settings ) {
244
+ $opts = Array();
245
+ foreach ( $settings as $k => $v ) if ( $v['save'] ) $opts[$k] = $v['default'];
246
+ foreach( $options as $k => $v ) if ( $v === NULL ) unset( $options[$k] );
247
+ $options = wp_parse_args( $options, $opts );
248
+ return $options;
249
+ }
250
+
251
+ function filter_metabox_options( $options, $location, $post_id ) {
252
+ if ( $location == 'settings' ) {
253
+ $prefix = $this->get_prefix( $location ) . $location;
254
+ if ( !empty( $options[$prefix . '_customimg'] ) ) {
255
+ $old_options = get_post_meta( $post_id, '_' . $prefix );
256
+ $prefix .= '_';
257
+ if ( empty( $old_options[$prefix . 'customimg'] ) || ( $old_options[$prefix . 'customimg'] != $options[$prefix . 'customimg'] ) )
258
+ $options[$prefix . 'image'] = $options[$prefix . 'customimg'];
259
+ }
260
+ }
261
+ return $options;
262
+ }
263
+
264
+ /** Custom settings **/
265
+ function display_custom_options( $buf, $args ) {
266
+ if ( $args['name'] == 'aiosp_opengraph_scan_header' ) {
267
+ $buf .= '<div class="aioseop aioseop_options aiosp_opengraph_settings"><div class="aioseop_wrapper aioseop_custom_type" id="aiosp_opengraph_scan_header_wrapper"><div class="aioseop_input" id="aiosp_opengraph_scan_header" style="padding-left:20px;">';
268
+ $args['options']['type'] = 'submit';
269
+ $args['attr'] = " class='button-primary' ";
270
+ $args['value'] = $args['options']['default'] = __( 'Scan Now', 'all_in_one_seo_pack' );
271
+ }
272
+ $buf .= __( 'Scan your site for duplicate social meta tags.', 'all_in_one_seo_pack' );
273
+ $buf .= '<br /><br />' . $this->get_option_html( $args );
274
+ $buf .= '</div></div></div>';
275
+ return $buf;
276
+ }
277
+
278
+ function add_attributes( $output ) { // avoid having duplicate meta tags
279
+ if ( !empty( $this->options[ 'aiosp_opengraph_disable_jetpack' ] ) )
280
+ remove_action( 'wp_head', 'jetpack_og_tags' );
281
+
282
+ return $output . 'xmlns="http://www.w3.org/1999/xhtml"
283
+ xmlns:og="http://ogp.me/ns#"
284
+ xmlns:fb="http://www.facebook.com/2008/fbml"';
285
+ }
286
+
287
+ function add_meta( ) {
288
+ global $post, $aiosp, $aioseop_options, $wp_query;
289
+ $metabox = $this->get_current_options( Array(), 'settings' );
290
+ $key = $this->options['aiosp_opengraph_key'];
291
+ $dimg = $this->options['aiosp_opengraph_dimg'];
292
+ $current_post_type = get_post_type();
293
+ $title = $description = $image = '';
294
+
295
+ $sitename = $this->options['aiosp_opengraph_sitename'];
296
+
297
+ if ( !empty( $aioseop_options['aiosp_hide_paginated_descriptions'] ) ) {
298
+ $first_page = false;
299
+ if ( $aiosp->get_page_number() < 2 ) $first_page = true;
300
+ } else {
301
+ $first_page = true;
302
+ }
303
+ $url = $aiosp->aiosp_mrt_get_url( $wp_query );
304
+ $url = apply_filters( 'aioseop_canonical_url',$url );
305
+ $setmeta = $this->options['aiosp_opengraph_setmeta'];
306
+ if ( is_home( ) || $aiosp->is_static_front_page() ) {
307
+ $title = $this->options['aiosp_opengraph_hometitle'];
308
+ if ( $first_page )
309
+ $description = $this->options['aiosp_opengraph_description'];
310
+ $type = $this->options['aiosp_opengraph_categories'];
311
+ $thumbnail = $this->options['aiosp_opengraph_dimg'];
312
+
313
+ /* If Use AIOSEO Title and Desc Selected */
314
+ if( $setmeta ) {
315
+ $title = $aioseop_options['aiosp_home_title'];
316
+ if ( $first_page )
317
+ $description = $aioseop_options['aiosp_home_description'];
318
+ }
319
+
320
+ /* Add some defaults */
321
+ if( empty($title) ) $title = get_bloginfo('name');
322
+ if( empty($sitename) ) $sitename = get_bloginfo('name');
323
+
324
+ if ( empty( $description ) && $first_page && ( !empty( $this->options['aiosp_opengraph_generate_descriptions'] ) ) )
325
+ $description = $aiosp->trim_excerpt_without_filters( $aiosp->internationalize( $post->post_content ), 1000 );
326
+
327
+ if ( empty($description) && $first_page ) $description = get_bloginfo('description');
328
+
329
+ } elseif ( is_singular( ) && $this->option_isset('types')
330
+ && is_array( $this->options['aiosp_opengraph_types'] )
331
+ && in_array( $current_post_type, $this->options['aiosp_opengraph_types'] ) ) {
332
+ if ( !empty( $metabox['aioseop_opengraph_settings_category'] ) ) {
333
+ $type = $metabox['aioseop_opengraph_settings_category'];
334
+ } elseif ( isset( $this->options["aiosp_opengraph_{$current_post_type}_fb_object_type"] ) ) {
335
+ $type = $this->options["aiosp_opengraph_{$current_post_type}_fb_object_type"];
336
+ }
337
+
338
+ $image = $metabox['aioseop_opengraph_settings_image'];
339
+ $title = $metabox['aioseop_opengraph_settings_title'];
340
+ $description = $metabox['aioseop_opengraph_settings_desc'];
341
+
342
+ /* Add AIOSEO variables if Site Title and Desc from AIOSEOP not selected */
343
+ global $aiosp;
344
+ if( empty( $title ) )
345
+ $title = $aiosp->get_aioseop_title( $post );
346
+ if ( empty( $description ) )
347
+ $description = trim( strip_tags( get_post_meta( $post->ID, "_aioseop_description", true ) ) );
348
+
349
+ /* Add some defaults */
350
+ if ( empty( $title ) ) $title = get_the_title();
351
+ if ( empty( $description ) && ( $this->options['aiosp_opengraph_generate_descriptions'] ) )
352
+ $description = $post->post_content;
353
+ if ( empty( $type ) ) $type = 'article';
354
+ } else return;
355
+
356
+ if ( !empty( $description ) )
357
+ $description = $aiosp->trim_excerpt_without_filters( $aiosp->internationalize( $description ), 1000 );
358
+
359
+ /* Data Validation */
360
+ $title = strip_tags( esc_attr( $title ) );
361
+ $sitename = strip_tags( esc_attr( $sitename ) );
362
+ $description = strip_tags( esc_attr( $description ) );
363
+
364
+ if ( empty( $thumbnail ) && !empty( $image ) )
365
+ $thumbnail = $image;
366
+
367
+ /* Get the first image attachment on the post */
368
+ // if( empty($thumbnail) ) $thumbnail = $this->get_the_image();
369
+
370
+ /* Add user supplied default image */
371
+ if( empty($thumbnail) ) {
372
+ if ( empty( $this->options['aiosp_opengraph_defimg'] ) )
373
+ $thumbnail = $this->options['aiosp_opengraph_dimg'];
374
+ else {
375
+ switch ( $this->options['aiosp_opengraph_defimg'] ) {
376
+ case 'featured' : $thumbnail = $this->get_the_image_by_post_thumbnail( );
377
+ break;
378
+ case 'attach' : $thumbnail = $this->get_the_image_by_attachment( );
379
+ break;
380
+ case 'content' : $thumbnail = $this->get_the_image_by_scan( );
381
+ break;
382
+ case 'custom' : $meta_key = $this->options['aiosp_opengraph_meta_key'];
383
+ if ( !empty( $meta_key ) && !empty( $post ) ) {
384
+ $meta_key = explode( ',', $meta_key );
385
+ $thumbnail = $this->get_the_image_by_meta_key( Array( 'post_id' => $post->ID, 'meta_key' => $meta_key ) );
386
+ }
387
+ break;
388
+ case 'auto' : $thumbnail = $this->get_the_image();
389
+ break;
390
+ default : $thumbnail = $this->options['aiosp_opengraph_dimg'];
391
+ }
392
+ }
393
+ }
394
+
395
+ $width = $height = '';
396
+ if ( !empty( $thumbnail ) ) {
397
+ if ( !empty( $metabox['aioseop_opengraph_settings_imagewidth'] ) )
398
+ $width = $metabox['aioseop_opengraph_settings_imagewidth'];
399
+ if ( !empty( $metabox['aioseop_opengraph_settings_imageheight'] ) )
400
+ $height = $metabox['aioseop_opengraph_settings_imageheight'];
401
+ }
402
+
403
+ $card = 'summary';
404
+
405
+ /* OG only: */
406
+ $meta = Array(
407
+ 'facebook' => Array(
408
+ 'title' => 'og:title',
409
+ 'type' => 'og:type',
410
+ 'url' => 'og:url',
411
+ 'thumbnail' => 'og:image',
412
+ 'width' => 'og:image:width',
413
+ 'height' => 'og:image:height',
414
+ 'sitename' => 'og:site_name',
415
+ 'key' => 'fb:admins',
416
+ 'description' => 'og:description'
417
+ ),
418
+ 'twitter' => Array(
419
+ 'card' => 'twitter:card',
420
+ 'description' => 'twitter:description',
421
+ )
422
+ );
423
+
424
+ // Add links to testing tools
425
+
426
+ /*
427
+ http://developers.facebook.com/tools/debug
428
+ https://dev.twitter.com/docs/cards/preview
429
+ http://www.google.com/webmasters/tools/richsnippets
430
+ */
431
+ /*
432
+ $meta = Array(
433
+ 'facebook' => Array(
434
+ 'title' => 'og:title',
435
+ 'type' => 'og:type',
436
+ 'url' => 'og:url',
437
+ 'thumbnail' => 'og:image',
438
+ 'sitename' => 'og:site_name',
439
+ 'key' => 'fb:admins',
440
+ 'description' => 'og:description'
441
+ ),
442
+ 'google+' => Array(
443
+ 'thumbnail' => 'image',
444
+ 'title' => 'name',
445
+ 'description' => 'description'
446
+ ),
447
+ 'twitter' => Array(
448
+ 'card' => 'twitter:card',
449
+ 'url' => 'twitter:url',
450
+ 'title' => 'twitter:title',
451
+ 'description' => 'twitter:description',
452
+ 'thumbnail' => 'twitter:image'
453
+
454
+ )
455
+ );
456
+ */
457
+
458
+ /*
459
+ Note -- add support for these too, as per https://dev.twitter.com/docs/cards
460
+
461
+ Card Property Description Required
462
+ twitter:site @username for the website used in the card footer. No
463
+ twitter:site:id Same as twitter:site, but the website's Twitter user ID instead. Note that user ids never change, while @usernames can be changed by the user. No
464
+ twitter:creator @username for the content creator / author. No
465
+ twitter:creator:id Same as twitter:creator, but the Twitter user's ID. No
466
+ */
467
+
468
+ $tags = Array(
469
+ 'facebook' => Array( 'name' => 'property', 'value' => 'content' ),
470
+ 'twitter' => Array( 'name' => 'name', 'value' => 'content' ),
471
+ 'google+' => Array( 'name' => 'itemprop', 'value' => 'content' )
472
+ );
473
+
474
+ foreach ( $meta as $t => $data )
475
+ foreach ( $data as $k => $v )
476
+ if ( !empty( $$k ) ) echo '<meta ' . $tags[$t]['name'] . '="' . $v . '" ' . $tags[$t]['value'] . '="' . $$k . '" />' . "\n";
477
+ }
478
+
479
+ function do_opengraph( ) {
480
+ add_filter( 'language_attributes', Array( $this, 'add_attributes' ) );
481
+ if ( !defined( 'DOING_AJAX' ) )
482
+ add_action( 'aioseop_modules_wp_head', Array( $this, 'add_meta' ), 5 );
483
+ }
484
+
485
+ function debug_post_types( ) {
486
+ add_filter( $this->prefix . 'display_settings', Array( $this, 'filter_settings' ), 10, 3 );
487
+ add_filter( $this->prefix . 'override_options', Array( $this, 'override_options' ), 10, 3 );
488
+ add_filter( $this->get_prefix( 'settings' ) . 'filter_metabox_options', Array( $this, 'filter_metabox_options' ), 10, 3 );
489
+ $post_types = $this->get_post_type_titles( );
490
+ $rempost = array( 'revision' => 1, 'nav_menu_item' => 1 );
491
+ $post_types = array_diff_key( $post_types, $rempost );
492
+ $this->default_options['types']['initial_options'] = $post_types;
493
+ foreach( $post_types as $slug => $name ) {
494
+ $field = $slug . '_fb_object_type';
495
+ $this->default_options[$field] = Array(
496
+ 'name' => "$name " . __( 'Object Type', 'all_in_one_seo_pack' ) . "<br />($slug)",
497
+ 'help_text' => __( 'Choose a default value that best describes the content of your post type.', 'all_in_one_seo_pack' ),
498
+ 'type' => 'select',
499
+ 'style' => '',
500
+ 'initial_options' => $this->fb_object_types,
501
+ 'default' => 'article',
502
+ 'condshow' => Array( 'aiosp_opengraph_types\[\]' => $slug )
503
+ );
504
+ $this->locations['opengraph']['options'][] = $field;
505
+ $this->layout['default']['options'][] = $field;
506
+ }
507
+ $this->setting_options();
508
+ }
509
+
510
+ function get_all_images( $options = null ) {
511
+ static $img = Array();
512
+ if ( empty( $img ) ) {
513
+ $size = apply_filters( 'post_thumbnail_size', 'large' );
514
+ $default = $this->get_the_image_by_default();
515
+ if ( !empty( $default ) )
516
+ $img[$default] = 0;
517
+ global $post, $aioseop_options, $wp_query;
518
+
519
+ $count = 1;
520
+
521
+ if ( !empty( $post ) ) {
522
+ if ( !is_object( $post ) ) $post = get_post( $post );
523
+ if ( is_object( $post ) && function_exists('get_post_thumbnail_id' ) ) {
524
+ if ( $post->post_type == 'attachment' )
525
+ $post_thumbnail_id = $post->ID;
526
+ else
527
+ $post_thumbnail_id = get_post_thumbnail_id( $post->ID );
528
+ if ( !empty( $post_thumbnail_id ) ) {
529
+ $image = wp_get_attachment_image_src( $post_thumbnail_id, $size );
530
+ if ( is_array( $image ) )
531
+ $img[$image[0]] = 1;
532
+ }
533
+ }
534
+
535
+ $post_id = $post->ID;
536
+ $p = $post; $w = $wp_query;
537
+
538
+ if ( !empty( $this->options['aiosp_opengraph_meta_key'] ) )
539
+ $meta_key = $this->options['aiosp_opengraph_meta_key'];
540
+ if ( !empty( $meta_key ) ) {
541
+ $image = $this->get_the_image_by_meta_key( Array( 'post_id' => $post_id, 'meta_key' => $meta_key ) );
542
+ if ( !empty( $image ) )
543
+ $img[$image] = $meta_key;
544
+ }
545
+ if (! $post->post_modified_gmt != '' )
546
+ $wp_query = new WP_Query( array( 'p' => $post_id, 'post_type' => $post->post_type ) );
547
+ if ( $post->post_type == 'page' )
548
+ $wp_query->is_page = true;
549
+ elseif ( $post->post_type == 'attachment' )
550
+ $wp_query->is_attachment = true;
551
+ else
552
+ $wp_query->is_single = true;
553
+ if ( get_option( 'show_on_front' ) == 'page' ) {
554
+ if ( is_page() && $post->ID == get_option( 'page_on_front' ) )
555
+ $wp_query->is_front_page = true;
556
+ elseif ( $post->ID == get_option( 'page_for_posts' ) )
557
+ $wp_query->is_home = true;
558
+ }
559
+ $args['options']['type'] = 'html';
560
+ $args['options']['nowrap'] = false;
561
+ $args['options']['save'] = false;
562
+ $wp_query->queried_object = $post;
563
+
564
+ $attachments = get_children( Array( 'post_parent' => $post->ID,
565
+ 'post_status' => 'inherit',
566
+ 'post_type' => 'attachment',
567
+ 'post_mime_type' => 'image',
568
+ 'order' => 'ASC',
569
+ 'orderby' => 'menu_order ID' ) );
570
+ if ( !empty( $attachments ) )
571
+ foreach( $attachments as $id => $attachment ) {
572
+ $image = wp_get_attachment_image_src( $id, $size );
573
+ if ( is_array( $image ) )
574
+ $img[$image[0]] = $id;
575
+ }
576
+ $matches = Array();
577
+ preg_match_all( '|<img.*?src=[\'"](.*?)[\'"].*?>|i', get_post_field( 'post_content', $post->ID ), $matches );
578
+ if ( isset( $matches ) && !empty( $matches[1] ) && !empty( $matches[1][0] ) )
579
+ foreach( $matches[1] as $i => $m )
580
+ $img[$m] = 'post' . $count++;
581
+ wp_reset_postdata();
582
+ $wp_query = $w; $post = $p;
583
+ }
584
+ }
585
+
586
+ if ( !empty( $options ) && !empty( $options['aioseop_opengraph_settings_customimg'] ) ) {
587
+ $img[$options['aioseop_opengraph_settings_customimg']] = 'customimg';
588
+ }
589
+ $image = array_flip( $img );
590
+ $images = Array();
591
+ if ( !empty( $image ) )
592
+ foreach( $image as $k => $v )
593
+ $images[$v] = '<img height=150 src="' . $v . '">';
594
+ return Array( $image, $images );
595
+ }
596
+
597
+ /*** Thanks to Justin Tadlock for the original get-the-image code - http://themehybrid.com/plugins/get-the-image ***/
598
+
599
+ function get_the_image( ) {
600
+ global $post;
601
+ $meta_key = $this->options['aiosp_opengraph_meta_key'];
602
+ if ( !empty( $meta_key ) && !empty( $post ) ) {
603
+ $meta_key = explode( ',', $meta_key );
604
+ $image = $this->get_the_image_by_meta_key( Array( 'post_id' => $post->ID, 'meta_key' => $meta_key ) );
605
+ }
606
+ if ( empty( $image ) ) $image = $this->get_the_image_by_post_thumbnail( );
607
+ if ( empty( $image ) ) $image = $this->get_the_image_by_attachment( );
608
+ if ( empty( $image ) ) $image = $this->get_the_image_by_scan( );
609
+ if ( empty( $image ) ) $image = $this->get_the_image_by_default( );
610
+ return $image;
611
+ }
612
+
613
+ function get_the_image_by_meta_key( $args = array() ) {
614
+
615
+ /* If $meta_key is not an array. */
616
+ if ( !is_array( $args['meta_key'] ) )
617
+ $args['meta_key'] = array( $args['meta_key'] );
618
+
619
+ /* Loop through each of the given meta keys. */
620
+ foreach ( $args['meta_key'] as $meta_key ) {
621
+ /* Get the image URL by the current meta key in the loop. */
622
+ $image = get_post_meta( $args['post_id'], $meta_key, true );
623
+ /* If a custom key value has been given for one of the keys, return the image URL. */
624
+ if ( !empty( $image ) )
625
+ return $image;
626
+ }
627
+ return false;
628
+ }
629
+
630
+ function get_the_image_by_post_thumbnail( ) {
631
+
632
+ global $post;
633
+
634
+ $post_thumbnail_id = null;
635
+ if ( function_exists('get_post_thumbnail_id' ) ) {
636
+ $post_thumbnail_id = get_post_thumbnail_id( $post->ID );
637
+ }
638
+
639
+ if ( empty( $post_thumbnail_id ) )
640
+ return false;
641
+
642
+ $size = apply_filters( 'post_thumbnail_size', 'large' );
643
+ $image = wp_get_attachment_image_src( $post_thumbnail_id, $size );
644
+ return $image[0];
645
+ }
646
+
647
+ function get_the_image_by_attachment( $args = array() ) {
648
+
649
+ global $post;
650
+ $attachments = get_children( Array( 'post_parent' => $post->ID,
651
+ 'post_status' => 'inherit',
652
+ 'post_type' => 'attachment',
653
+ 'post_mime_type' => 'image',
654
+ 'order' => 'ASC',
655
+ 'orderby' => 'menu_order ID' ) );
656
+
657
+ if ( empty( $attachments ) ) {
658
+ if ( 'attachment' == get_post_type( $post->ID ) ) {
659
+ $image = wp_get_attachment_image_src( $post->ID, 'large' );
660
+ }
661
+ }
662
+
663
+ /* If no attachments or image is found, return false. */
664
+ if ( empty( $attachments ) && empty( $image ) )
665
+ return false;
666
+
667
+ /* Set the default iterator to 0. */
668
+ $i = 0;
669
+
670
+ /* Loop through each attachment. Once the $order_of_image (default is '1') is reached, break the loop. */
671
+ foreach ( $attachments as $id => $attachment ) {
672
+ if ( ++$i == 1 ) {
673
+ $image = wp_get_attachment_image_src( $id, 'large' );
674
+ $alt = trim( strip_tags( get_post_field( 'post_excerpt', $id ) ) );
675
+ break;
676
+ }
677
+ }
678
+
679
+ /* Return the image URL. */
680
+ return $image[0];
681
+
682
+ }
683
+
684
+ function get_the_image_by_scan( ) {
685
+
686
+ global $post;
687
+
688
+ /* Search the post's content for the <img /> tag and get its URL. */
689
+ preg_match_all( '|<img.*?src=[\'"](.*?)[\'"].*?>|i', get_post_field( 'post_content', $post->ID ), $matches );
690
+
691
+ /* If there is a match for the image, return its URL. */
692
+ if ( isset( $matches ) && !empty( $matches[1][0] ) )
693
+ return $matches[1][0];
694
+
695
+ return false;
696
+
697
+ }
698
+
699
+ function get_the_image_by_default( $args = array() ) {
700
+ return $this->options['aiosp_opengraph_dimg'];
701
+ }
702
+
703
+ function settings_update( ) {
704
+
705
+ }
706
+ }
707
+ }
aioseop_sitemap.php CHANGED
@@ -793,6 +793,7 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
793
  $post_counts = $this->get_all_post_counts( Array('post_type' => $options['aiosp_sitemap_posttypes'], 'post_status' => 'publish') );
794
  }
795
  foreach( $options['aiosp_sitemap_posttypes'] as $sm ) {
 
796
  if ( $this->paginate ) {
797
  if ( $post_counts[$sm] > $this->max_posts ) {
798
  $count = 1;
793
  $post_counts = $this->get_all_post_counts( Array('post_type' => $options['aiosp_sitemap_posttypes'], 'post_status' => 'publish') );
794
  }
795
  foreach( $options['aiosp_sitemap_posttypes'] as $sm ) {
796
+ if ( $post_counts[$sm] == 0 ) continue;
797
  if ( $this->paginate ) {
798
  if ( $post_counts[$sm] > $this->max_posts ) {
799
  $count = 1;
all_in_one_seo_pack.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: All In One SEO Pack
4
  Plugin URI: http://semperfiwebdesign.com
5
  Description: Out-of-the-box SEO for your WordPress blog. <a href="admin.php?page=all-in-one-seo-pack/aioseop_class.php">Options configuration panel</a> | <a href="http://semperplugins.com/plugins/all-in-one-seo-pack-pro-version/?loc=plugins" target="_blank">Upgrade to Pro Version</a> | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=mrtorbert%40gmail%2ecom&item_name=All%20In%20One%20SEO%20Pack&item_number=Support%20Open%20Source&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8">Donate</a> | <a href="http://semperplugins.com/support/" >Support</a> | <a href="https://www.amazon.com/wishlist/1NFQ133FNCOOA/ref=wl_web" target="_blank" title="Amazon Wish List">Amazon Wishlist</a>
6
- Version: 2.0.4.1
7
  Author: Michael Torbert
8
  Author URI: http://michaeltorbert.com
9
  */
@@ -30,11 +30,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
30
 
31
  /**
32
  * @package All-in-One-SEO-Pack
33
- * @version 2.0.4.1
34
  */
35
 
36
  if ( ! defined( 'AIOSEOP_VERSION' ) )
37
- define( 'AIOSEOP_VERSION', '2.0.4.1' );
38
 
39
  if ( ! defined( 'AIOSEOP_PLUGIN_DIR' ) ) {
40
  define( 'AIOSEOP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
@@ -116,7 +116,7 @@ if ( !empty( $aioseop_mem_limit ) ) {
116
  }
117
 
118
  $aiosp_activation = false;
119
- $aioseop_module_list = Array( 'sitemap', 'performance' ); // list all available modules here
120
 
121
  if ( class_exists( 'All_in_One_SEO_Pack' ) ) {
122
  add_action( 'admin_notices', create_function( '', 'echo "<div class=\'error\'>The All In One SEO Pack class is already defined";'
@@ -141,9 +141,30 @@ if ( is_admin() ) {
141
  add_action( 'wp_ajax_aioseop_ajax_save_meta', 'aioseop_ajax_save_meta' );
142
  add_action( 'wp_ajax_aioseop_ajax_save_url', 'aioseop_ajax_save_url' );
143
  add_action( 'wp_ajax_aioseop_ajax_delete_url', 'aioseop_ajax_delete_url' );
 
144
  add_action( 'wp_ajax_aioseop_ajax_save_settings', 'aioseop_ajax_save_settings');
145
  add_action( 'wp_ajax_aioseop_ajax_get_menu_links', 'aioseop_ajax_get_menu_links');
146
  }
147
 
148
  if ( aioseop_option_isset( 'aiosp_unprotect_meta' ) )
149
  add_filter( 'is_protected_meta', 'aioseop_unprotect_meta', 10, 3 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  Plugin Name: All In One SEO Pack
4
  Plugin URI: http://semperfiwebdesign.com
5
  Description: Out-of-the-box SEO for your WordPress blog. <a href="admin.php?page=all-in-one-seo-pack/aioseop_class.php">Options configuration panel</a> | <a href="http://semperplugins.com/plugins/all-in-one-seo-pack-pro-version/?loc=plugins" target="_blank">Upgrade to Pro Version</a> | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=mrtorbert%40gmail%2ecom&item_name=All%20In%20One%20SEO%20Pack&item_number=Support%20Open%20Source&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8">Donate</a> | <a href="http://semperplugins.com/support/" >Support</a> | <a href="https://www.amazon.com/wishlist/1NFQ133FNCOOA/ref=wl_web" target="_blank" title="Amazon Wish List">Amazon Wishlist</a>
6
+ Version: 2.1
7
  Author: Michael Torbert
8
  Author URI: http://michaeltorbert.com
9
  */
30
 
31
  /**
32
  * @package All-in-One-SEO-Pack
33
+ * @version 2.1
34
  */
35
 
36
  if ( ! defined( 'AIOSEOP_VERSION' ) )
37
+ define( 'AIOSEOP_VERSION', '2.1' );
38
 
39
  if ( ! defined( 'AIOSEOP_PLUGIN_DIR' ) ) {
40
  define( 'AIOSEOP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
116
  }
117
 
118
  $aiosp_activation = false;
119
+ $aioseop_module_list = Array( 'sitemap', 'opengraph', 'performance' ); // list all available modules here
120
 
121
  if ( class_exists( 'All_in_One_SEO_Pack' ) ) {
122
  add_action( 'admin_notices', create_function( '', 'echo "<div class=\'error\'>The All In One SEO Pack class is already defined";'
141
  add_action( 'wp_ajax_aioseop_ajax_save_meta', 'aioseop_ajax_save_meta' );
142
  add_action( 'wp_ajax_aioseop_ajax_save_url', 'aioseop_ajax_save_url' );
143
  add_action( 'wp_ajax_aioseop_ajax_delete_url', 'aioseop_ajax_delete_url' );
144
+ add_action( 'wp_ajax_aioseop_ajax_scan_header', 'aioseop_ajax_scan_header' );
145
  add_action( 'wp_ajax_aioseop_ajax_save_settings', 'aioseop_ajax_save_settings');
146
  add_action( 'wp_ajax_aioseop_ajax_get_menu_links', 'aioseop_ajax_get_menu_links');
147
  }
148
 
149
  if ( aioseop_option_isset( 'aiosp_unprotect_meta' ) )
150
  add_filter( 'is_protected_meta', 'aioseop_unprotect_meta', 10, 3 );
151
+
152
+ if ( !function_exists( 'aioseop_scan_post_header' ) ) {
153
+ function aioseop_scan_post_header() {
154
+ require_once( ABSPATH . WPINC . '/default-filters.php' );
155
+ global $wp_query;
156
+ $wp_query->query_vars['paged'] = 0;
157
+ query_posts('post_type=post&posts_per_page=1');
158
+ if (have_posts()) the_post();
159
+ }
160
+ }
161
+
162
+ if ( defined( 'DOING_AJAX' ) && !empty( $_POST ) && !empty( $_POST['action'] ) && ( $_POST['action'] === 'aioseop_ajax_scan_header' ) ) {
163
+ remove_action( 'init', array( $aiosp, 'add_hooks' ) );
164
+ add_action('admin_init', 'aioseop_scan_post_header' );
165
+ add_action('shutdown', 'aioseop_ajax_scan_header' ); // if the action doesn't run -- pdb
166
+ include_once(ABSPATH . 'wp-admin/includes/screen.php');
167
+ global $current_screen;
168
+ if ( class_exists( 'WP_Screen' ) )
169
+ $current_screen = WP_Screen::get( 'front' );
170
+ }
images/SocialMeta-BW-Retina.png ADDED
Binary file
images/SocialMeta-BW-Standard.png ADDED
Binary file
images/SocialMeta-Color-Retina.png ADDED
Binary file
images/SocialMeta-Color-Standard.png ADDED
Binary file
images/ecwid_banner.png ADDED
Binary file