| @@ -16,12 +16,12 @@ | ||
| 16 | 16 | * @return mixed |
| 17 | 17 | */ |
| 18 | 18 | function timetics_get_option( $key = '', $default = false ) { |
| 19 | 19 | $options = get_option( 'timetics_settings' ); |
| 20 | - $value = $default; | |
| 20 | + $value = $default; | |
| 21 | 21 | |
| 22 | - if ( isset( $options[ $key ] ) ) { | |
| 23 | - $value = ! empty( $options[ $key ] ) ? $options[ $key ] : $default; | |
| 22 | + if ( isset( $options[$key] ) ) { | |
| 23 | + $value = ! empty( $options[$key] ) ? $options[$key] : $default; | |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | return $value; |
| 27 | 27 | } |
| @@ -46,9 +46,9 @@ | ||
| 46 | 46 | // Get the current settings. |
| 47 | 47 | $options = get_option( 'timetics_settings', [] ); |
| 48 | 48 | |
| 49 | 49 | // Set new settings value. |
| 50 | - $options[ $key ] = $value; | |
| 50 | + $options[$key] = $value; | |
| 51 | 51 | |
| 52 | 52 | // Update the settings. |
| 53 | 53 | $did_update = update_option( 'timetics_settings', $options ); |
| 54 | 54 | |
| @@ -71,6 +71,73 @@ | ||
| 71 | 71 | // Get the option key. |
| 72 | 72 | $settings = get_option( 'timetics_settings' ); |
| 73 | 73 | |
| 74 | 74 | return apply_filters( 'timetics_get_settings', $settings ); |
| 75 | + } | |
| 76 | +} | |
| 77 | + | |
| 78 | +if ( ! function_exists( 'timetics_get_busyness' ) ) { | |
| 79 | + /** | |
| 80 | + * Get selected busynsess | |
| 81 | + * | |
| 82 | + * @param string $category | |
| 83 | + * | |
| 84 | + * @return mixed | |
| 85 | + */ | |
| 86 | + function timetics_get_busyness( $category ) { | |
| 87 | + $busyness = [ | |
| 88 | + 'doctor' => [ | |
| 89 | + 'customer' => __( 'Patients', 'timetics' ), | |
| 90 | + 'staff' => __( 'Doctors', 'timetics' ), | |
| 91 | + ], | |
| 92 | + 'education' => [ | |
| 93 | + 'customer' => __( 'Students', 'timetics' ), | |
| 94 | + 'staff' => __( 'Teachers', 'timetics' ), | |
| 95 | + ], | |
| 96 | + ]; | |
| 97 | + | |
| 98 | + $busyness = apply_filters( 'timetics_busyness', $busyness ); | |
| 99 | + | |
| 100 | + $selected = ! empty( $busyness[$category] ) ? $busyness[$category] : ''; | |
| 101 | + | |
| 102 | + return $selected; | |
| 103 | + } | |
| 104 | +} | |
| 105 | + | |
| 106 | +if ( ! function_exists( 'timetics_get_busyness_categories' ) ) { | |
| 107 | + | |
| 108 | + /** | |
| 109 | + * Get busyness categories | |
| 110 | + * | |
| 111 | + * @return array | |
| 112 | + */ | |
| 113 | + function timetics_get_busyness_categories() { | |
| 114 | + $busyness_categories = [ | |
| 115 | + [ | |
| 116 | + 'id' => 'doctor', | |
| 117 | + 'name' => __( 'Doctors/Health clinic', 'timetics' ), | |
| 118 | + ], | |
| 119 | + [ | |
| 120 | + 'id' => 'education', | |
| 121 | + 'name' => __( 'Tutor and education center', 'timetics' ), | |
| 122 | + ], | |
| 123 | + [ | |
| 124 | + 'id' => 'others', | |
| 125 | + 'name' => __( 'Others', 'timetics' ), | |
| 126 | + ], | |
| 127 | + ]; | |
| 128 | + | |
| 129 | + return apply_filters( 'timetics_busyness_categories', $busyness_categories ); | |
| 130 | + } | |
| 131 | +} | |
| 132 | + | |
| 133 | +if ( ! function_exists( 'timetics_get_busyness_category' ) ) { | |
| 134 | + | |
| 135 | + /** | |
| 136 | + * Get busyness categories | |
| 137 | + * | |
| 138 | + * @return array | |
| 139 | + */ | |
| 140 | + function timetics_get_busyness_category() { | |
| 141 | + return timetics_get_option( 'busyness_category' ); | |
| 75 | 142 | } |
| 76 | 143 | } |