woocommerce/packages/js/create-extension/$slug.php.mustache

85 lines
1.7 KiB
Plaintext

<?php
/**
* Plugin Name: {{title}}
{{#description}}
* Description: {{description}}
{{/description}}
* Version: {{version}}
{{#author}}
* Author: {{author}}
{{/author}}
* Author URI: https://woocommerce.com
* Text Domain: {{textdomain}}
* Domain Path: /languages
*
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package {{namespace}}
*/
defined( 'ABSPATH' ) || exit;
if ( ! defined( 'MAIN_PLUGIN_FILE' ) ) {
define( 'MAIN_PLUGIN_FILE', __FILE__ );
}
require_once plugin_dir_path( __FILE__ ) . '/vendor/autoload_packages.php';
use {{slugPascalCase}}\Admin\Setup;
/**
* {{slugPascalCase}} class.
*/
class {{slugPascalCase}} {
/**
* This class instance.
*
* @var \{{slugPascalCase}} single instance of this class.
*/
private static $instance;
/**
* Constructor.
*/
public function __construct() {
add_action( 'plugins_loaded', array( $this, 'init' ) );
}
/**
* Init the plugin once WP is loaded.
*/
public function init() {
// If WooCommerce does not exist, deactivate plugin.
if ( ! class_exists( 'WooCommerce' ) ) {
deactivate_plugins( plugin_basename( __FILE__ ) );
}
if ( is_admin() ) {
// Load plugin translations.
$plugin_rel_path = basename( dirname( __FILE__ ) ) . '/languages'; /* Relative to WP_PLUGIN_DIR */
load_plugin_textdomain( '{{slug}}', false, $plugin_rel_path );
new Setup();
}
}
/**
* Gets the main instance.
*
* Ensures only one instance can be loaded.
*
* @return \{{slugPascalCase}}
*/
public static function instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
}
{{slugPascalCase}}::instance();