Main.php
2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
namespace AIOSEO\Plugin\Common\Main;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Models;
/**
* Abstract class that Pro and Lite both extend.
*
* @since 4.0.0
*/
class Main {
/**
* Construct method.
*
* @since 4.0.0
*/
public function __construct() {
$this->media = new Media();
add_action( 'admin_enqueue_scripts', [ $this, 'enqueueAssets' ] );
add_action( 'wp_enqueue_scripts', [ $this, 'enqueueFrontEndAssets' ] );
add_action( 'admin_footer', [ $this, 'adminFooter' ] );
}
/**
* Enqueue styles.
*
* @since 4.0.0
*
* @return void
*/
public function enqueueAssets() {
// Scripts.
$standalone = [
'app',
'notifications'
];
foreach ( $standalone as $key ) {
aioseo()->helpers->enqueueScript(
'aioseo-' . $key,
'js/' . $key . '.js'
);
}
aioseo()->helpers->enqueueScript(
'aioseo-vendors',
'js/chunk-vendors.js'
);
aioseo()->helpers->enqueueScript(
'aioseo-common',
'js/chunk-common.js'
);
wp_localize_script(
'aioseo-app',
'aioseoTranslations',
[
'translations' => aioseo()->helpers->getJedLocaleData( 'all-in-one-seo-pack' )
]
);
wp_localize_script(
'aioseo-notifications',
'aioseoNotifications',
[
'newNotifications' => count( Models\Notification::getNewNotifications() )
]
);
// Styles.
$rtl = is_rtl() ? '.rtl' : '';
aioseo()->helpers->enqueueStyle(
'aioseo-common',
"css/chunk-common$rtl.css"
);
aioseo()->helpers->enqueueStyle(
'aioseo-vendors',
"css/chunk-vendors$rtl.css"
);
foreach ( $standalone as $key ) {
aioseo()->helpers->enqueueStyle(
"aioseo-$key-style",
"css/$key$rtl.css"
);
}
}
/**
* Enqueue styles on the front-end.
*
* @since 4.0.0
*
* @return void
*/
public function enqueueFrontEndAssets() {
$canManageSeo = apply_filters( 'aioseo_manage_seo', 'aioseo_manage_seo' );
if (
! is_admin_bar_showing() ||
! ( current_user_can( $canManageSeo ) || aioseo()->access->canManage() )
) {
return;
}
// Styles.
aioseo()->helpers->enqueueStyle(
'aioseo-admin-bar',
'css/aioseo-admin-bar.css',
false
);
}
/**
* Enqueue the footer file to let vue attach.
*
* @since 4.0.0
*
* @return void
*/
public function adminFooter() {
echo '<div id="aioseo-admin"></div>';
}
}