Skip to content
Snippets Groups Projects
Select Git revision
  • d1c9beef2e40fdf3e78473c121ecb54f3c5750a1
  • master default protected
  • fix/deprecated_functions
  • devel
  • feat/translations
  • feat/upgrade_to_pro_url
  • feat/lang
  • bugfix/require-interface
  • bugfix/require-once-error
  • feature/activation-hooks
  • feature/template-loader
  • feature/template-renderer
  • feature/plugin-activation
  • feature/hookable-object
  • feature/builder-pattern
  • 2.1.2
  • 2.1.1
  • 2.1.0
  • 2.0.0
  • 2.0.0-beta1
  • 1.4.4
  • 1.4.3
  • 1.4.2
  • 1.4.1
  • 1.4
  • 1.3.3
  • 1.3.2
  • 1.3.1
  • 1.3.0
  • 1.2.0
  • 1.1
  • 1.0
32 results

AbstractPlugin.php

Blame
  • AbstractPlugin.php 3.47 KiB
    <?php
    
    namespace WPDesk\PluginBuilder\Plugin;
    
    /**
     * Base plugin class for WP Desk plugins.
     *
     * *************************************************************
     * * Important! This class should be not modified!             *
     * * This class is loaded at startup from first loaded plugin! *
     * *************************************************************
     *
     * @author Grzegorz, Dyszczo
     *
     */
    abstract class AbstractPlugin implements \WPDesk_Translable {
    
    	/** @var \WPDesk_Plugin_Info */
    	protected $plugin_info;
    
    	/** @var string */
    	protected $plugin_namespace;
    
    	/** @var string */
    	protected $plugin_url;
    
    	/** @var string */
    	protected $docs_url;
    
    	/** @var string */
    	protected $settings_url;
    
    	/**
    	 * Support URL.
    	 *
    	 * @var string
    	 */
    	protected $support_url;
    
    	/**
    	 * AbstractPlugin constructor.
    	 *
    	 * @param \WPDesk_Plugin_Info $plugin_info
    	 */
    	public function __construct( $plugin_info ) {
    		$this->plugin_info      = $plugin_info;
    		$this->plugin_namespace = strtolower( $plugin_info->get_plugin_dir() );
    	}
    
    	public function init() {
    		$this->init_base_variables();
    		$this->hooks();
    	}
    
    	public function init_base_variables() {
    		$this->plugin_url = plugin_dir_url( $this->plugin_info->get_plugin_dir() );
    	}
    
    	/**
    	 * @return void
    	 */
    	protected function hooks() {
    		add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] );
    
    		add_action( 'wp_enqueue_scripts', [ $this, 'wp_enqueue_scripts' ] );
    
    		add_action( 'plugins_loaded', [ $this, 'load_plugin_text_domain' ] );
    		add_filter( 'plugin_action_links_' . plugin_basename( $this->get_plugin_file_path() ), [
    			$this,
    			'links_filter'