activities_helper.php
3 months ago
agent_helper.php
3 months ago
analytics_helper.php
4 months ago
auth_helper.php
3 months ago
blocks_helper.php
3 months ago
booking_helper.php
3 months ago
bricks_helper.php
3 months ago
bundles_helper.php
3 months ago
calendar_helper.php
3 months ago
carts_helper.php
3 months ago
connector_helper.php
3 months ago
csv_helper.php
3 months ago
customer_helper.php
3 months ago
customer_import_helper.php
3 months ago
database_helper.php
3 months ago
debug_helper.php
3 months ago
defaults_helper.php
3 months ago
elementor_helper.php
3 months ago
email_helper.php
3 months ago
encrypt_helper.php
3 months ago
events_helper.php
3 months ago
form_helper.php
3 months ago
icalendar_helper.php
3 months ago
image_helper.php
3 months ago
invoices_helper.php
3 months ago
license_helper.php
3 months ago
location_helper.php
3 months ago
marketing_systems_helper.php
3 months ago
meeting_systems_helper.php
3 months ago
menu_helper.php
3 months ago
meta_helper.php
3 months ago
migrations_helper.php
3 months ago
money_helper.php
3 months ago
notifications_helper.php
3 months ago
nps_survey_helper.php
3 months ago
order_intent_helper.php
3 months ago
orders_helper.php
3 months ago
otp_helper.php
3 months ago
pages_helper.php
3 months ago
params_helper.php
3 months ago
payments_helper.php
3 months ago
price_breakdown_helper.php
3 months ago
process_jobs_helper.php
3 months ago
processes_helper.php
3 months ago
replacer_helper.php
3 months ago
resource_helper.php
3 months ago
roles_helper.php
3 months ago
router_helper.php
3 months ago
service_helper.php
3 months ago
sessions_helper.php
3 months ago
settings_helper.php
3 months ago
short_links_systems_helper.php
3 months ago
shortcodes_helper.php
3 months ago
sms_helper.php
3 months ago
steps_helper.php
3 months ago
stripe_connect_helper.php
3 months ago
styles_helper.php
3 months ago
support_topics_helper.php
3 months ago
time_helper.php
3 months ago
timeline_helper.php
3 months ago
transaction_helper.php
3 months ago
transaction_intent_helper.php
3 months ago
util_helper.php
3 months ago
version_specific_updates_helper.php
3 months ago
whatsapp_helper.php
3 months ago
work_periods_helper.php
3 months ago
wp_datetime.php
3 months ago
wp_user_helper.php
3 months ago
params_helper.php
93 lines
| 1 | <?php |
| 2 | |
| 3 | class OsParamsHelper { |
| 4 | |
| 5 | private static $params = []; |
| 6 | private static $files = []; |
| 7 | |
| 8 | public static function load_params() { |
| 9 | $params = array(); |
| 10 | $post_params = array(); |
| 11 | $get_params = array(); |
| 12 | if ( ! empty( $_POST['params'] ) ) { |
| 13 | if ( is_string( $_POST['params'] ) ) { |
| 14 | parse_str( $_POST['params'], $post_params ); |
| 15 | } |
| 16 | if ( is_array( $_POST['params'] ) ) { |
| 17 | $post_params = array_merge( $_POST['params'], $post_params ); |
| 18 | } |
| 19 | } |
| 20 | $get_params = $_GET; |
| 21 | $params = array_merge( $post_params, $get_params ); |
| 22 | $params = stripslashes_deep( $params ); |
| 23 | self::$params = $params; |
| 24 | } |
| 25 | |
| 26 | public static function load_files() { |
| 27 | if ( ! empty( $_FILES ) ) { |
| 28 | self::$files = $_FILES; |
| 29 | } else { |
| 30 | self::$files = []; |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | |
| 35 | public static function get_params() { |
| 36 | self::ensure_params_loaded(); |
| 37 | OsDebugHelper::log_params( self::$params ); |
| 38 | |
| 39 | return self::$params; |
| 40 | } |
| 41 | |
| 42 | public static function get_param( $param_name ) { |
| 43 | self::ensure_params_loaded(); |
| 44 | return self::$params[ $param_name ] ?? null; |
| 45 | } |
| 46 | |
| 47 | public static function ensure_params_loaded() { |
| 48 | if ( empty( self::$params ) ) { |
| 49 | self::load_params(); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | public static function get_files() { |
| 54 | self::ensure_files_loaded(); |
| 55 | OsDebugHelper::log_files( self::$files ); |
| 56 | |
| 57 | return self::$files; |
| 58 | } |
| 59 | |
| 60 | public static function get_file( $file_name ) { |
| 61 | self::ensure_files_loaded(); |
| 62 | |
| 63 | return self::$files[ $file_name ] ?? null; |
| 64 | } |
| 65 | |
| 66 | public static function ensure_files_loaded() { |
| 67 | if ( empty( self::$files ) ) { |
| 68 | self::load_files(); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | public static function sanitize_param( $value, $rule ) { |
| 73 | switch ( $rule ) { |
| 74 | case 'money': |
| 75 | $value = OsMoneyHelper::convert_amount_from_money_input_to_db_format( $value ); |
| 76 | break; |
| 77 | case 'percent': |
| 78 | $value = OsMoneyHelper::convert_value_from_percent_input_to_db_format( $value ); |
| 79 | break; |
| 80 | case 'date': |
| 81 | break; |
| 82 | } |
| 83 | |
| 84 | return $value; |
| 85 | } |
| 86 | |
| 87 | public static function permit_params( array $params, array $allowed_keys ): array { |
| 88 | $allowed_keys_arr = array_flip( $allowed_keys ); |
| 89 | |
| 90 | return array_intersect_key( $params, $allowed_keys_arr ); |
| 91 | } |
| 92 | } |
| 93 |