PluginProbe ʕ •ᴥ•ʔ
Ocean Extra / 2.5.7
Ocean Extra v2.5.7
2.5.7 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.4.1 1.1.4.2 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.0.1 1.2.1 1.2.1.1 1.2.1.2 1.2.10 1.2.2 1.2.2.1 1.2.2.2 1.2.2.3 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.10 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.14 1.4.15 1.4.16 1.4.17 1.4.18 1.4.19 1.4.2 1.4.20 1.4.21 1.4.22 1.4.23 1.4.24 1.4.25 1.4.26 1.4.27 1.4.28 1.4.29 1.4.3 1.4.30 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.12 1.5.13 1.5.14 1.5.15 1.5.16 1.5.17 1.5.18 1.5.19 1.5.2 1.5.20 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6
ocean-extra / includes / preloader / preloader.php
ocean-extra / includes / preloader Last commit date
assets 1 year ago customizer.php 1 year ago helper.php 1 year ago preloader.php 1 year ago
preloader.php
276 lines
1 <?php
2 /**
3 * Preloader
4 *
5 * @package Ocean_Extra
6 * @category Core
7 * @author OceanWP
8 */
9
10 // Exit if accessed directly.
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 // Start Class
16 class Ocean_Preloader {
17
18 /**
19 * Status
20 */
21 public $active = false;
22
23 /**
24 * Type
25 */
26 public $type = 'default';
27
28 /**
29 * Icon Type
30 */
31 public $icon_type = 'css';
32
33 /**
34 * Icon
35 */
36 public $icon = 'roller';
37
38 /**
39 * Elementor template id
40 */
41 public $template_id = '';
42
43 /**
44 * Initialize
45 */
46 public function __construct() {
47
48 $this->preloader_setup();
49
50 $this->active = get_theme_mod( 'ocean_preloader_enable', false );
51 $this->type = get_theme_mod( 'ocean_preloader_type', 'default' );
52 $this->icon_type = get_theme_mod( 'ocean_preloader_icon_type', 'css' );
53 $this->icon = get_theme_mod( 'ocean_preloader_default_icon', 'roller' );
54 $this->template_id = get_theme_mod( 'ocean_preloader_template' );
55
56 if ( $this->active ) {
57 add_filter( 'body_class', array( $this, 'preloader_body_class' ) );
58 add_action( 'wp_head', array( $this, 'preloader_view' ), 1000 );
59 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_assets' ) );
60 add_action( 'ocean_preloader', array( $this, 'render_preloader' ) );
61 }
62 }
63
64 /**
65 * Preloader setup
66 */
67 public function preloader_setup() {
68
69 require_once OE_PATH . '/includes/preloader/helper.php';
70 }
71
72 public function enqueue_assets() {
73
74 wp_enqueue_style(
75 'owp-preloader',
76 OE_URL . 'includes/preloader/assets/css/preloader.min.css',
77 array(),
78 OE_VERSION
79 );
80
81 if ( 'default' === $this->type && 'css' === $this->icon_type && $this->icon ) {
82 wp_enqueue_style(
83 'owp-preloader-icon',
84 OE_URL . 'includes/preloader/assets/css/styles/' . $this->icon . '.css',
85 array(),
86 OE_VERSION
87 );
88 }
89
90 if ( is_customize_preview() ) {
91 wp_enqueue_script(
92 'owp-preloader',
93 OE_URL . 'includes/preloader/assets/js/preloader.min.js',
94 array( 'jquery' ),
95 OE_VERSION,
96 false
97 );
98
99 wp_localize_script(
100 'owp-preloader',
101 'owpPreloader',
102 array(
103 'nonce' => wp_create_nonce( 'oceanwp_preloader' ),
104 )
105 );
106 } else {
107 wp_enqueue_script(
108 'owp-preloader',
109 OE_URL . 'includes/preloader/assets/js/preloader.min.js',
110 array( 'jquery' ),
111 OE_VERSION,
112 false
113 );
114
115 wp_localize_script(
116 'owp-preloader',
117 'owpPreloader',
118 array(
119 'nonce' => wp_create_nonce( 'oceanwp_preloader' ),
120 )
121 );
122 }
123
124 // Check if page is Elementor page.
125 $elementor = get_post_meta( $this->template_id, '_elementor_edit_mode', true );
126
127 // Elementor css load
128 if ( true === get_theme_mod( 'ocean_preloader_elementor_fouc', true ) && $elementor ) {
129 if ( ! class_exists( '\Elementor\Core\Files\CSS\Post' ) ) {
130 return;
131 }
132 $css_file = new \Elementor\Core\Files\CSS\Post( $this->template_id );
133 $css_file->enqueue();
134 }
135 }
136
137 /**
138 * Preloader view
139 */
140 public function preloader_body_class( $classes ) {
141 $classes[] = 'ocean-preloader--active';
142
143 return $classes;
144 }
145
146 /**
147 * Preloader view
148 */
149 public function preloader_view() {
150 ob_start();
151 ?>
152 <div id="ocean-preloader">
153 <?php do_action( 'ocean_preloader_before' ); ?>
154 <?php do_action( 'ocean_preloader' ); ?>
155 <?php do_action( 'ocean_preloader_after' ); ?>
156 </div>
157 <?php
158 $content = ob_get_clean();
159
160 echo $content;
161 }
162
163 /**
164 * Render preloader content
165 */
166 public function render_preloader() {
167
168 $image = get_theme_mod( 'ocean_preloader_icon_image', '' );
169 $svg_code = '';
170 $svg_path = get_theme_mod( 'ocean_preloader_icon_svg', '' );
171 if ( $svg_path ) {
172 $svg_code = file_get_contents( $svg_path );
173 }
174
175 $content = get_theme_mod( 'ocean_preloader_content', 'Site is Loading, Please wait...' );
176
177 // Check if page is Elementor page.
178 $elementor = get_post_meta( $this->template_id, '_elementor_edit_mode', true );
179
180 // Get content
181 $get_content = '';
182 if ( ! empty( $this->template_id ) ) {
183
184 $post_data = get_post( $this->template_id );
185
186 if ( $post_data && ! is_wp_error( $post_data ) ) {
187 $get_content = $post_data->post_content;
188 }
189
190 }
191
192 if ( 'default' === $this->type ) { ?>
193 <div class="preloader-content">
194 <div class="preloader-inner">
195 <?php
196 if ( 'css' === $this->icon_type ) :
197 ?>
198 <div class="preloader-icon">
199 <?php echo wp_kses_post( oe_preloader_icon( $this->icon ) ); ?>
200 </div>
201 <?php endif; ?>
202
203 <?php if ( 'image' === $this->icon_type ) :
204 ?>
205 <div class="preloader-image">
206 <?php oe_preloader_image(); ?>
207 </div>
208 <?php endif; ?>
209
210 <?php if ( 'logo' === $this->icon_type ) :
211 ?>
212 <div class="preloader-logo">
213 <?php the_custom_logo(); ?>
214 </div>
215 <?php endif; ?>
216
217 <?php if ( 'svg' === $this->icon_type ) :
218 ?>
219 <div class="preloader-svg">
220 <?php echo $svg_code; ?>
221 </div>
222 <?php endif; ?>
223
224 <?php if ( ! empty( $content ) ) :
225 ?>
226 <div class="preloader-after-content">
227 <?php echo wp_kses_post( $content ); ?>
228 </div>
229 <?php endif; ?>
230 </div>
231 </div>
232 <?php
233 }
234
235 if ( 'custom' === $this->type ) {
236
237 if ( class_exists( 'Elementor\Plugin' ) && $elementor ) {
238
239 echo Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $this->template_id );
240
241 }
242
243 // If Beaver Builder.
244 else if ( class_exists( 'FLBuilder' ) && ! empty( $this->template_id ) ) {
245
246 echo do_shortcode( '[fl_builder_insert_layout id="' . $this->template_id . '"]' );
247
248 }
249
250 // if SiteOrigin.
251 else if ( class_exists( 'SiteOrigin_Panels' ) && get_post_meta( $this->template_id, 'panels_data', true ) ) {
252
253 echo SiteOrigin_Panels::renderer()->render( $this->template_id );
254
255 }
256
257 // Else
258 else {
259
260 // If Gutenberg.
261 if ( ocean_is_block_template( $this->template_id ) ) {
262 $get_content = apply_filters( 'ocean_preloader_template_content', do_blocks( $get_content ) );
263 }
264
265 // Display template content.
266 echo do_shortcode( $get_content );
267
268 }
269
270 }
271 }
272
273 }
274
275 new Ocean_Preloader();
276