Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:LearnPress/learnpress into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhbdphyscode committed May 2, 2024
2 parents d553491 + 2913eee commit 45a346e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 115 deletions.
1 change: 1 addition & 0 deletions assets/src/scss/frontend/_profile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,7 @@ div.order-recover {
width: 100%;
border-spacing: 0;
border: 0.5px solid #ccc;
margin-bottom: 10px;

&__item {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ protected function render() {
}
?>
<li class="item-instructor">
<?php echo $singleInstructorTemplate->render_data( $instructor, html_entity_decode( $item_layout['layout_html'] ) ); ?>
<?php echo $singleInstructorTemplate->render_data(
$instructor,
wp_kses_post( html_entity_decode( $item_layout['layout_html'] ) )
); ?>
</li>
<?php
}
Expand Down
8 changes: 8 additions & 0 deletions inc/class-lp-page-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,14 @@ public function pre_get_posts( WP_Query $q ): WP_Query {
$q->set( 'post__not_in', $list_ids_exclude );
}

// Not search questions
$searchable_types = get_post_types();
unset( $searchable_types[ LP_QUESTION_CPT ] );
$q->set(
'post_type',
$searchable_types
);

return $q;
}

Expand Down
126 changes: 13 additions & 113 deletions inc/curds/class-lp-question-curd.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,27 +613,21 @@ public function delete_answer( $question_id, $answer_id, $force = false ) {

global $wpdb;

// delete all answer in question
if ( $force ) {
$delete = $wpdb->delete(
$wpdb->learnpress_question_answers,
array( 'question_id' => $question_id )
);
// Delete answer meta
$wpdb->delete(
$wpdb->learnpress_question_answermeta,
array( 'learnpress_question_answer_id' => $answer_id )
);

if ( $delete ) {
$question->set_data( 'answer_options', '' );
}
} else {
$delete = $wpdb->delete(
$wpdb->learnpress_question_answers,
array( 'question_answer_id' => $answer_id )
);
if ( $delete ) {
unset( $answers[ $answer_id ] );
$question->set_data( 'answer_options', $answers );
$delete = $wpdb->delete(
$wpdb->learnpress_question_answers,
array( 'question_answer_id' => $answer_id )
);
if ( $delete ) {
unset( $answers[ $answer_id ] );
$question->set_data( 'answer_options', $answers );

$this->sort_answers( $question_id, array_keys( $answers ) );
}
$this->sort_answers( $question_id, array_keys( $answers ) );
}

return $delete;
Expand Down Expand Up @@ -967,42 +961,6 @@ protected function _read_answers( $question_id ) {
return $answer_options;
}

/**
* Load answer options for the question from database.
* Load from cache if data is already loaded into cache.
* Otherwise, load from database and put to cache.
*
* @param $question LP_Question
* @deprecated 4.1.7
*/
/*protected function _load_answer_options( &$question ) {
$id = $question->get_id();
$answer_options = LP_Object_Cache::get( 'answer-options-' . $id, 'lp-questions' );
if ( false === $answer_options ) {
global $wpdb;
$query = $wpdb->prepare(
"
SELECT *
FROM {$wpdb->prefix}learnpress_question_answers
WHERE question_id = %d
ORDER BY `order` ASC
",
$id
);
$answer_options = $this->load_answer_options( $question->get_id() );
}
$answer_options = apply_filters( 'learn-press/question/load-answer-options', $answer_options, $id );
if ( ! empty( $answer_options['question_answer_id'] ) && $answer_options['question_answer_id'] > 0 ) {
$this->_load_answer_option_meta( $answer_options );
}
LP_Object_Cache::set( 'answer-options-' . $id, $answer_options, 'lp-questions' );
$question->set_data( 'answer_options', $answer_options );
}*/

/**
* Load question answers
*
Expand Down Expand Up @@ -1037,63 +995,5 @@ public function load_answer_options( $question_id ) {

return $answer_options;
}

/**
* Load meta data for answer options.
*
* @param array $answer_options
*
* @return mixed;
* @deprecated 4.1.7
*/
/*protected function _load_answer_option_meta( &$answer_options ) {
if ( ! $answer_options ) {
return false;
}
$answer_option_ids = wp_list_pluck( $answer_options, 'question_answer_id' );
$format = array_fill( 0, sizeof( $answer_option_ids ), '%d' );
$query = $wpdb->prepare(
"
SELECT *
FROM {$wpdb->prefix}learnpress_question_answermeta
WHERE learnpress_question_answer_id IN(" . join( ', ', $format ) . ')
',
$answer_option_ids
);
$metas = $wpdb->get_results( $query );
if ( $metas ) {
foreach ( $metas as $meta ) {
$key = $meta->meta_key;
$option_key = $meta->learnpress_question_answer_id;
if ( ! empty( $answer_options[ $option_key ] ) ) {
if ( $key == 'checked' ) {
$key = 'is_true';
}
$answer_options[ $option_key ][ $key ] = $meta->meta_value;
}
}
}
return true;
}*/

public function add_meta( &$object, $meta ) {
// TODO: Implement add_meta() method.
}

public function delete_meta( &$object, $meta ) {
// TODO: Implement delete_meta() method.
}

public function read_meta( &$object ) {
// TODO: Implement read_meta() method.
}

public function update_meta( &$object, $meta ) {
// TODO: Implement update_meta() method.
}
}
}
3 changes: 2 additions & 1 deletion templates/profile/tabs/courses/course-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@

<?php if ( $num_pages > 1 && $current_page < $num_pages && $current_page === 1 ) : ?>
<div class="lp_profile_course_progress__nav">
<button data-paged="<?php echo absint( $current_page + 1 ); ?>"
<button class="lp-button"
data-paged="<?php echo absint( $current_page + 1 ); ?>"
data-number="<?php echo absint( $num_pages ); ?>"><?php esc_html_e( 'View more', 'learnpress' ); ?>
</button>
</div>
Expand Down

0 comments on commit 45a346e

Please sign in to comment.