Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TMZ-37] Port over Forms to the Forms Lite module #59

Merged
merged 18 commits into from
Nov 13, 2024
32 changes: 32 additions & 0 deletions includes/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
exit; // Exit if accessed directly.
}

use Elementor\Utils as ElementorUtils;

/**
* class Utils
**/
Expand Down Expand Up @@ -33,4 +35,34 @@ public static function is_elementor_installed() {

return self::$elementor_installed;
}

public static function get_current_post_id() {
if ( isset( self::elementor()->documents ) && self::elementor()->documents->get_current() ) {
return self::elementor()->documents->get_current()->get_main_id();
}

return get_the_ID();
}

public static function get_client_ip() {
$server_ip_keys = [
'HTTP_CLIENT_IP',
'HTTP_X_FORWARDED_FOR',
'HTTP_X_FORWARDED',
'HTTP_X_CLUSTER_CLIENT_IP',
'HTTP_FORWARDED_FOR',
'HTTP_FORWARDED',
'REMOTE_ADDR',
];

foreach ( $server_ip_keys as $key ) {
$value = ElementorUtils::get_super_global_value( $_SERVER, $key );
if ( $value && filter_var( $value, FILTER_VALIDATE_IP ) ) {
return $value;
}
}

// Fallback local ip.
return '127.0.0.1';
}
}
Loading
Loading