/* Plugin Name: MoreAffiliate Lite Plugin URI: https://morewptools.com/product/moreaffiliate Description: A modern responsive WooCommerce dashboard. Upgrade to Pro for affiliate features and support ticket system. Version: 1.0.1 Author: MoreWPTools Author URI: https://morewptools.com Text Domain: moreaffiliate-lite License: GPLv2 or later */ if (!defined('ABSPATH')) { exit; } // Define constants define('MOREAFFILIATE_LITE', true); define('MOREAFFILIATE_VERSION', '1.0.1'); define('MOREAFFILIATE_DIR', plugin_dir_path(__FILE__)); define('MOREAFFILIATE_URL', plugin_dir_url(__FILE__)); // Load essential classes require_once MOREAFFILIATE_DIR . 'includes/class-moreaffiliate-core.php'; require_once MOREAFFILIATE_DIR . 'includes/class-moreaffiliate-tracking.php'; require_once MOREAFFILIATE_DIR . 'includes/class-moreaffiliate-admin.php'; // Initialize the plugin function moreaffiliate_init() { // Check if WooCommerce is active if (!class_exists('WooCommerce')) { add_action('admin_notices', 'moreaffiliate_missing_wc_notice'); return; } // Proceed with plugin initialization new MoreAffiliate_Core(); new MoreAffiliate_Tracking(); new MoreAffiliate_Admin(); } add_action('plugins_loaded', 'moreaffiliate_init', 10); // Load text domain function moreaffiliate_load_textdomain() { load_plugin_textdomain('moreaffiliate-lite', false, dirname(plugin_basename(__FILE__)) . '/languages/'); } add_action('plugins_loaded', 'moreaffiliate_load_textdomain'); // Admin notice if WooCommerce is not active function moreaffiliate_missing_wc_notice() { echo '

MoreAffiliate requires WooCommerce to be installed and active.

'; } // Deactivation feedback enqueue function moreaffiliate_enqueue_deactivation_scripts() { $screen = get_current_screen(); if ($screen && $screen->id === 'plugins') { wp_enqueue_style('moreaffiliate-feedback-css', MOREAFFILIATE_URL . 'assets/css/feedback.css', [], MOREAFFILIATE_VERSION); wp_enqueue_script('moreaffiliate-feedback-js', MOREAFFILIATE_URL . 'assets/js/feedback.js', ['jquery'], MOREAFFILIATE_VERSION, true); wp_localize_script('moreaffiliate-feedback-js', 'moreaffiliate_feedback', [ 'ajax_url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('moreaffiliate_deactivation_feedback'), 'plugin' => plugin_basename(__FILE__) ]); } } add_action('admin_enqueue_scripts', 'moreaffiliate_enqueue_deactivation_scripts'); // Handle feedback submission via AJAX and send email function moreaffiliate_submit_feedback() { check_ajax_referer('moreaffiliate_deactivation_feedback', 'nonce'); $reason = sanitize_text_field($_POST['reason'] ?? ''); $details = sanitize_textarea_field($_POST['details'] ?? ''); $site_url = get_site_url(); $timestamp = current_time('mysql'); $to = 'support@morewptools.com'; $subject = 'MoreAffiliate Deactivation Feedback'; $message = "A user has deactivated MoreAffiliate. Here’s their feedback:\n\n"; $message .= "Reason: $reason\n"; $message .= "Details: $details\n"; $message .= "Site URL: $site_url\n"; $message .= "Timestamp: $timestamp\n"; $headers = ['Content-Type: text/plain; charset=UTF-8']; $sent = wp_mail($to, $subject, $message, $headers); if ($sent) { wp_send_json_success(); } else { wp_send_json_error(['message' => 'Failed to send feedback. Deactivation will proceed.']); } } add_action('wp_ajax_moreaffiliate_submit_feedback', 'moreaffiliate_submit_feedback'); function moreaffiliate_override_wc_templates($template, $template_name, $template_path) { if ($template_name === 'myaccount/orders.php') { $custom_template = MOREAFFILIATE_DIR . 'templates/myaccount/orders.php'; if (file_exists($custom_template)) { return $custom_template; } } return $template; } add_filter('wc_get_template', 'moreaffiliate_override_wc_templates', 10, 3); Post Ads | NNUForum – NNUForum
Scroll to Top