PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /home/trave494/familymovies.us/wp-content/plugins/indeed-membership-pro/classes/
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
IP: 209.182.202.254
Choose File :

Url:
Dir : /home/trave494/familymovies.us/wp-content/plugins/indeed-membership-pro/classes/GeneralActions.php

<?php

namespace Indeed\Ihc;

class GeneralActions
{

    public function __construct()
    {
        add_action( 'ihc_before_user_save_custom_field', array( $this, 'changeAvatar' ), 999, 3 );

        add_action( 'ihc_action_general_init', [ $this, 'restrictEntireWebsiteWithoutLogin' ], 999, 1 );

        // checkout page - redirect
        add_action( 'ihc_action_general_init', [ $this, 'checkoutPageRestriction' ], 9999, 1 );

    }

    /**
     * @param string
     * @param string
     * @param string
     * @return none
     */
    public function changeAvatar( $uid='', $metaKey='', $metaValue='' )
    {
        if ( $metaKey != 'ihc_avatar' || $metaValue == '' ){
            return;
        }
        $oldValue = get_user_meta( $uid, 'ihc_avatar', true );
        if ( !$oldValue || $oldValue == $metaValue ){
            return;
        }
        if ( strpos( $oldValue, "http" ) === 0 ){
            return;
        }
        /// delete old avatar
        wp_delete_attachment( $oldValue, true );

    }

    /**
     * @param int
     * @return none
     */
    public function restrictEntireWebsiteWithoutLogin( $postId=0 )
    {
        global $current_user;
        if ( isset( $current_user->ID ) &&  $current_user->ID > 0 ){
            return;
        }
        $restrictionOn = get_option( 'ihc_security_restrict_everything' );
        if ( !$restrictionOn ){
            return ;
        }
        $login = get_option( 'ihc_general_login_default_page' );
        if ( $login == $postId ){
            return;
        }
        if ( $login === false || $login == '' || $login == -1 ){
            return;
        }
        $loginPermalink = get_permalink( $login );
        if ( $loginPermalink === false || $loginPermalink == '' ){
            return;
        }
        $except = get_option( 'ihc_security_restrict_everything_except' );
        $allow = explode( ',', preg_replace('/\s+/', '', $except ) );

        if ( count( $allow ) > 0 && in_array( $postId, $allow ) ){
            return;
        }
        wp_redirect( $loginPermalink );
        exit;
    }

    /**
     * @param int
     * @return none
     */
    public function checkoutPageRestriction( $postId=0 )
    {
        global $current_user;
        if ( isset( $current_user->ID ) &&  $current_user->ID > 0 ){
            // user is logged in
            return;
        }
        $checkoutPageId = get_option( 'ihc_checkout_page' );
        $checkoutPageId = (int)$checkoutPageId;
        if ( !$checkoutPageId ){
            // checkout page doesnt exists
            return;
        }
        if ( $checkoutPageId === $postId ){
            $register = get_option('ihc_general_register_default_page');
            $registerPage = get_permalink( $register );
            if ( $registerPage === false ){
                // current page is checkout page and user is not logged in so do the redirect
                return;
            }
            wp_redirect( $registerPage );
            exit;
        }
    }

}