2022-12-06 18:16:40 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Plugin Name: {{title}}
|
|
|
|
{{#description}}
|
|
|
|
* Description: {{description}}
|
|
|
|
{{/description}}
|
2022-12-14 15:35:22 +00:00
|
|
|
* Version: {{version}}
|
2022-12-06 18:16:40 +00:00
|
|
|
{{#author}}
|
|
|
|
* Author: {{author}}
|
|
|
|
{{/author}}
|
2024-04-09 08:50:15 +00:00
|
|
|
* Author URI: https://woocommerce.com
|
2022-12-06 18:16:40 +00:00
|
|
|
* 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;
|
|
|
|
|
2022-12-14 15:35:22 +00:00
|
|
|
// phpcs:disable WordPress.Files.FileName
|
|
|
|
|
2022-12-06 18:16:40 +00:00
|
|
|
/**
|
2022-12-14 15:35:22 +00:00
|
|
|
* WooCommerce fallback notice.
|
|
|
|
*
|
|
|
|
* @since {{version}}
|
2022-12-06 18:16:40 +00:00
|
|
|
*/
|
2022-12-14 15:35:22 +00:00
|
|
|
function {{slugSnakeCase}}_missing_wc_notice() {
|
|
|
|
/* translators: %s WC download URL link. */
|
2024-04-09 08:50:15 +00:00
|
|
|
echo '<div class="error"><p><strong>' . sprintf( esc_html__( '{{title}} requires WooCommerce to be installed and active. You can download %s here.', '{{slugSnakeCase}}' ), '<a href="https://woocommerce.com/" target="_blank">WooCommerce</a>' ) . '</strong></p></div>';
|
2022-12-14 15:35:22 +00:00
|
|
|
}
|
2022-12-06 18:16:40 +00:00
|
|
|
|
2022-12-14 15:35:22 +00:00
|
|
|
register_activation_hook( __FILE__, '{{slugSnakeCase}}_activate' );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Activation hook.
|
|
|
|
*
|
|
|
|
* @since {{version}}
|
|
|
|
*/
|
|
|
|
function {{slugSnakeCase}}_activate() {
|
|
|
|
if ( ! class_exists( 'WooCommerce' ) ) {
|
|
|
|
add_action( 'admin_notices', '{{slugSnakeCase}}_missing_wc_notice' );
|
|
|
|
return;
|
2022-12-06 18:16:40 +00:00
|
|
|
}
|
2022-12-14 15:35:22 +00:00
|
|
|
}
|
2022-12-06 18:16:40 +00:00
|
|
|
|
2022-12-14 15:35:22 +00:00
|
|
|
if ( ! class_exists( '{{slugSnakeCase}}' ) ) :
|
2022-12-06 18:16:40 +00:00
|
|
|
/**
|
2022-12-14 15:35:22 +00:00
|
|
|
* The {{slugSnakeCase}} class.
|
2022-12-06 18:16:40 +00:00
|
|
|
*/
|
2022-12-14 15:35:22 +00:00
|
|
|
class {{slugSnakeCase}} {
|
|
|
|
/**
|
|
|
|
* This class instance.
|
|
|
|
*
|
|
|
|
* @var \{{slugSnakeCase}} single instance of this class.
|
|
|
|
*/
|
|
|
|
private static $instance;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*/
|
|
|
|
public function __construct() {
|
|
|
|
if ( is_admin() ) {
|
|
|
|
new Setup();
|
|
|
|
}
|
2022-12-06 18:16:40 +00:00
|
|
|
}
|
|
|
|
|
2022-12-14 15:35:22 +00:00
|
|
|
/**
|
|
|
|
* Cloning is forbidden.
|
|
|
|
*/
|
|
|
|
public function __clone() {
|
|
|
|
wc_doing_it_wrong( __FUNCTION__, __( 'Cloning is forbidden.', '{{slugSnakeCase}}' ), $this->version );
|
|
|
|
}
|
2022-12-06 18:16:40 +00:00
|
|
|
|
2022-12-14 15:35:22 +00:00
|
|
|
/**
|
|
|
|
* Unserializing instances of this class is forbidden.
|
|
|
|
*/
|
|
|
|
public function __wakeup() {
|
|
|
|
wc_doing_it_wrong( __FUNCTION__, __( 'Unserializing instances of this class is forbidden.', '{{slugSnakeCase}}' ), $this->version );
|
2022-12-06 18:16:40 +00:00
|
|
|
}
|
|
|
|
|
2022-12-14 15:35:22 +00:00
|
|
|
/**
|
|
|
|
* Gets the main instance.
|
|
|
|
*
|
|
|
|
* Ensures only one instance can be loaded.
|
|
|
|
*
|
|
|
|
* @return \{{slugSnakeCase}}
|
|
|
|
*/
|
|
|
|
public static function instance() {
|
|
|
|
|
|
|
|
if ( null === self::$instance ) {
|
|
|
|
self::$instance = new self();
|
|
|
|
}
|
2022-12-06 18:16:40 +00:00
|
|
|
|
2022-12-14 15:35:22 +00:00
|
|
|
return self::$instance;
|
2022-12-06 18:16:40 +00:00
|
|
|
}
|
2022-12-14 15:35:22 +00:00
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
|
|
|
add_action( 'plugins_loaded', '{{slugSnakeCase}}_init', 10 );
|
2022-12-06 18:16:40 +00:00
|
|
|
|
2022-12-14 15:35:22 +00:00
|
|
|
/**
|
|
|
|
* Initialize the plugin.
|
|
|
|
*
|
|
|
|
* @since {{version}}
|
|
|
|
*/
|
|
|
|
function {{slugSnakeCase}}_init() {
|
|
|
|
load_plugin_textdomain( '{{slugSnakeCase}}', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
|
|
|
|
|
|
|
|
if ( ! class_exists( 'WooCommerce' ) ) {
|
|
|
|
add_action( 'admin_notices', '{{slugSnakeCase}}_missing_wc_notice' );
|
|
|
|
return;
|
2022-12-06 18:16:40 +00:00
|
|
|
}
|
|
|
|
|
2022-12-14 15:35:22 +00:00
|
|
|
{{slugSnakeCase}}::instance();
|
|
|
|
|
|
|
|
}
|