Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b9f5f93
Multisite support added for wp_users & wp_usermeta table
shewa12 May 21, 2026
4c82df5
Merge branch '4.0.0-dev' of https://github.com/themeum/tutor into mul…
shewa12 May 22, 2026
6367bc3
Merge branch '4.0.0-dev' of https://github.com/themeum/tutor into mul…
shewa12 Jun 2, 2026
1c931f1
Refactored the base prefix settings mechanism
shewa12 Jun 3, 2026
462262a
Removed unsed global wpdb
shewa12 Jun 4, 2026
3619f2c
Refactored the is_base_table method
shewa12 Jun 4, 2026
f94656c
Refactored the is_base_table method
shewa12 Jun 4, 2026
9317660
Table name with alias case handled
shewa12 Jun 4, 2026
702c06a
Refactor is_plugin_active method to make it compitable for single & m…
shewa12 Jun 4, 2026
6254152
Removed the redundant typecast
shewa12 Jun 4, 2026
cea93eb
Doc comment updated
shewa12 Jun 4, 2026
1043768
Plugin active & null check added
shewa12 Jun 4, 2026
518a5c9
Explicit prefix removed
shewa12 Jun 4, 2026
a7426a9
Merge branch '4.0.0-dev' of https://github.com/themeum/tutor into mul…
shewa12 Jun 4, 2026
a875dbf
Merge branch '4.0.0-dev' of https://github.com/themeum/tutor into mul…
shewa12 Jun 10, 2026
e7c1063
Merge branch '4.0.0-dev' of https://github.com/themeum/tutor into mul…
shewa12 Jun 11, 2026
d90b84e
Merge branch '4.0.0-dev' of https://github.com/themeum/tutor into mul…
shewa12 Jun 15, 2026
8c0f43c
Check login cookie before usage
shewa12 Jun 16, 2026
4ba746d
Revert "Check login cookie before usage"
shewa12 Jun 17, 2026
7704af2
Deployment workflow added
shewa12 Jun 18, 2026
1a448cb
PHPStan workflow removed
shewa12 Jun 18, 2026
057c590
Fix run command issue
shewa12 Jun 18, 2026
8db4963
Node version updated
shewa12 Jun 19, 2026
109190f
Node version updated
shewa12 Jun 19, 2026
4dcb965
Removed staging build & deploy
shewa12 Jun 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/demo-build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build and Deploy

on:
push:
branches:
- multisite

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Extract version number
id: get_version
run: |
version=$(grep -Po 'Version:\s*\K[\d.]+' tutor.php)
echo "VERSION_NUMBER=$version" >> $GITHUB_ENV
echo "ZIP_PATH=tutor-${version}.zip" >> $GITHUB_ENV

- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: Install Composer
run: sudo apt-get update && sudo apt-get install -y composer

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build project
run: pnpm run build-dev

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: build-artifact
path: ${{ env.ZIP_PATH }}

- name: Setup SSH
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.DEMO_SSH_PRIVATE_KEY }}

- name: Add remote server to known hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan -H 172.105.64.114 >> ~/.ssh/known_hosts

- name: Transfer file to remote
run: scp ${{ env.ZIP_PATH }} root@172.105.64.114:/var/www/tutor-demo/wp-content/plugins

- name: UNZIP file
run: |
ssh root@172.105.64.114 << 'EOF'
rm -rf /var/www/tutor-demo/wp-content/plugins/tutor
unzip -o /var/www/tutor-demo/wp-content/plugins/${{ env.ZIP_PATH }} -d /var/www/tutor-demo/wp-content/plugins
EOF
22 changes: 0 additions & 22 deletions .github/workflows/phpstan.yml

This file was deleted.

70 changes: 0 additions & 70 deletions .github/workflows/staging-build-and-deploy.yml

This file was deleted.

19 changes: 11 additions & 8 deletions classes/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,14 +525,20 @@ public function is_monetize_by_tutor() {
*
* @since 1.0.0
*
* @param string $plugin_path plugin path.
* @param string|array $plugin_path plugin path.
*
* @return boolean
*/
public function is_plugin_active( $plugin_path ) {
$activated_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
$depends = is_array( $plugin_path ) ? $plugin_path : array( $plugin_path );
$has_plugin = count( array_intersect( $depends, $activated_plugins ) ) == count( $depends );
$depends = is_array( $plugin_path ) ? $plugin_path : array( $plugin_path );
$has_plugin = true;

foreach ( $depends as $plugin ) {
if ( ! is_plugin_active( $plugin ) ) {
$has_plugin = false;
break;
}
}

return $has_plugin;
}
Expand Down Expand Up @@ -576,10 +582,7 @@ public function is_addon_enabled( $basename ) {
* @return bool
*/
public function has_bp() {
$activated_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
$depends = array( 'buddypress/bp-loader.php' );
$has_bp = count( array_intersect( $depends, $activated_plugins ) ) == count( $depends );
return $has_bp;
return $this->is_plugin_active( 'buddypress/bp-loader.php' );
}

/**
Expand Down
37 changes: 35 additions & 2 deletions helpers/QueryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1251,13 +1251,45 @@ public static function get_last_query(){
*
* @since 3.7.0
*

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update comment

* @since 4.0.0 $table_name param added
*
* @param string $table_name Table name.
*
* @return string
*/
public static function get_table_prefix() {
public static function get_table_prefix( $table_name ) {
global $wpdb;

if ( is_multisite() && self::is_base_table( $table_name ) ) {
return $wpdb->base_prefix;
}

return $wpdb->prefix;
}

/**
* Check if accessing the base tables
*
* @since 4.0.0
*
* @param string $table_name Table name.
*
* @return bool
*/
private static function is_base_table( string $table_name ): bool {
$base_tables = array(
'users',
'usermeta',
);

// Table name examples: wp_users, wp_3_users, td_12_usermeta, users, usermeta, wp_users u, wp_users AS u.
$pattern = '/(?:^|_)(?:' .
implode( '|', array_map( 'preg_quote', $base_tables ) ) .
')(?:\s+(?:AS\s+)?[a-zA-Z_][a-zA-Z0-9_]*)?$/i';

return (bool) preg_match( $pattern, trim( $table_name ) );
}

/**
* Prepare table name with prefix.
*
Expand All @@ -1268,7 +1300,8 @@ public static function get_table_prefix() {
* @return string
*/
public static function prepare_table_name( string $table_name ) {
$table_prefix = self::get_table_prefix();
$table_name = trim( $table_name );
$table_prefix = self::get_table_prefix( $table_name );
if ( strpos( $table_name,$table_prefix ) !== 0 ) {
$table_name = $table_prefix . $table_name;
}
Expand Down
2 changes: 1 addition & 1 deletion models/WithdrawModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public static function get_withdraw_summary( $instructor_id, $args = array() ) {
HAVING user_id = u.ID
),0) total_matured

FROM {$wpdb->prefix}users u WHERE u.ID=%d
FROM {$wpdb->users} u WHERE u.ID=%d

) a",
'completed',
Expand Down
10 changes: 5 additions & 5 deletions templates/dashboard/account/withdrawals.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@
$currency_symbol = $currency_config['symbol'] ?? '';

$summary_data = WithdrawModel::get_withdraw_summary( $user_id );
$available_for_withdraw = $summary_data->available_for_withdraw - $summary_data->total_pending;
$available_for_withdraw = $summary_data ? $summary_data->available_for_withdraw - $summary_data->total_pending : 0;
$is_balance_sufficient = $available_for_withdraw >= $min_withdraw;
$available_for_withdraw_formatted = tutor_utils()->tutor_price( $available_for_withdraw );
$current_balance_formated = tutor_utils()->tutor_price( $summary_data->current_balance );
$current_balance_formated = tutor_utils()->tutor_price( $summary_data->current_balance ?? 0 );
?>

<?php require_once tutor_get_template( 'account-header' ); ?>
Expand Down Expand Up @@ -123,15 +123,15 @@
<div class="tutor-withdrawal-status">
<div class="tutor-withdrawal-status-item">
<div class="tutor-withdrawal-status-item-label"><?php esc_html_e( 'Net Income', 'tutor' ); ?></div>
<div class="tutor-withdrawal-status-item-value"><?php echo wp_kses( tutor_utils()->tutor_price( $summary_data->total_income ), tutor_price_allowed_html() ); ?></div>
<div class="tutor-withdrawal-status-item-value"><?php echo wp_kses( tutor_utils()->tutor_price( $summary_data->total_income ?? 0 ), tutor_price_allowed_html() ); ?></div>
</div>
<div class="tutor-withdrawal-status-item">
<div class="tutor-withdrawal-status-item-label tutor-flex tutor-items-center tutor-gap-1">
<?php esc_html_e( 'Pending Withdrawals', 'tutor' ); ?>

</div>
<div class="tutor-withdrawal-status-item-value tutor-withdrawal-status-item-value--pending tutor-flex tutor-items-center tutor-gap-3">
<?php echo wp_kses( tutor_utils()->tutor_price( $summary_data->total_pending ), tutor_price_allowed_html() ); ?>
<?php echo wp_kses( tutor_utils()->tutor_price( $summary_data->total_pending ?? 0 ), tutor_price_allowed_html() ); ?>
<?php
Tooltip::make()
->content( __( 'Total amount requested but not yet processed.', 'tutor' ) )
Expand All @@ -144,7 +144,7 @@
</div>
<div class="tutor-withdrawal-status-item">
<div class="tutor-withdrawal-status-item-label"><?php esc_html_e( 'Withdrawal Total', 'tutor' ); ?></div>
<div class="tutor-withdrawal-status-item-value"><?php echo wp_kses( tutor_utils()->tutor_price( $summary_data->total_withdraw ), tutor_price_allowed_html() ); ?></div>
<div class="tutor-withdrawal-status-item-value"><?php echo wp_kses( tutor_utils()->tutor_price( $summary_data->total_withdraw ?? 0 ), tutor_price_allowed_html() ); ?></div>
</div>
</div>
</div>
Expand Down
Loading