* @return void * @since 4.0.0 */ public static function define_tables() { global $wpdb; $wpdb->waitlists = $wpdb->prefix . self::WAITLISTS_TABLE; $wpdb->tables[] = self::WAITLISTS_TABLE; $wpdb->waitlist_users = $wpdb->prefix . self::WAITLISTS_USERS_TABLE; $wpdb->tables[] = self::WAITLISTS_USERS_TABLE; $wpdb->waitlist_emails = $wpdb->prefix . self::WAITLISTS_EMAILS_TABLE; $wpdb->tables[] = self::WAITLISTS_EMAILS_TABLE; } /** * Must execute activation process? * Conditions: * - current version installed is older than current one; * - forced by query string; * - register_activation_hook triggered. * * @access protected static * @return boolean * @since 3.0.0 */ protected static function do_activation() { return version_compare( self::get_installed_version(), YITH_WCWTL_VERSION, '<' ) || ! empty( $_GET['yith_wcwtl_force_activation_process'] ) || 'yes' === get_option( 'yith_wcwtl_do_activation_process', 'no' ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended } /** * Get current installed plugin version. * If it's first installation get the current version to avoid processing version migration actions. * * @access protected static * @return string * @since 3.0.0 */ protected static function get_installed_version() { return get_option( 'yith_wcwtl_version', null ); } /** * Activation plugin process * * @return void * @since 3.0.0 */ public static function activate() { // Create tables. self::create_waitlists_table(); self::create_waitlists_users_table(); self::create_waitlists_emails_table(); // Update callbacks. foreach ( self::$updates as $version => $callbacks ) { if ( version_compare( self::get_installed_version(), $version, '<' ) ) { foreach ( $callbacks as $callback ) { self::$callback(); } } } update_option( 'yith_wcwtl_version', YITH_WCWTL_VERSION ); delete_option( 'yith_wcwtl_do_activation_process' ); do_action( 'yith_wcwtl_plugin_activation_process_completed' ); } /** * Create waitlists table * * @return void * @since 3.0.0 * @see dbDelta() */ public static function create_waitlists_table() { global $wpdb; // Check if dbDelta() exists. if ( ! function_exists( 'dbDelta' ) ) { require_once ABSPATH . 'wp-admin/includes/upgrade.php'; } $charset_collate = $wpdb->get_charset_collate(); $table_name = $wpdb->prefix . self::WAITLISTS_TABLE; $create = "CREATE TABLE $table_name ( list_id bigint(20) NOT NULL AUTO_INCREMENT, product_id bigint(20) NOT NULL, product_name VARCHAR(300) NOT NULL, variation_id bigint(20), created_date DATETIME NOT NULL DEFAULT '000-00-00 00:00:00', created_date_gmt DATETIME NOT NULL DEFAULT '000-00-00 00:00:00', counter_users int(20) NOT NULL DEFAULT 0, PRIMARY KEY (list_id) ) $charset_collate;"; dbDelta( $create ); } /** * Create waitlists users table * * @return void * @since 3.0.0 * @see dbDelta() */ public static function create_waitlists_users_table() { global $wpdb; // Check if dbDelta() exists. if ( ! function_exists( 'dbDelta' ) ) { require_once ABSPATH . 'wp-admin/includes/upgrade.php'; } $charset_collate = $wpdb->get_charset_collate(); $table_name = $wpdb->prefix . self::WAITLISTS_USERS_TABLE; $create = "CREATE TABLE $table_name ( ID bigint(20) NOT NULL AUTO_INCREMENT, list_id bigint(20) NOT NULL, user_email VARCHAR(100) NOT NULL, user_id bigint(20), registration_date DATETIME NOT NULL DEFAULT '000-00-00 00:00:00', registration_date_gmt DATETIME NOT NULL DEFAULT '000-00-00 00:00:00', PRIMARY KEY (ID) ) $charset_collate;"; dbDelta( $create ); } /** * Create waitlists emails table * * @return void * @since 3.0.0 * @see dbDelta() */ public static function create_waitlists_emails_table() { global $wpdb; // Check if dbDelta() exists. if ( ! function_exists( 'dbDelta' ) ) { require_once ABSPATH . 'wp-admin/includes/upgrade.php'; } $charset_collate = $wpdb->get_charset_collate(); $table_name = $wpdb->prefix . self::WAITLISTS_EMAILS_TABLE; $create = "CREATE TABLE $table_name ( email_id bigint(20) NOT NULL AUTO_INCREMENT, email_type VARCHAR(20) NOT NULL, list_id bigint(20) NOT NULL, product_id bigint(20) NOT NULL, earning double(15,4) NOT NULL, counter_users int(20) NOT NULL, sending_date DATETIME NOT NULL DEFAULT '000-00-00 00:00:00', sending_date_gmt DATETIME NOT NULL DEFAULT '000-00-00 00:00:00', PRIMARY KEY (email_id) ) $charset_collate;"; dbDelta( $create ); } /** * Schedule action to migrate waitlista data to tables * * @access public * * @param $offset * * @return void * @since 3.0.0 */ public static function schedule_update_300( $offset = 0 ) { WC()->queue()->schedule_single( time(), 'yith_wcwtl_update_waitlist_tables_300', array( 'offset' => $offset ) ); } /** * Update db options. * * @access public * * * @return void * @since 3.0.0 */ public static function update_plugin_options_300() { if ( defined( 'ICL_SITEPRESS_VERSION' ) ) { $wpml_options = array( 'woocommerce_yith_waitlist_mail_subscribe_optin_settings' => 'woocommerce_yith_waitlist_subscribe_optin_email_settings', 'woocommerce_yith_waitlist_mail_subscribe_settings' => 'woocommerce_yith_waitlist_subscribe_email_settings', 'woocommerce_yith_waitlist_mail_admin_settings' => 'woocommerce_yith_waitlist_admin_email_settings', 'woocommerce_yith_waitlist_mail_instock_settings' => 'woocommerce_yith_waitlist_instock_email_settings', 'woocommerce_yith_waitlist_mail_promotion_settings' => 'woocommerce_yith_waitlist_promotion_email_settings', ); foreach ( $wpml_options as $old => $new ) { $value = get_option( $old ); if ( '' !== $value ) { update_option( $new, $value ); } } } } /** * Process migration of data from postmeta to version 3.0.0 * * @access public * * @param $offset * * @return void * @since 3.0.0 */ public static function update_waitlist_tables_300( $offset = 0 ) { global $wpdb; $query = "SELECT post_id as product_id, meta_value as users FROM {$wpdb->postmeta} WHERE meta_key = '_yith_wcwtl_users_list' AND meta_value != 'a:0:{}' LIMIT 50 OFFSET {$offset}"; $waitlists = $wpdb->get_results( $query ); if ( ! empty( $waitlists ) ) { $yith_wcwtl_db = YITH_WCWTL_DB(); foreach ( $waitlists as $waitlist ) { $product = wc_get_product( $waitlist->product_id ); if( ! $product instanceof WC_Product){ continue; } if ( $product->is_type( 'variation' ) ) { $variation_id = $waitlist->product_id; $product_id = $product->get_parent_id(); } else { $variation_id = null; $product_id = $waitlist->product_id; } $product_name = wc_get_product( $product_id )->get_name(); $data = array( 'product_id' => $product_id, 'variation_id' => $variation_id, 'product_name' => $product_name, ); $list_id = $yith_wcwtl_db->insert( $wpdb->waitlists, $data ); $users = unserialize( $waitlist->users ); if ( is_array( $users ) ) { foreach ( $users as $user_email ) { $user_id = get_user_by( 'email', $user_email )->ID ?? null; $data = array( 'list_id' => $list_id, 'user_email' => $user_email, 'user_id' => $user_id, ); $yith_wcwtl_db->insert( $wpdb->waitlist_users, $data ); } } } $offset += 50; self::schedule_update_300( $offset ); } else { update_option( 'yith_wcwtl_migration300_completed', 'yes' ); } } /** * Alter YITH Waitlist Table during update * * @return void */ public static function alter_waitlist_table_3100() { global $wpdb; $table_name = $wpdb->prefix . self::WAITLISTS_TABLE; $query = "ALTER TABLE {$table_name} MODIFY COLUMN product_name VARCHAR(300) NOT NULL"; $wpdb->query( $query ); } } }
Fatal error: Uncaught Error: Class "YITH_VWCWTL_Install" not found in /home/valigeria/public_html/wp-content/plugins/yith-woocommerce-waiting-list-premium/init.php:216 Stack trace: #0 /home/valigeria/public_html/wp-content/plugins/yith-woocommerce-waiting-list-premium/init.php(184): yith_wcwtl_plugin_install() #1 /home/valigeria/public_html/wp-includes/class-wp-hook.php(324): yith_wcwtl_premium_init('') #2 /home/valigeria/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array) #3 /home/valigeria/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #4 /home/valigeria/public_html/wp-content/plugins/yith-woocommerce-waiting-list-premium/init.php(206): do_action('yith_wcwtl_prem...') #5 /home/valigeria/public_html/wp-includes/class-wp-hook.php(324): yith_wcwtl_premium_install('') #6 /home/valigeria/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #7 /home/valigeria/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #8 /home/valigeria/public_html/wp-settings.php(550): do_action('plugins_loaded') #9 /home/valigeria/public_html/wp-config.php(111): require_once('/home/valigeria...') #10 /home/valigeria/public_html/wp-load.php(50): require_once('/home/valigeria...') #11 /home/valigeria/public_html/wp-blog-header.php(13): require_once('/home/valigeria...') #12 /home/valigeria/public_html/index.php(17): require('/home/valigeria...') #13 {main} thrown in /home/valigeria/public_html/wp-content/plugins/yith-woocommerce-waiting-list-premium/init.php on line 216