Plugin Directory

Changeset 2388997


Ignore:
Timestamp:
09/26/2020 09:59:12 PM (5 years ago)
Author:
Bijingus
Message:

Added option to enable or disable the REST API for courses, modules, lessons and teachers. Disabled by default.

Location:
wp-courses/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wp-courses/trunk/README.md

    r2387944 r2388997  
    55Requires at least: 4.6
    66Tested up to: 5.5.1
    7 Stable tag: 2.0.27
     7Stable tag: 2.0.28
    88License: GPLv2 or later license
    99
  • wp-courses/trunk/wp-courses.php

    r2387944 r2388997  
    33 * Plugin Name: WP Courses LMS
    44 * Description: WP Courses is a free learning management system (LMS) plugin for WordPress.  It includes a rich feature set that allows you to create unlimited courses, restrict content and much more.
    5  * Version: 2.0.27
     5 * Version: 2.0.28
    66 * Author: Myles English
    77 * Plugin URI: https://wpcoursesplugin.com
     
    292292}
    293293add_action( 'admin_enqueue_scripts', 'wpc_enqueue_admin_scripts' );
     294
    294295// Register Custom Post Type Course
    295296function wpc_register_course_cp(){
    296   $labels = array(
    297     'name'               => _x( 'Courses', 'post type general name'),
    298     'singular_name'      => _x( 'Course', 'post type singular name'),
    299     'add_new'            => _x( 'Add New', 'Course'),
    300     'add_new_item'       => __( 'Add New Course'),
    301     'edit_item'          => __( 'Edit Course' ),
    302     'new_item'           => __( 'New Course' ),
    303     'all_items'          => __( 'All Courses' ),
    304     'view_item'          => __( 'View Course' ),
    305     'search_items'       => __( 'Search Courses' ),
    306     'not_found'          => __( 'No Courses Found' ),
    307     'not_found_in_trash' => __( 'No Courses Found in the Trash' ),
    308     'parent_item_colon'  => '',
    309     'menu_name'          => __('Courses', 'wp-courses'),
     297    $labels = array(
     298        'name'               => _x( 'Courses', 'post type general name'),
     299        'singular_name'      => _x( 'Course', 'post type singular name'),
     300        'add_new'            => _x( 'Add New', 'Course'),
     301        'add_new_item'       => __( 'Add New Course'),
     302        'edit_item'          => __( 'Edit Course' ),
     303        'new_item'           => __( 'New Course' ),
     304        'all_items'          => __( 'All Courses' ),
     305        'view_item'          => __( 'View Course' ),
     306        'search_items'       => __( 'Search Courses' ),
     307        'not_found'          => __( 'No Courses Found' ),
     308        'not_found_in_trash' => __( 'No Courses Found in the Trash' ),
     309        'parent_item_colon'  => '',
     310        'menu_name'          => __('Courses', 'wp-courses'),
    310311    );
    311   $args = array(
    312     'labels'              => $labels,
    313     'show_in_admin_bar'   => true,
    314     'menu_icon'           => null,
    315     'show_in_nav_menus'   => false,
    316     'publicly_queryable'  => true,
    317     'query_var'           => true,
    318     'can_export'          => true,
    319     'rewrite'             => true,
    320     'show_in_menu'        => '',
    321     'description'         => __('Enter a Course Description Here', 'wp-courses'),
    322     'public'              => true,
    323     'show_ui'             => true,
    324     'hierarchical'        => false,
    325     'supports'            => array('title', 'editor', 'excerpt', 'page-attributes', 'thumbnail', 'custom-fields'),
    326     'has_archive'         => true,
    327     'hierarchical'        => false,
    328     'show_in_rest'        => true,
     312    $args = array(
     313        'labels'                => $labels,
     314        'show_in_admin_bar'     => true,
     315        'menu_icon'             => null,
     316        'show_in_nav_menus'     => false,
     317        'publicly_queryable'    => true,
     318        'query_var'             => true,
     319        'can_export'            => true,
     320        'rewrite'               => true,
     321        'show_in_menu'          => '',
     322        'description'           => __('Enter a Course Description Here', 'wp-courses'),
     323        'public'                => true,
     324        'show_ui'               => true,
     325        'hierarchical'          => false,
     326        'supports'              => array('title', 'editor', 'excerpt', 'page-attributes', 'thumbnail', 'custom-fields'),
     327        'has_archive'           => true,
     328        'show_in_rest'          => false,
    329329    );
     330
     331   $wpc_enable_rest_course = get_option( 'wpc_enable_rest_course' );
     332
     333    if( $wpc_enable_rest_course == 'true' ){
     334        $args['show_in_rest'] = true;
     335    }
     336
    330337    register_post_type('course', $args);
    331338    flush_rewrite_rules(false);
     
    383390    'show_in_menu'        => '',
    384391    'has_archive'         => true,
    385     'hierarchical'        => false,
     392    'hierarchical'        => true,
    386393    'public'              => true,
    387394    'show_ui'             => true,
    388     'hierarchical'        => false,
     395    'show_in_rest'        => false,
    389396    'labels'        => $labels,
    390397    'description'   => __('Enter a lesson description here', 'wp-courses'),
    391398    'supports'      => array( 'title', 'editor', 'excerpt', 'comments', 'revisions', 'author', 'custom-fields', 'page-attributes'),
    392     'show_in_rest' => true,
    393399  );
     400
     401    $wpc_enable_rest_lesson = get_option('wpc_enable_rest_lesson');
     402
     403    if( $wpc_enable_rest_lesson == 'true' ){
     404        $args['show_in_rest'] = true;
     405    }
     406
    394407  register_post_type( 'lesson', $args );
    395408  flush_rewrite_rules( false );
     
    419432// Register Custom Post Type Module
    420433function wpc_register_module_cp(){
    421   $labels = array(
    422     'name'               => _x( 'Module', 'post type general name' ),
    423     'singular_name'      => _x( 'Module', 'post type singular name' ),
    424     'add_new'            => _x( 'Add New', 'Module' ),
    425     'add_new_item'       => __( 'Add New Module' ),
    426     'edit_item'          => __( 'Edit Module' ),
    427     'new_item'           => __( 'New Module' ),
    428     'all_items'          => __( 'All Modules' ),
    429     'view_item'          => __( 'View Module' ),
    430     'search_items'       => __( 'Search Modules' ),
    431     'not_found'          => __( 'No Modules found' ),
    432     'not_found_in_trash' => __( 'No Modules found in the Trash' ),
    433     'parent_item_colon'  => '',
    434     'menu_name'          => __('Modules', 'wp-courses'),
    435   );
    436   $args = array(
    437     'show_in_admin_bar'   => false,
    438     'menu_icon'           => null,
    439     'show_in_nav_menus'   => false,
    440     'publicly_queryable'  => true,
    441     'exclude_from_search' => true,
    442     'has_archive'         => false,
    443     'query_var'           => true,
    444     'can_export'          => true,
    445     'rewrite'             => true,
    446     'show_in_menu'        => '',
    447     'has_archive'         => true,
    448     'hierarchical'        => false,
    449     'public'              => true,
    450     'show_ui'             => true,
    451     'hierarchical'        => false,
    452     'labels'              => $labels,
    453     'description'         => __('Enter a module description here', 'wp-courses'),
    454     'supports'            => array( 'title' ),
    455   );
    456   register_post_type( 'wpc-module', $args );
    457   flush_rewrite_rules( false );
     434
     435    $labels = array(
     436        'name'               => _x( 'Module', 'post type general name' ),
     437        'singular_name'      => _x( 'Module', 'post type singular name' ),
     438        'add_new'            => _x( 'Add New', 'Module' ),
     439        'add_new_item'       => __( 'Add New Module' ),
     440        'edit_item'          => __( 'Edit Module' ),
     441        'new_item'           => __( 'New Module' ),
     442        'all_items'          => __( 'All Modules' ),
     443        'view_item'          => __( 'View Module' ),
     444        'search_items'       => __( 'Search Modules' ),
     445        'not_found'          => __( 'No Modules found' ),
     446        'not_found_in_trash' => __( 'No Modules found in the Trash' ),
     447        'parent_item_colon'  => '',
     448        'menu_name'          => __('Modules', 'wp-courses'),
     449    );
     450
     451    $args = array(
     452        'show_in_admin_bar'   => false,
     453        'menu_icon'           => null,
     454        'show_in_nav_menus'   => false,
     455        'publicly_queryable'  => true,
     456        'exclude_from_search' => true,
     457        'has_archive'         => false,
     458        'query_var'           => true,
     459        'can_export'          => true,
     460        'rewrite'             => true,
     461        'show_in_menu'        => '',
     462        'has_archive'         => true,
     463        'hierarchical'        => false,
     464        'public'              => true,
     465        'show_ui'             => true,
     466        'show_in_rest'        => false,
     467        'labels'              => $labels,
     468        'description'         => __('Enter a module description here', 'wp-courses'),
     469        'supports'            => array( 'title' ),
     470    );
     471
     472    $wpc_enable_rest_lesson = get_option('wpc_enable_rest_lesson');
     473
     474    if( $wpc_enable_rest_lesson == 'true' ){
     475        $args['show_in_rest'] = true;
     476    }
     477
     478    register_post_type( 'wpc-module', $args );
     479    flush_rewrite_rules( false );
     480
    458481}
    459482add_action( 'init', 'wpc_register_module_cp' );
     
    510533    'public'              => true,
    511534    'show_ui'             => true,
    512     'hierarchical'        => false,
     535    'show_in_rest'        => false,
    513536    'labels'              => $labels,
    514537    'description'         => __('Enter a Teacher Description Here', 'wp-courses'),
    515538    'supports'            => array('title', 'editor', 'excerpt', 'page-attributes', 'thumbnail'),
    516     'show_in_rest'        => true,
    517539    );
     540
     541    $wpc_enable_rest_teacher = get_option('wpc_enable_rest_teacher');
     542
     543    if( $wpc_enable_rest_teacher == 'true' ){
     544        $args['show_in_rest'] = true;
     545    }
     546
    518547    register_post_type('teacher', $args);
    519548    flush_rewrite_rules(false);
  • wp-courses/trunk/wp-courses.pot

    r2387944 r2388997  
    44"Project-Id-Version: WP Courses LMS\n"
    55"Report-Msgid-Bugs-To: \n"
    6 "POT-Creation-Date: 2020-09-24 22:12+0000\n"
     6"POT-Creation-Date: 2020-09-26 21:56+0000\n"
    77"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    88"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    158158msgstr ""
    159159
    160 #: admin-nav-menu.php:11 wp-courses.php:309
     160#: admin-nav-menu.php:11 wp-courses.php:310
    161161msgid "Courses"
    162162msgstr ""
     
    183183msgstr ""
    184184
    185 #: wp-courses.php:321
     185#: wp-courses.php:322
    186186msgid "Enter a Course Description Here"
    187187msgstr ""
    188188
    189 #: wp-courses.php:390
     189#: wp-courses.php:397
    190190msgid "Enter a lesson description here"
    191191msgstr ""
    192192
    193 #: wp-courses.php:453
     193#: wp-courses.php:468
    194194msgid "Enter a module description here"
    195195msgstr ""
    196196
    197 #: wp-courses.php:514
     197#: wp-courses.php:537
    198198msgid "Enter a Teacher Description Here"
    199199msgstr ""
     
    248248msgstr ""
    249249
    250 #: wp-courses.php:371
     250#: wp-courses.php:378
    251251msgid "Lessons"
    252252msgstr ""
     
    280280msgstr ""
    281281
    282 #: wp-courses.php:434
     282#: wp-courses.php:448
    283283msgid "Modules"
    284284msgstr ""
     
    414414msgstr ""
    415415
    416 #: admin-nav-menu.php:29 wp-courses.php:496
     416#: admin-nav-menu.php:29 wp-courses.php:519
    417417msgid "Teachers"
    418418msgstr ""
  • wp-courses/trunk/wpc-options.php

    r2282707 r2388997  
    22
    33function wpc_register_settings() {
     4
     5    add_option( 'wpc_enable_rest_course', 'false');
     6    add_option( 'wpc_enable_rest_lesson', 'false');
     7    add_option( 'wpc_enable_rest_teacher', 'false');
    48
    59    add_option( 'wpc_show_breadcrumb_trail', 'true');
     
    2832    // register_setting( 'wpc_options', 'wpc_course_page', 'wpc_callback' );
    2933
     34    register_setting( 'wpc_options', 'wpc_enable_rest_course', 'wpc_callback' );
     35    register_setting( 'wpc_options', 'wpc_enable_rest_lesson', 'wpc_callback' );
     36    register_setting( 'wpc_options', 'wpc_enable_rest_teacher', 'wpc_callback' );
     37
    3038    register_setting( 'wpc_options', 'wpc_show_breadcrumb_trail', 'wpc_callback' );
    3139    register_setting( 'wpc_options', 'wpc_show_lesson_numbers', 'wpc_callback' );
     
    6472            settings_fields( 'wpc_options' );
    6573
     74            $wpc_enable_rest_course = get_option('wpc_enable_rest_course');
     75            $wpc_enable_rest_lesson = get_option('wpc_enable_rest_lesson');
     76            $wpc_enable_rest_teacher = get_option('wpc_enable_rest_teacher');
     77
    6678            $wpc_show_breadcrumb_trail = get_option('wpc_show_breadcrumb_trail');
    6779            $wpc_show_lesson_numbers = get_option('wpc_show_lesson_numbers');
     
    88100            $id = get_the_ID();
    89101
     102            if( $wpc_enable_rest_course == 'true' ){
     103                $rest_course_checked = 'checked';
     104            } else {
     105                $rest_course_checked = '';
     106            }
     107
     108            if( $wpc_enable_rest_lesson == 'true' ){
     109                $rest_lesson_checked = 'checked';
     110            } else {
     111                $rest_lesson_checked = '';
     112            }
     113
     114            if( $wpc_enable_rest_teacher == 'true' ){
     115                $rest_teacher_checked = 'checked';
     116            } else {
     117                $rest_teacher_checked = '';
     118            }
     119
    90120            if($wpc_show_breadcrumb_trail == 'true'){
    91121                $breadcrumb_checked = 'checked';
     
    113143
    114144            ?>
     145
     146            <div class="wpc-admin-box">
     147
     148                <h2 class="wpc-admin-box-header">General Options</h2>
     149
     150                <h2>REST API</h2>
     151
     152                <div class="wpc-option">
     153                    <input type="checkbox" id="wpc-enable-lesson-rest" name="wpc_enable_rest_lesson" value="true" <?php echo $rest_lesson_checked; ?>/><label for="wpc-enable-lesson-rest">Enable REST API for Lessons and Modules.  <b>Warning!</b>  If checked, restricted lesson content is accessable <b>TO ANYONE</b> via the REST API.</label>
     154                </div>
     155
     156                <div class="wpc-option">
     157                    <input type="checkbox" id="wpc-enable-course-rest" name="wpc_enable_rest_course" value="true" <?php echo $rest_course_checked; ?>/><label for="wpc-enable-course-rest">Enable REST API for Courses</label>
     158                </div>
     159
     160                <div class="wpc-option">
     161                    <input type="checkbox" id="wpc-enable-teacher-rest" name="wpc_enable_rest_teacher" value="true" <?php echo $rest_teacher_checked; ?>/><label for="wpc-enable-teacher-rest">Enable REST API for Teachers</label>
     162                </div>
     163
     164            </div>
    115165
    116166            <div class="wpc-admin-box">
Note: See TracChangeset for help on using the changeset viewer.