1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Subway WordPress Plugin Package. |
4
|
|
|
* |
5
|
|
|
* (c) Joseph Gabito <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
* |
10
|
|
|
* PHP Version 5.4 |
11
|
|
|
* |
12
|
|
|
* @category Subway\Enqueue |
13
|
|
|
* @package Subway |
14
|
|
|
* @author Joseph G. <[email protected]> |
15
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
16
|
|
|
* @version GIT:github.com/codehaiku/subway |
17
|
|
|
* @link github.com/codehaiku/subway The Plugin Repository |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace Subway; |
21
|
|
|
|
22
|
|
|
if (! defined('ABSPATH') ) { |
23
|
|
|
return; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Registers all stylesheet and javascript documents. |
28
|
|
|
* |
29
|
|
|
* @category Subway\Enqueue |
30
|
|
|
* @package Subway |
31
|
|
|
* @author Joseph G. <[email protected]> |
32
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
33
|
|
|
* @link github.com/codehaiku/subway The Plugin Repository |
34
|
|
|
* @since 1.0 |
35
|
|
|
*/ |
36
|
|
|
final class Enqueue |
37
|
|
|
{ |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Registers our CSS and Javascript to WordPress Enqueue Handler. |
41
|
|
|
* |
42
|
|
|
* @return void |
43
|
|
|
*/ |
44
|
|
|
public static function registerJs() |
45
|
|
|
{ |
46
|
|
|
|
47
|
|
|
$post_id = absint(get_queried_object_id()); |
48
|
|
|
|
49
|
|
|
$signin_page = absint(get_option('subway_login_page')); |
50
|
|
|
|
51
|
|
|
wp_enqueue_style('subway-style', SUBWAY_DIR_URL . 'assets/css/subway.css'); |
52
|
|
|
|
53
|
|
|
// Only load the stylesheet and javascript documents inside our sign-in page. |
54
|
|
|
if ($post_id === $signin_page ) { |
55
|
|
|
|
56
|
|
|
if (! is_user_logged_in() ) { |
57
|
|
|
|
58
|
|
|
wp_enqueue_script( |
59
|
|
|
'subway-script', |
60
|
|
|
SUBWAY_DIR_URL . 'assets/js/subway.js', |
61
|
|
|
array( 'jquery' ) |
62
|
|
|
); |
63
|
|
|
|
64
|
|
|
wp_localize_script( |
65
|
|
|
'subway-script', 'subway_config', array( |
66
|
|
|
'ajax_url' => admin_url('admin-ajax.php'), |
67
|
|
|
'login_http_error' => esc_html__( |
68
|
|
|
'An error occured while |
69
|
|
|
transmitting the data. Refresh the page and try again', |
70
|
|
|
'subway' |
71
|
|
|
), |
72
|
|
|
) |
73
|
|
|
); |
74
|
|
|
|
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
return; |
79
|
|
|
|
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
} |
83
|
|
|
|