| @@ -1,0 +1,131 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Tutor Extension | |
| 5 | + * | |
| 6 | + * @package NotificationX\Extensions | |
| 7 | + */ | |
| 8 | + | |
| 9 | +namespace NotificationX\Extensions\Tutor; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * Tutor Extension | |
| 13 | + */ | |
| 14 | +class TutorInline extends Tutor { | |
| 15 | + protected static $instance = null; | |
| 16 | + | |
| 17 | + public $priority = 15; | |
| 18 | + public $id = 'tutor_inline'; | |
| 19 | + public $img = NOTIFICATIONX_ADMIN_URL . 'images/extensions/sources/tutor.png'; | |
| 20 | + public $doc_link = 'https://notificationx.com/docs/tutor-lms/'; | |
| 21 | + public $types = 'inline'; | |
| 22 | + public $module_priority = 7; | |
| 23 | + public $function = 'tutor_lms'; | |
| 24 | + public $is_pro = true; | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * Initially Invoked when initialized. | |
| 28 | + */ | |
| 29 | + public function __construct() { | |
| 30 | + parent::__construct(); | |
| 31 | + add_filter( 'nx_show_on_exclude', array( $this, 'show_on_exclude' ), 10, 4 ); | |
| 32 | + } | |
| 33 | + | |
| 34 | + public function init_extension() | |
| 35 | + { | |
| 36 | + $this->themes = [ | |
| 37 | + 'conv-theme-seven' => array( | |
| 38 | + 'is_pro' => true, | |
| 39 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/pro/tutor-inline.png', | |
| 40 | + 'image_shape' => 'rounded', | |
| 41 | + 'inline_location' => ['tutor/course/single/entry-box/free'], | |
| 42 | + 'template' => [ | |
| 43 | + 'first_param' => 'tag_sales_count', | |
| 44 | + 'second_param' => __('people enrolled', 'notificationx'), | |
| 45 | + 'third_param' => 'tag_custom', | |
| 46 | + 'custom_third_param' => ' ', | |
| 47 | + 'fourth_param' => 'tag_7days', | |
| 48 | + 'custom_fourth_param' => __('in last {{day:7}}', 'notificationx'), | |
| 49 | + ], | |
| 50 | + ), | |
| 51 | + 'conv-theme-eight' => array( | |
| 52 | + 'is_pro' => true, | |
| 53 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/pro/tutor-inline-2.png', | |
| 54 | + 'image_shape' => 'rounded', | |
| 55 | + 'inline_location' => ['tutor_course/loop/after_title'], | |
| 56 | + 'template' => [ | |
| 57 | + 'first_param' => 'tag_sales_count', | |
| 58 | + 'second_param' => __('people enrolled', 'notificationx'), | |
| 59 | + 'third_param' => 'tag_custom', | |
| 60 | + 'custom_third_param' => ' ', | |
| 61 | + 'fourth_param' => 'tag_7days', | |
| 62 | + 'custom_fourth_param' => __('in last {{day:7}}', 'notificationx'), | |
| 63 | + ], | |
| 64 | + ), | |
| 65 | + ]; | |
| 66 | + $this->templates = [ | |
| 67 | + 'tutor_inline_template_sales_count' => [ | |
| 68 | + 'first_param' => [ | |
| 69 | + 'tag_sales_count' => __( 'Sales Count', 'notificationx' ), | |
| 70 | + ], | |
| 71 | + 'third_param' => [ | |
| 72 | + 'tag_course_title' => __('Course Title', 'notificationx'), | |
| 73 | + ], | |
| 74 | + 'fourth_param' => [ | |
| 75 | + 'tag_1day' => __( 'In last 1 day', 'notificationx' ), | |
| 76 | + 'tag_7days' => __( 'In last 7 days', 'notificationx' ), | |
| 77 | + 'tag_30days' => __( 'In last 30 days', 'notificationx' ), | |
| 78 | + ], | |
| 79 | + '_themes' => [ | |
| 80 | + 'tutor_inline_conv-theme-seven', | |
| 81 | + 'tutor_inline_conv-theme-eight', | |
| 82 | + ] | |
| 83 | + ], | |
| 84 | + ]; | |
| 85 | + } | |
| 86 | + | |
| 87 | + /** | |
| 88 | + * @todo Something | |
| 89 | + * | |
| 90 | + * @param [type] $exclude | |
| 91 | + * @param [type] $settings | |
| 92 | + * @return void | |
| 93 | + */ | |
| 94 | + public function show_on_exclude( $exclude, $settings ) { | |
| 95 | + if ( 'inline' === $settings['type'] && $settings['source'] === $this->id ) { | |
| 96 | + $edd_location = $settings['inline_location']; | |
| 97 | + $hooks = [ 'tutor_course/loop/after_title', 'tutor/course/single/entry-box/free' ]; | |
| 98 | + $diff = array_diff( $hooks, $edd_location ); | |
| 99 | + if ( count( $diff ) <= count( $hooks ) ) { | |
| 100 | + return true; | |
| 101 | + } | |
| 102 | + } | |
| 103 | + return $exclude; | |
| 104 | + } | |
| 105 | + | |
| 106 | + /** | |
| 107 | + * Get the instance of called class. | |
| 108 | + * | |
| 109 | + * @return ReviewX | |
| 110 | + */ | |
| 111 | + public static function get_instance($args = null){ | |
| 112 | + if ( is_null( static::$instance ) ) { | |
| 113 | + $class = __CLASS__; | |
| 114 | + if(strpos($class, "NotificationX\\") === 0){ | |
| 115 | + $pro_class = str_replace("NotificationX\\", "NotificationXPro\\", $class); | |
| 116 | + if(class_exists($pro_class)){ | |
| 117 | + $class = $pro_class; | |
| 118 | + } | |
| 119 | + } | |
| 120 | + if(!empty($args)){ | |
| 121 | + static::$instance = new $class($args); | |
| 122 | + } | |
| 123 | + else{ | |
| 124 | + static::$instance = new $class; | |
| 125 | + } | |
| 126 | + } | |
| 127 | + return static::$instance; | |
| 128 | + } | |
| 129 | + | |
| 130 | + | |
| 131 | +} | |