Changeset 2679280
- Timestamp:
- 02/15/2022 04:52:49 PM (4 years ago)
- Location:
- easy-dash-for-learndash/trunk
- Files:
-
- 8 edited
-
admin/tred-admin.php (modified) (3 diffs)
-
admin/tred-settings.php (modified) (1 diff)
-
assets/js/tred-admin.js (modified) (3 diffs)
-
includes/callbacks-actions.php (modified) (1 diff)
-
includes/functions.php (modified) (3 diffs)
-
includes/translations.php (modified) (2 diffs)
-
learndash-easy-dash.php (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
easy-dash-for-learndash/trunk/admin/tred-admin.php
r2677389 r2679280 5 5 'type' => 'select', 6 6 'kind' => '', 7 'options' => ['7','10','14','30','60' ],7 'options' => ['7','10','14','30','60','90','120','180','365','all time'], 8 8 'default' => '30', 9 9 'description'=> __('Some widgets in the dashboard limit queries to the last x days. Choose here how many days you want to limit.', 'learndash-easy-dash'), 10 10 'obs' => __('All widgets with queries limited by days will be affected.', 'learndash-easy-dash'), 11 'final' => __('Default: 30 days. ', 'learndash-easy-dash'),12 'order' => 4,11 'final' => __('Default: 30 days. Options above \'90\' days may not work due to memory size and timeout issues', 'learndash-easy-dash'), 12 'order' => 1, 13 13 ], 14 14 'tred_cache_x_hours' => [ … … 20 20 'obs' => __('All queries will be affected next time they are cached.', 'learndash-easy-dash'), 21 21 'final' => __('Default: 6 hours.', 'learndash-easy-dash'), 22 'order' => 5,22 'order' => 2, 23 23 ], 24 24 'tred_select_x_items' => [ … … 30 30 'obs' => __('All queries that limit the number of items to be selected will be affected. Please note that your chart may look bad if too many items are queried.', 'learndash-easy-dash'), 31 31 'final' => __('Default: 10 items.', 'learndash-easy-dash'), 32 'order' => 6,32 'order' => 3, 33 33 ] 34 34 ]; -
easy-dash-for-learndash/trunk/admin/tred-settings.php
r2677389 r2679280 37 37 foreach($vals['options'] as $v => $label) { 38 38 $pt = (is_integer($v)) ? $label : $v; 39 if($label == 'all time') { 40 $pt = '-1'; 41 } 39 42 ?> 40 43 <option value="<?php echo esc_attr($pt); ?>" <?php -
easy-dash-for-learndash/trunk/assets/js/tred-admin.js
r2677389 r2679280 238 238 let widgetsParents = divTab.find('.tred-widgets-parents'); 239 239 if(!widgetsToShow) { 240 console.log('!widgetsToShow');241 240 return false; 242 241 } 243 242 widgetsArr = widgetsToShow.split(','); 244 243 if(!widgetsArr) { 245 console.log('!widgetsArr');246 244 return false; 247 245 } … … 832 830 } 833 831 //don't do the rest of the code 834 console.log('end here');835 832 return; 836 833 } 837 838 839 840 841 842 843 console.log('go on...');844 834 845 835 //load the translated button texts … … 906 896 } 907 897 898 899 $('select[name="tred_last_x_days"]').on('change', function() { 900 let select = $(this); 901 let value = select.val(); 902 if(value > 90) { 903 alert(value + ' ' + tredElementsTranslation['alert']['more_than_x_days']); 904 } 905 if(value < 0) { 906 alert(tredElementsTranslation['alert']['all_time']); 907 } 908 }); 908 909 //END - PAGE LOADS 909 910 -
easy-dash-for-learndash/trunk/includes/callbacks-actions.php
r2677389 r2679280 277 277 $activity = tred_learndash_get_activity(); 278 278 if(!is_array($activity)) { 279 $response['result'] = 'error';279 $response['result'] = $activity; 280 280 echo json_encode($response); 281 281 die(); -
easy-dash-for-learndash/trunk/includes/functions.php
r2677389 r2679280 3 3 4 4 //UTILITY FUNCTIONS 5 function tred_get_plugin_basic_version($string_version) { 6 //get first two numbers 7 $string_version = preg_replace('/[^0-9]/', '', $string_version); 8 return substr($string_version, 0, 2); 9 } 10 5 11 function tred_year_month_numbers_to_string_month_slash_year($year_month) { 6 12 if(empty($year_month)) { … … 422 428 return $tred_learndash_get_activity; 423 429 } 430 424 431 $transient_expire_time = (int)$hours * HOUR_IN_SECONDS; 432 425 433 global $wpdb; 426 $where_updated = '(activity_updated IS NOT NULL AND activity_updated != "" AND DATEDIFF(NOW(), FROM_UNIXTIME(activity_updated)) < %d)'; 427 $sql_select = 'SELECT * FROM ' . esc_sql( LDLMS_DB::get_table_name( 'user_activity' ) ) . ' WHERE '; 428 $sql_select .= $where_updated; 429 $sql_str = $wpdb->prepare( $sql_select, $days ); 430 $activity = $wpdb->get_results( $sql_str ); 434 $sql_select = 'SELECT * FROM ' . esc_sql( LDLMS_DB::get_table_name( 'user_activity' ) ) . ' WHERE activity_updated IS NOT NULL AND activity_updated != ""'; 435 $sql_prepared = $sql_select; 436 if( !empty($days) && is_numeric($days) && $days > 0 ) { 437 $sql_select .= ' AND DATEDIFF(NOW(), FROM_UNIXTIME(activity_updated)) < %d'; 438 $sql_prepared = $wpdb->prepare( $sql_select, $days ); 439 } 440 $activity = $wpdb->get_results( $sql_prepared ); 431 441 if ( $activity ) { 432 442 set_transient( 'tred_learndash_get_activity_' . $days . '_days', $activity, $transient_expire_time ); … … 637 647 if(!is_numeric($timestamp) || !is_numeric($days)) { 638 648 return false; 649 } 650 if($days <= 0) { 651 //all time 652 return true; 639 653 } 640 654 $startDate = new DateTime("-$days days"); -
easy-dash-for-learndash/trunk/includes/translations.php
r2677389 r2679280 10 10 'select' => esc_html__('select', 'learndash-easy-dash'), 11 11 'go' => esc_html__('go', 'learndash-easy-dash'), 12 'alert' => [ 13 'more_than_x_days' => esc_html__('days for a database query might be too much for your website, depending on how many courses and students it has. You can save and try; if it does not work as expected, go back to reduce this value.', 'learndash-easy-dash'), 14 'all_time' => esc_html__('All time? Really? Depending on how many courses and students your website has, it can be a daunting task. You can save and try; if it does not work as expected, go back to reduce this value.', 'learndash-easy-dash'), 15 ] 12 16 ]; 13 17 } … … 81 85 if(strpos($term, '%d days') !== false) { 82 86 $translation_array[$widget_type][$key][$term] = sprintf( esc_html__($term, 'learndash-easy-dash'), TRED_LAST_X_DAYS ); 87 if('-1' == TRED_LAST_X_DAYS) { 88 $translation_array[$widget_type][$key][$term] = esc_html__(str_ireplace('last %d days', 'all time',$term), 'learndash-easy-dash'); 89 } 83 90 } else if(strpos($term, 'Top %d') !== false) { 84 91 $translation_array[$widget_type][$key][$term] = sprintf( esc_html__($term, 'learndash-easy-dash'), TRED_SELECT_X_ITEMS ); -
easy-dash-for-learndash/trunk/learndash-easy-dash.php
r2677389 r2679280 6 6 * Author: Luis Rock 7 7 * Author URI: https://wptrat.com/ 8 * Version: 2. 0.08 * Version: 2.1.0 9 9 * Text Domain: learndash-easy-dash 10 10 * Domain Path: /languages … … 19 19 if ( ! defined( 'ABSPATH' ) ) exit; 20 20 21 define("TRED_VERSION", "2. 0.0");21 define("TRED_VERSION", "2.1.0"); 22 22 23 23 // Check if LearnDash is active. If not, deactivate... … … 49 49 } //end if( !is_plugin_active('sfwd-lms/sfwd_lms.php' ) ) 50 50 51 52 51 add_action( 'init', 'tred_load_textdomain' ); 53 52 function tred_load_textdomain() { … … 128 127 require_once('includes/callbacks-actions.php'); 129 128 129 // var_dump(TRED_LAST_X_DAYS); 130 // die(); 130 131 131 132 function tred_register_all_scripts_and_styles() { -
easy-dash-for-learndash/trunk/readme.txt
r2677389 r2679280 3 3 Tags: learndash, education, elearning, lms, learning 4 4 Requires at least: 5.0 5 Tested up to: 5. 85 Tested up to: 5.9 6 6 Requires PHP: 5.6 7 Stable tag: 2. 0.07 Stable tag: 2.1.0 8 8 License: GNU General Public License v3.0 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html 10 10 11 **Easy Dash for LearnDash: an improved (and easy) dashboard for your LearnDash site.11 Easy Dash for LearnDash: an improved (and easy) dashboard for your LearnDash site. 12 12 13 13 == Description == … … 69 69 70 70 == Changelog == 71 = 2.1.0 = 72 * New: added more options do "last x days" queries: '120', '180', '365' and 'all time'. 73 * Fixed: tested up to 5.9 74 71 75 = 2.0.0 = 72 76 * New: filter course and get its stats
Note: See TracChangeset
for help on using the changeset viewer.