diff --git a/assets/js/ws-ls.js b/assets/js/ws-ls.js index 3d1fe41b..48c6e23c 100755 --- a/assets/js/ws-ls.js +++ b/assets/js/ws-ls.js @@ -24,24 +24,6 @@ jQuery( document ).ready( function ( $ ) { function() { window.location.replace( ws_ls_config[ 'current-url' ] + '?target-cleared=true&wt-user-id=' + user_id ) } ); }); - // ----------------------------------------------------------------------- - // Tabs (ZoZo) - // ----------------------------------------------------------------------- - - // Just saved data or cancelled? If so, set default Tab to be "In Detail" - let default_tab = ( ws_ls_querystring_value( 'ws-edit-saved' ) || ws_ls_querystring_value( 'ws-edit-cancel' ) ) ? 'tab2' : 'tab1'; - - let tabs_are_ready = function( event, item ) { - $( '#ws-ls-tabs-loading' ).addClass( 'ws-ls-hide' ); - $( '#' + item.id ).addClass( 'ws-ls-force-show' ); - $( '#' + item.id ).removeClass( 'ws-ls-hide' ); - }; - - ws_ls_config[ 'tab-config' ][ 'defaultTab' ] = default_tab; - ws_ls_config[ 'tab-config' ][ 'ready' ] = tabs_are_ready; - - tabs_global = $( '#ws-ls-tabs' ).zozoTabs( ws_ls_config[ 'tab-config' ] ); - // ----------------------------------------------------------------------- // Progress Bar // ----------------------------------------------------------------------- diff --git a/assets/js/ws-ls.min.js b/assets/js/ws-ls.min.js index e913dca6..5db95603 100644 --- a/assets/js/ws-ls.min.js +++ b/assets/js/ws-ls.min.js @@ -1 +1 @@ -let tabs_global=!1;jQuery(document).ready(function(a){a(".ws-ls-clear-target").click(function(b){if(b.preventDefault(),!1===confirm(ws_ls_config["clear-target"]))return;let c=a(this).data("user-id");ws_ls_post("ws_ls_clear_target",{"user-id":c},function(){window.location.replace(ws_ls_config["current-url"]+"?target-cleared=true&wt-user-id="+c)})});let b=ws_ls_querystring_value("ws-edit-saved")||ws_ls_querystring_value("ws-edit-cancel")?"tab2":"tab1";if(ws_ls_config["tab-config"].defaultTab=b,ws_ls_config["tab-config"].ready=function(b,c){a("#ws-ls-tabs-loading").addClass("ws-ls-hide"),a("#"+c.id).addClass("ws-ls-force-show"),a("#"+c.id).removeClass("ws-ls-hide")},tabs_global=a("#ws-ls-tabs").zozoTabs(ws_ls_config["tab-config"]),a(".ws-ls-progress").each(function(){let b="#"+a(this).attr("id"),c=a(this).data("progress"),d=a(this).data("percentage-text"),e={strokeWidth:a(this).data("stroke-width"),easing:"easeInOut",duration:a(this).data("animation-duration"),color:a(this).data("stroke-colour"),trailColor:a(this).data("trail-colour"),trailWidth:a(this).data("trail-width"),svgStyle:{width:a(this).data("width"),height:a(this).data("height")},text:{style:{color:a(this).data("text-colour")},value:Math.round(100*c)+"% "+d},step:function(a,b){b.setText(Math.round(100*b.value())+"% "+d)}},f=!1;f="circle"===a(this).data("type")?new ProgressBar.Circle(b,e):new ProgressBar.Line(b,e),f.animate(c)}),"true"===ws_ls_config["photos-enabled"]){let a=document.querySelectorAll(".ws-ls-input-file");Array.prototype.forEach.call(a,function(a){let b=a.nextElementSibling,c=b.innerHTML;a.addEventListener("change",function(a){let d=a.target.value.split("\\").pop();d?b.querySelector("span").innerHTML=d:b.innerHTML=c}),a.addEventListener("focus",function(){a.classList.add("has-focus")}),a.addEventListener("blur",function(){a.classList.remove("has-focus")})})}if("true"===ws_ls_config["is-pro"]){function b(){let b={"user-id":a("#ws-ls-user-id").val()};a(".ws-ls-user-pref-form select, .ws-ls-user-pref-form .custom-field").each(function(){b[a(this).attr("id")]=a(this).val()}),b["ws-ls-dob"]=a("#ws-ls-dob").val(),ws_ls_post("ws_ls_save_preferences",b,ws_ls_user_preference_callback)}a(".ws-ls-user-delete-all").validate({errorClass:"ws-ls-invalid",validClass:"ws-ls-valid",errorContainer:".ws-ls-user-delete-all .ws-ls-error-summary",errorLabelContainer:".ws-ls-user-delete-all .ws-ls-error-summary ul",wrapper:"li",messages:{"ws-ls-delete-all":ws_ls_config["validation-we-ls-history"]},submitHandler:function(a){a.submit()}}),a(".ws-ls-user-pref-form").submit(function(a){a.preventDefault(),"true"!==ws_ls_config["validation-about-you-mandatory"]&&b()});let c=!1;"true"===ws_ls_config["validation-about-you-mandatory"]&&(c=a(".ws-ls-user-pref-form").validate({errorClass:"ws-ls-invalid",validClass:"ws-ls-valid",errorContainer:".ws-ls-user-pref-form .ws-ls-error-summary",errorLabelContainer:".ws-ls-user-pref-form .ws-ls-error-summary ul",wrapper:"li",rules:ws_ls_config["validation-user-pref-rules"],messages:ws_ls_config["validation-user-pref-messages"],submitHandler:function(){b()}}),a.extend(jQuery.validator.messages,{required:ws_ls_config["validation-required"]}),a(".ws-ls-user-pref-form .we-ls-datepicker").length&&("true"===ws_ls_config["us-date"]?a(".ws-ls-user-pref-form .we-ls-datepicker").rules("add",{required:!0,date:!0}):a(".ws-ls-user-pref-form .we-ls-datepicker").rules("add",{required:!0,dateITA:!0})))}});function ws_ls_post(a,b,c){b.action=a,b.security=ws_ls_config["ajax-security-nonce"],jQuery.post(ws_ls_config["ajax-url"],b,function(a){c(b,a)})}function ws_ls_user_preference_callback(a,b){if(1==b){let a=jQuery(".ws-ls-user-pref-form").data("redirect-url");a?window.location.replace(a):window.location.replace(ws_ls_config["current-url"]+"?user-preference-saved=true")}}function ws_ls_querystring_value(a){let b=window.location.search.substring(1),c=b.split("&");for(let b,d=0;d The following shortcode is available in both the free and [Pro/Pro Plus]({{ site.baseurl }}/features.html) version of the plugin. The Pro version has the following additional features: -> * Support for measurements and [custom fields]({{ site.baseurl }}/custom-fields.html). -> * Advanced data table for viewing weight entries. Supporting sorting, paging, editing and deleting. -> * Support for BMI, BMR, suggested calorie intake and Macronutrients. -> * A settings page to allow the user to tailor the plugin to their needs. -> * User Settings - -*Note: Please only place this shortcode once per page. If placed more than once you may experience unstable results.* - -**Overview** - -![Main image](http://yeken.uk/wp-content/uploads/2021/03/wt-e1615930590182.png) - -Displays a chart of the user's weight and custom field ([Pro feature]({{ site.baseurl }}/upgrade.html)) entries in either imperial or metric. The appearance of chart can be customised within the admin settings to change its appearance, type, maximum number of points, etc. - -Below the chart is a target form and weight / custom field entry form. If enabled, the target form allows the user to enter their desired target weight. This target is then displayed on the chart and used by other shortcodes / widgets. - -The main feature of the Overview screen is the ability to enter a weight for the given day or overwrite a previous entry. These entries are then stored against the user's record in chronological order and displayed on the chart and “In Detail” tab. - -[Pro]({{ site.baseurl }}/upgrade.html) users that have enabled measurements will be presented with additional fields that allow your user's to enter measurements for various parts of their body. Measurement entries are displayed alongside the weight entries - -**In detail** - - “The in Detail” tab has another target form for ease of use but its primary function is to display all of the user's weight and custom field entries in tabular format. The [Pro]({{ site.baseurl }}/upgrade.html) version has an improved data table with features such as sortable, expandable and contains links to edit / delete each weight entry. The weight entries can also be filtered by the drop down to show all entries or select them by a week by week basis. This filtering is reflected in the table and the chart. - -**Advanced** - -![Advanced tab](https://yeken.uk/wp-content/uploads/2021/03/advanced-tab-e1616003559458.png) - -With a [Pro Plus](https://shop.yeken.uk/product/weight-tracker-pro-plus/) license an additional tab is present with "Advanced" data. This tab contains the following information; - -- BMI (Body Mass Index) -- BMR (Basal Metabolic Rate) -- Suggested Calorie Intake -- Macronutrients - -For more information on these values, please read our guide on [Weight Tracker calculations]({{ site.baseurl }}/calculations.html). - -**Settings** - - If enabled and you have [Pro]({{ site.baseurl }}/upgrade.html), the last tab presents the logged in user with a settings page. This allows users to specify their height (if BMI enabled), select their preferred measurement units and date format. - -They also have the option to delete their existing data. - -**Shortcode arguments** - -The shortcode supports the following arguments: - -| Argument | Description | Options | Example | -|--|--|--|--| -| allow-delete-data | If set to false (default is true), the section allowing users to delete their own data is hidden. | True (default) or false | [wt-legacy allow-delete-data="false"] | -| bmi-format | Specify the format that BMI should be displayed in. |'label' (default), 'both' or 'index' | [wt-legacy bmi-format='both'] | -| custom-field-groups (8.4+) | Specify one or more custom field group slugs. Specifying groups will ensure that only custom fields within those groups are displayed on the control. | An individual slug or multiple slugs comma delimited. | [wt-legacy custom-field-groups='measurements'] [wt-legacy custom-field-groups='measurements,fitness-test'] | -| custom-field-slugs (8.4+) | Specify one or more custom field slugs. Specifying slugs will ensure only the fields specified are displayed on the control. | An individual slug or multiple slugs comma delimited. | [wt-legacy custom-field-slugs='waist'] [wt-legacy custom-field-slugs='waist,bicep,distance-run'] | -| disable-advanced-tables |If set to true, disable advanced data tables (responsive with delete and add / edit options). | True or false (default). | [wt-legacy disable-advanced-tables=true] | -| disable-second-check | Disables the check to see if the [wt-legacy] shortcode has already been placed on the page. Some themes and plugins may throw an error when this check is enabled. | True or false (default). | [wt-legacy disable-second-check=true] | -| disable-tabs | If set to true, disable tabs and display all content on one "page" | True or false (default). | [wt-legacy disable-tabs=true] | | -| enable-week-ranges | If enabled, a drop down of weeks shall be displayed above the "Weight History" table. When a week is selected, the table will be filtered to only show entries within that week. | True or false (default). | [wt-legacy enable-week-ranges=true] | -| hide-advanced-narrative | If set to true (default is false) hide the text on the Advanced tab which explains each section. | True or false (default). | [wt-legacy hide-advanced-narrative=true] | -| hide-chart-overview (8.4+) | Hide the chart from the "Overview" tab. | True or false (default). | [wt-legacy hide-chart-overview=true] | -| hide-first-target-form | Hide the target form from the Overview tab. | True or false (default). | [wt-legacy hide-first-target-form=true] | -| hide-notes | If set to true (default is false) hide the "notes" section of the form. | True or false (default). | [wt-legacy hide-notes=true] | -| hide-photos | If set to true (default is false) hide the photo upload section of the form. | True or false (default). | [wt-legacy hide-photos=true] | -| hide-tab-advanced | If set to true (default is false) hide the Advanced tab. | True or false (default). | [wt-legacy hide-tab-advanced=true] | -| hide-tab-descriptions | If set to true (default is false) hide the descriptions under the tab title. | True or false (default). | [wt-legacy hide-tab-descriptions=true] | -| hide-tab-photos | If set to true (default is false) hide the Photos tab. | True or false (default). | [wt-legacy hide-tab-photos=true] | -| hide-second-target-form | Hide the target form from the "In Detail" tab. | True or false (default). |[wt-legacy hide-second-target-form=true] | -| min-chart-points|Specifies how many weight entries must be present before the chart is displayed. By default, it is set to 2.|A numeric value. Default 2.|[wt-legacy min-chart-points=0]| -| show-add-button | If true, an "Add Entry" button is displayed above the chart. Clicking this button jumps the user to the weight entry form. | True or false (default). | [wl show-add-button=true] | -| show-chart-history (8.4+) | If true, display a chart on the "History" tab. | True or false (default). | [wt-legacy show-chart-history=true] | -|weight-mandatory|By default, for a weight form, it is mandatory for a weight to be entered. If setting this argument to false, the form can be submitted with out.|true or false (default)|[wt-legacy weight-mandatory='true'] \ No newline at end of file diff --git a/includes/admin-pages/awards/page-awards-add-update.php b/includes/admin-pages/awards/page-awards-add-update.php index 972f71dd..8206850d 100755 --- a/includes/admin-pages/awards/page-awards-add-update.php +++ b/includes/admin-pages/awards/page-awards-add-update.php @@ -23,7 +23,7 @@ function ws_ls_awards_add_update_page() { $mandatory_fields = array_merge( $mandatory_fields, [ 'weight_percentage' ] ); } else if ( 'weight' === $award['category'] ) { if( ws_ls_setting( 'use-imperial' ) ) { - if ( 'stones_pounds' === ws_ls_setting( 'weight-unit' ) ) { + if ( 'stones_pounds' === ws_ls_setting() ) { $mandatory_fields = array_merge( $mandatory_fields, [ 'stones', 'pounds' ] ); $award['value'] = ws_ls_convert_stones_pounds_to_kg( $award['stones'], $award['pounds'] ); } else { @@ -159,7 +159,7 @@ function ws_ls_awards_add_update_page() { if( ws_ls_setting( 'use-imperial' ) ) { - if ( 'stones_pounds' === ws_ls_setting( 'weight-unit' ) ) { + if ( 'stones_pounds' === ws_ls_setting() ) { if ( true === $validation_fail ) { $weight['stones'] = $award['stones']; diff --git a/includes/admin-pages/settings/page-settings-generic.php b/includes/admin-pages/settings/page-settings-generic.php index 48ed6dcc..66027e29 100755 --- a/includes/admin-pages/settings/page-settings-generic.php +++ b/includes/admin-pages/settings/page-settings-generic.php @@ -11,7 +11,7 @@ function ws_ls_settings_page_generic() { $disable_if_not_pro_class = (WS_LS_IS_PRO) ? '' : 'ws-ls-disabled'; $disable_if_not_pro_plus_class = (WS_LS_IS_PRO_PLUS) ? '' : 'ws-ls-disabled-pro-plus'; - $clear_cache = ( isset($_GET['settings-updated']) && 'true' == $_GET['settings-updated'] ) ? true : false; + $clear_cache = isset( $_GET[ 'settings-updated' ] ) && 'true' == $_GET[ 'settings-updated' ]; if ( true === is_admin() && false === empty( $_GET['recreatetables'] ) ) { @@ -230,67 +230,6 @@ function ws_ls_settings_page_generic() { -

- - - - - - - - - - - - - - -
- - -

.

-
- - -
- -

.

-
-

- - - - - -
- - -

-

@@ -340,22 +279,6 @@ function ws_ls_settings_page_generic() {
-

- - - - - -
- - -

.

-

@@ -1209,14 +1132,8 @@ function ws_ls_register_settings(){ register_setting( 'we-ls-options-group', 'ws-ls-fill-under-weight-line' ); register_setting( 'we-ls-options-group', 'ws-ls-fill-under-weight-line-opacity' ); register_setting( 'we-ls-options-group', 'ws-ls-fill-under-weight-line-colour' ); - register_setting( 'we-ls-options-group', 'ws-ls-number-formatting-separator' ); register_setting( 'we-ls-options-group', 'ws-ls-default-aim' ); - // Tabs - register_setting( 'we-ls-options-group', 'ws-ls-tab-window-resize' ); - register_setting( 'we-ls-options-group', 'ws-ls-tab-hide-descriptions' ); - register_setting( 'we-ls-options-group', 'ws-ls-tab-theme' ); - // Pro only open if( WS_LS_IS_PRO ){ @@ -1283,8 +1200,7 @@ function ws_ls_register_settings(){ register_setting( 'we-ls-options-group', 'ws-ls-cal-show-gain' ); register_setting( 'we-ls-options-group', 'ws-ls-cal-add-unit' ); register_setting( 'we-ls-options-group', 'ws-ls-cal-lose-unit' ); - register_setting( 'we-ls-options-group', 'ws-ls-challenges-enabled' ); - register_setting( 'we-ls-options-group', 'ws-ls-awards-delete-when-entry-deleted-enabled' ); + register_setting( 'we-ls-options-group', 'ws-ls-awards-delete-when-entry-deleted-enabled' ); register_setting( 'we-ls-options-group', 'ws-ls-macro-proteins-maintain' ); register_setting( 'we-ls-options-group', 'ws-ls-macro-carbs-maintain' ); diff --git a/includes/admin-pages/user-data/data-groups.php b/includes/admin-pages/user-data/data-groups.php index bba51461..a65169e4 100755 --- a/includes/admin-pages/user-data/data-groups.php +++ b/includes/admin-pages/user-data/data-groups.php @@ -55,8 +55,7 @@ function ws_ls_admin_page_group_view() { if ( true === (bool) apply_filters( 'wlt-filters-admin-entries-per-group-view-enabled', true ) ) { echo ws_ls_component_group_view_entries( [ 'group-id' => $group_id, 'enable-group-select' => false, 'uikit' => false ]); } - - ;?> + ?>

diff --git a/includes/admin-pages/user-data/data-notes.php b/includes/admin-pages/user-data/data-notes.php index 6e8ab11a..381ddca1 100644 --- a/includes/admin-pages/user-data/data-notes.php +++ b/includes/admin-pages/user-data/data-notes.php @@ -28,10 +28,7 @@ function ws_ls_admin_page_data_notes_for_user() { $notes = ws_ls_notes_fetch( $user_id, NULL ); if ( false === empty( $notes ) ) { - - if ( false === empty( $notes ) ) { - array_map( 'ws_ls_notes_render', $notes ); - } + array_map( 'ws_ls_notes_render', $notes ); } else { printf( '

diff --git a/includes/admin-pages/user-data/data-search-results.php b/includes/admin-pages/user-data/data-search-results.php index 3f845882..89ce7bc1 100755 --- a/includes/admin-pages/user-data/data-search-results.php +++ b/includes/admin-pages/user-data/data-search-results.php @@ -23,11 +23,11 @@ function ws_ls_admin_page_search_results() { ws_ls_display_pro_upgrade_notice(); } - $search_term = ws_ls_querystring_value( 'search', false ); + $search_term = ws_ls_querystring_value( 'search' ); if( true === WS_LS_IS_PRO && false === empty( $search_term ) ) { - $search_results = ws_ls_user_search( $search_term,true ); + $search_results = ws_ls_user_search( $search_term ); if( false === empty( $search_results ) ) { diff --git a/includes/admin-pages/user-data/data-summary.php b/includes/admin-pages/user-data/data-summary.php index b507f0b4..f7033e0e 100755 --- a/includes/admin-pages/user-data/data-summary.php +++ b/includes/admin-pages/user-data/data-summary.php @@ -191,12 +191,12 @@ function ws_ls_postbox_league_table() { // If changing gain / loss set options if( false === empty($_GET['show-gain'])) { - $value = ('y' === $_GET['show-gain']) ? true : false; + $value = 'y' === $_GET['show-gain']; update_option('ws-ls-show-gains', $value); } // Are we wanting to see who has lost the most? Or gained? - $show_gain = get_option('ws-ls-show-gains') ? true : false; + $show_gain = (bool) get_option( 'ws-ls-show-gains' ); $title = ( false === $show_gain ) ? __( 'League table for those that have lost the most', WE_LS_SLUG ) : __( 'League Table for those that have gained the most', WE_LS_SLUG ); ws_ls_postbox_header( [ 'title' => $title, 'postbox-id' => 'league-table' ] ); @@ -250,12 +250,12 @@ function ws_ls_postbox_latest_entries() {?> // Show meta data? if( false === empty( $_GET['show-meta'] ) ) { - $value = ( 'y' === $_GET['show-meta'] ) ? true : false; + $value = 'y' === $_GET['show-meta']; update_option('ws-ls-show-meta', $value ); } $entries_limit = (int) get_option( 'ws-ls-entries-limit', 100 ); - $show_meta = get_option( 'ws-ls-show-meta' ) ? true : false; + $show_meta = (bool) get_option( 'ws-ls-show-meta' ); $title = ( false === empty( $entries_limit ) ) ? sprintf( 'Last %d entries', $entries_limit ) : __( 'All entries', WE_LS_SLUG ); diff --git a/includes/admin-pages/user-data/data-view-all.php b/includes/admin-pages/user-data/data-view-all.php index ab4ccb1e..8f7f5f00 100755 --- a/includes/admin-pages/user-data/data-view-all.php +++ b/includes/admin-pages/user-data/data-view-all.php @@ -58,11 +58,11 @@ function ws_ls_admin_page_view_all() { // Show meta data? if ( false === empty( $_GET['show-meta'] ) ) { - $value = ( 'y' === $_GET['show-meta'] ) ? true : false; + $value = 'y' === $_GET['show-meta']; update_option( 'ws-ls-show-meta', $value ); } - $show_meta = get_option( 'ws-ls-show-meta' ) ? true : false; + $show_meta = (bool) get_option( 'ws-ls-show-meta' ); echo ws_ls_data_table_render( [ 'limit' => 5000, 'enable-meta-fields' => $show_meta, 'custom-field-col-size' => 'xs' ] ); diff --git a/includes/ajax.php b/includes/ajax.php index f9d5cfd7..6874b723 100644 --- a/includes/ajax.php +++ b/includes/ajax.php @@ -13,7 +13,7 @@ function ws_ls_clear_target_callback() { $user_id = ws_ls_post_value('user-id'); - if( true == ws_ls_db_target_delete( $user_id ) ){ + if( ws_ls_db_target_delete( $user_id ) ){ wp_send_json(1); } @@ -45,7 +45,7 @@ function ws_ls_save_preferences_callback() { check_ajax_referer( 'ws-ls-nonce', 'security' ); - $in_admin_area = ( NULL !== ws_ls_post_value('we-ls-in-admin' ) ) ? true : false; + $in_admin_area = NULL !== ws_ls_post_value('we-ls-in-admin' ); $fields = []; @@ -70,7 +70,7 @@ function ws_ls_save_preferences_callback() { do_action( 'ws-ls-hook-user-preference-save', (int) $fields['user_id'], $in_admin_area, $fields ); - if( false == ws_ls_set_user_preferences( $in_admin_area, $fields ) ){ + if( ! ws_ls_set_user_preferences( $in_admin_area, $fields ) ){ wp_send_json (0 ); } diff --git a/includes/caching.php b/includes/caching.php index 4d5b0130..ff7755a7 100755 --- a/includes/caching.php +++ b/includes/caching.php @@ -56,7 +56,7 @@ function ws_ls_cache_user_get( $user_id, $key ) { // If no data is found at this key, presume the cache entry has expired, so remove from lookup. if ( false === $data_value ) { unset( $user_lookup_table[ $key ] ); - ws_ls_cache_set( $user_id, $user_lookup_table, WE_LS_CACHE_TIME ); + ws_ls_cache_set( $user_id, $user_lookup_table ); } return $data_value; diff --git a/includes/components.php b/includes/components.php index ddcea9d6..43430be1 100644 --- a/includes/components.php +++ b/includes/components.php @@ -31,7 +31,7 @@ function ws_ls_uikit_summary_boxes( $arguments, $boxes = [] ) { $arguments = wp_parse_args( $arguments, [ 'user-id' => get_current_user_id(), 'breakpoint_s' => 2 ] ); $no_boxes = count( $boxes ); - $breakpoint_m = $no_boxes < 4 ? $no_boxes : 4; + $breakpoint_m = min( $no_boxes, 4 ); $breakpoint_s = $no_boxes < 3 ? $no_boxes : (int) $arguments[ 'breakpoint_s' ]; $divider_count = 0; @@ -519,8 +519,7 @@ function ws_ls_component_latest_versus_another( $args = [] ) { $percentage_difference = 0; } else { - $percentage_difference = ( NULL !== $percentage_difference && - true === $percentage_difference[ 'increase' ] ) ? $percentage_difference[ 'percentage' ] : -$percentage_difference[ 'percentage' ]; + $percentage_difference = ( true === $percentage_difference[ 'increase' ] ) ? $percentage_difference[ 'percentage' ] : -$percentage_difference[ 'percentage' ]; $percentage_difference = ws_ls_round_number( $percentage_difference, 1 ); } diff --git a/includes/converters.php b/includes/converters.php index 35a10c26..32b7916f 100755 --- a/includes/converters.php +++ b/includes/converters.php @@ -56,7 +56,7 @@ function ws_ls_convert_pounds_to_stones( $pounds ) { * @return array */ function ws_ls_convert_pounds_to_stone_pounds( $lb ) { - $weight = [ 'stones' => 0, 'pounds' => 0 ]; + $weight[ 'stones' ] = $lb < 0 ? -1 * floor(-1 * $lb / 14 ) : floor($lb / 14 ); $weight[ 'pounds' ] = Round( fmod( $lb, 14 ), 1 ); return $weight; @@ -80,7 +80,7 @@ function ws_ls_convert_kg_to_lb( $kg ) { * @return array */ function ws_ls_convert_kg_to_stone_pounds( $kg ) { - $weight = [ 'stones' => 0, 'pounds' => 0 ]; + $totalPounds = Round($kg * 2.20462, 3 ); $weight[ 'stones' ] = $totalPounds < 0 ? -1 * floor(-1 * $totalPounds / 14 ) : floor($totalPounds / 14 ); $weight[ 'pounds' ] = Round ( fmod( $totalPounds, 14 ), 2 ); @@ -112,7 +112,6 @@ function ws_ls_weight_display( $kg, $user_id = NULL, $key = false, $force_admin $weight[ 'pounds' ] = ws_ls_convert_kg_to_lb( $kg ); $weight[ 'display' ] = sprintf( '%s%s', $weight[ 'pounds' ], __( 'lbs', WE_LS_SLUG ) ); $weight[ 'graph-value' ] = $weight[ 'pounds' ]; - $weight[ 'pounds' ] = $weight['pounds']; $weight[ 'imperial' ] = true; break; diff --git a/includes/core-forms.php b/includes/core-forms.php index e835a835..c62a87ba 100644 --- a/includes/core-forms.php +++ b/includes/core-forms.php @@ -96,7 +96,7 @@ function ws_ls_form_weight( $arguments = [] ) { if ( true === in_array( $arguments[ 'type' ], [ 'custom-fields', 'weight' ] ) && ( true === empty( $arguments[ 'entry-id' ] ) && empty( $arguments[ 'entry' ] ) ) - && WS_LS_IS_PRO && ws_ls_option_to_bool( 'ws-ls-populate-form-with-values-on-date', 'yes' ) + && WS_LS_IS_PRO && ws_ls_option_to_bool( 'ws-ls-populate-form-with-values-on-date' ) ) { $date = ws_ls_convert_date_to_iso( $arguments[ 'todays-date' ]); @@ -330,7 +330,7 @@ function ws_ls_form_init( $arguments = [] ) { // Are photo fields enabled for this form? $arguments[ 'photos-enabled' ] = ( false === $arguments[ 'hide-fields-photos' ] && true === $arguments[ 'meta-enabled' ] && - true === ws_ls_meta_fields_photo_any_enabled( false ) ); + true === ws_ls_meta_fields_photo_any_enabled() ); // Custom field filtering? $arguments[ 'custom-field-groups' ] = ws_ls_meta_fields_groups_slugs_to_ids( $arguments[ 'custom-field-groups' ] ); diff --git a/includes/core.php b/includes/core.php index 2f88375c..93c9807a 100755 --- a/includes/core.php +++ b/includes/core.php @@ -36,8 +36,7 @@ function ws_ls_config_js() { 'date-picker-locale' => ws_ls_config_js_datapicker_locale(), 'in-admin' => ( is_admin() ) ? 'true' : 'false', 'max-photo-upload' => ws_ls_photo_max_upload_size(), - 'tab-config' => ws_ls_config_js_tab_config(), - 'form-load-previous' => false === is_admin() && WS_LS_IS_PRO && ws_ls_option_to_bool( 'ws-ls-populate-form-with-values-on-date', 'yes' ), + 'form-load-previous' => false === is_admin() && WS_LS_IS_PRO && ws_ls_option_to_bool( 'ws-ls-populate-form-with-values-on-date' ), 'focus' => ws_ls_querystring_value( 'focus' ), 'load-entry-url' => apply_filters( 'wlt_current_url', get_permalink() ), ]; @@ -89,21 +88,4 @@ function ws_ls_config_js_datapicker_locale() { 'firstDay' => get_option( 'start_of_week' ), 'entry-found' => __( 'An entry has been found for this date. Would you like to load the existing entry?', WE_LS_SLUG ) . PHP_EOL . PHP_EOL . __( 'Note: Any unsaved data shall be lost!', WE_LS_SLUG ) ]; -} - -/** - * JS Config for Tabs - * @return array - */ -function ws_ls_config_js_tab_config() { - - return [ 'rounded' => false, - 'multiline' => true, - 'theme' => get_option( 'ws-ls-tab-theme', 'silver' ), // white, crystal, silver, gray, black, orange, red, green, blue, deepblue - 'size' => 'small', - 'minWindowWidth' => (int) get_option( 'ws-ls-tab-window-resize', '1200' ), - 'mobileNav' => true, - 'responsive' => true, - 'animation' => [ 'effects' => 'slideH', 'easing' => 'easeInOutCirc', 'type' => 'jquery' ] - ]; -} +} \ No newline at end of file diff --git a/includes/db.php b/includes/db.php index 10c71dfb..2217e117 100755 --- a/includes/db.php +++ b/includes/db.php @@ -448,6 +448,7 @@ function ws_ls_db_entry_delete_all() { $wpdb->query('TRUNCATE TABLE ' . $wpdb->prefix . WE_LS_TARGETS_TABLENAME ); $wpdb->query('TRUNCATE TABLE ' . $wpdb->prefix . WE_LS_TABLENAME ); $wpdb->query('TRUNCATE TABLE ' . $wpdb->prefix . WE_LS_USER_STATS_TABLENAME ); + } /** @@ -634,7 +635,7 @@ function ws_ls_set_user_preference( $field, $value, $user_id = NULL ) { $db_field_types ); - $result = ($result === false) ? false : true; + $result = ! ( ( $result === false ) ); // Tidy up cache ws_ls_cache_user_delete( $db_fields['user_id'] ); @@ -679,7 +680,7 @@ function ws_ls_set_user_preference_simple( $field, $value, $user_id = NULL ) { [ '%d' ] ); - $result = ($result === false) ? false : true; + $result = ! ( ( $result === false ) ); // If settings are saved correctly, then fire hook for others. if ( true === $result ) { @@ -738,8 +739,7 @@ function ws_ls_db_user_preferences( $user_id = NULL, $use_cache = true ) { $cache = ws_ls_cache_user_get( $user_id, 'user-preferences' ); - if ( true == $use_cache && - false === empty( $cache ) ) { + if ( $use_cache && ! empty( $cache ) ) { return $cache; } @@ -767,8 +767,7 @@ function ws_ls_db_entries_count( $user_id = NULL, $use_cache = true ) { $cache = ws_ls_cache_user_get( $user_id, 'entry-counts' ); - if ( true == $use_cache && - false === empty( $cache ) ) { + if ( $use_cache && ! empty( $cache ) ) { return $cache; } diff --git a/includes/deprecated.php b/includes/deprecated.php index 856c3091..7deacd0e 100644 --- a/includes/deprecated.php +++ b/includes/deprecated.php @@ -18,8 +18,6 @@ function ws_ls_harris_benedict_migrate_old_macro_percentages() { update_option( 'ws-ls-macro-carbs-' . $key, ws_ls_harris_benedict_setting( 'ws-ls-macro-carbs' ) ); update_option( 'ws-ls-macro-fats-' . $key, ws_ls_harris_benedict_setting( 'ws-ls-macro-fats' ) ); } - - return; } } add_action( 'admin_init', 'ws_ls_harris_benedict_migrate_old_macro_percentages' ); diff --git a/includes/email-manager.php b/includes/email-manager.php index 5cb9571f..03141a18 100755 --- a/includes/email-manager.php +++ b/includes/email-manager.php @@ -484,7 +484,7 @@ function ws_ls_emailer_get_all( $only_editable = true ) { $sql = 'Select * from ' . $wpdb->prefix . WE_LS_EMAIL_TABLENAME; - if ( true == $only_editable ) { + if ( $only_editable ) { $sql .= ' where editable = 1'; } diff --git a/includes/form-handler.php b/includes/form-handler.php index df9afeea..6cff15c2 100755 --- a/includes/form-handler.php +++ b/includes/form-handler.php @@ -226,7 +226,7 @@ function ws_ls_form_post_handler_extract_weight( $get_or_post = 'post' ) { // Are we lucky? Metric by default? $kg = 'post' === $get_or_post ? ws_ls_post_value( 'ws-ls-weight-kg', NULL, true ) : - ws_ls_querystring_value( 'ws-ls-weight-kg', false, NULL, true ); + ws_ls_querystring_value( 'ws-ls-weight-kg', false, NULL ); if ( NULL !== $kg ) { return $kg; @@ -234,11 +234,11 @@ function ws_ls_form_post_handler_extract_weight( $get_or_post = 'post' ) { $stones = 'post' === $get_or_post ? ws_ls_post_value( 'ws-ls-weight-stones', NULL, true ) : - ws_ls_querystring_value( 'ws-ls-weight-stones', false, NULL, true ); + ws_ls_querystring_value( 'ws-ls-weight-stones', false, NULL ); $pounds = 'post' === $get_or_post ? ws_ls_post_value( 'ws-ls-weight-pounds', NULL, true ) : - ws_ls_querystring_value( 'ws-ls-weight-pounds', false, NULL, true ); + ws_ls_querystring_value( 'ws-ls-weight-pounds', false, NULL ); // Stones and Pounds if ( NULL !== $stones ) { diff --git a/includes/functions.php b/includes/functions.php index 42221234..254c3bc7 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -309,9 +309,7 @@ function ws_ls_entry_get( $arguments = [] ) { } - $entry = ws_ls_weight_prep( $entry ); - - return $entry; + return ws_ls_weight_prep( $entry ); } /** @@ -480,7 +478,7 @@ function ws_ls_entry_get_todays( $arguments = [] ) { if ( true === empty( $todays_entry ) ) { return NULL; - }; + } return ( true === $arguments[ 'kg-only'] && false === empty( $todays_entry[ 'kg' ] ) ) ? @@ -548,7 +546,7 @@ function ws_ls_entry_get_previous_kg( $user_id = NULL ) { function ws_ls_force_bool_argument( $value ) { return ( 'true' === strtolower( $value ) || - ( true === is_bool( $value ) && true === $value ) ); + ( true === $value ) ); } /** @@ -630,7 +628,7 @@ function ws_ls_force_dimension_argument($value, $default = false) { if ( false === empty($value) ) { // Is this a percentage? - $is_percentage = (false !== stripos($value, '%') ) ? true: false; + $is_percentage = false !== stripos( $value, '%' ); // Strip % sign out if needed $value = ( $is_percentage ) ? ws_ls_remove_non_numeric($value) : $value; @@ -990,7 +988,7 @@ function ws_ls_display_blockquote( $text, $class = '', $just_echo = false, $incl if ( true === $just_echo ) { echo $html_output; - return; + return ''; } return $html_output; @@ -1033,6 +1031,15 @@ function ws_ls_blockquote_login_prompt( ) { return ws_ls_display_blockquote( __( 'You must be logged in to view or edit your data.' , WE_LS_SLUG ) , '', false, true ); } +/** + * @param $title_text + * + * @return string + */ +function ws_ls_title( $title_text ) { + return sprintf( '

%s

', esc_html( $title_text ) ); +} + /** * Calculate max upload size (taken from Drupal) * @return float|int @@ -1152,7 +1159,7 @@ function ws_ls_photo_display_max_upload_size() { $upload_size = ws_ls_photo_get_sizes($max_size); - return ( true == is_array($upload_size) ) ? ws_ls_display_max_server_upload_size() : $upload_size; + return is_array( $upload_size ) ? ws_ls_display_max_server_upload_size() : $upload_size; } /** @@ -1388,8 +1395,7 @@ function ws_ls_user_display_name( $user_id ) { * @return bool */ function ws_ls_challenges_is_enabled() { - return ( WS_LS_IS_PRO_PLUS && - true === ws_ls_settings_challenges_enabled() ); + return WS_LS_IS_PRO_PLUS; } /** @@ -1404,10 +1410,7 @@ function ws_ls_round_number( $number, $decimal_places = 0 ) { var_dump($number); } - - $seperator = ( 'yes' === get_option( 'ws-ls-number-formatting-separator', 'yes' ) ) ? ',' : ''; - - return number_format( $number, $decimal_places, '.', $seperator ); + return number_format( $number, $decimal_places ); } /** @@ -1432,7 +1435,7 @@ function ws_ls_user_preferences_is_enabled() { } /** - * Hass CSS been disabled? + * Has CSS been disabled? * @return bool */ function ws_ls_css_is_disabled() { @@ -1447,14 +1450,6 @@ function ws_ls_targets_enabled() { return ( 'yes' === get_option( 'ws-ls-allow-targets', 'yes' ) ); } -/** - * Challenges enabled? - * @return bool - */ -function ws_ls_settings_challenges_enabled() { - return ( 'yes' === get_option( 'ws-ls-challenges-enabled', 'yes' ) ); -} - /** * Fetch weight unit as readable text * @param $key @@ -1574,13 +1569,10 @@ function ws_ls_setting( $key = 'weight-unit', $user_id = NULL, $force_admin = fa case 'weight-unit': return ws_ls_settings_weight_unit(); - break; case 'use-imperial': return ws_ls_settings_weight_is_imperial(); - break; case 'use-us-dates': return ws_ls_settings_date_is_us(); - break; } return NULL; @@ -1641,7 +1633,7 @@ function ws_ls_weight_difference_from_start( $user_id, $kg ) { */ function ws_ls_get_unit() { - switch ( ws_ls_setting( 'weight-unit' )) { + switch ( ws_ls_setting() ) { case 'pounds_only': $unit = __("lbs", WE_LS_SLUG); break; diff --git a/includes/hooks.php b/includes/hooks.php index 8fa85748..c1f01b2d 100755 --- a/includes/hooks.php +++ b/includes/hooks.php @@ -16,14 +16,10 @@ function ws_ls_build_admin_menu() { add_submenu_page( 'ws-ls-data-home', __( 'User Groups', WE_LS_SLUG ), __( 'User Groups', WE_LS_SLUG ), 'manage_options', 'ws-ls-user-groups', 'ws_ls_settings_page_group' ); add_submenu_page( 'ws-ls-data-home', __( 'Custom Fields', WE_LS_SLUG ), __('Custom Fields', WE_LS_SLUG), 'manage_options', 'ws-ls-meta-fields', 'ws_ls_meta_fields_page' ); add_submenu_page( 'ws-ls-data-home', __( 'Awards', WE_LS_SLUG ), __('Awards', WE_LS_SLUG), 'manage_options', 'ws-ls-awards', 'ws_ls_awards_page' ); - - if ( true === ws_ls_settings_challenges_enabled() ) { - add_submenu_page( 'ws-ls-data-home', __( 'Challenges', WE_LS_SLUG ), __('Challenges', WE_LS_SLUG), 'manage_options', 'ws-ls-challenges', 'ws_ls_challenges_admin_page' ); - } + add_submenu_page( 'ws-ls-data-home', __( 'Challenges', WE_LS_SLUG ), __('Challenges', WE_LS_SLUG), 'manage_options', 'ws-ls-challenges', 'ws_ls_challenges_admin_page' ); $menu_text = ( false === WS_LS_IS_PRO && false === WS_LS_IS_PRO_PLUS ) ? __('Upgrade', WE_LS_SLUG) : __('Your License', WE_LS_SLUG); - add_submenu_page( 'ws-ls-data-home', __('Settings', WE_LS_SLUG), __('Settings', WE_LS_SLUG), 'manage_options', 'ws-ls-settings', 'ws_ls_settings_page'); add_submenu_page( 'ws-ls-data-home', $menu_text, $menu_text, 'manage_options', 'ws-ls-license', 'ws_ls_advertise_pro'); @@ -235,7 +231,7 @@ function ws_ls_enqueue_form_dependencies() { * @return string */ function ws_ls_use_minified() { - return ( defined('SCRIPT_DEBUG' ) && false == SCRIPT_DEBUG ) ? '.min' : ''; + return ( defined('SCRIPT_DEBUG' ) && ! SCRIPT_DEBUG ) ? '.min' : ''; } function ws_ls_admin_config() { diff --git a/includes/license.php b/includes/license.php index e4956567..b14e6d7b 100755 --- a/includes/license.php +++ b/includes/license.php @@ -365,7 +365,7 @@ function ws_ls_has_a_valid_old_pro_license() { $valid_license = get_option(WS_LS_LICENSE_VALID); - if(true == $valid_license) { + if( $valid_license ) { return true; } diff --git a/includes/shortcode-wt-legacy.php b/includes/shortcode-wt-legacy.php deleted file mode 100755 index 5ff51863..00000000 --- a/includes/shortcode-wt-legacy.php +++ /dev/null @@ -1,400 +0,0 @@ - 2, // Minimum number of data entries before chart is shown - 'hide-first-target-form' => false, // Hide first Target form - 'hide-second-target-form' => false, // Hide second Target form - 'custom-field-groups' => '', // If specified, only show custom fields that are within these groups - 'custom-field-slugs' => '', // If specified, only show the custom fields that are specified - 'bmi-format' => 'label', // Format for display BMI - 'show-add-button' => false, // Display a "Add weight" button above the chart. - 'show-chart-history' => false, // Display a chart on the History tab. - 'allow-delete-data' => true, // Show "Delete your data" section - 'hide-notes' => ws_ls_setting_hide_notes(), // Hide notes field - 'hide-photos' => false, // Hide photos part of form - 'hide-chart-overview' => false, // Hide chart on the overview tab - 'hide-tab-photos' => false, // Hide Photos tab - 'hide-tab-advanced' => false, // Hide Advanced tab (macroN, calories, etc) - 'hide-tab-descriptions' => ws_ls_option_to_bool( 'ws-ls-tab-hide-descriptions', 'yes' ), // Hide tab descriptions - 'hide-advanced-narrative' => false, // Hide text describing BMR, MarcoN, etc - 'disable-advanced-tables' => false, // Disable advanced data tables. - 'disable-tabs' => false, // Disable using tabs. - 'disable-second-check' => false, // Disable check to see if [wlt] placed more than once - 'enable-week-ranges' => false, // Enable Week Ranges? - 'user-id' => get_current_user_id(), - 'weight-mandatory' => true, // Is weight mandatory? - ], $user_defined_arguments ); - - if ( true === $ws_ls_wlt_already_placed && false === ws_ls_to_bool( $shortcode_arguments['disable-second-check'] ) ) { - return sprintf('

%s

', __( 'This shortcode can only be placed once on a page / post. To disable this check, try: [wt disable-second-check=true]', WE_LS_SLUG ) ); - } - - ws_ls_enqueue_files(); - - // Display error if user not logged in - if ( false === is_user_logged_in() ) { - return ws_ls_display_blockquote( __( 'You need to be logged in to record your weight.', WE_LS_SLUG ) , '', false, true ); - } - - $user_id = (int) $shortcode_arguments[ 'user-id' ]; - $use_tabs = ( false === ws_ls_to_bool( $shortcode_arguments[ 'disable-tabs' ] ) ); - $show_advanced_tab = ( false === ws_ls_to_bool( $shortcode_arguments[ 'hide-tab-advanced' ] ) && true === WS_LS_IS_PRO_PLUS ); - $show_photos_tab = ( false === ws_ls_to_bool( $shortcode_arguments[ 'hide-tab-photos' ] ) && true === ws_ls_meta_fields_photo_any_enabled( true ) ); - $week_ranges_enabled = ws_ls_to_bool( $shortcode_arguments[ 'enable-week-ranges' ] ); - $shortcode_arguments[ 'min-chart-points' ] = (int) $shortcode_arguments[ 'min-chart-points' ]; - $html_output = ''; - - $html_output .= ws_ls_wt_legacy_notice(); - - // If a form was previously submitted then display resulting message! - if ( false === empty( $save_response[ 'message' ] ) ){ - $html_output .= $save_response[ 'message' ]; - } - - if( 'true' === ws_ls_querystring_value( 'user-preference-saved', 'true' ) ) { - $html_output .= ws_ls_blockquote_success( __( 'Your settings have been successfully saved!', WE_LS_SLUG ) ); - } elseif( 'true' === ws_ls_querystring_value( 'user-delete-all', 'true' ) ) { - $html_output .= ws_ls_blockquote_success( __( 'Your data has successfully been deleted.', WE_LS_SLUG ) ); - } - - $selected_week_number = ( true === $week_ranges_enabled ) ? ws_ls_post_value_numeric( 'week-number' ) : NULL; - $weight_data = ws_ls_entries_get( [ 'week' => $selected_week_number, - 'prep' => true, - 'week' => $selected_week_number, - 'reverse' => true, - 'sort' => 'desc' ] ); - - // If enabled, render tab header - if ( $use_tabs ) { - - $hide_tab_descriptions = ws_ls_to_bool( $shortcode_arguments[ 'hide-tab-descriptions' ] ); - - $html_output .= '
-
- -
'; - } - - // Start Chart Tab - $html_output .= ws_ls_start_tab("wlt-chart", $use_tabs); - - // Display chart? - if ( false === ws_ls_to_bool( $shortcode_arguments[ 'hide-chart-overview' ] ) ) { - $html_output .= ws_ls_shortcode_embed_chart( $weight_data, $shortcode_arguments ); - } - - // Include target form? - if ( true === ws_ls_targets_enabled() && false === ws_ls_to_bool( $shortcode_arguments[ 'hide-first-target-form' ] ) ) { - $html_output .= ws_ls_form_weight( [ 'type' => 'target', 'css-class-form' => 'ws-ls-target-form', 'user-id' => $user_id, 'hide-confirmation' => true ] ) . '
'; - } - - // Display "Add Weight" anchor? - if(true == $shortcode_arguments['show-add-button']) { - $html_output .= ''; - } - - $entry_id = ws_ls_querystring_value('ws-edit-entry', true); - - // Are we in front end and editing enabled, and of course we want to edit, then do so! - if( false === empty( $entry_id ) ) { - - //If we have a Redirect URL, base decode. - $redirect_url = ws_ls_querystring_value( 'redirect' ); - - if ( false === empty( $redirect_url ) ) { - $redirect_url = base64_decode( $redirect_url ); - } - - $html_output .= ws_ls_form_weight( [ 'css-class-form' => 'ws-ls-main-weight-form', - 'user-id' => $user_id, - 'entry-id' => $entry_id, - 'hide-fields-photos' => ws_ls_to_bool( $shortcode_arguments[ 'hide-photos' ] ), - 'redirect-url' => $redirect_url, - 'hide-notes' => ws_ls_to_bool( $shortcode_arguments[ 'hide-notes' ] ), - 'hide-confirmation' => true, - 'custom-field-groups' => $shortcode_arguments[ 'custom-field-groups' ], - 'custom-field-slugs' => $shortcode_arguments[ 'custom-field-slugs' ], - 'weight-mandatory' => $shortcode_arguments[ 'weight-mandatory' ] - ] ); - - } else { - - $html_output .= ws_ls_form_weight( [ 'css-class-form' => 'ws-ls-main-weight-form', - 'user-id' => $user_id, - 'hide-fields-photos' => ws_ls_to_bool( $shortcode_arguments[ 'hide-photos' ] ), - 'hide-notes' => ws_ls_to_bool( $shortcode_arguments[ 'hide-notes' ] ), - 'hide-confirmation' => true, - 'custom-field-groups' => $shortcode_arguments[ 'custom-field-groups' ], - 'custom-field-slugs' => $shortcode_arguments[ 'custom-field-slugs' ], - 'weight-mandatory' => $shortcode_arguments[ 'weight-mandatory' ] - ] ); - } - - // Close first tab - $html_output .= ws_ls_end_tab( $use_tabs ); - - // Start data table tab? - if ( true === $use_tabs ) { - $html_output .= ws_ls_start_tab( 'wlt-weight-history', $use_tabs ); - } - - $week_ranges = ( true === $week_ranges_enabled ) ? ws_ls_week_ranges_get( $user_id ) : NULL; - - // If we have data, display data table - if ( false === empty( $weight_data ) ) { - - if ( true === ws_ls_to_bool( $shortcode_arguments[ 'show-chart-history' ] ) ) { - $html_output .= ws_ls_shortcode_embed_chart( $weight_data, $shortcode_arguments ); - } - - if ( true === ws_ls_targets_enabled() && $use_tabs && - false === ws_ls_to_bool( $shortcode_arguments[ 'hide-second-target-form' ] ) ) { - $html_output .= ws_ls_form_weight( [ 'type' => 'target', 'css-class-form' => 'ws-ls-target-form', 'user-id' => $user_id, 'hide-confirmation' => true ] ) . '
'; - } - - // Display week filters and data tab - $html_output .= ws_ls_title( __( 'Weight History', WE_LS_SLUG ) ); - - if( true === $week_ranges_enabled ) { - $html_output .= ws_ls_week_ranges_display( $week_ranges, $selected_week_number ); - } - - if ( true === WS_LS_IS_PRO && false === ws_ls_to_bool( $shortcode_arguments[ 'disable-advanced-tables' ] ) ){ - $html_output .= ws_ls_shortcode_table( [ 'user-id' => $user_id, 'enable-add-edit' => true, 'enable-meta-fields' => true, - 'week' => $selected_week_number, 'bmi-format' => $shortcode_arguments[ 'bmi-format' ], - 'custom-field-groups' => $shortcode_arguments[ 'custom-field-groups' ], - 'custom-field-slugs' => $shortcode_arguments[ 'custom-field-slugs' ] - ] ); - } else { - $html_output .= ws_ls_display_table( $user_id, $weight_data ); - } - } - elseif ( $use_tabs && false === empty( $selected_week_number ) ) { - $html_output .= __( 'No data could be found for this week, please try selecting another:', WE_LS_SLUG ); - if( true === $week_ranges_enabled ) { - $html_output .= ws_ls_week_ranges_display( $week_ranges, $selected_week_number ); - } - } - elseif ( $use_tabs ) { - $html_output .= __('You haven\'t entered any weight data yet.', WE_LS_SLUG); - } - - $html_output .= ws_ls_end_tab($use_tabs); - - // Photos tab? - if ( true === $show_photos_tab ){ - $html_output .= ws_ls_start_tab( 'wlt-user-photos', $use_tabs ); - $html_output .= ws_ls_shortcode_wlt_display_photos_tab( $user_id ); - $html_output .= ws_ls_end_tab( $use_tabs ); - } - - // Advanced Data? MacroN etc? - if ( true === $show_advanced_tab ){ - $html_output .= ws_ls_start_tab( 'wlt-user-advanced', $use_tabs ); - $html_output .= ws_ls_shortcode_wlt_display_advanced_tab( $shortcode_arguments ); - $html_output .= ws_ls_end_tab( $use_tabs ); - } - - // If enabled, have a third tab to allow users to manage their own settings! - if( true === ws_ls_user_preferences_is_enabled() ){ - $html_output .= ws_ls_start_tab( 'wlt-user-preferences', $use_tabs ); - $html_output .= ws_ls_user_preferences_form( [ 'user-id' => $user_id, 'allow-delete-data' => ws_ls_to_bool( $shortcode_arguments[ 'allow-delete-data' ] ) ] ); - $html_output .= ws_ls_end_tab( $use_tabs ); - } - - $html_output .= ws_ls_end_tab( $use_tabs ); - $html_output .= ws_ls_end_tab( $use_tabs ); - - $ws_ls_wlt_already_placed = true; - - return $html_output; - -} -add_shortcode( 'wlt', 'ws_ls_shortcode_wt_legacy' ); -add_shortcode( 'wt-legacy', 'ws_ls_shortcode_wt_legacy' ); - -/** - * Embed Chart - * - * @param $weight_data - * @param $shortcode_arguments - * - * @return string - */ -function ws_ls_shortcode_embed_chart( $weight_data, $shortcode_arguments ) { - - $shortcode_arguments = wp_parse_args( $shortcode_arguments, [ 'custom-field-groups' => [], - 'custom-field-slugs' => [], - 'hide-title' => false, - 'legend-position' => 'top', - 'uikit' => false, - 'hide-custom-fields' => false, - 'user-id' => get_current_user_id() - - ] ); - - $html_output = ''; - - // Do we have enough data points to display a chart? - if ( ( false === empty( $weight_data ) && count( $weight_data ) >= $shortcode_arguments[ 'min-chart-points' ] ) || - ( true === empty( $weight_data ) && 0 === $shortcode_arguments[ 'min-chart-points' ] ) ) { - - // Display "Add Weight" button? - if( false === empty( $shortcode_arguments[ 'show-add-button' ] ) && - true === ws_ls_to_bool( $shortcode_arguments[ 'show-add-button' ] ) ) { - $html_output .= sprintf('
- -
', - __( 'Add a weight entry', WE_LS_SLUG ) - ); - } - - if ( false === $shortcode_arguments[ 'hide-title'] ) { - $html_output .= ws_ls_title( __( 'In a chart', WE_LS_SLUG ) ); - } - - $html_output .= ws_ls_display_chart( $weight_data, [ 'custom-field-groups' => $shortcode_arguments[ 'custom-field-groups' ], - 'custom-field-slugs' => $shortcode_arguments[ 'custom-field-slugs' ], - 'legend-position' => $shortcode_arguments[ 'legend-position' ], - 'user-id' => $shortcode_arguments[ 'user-id' ], - 'show-meta-fields' => ! $shortcode_arguments[ 'hide-custom-fields' ] - ] ); - - } else { - - $message = sprintf( __( 'A graph shall appear when %d or more weight entries have been entered.', WE_LS_SLUG ), - $shortcode_arguments[ 'min-chart-points' ] ); - - $html_output .= ( true === empty( $shortcode_arguments[ 'uikit' ] ) ) ? - ws_ls_display_blockquote( $message ) : - ws_ls_component_alert( [ 'message' => $message, 'type' => 'warning', 'closable' => false ] ); - - } - - return $html_output; -} - -/** -* HTML for opening tab -* @param $tab_name -* @param $use_tabs -* -* @return string -*/ -function ws_ls_start_tab( $tab_name, $use_tabs ) { - return ( true === $use_tabs ) ? sprintf( '
', $tab_name ) : ''; -} - -/** -* HTML for closing tab -* @param $use_tabs -* -* @return string -*/ -function ws_ls_end_tab( $use_tabs ) { - return ( true === $use_tabs ) ? '
' : ''; -} - -/** -* @param $title_text -* -* @return string -*/ -function ws_ls_title( $title_text ) { - return sprintf( '

%s

', esc_html( $title_text ) ); -} - - -/** - * Display a notice about it being beta - * @return string - */ -function ws_ls_wt_legacy_notice() { - - if ( !current_user_can( 'manage_options' ) ) { - return ''; - } - - $message = '

- - Note: Only administrators can see this message. - -

-

This shortcode, [wt-legacy] will soon be deprecated and removed from the plugin. Please switch to [wt]. Read more:

-

https://docs.yeken.uk/shortcodes/wt.html.

-'; - - return ws_ls_blockquote_error( $message ); -} diff --git a/includes/shortcode-wt.php b/includes/shortcode-wt.php index 02c16f6b..0818cb36 100644 --- a/includes/shortcode-wt.php +++ b/includes/shortcode-wt.php @@ -187,7 +187,6 @@ function ws_ls_shortcode_wt( $user_defined_arguments ) { return $html . '
'; } add_shortcode( 'wt', 'ws_ls_shortcode_wt' ); -add_shortcode( 'wt-beta', 'ws_ls_shortcode_wt' ); /** * Wrapper for [wt] to enable shortcode mode @@ -652,3 +651,64 @@ function ws_ls_wt_link_goto_tab( $tab ) { return esc_url( add_query_arg( 'tab', $tab, $link ) ); } + +/** + * Embed Chart + * + * @param $weight_data + * @param $shortcode_arguments + * + * @return string + */ +function ws_ls_shortcode_embed_chart( $weight_data, $shortcode_arguments ) { + + $shortcode_arguments = wp_parse_args( $shortcode_arguments, [ 'custom-field-groups' => [], + 'custom-field-slugs' => [], + 'hide-title' => false, + 'legend-position' => 'top', + 'uikit' => false, + 'hide-custom-fields' => false, + 'user-id' => get_current_user_id() + + ] ); + + $html_output = ''; + + // Do we have enough data points to display a chart? + if ( ( false === empty( $weight_data ) && count( $weight_data ) >= $shortcode_arguments[ 'min-chart-points' ] ) || + ( true === empty( $weight_data ) && 0 === $shortcode_arguments[ 'min-chart-points' ] ) ) { + + // Display "Add Weight" button? + if( false === empty( $shortcode_arguments[ 'show-add-button' ] ) && + true === ws_ls_to_bool( $shortcode_arguments[ 'show-add-button' ] ) ) { + $html_output .= sprintf('
+ +
', + __( 'Add a weight entry', WE_LS_SLUG ) + ); + } + + if ( false === $shortcode_arguments[ 'hide-title'] ) { + $html_output .= ws_ls_title( __( 'In a chart', WE_LS_SLUG ) ); + } + + $html_output .= ws_ls_display_chart( $weight_data, [ 'custom-field-groups' => $shortcode_arguments[ 'custom-field-groups' ], + 'custom-field-slugs' => $shortcode_arguments[ 'custom-field-slugs' ], + 'legend-position' => $shortcode_arguments[ 'legend-position' ], + 'user-id' => $shortcode_arguments[ 'user-id' ], + 'show-meta-fields' => ! $shortcode_arguments[ 'hide-custom-fields' ] + ] ); + + } else { + + $message = sprintf( __( 'A graph shall appear when %d or more weight entries have been entered.', WE_LS_SLUG ), + $shortcode_arguments[ 'min-chart-points' ] ); + + $html_output .= ( true === empty( $shortcode_arguments[ 'uikit' ] ) ) ? + ws_ls_display_blockquote( $message ) : + ws_ls_component_alert( [ 'message' => $message, 'type' => 'warning', 'closable' => false ] ); + + } + + return $html_output; +} \ No newline at end of file diff --git a/pro-features/db.php b/pro-features/db.php index 4f4f90cf..0fb251a7 100755 --- a/pro-features/db.php +++ b/pro-features/db.php @@ -24,7 +24,7 @@ function ws_ls_db_stats_sum_weight_difference() { global $wpdb; $result = $wpdb->get_var( 'SELECT sum( weight_difference ) FROM ' . $wpdb->prefix . WE_LS_USER_STATS_TABLENAME ); - return ( false == empty( $result ) ) ? floatval( $result ) : false; + return ! empty( $result ) ? floatval( $result ) : false; } /** @@ -42,7 +42,7 @@ function ws_ls_db_stats_insert_missing_user_ids_into_stats() { Select distinct weight_user_id, NULL, NULL, NULL, NOW() - INTERVAL 7 DAY from $data_table_name where weight_weight is not null and weight_user_id not in (Select user_id from $stats_table_name)"; $wpdb->query( $sql ); - return; + } /** @@ -58,8 +58,6 @@ function ws_ls_db_stats_remove_deleted_user_ids_from_stats() { $sql = "Delete from $stats_table_name Where user_id not in ( Select ID from $data_table_name )"; $wpdb->query( $sql ); - - return; } /** @@ -90,7 +88,7 @@ function ws_ls_db_stats_league_table_fetch( $ignore_cache = false, $limit = 10, $where = []; // Select only users that have lost weight? - if( true == ws_ls_force_bool_argument( $losers_only ) ) { + if( ws_ls_force_bool_argument( $losers_only ) ) { $where[] = 'weight_difference <= 0'; } @@ -127,5 +125,4 @@ function ws_ls_db_stats_clear_last_updated_date(){ // Note: Set last update to 7 days ago so this record is considered to be out of date and requiring a refresh $wpdb->query( 'Update ' . $wpdb->prefix . WE_LS_USER_STATS_TABLENAME . ' set last_update = NOW() - INTERVAL 7 DAY' ); - return; } diff --git a/pro-features/email-notifications.php b/pro-features/email-notifications.php index 8d8750a7..2c11651c 100644 --- a/pro-features/email-notifications.php +++ b/pro-features/email-notifications.php @@ -123,8 +123,6 @@ function ws_ls_email_notification( $type, $weight_data ) { ws_ls_emailer_send( $email_addresses, $email_data[ 'subject' ], $message[ 'email' ], $email_data ); } } - - return; } add_action( 'wlt-hook-data-added-edited', 'ws_ls_email_notification', 10, 2); diff --git a/pro-features/export/admin.page.php b/pro-features/export/admin.page.php index ad4dd6f4..c03936a0 100644 --- a/pro-features/export/admin.page.php +++ b/pro-features/export/admin.page.php @@ -266,7 +266,7 @@ function ws_ls_export_admin_page_new() {
-

+

-

+

diff --git a/pro-features/export/db.php b/pro-features/export/db.php index 6c11b0ae..ed54ab0e 100644 --- a/pro-features/export/db.php +++ b/pro-features/export/db.php @@ -275,7 +275,7 @@ function ws_ls_db_export_criteria_step( $export_id, $step = 0 ) { [ '%d' ], [ '%d' ] ); - ws_ls_cache_user_delete( 'exports', (int) $export_id ); + ws_ls_cache_user_delete( 'exports' ); return $result; } @@ -296,7 +296,7 @@ function ws_ls_db_export_criteria_count( $export_id, $count = 0 ) { [ '%d' ], [ '%d' ] ); - ws_ls_cache_user_delete( 'exports', (int) $export_id ); + ws_ls_cache_user_delete( 'exports' ); return $result; } diff --git a/pro-features/footable.php b/pro-features/footable.php index 687c9b22..09acb044 100755 --- a/pro-features/footable.php +++ b/pro-features/footable.php @@ -232,8 +232,6 @@ function ws_ls_datatable_rows( $arguments ) { $gain_loss = $entry[ 'user_profile' ] = sprintf('%s', ws_ls_get_link_to_user_profile( $entry[ 'user_id' ] ), __( 'Check record', WE_LS_SLUG ) ); } elseif ( false === empty( $entry[ 'kg' ] ) ) { $gain_loss = __( 'First weight entry', WE_LS_SLUG ); - } else { - $gain_loss = ''; } if ( false === empty( $entry[ 'kg' ] ) ) { @@ -276,8 +274,6 @@ function ws_ls_datatable_rows( $arguments ) { $gain_loss = $entry[ 'user_profile' ] = sprintf('%s', ws_ls_get_link_to_user_profile( $entry[ 'user_id' ] ), __( 'Check record', WE_LS_SLUG ) ); } elseif ( false === empty( $entry[ 'kg' ] ) ) { $gain_loss = __( 'First weight entry', WE_LS_SLUG ); - } else { - $gain_loss = ''; } if ( true === is_numeric( $gain_loss ) ) { @@ -329,7 +325,7 @@ function ws_ls_datatable_rows( $arguments ) { $row[ 'options' ][ 'classes' ] = 'ws-ls-has-note'; } - array_push( $rows, $row ); + $rows[] = $row; } ws_ls_cache_user_set( $arguments[ 'user-id' ], $cache_key, $rows ); @@ -339,9 +335,7 @@ function ws_ls_datatable_rows( $arguments ) { $rows = array_reverse( $rows ); // Localise the row for the user viewing - $rows = array_map( 'ws_ls_datatable_rows_localise', $rows ); - - return $rows; + return array_map( 'ws_ls_datatable_rows_localise', $rows ); } /** @@ -398,7 +392,7 @@ function ws_ls_datatable_columns( $arguments = [] ) { [ 'name' => 'user_id', 'title' => 'USER ID', 'visible' => false, 'type' => 'number' ] ]; - // If not front end, add nice nice name + // If not front end, add nice name if ( false === $arguments[ 'front-end' ] ) { $columns[] = [ 'name' => 'user_nicename', 'title' => __( 'User', WE_LS_SLUG ), 'breakpoints'=> '', 'type' => 'text' ]; } else { @@ -419,7 +413,8 @@ function ws_ls_datatable_columns( $arguments = [] ) { // Add BMI? if( true === $arguments[ 'enable-bmi' ] && true === ws_ls_bmi_in_tables() ) { - array_push($columns, [ 'name' => 'bmi', 'title' => ws_ls_tooltip( __( 'BMI', WE_LS_SLUG ), __( 'Body Mass Index', WE_LS_SLUG ) ), 'breakpoints'=> 'xs', 'type' => 'text' ] ); + + $columns[] = [ 'name' => 'bmi', 'title' => ws_ls_tooltip( __( 'BMI', WE_LS_SLUG ), __( 'Body Mass Index', WE_LS_SLUG ) ), 'breakpoints'=> 'xs', 'type' => 'text' ]; } if ( true === $arguments[ 'enable-meta' ] && @@ -450,13 +445,13 @@ function ws_ls_datatable_columns( $arguments = [] ) { continue; } - array_push($columns, [ 'name' => 'meta-' . $field['id'], 'title' => stripslashes( $field['field_name'] ), 'breakpoints'=> $column_size, 'type' => 'text' ] ); + $columns[] = [ 'name' => 'meta-' . $field['id'], 'title' => stripslashes( $field['field_name'] ), 'breakpoints'=> $column_size, 'type' => 'text' ]; } } } if ( true === $arguments[ 'enable-notes' ] ) { - array_push($columns, [ 'name' => 'notes', 'title' => __( 'Notes', WE_LS_SLUG ), 'breakpoints'=> 'lg', 'type' => 'text' ] ); + $columns[] = [ 'name' => 'notes', 'title' => __( 'Notes', WE_LS_SLUG ), 'breakpoints'=> 'lg', 'type' => 'text' ]; } return apply_filters( 'wlt-filter-front-end-data-table-columns', $columns, $arguments[ 'front-end' ] ); @@ -513,7 +508,7 @@ function ws_ls_data_js_config() { } else { $config[ 'current-url-base64' ] = ws_ls_get_url( true ); - $config[ 'us-date' ] = ( true == ws_ls_settings_date_is_us() ) ? 'true' : 'false'; + $config[ 'us-date' ] = ws_ls_settings_date_is_us() ? 'true' : 'false'; // Have we detected were in Admin, on a user profile? if ( true === ws_ls_datatable_is_user_profile() ) { diff --git a/pro-features/functions-pages.php b/pro-features/functions-pages.php index 8bebc5d9..10658fa8 100644 --- a/pro-features/functions-pages.php +++ b/pro-features/functions-pages.php @@ -71,8 +71,6 @@ function ws_ls_user_side_bar( $user_id ) { ws_ls_postbox_sidebar_user_information( $user_id ); } elseif ( 'add-entry' === $postbox ) { ws_ls_postbox_sidebar_add_entry( $user_id ); - } elseif ( 'user-information' === $postbox ) { - ws_ls_postbox_sidebar_user_information( $user_id ); } elseif ( 'export-data' === $postbox ) { ws_ls_postbox_sidebar_export_data( $user_id ); } elseif ( 'settings' === $postbox ) { diff --git a/pro-features/functions-stats.php b/pro-features/functions-stats.php index 424bb309..82310681 100644 --- a/pro-features/functions-stats.php +++ b/pro-features/functions-stats.php @@ -35,7 +35,7 @@ function ws_ls_stats_run_cron() { */ function ws_ls_stats_run_cron_for_first_time() { - if( false == get_option('ws-ls-stats-run-for-first-time')) { + if( ! get_option( 'ws-ls-stats-run-for-first-time' ) ) { ws_ls_stats_run_cron(); update_option('ws-ls-stats-run-for-first-time', true); } diff --git a/pro-features/functions.php b/pro-features/functions.php index 6610ead2..0673510b 100755 --- a/pro-features/functions.php +++ b/pro-features/functions.php @@ -144,13 +144,10 @@ function ws_ls_bmi_display( $bmi, $display = 'index' ) { switch ( $display ) { case 'label': return ws_ls_calculate_bmi_label( $bmi ); - break; case 'both': return sprintf( '%s (%s)', ws_ls_calculate_bmi_label( $bmi ), $bmi ); - break; default: return $bmi; - break; } return ''; @@ -400,9 +397,7 @@ function ws_ls_activity_levels() { '1.9' => __( 'Extra Active (very active & physical job)', WE_LS_SLUG ) ]; - $activity_levels = apply_filters( 'wlt-filter-activity-levels', $activity_levels ); - - return $activity_levels; + return apply_filters( 'wlt-filter-activity-levels', $activity_levels ); } /** @@ -419,13 +414,9 @@ function ws_ls_aims() { 3 => __('Gain weight', WE_LS_SLUG) ]; - $aims = apply_filters( 'wlt-filter-aims', $aims ); - - return $aims; + return apply_filters( 'wlt-filter-aims', $aims ); } - - /** * Return an array of heights * @@ -782,7 +773,7 @@ function ws_ls_user_exist( $user_id ) { return false; } - return ( false === get_userdata( $user_id ) ) ? false : true; + return ! ( ( false === get_userdata( $user_id ) ) ); } /** @@ -822,9 +813,7 @@ function ws_ls_get_progress_attribute_from_aim() { $aim_string = 'lose'; } - $aim_string = apply_filters( 'wlt-filter-aim-progress-attribute', $aim_string, $aim_int ); - - return $aim_string; + return apply_filters( 'wlt-filter-aim-progress-attribute', $aim_string, $aim_int ); } /** diff --git a/pro-features/hook-gravity-forms.php b/pro-features/hook-gravity-forms.php index 069e7e8c..3d133ce1 100755 --- a/pro-features/hook-gravity-forms.php +++ b/pro-features/hook-gravity-forms.php @@ -239,9 +239,7 @@ function ws_ls_gravity_forms_keys() { $keys = array_merge( $keys, ws_ls_gravity_forms_weight_keys() ); $keys = array_merge( $keys, ws_ls_gravity_forms_preferences_keys() ); - $keys = array_merge( $keys, ws_ls_gravity_forms_meta_fields_keys() ); - - return $keys; + return array_merge( $keys, ws_ls_gravity_forms_meta_fields_keys() ); } /** @@ -256,9 +254,7 @@ function ws_ls_gravity_forms_weight_keys() { $keys[] = $prefix . 'pounds'; $keys[] = $prefix . 'stones'; - $keys = apply_filters( 'wlt-filters-gf-weight-keys', $keys ); - - return $keys; + return apply_filters( 'wlt-filters-gf-weight-keys', $keys ); } /** @@ -272,9 +268,7 @@ function ws_ls_gravity_forms_preferences_keys() { $keys[] = $prefix . 'body-type'; - $keys = apply_filters( 'wlt-filters-gf-preferences-keys', $keys ); - - return $keys; + return apply_filters( 'wlt-filters-gf-preferences-keys', $keys ); } /** diff --git a/pro-features/plus/awards/functions.php b/pro-features/plus/awards/functions.php index 2ebba2e3..75cbc8b2 100755 --- a/pro-features/plus/awards/functions.php +++ b/pro-features/plus/awards/functions.php @@ -38,7 +38,7 @@ function ws_ls_awards_categories( $simple = false) { } - $fields = [ + return [ 'bmi' => __('BMI: Change', WE_LS_SLUG ), 'bmi-equals' => __('BMI: Equals', WE_LS_SLUG ), 'weight-target' => __('Weight: Target met (based on user aim)', WE_LS_SLUG ), @@ -47,7 +47,6 @@ function ws_ls_awards_categories( $simple = false) { ]; - return $fields; } /** @@ -62,10 +61,8 @@ function ws_ls_awards_gain_loss_display( $gain_loss ) { switch ( $gain_loss ) { case 'gain'; return __('Gain', WE_LS_SLUG); - break; case 'loss': return __('Loss', WE_LS_SLUG); - break; default: return ''; } @@ -213,7 +210,7 @@ function ws_ls_awards_to_give( $user_id = NULL, $change_type = NULL, $losing_wei // Loop through each award in DB, count it's type and decide whether to consider issuing it. return [ - 'any' => ( count( $awards ) > 0 ) ? true : false, + 'any' => count( $awards ) > 0, 'counts' => $counts, 'awards' => $awards ]; @@ -367,5 +364,5 @@ function ws_ls_awards_render_badges( $user_defined_arguments ) { * @return bool */ function ws_ls_awards_email_notifications_enabled() { - return 'y' === get_option('ws-ls-awards-email-notifications', false ) ? true : false; + return 'y' === get_option('ws-ls-awards-email-notifications', false ); } diff --git a/pro-features/plus/awards/hooks.php b/pro-features/plus/awards/hooks.php index c191c764..e9940da6 100755 --- a/pro-features/plus/awards/hooks.php +++ b/pro-features/plus/awards/hooks.php @@ -179,7 +179,7 @@ function ws_ls_awards_listen( $info, $weight_object ) { // Percentage of body weight lost // --------------------------------------------------------------- - if ( false === empty( $awards['counts']['weight-percentage'] ) && false === empty( $weight_object['difference_from_start_kg'] ) ) { + if ( false === empty( $awards['counts']['weight-percentage'] ) ) { $percentage_difference = ws_ls_calculate_percentage_difference( $start_weight, $weight_object['kg'] ); diff --git a/pro-features/plus/challenge/db.php b/pro-features/plus/challenge/db.php index 96b2b862..7b367769 100644 --- a/pro-features/plus/challenge/db.php +++ b/pro-features/plus/challenge/db.php @@ -367,9 +367,7 @@ function ws_ls_challenges_stats( $challenge_id ) { } global $wpdb; - - $stats = [ 'count' => NULL, 'to-be-processed' => NULL, 'processed' => NULL ]; - + $challenge_id = (int) $challenge_id; $stats[ 'count' ] = $wpdb->get_var( 'SELECT count( user_id ) FROM ' . $wpdb->prefix . WE_LS_MYSQL_CHALLENGES_DATA . ' WHERE challenge_id = ' . $challenge_id ); @@ -456,7 +454,6 @@ function ws_ls_challenges_get_meal_tracker_entries( $user_id, $start_date = NULL $result = $wpdb->get_results( $sql, ARRAY_A ); - $result = ( false === empty( $result ) ) ? $result : false; + return ( ! empty( $result ) ) ? $result : false; - return $result; } diff --git a/pro-features/plus/challenge/functions.php b/pro-features/plus/challenge/functions.php index 9f7af942..e5bb86ea 100644 --- a/pro-features/plus/challenge/functions.php +++ b/pro-features/plus/challenge/functions.php @@ -502,7 +502,7 @@ function ws_ls_challenges_show_filters() { */ function ws_ls_challenge_filters_group_select_values() { - $groups = ws_ls_groups( true ); + $groups = ws_ls_groups(); return wp_list_pluck( $groups, 'name', 'id' ); } @@ -520,7 +520,5 @@ function ws_ls_challenge_link( $challenge_id, $mode = 'view' ) { $url = sprintf( 'admin.php?page=ws-ls-challenges&mode=%1$s&challenge-id=%2$d', $mode, $challenge_id ); - $url = admin_url( $url ); - - return $url; + return admin_url( $url ); } diff --git a/pro-features/plus/challenge/shortcodes.php b/pro-features/plus/challenge/shortcodes.php index e3d857b1..ce1c9445 100644 --- a/pro-features/plus/challenge/shortcodes.php +++ b/pro-features/plus/challenge/shortcodes.php @@ -21,7 +21,7 @@ function ws_ls_challenges_shortcodes_opt_in( $user_defined_arguments ) { $get_optin = ws_ls_querystring_value( 'opt-in' ); // Update user preferences; - if ( false !== $get_optin && true === in_array( $get_optin, [ 'yes', 'no' ] ) ) { + if ( true === in_array( $get_optin, [ 'yes', 'no' ] ) ) { ws_ls_set_user_preference_simple( 'challenge_opt_in', ( 'yes' === $get_optin ) ? 1 : 0 ); return sprintf( '

%1$s %2$s.

', diff --git a/pro-features/plus/harris-benedict.php b/pro-features/plus/harris-benedict.php index d05ebc19..05ad34ba 100644 --- a/pro-features/plus/harris-benedict.php +++ b/pro-features/plus/harris-benedict.php @@ -88,13 +88,11 @@ function ws_ls_harris_benedict_calculate_calories_raw( $bmr, $gender, $activity_ // Lose // -------------------------------------------------- - $calories_to_lose = ws_ls_harris_benedict_filter_calories_to_lose( $calorie_intake['maintain']['total'], $gender, false ); + $calories_to_lose = ws_ls_harris_benedict_filter_calories_to_lose( $calorie_intake['maintain']['total'], $gender ); $calories_to_lose = ( $calorie_intake['maintain']['total'] > $calories_to_lose ) ? $calorie_intake['maintain']['total'] - $calories_to_lose : $calorie_intake['maintain']['total']; $is_female = ws_ls_is_female_raw( $gender ); - $calorie_cap = ( true == $is_female ) ? - ws_ls_harris_benedict_setting( 'ws-ls-female-cal-cap' ) - : ws_ls_harris_benedict_setting( 'ws-ls-male-cal-cap' ); + $calorie_cap = $is_female ? ws_ls_harris_benedict_setting( 'ws-ls-female-cal-cap' ) : ws_ls_harris_benedict_setting( 'ws-ls-male-cal-cap' ); // If suggested calorie intake to lose weight is above the cap, then set to cap. if ( $calories_to_lose > $calorie_cap ) { @@ -140,9 +138,7 @@ function ws_ls_harris_benedict_calculate_calories_raw( $bmr, $gender, $activity_ $calorie_intake[ $key ] = array_map('ws_ls_round_bmr_harris', $calorie_intake[$key]); } - $calorie_intake = apply_filters( 'wlt-filter-harris-benedict', $calorie_intake, $user_id, $bmr, $activity_level, $calories_to_lose, $calories_to_gain, $gender ); - - return $calorie_intake; + return apply_filters( 'wlt-filter-harris-benedict', $calorie_intake, $user_id, $bmr, $activity_level, $calories_to_lose, $calories_to_gain, $gender ); } /** @@ -458,9 +454,7 @@ function ws_ls_display_calorie_cap( $user_id = false ) { function ws_ls_display_calorie_cap_raw( $gender ) { $is_female = ws_ls_is_female_raw( $gender ); - $calorie_cap = ( true == $is_female ) ? - ws_ls_harris_benedict_setting( 'ws-ls-female-cal-cap' ) : - ws_ls_harris_benedict_setting( 'ws-ls-male-cal-cap' ); + $calorie_cap = $is_female ? ws_ls_harris_benedict_setting( 'ws-ls-female-cal-cap' ) : ws_ls_harris_benedict_setting( 'ws-ls-male-cal-cap' ); return sprintf('%s %s %s. %s %s.', ($is_female) ? __('Female', WE_LS_SLUG ) : __('Male', WE_LS_SLUG ), @@ -483,7 +477,7 @@ function ws_ls_harris_benedict_show_lose_figures() { return false; } - return 'no' === get_option('ws-ls-cal-show-loss', true ) ? false : true; + return ! ( 'no' === get_option( 'ws-ls-cal-show-loss', true ) ); } /** @@ -497,7 +491,7 @@ function ws_ls_harris_benedict_show_gain_figures() { return false; } - return 'yes' === get_option('ws-ls-cal-show-gain', false ) ? true : false; + return 'yes' === get_option('ws-ls-cal-show-gain', false ); } /** @@ -526,7 +520,7 @@ function ws_ls_harris_benedict_filter_show_hide_gains_loss( $calorie_intake ) { return $calorie_intake; } -add_filter( 'wlt-filter-calories-pre', 'ws_ls_harris_benedict_filter_show_hide_gains_loss', 10, 1 ); +add_filter( 'wlt-filter-calories-pre', 'ws_ls_harris_benedict_filter_show_hide_gains_loss' ); /** * Return the setting for calories to add weight diff --git a/pro-features/plus/macronutrient-calculator.php b/pro-features/plus/macronutrient-calculator.php index 9f8cbe4a..86d8df73 100644 --- a/pro-features/plus/macronutrient-calculator.php +++ b/pro-features/plus/macronutrient-calculator.php @@ -153,7 +153,7 @@ function ws_ls_macro_render_table($user_id, $missing_data_text = false, $additio
', ws_ls_get_macro_name( $key ), - ws_ls_round_number( $macros[$key]['calories'], 0 ), + ws_ls_round_number( $macros[$key]['calories'] ), __('Total', WE_LS_SLUG), __('Breakfast', WE_LS_SLUG), __('Lunch', WE_LS_SLUG), diff --git a/pro-features/plus/messaging/db.php b/pro-features/plus/messaging/db.php index 6171485c..49189e0e 100644 --- a/pro-features/plus/messaging/db.php +++ b/pro-features/plus/messaging/db.php @@ -236,7 +236,6 @@ function ws_ls_messages_db_stats( $user_id ) { $latest_note_id = $wpdb->get_var( 'SELECT id FROM ' . $wpdb->prefix . WE_LS_MYSQL_MESSAGES . ' WHERE `note` = 1 and `to` = ' . $user_id . ' order by created desc' ); $latest_note = ws_ls_messaging_db_get( $latest_note_id ); - $stats = [ 'notes-count' => NULL, 'notes-count-visible' => NULL ]; $user_id = (int) $user_id; $stats[ 'notes-count' ] = $wpdb->get_var( 'SELECT count( id ) FROM ' . $wpdb->prefix . WE_LS_MYSQL_MESSAGES . ' WHERE `note` = 1 and `to` = ' . $user_id ); $stats[ 'notes-count-visible' ] = $wpdb->get_var( 'SELECT count( id ) FROM ' . $wpdb->prefix . WE_LS_MYSQL_MESSAGES . ' WHERE `note` = 1 and `visible_to_user` = 1 and `to` = ' . $user_id ); diff --git a/pro-features/plus/messaging/functions-notes.php b/pro-features/plus/messaging/functions-notes.php index 43f7003a..deb6d43c 100644 --- a/pro-features/plus/messaging/functions-notes.php +++ b/pro-features/plus/messaging/functions-notes.php @@ -124,6 +124,8 @@ function ws_ls_notes_render( $note, $echo = true, $uikit = false, $alternate = f } echo $html; + + return ''; } /** @@ -140,7 +142,5 @@ function ws_ls_notes_sanitise( $content ) { $content = stripslashes( $content ); $content = wp_kses_post( $content ); - $content = str_replace( PHP_EOL, '
', $content ); - - return $content; + return str_replace( PHP_EOL, '
', $content ); } diff --git a/pro-features/plus/meta-fields/db.php b/pro-features/plus/meta-fields/db.php index f4b85c79..0ce305b3 100755 --- a/pro-features/plus/meta-fields/db.php +++ b/pro-features/plus/meta-fields/db.php @@ -15,9 +15,7 @@ function ws_ls_meta( $entry_id ) { $sql = $wpdb->prepare( 'Select * from ' . $wpdb->prefix . WE_LS_MYSQL_META_ENTRY . ' where entry_id = %d', $entry_id ); - $data = $wpdb->get_results( $sql, ARRAY_A ); - - return $data; + return $wpdb->get_results( $sql, ARRAY_A ); } /** @@ -33,9 +31,7 @@ function ws_ls_meta_for_given_meta_field( $meta_field_id ) { $sql = $wpdb->prepare( 'Select * from ' . $wpdb->prefix . WE_LS_MYSQL_META_ENTRY . ' where meta_field_id = %d', $meta_field_id ); - $data = $wpdb->get_results( $sql, ARRAY_A ); - - return $data; + return $wpdb->get_results( $sql, ARRAY_A ); } /** @@ -159,11 +155,9 @@ function ws_ls_meta_fields_enabled() { if ( false === empty( $fields ) ) { // Remove any disabled fields! - $fields = array_filter( $fields, function( $value ) { + return array_filter( $fields, function( $value ) { return ( false === empty( $value['enabled'] ) && 2 === (int) $value['enabled'] ); }); - - return $fields; } return []; @@ -394,7 +388,7 @@ function ws_ls_meta_fields_key_exist( $key ) { $count = $wpdb->get_var( $sql ); - return ( 0 === (int) $count ) ? false : true; + return ! ( ( 0 === (int) $count ) ); } /** diff --git a/pro-features/plus/meta-fields/functions-photos.php b/pro-features/plus/meta-fields/functions-photos.php index edad6de5..9a4e031b 100644 --- a/pro-features/plus/meta-fields/functions-photos.php +++ b/pro-features/plus/meta-fields/functions-photos.php @@ -115,7 +115,7 @@ function ws_ls_meta_fields_photos_process_upload( $field_name, $date_text = NULL // The wp_insert_attachment function needs the literal system path, which was passed back from wp_handle_upload $file_name_and_location = $uploaded_file['file']; - if( true == empty( $user_id ) ){ + if( empty( $user_id ) ){ $user_id = get_current_user_id(); } diff --git a/pro-features/plus/meta-fields/functions.php b/pro-features/plus/meta-fields/functions.php index 7c9e0c8a..b8f1bfca 100755 --- a/pro-features/plus/meta-fields/functions.php +++ b/pro-features/plus/meta-fields/functions.php @@ -229,10 +229,8 @@ function ws_ls_fields_display_field_value_yes_no( $value ) { switch ( (int) $value ) { case 1: return __('No', WE_LS_SLUG); - break; case 2: return __('Yes', WE_LS_SLUG); - break; default: return ''; diff --git a/pro-features/plus/meta-fields/hooks.php b/pro-features/plus/meta-fields/hooks.php index 66d4842d..aea51332 100755 --- a/pro-features/plus/meta-fields/hooks.php +++ b/pro-features/plus/meta-fields/hooks.php @@ -145,10 +145,7 @@ function ws_ls_meta_fields_ajax_custom_field_groups_get(){ $rows = ws_ls_meta_fields_groups( false ); foreach ( $rows as &$row ) { - $row[ 'id' ] = $row[ 'id' ]; - $row[ 'slug' ] = $row[ 'slug' ]; - $row[ 'name' ] = $row[ 'name' ]; - $row[ 'count' ] = ws_ls_meta_fields_groups_count( $row[ 'id' ] ); + $row[ 'count' ] = ws_ls_meta_fields_groups_count( $row[ 'id' ] ); } } diff --git a/pro-features/plus/meta-fields/shortcodes.php b/pro-features/plus/meta-fields/shortcodes.php index 1d6ba92d..2b6071ea 100644 --- a/pro-features/plus/meta-fields/shortcodes.php +++ b/pro-features/plus/meta-fields/shortcodes.php @@ -95,8 +95,7 @@ function ws_ls_meta_fields_shortcode_accumulator( $user_defined_arguments ) { $increments = explode( ',', $shortcode_arguments[ 'increment-values' ] ); - if ( true == empty( $shortcode_arguments[ 'increment-values' ] ) || - true === empty( $increments ) ) { + if ( empty( $shortcode_arguments['increment-values'] ) || empty( $increments ) ) { return __( 'Please ensure you have a valid list of increment values e.g. [wt-custom-fields-accumulator increment-values="1,5,10"]', WE_LS_SLUG ); } diff --git a/pro-features/plus/shortcode.calculator.php b/pro-features/plus/shortcode.calculator.php index f74b8f04..b6200557 100644 --- a/pro-features/plus/shortcode.calculator.php +++ b/pro-features/plus/shortcode.calculator.php @@ -104,7 +104,7 @@ function ws_ls_shortcode_calculator( $user_defined_arguments ) { $html_output .= sprintf( '

%1$s %2$s.

', esc_html( $arguments[ 'text-bmi' ] ), esc_html( $bmi ) ); } - $calories = ws_ls_harris_benedict_calculate_calories_raw( $bmr, $entry[ 'ws-ls-gender' ], $entry[ 'ws-ls-activity-level' ], false ); + $calories = ws_ls_harris_benedict_calculate_calories_raw( $bmr, $entry[ 'ws-ls-gender' ], $entry[ 'ws-ls-activity-level' ] ); if ( true === ws_ls_to_bool( $arguments[ 'results-show-calories' ] ) ) { diff --git a/pro-features/shortcode-if.php b/pro-features/shortcode-if.php index b056d710..597dd020 100755 --- a/pro-features/shortcode-if.php +++ b/pro-features/shortcode-if.php @@ -38,7 +38,7 @@ function ws_ls_shortcode_if( $user_defined_arguments, $content = null, $level = } // Remove Pro Plus fields if they don't have a license - if( false === WS_LS_IS_PRO_PLUS && true === in_array( $arguments[ 'field' ], [ 'bmr' ] ) ) { + if( false === WS_LS_IS_PRO_PLUS && true === ( $arguments['field'] == 'bmr' ) ) { return sprintf( '

%s

', __( 'Unfortunately the field you specified is for Pro Plus licenses only.', WE_LS_SLUG ) ); } diff --git a/pro-features/shortcode-progress-bar.php b/pro-features/shortcode-progress-bar.php index f7d164a0..35dfd52d 100755 --- a/pro-features/shortcode-progress-bar.php +++ b/pro-features/shortcode-progress-bar.php @@ -61,7 +61,7 @@ function ws_ls_shortcode_progress_bar( $user_defined_arguments ) { $arguments['animation-duration'] = ws_ls_force_numeric_argument( $arguments[ 'animation-duration' ], 1400 ); // If no width or height specified by user, then set circle to a better default size. - if('circle' == $arguments['type'] && false == $arguments['width-height-specified']) { + if( 'circle' == $arguments['type'] && ! $arguments['width-height-specified'] ) { $arguments['width'] = '150px'; $arguments['height'] = '150px'; } diff --git a/pro-features/shortcode-stats.php b/pro-features/shortcode-stats.php index 52d492f0..dbe2c210 100755 --- a/pro-features/shortcode-stats.php +++ b/pro-features/shortcode-stats.php @@ -38,7 +38,7 @@ function ws_ls_shortcode_stats_league_total( $user_defined_arguments ) { '; - if(true == $arguments['show_percentage']) { + if( $arguments['show_percentage'] ) { $html .= ''; } @@ -62,12 +62,12 @@ function ws_ls_shortcode_stats_league_total( $user_defined_arguments ) { } // Get the display value for weight - $stats = ws_ls_shortcode_stats_display_value([ 'kg' => $row['weight_difference'], 'display-unit' => ws_ls_setting( 'weight-unit' ), 'display-value' => '' ], $arguments ); + $stats = ws_ls_shortcode_stats_display_value([ 'kg' => $row['weight_difference'], 'display-unit' => ws_ls_setting(), 'display-value' => '' ], $arguments ); $percentage = ''; // Calculate % - if( true == $arguments[ 'show_percentage' ] && 0 !== (int) $row[ 'start_weight' ] ) { + if( $arguments['show_percentage'] && 0 !== (int) $row[ 'start_weight' ] ) { $percentage = ( ( $row[ 'recent_weight' ] - $row[ 'start_weight' ]) / $row[ 'start_weight' ] ) * 100; $percentage = ( false === ws_ls_to_bool( $arguments[ 'invert' ] ) ) ? $percentage : -$percentage ; $percentage = round( $percentage ) . '%'; @@ -89,7 +89,7 @@ function ws_ls_shortcode_stats_league_total( $user_defined_arguments ) { ws_ls_blur(), $display_name, ws_ls_blur_text( $stats[ 'display-value' ] ), - ( true == $arguments[ 'show_percentage' ] ) ? '' : '', + $arguments['show_percentage'] ? '' : '', ws_ls_blur_text( $row[ 'no_entries' ] ) ); @@ -122,7 +122,7 @@ function ws_ls_shortcode_stats_total_lost( $user_defined_arguments ) { $arguments = shortcode_atts( [ 'display' => 'number/text', 'force-to-kg' => 'false', 'invert' => false ], $user_defined_arguments ); $summary_stats = ws_ls_stats_get_summary_stats(); - $stats = ws_ls_shortcode_stats_display_value( [ 'kg' => $summary_stats['difference'], 'display-unit' => ws_ls_setting('weight-unit' ), 'display-value' => '' ], $arguments ); + $stats = ws_ls_shortcode_stats_display_value( [ 'kg' => $summary_stats['difference'], 'display-unit' => ws_ls_setting(), 'display-value' => '' ], $arguments ); return $stats['display-value']; } @@ -157,7 +157,7 @@ function ws_ls_shortcode_stats_display_value( $stats, $arguments ) { } // Ignore global and user settings and force display to Kg? - if( true == ws_ls_to_bool( $arguments[ 'force-to-kg' ] ) ) { + if( ws_ls_to_bool( $arguments['force-to-kg'] ) ) { $stats[ 'display-unit' ] = 'kg'; } @@ -174,9 +174,7 @@ function ws_ls_shortcode_stats_display_value( $stats, $arguments ) { } // Allow theme developer to override stats message - $stats = apply_filters( 'wlt-filter-stats-shortcode', $stats); - - return $stats; + return apply_filters( 'wlt-filter-stats-shortcode', $stats ); } return ''; diff --git a/pro-features/user-birthdays.php b/pro-features/user-birthdays.php index 0461b481..ee7686d9 100755 --- a/pro-features/user-birthdays.php +++ b/pro-features/user-birthdays.php @@ -13,7 +13,7 @@ function ws_ls_birthdays_enabled() { return false; } - return 'yes' === get_option('ws-ls-enable-birthdays', false ) ? true : false; + return 'yes' === get_option('ws-ls-enable-birthdays', false ); } /** diff --git a/pro-features/user-groups.php b/pro-features/user-groups.php index 2733e978..42dfc5cd 100755 --- a/pro-features/user-groups.php +++ b/pro-features/user-groups.php @@ -28,7 +28,7 @@ function ws_ls_groups_can_users_edit() { return false; } - return 'yes' === get_option('ws-ls-enable-groups-user-edit', false ) ? true : false; + return 'yes' === get_option('ws-ls-enable-groups-user-edit', false ); } /** @@ -136,7 +136,7 @@ function ws_ls_groups_hooks_user_preferences_form( $html, $user_id ) { if ( true === ws_ls_groups_enabled() ) { - $groups = ws_ls_groups( true ); + $groups = ws_ls_groups(); if ( false === empty( $groups ) ) { @@ -557,8 +557,6 @@ function ws_ls_groups_export_add( $row ) { return $row; } - $row[ 'group' ] = ''; - $group = ws_ls_groups_user( $row[ 'user_id' ] ); if ( false === empty( $group[ 0 ][ 'name' ] ) ) { @@ -1030,4 +1028,4 @@ function ws_ls_groups_add_missing_group( $user_id ) { ws_ls_groups_add_to_user( 0, $user_id ); } -add_action( 'wlt-hook-data-attempting-added-edited', 'ws_ls_groups_add_missing_group', 10, 1 ); +add_action( 'wlt-hook-data-attempting-added-edited', 'ws_ls_groups_add_missing_group' ); diff --git a/pro-features/user-preferences.php b/pro-features/user-preferences.php index a07b5002..b5543f03 100755 --- a/pro-features/user-preferences.php +++ b/pro-features/user-preferences.php @@ -40,7 +40,7 @@ function ws_ls_user_preferences_form( $user_defined_arguments ) { // Have user preferences been allowed in Settings? if ( false === ws_ls_user_preferences_is_enabled() && false === is_admin() && false === $arguments[ 'kiosk-mode' ]) { - return ws_ls_display_blockquote( __( 'To use this shortcode, please ensure you have enabled the setting "Allow user settings".', WE_LS_SLUG) );; + return ws_ls_display_blockquote( __( 'To use this shortcode, please ensure you have enabled the setting "Allow user settings".', WE_LS_SLUG) ); } // Delete all the user's data if selected @@ -53,8 +53,7 @@ function ws_ls_user_preferences_form( $user_defined_arguments ) { // Decide which set of labels to render $labels = [ - 'title-about' => __( 'About You:', WE_LS_SLUG ), - 'height' => __( 'Your height:', WE_LS_SLUG ), + 'height' => __( 'Your height:', WE_LS_SLUG ), 'weight' => __( 'In which unit would you like to record your weight:', WE_LS_SLUG ), 'date' => __( 'Display dates in the following formats:', WE_LS_SLUG ), 'gender' => __( 'Your Gender:', WE_LS_SLUG ), @@ -66,9 +65,7 @@ function ws_ls_user_preferences_form( $user_defined_arguments ) { // If admin, add notice and override labels if( is_admin() ) { - $labels = [ - 'title-about' => __( 'About User:', WE_LS_SLUG ), - 'height' => __( 'Height:', WE_LS_SLUG ), + $labels = [ 'height' => __( 'Height:', WE_LS_SLUG ), 'weight' => __( 'Weight unit:', WE_LS_SLUG ), 'date' => __( 'Date format:', WE_LS_SLUG ), 'gender' => __( 'Gender:', WE_LS_SLUG ), @@ -85,8 +82,6 @@ function ws_ls_user_preferences_form( $user_defined_arguments ) { ws_ls_enqueue_files(); } - $html_output = ''; - // If enabled, show user preferences form if( false === empty( $arguments[ 'show-user-preferences' ] ) ) { @@ -98,7 +93,7 @@ function ws_ls_user_preferences_form( $user_defined_arguments ) { '; if ( false === ws_ls_to_bool( $arguments[ 'hide-aim' ] ) ) { - $html_output .= ws_ls_form_field_select( [ 'uikit' => $arguments[ 'uikit' ], 'key' => 'ws-ls-aim', 'label' => $labels['aim'], 'values' => ws_ls_aims(), 'selected' => ws_ls_user_preferences_get( 'aim', $user_id, NULL ), 'css-class' => 'ws-ls-aboutyou-field' ] ); + $html_output .= ws_ls_form_field_select( [ 'uikit' => $arguments[ 'uikit' ], 'key' => 'ws-ls-aim', 'label' => $labels['aim'], 'values' => ws_ls_aims(), 'selected' => ws_ls_user_preferences_get( 'aim', $user_id ), 'css-class' => 'ws-ls-aboutyou-field' ] ); } if ( false === ws_ls_to_bool( $arguments[ 'hide-extras' ] ) ) { diff --git a/pro-features/web-hooks.php b/pro-features/web-hooks.php index 40f1c00c..cb8ecfbb 100644 --- a/pro-features/web-hooks.php +++ b/pro-features/web-hooks.php @@ -208,7 +208,7 @@ function ws_ls_webhooks_data_prep_weight( $entry ) { $data[ 'custom-fields' ] = []; foreach ( $entry[ 'meta' ] as $id => $value ) { - $index = ws_ls_meta_fields_get_column( $id, 'field_key' ); + $index = ws_ls_meta_fields_get_column( $id ); $data[ 'custom-fields' ][ $index ] = ws_ls_fields_display_field_value( $value, $id, true ); } } diff --git a/readme.txt b/readme.txt index 769ae23a..11d16d73 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: aliakro Tags: weight,tracker,chart,bmi,bmr,macronutrient,measure,awards,custom fields,history,measurements,data Requires at least: 5.7 Tested up to: 6.3 -Stable tag: 10.6 +Stable tag: 10.7 Requires PHP: 7.2 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -152,6 +152,18 @@ Measurements are created using Custom Fields. You can therefore specify the unit == Changelog == += 10.7 = + +* Maintenance: Removed support for the shortcode [wt-beta], you must use [wt] instead. +* Maintenance: Removed support for the shortcode [wlt], you must use [wt] instead. +* Maintenance: Removed support for the shortcode [wt-legacy], you must use [wt] instead. +* Maintenance: Removed redundant setting "Hide tab descriptions" from the "User Experience" settings page. +* Maintenance: Removed redundant setting "Tab appearance" from the "User Experience" settings page. +* Maintenance: Removed redundant setting "Switching to a drop down" from the "User Experience" settings page. +* Maintenance: Removed redundant setting "Switching to a drop down" from the "User Experience" settings page. +* Maintenance: Challenges functionality is now enabled by default. +* Maintenance: Based on PHPStorm inspection made 129+ changes to code for optimisation. + = 10.6 = * New feature: Added the arguments "bmi-alert-if-below" and "bmi-alert-if-above" to [wt] to show an alert if the user's BMI is below or above the specified value. diff --git a/weight-loss-tracker.php b/weight-loss-tracker.php index d18eb0f2..4c3ebe44 100755 --- a/weight-loss-tracker.php +++ b/weight-loss-tracker.php @@ -5,7 +5,7 @@ /** * Plugin Name: Weight Tracker * Description: Allow your users to track their weight, body measurements, photos and other pieces of custom data. Display in charts, tables, shortcodes and widgets. Manage their data, issue awards, email notifications, etc! Provide advanced data on Body Mass Index (BMI), Basal Metabolic Rate (BMR), Calorie intake, Harris Benedict Formula, Macronutrients Calculator and more. - * Version: 10.6 + * Version: 10.7 * Requires at least: 5.7 * Tested up to: 6.3 * Requires PHP: 7.2 @@ -18,7 +18,7 @@ */ define( 'WS_LS_ABSPATH', plugin_dir_path( __FILE__ ) ); -define( 'WE_LS_CURRENT_VERSION', '10.6' ); +define( 'WE_LS_CURRENT_VERSION', '10.7' ); define( 'WE_LS_TITLE', 'Weight Tracker' ); define( 'WE_LS_SLUG', 'weight-loss-tracker' ); define( 'WE_LS_LICENSE_TYPES_URL', 'https://docs.yeken.uk/features.html' ); @@ -28,8 +28,8 @@ define( 'WE_LS_FREE_TRIAL_URL', 'https://shop.yeken.uk/get-a-trial-license/' ); define( 'WE_LS_CDN_CHART_JS', 'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.2.0/chart.min.js' ); define( 'WE_LS_CDN_FONT_AWESOME_CSS', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css' ); -define( 'WE_LS_PRO_PRICE', 50.00 ); -define( 'WE_LS_PRO_PLUS_PRICE', 100.00 ); +define( 'WE_LS_PRO_PRICE', 60.00 ); +define( 'WE_LS_PRO_PLUS_PRICE', 120.00 ); global $form_number; // This is used to keep track of multiple forms on a page allowing us to pass messages to each global $save_response; // This is used to keep track of form posts responses @@ -82,7 +82,6 @@ require_once( WS_LS_ABSPATH . 'includes/ajax.php' ); require_once( WS_LS_ABSPATH . 'includes/setup-wizard.php' ); require_once( WS_LS_ABSPATH . 'includes/components.php' ); -require_once( WS_LS_ABSPATH . 'includes/shortcode-wt-legacy.php' ); require_once( WS_LS_ABSPATH . 'includes/shortcode-wt.php' ); require_once( WS_LS_ABSPATH . 'includes/shortcode-various.php' ); require_once( WS_LS_ABSPATH . 'includes/form-handler.php' ); @@ -159,11 +158,7 @@ require_once( WS_LS_ABSPATH . 'pro-features/plus/awards/hooks.php' ); require_once( WS_LS_ABSPATH . 'pro-features/email-notifications.php' ); require_once( WS_LS_ABSPATH . 'pro-features/web-hooks.php' ); - -if ( true === ws_ls_settings_challenges_enabled() ) { - require_once( WS_LS_ABSPATH . 'pro-features/plus/challenge/inc.php' ); -} - +require_once( WS_LS_ABSPATH . 'pro-features/plus/challenge/inc.php' ); require_once( WS_LS_ABSPATH . 'pro-features/plus/messaging/inc.php' ); require_once( WS_LS_ABSPATH . 'pro-features/plus/bmr.php' );
' . __('Name', WE_LS_SLUG) . ' ' . __('Weight Difference', WE_LS_SLUG) . '+/-' . ws_ls_blur_text( $percentage ) . '' . ws_ls_blur_text( $percentage ) . '