PluginProbe
Orderable – Restaurant & Food Ordering System / 0.2.0
Orderable – Restaurant & Food Ordering System v0.2.0
0.1.4 0.1.5 0.2.0 1.0.0 1.1.0 1.1.1 1.10.0 1.10.1 1.11.0 1.12.0 1.12.1 1.12.2 1.13.0 1.14.0 1.15.0 1.16.0 1.17.0 1.17.1 1.18.0 1.19.0 1.19.1 1.19.2 1.2.0 1.20.0 1.20.1 All 44 releases
orderable / inc / modules / drawer / class-drawer.php

class-drawer.php in Orderable – Restaurant & Food Ordering System 0.2.0, at inc/modules/drawer/class-drawer.php

90 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Module: Drawer.
4 *
5 * @package Orderable/Classes
6 */
7
8 defined( 'ABSPATH' ) || exit;
9
10 /**
11 * Drawer module class.
12 */
13 class Orderable_Drawer {
14 /**
15 * Init.
16 */
17 public static function run() {
18 self::load_classes();
19
20 add_action( 'wp_footer', array( __CLASS__, 'add' ) );
21 add_filter( 'woocommerce_add_to_cart_fragments', array( __CLASS__, 'cart_count_fragments' ), 10, 1 );
22 add_filter( 'woocommerce_cart_item_permalink', '__return_false' );
23 add_filter( 'wc_get_template', array( __CLASS__, 'mini_cart_template' ), 100, 5 );
24 }
25
26 /**
27 * Load classes for this module.
28 */
29 public static function load_classes() {
30 $classes = array(
31 'drawer-settings' => 'Orderable_Drawer_Settings',
32 'drawer-ajax' => 'Orderable_Drawer_Ajax',
33 );
34
35 foreach ( $classes as $file_name => $class_name ) {
36 require_once ORDERABLE_MODULES_PATH . 'drawer/class-' . $file_name . '.php';
37
38 $class_name::run();
39 }
40 }
41
42 /**
43 * Add drawer and overlay.
44 */
45 public static function add() {
46 if ( is_admin() || is_cart() || is_checkout() ) {
47 return;
48 }
49
50 include ORDERABLE_MODULES_PATH . 'drawer/templates/overlay.php';
51 include ORDERABLE_MODULES_PATH . 'drawer/templates/drawer.php';
52 include ORDERABLE_MODULES_PATH . 'drawer/templates/floating-cart.php';
53 }
54
55 /**
56 * Update cart count after adding to cart.
57 *
58 * @param array $fragments Array of HTML fragments.
59 *
60 * @return mixed
61 */
62 public static function cart_count_fragments( $fragments ) {
63 ob_start();
64
65 include ORDERABLE_MODULES_PATH . 'drawer/templates/floating-cart.php';
66
67 $fragments['.orderable-floating-cart'] = ob_get_clean();
68
69 return $fragments;
70 }
71
72 /**
73 * Replace mini cart template.
74 *
75 * @param string $template
76 * @param string $template_name
77 * @param array $args
78 * @param string $template_path
79 * @param string $default_path
80 *
81 * @return string
82 */
83 public static function mini_cart_template( $template, $template_name, $args, $template_path, $default_path ) {
84 if ( 'cart/mini-cart.php' !== $template_name ) {
85 return $template;
86 }
87
88 return ORDERABLE_PATH . 'woocommerce/cart/mini-cart.php';
89 }
90 }