• Fatal error: Uncaught Error: Class ‘ASLQ\Installer’ not found in /home/tc/public_html/wp-content/plugins/ajax-shop-loop-quantity-for-woocommerce/ajax-shop-loop-qty.php:78 Stack trace: #0 /home/tc/public_html/wp-includes/class-wp-hook.php(303): Ajax_Shop_Loop_Qty->activate() #1 /home/tc/public_html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters() #2 /home/tc/public_html/wp-includes/plugin.php(470): WP_Hook->do_action() #3 /home/tc/public_html/wp-admin/plugins.php(193): do_action() #4 {main} thrown in /home/tc/public_html/wp-content/plugins/ajax-shop-loop-quantity-for-woocommerce/ajax-shop-loop-qty.php on line 78

Viewing 1 replies (of 1 total)
  • I was able to get around this error by moving the Installer class into ajax-shop-loop-qty.php. This is my ajax-shop-loop-qty.php file:

    <?php
    
    /**
     * Plugin Name:       Ajax Shop Loop Quantity for WooCommerce
     * Plugin URI:        https://ww.wp.xz.cn/plugins/ajax-shop-loop-quantity-for-woocommerce
     * Description:       A WordPress plugin to enable ajax quantity field in shop loop items for woocommerce.
     * Version:           1.0
     * Author:            Apple Mahmood
     * Author URI:        https://www.applemahmood.com
     * License:           GPL v2 or later
     * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
     * Text Domain:       ajax-shop-loop-qty
     * Domain Path:       /languages
     */
    namespace ASLQ;
    
    /**
     * The Installer class
     */
    class Installer
    {
      /**
       * Run the installer
       *
       * @return void
       */
      public function run()
      {
        $this->add_version();
        set_transient('aslq_show_admin_notice', true, 5);
      }
    
      public function add_version()
      {
        $installed = get_option('ASLQ_INSTALLED');
        if (!$installed) {
          update_option("ASLQ_INSTALLED", time());
        }
    
        update_option("ASLQ_VERSION", ASLQ_VERSION);
      }
    }
    if (!defined('ABSPATH')) {
      exit;
    }
    
    require_once __DIR__ . "/vendor/autoload.php";
    
    /**
     * Main class for the plugin
     */
    final class Ajax_Shop_Loop_Qty
    {
    
      const version = 1.0;
      /**
       * Class Constructor
       */
      private function __construct()
      {
        $this->define_constants();
    
        register_activation_hook(ASLQ_FILE, [$this, 'activate']);
    
        add_action('plugins_loaded', [$this, 'plugin_init']);
      }
      /**
       * Singletone instance function
       *
       * @return \ASLQ
       */
      public static function init()
      {
        static $instance = false;
    
        if (!$instance) {
          $instance = new self();
        }
    
        return $instance;
      }
    
      /**
       * Defining necessary constants
       *
       * @return void
       */
      public function define_constants()
      {
        define('ASLQ_VERSION', self::version);
        define('ASLQ_NAME', 'Ajax Shop Loop Quantity');
        define('ASLQ_FILE', __FILE__);
        define('ASLQ_PATH', __DIR__);
        define('ASLQ_URL', plugins_url('', ASLQ_FILE));
        define('ASLQ_ASSETS', ASLQ_URL . '/assets');
      }
    
      /**
       * Upon activating the plugin
       *
       * @return void
       */
      public function activate()
      {
        $installer = new \ASLQ\Installer();
        $installer->run();
      }
    
      public function plugin_init()
      {
        if (class_exists('WooCommerce')) {
          if (is_admin()) {
            new \ASLQ\Admin();
          } else {
            new \ASLQ\Frontend();
          }
        } else {
          add_action('admin_notices', [$this, 'aslq_admin_notice_error']);
        }
      }
    
      public function aslq_admin_notice_error()
      {
      ?>
        <div class="notice notice-error is-dismissible">
          <p><?php
              printf(
                esc_html__('%1$s%2$s%3$s plugin requires %4$s to be installed and active', 'ajax-shop-loop-qty'),
                '<strong>',
                ASLQ_NAME,
                '</strong>',
                '<a target="_blank" href="https://en-ca.ww.wp.xz.cn/plugins/woocommerce/"><strong>WooCommerce</strong></a>'
              );
              ?></p>
        </div>
      <?php
      }
    }
    
    /**
     * Initializing the plugin
     *
     * @return \ASLQ
     */
    function ASLQ()
    {
      return Ajax_Shop_Loop_Qty::init();
    }
    
    /**
     * Starting the plugin
     */
    ASLQ();
    
Viewing 1 replies (of 1 total)

The topic ‘Plugin Triggers a Fatal Error on Install’ is closed to new replies.