PluginProbe
Depicter — Popup & Slider Builder / trunk
Depicter — Popup & Slider Builder vtrunk
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Rules / ServiceProvider.php

ServiceProvider.php in Depicter — Popup & Slider Builder trunk, at app/src/Rules/ServiceProvider.php

60 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Depicter\Rules;
4
5 use Depicter\Rules\Condition\Conditions;
6 use WPEmerge\ServiceProviders\ServiceProviderInterface;
7
8 class ServiceProvider implements ServiceProviderInterface
9 {
10
11 /**
12 * {@inheritDoc}
13 */
14 public function register( $container ) {
15 $app = $container[ WPEMERGE_APPLICATION_KEY ];
16
17 // register conditions manager
18 $container[ 'depicter.displayRules.conditions' ] = function () {
19 return new Conditions();
20 };
21
22 $app->alias( 'conditions', 'depicter.displayRules.conditions' );
23 }
24
25 /**
26 * {@inheritDoc}
27 */
28 public function bootstrap($container)
29 {
30 add_action( 'wp_head', function(){
31 $documentIDs = \Depicter::document()->getConditionalDocumentIDs();
32
33 foreach( $documentIDs as $documentID ) {
34 if ( !empty( $_GET['dp-disable-popups'] ) ) {
35 try{
36 $documentType = \Depicter::documentRepository()->findOne( $documentID )->getProperty('type');
37 if ( in_array( $documentType, ['popup', 'banner-bar'] ) ) {
38 continue;
39 }
40 }catch( \Exception $e ){
41 }
42 }
43
44 if ( \Depicter::document()->displayRules( $documentID )->displayConditions()->areMet() ) {
45 \Depicter::front()->assets()->enqueueStyles();
46 \Depicter::front()->assets()->enqueueScripts();
47
48 \Depicter::document()->cacheCustomStyles( $documentID );
49 \Depicter::front()->assets()->enqueueCustomAssets( $documentID );
50 \Depicter::front()->assets()->enqueuePreloadTags( $documentID );
51
52 add_action( 'wp_footer', function() use ( $documentID ) {
53 echo \Depicter::front()->render()->document( $documentID );
54 });
55 }
56 }
57 });
58 }
59 }
60