--- a/tutor/classes/User.php
+++ b/tutor/classes/User.php
@@ -246,7 +246,11 @@
$meta_key = 'cover_photo' == $type ? '_tutor_cover_photo' : '_tutor_profile_photo';
$photo_id = get_user_meta( $user_id, $meta_key, true );
if ( is_numeric( $photo_id ) ) {
- wp_delete_attachment( $photo_id, true );
+ $attachment = get_post( $photo_id );
+ $post_author = (int) $attachment->post_author ?? 0;
+ if ( $user_id === $post_author ) {
+ wp_delete_attachment( $photo_id, true );
+ }
}
delete_user_meta( $user_id, $meta_key );
}
@@ -375,15 +379,6 @@
$_tutor_profile_bio = Input::post( self::PROFILE_BIO_META, '', Input::TYPE_KSES_POST );
$_tutor_profile_image = Input::post( self::PROFILE_PHOTO_META, '', Input::TYPE_KSES_POST );
- // Check if the image uploaded is by the same user.
- if ( is_numeric( $_tutor_profile_image ) ) {
- $attachment = get_post( $_tutor_profile_image );
- $author_id = (int) $attachment->post_author ?? 0;
- if ( 'attachment' === $attachment->post_type && $user_id !== $author_id ) {
- return;
- }
- }
-
update_user_meta( $user_id, self::PROFILE_JOB_TITLE_META, $_tutor_profile_job_title );
update_user_meta( $user_id, self::PROFILE_BIO_META, $_tutor_profile_bio );
update_user_meta( $user_id, self::PROFILE_PHOTO_META, $_tutor_profile_image );
--- a/tutor/ecommerce/HooksHandler.php
+++ b/tutor/ecommerce/HooksHandler.php
@@ -189,7 +189,15 @@
$transaction_id = $res->transaction_id;
$order_details = $this->order_model->get_order_by_id( $order_id );
- if ( $order_details ) {
+
+ /**
+ * Ignore canceled/failed webhooks for old/failed payment session to avoid unenrolling paid users.
+ *
+ * @since 3.9.7
+ */
+ $is_valid_paid_order = OrderModel::ORDER_COMPLETED === $order_details && OrderModel::PAYMENT_PAID === $order_details->payment_status;
+
+ if ( $order_details && ! $is_valid_paid_order ) {
$prev_payment_status = $order_details->payment_status;
$order_data = array(
--- a/tutor/helpers/QueryHelper.php
+++ b/tutor/helpers/QueryHelper.php
@@ -252,6 +252,7 @@
* Otherwise the clause would be `WHERE column_name = 'value'`
*
* @since 3.0.0
+ * @since 3.9.7 added prepared statement for value.
*
* @param array $where The where clause array. e.g. array( 'id', 'IN', array(1, 2, 3) ) or array( 'id', '=', 1 ).
*
@@ -261,8 +262,16 @@
list ( $field, $operator, $value ) = $where;
$upper_operator = strtoupper( $operator );
+
if ( in_array( $upper_operator, array( 'IN', 'NOT IN' ), true ) ) {
$value = '(' . self::prepare_in_clause( $value ) . ')';
+ } elseif ( in_array( $upper_operator, array( 'BETWEEN', 'NOT BETWEEN' ), true ) ) {
+ $value = array_map( fn( $val ) => self::prepare_value( $val ), $value );
+ $value = implode( ' AND ', $value );
+ } elseif ( strtoupper( $value ) === 'NULL' ) {
+ $value = 'NULL';
+ } else {
+ $value = self::prepare_value( $value );
}
return "{$field} {$upper_operator} {$value}";
@@ -346,15 +355,13 @@
case 'BETWEEN':
case 'NOT BETWEEN':
if ( is_array( $val ) && count( $val ) === 2 ) {
- $val1 = is_numeric( $val[0] ) ? $val[0] : "'" . $val[0] . "'";
- $val2 = is_numeric( $val[1] ) ? $val[1] : "'" . $val[1] . "'";
- $clause = array( $field, $operator, "{$val1} AND {$val2}" );
+ $clause = array( $field, $operator, $val );
}
break;
case 'IS':
case 'IS NOT':
- $val = strtoupper( $val ) === 'NULL' ? 'NULL' : "'" . $val . "'";
+ $val = strtoupper( $val ) === 'NULL' ? 'NULL' : $val;
$clause = array( $field, $operator, $val );
break;
case 'RAW':
@@ -365,16 +372,14 @@
$clause = $final_query;
break;
default: // =, !=, <, >, <=, >=, LIKE, NOT LIKE, <>
- $val = is_numeric( $val ) ? $val : "'" . $val . "'";
$clause = array( $field, $operator, $val );
break;
}
} elseif ( is_array( $value ) ) {
$clause = array( $field, 'IN', $value );
} elseif ( 'null' === strtolower( $value ) ) {
- $clause = array( $field, 'IS', 'NULL' );
+ $clause = array( $field, 'IS', 'NULL' );
} else {
- $value = is_numeric( $value ) ? $value : "'" . $value . "'";
$clause = array( $field, '=', $value );
}
@@ -911,31 +916,40 @@
}
/**
+ * Prepare value before using in query.
+ *
+ * @since 3.9.7
+ *
+ * @param string|int|float $value the value to prepare.
+ *
+ * @return mixed
+ */
+ public static function prepare_value( $value ) {
+ global $wpdb;
+ $escaped_value = null;
+ if ( is_int( $value ) ) {
+ $escaped_value = $wpdb->prepare( '%d', $value );
+ } elseif ( is_float( $value ) ) {
+ list( $whole, $decimal ) = explode( '.', $value );
+ $expression = '%.'. strlen( $decimal ) . 'f';
+ $escaped_value = $wpdb->prepare( $expression, $value );
+ } else {
+ $escaped_value = $wpdb->prepare( '%s', $value );
+ }
+ return $escaped_value;
+ }
+
+ /**
* Make sanitized SQL IN clause value from an array
*
+ * @since 2.1.1
+ *
* @param array $arr a sequential array.
+ *
* @return string
- * @since 2.1.1
*/
public static function prepare_in_clause( array $arr ) {
- $escaped = array_map(
- function( $value ) {
- global $wpdb;
- $escaped_value = null;
- if ( is_int( $value ) ) {
- $escaped_value = $wpdb->prepare( '%d', $value );
- } else if( is_float( $value ) ) {
- list( $whole, $decimal ) = explode( '.', $value );
- $expression = '%.'. strlen( $decimal ) . 'f';
- $escaped_value = $wpdb->prepare( $expression, $value );
- } else {
- $escaped_value = $wpdb->prepare( '%s', $value );
- }
- return $escaped_value;
- },
- $arr
- );
-
+ $escaped = array_map( fn( $value ) => self::prepare_value( $value ), $arr );
return implode( ',', $escaped );
}
--- a/tutor/includes/droip/backend/ElementGenerator/ThumbnailGenerator.php
+++ b/tutor/includes/droip/backend/ElementGenerator/ThumbnailGenerator.php
@@ -73,7 +73,7 @@
'type' => 'video',
'src' => $video_info->$source_key,
'source' => $video_info->source,
- 'poster_url' => $video_info->poster_url
+ 'poster_url' => isset($video_info->poster_url) ? $video_info->poster_url: null,
);
} elseif ( $video_info->source === 'youtube' ) {
$youtube_video_id = tutor_utils()->get_youtube_video_id( tutor_utils()->avalue_dot( 'source_youtube', $video_info ) );
--- a/tutor/includes/droip/backend/Hooks.php
+++ b/tutor/includes/droip/backend/Hooks.php
@@ -206,6 +206,19 @@
['title' => 'Content', 'value' => 'TUTOR_LMS-membership-features-feature-content'],
];
}
+ } else if (isset($collection_data['collectionType']) && $collection_data['collectionType'] === 'user' || $collection_data['collectionType'] === 'users') {
+ if ($collection_data['elementContentType'] === 'anchor') {
+ $fields['typeValuesAttr']['anchor']['author'] = array_merge(
+ $fields['typeValuesAttr']['anchor']['author'],
+ [
+ ['title' => 'Facebook', 'value' => 'TUTOR_LMS-instructor-facebook'],
+ ['title' => 'X (Twitter)', 'value' => 'TUTOR_LMS-instructor-twitter'],
+ ['title' => 'Linkedin', 'value' => 'TUTOR_LMS-instructor-linkedin'],
+ ['title' => 'Website', 'value' => 'TUTOR_LMS-instructor-website'],
+ ['title' => 'Github', 'value' => 'TUTOR_LMS-instructor-github'],
+ ]
+ );
+ }
}
return $fields;
@@ -758,6 +771,20 @@
return $url;
}
+ } else if ($dynamicContent['type'] === 'author') {
+ $user_id = isset($args['options'], $args['options']['user']) ? $args['options']['user']['ID'] : false;
+
+ if ($dynamicContent['value'] === 'TUTOR_LMS-instructor-facebook') {
+ return get_user_meta($user_id, '_tutor_profile_facebook', true);
+ } else if ($dynamicContent['value'] === 'TUTOR_LMS-instructor-twitter') {
+ return get_user_meta($user_id, '_tutor_profile_twitter', true);
+ } else if ($dynamicContent['value'] === 'TUTOR_LMS-instructor-linkedin') {
+ return get_user_meta($user_id, '_tutor_profile_linkedin', true);
+ } else if ($dynamicContent['value'] === 'TUTOR_LMS-instructor-website') {
+ return get_user_meta($user_id, '_tutor_profile_website', true);
+ } else if ($dynamicContent['value'] === 'TUTOR_LMS-instructor-github') {
+ return get_user_meta($user_id, '_tutor_profile_github', true);
+ }
}
} elseif (isset($args['settings'])) {
$settings = $args['settings'];
--- a/tutor/includes/droip/backend/VisibilityCondition.php
+++ b/tutor/includes/droip/backend/VisibilityCondition.php
@@ -328,6 +328,52 @@
'title' => 'Offer sale Price',
'operator_type' => 'boolean_operators',
),
+
+ // start: trial
+ array(
+ 'source' => TDE_APP_PREFIX,
+ 'value' => 'trial_value',
+ 'title' => 'Length of Trial',
+ 'operator_type' => 'numeric_operators',
+ 'operand_type' => array_merge(
+ DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
+ array(
+ 'placeholder' => 'Trial Value',
+ )
+ ),
+ ),
+
+ array(
+ 'source' => TDE_APP_PREFIX,
+ 'value' => 'trial_interval',
+ 'title' => 'Trial Interval',
+ 'operator_type' => 'dropdown_operators',
+ 'operand_type' => array_merge(
+ DROIP_PLUGIN_SETTINGS['SELECT'],
+ array(
+ 'options' => array(
+ array(
+ 'value' => 'day',
+ 'title' => 'Day',
+ ),
+ ),
+ ),
+ ),
+ ),
+
+ array(
+ 'source' => TDE_APP_PREFIX,
+ 'value' => 'trial_fee',
+ 'title' => 'Trial Fee',
+ 'operator_type' => 'numeric_operators',
+ 'operand_type' => array_merge(
+ DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
+ array(
+ 'placeholder' => 'Trial Fee',
+ )
+ ),
+ ),
+ // end: trial
),
),
);
@@ -599,6 +645,35 @@
'title' => 'Certificate Enabled',
'operator_type' => 'boolean_operators',
),
+ array(
+ 'source' => TDE_APP_PREFIX,
+ 'value' => 'difficulty_level',
+ 'title' => 'Difficulty Level',
+ 'operator_type' => 'dropdown_operators',
+ 'operand_type' => array_merge(
+ DROIP_PLUGIN_SETTINGS['SELECT'],
+ array(
+ 'options' => array(
+ array(
+ 'value' => 'all_levels',
+ 'title' => 'All Levels',
+ ),
+ array(
+ 'value' => 'beginner',
+ 'title' => 'Beginner',
+ ),
+ array(
+ 'value' => 'intermediate',
+ 'title' => 'Intermediate',
+ ),
+ array(
+ 'value' => 'expert',
+ 'title' => 'Expert',
+ ),
+ ),
+ )
+ ),
+ ),
)
),
);
@@ -860,14 +935,27 @@
switch ($field) {
case 'enrollment_fee':
case 'sale_price': {
- return $membership_plan[$field] !== '0.00';
- }
+ return $membership_plan[$field] !== '0.00';
+ }
case 'is_featured':
case 'provide_certificate': {
- return $membership_plan[$field] == '1';
+ return $membership_plan[$field] == '1';
+ }
+
+ case 'trial_value':
+ case 'trial_fee': {
+ if (isset($membership_plan[$field])) {
+ return floatval($membership_plan[$field]);
}
+ return false;
+ }
+
+ case 'trial_interval': {
+ return $membership_plan['trial_interval'] ?? false;
+ }
+
default:
return isset($membership_plan[$field]) ? $membership_plan[$field] : null;
}
@@ -948,6 +1036,10 @@
}
return false;
}
+
+ case 'difficulty_level': {
+ return get_post_meta($course_id, '_tutor_course_level', true);
+ }
}
}
--- a/tutor/models/CouponModel.php
+++ b/tutor/models/CouponModel.php
@@ -810,7 +810,7 @@
} else {
$coupon = $this->get_coupon(
array(
- 'coupon_code' => esc_sql( $coupon_code ),
+ 'coupon_code' => $coupon_code,
'coupon_status' => self::STATUS_ACTIVE,
)
);
--- a/tutor/tutor.php
+++ b/tutor/tutor.php
@@ -4,7 +4,7 @@
* Plugin URI: https://tutorlms.com
* Description: Tutor is a complete solution for creating a Learning Management System in WordPress way. It can help you to create small to large scale online education site very conveniently. Power features like report, certificate, course preview, private file sharing make Tutor a robust plugin for any educational institutes.
* Author: Themeum
- * Version: 3.9.6
+ * Version: 3.9.7
* Author URI: https://themeum.com
* Requires PHP: 7.4
* Requires at least: 5.3
@@ -26,7 +26,7 @@
*
* @since 1.0.0
*/
-define( 'TUTOR_VERSION', '3.9.6' );
+define( 'TUTOR_VERSION', '3.9.7' );
define( 'TUTOR_FILE', __FILE__ );
/**
--- a/tutor/vendor/composer/installed.php
+++ b/tutor/vendor/composer/installed.php
@@ -3,7 +3,7 @@
'name' => 'themeum/tutor',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
- 'reference' => '11d7e23fa5b4dbc33a21b43c6a3458484fd24999',
+ 'reference' => '379e90b7840e362483da16f96d4d9bb7de1572de',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -13,7 +13,7 @@
'themeum/tutor' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
- 'reference' => '11d7e23fa5b4dbc33a21b43c6a3458484fd24999',
+ 'reference' => '379e90b7840e362483da16f96d4d9bb7de1572de',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),