PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 All 140 releases
← All changes | inc/TemplateHooks/CourseBuilder/BuilderPopupTemplate.php +39 -11 4.3.7 → 4.4.9 View file →
@@ -51,9 +51,9 @@
51 51 * @param int $item_id
52 52 *
53 53 * @throws Exception
54 54 */
55 - private static function ensure_popup_access( string $item_type, int $item_id ) {
55 + /*private static function ensure_popup_access( string $item_type, int $item_id ) {
56 56 if ( $item_id > 0 ) {
57 57 if ( ! CourseBuilderAccessPolicy::can_edit_item( $item_type, $item_id ) ) {
58 58 throw new Exception( __( "Sorry, you don't have permission to access this content", 'learnpress' ) );
59 59 }
@@ -63,9 +63,9 @@
63 63
64 64 if ( ! CourseBuilderAccessPolicy::can_create_item_type( $item_type ) ) {
65 65 throw new Exception( __( "Sorry, you don't have permission to create this item", 'learnpress' ) );
66 66 }
67 - }
67 + }*/
68 68
69 69 /**
70 70 * Get popup wrapper HTML structure.
71 71 */
@@ -149,18 +149,27 @@
149 149 }
150 150
151 151 /**
152 152 * Render Lesson Popup
153 + * @throws Exception
153 154 */
154 155 public static function render_lesson_popup( array $args = [] ): stdClass {
155 156 $response = new stdClass();
156 157 $lesson_id = absint( $args['lesson_id'] ?? 0 );
157 - self::ensure_popup_access( LP_LESSON_CPT, $lesson_id );
158 + //self::ensure_popup_access( LP_LESSON_CPT, $lesson_id );
158 159
159 160 $lesson_model = $lesson_id ? LessonPostModel::find( $lesson_id, true ) : null;
160 - $title = $lesson_model ? __( 'Edit Lesson', 'learnpress' ) : __( 'New Lesson', 'learnpress' );
161 - $status = $lesson_model ? $lesson_model->post_status : '';
162 161
162 + if ( $lesson_model instanceof LessonPostModel ) {
163 + $lesson_model->check_capabilities_update_item_course();
164 + } else {
165 + $lessonPostModelNew = new LessonPostModel();
166 + $lessonPostModelNew->check_capabilities_create_item_course();
167 + }
168 +
169 + $title = $lesson_model ? __( 'Edit Lesson', 'learnpress' ) : __( 'New Lesson', 'learnpress' );
170 + $status = $lesson_model ? $lesson_model->post_status : '';
171 +
163 172 $instance = self::instance();
164 173 $content = $instance->build_lesson_content( $lesson_id, $lesson_model );
165 174
166 175 $html = array_merge(
@@ -175,8 +184,9 @@
175 184 }
176 185
177 186 /**
178 187 * Build lesson content
188 + * @throws Exception
179 189 */
180 190 private function build_lesson_content( int $lesson_id, $lesson_model ): string {
181 191 if ( $lesson_model && $lesson_model->post_status === PostModel::STATUS_TRASH ) {
182 192 $message = __(
@@ -210,18 +220,27 @@
210 220 }
211 221
212 222 /**
213 223 * Render Quiz Popup
224 + * @throws Exception
214 225 */
215 226 public static function render_quiz_popup( array $args = [] ): stdClass {
216 227 $response = new stdClass();
217 228 $quiz_id = absint( $args['quiz_id'] ?? 0 );
218 - self::ensure_popup_access( LP_QUIZ_CPT, $quiz_id );
229 + //self::ensure_popup_access( LP_QUIZ_CPT, $quiz_id );
219 230
220 231 $quiz_model = $quiz_id ? QuizPostModel::find( $quiz_id, true ) : null;
221 - $title = $quiz_model ? __( 'Edit Quiz', 'learnpress' ) : __( 'New Quiz', 'learnpress' );
222 - $status = $quiz_model ? $quiz_model->post_status : '';
223 232
233 + if ( $quiz_model instanceof QuizPostModel ) {
234 + $quiz_model->check_capabilities_update_item_course();
235 + } else {
236 + $quizPostModelNew = new QuizPostModel();
237 + $quizPostModelNew->check_capabilities_create_item_course();
238 + }
239 +
240 + $title = $quiz_model ? __( 'Edit Quiz', 'learnpress' ) : __( 'New Quiz', 'learnpress' );
241 + $status = $quiz_model ? $quiz_model->post_status : '';
242 +
224 243 $instance = self::instance();
225 244 $content = $instance->build_quiz_content( $quiz_id, $quiz_model );
226 245
227 246 $html = array_merge(
@@ -264,17 +283,26 @@
264 283 }
265 284
266 285 /**
267 286 * Render Question Popup
287 + * @throws Exception
268 288 */
269 289 public static function render_question_popup( array $args = [] ): stdClass {
270 290 $response = new stdClass();
271 291 $question_id = absint( $args['question_id'] ?? 0 );
272 - self::ensure_popup_access( LP_QUESTION_CPT, $question_id );
292 + //self::ensure_popup_access( LP_QUESTION_CPT, $question_id );
273 293
274 294 $question_model = $question_id ? QuestionPostModel::find( $question_id, true ) : null;
275 - $title = $question_model ? __( 'Edit Question', 'learnpress' ) : __( 'New Question', 'learnpress' );
276 - $status = $question_model ? $question_model->post_status : '';
295 +
296 + if ( $question_model instanceof QuestionPostModel ) {
297 + $question_model->check_capabilities_update_item_course();
298 + } else {
299 + $questionPostModelNew = new QuestionPostModel();
300 + $questionPostModelNew->check_capabilities_create_item_course();
301 + }
302 +
303 + $title = $question_model ? __( 'Edit Question', 'learnpress' ) : __( 'New Question', 'learnpress' );
304 + $status = $question_model ? $question_model->post_status : '';
277 305
278 306 $instance = self::instance();
279 307 $content = $instance->build_question_content( $question_id, $question_model );
280 308