activities_helper.php
1 year ago
agent_helper.php
1 year ago
auth_helper.php
1 year ago
blocks_helper.php
1 year ago
booking_helper.php
1 year ago
bricks_helper.php
1 year ago
bundles_helper.php
1 year ago
calendar_helper.php
1 year ago
carts_helper.php
1 year ago
connector_helper.php
1 year ago
csv_helper.php
1 year ago
customer_helper.php
1 year ago
database_helper.php
1 year ago
debug_helper.php
1 year ago
defaults_helper.php
1 year ago
elementor_helper.php
1 year ago
email_helper.php
1 year ago
encrypt_helper.php
1 year ago
events_helper.php
1 year ago
form_helper.php
1 year ago
icalendar_helper.php
1 year ago
image_helper.php
1 year ago
invoices_helper.php
1 year ago
license_helper.php
1 year ago
location_helper.php
1 year ago
marketing_systems_helper.php
1 year ago
meeting_systems_helper.php
1 year ago
menu_helper.php
1 year ago
meta_helper.php
1 year ago
migrations_helper.php
1 year ago
money_helper.php
1 year ago
notifications_helper.php
1 year ago
order_intent_helper.php
1 year ago
orders_helper.php
1 year ago
pages_helper.php
1 year ago
params_helper.php
1 year ago
payments_helper.php
1 year ago
price_breakdown_helper.php
1 year ago
process_jobs_helper.php
1 year ago
processes_helper.php
1 year ago
replacer_helper.php
1 year ago
resource_helper.php
1 year ago
roles_helper.php
1 year ago
router_helper.php
1 year ago
service_helper.php
1 year ago
sessions_helper.php
1 year ago
settings_helper.php
1 year ago
shortcodes_helper.php
1 year ago
sms_helper.php
1 year ago
steps_helper.php
1 year ago
stripe_connect_helper.php
1 year ago
styles_helper.php
1 year ago
support_topics_helper.php
1 year ago
time_helper.php
1 year ago
timeline_helper.php
1 year ago
transaction_intent_helper.php
1 year ago
util_helper.php
1 year ago
version_specific_updates_helper.php
1 year ago
work_periods_helper.php
1 year ago
wp_datetime.php
1 year ago
wp_user_helper.php
1 year ago
settings_helper.php
495 lines
| 1 | <?php |
| 2 | |
| 3 | class OsSettingsHelper { |
| 4 | |
| 5 | public static $loaded_values; |
| 6 | |
| 7 | |
| 8 | private static $encrypted_settings = [ |
| 9 | 'license', |
| 10 | 'google_calendar_client_secret', |
| 11 | 'facebook_app_secret', |
| 12 | 'google_client_secret', |
| 13 | 'braintree_secret_key', |
| 14 | 'braintree_merchant_id', |
| 15 | 'paypal_client_secret']; |
| 16 | |
| 17 | private static $settings_to_autoload = [ |
| 18 | 'enable_google_login', |
| 19 | 'time_system', |
| 20 | 'date_format', |
| 21 | 'currency_symbol_before', |
| 22 | 'currency_symbol_after', |
| 23 | 'phone_format', |
| 24 | 'steps_show_timezone_selector', |
| 25 | 'show_booking_end_time', |
| 26 | 'stripe_publishable_key', |
| 27 | 'enable_facebook_login', |
| 28 | 'earliest_possible_booking', |
| 29 | 'enable_payments_local', |
| 30 | 'color_scheme_for_booking_form', |
| 31 | 'latest_possible_booking', |
| 32 | 'facebook_app_id', |
| 33 | 'google_client_id', |
| 34 | 'paypal_client_id', |
| 35 | 'paypal_currency_iso_code', |
| 36 | 'paypal_use_braintree_api', |
| 37 | 'stripe_secret_key', |
| 38 | 'steps_hide_agent_info', |
| 39 | 'booking_hash', |
| 40 | 'payments_environment', |
| 41 | 'list_of_phone_countries', |
| 42 | 'included_phone_countries', |
| 43 | 'wp_users_as_customers', |
| 44 | 'thousand_separator', |
| 45 | 'decimal_separator', |
| 46 | 'number_of_decimals', |
| 47 | 'default_phone_country']; |
| 48 | |
| 49 | private static $defaults = [ |
| 50 | 'date_format' => LATEPOINT_DEFAULT_DATE_FORMAT, |
| 51 | 'time_system' => LATEPOINT_DEFAULT_TIME_SYSTEM, |
| 52 | 'currency_symbol_before' => '$' |
| 53 | ]; |
| 54 | |
| 55 | public static function get_remote_url($extra = '') { |
| 56 | return base64_decode(LATEPOINT_REMOTE_HASH) . $extra; |
| 57 | } |
| 58 | |
| 59 | public static function get_business_logo_url() { |
| 60 | $default_logo_url = LATEPOINT_IMAGES_URL . 'logo.png'; |
| 61 | return OsImageHelper::get_image_url_by_id(OsSettingsHelper::get_settings_value('business_logo'), 'thumbnail', $default_logo_url); |
| 62 | } |
| 63 | |
| 64 | public static function get_business_logo_image($height = '50px') { |
| 65 | $url = self::get_business_logo_url(); |
| 66 | return '<img src="' . $url . '" style="height: ' . $height . '; width: auto"/>'; |
| 67 | } |
| 68 | |
| 69 | public static function get_encrypted_settings() { |
| 70 | $encrypted_settings = apply_filters('latepoint_encrypted_settings', self::$encrypted_settings); |
| 71 | return $encrypted_settings; |
| 72 | } |
| 73 | |
| 74 | public static function run_autoload() { |
| 75 | /** |
| 76 | * Default settings to be used in SettingsHelper when no value exists in DB |
| 77 | * |
| 78 | * @since 4.7.2 |
| 79 | * @hook latepoint_settings_defaults |
| 80 | * |
| 81 | * @param {array} $default_settings Array of key => value pairs of setting names and their default values |
| 82 | * @returns {array} The filtered array of default settings |
| 83 | */ |
| 84 | self::$defaults = apply_filters('latepoint_settings_defaults', self::$defaults); |
| 85 | foreach (self::$defaults as $name => $default) { |
| 86 | self::$loaded_values[$name] = $default; |
| 87 | } |
| 88 | |
| 89 | $settings_model = new OsSettingsModel(); |
| 90 | |
| 91 | /** |
| 92 | * Settings to autoload in SettingsHelper on every page load, this is done to reduce the number of queries to DB |
| 93 | * |
| 94 | * @since 4.7.2 |
| 95 | * @hook latepoint_settings_to_autoload |
| 96 | * |
| 97 | * @param {array} $settings Array of setting names to autoload |
| 98 | * @returns {array} The filtered array of setting names |
| 99 | */ |
| 100 | self::$settings_to_autoload = apply_filters('latepoint_settings_to_autoload', self::$settings_to_autoload); |
| 101 | $settings_arr = $settings_model->select('name, value')->where(array('name' => self::$settings_to_autoload))->get_results(); |
| 102 | |
| 103 | |
| 104 | if ($settings_arr && is_array($settings_arr)) { |
| 105 | foreach ($settings_arr as $setting) { |
| 106 | if (in_array($setting->name, self::get_encrypted_settings())) { |
| 107 | self::$loaded_values[$setting->name] = OsEncryptHelper::decrypt_value($setting->value); |
| 108 | } else { |
| 109 | self::$loaded_values[$setting->name] = $setting->value; |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | |
| 116 | // ENVIRONMENT SETTINGS |
| 117 | |
| 118 | // BASE ENVIRONMENT |
| 119 | public static function is_env_live() { |
| 120 | return (LATEPOINT_ENV == LATEPOINT_ENV_LIVE); |
| 121 | } |
| 122 | |
| 123 | public static function is_env_dev() { |
| 124 | return (LATEPOINT_ENV == LATEPOINT_ENV_DEV); |
| 125 | } |
| 126 | |
| 127 | public static function is_env_demo() { |
| 128 | return (LATEPOINT_ENV == LATEPOINT_ENV_DEMO); |
| 129 | } |
| 130 | |
| 131 | // SMS, EMAILS |
| 132 | |
| 133 | public static function is_sms_allowed() { |
| 134 | return LATEPOINT_ALLOW_SMS; |
| 135 | } |
| 136 | |
| 137 | public static function is_email_allowed() { |
| 138 | return LATEPOINT_ALLOW_EMAILS; |
| 139 | } |
| 140 | |
| 141 | // PAYMENTS ENVIRONMENT |
| 142 | public static function is_env_payments_live() { |
| 143 | return (self::get_payments_environment() == LATEPOINT_PAYMENTS_ENV_LIVE); |
| 144 | } |
| 145 | |
| 146 | public static function is_env_payments_dev() { |
| 147 | return (self::get_payments_environment() == LATEPOINT_PAYMENTS_ENV_DEV); |
| 148 | } |
| 149 | |
| 150 | public static function is_env_payments_demo() { |
| 151 | return (self::get_payments_environment() == LATEPOINT_PAYMENTS_ENV_DEMO); |
| 152 | } |
| 153 | |
| 154 | public static function get_payments_environment() { |
| 155 | return self::get_settings_value('payments_environment', LATEPOINT_PAYMENTS_ENV_LIVE); |
| 156 | } |
| 157 | |
| 158 | |
| 159 | public static function append_payment_env_key(string $string, string $force_env = ''): string{ |
| 160 | if($force_env){ |
| 161 | if($force_env == LATEPOINT_PAYMENTS_ENV_DEV) $string.=LATEPOINT_PAYMENTS_DEV_SUFFIX; |
| 162 | }else{ |
| 163 | if(self::is_env_payments_dev()) $string.=LATEPOINT_PAYMENTS_DEV_SUFFIX; |
| 164 | } |
| 165 | return $string; |
| 166 | } |
| 167 | |
| 168 | public static function set_menu_layout_style($layout) { |
| 169 | OsSessionsHelper::setcookie(LATEPOINT_ADMIN_MENU_LAYOUT_STYLE_COOKIE, $layout); |
| 170 | } |
| 171 | |
| 172 | public static function get_menu_layout_style() { |
| 173 | if (!isset($_COOKIE[LATEPOINT_ADMIN_MENU_LAYOUT_STYLE_COOKIE])) { |
| 174 | self::set_menu_layout_style('full'); |
| 175 | } |
| 176 | return isset($_COOKIE[LATEPOINT_ADMIN_MENU_LAYOUT_STYLE_COOKIE]) ? sanitize_text_field( wp_unslash($_COOKIE[LATEPOINT_ADMIN_MENU_LAYOUT_STYLE_COOKIE])) : 'full'; |
| 177 | } |
| 178 | |
| 179 | public static function get_time_system() { |
| 180 | return self::get_settings_value('time_system', LATEPOINT_DEFAULT_TIME_SYSTEM); |
| 181 | } |
| 182 | |
| 183 | public static function get_date_format() { |
| 184 | return self::get_settings_value('date_format', LATEPOINT_DEFAULT_DATE_FORMAT); |
| 185 | } |
| 186 | |
| 187 | public static function get_date_format_for_js() { |
| 188 | $format = strtolower(self::get_date_format()); |
| 189 | return str_replace(['d', 'm', 'y'], ['dd', 'mm', 'yyyy'], $format); |
| 190 | } |
| 191 | |
| 192 | public static function get_readable_datetime_format($no_year = false, $no_seconds = true) { |
| 193 | return self::get_readable_date_format($no_year) . ', ' . self::get_readable_time_format($no_seconds); |
| 194 | } |
| 195 | |
| 196 | public static function get_order_types_list_for_any_agent_logic(): array{ |
| 197 | $order_types = [ |
| 198 | LATEPOINT_ANY_AGENT_ORDER_RANDOM => __('Randomly picked agent', 'latepoint'), |
| 199 | LATEPOINT_ANY_AGENT_ORDER_PRICE_HIGH => __('Most expensive agent', 'latepoint'), |
| 200 | LATEPOINT_ANY_AGENT_ORDER_PRICE_LOW => __('Least expensive agent', 'latepoint'), |
| 201 | LATEPOINT_ANY_AGENT_ORDER_BUSY_HIGH => __('Agent with the most bookings on that day', 'latepoint'), |
| 202 | LATEPOINT_ANY_AGENT_ORDER_BUSY_LOW => __('Agent with the least bookings on that day', 'latepoint') ]; |
| 203 | /** |
| 204 | * Get the list of order types for agent selection logic when "ANY" agent is pre-selected in the booking form |
| 205 | * |
| 206 | * @since 4.7.6 |
| 207 | * @hook latepoint_get_order_types_list_for_any_agent_logic |
| 208 | * |
| 209 | * @param {array} $order_types Array of order types |
| 210 | * |
| 211 | * @returns {array} Filtered array of order types |
| 212 | */ |
| 213 | return apply_filters('latepoint_get_order_types_list_for_any_agent_logic', $order_types); |
| 214 | } |
| 215 | |
| 216 | public static function get_readable_time_format($no_seconds = true) { |
| 217 | $seconds = $no_seconds ? '' : ':s'; |
| 218 | $format = (self::get_time_system() == '12') ? "g:i$seconds a" : "G:i$seconds"; |
| 219 | return $format; |
| 220 | } |
| 221 | |
| 222 | public static function get_readable_date_format($no_year = false) { |
| 223 | if (OsSettingsHelper::is_on('disable_verbose_date_output')) return self::get_date_format(); |
| 224 | $format = ($no_year) ? 'F j' : 'M j, Y'; |
| 225 | switch (self::get_date_format()) { |
| 226 | case 'm/d/Y': |
| 227 | case 'm.d.Y': |
| 228 | $format = ($no_year) ? 'F j' : 'M j, Y'; |
| 229 | break; |
| 230 | case 'd.m.Y': |
| 231 | case 'd/m/Y': |
| 232 | $format = ($no_year) ? 'j F' : 'j M, Y'; |
| 233 | break; |
| 234 | case 'Y-m-d': |
| 235 | $format = ($no_year) ? 'F j' : 'Y, M j'; |
| 236 | break; |
| 237 | } |
| 238 | return $format; |
| 239 | } |
| 240 | |
| 241 | |
| 242 | public static function get_booking_template_for_calendar() { |
| 243 | return OsSettingsHelper::get_settings_value('booking_template_for_calendar', '{{service_name}}'); |
| 244 | } |
| 245 | |
| 246 | |
| 247 | public static function get_selected_columns_for_bookings_table() { |
| 248 | return OsSettingsHelper::get_settings_value('bookings_table_columns', []); |
| 249 | } |
| 250 | |
| 251 | public static function get_available_columns_for_bookings_table() { |
| 252 | $available_columns = []; |
| 253 | |
| 254 | $available_columns['customer'] = ['email' => __('Email', 'latepoint'), |
| 255 | 'phone' => __('Phone', 'latepoint')]; |
| 256 | |
| 257 | $available_columns['booking'] = ['booking_code' => __('Code', 'latepoint'), |
| 258 | 'duration' => __('Duration', 'latepoint'), |
| 259 | 'source_id' => __('Source ID', 'latepoint'), |
| 260 | 'payment_method' => __('Payment Method', 'latepoint'), |
| 261 | 'payment_portion' => __('Payment Portion', 'latepoint'), |
| 262 | 'formatted_price' => __('Price', 'latepoint')]; |
| 263 | |
| 264 | $available_columns = apply_filters('latepoint_bookings_table_columns', $available_columns); |
| 265 | return $available_columns; |
| 266 | } |
| 267 | |
| 268 | public static function force_bite($request) { |
| 269 | } |
| 270 | |
| 271 | public static function read_encoded($str) { |
| 272 | return base64_decode($str); |
| 273 | } |
| 274 | |
| 275 | public static function get_db_version() { |
| 276 | return get_option('latepoint_db_version'); |
| 277 | } |
| 278 | |
| 279 | public static function force_release($request) { |
| 280 | } |
| 281 | |
| 282 | public static function is_enabled_show_dial_code_with_flag(){ |
| 283 | return (self::get_settings_value('show_dial_code_with_flag', LATEPOINT_VALUE_ON) == LATEPOINT_VALUE_ON); |
| 284 | } |
| 285 | |
| 286 | public static function is_using_google_login() { |
| 287 | return self::is_on('enable_google_login'); |
| 288 | } |
| 289 | |
| 290 | public static function is_using_facebook_login() { |
| 291 | return self::is_on('enable_facebook_login'); |
| 292 | } |
| 293 | |
| 294 | public static function is_using_social_login() { |
| 295 | return (self::is_using_google_login() || self::is_using_facebook_login()); |
| 296 | } |
| 297 | |
| 298 | public static function get_steps_support_text() { |
| 299 | $default = '<h5>Questions?</h5><p>Call (858) 939-3746 for help</p>'; |
| 300 | return self::get_settings_value('steps_support_text', $default); |
| 301 | } |
| 302 | |
| 303 | public static function get_default_fields_for_customer() { |
| 304 | $default_fields = ['first_name' => ['locked' => false, 'label' => __('First Name', 'latepoint'), 'required' => true, 'width' => 'os-col-6', 'active' => true], |
| 305 | 'last_name' => ['locked' => false, 'label' => __('Last Name', 'latepoint'), 'required' => true, 'width' => 'os-col-6', 'active' => true], |
| 306 | 'email' => ['locked' => true, 'label' => __('Email Address', 'latepoint'), 'required' => true, 'width' => 'os-col-6', 'active' => true], |
| 307 | 'phone' => ['locked' => false, 'label' => __('Phone Number', 'latepoint'), 'required' => false, 'width' => 'os-col-6', 'active' => true], |
| 308 | 'notes' => ['locked' => false, 'label' => __('Comments', 'latepoint'), 'required' => false, 'width' => 'os-col-12', 'active' => true]]; |
| 309 | |
| 310 | $fields_from_db = OsSettingsHelper::get_settings_value('default_fields_for_customer', ''); |
| 311 | $fields_from_db_arr = json_decode($fields_from_db, true); |
| 312 | if ($fields_from_db_arr) { |
| 313 | foreach ($fields_from_db_arr as $name => $field_from_db) { |
| 314 | if (isset($default_fields[$name])) $default_fields[$name] = $field_from_db; |
| 315 | } |
| 316 | } |
| 317 | $default_fields = apply_filters('latepoint_default_fields_for_customer', $default_fields); |
| 318 | return $default_fields; |
| 319 | } |
| 320 | |
| 321 | public static function remove_setting_by_name($name) { |
| 322 | $settings_model = new OsSettingsModel(); |
| 323 | $settings_model = $settings_model->delete_where(array('name' => $name)); |
| 324 | self::reset_loaded_value($name); |
| 325 | } |
| 326 | |
| 327 | public static function save_setting_by_name($name, $value) { |
| 328 | $settings_model = new OsSettingsModel(); |
| 329 | $settings_model = $settings_model->where(array('name' => $name))->set_limit(1)->get_results_as_models(); |
| 330 | if ($settings_model) { |
| 331 | $settings_model->value = self::prepare_value($name, $value); |
| 332 | } else { |
| 333 | $settings_model = new OsSettingsModel(); |
| 334 | $settings_model->name = $name; |
| 335 | $settings_model->value = self::prepare_value($name, $value); |
| 336 | } |
| 337 | self::reset_loaded_value($name); |
| 338 | return $settings_model->save(); |
| 339 | } |
| 340 | |
| 341 | public static function reset_loaded_value($name){ |
| 342 | unset(self::$loaded_values[$name]); |
| 343 | } |
| 344 | |
| 345 | public static function prepare_value($name, $value) { |
| 346 | if (in_array($name, self::get_encrypted_settings())) { |
| 347 | $value = OsEncryptHelper::encrypt_value($value); |
| 348 | } |
| 349 | if (is_array($value)) { |
| 350 | $value = maybe_serialize($value); |
| 351 | } |
| 352 | return $value; |
| 353 | } |
| 354 | |
| 355 | public static function get_settings_value($name, $default = false) { |
| 356 | if (isset(self::$loaded_values[$name])) return self::$loaded_values[$name]; |
| 357 | $settings_model = new OsSettingsModel(); |
| 358 | $settings_model = $settings_model->where(array('name' => $name))->set_limit(1)->get_results_as_models(); |
| 359 | if ($settings_model) { |
| 360 | if (in_array($name, self::get_encrypted_settings())) { |
| 361 | $value = OsEncryptHelper::decrypt_value($settings_model->value); |
| 362 | } else { |
| 363 | $value = maybe_unserialize($settings_model->value); |
| 364 | } |
| 365 | } else { |
| 366 | $value = $default; |
| 367 | } |
| 368 | self::$loaded_values[$name] = $value; |
| 369 | return self::$loaded_values[$name]; |
| 370 | } |
| 371 | |
| 372 | |
| 373 | public static function get_any_agent_order() { |
| 374 | return self::get_settings_value('any_agent_order', LATEPOINT_ANY_AGENT_ORDER_RANDOM); |
| 375 | } |
| 376 | |
| 377 | public static function get_day_calendar_min_height() { |
| 378 | $height = preg_replace('/\D/', '', self::get_settings_value('day_calendar_min_height', 700)); |
| 379 | if (!$height) $height = 700; |
| 380 | return $height; |
| 381 | } |
| 382 | |
| 383 | public static function get_default_timeblock_interval() { |
| 384 | $timeblock_interval = self::get_settings_value('timeblock_interval', LATEPOINT_DEFAULT_TIMEBLOCK_INTERVAL); |
| 385 | if (empty($timeblock_interval)) $timeblock_interval = LATEPOINT_DEFAULT_TIMEBLOCK_INTERVAL; |
| 386 | return intval($timeblock_interval); |
| 387 | } |
| 388 | |
| 389 | public static function get_customer_dashboard_url($include_site_url = true) { |
| 390 | $path = self::get_settings_value('page_url_customer_dashboard', '/customer-dashboard'); |
| 391 | return ($include_site_url) ? site_url($path) : $path; |
| 392 | } |
| 393 | |
| 394 | public static function get_customer_login_url($include_site_url = true) { |
| 395 | $path = self::get_settings_value('page_url_customer_login', '/customer-login'); |
| 396 | return ($include_site_url) ? site_url($path) : $path; |
| 397 | } |
| 398 | |
| 399 | |
| 400 | // BOOKING STEPS |
| 401 | |
| 402 | public static function steps_show_service_categories() { |
| 403 | return (self::get_settings_value('steps_show_service_categories', 'on') == 'on'); |
| 404 | } |
| 405 | |
| 406 | public static function steps_show_location_categories() { |
| 407 | return (self::get_settings_value('steps_show_location_categories', 'on') == 'on'); |
| 408 | } |
| 409 | |
| 410 | public static function steps_show_agent_bio() { |
| 411 | return (self::get_settings_value('steps_show_agent_bio') == 'on'); |
| 412 | } |
| 413 | |
| 414 | public static function get_booking_form_color_scheme() { |
| 415 | return self::get_settings_value('color_scheme_for_booking_form', 'blue'); |
| 416 | } |
| 417 | |
| 418 | public static function get_booking_form_border_radius() { |
| 419 | return self::get_settings_value('border_radius', 'flat'); |
| 420 | } |
| 421 | |
| 422 | public static function get_default_phone_country() { |
| 423 | return OsSettingsHelper::get_settings_value('default_phone_country', 'us'); |
| 424 | } |
| 425 | |
| 426 | public static function get_included_phone_countries(): array { |
| 427 | if (OsSettingsHelper::get_settings_value('list_of_phone_countries', LATEPOINT_ALL) == LATEPOINT_ALL) { |
| 428 | return []; |
| 429 | } else { |
| 430 | return array_map('trim', explode(',', OsSettingsHelper::get_settings_value('included_phone_countries', ''))); |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | |
| 435 | public static function is_on(string $setting, $default = false): bool { |
| 436 | return (self::get_settings_value($setting, $default) == LATEPOINT_VALUE_ON); |
| 437 | } |
| 438 | |
| 439 | public static function is_off(string $setting, $default = false): bool { |
| 440 | return (self::get_settings_value($setting, $default) != LATEPOINT_VALUE_ON); |
| 441 | } |
| 442 | |
| 443 | public static function generate_default_form_fields(array $default_fields) { |
| 444 | ?> |
| 445 | <div class="os-default-fields" data-route="<?php echo esc_attr(OsRouterHelper::build_route_name('form_fields', 'update_default_fields')); ?>"> |
| 446 | <form> |
| 447 | <?php foreach ($default_fields as $name => $default_field) { |
| 448 | $atts = []; |
| 449 | if ($default_field['locked']) $atts['disabled'] = 'disabled'; |
| 450 | ?> |
| 451 | <div class="os-default-field <?php echo $default_field['active'] ? '' : 'is-disabled'; ?>"> |
| 452 | <?php |
| 453 | if ($default_field['locked']) { |
| 454 | echo '<div class="locked-field"><i class="latepoint-icon latepoint-icon-lock"></i><span>' . esc_html__('Email Address field can not be disabled.', 'latepoint') . '</span></div>'; |
| 455 | } else { |
| 456 | $active = $default_field['active'] ? 'on' : 'off'; |
| 457 | $field_name = 'default_fields[' . $name . '][active]'; |
| 458 | echo '<div class="os-toggler ' . esc_attr($active) . '" data-for="' . esc_attr(OsFormHelper::name_to_id($field_name)) . '"><div class="toggler-rail"><div class="toggler-pill"></div></div></div>'; |
| 459 | echo OsFormHelper::hidden_field($field_name, $default_field['active']); |
| 460 | } ?> |
| 461 | <div class="os-field-name"><?php echo esc_html($default_field['label']); ?></div> |
| 462 | <div class="os-field-setting"> |
| 463 | <?php echo OsFormHelper::checkbox_field('default_fields[' . $name . '][required]', __('Required?', 'latepoint'), 'on', $default_field['required'], $atts); ?> |
| 464 | </div> |
| 465 | <div class="os-field-setting"> |
| 466 | <?php echo OsFormHelper::select_field('default_fields[' . $name . '][width]', false, array('os-col-12' => __('Full Width', 'latepoint'), 'os-col-6' => __('Half Width', 'latepoint')), $default_field['width']); ?> |
| 467 | </div> |
| 468 | </div> |
| 469 | <?php } ?> |
| 470 | </form> |
| 471 | </div> |
| 472 | <?php |
| 473 | } |
| 474 | |
| 475 | |
| 476 | /** |
| 477 | * Get value set for start of week in WordPress, can be from 1-7 (representing Monday-Sunday) |
| 478 | * @return mixed |
| 479 | */ |
| 480 | public static function get_start_of_week() :int { |
| 481 | $wp_value = intval(get_option('start_of_week', 0)); |
| 482 | return $wp_value ? $wp_value : 7; // in WordPress they start count on sunday and it's 0, we are using PHP Date library that starts week on Monday and it's 1-7 |
| 483 | } |
| 484 | |
| 485 | public static function get_number_of_records_per_page(): int { |
| 486 | return intval(OsSettingsHelper::get_settings_value('number_of_records_per_page', 20)); |
| 487 | } |
| 488 | |
| 489 | public static function can_download_records_as_csv(): bool { |
| 490 | return OsAuthHelper::is_admin_logged_in() || self::is_on('allow_non_admins_download_csv'); |
| 491 | } |
| 492 | |
| 493 | } |
| 494 | |
| 495 | ?> |