Beispiel #1
0
 function sensei_check_woocommerce_version($version = '2.1')
 {
     if (Sensei_WC::is_woocommerce_active()) {
         global $woocommerce;
         if (version_compare($woocommerce->version, $version, ">=")) {
             return true;
         }
     }
     return false;
 }
 /**
  * Constructor function.
  * @since  1.0.0
  * @return  void
  */
 public function __construct()
 {
     /* Widget variable settings. */
     $this->woo_widget_cssclass = 'widget_sensei_course_component';
     $this->woo_widget_description = __('This widget will output a list of Courses - New, Featured, Free, Paid, Active, Completed.', 'woothemes-sensei');
     $this->woo_widget_idbase = 'sensei_course_component';
     $this->woo_widget_title = __('Sensei - Course Component', 'woothemes-sensei');
     $this->woo_widget_componentslist = array('usercourses' => __('New Courses', 'woothemes-sensei'), 'featuredcourses' => __('Featured Courses', 'woothemes-sensei'), 'activecourses' => __('My Active Courses', 'woothemes-sensei'), 'completedcourses' => __('My Completed Courses', 'woothemes-sensei'));
     // Add support for the WooCommerce shelf.
     if (Sensei_WC::is_woocommerce_active()) {
         $this->woo_widget_componentslist['freecourses'] = __('Free Courses', 'woothemes-sensei');
         $this->woo_widget_componentslist['paidcourses'] = __('Paid Courses', 'woothemes-sensei');
     }
     /* Widget settings. */
     $widget_ops = array('classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description);
     /* Widget control settings. */
     $control_ops = array('width' => 250, 'height' => 350, 'id_base' => $this->woo_widget_idbase);
     /* Create the widget. */
     parent::__construct($this->woo_widget_idbase, $this->woo_widget_title, $widget_ops, $control_ops);
 }
 *
 * @since 1.8.0
 */
function Sensei()
{
    return Sensei_Main::instance();
}
// set the sensei version number
Sensei()->version = '1.9.2';
//backwards compatibility
global $woothemes_sensei;
$woothemes_sensei = Sensei();
/**
 * Hook in WooCommerce functionality
 */
if (Sensei_WC::is_woocommerce_active()) {
    add_action('init', array('Sensei_WC', 'load_woocommerce_integration_hooks'));
}
/**
 * Load all Template hooks
 */
if (!is_admin()) {
    require_once 'includes/hooks/template.php';
}
/**
 * Plugin updates
 * @since  1.0.1
 */
woothemes_queue_update(plugin_basename(__FILE__), 'bad2a02a063555b7e2bee59924690763', 152116);
/**
 * Sensei Activation Hook registration
    /**
     * Outputs the lessons course signup lingk
     *
     * This hook runs inside the single lesson page.
     *
     * @since 1.9.0
     */
    public static function course_signup_link()
    {
        $course_id = Sensei()->lesson->get_course_id(get_the_ID());
        if (empty($course_id) || 'course' != get_post_type($course_id) || sensei_all_access()) {
            return;
        }
        ?>

        <section class="course-signup lesson-meta">

            <?php 
        $wc_post_id = (int) get_post_meta($course_id, '_course_woocommerce_product', true);
        if (Sensei_WC::is_woocommerce_active() && 0 < $wc_post_id) {
            global $current_user;
            if (is_user_logged_in()) {
                wp_get_current_user();
                $course_purchased = Sensei_Utils::sensei_customer_bought_product($current_user->user_email, $current_user->ID, $wc_post_id);
                if ($course_purchased) {
                    $prereq_course_id = get_post_meta($course_id, '_course_prerequisite', true);
                    $course_link = '<a href="' . esc_url(get_permalink($prereq_course_id)) . '" title="' . esc_attr(get_the_title($prereq_course_id)) . '">' . __('the previous course', 'woothemes-sensei') . '</a>';
                    ?>
                            <div class="sensei-message info">

                                <?php 
                    echo sprintf(__('Please complete %1$s before starting the lesson.', 'woothemes-sensei'), $course_link);
                    ?>

                            </div>

                    <?php 
                } else {
                    ?>

                        <div class="sensei-message info">

                            <?php 
                    $course_link = '<a href="' . esc_url(get_permalink($course_id)) . '"title="' . __('Sign Up', 'woothemes-sensei') . '">' . __('course', 'woothemes-sensei') . '</a>';
                    echo sprintf(__('Please purchase the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link);
                    ?>

                        </div>
                    <?php 
                }
                ?>

                <?php 
            } else {
                ?>

                    <div class="sensei-message info"><?php 
                echo sprintf(__('Please purchase the %1$s before starting the lesson.', 'woothemes-sensei'), '<a href="' . esc_url(get_permalink($course_id)) . '" title="' . __('Sign Up', 'woothemes-sensei') . '">' . __('course', 'woothemes-sensei') . '</a>');
                ?>
</div>

                <?php 
            }
            ?>

            <?php 
        } else {
            ?>

            <?php 
            if (!Sensei_Utils::user_started_course($course_id, get_current_user_id()) && sensei_is_login_required()) {
                ?>

                <div class="sensei-message alert">
                    <?php 
                $course_link = '<a href="' . esc_url(get_permalink($course_id)) . '" title="' . __('Sign Up', 'woothemes-sensei') . '">' . __('course', 'woothemes-sensei') . '</a>';
                if (Sensei_Utils::is_preview_lesson(get_the_ID())) {
                    echo sprintf(__('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei'), $course_link);
                } else {
                    echo sprintf(__('Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link);
                }
                ?>
                </div>

            <?php 
            }
            ?>

            <?php 
        }
        // End If Statement
        ?>

        </section>

        <?php 
    }
Beispiel #5
0
 /**
  * Checks if a user (by email) has bought an item.
  *
  * @deprecated since 1.9.0 use Sensei_WC::has_customer_bought_product($user_id, $product_id)
  * @access public
  * @since  1.0.0
  * @param  string $customer_email
  * @param  int $user_id
  * @param  int $product_id
  * @return bool
  */
 public static function sensei_customer_bought_product($customer_email, $user_id, $product_id)
 {
     $emails = array();
     if ($user_id) {
         $user = get_user_by('id', intval($user_id));
         $emails[] = $user->user_email;
     }
     if (is_email($customer_email)) {
         $emails[] = $customer_email;
     }
     if (sizeof($emails) == 0) {
         return false;
     }
     return Sensei_WC::has_customer_bought_product($user_id, $product_id);
 }
/**
 * sensei_simple_course_price function.
 *
 * @access public
 * @param mixed $post_id
 * @return void
 */
function sensei_simple_course_price($post_id)
{
    //WooCommerce Pricing
    if (Sensei_WC::is_woocommerce_active()) {
        $wc_post_id = get_post_meta($post_id, '_course_woocommerce_product', true);
        if (0 < $wc_post_id) {
            // Get the product
            $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id);
            if (isset($product) && !empty($product) && $product->is_purchasable() && $product->is_in_stock() && !sensei_check_if_product_is_in_cart($wc_post_id)) {
                ?>
    	    		<span class="course-price"><?php 
                echo $product->get_price_html();
                ?>
</span>
    	    	<?php 
            }
            // End If Statement
        }
        // End If Statement
    }
    // End If Statement
}
Beispiel #7
0
 /**
  * Load the WooCommerce single product actions above
  * single courses if woocommerce is active allowing purchase
  * information and actions to be hooked from WooCommerce.
  */
 public static function do_single_course_wc_single_product_action()
 {
     /**
      * this hooks is documented within the WooCommerce plugin.
      */
     if (Sensei_WC::is_woocommerce_active()) {
         do_action('woocommerce_before_single_product');
     }
     // End If Statement
 }
 /**
  * Activate single course if already purchases
  * @return void
  */
 public function activate_purchased_single_course()
 {
     global $post, $current_user;
     if (Sensei_WC::is_woocommerce_active()) {
         if (!is_user_logged_in()) {
             return;
         }
         if (!isset($post->ID)) {
             return;
         }
         $user_id = $current_user->ID;
         $course_id = $post->ID;
         $course_product_id = (int) get_post_meta($course_id, '_course_woocommerce_product', true);
         if (!$course_product_id) {
             return;
         }
         $user_course_status = Sensei_Utils::user_course_status(intval($course_id), $user_id);
         // Ignore course if already completed
         if (Sensei_Utils::user_completed_course($user_course_status)) {
             return;
         }
         // Ignore course if already started
         if ($user_course_status) {
             return;
         }
         // Get all user's orders
         $order_args = array('post_type' => 'shop_order', 'posts_per_page' => -1, 'post_status' => array('wc-processing', 'wc-completed'), 'meta_query' => array(array('key' => '_customer_user', 'value' => $user_id)), 'fields' => 'ids');
         $orders = get_posts($order_args);
         foreach ($orders as $order_post_id) {
             // Get course product IDs from order
             $order = new WC_Order($order_post_id);
             $items = $order->get_items();
             foreach ($items as $item) {
                 $product = wc_get_product($item['product_id']);
                 // handle product bundles
                 if (is_object($product) && $product->is_type('bundle')) {
                     $bundled_product = new WC_Product_Bundle($product->id);
                     $bundled_items = $bundled_product->get_bundled_items();
                     foreach ($bundled_items as $bundled_item) {
                         if ($bundled_item->product_id == $course_product_id) {
                             Sensei_Utils::user_start_course($user_id, $course_id);
                             return;
                         }
                     }
                 } else {
                     // handle regular products
                     if ($item['product_id'] == $course_product_id) {
                         Sensei_Utils::user_start_course($user_id, $course_id);
                         return;
                     }
                 }
             }
         }
     }
 }
 /**
  * Generates content for a single row of the table in the user management
  * screen.
  *
  * @since  1.7.0
  *
  * @param object $item The current item
  *
  * @return void
  */
 protected function get_row_data($item)
 {
     global $wp_version, $woothemes_sensei;
     switch ($this->view) {
         case 'learners':
             // in this case the item passed in is actually the users activity on course of lesson
             $user_activity = $item;
             $post_id = false;
             if ($this->lesson_id) {
                 $post_id = intval($this->lesson_id);
                 $object_type = __('lesson', 'woothemes-sensei');
                 $post_type = 'lesson';
             } elseif ($this->course_id) {
                 $post_id = intval($this->course_id);
                 $object_type = __('course', 'woothemes-sensei');
                 $post_type = 'course';
             }
             if ('complete' == $user_activity->comment_approved || 'graded' == $user_activity->comment_approved || 'passed' == $user_activity->comment_approved) {
                 $status_html = '<span class="graded">' . apply_filters('sensei_completed_text', __('Completed', 'woothemes-sensei')) . '</span>';
             } else {
                 $status_html = '<span class="in-progress">' . apply_filters('sensei_in_progress_text', __('In Progress', 'woothemes-sensei')) . '</span>';
             }
             $title = $woothemes_sensei->learners->get_learner_full_name($user_activity->user_id);
             $a_title = sprintf(__('Edit &#8220;%s&#8221;'), $title);
             // get the learners order for this course if the course was purchased
             $course_order_id_attribute = '';
             if (is_woocommerce_active()) {
                 $course_product_order_id = Sensei_WC::get_learner_course_active_order_id($user_activity->user_id, $post_id);
                 if ($course_product_order_id) {
                     $course_order_id_attribute = ' data-order_id="' . $course_product_order_id . '" ';
                 }
             }
             /**
              * sensei_learners_main_column_data filter
              *
              * This filter runs on the learner management screen for a specific course.
              * It provides the learner row column details.
              *
              * @param array $columns{
              *   type string $title
              *   type string $date_started
              *   type string $course_status (completed, started etc)
              *   type html $action_buttons
              * }
              */
             $column_data = apply_filters('sensei_learners_main_column_data', array('title' => '<strong><a class="row-title" href="' . admin_url('user-edit.php?user_id=' . $user_activity->user_id) . '" title="' . esc_attr($a_title) . '">' . $title . '</a></strong>', 'date_started' => get_comment_meta($user_activity->comment_ID, 'start', true), 'user_status' => $status_html, 'actions' => '<a class="remove-learner button" data-user_id="' . $user_activity->user_id . '" data-post_id="' . $post_id . '" data-post_type="' . $post_type . '" ' . $course_order_id_attribute . '">' . sprintf(__('Remove from %1$s', 'woothemes-sensei'), $object_type) . '</a>'), $item, $post_id, $post_type);
             break;
         case 'lessons':
             $lesson_learners = WooThemes_Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_learners_lesson_learners', array('post_id' => $item->ID, 'type' => 'sensei_lesson_status', 'status' => 'any')));
             $title = get_the_title($item);
             $a_title = sprintf(__('Edit &#8220;%s&#8221;'), $title);
             $grading_action = '';
             if (get_post_meta($item->ID, '_quiz_has_questions', true)) {
                 $grading_action = ' <a class="button" href="' . esc_url(add_query_arg(array('page' => 'sensei_grading', 'lesson_id' => $item->ID, 'course_id' => $this->course_id), admin_url('admin.php'))) . '">' . __('Grading', 'woothemes-sensei') . '</a>';
             }
             $column_data = apply_filters('sensei_learners_main_column_data', array('title' => '<strong><a class="row-title" href="' . admin_url('post.php?action=edit&post=' . $item->ID) . '" title="' . esc_attr($a_title) . '">' . $title . '</a></strong>', 'num_learners' => $lesson_learners, 'updated' => $item->post_modified, 'actions' => '<a class="button" href="' . esc_url(add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->ID, 'course_id' => $this->course_id, 'view' => 'learners'), admin_url('admin.php'))) . '">' . __('Manage learners', 'woothemes-sensei') . '</a> ' . $grading_action), $item, $this->course_id);
             break;
         case 'courses':
         default:
             $course_learners = WooThemes_Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_learners_course_learners', array('post_id' => $item->ID, 'type' => 'sensei_course_status', 'status' => 'any')));
             $title = get_the_title($item);
             $a_title = sprintf(__('Edit &#8220;%s&#8221;'), $title);
             $grading_action = '';
             if (version_compare($wp_version, '4.1', '>=')) {
                 $grading_action = ' <a class="button" href="' . esc_url(add_query_arg(array('page' => 'sensei_grading', 'course_id' => $item->ID), admin_url('admin.php'))) . '">' . __('Grading', 'woothemes-sensei') . '</a>';
             }
             $column_data = apply_filters('sensei_learners_main_column_data', array('title' => '<strong><a class="row-title" href="' . admin_url('post.php?action=edit&post=' . $item->ID) . '" title="' . esc_attr($a_title) . '">' . $title . '</a></strong>', 'num_learners' => $course_learners, 'updated' => $item->post_modified, 'actions' => '<a class="button" href="' . esc_url(add_query_arg(array('page' => $this->page_slug, 'course_id' => $item->ID, 'view' => 'learners'), admin_url('admin.php'))) . '">' . __('Manage learners', 'woothemes-sensei') . '</a> ' . $grading_action), $item);
             break;
     }
     // switch
     return $column_data;
 }
Beispiel #10
0
 /**
  * Determine if the user has and active subscription to give them access
  * to the requested resource.
  *
  * @since 1.9.0
  *
  * @param  boolean$user_access_permission
  * @param  integer $user_id
  * @return boolean $user_access_permission
  */
 public static function get_subscription_permission($user_access_permission, $user_id)
 {
     global $post;
     // ignore the current case if the following conditions are met
     if (!class_exists('WC_Subscriptions') || empty($user_id) || !in_array($post->post_type, array('course', 'lesson', 'quiz')) || !wcs_user_has_subscription($user_id)) {
         return $user_access_permission;
     }
     // at this user has a subscription
     // is the subscription on the the current course?
     $course_id = 0;
     if ('course' == $post->post_type) {
         $course_id = $post->ID;
     } elseif ('lesson' == $post->post_type) {
         $course_id = Sensei()->lesson->get_course_id($post->ID);
     } else {
         $lesson_id = Sensei()->quiz->get_lesson_id($post->ID);
         $course_id = Sensei()->lesson->get_course_id($lesson_id);
     }
     // if the course has no subscription WooCommerce product attached to return the permissions as is
     $product_id = Sensei_WC::get_course_product_id($course_id);
     $product = wc_get_product($product_id);
     if (!in_array($product->get_type(), self::get_subscription_types())) {
         return $user_access_permission;
     }
     // give access if user has active subscription on the product otherwise restrict it.
     // also check if the user was added to the course directly after the subscription started.
     if (wcs_user_has_subscription($user_id, $product_id, 'active') || wcs_user_has_subscription($user_id, $product_id, 'pending-cancel') || self::was_user_added_without_subscription($user_id, $product_id, $course_id)) {
         $user_access_permission = true;
     } else {
         $user_access_permission = false;
         // do not show the WC permissions message
         remove_filter('sensei_the_no_permissions_message', array('Sensei_WC', 'alter_no_permissions_message'), 20, 2);
         Sensei()->permissions_message['title'] = __('No active subscription', 'woothemes-sensei');
         Sensei()->permissions_message['message'] = __('Sorry, you do not have an access to this content without an active subscription.', 'woothemes-sensei');
     }
     return $user_access_permission;
 }
Beispiel #11
0
 /**
  * sensei_woocommerce_complete_order description
  * @since   1.0.3
  * @access  public
  * @param   int $order_id WC order ID
  * @return  void
  */
 public function sensei_woocommerce_complete_order($order_id = 0)
 {
     $order_user = array();
     // Check for WooCommerce
     if (Sensei_WC::is_woocommerce_active() && 0 < $order_id) {
         // Get order object
         $order = new WC_Order($order_id);
         $user = get_user_by('id', $order->get_user_id());
         $order_user['ID'] = $user->ID;
         $order_user['user_login'] = $user->user_login;
         $order_user['user_email'] = $user->user_email;
         $order_user['user_url'] = $user->user_url;
         // Run through each product ordered
         if (0 < sizeof($order->get_items())) {
             foreach ($order->get_items() as $item) {
                 $product_type = '';
                 if (isset($item['variation_id']) && 0 < $item['variation_id']) {
                     $item_id = $item['variation_id'];
                     $product_type = 'variation';
                 } else {
                     $item_id = $item['product_id'];
                 }
                 // End If Statement
                 $_product = $this->sensei_get_woocommerce_product_object($item_id, $product_type);
                 // Get courses that use the WC product
                 $courses = $this->post_types->course->get_product_courses($_product->id);
                 // Loop and update those courses
                 foreach ($courses as $course_item) {
                     $update_course = $this->woocommerce_course_update($course_item->ID, $order_user);
                 }
                 // End For Loop
             }
             // End For Loop
         }
         // End If Statement
         // Add meta to indicate that payment has been completed successfully
         update_post_meta($order_id, 'sensei_payment_complete', '1');
     }
     // End If Statement
 }
Beispiel #12
0
    /**
     * Output the course actions like start taking course, register, add to cart etc.
     *
     * @since 1.9.0
     */
    public static function the_course_enrolment_actions()
    {
        ?>
        <section class="course-meta course-enrolment">
        <?php 
        global $post, $current_user;
        $is_user_taking_course = Sensei_Utils::user_started_course($post->ID, $current_user->ID);
        if (is_user_logged_in() && !$is_user_taking_course) {
            // Get the product ID
            $wc_post_id = absint(get_post_meta($post->ID, '_course_woocommerce_product', true));
            // Check for woocommerce
            if (Sensei_WC::is_woocommerce_active() && 0 < intval($wc_post_id)) {
                sensei_wc_add_to_cart($post->ID);
            } else {
                sensei_start_course_form($post->ID);
            }
            // End If Statement
        } elseif (is_user_logged_in()) {
            // Check if course is completed
            $user_course_status = Sensei_Utils::user_course_status($post->ID, $current_user->ID);
            $completed_course = Sensei_Utils::user_completed_course($user_course_status);
            // Success message
            if ($completed_course) {
                ?>
                <div class="status completed"><?php 
                _e('Completed', 'woothemes-sensei');
                ?>
</div>
                <?php 
                $has_quizzes = Sensei()->course->course_quizzes($post->ID, true);
                if (has_filter('sensei_results_links') || $has_quizzes) {
                    ?>
                    <p class="sensei-results-links">
                        <?php 
                    $results_link = '';
                    if ($has_quizzes) {
                        $results_link = '<a class="view-results" href="' . Sensei()->course_results->get_permalink($post->ID) . '">' . __('View results', 'woothemes-sensei') . '</a>';
                    }
                    /**
                     * Filter documented in Sensei_Course::the_course_action_buttons
                     */
                    $results_link = apply_filters('sensei_results_links', $results_link, $post->ID);
                    echo $results_link;
                    ?>
</p>
                <?php 
                }
                ?>
            <?php 
            } else {
                ?>
                <div class="status in-progress"><?php 
                echo __('In Progress', 'woothemes-sensei');
                ?>
</div>
            <?php 
            }
        } else {
            // Get the product ID
            $wc_post_id = absint(get_post_meta($post->ID, '_course_woocommerce_product', true));
            // Check for woocommerce
            if (Sensei_WC::is_woocommerce_active() && 0 < intval($wc_post_id)) {
                sensei_wc_add_to_cart($post->ID);
            } else {
                if (get_option('users_can_register')) {
                    $my_courses_page_id = '';
                    /**
                     * Filter to force Sensei to output the default WordPress user
                     * registration link.
                     *
                     * @since 1.9.0
                     * @param bool $wp_register_link default false
                     */
                    $wp_register_link = apply_filters('sensei_use_wp_register_link', false);
                    $settings = Sensei()->settings->get_settings();
                    if (isset($settings['my_course_page']) && 0 < intval($settings['my_course_page'])) {
                        $my_courses_page_id = $settings['my_course_page'];
                    }
                    // If a My Courses page was set in Settings, and 'sensei_use_wp_register_link'
                    // is false, link to My Courses. If not, link to default WordPress registration page.
                    if (!empty($my_courses_page_id) && $my_courses_page_id && !$wp_register_link) {
                        $my_courses_url = get_permalink($my_courses_page_id);
                        $register_link = '<a href="' . $my_courses_url . '">' . __('Register', 'woothemes-sensei') . '</a>';
                        echo '<div class="status register">' . $register_link . '</div>';
                    } else {
                        wp_register('<div class="status register">', '</div>');
                    }
                }
                // end if user can register
            }
            // End If Statement
        }
        // End If Statement
        ?>

        </section><?php 
    }
Beispiel #13
0
 /**
  * Change order status with virtual products to completed
  *
  * @deprecated since 1.9.0 use Sensei_WC::virtual_order_payment_complete( $order_status, $order_id )
  *
  * @since  1.1.0
  * @param string $order_status
  * @param int $order_id
  * @return string
  **/
 public function virtual_order_payment_complete($order_status, $order_id)
 {
     return Sensei_WC::virtual_order_payment_complete($order_status, $order_id);
 }
Beispiel #14
0
 function is_woocommerce_active()
 {
     // calling is present instead of is active here
     // as this function can override other is_woocommerce_active
     // function in other woo plugins and Sensei_WC::is_woocommerce_active
     // also check the sensei settings for enable WooCommerce support, which
     // other plugins should not check against.
     return Sensei_WC::is_woocommerce_present();
 }
Beispiel #15
0
 /**
  * Add settings fields.
  * @access public
  * @since  1.0.0
  * @uses   Sensei_Utils::get_slider_types()
  * @return void
  */
 public function init_fields()
 {
     global $pagenow;
     $pages_array = $this->pages_array();
     $posts_per_page_array = array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20');
     $complete_settings = array('passed' => __('Once all the course lessons have been completed', 'woothemes-sensei'), 'complete' => __('At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei'));
     $course_display_settings = array('excerpt' => __('Course Excerpt', 'woothemes-sensei'), 'full' => __('Full Course Content', 'woothemes-sensei'));
     $fields = array();
     $fields['access_permission'] = array('name' => __('Access Permissions', 'woothemes-sensei'), 'description' => __('Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei'), 'type' => 'checkbox', 'default' => true, 'section' => 'default-settings');
     $fields['messages_disable'] = array('name' => __('Disable Private Messages', 'woothemes-sensei'), 'description' => __('Disable the private message functions between learners and teachers.', 'woothemes-sensei'), 'type' => 'checkbox', 'default' => false, 'section' => 'default-settings');
     $fields['course_page'] = array('name' => __('Course Archive Page', 'woothemes-sensei'), 'description' => __('The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei'), 'type' => 'select', 'default' => get_option('woothemes-sensei_courses_page_id', 0), 'section' => 'default-settings', 'required' => 0, 'options' => $pages_array);
     $fields['my_course_page'] = array('name' => __('My Courses Page', 'woothemes-sensei'), 'description' => __('The page to use to display the courses that a user is currently taking as well as the courses a user has complete.', 'woothemes-sensei'), 'type' => 'select', 'default' => get_option('woothemes-sensei_user_dashboard_page_id', 0), 'section' => 'default-settings', 'required' => 0, 'options' => $pages_array);
     $fields['placeholder_images_enable'] = array('name' => __('Use placeholder images', 'woothemes-sensei'), 'description' => __('Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei'), 'type' => 'checkbox', 'default' => false, 'section' => 'default-settings');
     $fields['styles_disable'] = array('name' => __('Disable Sensei Styles', 'woothemes-sensei'), 'description' => __('Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei'), 'type' => 'checkbox', 'default' => false, 'section' => 'default-settings');
     $fields['js_disable'] = array('name' => __('Disable Sensei Javascript', 'woothemes-sensei'), 'description' => __('Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei'), 'type' => 'checkbox', 'default' => false, 'section' => 'default-settings');
     // Course Settings
     $fields['course_completion'] = array('name' => __('Courses are complete:', 'woothemes-sensei'), 'description' => __('This will determine when courses are marked as complete.', 'woothemes-sensei'), 'type' => 'select', 'default' => 'passed', 'section' => 'course-settings', 'required' => 0, 'options' => $complete_settings);
     $fields['course_author'] = array('name' => __('Display Course Author', 'woothemes-sensei'), 'description' => __('Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei'), 'type' => 'checkbox', 'default' => true, 'section' => 'course-settings');
     $fields['my_course_amount'] = array('name' => __('My Courses Pagination', 'woothemes-sensei'), 'description' => __('The number of courses to output for the my courses page.', 'woothemes-sensei'), 'type' => 'range', 'default' => '0', 'section' => 'course-settings', 'required' => 0, 'options' => $posts_per_page_array);
     $fields['course_archive_image_enable'] = array('name' => __('Course Archive Image', 'woothemes-sensei'), 'description' => __('Output the Course Image on the Course Archive Page.', 'woothemes-sensei'), 'type' => 'checkbox', 'default' => true, 'section' => 'course-settings');
     $fields['course_archive_image_width'] = array('name' => __('Image Width - Archive', 'woothemes-sensei'), 'description' => __('The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei'), 'type' => 'text', 'default' => '100', 'section' => 'course-settings', 'required' => 0);
     $fields['course_archive_image_height'] = array('name' => __('Image Height - Archive', 'woothemes-sensei'), 'description' => __('The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei'), 'type' => 'text', 'default' => '100', 'section' => 'course-settings', 'required' => 0);
     $fields['course_archive_image_hard_crop'] = array('name' => __('Image Hard Crop - Archive', 'woothemes-sensei'), 'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="' . esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/') . '">', '</a>'), 'type' => 'checkbox', 'default' => false, 'section' => 'course-settings');
     $fields['course_single_image_enable'] = array('name' => __('Single Course Image', 'woothemes-sensei'), 'description' => __('Output the Course Image on the Single Course Page.', 'woothemes-sensei'), 'type' => 'checkbox', 'default' => false, 'section' => 'course-settings');
     $fields['course_single_image_width'] = array('name' => __('Image Width - Single', 'woothemes-sensei'), 'description' => __('The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei'), 'type' => 'text', 'default' => '100', 'section' => 'course-settings', 'required' => 0);
     $fields['course_single_image_height'] = array('name' => __('Image Height - Single', 'woothemes-sensei'), 'description' => __('The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei'), 'type' => 'text', 'default' => '100', 'section' => 'course-settings', 'required' => 0);
     $fields['course_single_image_hard_crop'] = array('name' => __('Image Hard Crop - Single', 'woothemes-sensei'), 'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="' . esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/') . '">', '</a>'), 'type' => 'checkbox', 'default' => false, 'section' => 'course-settings');
     $fields['course_single_content_display'] = array('name' => __('Single Course page displays:', 'woothemes-sensei'), 'description' => __('Determines what content to display on the single course page.', 'woothemes-sensei'), 'type' => 'select', 'default' => 'excerpt', 'section' => 'course-settings', 'required' => 0, 'options' => $course_display_settings);
     $fields['course_archive_featured_enable'] = array('name' => __('Featured Courses Panel', 'woothemes-sensei'), 'description' => __('Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei'), 'type' => 'checkbox', 'default' => true, 'section' => 'course-settings');
     $fields['course_archive_more_link_text'] = array('name' => __('More link text', 'woothemes-sensei'), 'description' => __('The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei'), 'type' => 'text', 'default' => __('More', 'woothemes-sensei'), 'section' => 'course-settings', 'required' => 0);
     // Lesson Settings
     $fields['lesson_comments'] = array('name' => __('Allow Comments for Lessons', 'woothemes-sensei'), 'description' => __('This will allow learners to post comments on the single Lesson page, only learner who have access to the Lesson will be allowed to comment.', 'woothemes-sensei'), 'type' => 'checkbox', 'default' => true, 'section' => 'lesson-settings');
     $fields['lesson_author'] = array('name' => __('Display Lesson Author', 'woothemes-sensei'), 'description' => __('Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei'), 'type' => 'checkbox', 'default' => true, 'section' => 'lesson-settings');
     $fields['course_lesson_image_enable'] = array('name' => __('Course Lesson Images', 'woothemes-sensei'), 'description' => __('Output the Lesson Image on the Single Course Page.', 'woothemes-sensei'), 'type' => 'checkbox', 'default' => false, 'section' => 'lesson-settings');
     $fields['lesson_archive_image_width'] = array('name' => __('Image Width - Course Lessons', 'woothemes-sensei'), 'description' => __('The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei'), 'type' => 'text', 'default' => '100', 'section' => 'lesson-settings', 'required' => 0);
     $fields['lesson_archive_image_height'] = array('name' => __('Image Height - Course Lessons', 'woothemes-sensei'), 'description' => __('The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei'), 'type' => 'text', 'default' => '100', 'section' => 'lesson-settings', 'required' => 0);
     $fields['lesson_archive_image_hard_crop'] = array('name' => __('Image Hard Crop - Course Lessons', 'woothemes-sensei'), 'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="' . esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/') . '">', '</a>'), 'type' => 'checkbox', 'default' => false, 'section' => 'lesson-settings');
     $fields['lesson_single_image_enable'] = array('name' => __('Single Lesson Images', 'woothemes-sensei'), 'description' => __('Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei'), 'type' => 'checkbox', 'default' => false, 'section' => 'lesson-settings');
     $fields['lesson_single_image_width'] = array('name' => __('Image Width - Single', 'woothemes-sensei'), 'description' => __('The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei'), 'type' => 'text', 'default' => '100', 'section' => 'lesson-settings', 'required' => 0);
     $fields['lesson_single_image_height'] = array('name' => __('Image Height - Single', 'woothemes-sensei'), 'description' => __('The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei'), 'type' => 'text', 'default' => '100', 'section' => 'lesson-settings', 'required' => 0);
     $fields['lesson_single_image_hard_crop'] = array('name' => __('Image Hard Crop - Single', 'woothemes-sensei'), 'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="' . esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/') . '">', '</a>'), 'type' => 'checkbox', 'default' => false, 'section' => 'lesson-settings');
     // Learner Profile settings
     $profile_url_base = apply_filters('sensei_learner_profiles_url_base', __('learner', 'woothemes-sensei'));
     $profile_url_example = trailingslashit(get_site_url()) . $profile_url_base . '/%username%';
     $fields['learner_profile_enable'] = array('name' => __('Public learner profiles', 'woothemes-sensei'), 'description' => sprintf(__('Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei'), $profile_url_example), 'type' => 'checkbox', 'default' => true, 'section' => 'learner-profile-settings');
     $fields['learner_profile_show_courses'] = array('name' => __('Show learner\'s courses', 'woothemes-sensei'), 'description' => __('Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei'), 'type' => 'checkbox', 'default' => true, 'section' => 'learner-profile-settings');
     // Email notifications
     $learner_email_options = array('learner-graded-quiz' => __('Their quiz is graded (auto and manual grading)', 'woothemes-sensei'), 'learner-completed-course' => __('They complete a course', 'woothemes-sensei'));
     $teacher_email_options = array('teacher-started-course' => __('A learner starts their course', 'woothemes-sensei'), 'teacher-completed-course' => __('A learner completes their course', 'woothemes-sensei'), 'teacher-completed-lesson' => __('A learner completes a lesson', 'woothemes-sensei'), 'teacher-quiz-submitted' => __('A learner submits a quiz for grading', 'woothemes-sensei'), 'teacher-new-message' => __('A learner sends a private message to a teacher', 'woothemes-sensei'));
     $global_email_options = array('new-message-reply' => __('They receive a reply to their private message', 'woothemes-sensei'));
     $fields['email_learners'] = array('name' => __('Emails Sent to Learners', 'woothemes-sensei'), 'description' => __('Select the notifications that will be sent to learners.', 'woothemes-sensei'), 'type' => 'multicheck', 'options' => $learner_email_options, 'defaults' => array('learner-graded-quiz', 'learner-completed-course'), 'section' => 'email-notification-settings');
     $fields['email_teachers'] = array('name' => __('Emails Sent to Teachers', 'woothemes-sensei'), 'description' => __('Select the notifications that will be sent to teachers.', 'woothemes-sensei'), 'type' => 'multicheck', 'options' => $teacher_email_options, 'defaults' => array('teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message'), 'section' => 'email-notification-settings');
     $fields['email_global'] = array('name' => __('Emails Sent to All Users', 'woothemes-sensei'), 'description' => __('Select the notifications that will be sent to all users.', 'woothemes-sensei'), 'type' => 'multicheck', 'options' => $global_email_options, 'defaults' => array('new-message-reply'), 'section' => 'email-notification-settings');
     $fields['email_from_name'] = array('name' => __('"From" Name', 'woothemes-sensei'), 'description' => __('The name from which all emails will be sent.', 'woothemes-sensei'), 'type' => 'text', 'default' => get_bloginfo('name'), 'section' => 'email-notification-settings', 'required' => 1);
     $fields['email_from_address'] = array('name' => __('"From" Address', 'woothemes-sensei'), 'description' => __('The address from which all emails will be sent.', 'woothemes-sensei'), 'type' => 'text', 'default' => get_bloginfo('admin_email'), 'section' => 'email-notification-settings', 'required' => 1);
     $fields['email_header_image'] = array('name' => __('Header Image', 'woothemes-sensei'), 'description' => sprintf(__('Enter a URL to an image you want to show in the email\'s header. Upload your image using the %1$smedia uploader%2$s.', 'woothemes-sensei'), '<a href="' . admin_url('media-new.php') . '">', '</a>'), 'type' => 'text', 'default' => '', 'section' => 'email-notification-settings', 'required' => 0);
     $fields['email_footer_text'] = array('name' => __('Email Footer Text', 'woothemes-sensei'), 'description' => __('The text to appear in the footer of Sensei emails.', 'woothemes-sensei'), 'type' => 'textarea', 'default' => sprintf(__('%1$s - Powered by Sensei', 'woothemes-sensei'), get_bloginfo('name')), 'section' => 'email-notification-settings', 'required' => 0);
     $fields['email_base_color'] = array('name' => __('Base Colour', 'woothemes-sensei'), 'description' => sprintf(__('The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei'), '<code>', '</code>'), 'type' => 'color', 'default' => '#557da1', 'section' => 'email-notification-settings', 'required' => 1);
     $fields['email_background_color'] = array('name' => __('Background Colour', 'woothemes-sensei'), 'description' => sprintf(__('The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei'), '<code>', '</code>'), 'type' => 'color', 'default' => '#f5f5f5', 'section' => 'email-notification-settings', 'required' => 1);
     $fields['email_body_background_color'] = array('name' => __('Body Background Colour', 'woothemes-sensei'), 'description' => sprintf(__('The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei'), '<code>', '</code>'), 'type' => 'color', 'default' => '#fdfdfd', 'section' => 'email-notification-settings', 'required' => 1);
     $fields['email_text_color'] = array('name' => __('Body Text Colour', 'woothemes-sensei'), 'description' => sprintf(__('The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei'), '<code>', '</code>'), 'type' => 'color', 'default' => '#505050', 'section' => 'email-notification-settings', 'required' => 1);
     if (Sensei_WC::is_woocommerce_present()) {
         // WooCommerce Settings
         $fields['woocommerce_enabled'] = array('name' => __('Enable WooCommerce Courses', 'woothemes-sensei'), 'description' => __('Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei'), 'type' => 'checkbox', 'default' => true, 'section' => 'woocommerce-settings');
         $fields['course_archive_free_enable'] = array('name' => __('Free Courses Panel', 'woothemes-sensei'), 'description' => __('Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei'), 'type' => 'checkbox', 'default' => true, 'section' => 'woocommerce-settings');
         $fields['course_archive_paid_enable'] = array('name' => __('Paid Courses Panel', 'woothemes-sensei'), 'description' => __('Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei'), 'type' => 'checkbox', 'default' => true, 'section' => 'woocommerce-settings');
     }
     // End If Statement
     if ('en_US' !== get_locale()) {
         $fields['install_language_pack'] = array('name' => __('Install Language Pack', 'woothemes-sensei'), 'description' => __('Use this action to install or re-install translation for your language if available.', 'woothemes-sensei'), 'type' => 'button', 'section' => 'language-settings', 'target' => Sensei_Language_Pack_Manager::get_install_uri(), 'label' => __('Install', 'woothemes-sensei'));
     }
     $this->fields = apply_filters('sensei_settings_fields', $fields);
 }