HEX
Server: Apache
System: Linux p3plzcpnl506847.prod.phx3.secureserver.net 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: slfopp7cb1df (5698090)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: /home/slfopp7cb1df/www/home/wp-content/plugins/easy-pricing-tables/includes/pointer.php
<?php

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;

// Load pointers 
function dh_ptp_pointer_load($hook_suffix)
{
    // Sanity checks
    if ((!current_user_can('manage_options') || !is_super_admin()) || (get_bloginfo( 'version' ) < '3.3')) {
		return;
    }
  
    // Load mailing list pointer popup
    global $current_screen;
    global $pagenow;
    
    // Show mailing list pointer popup once
    $mailing_list = get_option('dh_ptp_mailing_list');
    if ( 'easy-pricing-table' == $current_screen->post_type &&
           (( isset($_REQUEST['action']) && 'edit' == $_REQUEST['action']) || 'post-new.php' == $pagenow) && 
           !in_array($mailing_list, array('yes', 'no'))) {
        
        wp_enqueue_style('wp-pointer');
        wp_enqueue_script('wp-pointer');
        add_action('admin_print_footer_scripts', 'dh_ptp_mailing_list_pointer');        
    }
}
add_action('admin_enqueue_scripts', 'dh_ptp_pointer_load');


// Add mailing list subscription
function dh_ptp_mailing_list_pointer() 
{
	// Get current user info
	$current_user = wp_get_current_user();
	
    // Ajax request template
	$gdpr_script = 'if ( jQuery("#gdpr_consent").prop("checked") == false )
			return alert("Your consent is required to complete this action.  Please agree to the terms before proceeding.")';
		
    $ajax = '
		
        jQuery.ajax({
            type: "POST",
            url:  "'.admin_url('admin-ajax.php').'",
            data: {action: "dh_ptp_mailing_list", email: jQuery("#ept_email").val(), nonce: "'.wp_create_nonce('dh_ptp_mailing_list').'", subscribe: "%s" }
        }).done(function( html ) {
                      eval( html  );
         });
    ';
    
    // Target
    $id = '#wpadminbar';
    
    // Buttons
    $button_1_title = __('No, thanks', 'easy-pricing-tables');
    $button_1_fn    = sprintf($ajax, 'no');
    $button_2_title = __("Let&#39;s do it!", 'easy-pricing-tables');
    $button_2_fn    = $gdpr_script . sprintf($ajax, 'yes');
    
    // Content
    $content  = '<h3>' . __('Pricing Table Crash Course', 'easy-pricing-tables') . '</h3>';
    $content .= '<p>' . __("Instead of watching 99% of your visitors bounce, imagine you could increase your pricing table&#39;s conversion rate and make more money. Find out how in this ridiculously actionable (and totally free) 5-part email course.", 'easy-pricing-tables') . '</p>';
    $content .= '<p>' . '<input type="text" name="ept_email" id="ept_email" value="' . $current_user->user_email . '" style="width: 100%"/>' . '</p>';
	$content .= '<p><label><input type="checkbox" id="gdpr_consent"></input>'. __('I agree to receive occasional email updates', 'easy-pricing-tables').'</label></p>';
	
    // Options
    $options = array(
        'content' => $content,
        'position' => array('edge' => 'top', 'align' => 'center')
    );
    
    dh_ptp_print_script($id, $options, $button_1_title, $button_2_title, $button_1_fn, $button_2_fn);
}

function dh_ptp_mailing_list_pointer_ajax()
{
	// Get current user info
	$current_user = wp_get_current_user();

    // Verify nonce
    if(!wp_verify_nonce($_POST['nonce'], 'dh_ptp_mailing_list') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
        die ('No tricky business!');
    }
    
    // Check status
    $result = ($_POST['subscribe'] == 'yes')?'yes':'no';
    if ($result == 'no') {
        update_option('dh_ptp_mailing_list', 'no');
        exit();
    }
    
	dh_ptp_add_subscriber(
                'https://www.getdrip.com/forms/7564307/submissions',
		
		array(  'fields[name]'  => $current_user->display_name,
			'fields[email]' => $_POST['email'], //$current_user->user_email,,
					)
	);
                
    update_option('dh_ptp_mailing_list', $result);
    
    // After custommers "sign up", display another pointer to ask them check the confirm email  
    $button_2_title = false;
    $kind_of_email_link = '';
    if ( strpos( $_POST['email'] , '@yahoo' ) !== false ) {
        $button_2_title = 'Go to Yahoo! Mail';
        $kind_of_email_link = 'https://mail.yahoo.com/';
    } elseif ( strpos( $_POST['email'] , '@hotmail' ) !== false )
    {
        $button_2_title = 'Go to Hotmail';
        $kind_of_email_link = 'https://www.hotmail.com/';
    } elseif ( strpos( $_POST['email'] , '@gmail' ) !== false )
    {
        $button_2_title = 'Go to Gmail';
        $kind_of_email_link = 'https://mail.google.com/';
    } elseif ( strpos( $_POST['email'] , '@aol' ) !== false ) 
    {
        $button_2_title = 'Go to AOL Mail';
        $kind_of_email_link = 'https://mail.aol.com/';
    }
    
    $button_2_func = "window.open('$kind_of_email_link', '_blank');";
    
    // Target
    $id = '#wpadminbar';
    
    // Buttons
    $button_1_title = __('Close', 'easy-pricing-tables');
    
    // Content
    $content  = '<h3>' . __('Please confirm your email', 'easy-pricing-tables') . '</h3>';
    $content .= '<p>' . __("Thanks! For privacy reasons you'll have to confirm your email. Please check your email inbox.", 'easy-pricing-tables') . '</p>';
    
    // Options
    $options = array(
        'content' => $content,
        'position' => array('edge' => 'top', 'align' => 'center')
    );
    
    dh_ptp_print_script($id, $options, $button_1_title, $button_2_title , '' , $button_2_func , true);    
    
    exit();
}
add_action( 'wp_ajax_dh_ptp_mailing_list', 'dh_ptp_mailing_list_pointer_ajax');

function dh_ptp_add_subscriber($url, $payload = array())
{
        $data = http_build_query($payload);
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC) ; 
		curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); 
		curl_setopt($ch, CURLOPT_HEADER, false);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_POST, true);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
		curl_setopt($ch, CURLOPT_URL, $url);
		$result = curl_exec($ch);
		curl_close($ch);
		return $result;
}


// Print JS Content
function dh_ptp_print_script($selector, $options, $button1, $button2 = false, $button1_fn = '', $button2_fn = '', $isCallBackFunc = false)
{ 
    if( !$isCallBackFunc ) {
    ?>
    <script type="text/javascript">
		//<![CDATA[
            (function ($) {
                <?php 
          }
                ?>
                var dh_ptp_pointer_options = <?php echo json_encode( $options ); ?>, setup;
     
                dh_ptp_pointer_options = $.extend(dh_ptp_pointer_options, {
                    buttons:function (event, t) {
                        button = jQuery('<a id="pointer-close" style="margin-left:5px" class="button-secondary">' + '<?php echo $button1; ?>' + '</a>');
                        button.bind('click.pointer', function () {
                            t.element.pointer('close');
                        });
                        return button;
                    },
                    close:function () {
                    }
                });
     
                setup = function () {
                    $('<?php echo $selector; ?>').pointer(dh_ptp_pointer_options).pointer('open');
                    <?php if ( $button2 ) : ?>
                        jQuery('#pointer-close').after('<a id="pointer-primary" class="button-primary">' + '<?php echo $button2; ?>' + '</a>');
                        jQuery('#pointer-primary').click(function () {
                            <?php echo $button2_fn; ?>
                            $('<?php echo $selector; ?>').pointer('close');
                        });
                        
                        jQuery('#ept_email').keypress(function ( event ) {
                             if ( event.which == 13 ) {
                                <?php echo $button2_fn; ?>
                                $('<?php echo $selector; ?>').pointer('close');
                             }
                            
                        });
                        
                        jQuery('#pointer-close').click(function () {
                            <?php echo $button1_fn; ?>
                            $('<?php echo $selector; ?>').pointer('close');
                        });
                    <?php endif; ?>
                };
 
                $(document).ready(setup);
          <?php if( !$isCallBackFunc ) { ?>
          })(jQuery);
        //]]>
	</script>
    <?php
          }
}
?>