| 1 |
<?php |
| 2 |
|
| 3 |
namespace HelloPlus\Modules\Admin\Components; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; // Exit if accessed directly. |
| 7 |
} |
| 8 |
|
| 9 |
class Admin_Controller { |
| 10 |
|
| 11 |
public function plugin_row_meta( $plugin_meta, $plugin_file ) { |
| 12 |
if ( HELLOPLUS_PLUGIN_BASE === $plugin_file ) { |
| 13 |
$row_meta = [ |
| 14 |
'changelog' => '<a href="#" id="hello-plus-whats-new-link" aria-label="' . esc_attr( esc_html__( 'Changelog', 'hello-plus' ) ) . '" >' . esc_html__( 'Changelog', 'hello-plus' ) . '</a><div id="hello-plus-whats-new"></div>', |
| 15 |
]; |
| 16 |
|
| 17 |
$plugin_meta = array_merge( $plugin_meta, $row_meta ); |
| 18 |
} |
| 19 |
|
| 20 |
return $plugin_meta; |
| 21 |
} |
| 22 |
|
| 23 |
public function maybe_init_cart() { |
| 24 |
if ( ! class_exists( 'WooCommerce' ) ) { |
| 25 |
return; |
| 26 |
} |
| 27 |
|
| 28 |
$has_cart = is_a( WC()->cart, 'WC_Cart' ); |
| 29 |
if ( ! $has_cart ) { |
| 30 |
$session_class = apply_filters( 'woocommerce_session_handler', 'WC_Session_Handler' ); |
| 31 |
WC()->session = new $session_class(); |
| 32 |
WC()->session->init(); |
| 33 |
WC()->cart = new \WC_Cart(); |
| 34 |
WC()->customer = new \WC_Customer( get_current_user_id(), true ); |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
public function __construct() { |
| 40 |
add_filter( 'plugin_row_meta', [ $this, 'plugin_row_meta' ], 10, 2 ); |
| 41 |
add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'maybe_init_cart' ] ); |
| 42 |
} |
| 43 |
} |
| 44 |
|