Нема описа

woo-custom-emails-per-product.php 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * Plugin Name: Woo Custom Emails Per Product
  4. * Description: Add custom content per product into the default WooCommerce customer receipt email template.
  5. * Version: 2.2.9
  6. * Author: Alex Mustin
  7. * Author URI: http://alexmustin.com
  8. * Text Domain: woo_custom_emails_domain
  9. * License: GPL-2.0+
  10. * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
  11. * WC requires at least: 4.9.2
  12. * WC tested up to: 5.2.2
  13. *
  14. * @package woo_custom_emails_domain
  15. */
  16. // Exit if not WordPress.
  17. if ( ! defined( 'WPINC' ) ) {
  18. die;
  19. }
  20. // Exit if accessed directly.
  21. if ( ! defined( 'ABSPATH' ) ) {
  22. exit;
  23. }
  24. // Define Globals.
  25. define( 'WCE_PLUGIN_VERSION', '2.2.9' );
  26. // Add a check for WooCommerce on plugin activation.
  27. register_activation_hook( __FILE__, 'woo_custom_emails_activate_check_for_woo' );
  28. /**
  29. * Checks for WooCommerce on plugin activation.
  30. */
  31. function woo_custom_emails_activate_check_for_woo() {
  32. if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
  33. $woo_plugin_url = esc_url( 'https://wordpress.org/plugins/woocommerce/' );
  34. $text_string = '';
  35. $text_string .= sprintf( '%1$s%2$s%3$s', '<h2>', esc_html__( 'Oops!', 'woo_custom_emails_domain' ), '</h2>' );
  36. $text_string .= sprintf( '%1$s%2$sWooCommerce%3$s%4$s%5$s', '<p>', '<a href="' . $woo_plugin_url . '" target="_blank">', '</a>', esc_html__( ' is required for this plugin.', 'woo_custom_emails_domain' ), '</p>' );
  37. $text_string .= sprintf( '%1$s%2$s%3$s', '<p>', esc_html__( 'Please install and activate WooCommerce and try again.', 'woo_custom_emails_domain' ), '</p>' );
  38. wp_die( $text_string ); // phpcs:ignore
  39. }
  40. }
  41. // Add a custom Database Table on plugin activation.
  42. register_activation_hook( __FILE__, 'woo_custom_emails_add_db_table' );
  43. function woo_custom_emails_add_db_table() {
  44. // Global var for WP db.
  45. global $wpdb;
  46. // Collation setting.
  47. $charset_collate = $wpdb->get_charset_collate();
  48. // Custom Table name.
  49. $table_name = $wpdb->prefix . 'wcepp_messages';
  50. // SQL statement.
  51. $sql = "CREATE TABLE `$table_name` (
  52. `id` int(9) NOT NULL AUTO_INCREMENT,
  53. `product_id` int(9) DEFAULT NULL,
  54. `msg_processing` varchar(220) DEFAULT NULL,
  55. `msg_processing_loc` varchar(220) DEFAULT NULL,
  56. `msg_onhold` varchar(220) DEFAULT NULL,
  57. `msg_onhold_loc` varchar(220) DEFAULT NULL,
  58. `msg_completed` varchar(220) DEFAULT NULL,
  59. `msg_completed_loc` varchar(220) DEFAULT NULL,
  60. PRIMARY KEY(id)
  61. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  62. ";
  63. // If the table does not exist, run the SQL statement using dbDelta() function.
  64. if ( $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) != $table_name ) {
  65. require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
  66. dbDelta( $sql );
  67. }
  68. }
  69. // Include required files.
  70. require_once plugin_dir_path( __FILE__ ) . 'includes/class-woo-custom-emails-per-product.php';
  71. require_once plugin_dir_path( __FILE__ ) . 'admin/class-woo-custom-emails-per-product-cpt.php';
  72. require_once plugin_dir_path( __FILE__ ) . 'admin/class-woo-custom-emails-column-display.php';
  73. require_once plugin_dir_path( __FILE__ ) . 'admin/class-woo-custom-emails-per-product-admin-settings.php';
  74. // require_once plugin_dir_path( __FILE__ ) . 'admin/class-woo-custom-emails-assigned-messages.php';
  75. require_once plugin_dir_path( __FILE__ ) . 'includes/class-woo-custom-emails-output.php';
  76. /**
  77. * Runs main plugin functions.
  78. */
  79. function run_woo_custom_emails_per_product() {
  80. // Create a new object.
  81. $woo_custom_emails_domain = new Woo_Custom_Emails_Per_Product();
  82. // Do the 'run' function inside our object.
  83. $woo_custom_emails_domain->run();
  84. // Create a new output object.
  85. new Woo_Custom_Emails_Output();
  86. }
  87. // Go!
  88. run_woo_custom_emails_per_product();