PluginProbe
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO / trunk
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO vtrunk
1.4.13 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 1.4.6 1.4.5 1.4.4 1.4.3 1.4.2 1.4.1 1.4.0 1.3.54 1.3.53 1.3.52 1.3.51 1.3.50 1.3.49 1.3.48 1.3.47 1.3.46 1.3.45 1.3.44 All 176 releases
disco / frontend / Enqueue.php

Enqueue.php in Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO trunk, at frontend/Enqueue.php

102 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Disco
4 *
5 * @package Disco
6 * @author Ohidul Islam <wahid0003@gmail.com>
7 * @copyright 2022 WebAppick
8 * @license GPL 2.0+
9 * @link http://domain.tld
10 */
11
12 namespace Disco\Frontend;
13
14 use Disco\Engine\Base;
15 use Inpsyde\Assets\Asset;
16 use Inpsyde\Assets\AssetManager;
17 use Inpsyde\Assets\Script;
18 use Inpsyde\Assets\Style;
19
20 /**
21 * Enqueue stuff on the frontend
22 */
23 class Enqueue extends Base {
24
25 /**
26 * Initialize the class.
27 *
28 * @return void|bool
29 */
30 public function initialize() {
31 parent::initialize();
32
33 \add_action( AssetManager::ACTION_SETUP, array( $this, 'enqueue_assets' ) );
34 }
35
36 /**
37 * Enqueue assets with Inpyside library https://inpsyde.github.io/assets
38 *
39 * @param \Inpsyde\Assets\AssetManager $asset_manager The class.
40 * @return void
41 */
42 public function enqueue_assets( AssetManager $asset_manager ) {
43 // Load public-facing style sheet and JavaScript.
44 $assets = $this->enqueue_styles();
45
46 if ( ! empty( $assets ) ) {
47 foreach ( $assets as $asset ) {
48 $asset_manager->register( $asset );
49 }
50 }
51
52 $assets = $this->enqueue_scripts();
53
54 if ( empty( $assets ) ) {
55 return;
56 }
57
58 foreach ( $assets as $asset ) {
59 $asset_manager->register( $asset );
60 }
61 }
62
63 /**
64 * Register and enqueue public-facing style sheet.
65 *
66 * @since 1.0.0
67 * @return array
68 */
69 public function enqueue_styles() {
70 $styles = array();
71 $styles[0] = new Style( DISCO_TEXTDOMAIN . '-plugin-styles', \plugins_url( 'assets/build/plugin-public.css', DISCO_PLUGIN_ABSOLUTE ) );
72 $styles[0]->forLocation( Asset::FRONTEND )->useAsyncFilter()->withVersion( DISCO_VERSION );
73 $styles[0]->dependencies();
74
75 return $styles;
76 }
77
78 /**
79 * Register and enqueues public-facing JavaScript files.
80 *
81 * @since 1.0.0
82 * @return array
83 */
84 public static function enqueue_scripts() {
85 $scripts = array();
86 $scripts[0] = new Script( DISCO_TEXTDOMAIN . '-plugin-script', \plugins_url( 'assets/build/plugin-public.js', DISCO_PLUGIN_ABSOLUTE ) );
87 $scripts[0]->forLocation( Asset::FRONTEND )->useAsyncFilter()->withVersion( DISCO_VERSION );
88 $scripts[0]->dependencies();
89 $scripts[0]->withLocalize(
90 'exampleDemo',
91 array(
92 'alert' => \__( 'Error!', 'disco' ),
93 'nonce' => \wp_create_nonce( 'demo_example' ),
94 'wp_rest' => \wp_create_nonce( 'wp_rest' ),
95 )
96 );
97
98 return $scripts;
99 }
100
101 }
102