GRAYBYTE WORDPRESS FILE MANAGER3436

Server IP : 68.65.123.43 / Your IP : 216.73.216.162
System : Linux server266.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
PHP Version : 8.0.30
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /home/inteuuod/public_html/wp-content/plugins/userswp/includes/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/inteuuod/public_html/wp-content/plugins/userswp/includes//class-meta.php
<?php
/**
 * UsersWP Meta functions
 *
 * All UsersWP related User Settings and Site settings can be created, updated and accessed via this class.
 *
 * @since      1.0.0
 * @author     GeoDirectory Team <info@wpgeodirectory.com>
 */
class UsersWP_Meta {

    /**
     * Gets UsersWP user meta value using key.
     *
     * @since       1.0.0
     * @package     userswp
     * 
     * @param       int|bool        $user_id        User ID.
     * @param       string          $key            User meta Key.
     * @param       bool|string     $default        Default value.
     * 
     * @return      string                          User meta Value.
     */
    public function get_usermeta( $user_id = false, $key = '', $default = false ) {
        if (!$user_id) {
            return $default;
        }

        if(!$key){
        	return $default;
        }

        global $wpdb;
        $meta_table = get_usermeta_table_prefix() . 'uwp_usermeta';

        if (uwp_str_ends_with($key, '_privacy')) {
	        if (uwp_str_ends_with($key, '_tab_privacy')) {
		        $obj_key = $user_id.'_tabs_privacy';
		        $row = wp_cache_get( $obj_key, 'uwp_usermeta_tabs_privacy' );
		        if ( ! $row ) {
			        $row = $wpdb->get_row($wpdb->prepare("SELECT tabs_privacy FROM {$meta_table} WHERE user_id = %d", $user_id), ARRAY_A);
			        wp_cache_set( $obj_key, $row, 'uwp_usermeta_tabs_privacy' );
		        }

		        $value = false;
		        if (!empty($row)) {
			        $public_fields = isset($row['tabs_privacy']) ? maybe_unserialize($row['tabs_privacy']) : $default;
			        $public_fields_keys = is_array($public_fields) ? array_keys($public_fields) : $public_fields;
			        if (is_array($public_fields) && in_array($key, $public_fields_keys)) {
				        $value = $public_fields[$key];
			        }
		        }
	        } else {
		        $obj_key = $user_id.'_user_privacy';
		        $row = wp_cache_get( $obj_key, 'uwp_usermeta_user_privacy' );
		        if ( ! $row ) {
			        $row = $wpdb->get_row($wpdb->prepare("SELECT user_privacy FROM {$meta_table} WHERE user_id = %d", $user_id), ARRAY_A);
			        wp_cache_set( $obj_key, $row, 'uwp_usermeta_user_privacy' );
		        }

		        $value = 'yes';
		        if (!empty($row)) {
			        $output = isset($row['user_privacy']) ? $row['user_privacy'] : $default;
			        $public_fields = explode(',', $output);
			        if (in_array($key, $public_fields)) {
				        $value = 'no';
			        }
		        }
	        }
        } else {
            $value = null;
            $user_data = get_userdata($user_id);

	        if (!$user_data) {
		        return $value;
	        }

            switch ($key){
                case 'email': $value = $user_data->user_email; break;
                case 'username': $value = $user_data->user_login; break;
                case 'user_nicename': $value = $user_data->user_nicename; break;
                case 'bio': $value = $user_data->description; break;
                case 'uwp_language': $value = $user_data->locale; break;
                default :
					$obj_key = $user_id.'_'.$key;
	                $row = wp_cache_get( $obj_key, 'uwp_usermeta' );
	                if ( ! $row ) {
	                	if(uwp_column_exist($meta_table, $key)){
			                $row = $wpdb->get_row($wpdb->prepare("SELECT {$key} FROM {$meta_table} WHERE user_id = %d", $user_id), ARRAY_A);
			                wp_cache_set( $obj_key, $row, 'uwp_usermeta' );
		                }
	                }

                    if (!empty($row)) {
                        $value = isset($row[$key]) ? $row[$key] : $default;
                    } else {
                        $value = $default;
                    }
                    break;
            }
        }

        $value = uwp_maybe_unserialize($key, $value);
        $value = wp_unslash($value);
        $value = apply_filters( 'uwp_get_usermeta', $value, $user_id, $key, $default );
        return apply_filters( 'uwp_get_usermeta_' . $key, $value, $user_id, $key, $default );
    }

    /**
     * Updates UsersWP user meta value using key.
     *
     * @since       1.0.0
     * @package     userswp
     * 
     * @param       int|bool        $user_id        User ID.
     * @param       string|bool     $key            User meta Key.
     * @param       string          $value          User meta Value.
     * 
     * @return      bool                            Update success or not?.
     */
    public function update_usermeta( $user_id, $key, $value ) {

        if (!$user_id || !$key ) {
            return false;
        }

        global $wpdb;
        $meta_table = get_usermeta_table_prefix() . 'uwp_usermeta';
	    $cache_group = 'uwp_usermeta';
	    $obj_key = $user_id . '_' . $key;

	    if (uwp_str_ends_with($key, '_privacy')) {
		    if ( 'tabs_privacy' == $key ) {
			    $obj_key = $user_id . '_tabs_privacy';
				$cache_group = 'uwp_usermeta_tab_privacy';
		    } elseif('user_privacy' == $key) {
			    $obj_key = $user_id . '_user_privacy';
			    $cache_group = 'uwp_usermeta_user_privacy';
		    }
	    }

        $user_meta_info = $wpdb->get_col( $wpdb->prepare( "SELECT $key FROM $meta_table WHERE user_id = %d", $user_id ) );

        $value = apply_filters( 'uwp_update_usermeta', $value, $user_id, $key, $user_meta_info );
        $value =  apply_filters( 'uwp_update_usermeta_' . $key, $value, $user_id, $key, $user_meta_info );

        do_action( 'uwp_before_update_usermeta', $user_id, $key, $value, $user_meta_info );

        $value = uwp_maybe_serialize($key, $value);

        if (!empty($user_meta_info)) {
	        $result = $wpdb->update(
                $meta_table,
                array($key => $value),
                array('user_id' => $user_id),
                array('%s'),
                array('%d')
            );

	        if ( ! $result ) {
		        return false;
	        }

        } else {
	        $result = $wpdb->insert(
                $meta_table,
                array('user_id' => $user_id, $key => $value)
            );

	        if ( ! $result ) {
		        return false;
	        }
        }

	    wp_cache_delete( $obj_key, $cache_group );

        return true;
    }

    /**
     * Gets UsersWP user meta row using user ID.
     *
     * @since       1.0.0
     * @package     userswp
     * 
     * @param       int|bool            $user_id    User ID.
     * 
     * @return      object|bool                     User meta row object.
     */
    public function get_usermeta_row($user_id = false) {
        if (!$user_id) {
            return false;
        }

        global $wpdb;
        $meta_table = get_usermeta_table_prefix() . 'uwp_usermeta';

	    $row = wp_cache_get( $user_id, 'uwp_usermeta_row' );
	    if ( ! $row ) {
		    $row = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$meta_table} WHERE user_id = %d", $user_id));
		    wp_cache_set( $user_id, $row, 'uwp_usermeta_row' );
	    }

        return $row;
    }

    /**
     * Deletes a UsersWP meta row using the user ID.
     *
     * @since       1.0.5
     * @package     UsersWP
     * 
     * @param       int|bool            $user_id        User ID.
     * 
     * @return      void
     */
    public function delete_usermeta_row($user_id = false) {
        if (!$user_id) {
            return;
        }

        global $wpdb;
        $meta_table = get_usermeta_table_prefix() . 'uwp_usermeta';

        $count = $wpdb->query($wpdb->prepare("DELETE FROM {$meta_table} WHERE user_id = %d", $user_id));

	    if ( ! $count ) {
		    return false;
	    }

	    wp_cache_delete( $user_id, 'uwp_usermeta_row' );

    }

    /**
     * Syncs WP usermeta with UsersWP usermeta.
     *
     * @since       1.0.0
     * @package     userswp
     * 
     * @param       int            $user_id        User ID.
     * 
     * @return      void
     */
    public function sync_usermeta($user_id) {

        global $wpdb;
        $user_data = get_userdata($user_id);
        $meta_table = get_usermeta_table_prefix() . 'uwp_usermeta';

        $user_meta = array(
            'username' => $user_data->user_login,
            'email' => $user_data->user_email,
            'display_name' => $user_data->display_name,
            'first_name' => $user_data->first_name,
            'last_name' => $user_data->last_name,
            'user_url' => $user_data->user_url,
            'bio' => $user_data->description,
        );

        foreach ($user_meta as $key => $meta){
            do_action('sync_usermeta_on_register', $user_id, $key, $meta); // for adding points via mycred add on.
        }

        $users = $wpdb->get_var($wpdb->prepare("SELECT COUNT(user_id) FROM {$meta_table} WHERE user_id = %d", $user_id));

        if($users){
            $wpdb->update(
                $meta_table,
                $user_meta,
                array('user_id' => $user_id)
            );
        } else {
            $user_meta['user_id'] = $user_id;
            $wpdb->insert(
                $meta_table,
                $user_meta
            );
        }

    }

    /**
     * Delete UsersWP meta when user get deleted.
     *
     * @since       1.0.5
     * @package     UsersWP
     * 
     * @param       int            $user_id        User ID.
     * 
     * @return      void
     */
    public function delete_usermeta_for_user($user_id) {
        $this->delete_usermeta_row($user_id);
    }

    /**
     * Delete UsersWP meta when user get deleted from subsite of multisite network.
     *
     * @package     UsersWP
     *
     * @param       int            $user_id        User ID.
     *
     * @return      void
     */
    public function remove_user_from_blog($user_id, $blog_id) {
        switch_to_blog( $blog_id );
        $this->delete_usermeta_row($user_id);
        restore_current_blog();
    }

    /**
     * Saves User IP during registration. 
     *
     * @since       1.0.5
     * @package     userswp
     * 
     * @param       array       $result         Validated form result.
     * @param       string      $type           Form Type. 
     * @param       int         $user_id        User ID.
     * 
     * @return      array                       Validated form result.
     */
    public function save_user_ip_on_register($result, $type, $user_id) {
        if ($type == 'register') {
            $ip = uwp_get_ip();
            uwp_update_usermeta($user_id, 'user_ip', $ip);
        }
        return $result;
    }

    /**
     * Saves the users IP on login.
     *
     * @since       1.0.0
     * @package     userswp
     * 
     * @param       string      $user_login     The users username.
     * @param       object      $user           The user object WP_User.
     * 
     * @return      void
     */
    public function save_user_ip_on_login( $user_login, $user ) {
        if (isset($user->ID)) {
	        $ip = uwp_get_ip();
            uwp_update_usermeta($user->ID, 'user_ip', $ip);    
        }
    }

    /**
     * Modifies date value from unix timestamp to string while updating into the db.
     *
     * @since       1.0.0
     * @package     userswp
     * 
     * @param       int         $value          Unix Timestamp.
     * @param       int         $user_id        The User ID.
     * @param       string      $key            Custom field key.
     * 
     * @return      string                      Date string.
     */
    public function modify_datepicker_value_on_update($value, $user_id, $key) {
        // modify timestamp to date
        if (is_int($value)) {
            $field_info = uwp_get_custom_field_info($key);
            if ($field_info->field_type == 'datepicker') {
                $value = date('Y-m-d', $value);
            }
        }
        return $value;
    }

    /**
     * Modifies date value from string to unix timestamp while fetching from the db.
     *
     * @since       1.0.0
     * @package     userswp
     * 
     * @param       string      $value          Date string.
     * @param       int         $user_id        The User ID.
     * @param       string      $key            Custom field key.
     * 
     * @return      int                         Unix Timestamp.
     */
    public function modify_datepicker_value_on_get($value, $user_id, $key, $default) {
        // modify date to timestamp
	    $field_info = uwp_get_custom_field_info($key);
	    if (isset($field_info->field_type) && $field_info->field_type == 'datepicker') {
		    if (is_string($value) && (strpos($value, '-') !== false) && $value != '0000-00-00') {
			    $value = strtotime( $value );
		    } elseif($value === '0000-00-00'){$value = '';}
	    }

        return $value;
    }

	/**
	 * Make UWP user meta available through the standard get_user_meta() function if prefixed with `user_`
	 *
	 * @param $metadata
	 * @param $object_id
	 * @param $meta_key
	 * @param $single
	 *
	 * @return bool|mixed|null|string
	 */
	public static function dynamically_add_user_meta( $metadata, $object_id, $meta_key, $single ) {

		if ( strpos( $meta_key, 'uwp_meta_' ) === 0 ) {
			$meta_key = substr( $meta_key, 9 );
			$maybe_meta = uwp_get_usermeta( $object_id, $meta_key, $single );
			if ( ! empty( $maybe_meta ) ) {
				$metadata = $maybe_meta;
			}
		}

		return $metadata;
	}

}

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 10 2025 04:32:23
inteuuod / inteuuod
0755
helpers
--
July 10 2025 04:32:23
inteuuod / inteuuod
0755
libraries
--
July 10 2025 04:32:23
inteuuod / inteuuod
0755
.htaccess
0.41 KB
July 10 2025 04:32:23
inteuuod / inteuuod
0644
abstract-uwp-privacy.php
3.543 KB
May 24 2018 18:32:58
inteuuod / inteuuod
0644
class-account.php
9.071 KB
January 09 2025 21:52:58
inteuuod / inteuuod
0644
class-activator.php
30.118 KB
February 04 2025 23:32:52
inteuuod / inteuuod
0644
class-addons.php
9.592 KB
March 13 2024 17:47:28
inteuuod / inteuuod
0644
class-ajax.php
2.782 KB
March 13 2024 17:47:28
inteuuod / inteuuod
0644
class-countries.php
11.445 KB
April 28 2022 17:18:48
inteuuod / inteuuod
0644
class-date.php
6.316 KB
September 19 2017 17:57:46
inteuuod / inteuuod
0644
class-emails.php
22.155 KB
April 10 2025 19:10:18
inteuuod / inteuuod
0644
class-files.php
23.46 KB
July 16 2024 18:34:28
inteuuod / inteuuod
0644
class-forms.php
170.66 KB
February 19 2025 22:09:02
inteuuod / inteuuod
0644
class-meta.php
12.987 KB
May 25 2022 16:36:12
inteuuod / inteuuod
0644
class-notices.php
7.954 KB
December 12 2024 21:47:10
inteuuod / inteuuod
0644
class-pages.php
17.646 KB
June 01 2021 17:14:04
inteuuod / inteuuod
0644
class-profile.php
60.792 KB
March 13 2024 17:47:28
inteuuod / inteuuod
0644
class-status.php
19.468 KB
July 16 2020 17:09:12
inteuuod / inteuuod
0644
class-tables.php
13.046 KB
June 25 2024 02:23:32
inteuuod / inteuuod
0644
class-templates.php
43.835 KB
March 19 2025 15:13:04
inteuuod / inteuuod
0644
class-tools.php
38.828 KB
March 13 2024 17:47:28
inteuuod / inteuuod
0644
class-user-notifications.php
5.606 KB
February 19 2025 22:09:02
inteuuod / inteuuod
0644
class-userswp.php
35.552 KB
February 04 2025 23:32:52
inteuuod / inteuuod
0644
class-uwp-background-updater.php
3.044 KB
June 27 2019 18:13:34
inteuuod / inteuuod
0644
class-uwp-compatibility.php
3.123 KB
October 10 2024 19:01:40
inteuuod / inteuuod
0644
class-uwp-defaults.php
9.666 KB
February 04 2025 23:32:52
inteuuod / inteuuod
0644
class-uwp-privacy-erasers.php
1.328 KB
May 24 2018 18:32:58
inteuuod / inteuuod
0644
class-uwp-privacy-exporters.php
3.309 KB
February 19 2020 16:22:32
inteuuod / inteuuod
0644
class-uwp-privacy.php
3.062 KB
December 20 2024 18:16:58
inteuuod / inteuuod
0644
class-uwp-seo.php
11.987 KB
March 13 2024 17:47:28
inteuuod / inteuuod
0644
class-validation.php
15.852 KB
November 01 2023 11:49:38
inteuuod / inteuuod
0644
deprecated-functions.php
0.181 KB
January 23 2020 19:10:04
inteuuod / inteuuod
0644
helpers.php
0.502 KB
January 23 2020 19:10:04
inteuuod / inteuuod
0644
index.php
0.025 KB
July 27 2017 16:44:24
inteuuod / inteuuod
0644
template-functions.php
6.082 KB
December 12 2024 21:47:10
inteuuod / inteuuod
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF