HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wpamazingsecret/wp-content/plugins_/woo-cart-weight/src/Plugin.php
<?php
/**
 * Plugin main class.
 *
 * @package WPDesk\WooCommerceCartWeight
 */

namespace WPDesk\WooCommerceCartWeight;

use WCWeightVendor\Octolize\Tracker\OptInNotice\ShouldDisplayNever;
use WCWeightVendor\Octolize\Tracker\TrackerInitializer;
use WCWeightVendor\WPDesk\PluginBuilder\Plugin\AbstractPlugin;
use WCWeightVendor\WPDesk\PluginBuilder\Plugin\HookableCollection;
use WCWeightVendor\WPDesk\PluginBuilder\Plugin\HookableParent;
use WCWeightVendor\WPDesk\View\Renderer\Renderer;
use WCWeightVendor\WPDesk\View\Renderer\SimplePhpRenderer;
use WCWeightVendor\WPDesk\View\Resolver\ChainResolver;
use WCWeightVendor\WPDesk\View\Resolver\DirResolver;
use WCWeightVendor\WPDesk\View\Resolver\WPThemeResolver;
use WPDesk\WooCommerceCartWeight\Renderer\CartWeightRenderer;
use WPDesk\WooCommerceCartWeight\Renderer\CheckoutWeightRenderer;
use WPDesk\WooCommerceCartWeight\Renderer\WidgetWeightRenderer;

/**
 * Main plugin class. The most important flow decisions are made here.
 *
 * @package WPDesk\WooCommerceCartWeight
 */
class Plugin extends AbstractPlugin implements HookableCollection {

	use HookableParent;

	/**
	 * Define plugin namespace for backward compatibility.
	 */
	const PLUGIN_NAMESPACE = 'woo-cart-weight';

	/**
	 * Plugin path
	 *
	 * @var string
	 */
	private $plugin_path;

	/**
	 * Template path
	 *
	 * @var string
	 */
	private $template_path;

	/**
	 * Renderer.
	 *
	 * @var Renderer
	 */
	private $renderer;

	/**
	 * Plugin constructor.
	 *
	 * @param \WCWeightVendor\WPDesk_Plugin_Info $plugin_info Plugin info.
	 */
	public function __construct( \WCWeightVendor\WPDesk_Plugin_Info $plugin_info ) {
		$this->plugin_info = $plugin_info;
		parent::__construct( $plugin_info );
	}

	/**
	 * Init base variables for plugin
	 */
	public function init_base_variables() {
		$this->plugin_url         = $this->plugin_info->get_plugin_url();
		$this->plugin_namespace   = self::PLUGIN_NAMESPACE;
		$this->plugin_path        = $this->plugin_info->get_plugin_dir();
		$this->template_path      = $this->plugin_info->get_text_domain();
	}

	/**
	 * Init plugin
	 */
	public function init() {
		$this->init_base_variables();
		$this->init_renderer();
		$this->init_tracker();
		$this->load_dependencies();
		parent::init();
	}

	/**
	 * Init tracker.
	 *
	 * @return void
	 */
	private function init_tracker() {
		$this->add_hookable( TrackerInitializer::create_from_plugin_info( $this->plugin_info, new ShouldDisplayNever() ) );
	}

	/**
	 * Init renderer.
	 *
	 * @return void
	 */
	private function init_renderer() {
		$resolver = new ChainResolver();
		$resolver->appendResolver( new WPThemeResolver( $this->template_path ) );
		$resolver->appendResolver( new DirResolver( trailingslashit( $this->plugin_path ) . 'templates' ) );
		$this->renderer = new SimplePhpRenderer( $resolver );
	}

	/**
	 * Load dependencies.
	 *
	 * @return void
	 */
	public function load_dependencies() {
	}

	/**
	 * Fires hooks
	 *
	 * @return void
	 */
	public function hooks() {
		parent::hooks();
		add_action( 'woocommerce_init', [ $this, 'init_renderers' ] );
		$this->hooks_on_hookable_objects();
	}

	/**
	 * Init renderers.
	 *
	 * @return void
	 */
	public function init_renderers() {
		$cart = WC()->cart;
		if ( null !== $cart ) {
			( new CartWeightRenderer( $this->renderer, $cart ) )->hooks();
			( new CheckoutWeightRenderer( $this->renderer, $cart ) )->hooks();
			( new WidgetWeightRenderer( $this->renderer, $cart ) )->hooks();
		}
	}

	/**
	 * Initialize plugin admin links. This is a hook function. Do not execute directly.
	 *
	 * @param string[] $links
	 *
	 * @return string[]
	 */
	public function links_filter( $links ) {
		$support_link = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/support/' : 'https://octol.io/cart-weight-support';

		$plugin_links = [ '<a target="_blank" href="' . esc_url( $support_link ) . '">' . __( 'Support', 'woo-cart-weight' ) . '</a>' ];

		return array_merge( $plugin_links, $links );
	}
}