Skip to content

Commit

Permalink
merge branch 'dev' of https://github.com/themeum/tutor into ecommerce…
Browse files Browse the repository at this point in the history
…-backend
  • Loading branch information
shewa12 committed Nov 19, 2024
2 parents 92572f8 + 903937d commit 666b03a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 32 deletions.
1 change: 1 addition & 0 deletions assets/react/v3/@types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ declare global {
hide_admin_bar_for_users: 'on' | 'off';
enable_redirect_on_course_publish_from_frontend: 'on' | 'off';
instructor_can_publish_course: 'on' | 'off';
youtube_api_key_exist: boolean;
};
tutor_currency: {
symbol: string;
Expand Down
39 changes: 8 additions & 31 deletions assets/react/v3/shared/components/fields/FormVideoInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ const FormVideoInput = ({
minutes: 0,
seconds: 0,
});
const [localPoster, setLocalPoster] = useState<string>('');

const videoSource = form.watch('videoSource') || '';

Expand Down Expand Up @@ -254,12 +255,7 @@ const FormVideoInput = ({
generateVideoThumbnail(source, fieldValue[`source_${source}` as keyof CourseVideo] || '')
.then((url) => {
setIsThumbnailLoading(false);
field.onChange(
updateFieldValue(fieldValue, {
poster: '',
poster_url: url,
}),
);
setLocalPoster(url);
})
.finally(() => {
setIsThumbnailLoading(false);
Expand Down Expand Up @@ -306,7 +302,7 @@ const FormVideoInput = ({
});
}

if (fieldValue.source === 'youtube') {
if (fieldValue.source === 'youtube' && tutorConfig.settings?.youtube_api_key_exist) {
const videoId = videoValidation.youtube(fieldValue['source_youtube' as keyof CourseVideo] || '') ?? '';
getYouTubeVideoDurationMutation.mutateAsync(videoId).then((response) => {
const duration = response.data.duration;
Expand Down Expand Up @@ -369,21 +365,7 @@ const FormVideoInput = ({
}

if (posterUrl) {
field.onChange(
updateFieldValue(fieldValue, {
...updateData,
poster: '',
poster_url: posterUrl,
}),
);

onChange?.(
updateFieldValue(fieldValue, {
...updateData,
poster: '',
poster_url: posterUrl,
}),
);
setLocalPoster(posterUrl);
}
} catch (error) {
console.error(error);
Expand All @@ -402,6 +384,7 @@ const FormVideoInput = ({
const updatedValue = updateFieldValue(fieldValue, updateData);

field.onChange(updatedValue);
setLocalPoster('');
setDuration({
hours: 0,
minutes: 0,
Expand Down Expand Up @@ -447,13 +430,7 @@ const FormVideoInput = ({
}

if (thumbnail) {
const valueWithThumbnail = updateFieldValue(fieldValue, {
...updatedValue,
poster: '',
poster_url: thumbnail,
});
field.onChange(valueWithThumbnail);
onChange?.(valueWithThumbnail);
setLocalPoster(thumbnail);
}
} finally {
setIsThumbnailLoading(false);
Expand Down Expand Up @@ -612,8 +589,8 @@ const FormVideoInput = ({
value={
fieldValue
? {
id: Number(fieldValue.poster),
url: fieldValue.poster_url,
id: Number(fieldValue.poster) || 0,
url: fieldValue.poster_url || localPoster,
title: '',
}
: null
Expand Down
1 change: 1 addition & 0 deletions classes/Course.php
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,7 @@ public function enqueue_course_builder_assets() {
$settings = Options_V2::get_only( $required_options );
$settings['course_builder_logo_url'] = wp_get_attachment_image_url( $full_settings['tutor_frontend_course_page_logo_id'] ?? 0, 'full' );
$settings['chatgpt_key_exist'] = tutor()->has_pro && ! empty( $full_settings['chatgpt_api_key'] ?? '' );
$settings['youtube_api_key_exist'] = ! empty( $full_settings['lesson_video_duration_youtube_api_key'] ?? '' );

$new_data = array( 'settings' => $settings );

Expand Down
2 changes: 1 addition & 1 deletion ecommerce/PaymentGateways/Configs/PaymentUrlsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getCancelUrl(): string {
public function get_field_value( array $config, string $field_name ) {
$value = '';
foreach ( $config['fields'] as $field ) {
if ( $field['name'] === $field_name ) {
if ( isset( $field['name'] ) && $field['name'] === $field_name ) {
$value = $field['value'] ?? '';
break;
}
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ All of these Tutor LMS features allow the users to design a more powerful and di
== Changelog ==

= 3.0.0 - November 20, 2024

New: Redesigned course and quiz builders with an intuitive interface for easier course creation.
New: Native eCommerce to sell courses directly within Tutor LMS.
New: Added popular payment gateways support: PayPal, Stripe, Mollie, Klarna, Razorpay, Paystack, and Alipay.
Expand Down

0 comments on commit 666b03a

Please sign in to comment.