如何提取从php到wordpress的推荐链接?

时间:2017-05-17 06:37:53

标签: php wordpress

我需要帮助。 我有一个带有推荐功能的wordpress网络系统。它链接到推荐链接。

但问题是,我不知道如何提取EXACT推荐链接并将其复制并将其放入共享按钮。因此,它将强制共享链接URL引用链接而不是主站点。

示例:

我创建了一个用户g3。 g3推荐链接是www.domain.com/ref=g3 但当我把插件分享按钮时,它只分享www.domain.com,而不是www.domain.com/ref=g3

首先,我不知道www.domain.com/ref=g3在哪里生成。

这是PHP代码:它不是我的程序。这是由一名平均开发人员完成的,他在完成项目中途后逃跑了。请帮助。

<?php
function mlmNetworkDetailsPage() {
    global $current_user, $wpdb;
    $user_id = get_current_userID();
    $personalSales = totalMyPersonalSales( $user_id );
    $activePersonalSales = activeUsersOnPersonalSales( $user_id );
    $fivePersonalUsers = myFivePersonalUsers( $user_id );
    wp_get_current_user();
    $username = $current_user->ID;

    $user_info = get_userdata($current_user->ID);
    $_SESSION['ajax'] = 'ajax_check';

    $add_page_id = get_post_id('mlm_registration_page');
    $sponsor_name = $current_user->user_login;
    $mlm_settings = get_option('wp_mlm_general_settings');
    $affiliateURLold = site_url() . '?page_id=' . $add_page_id . '&sp_name=' . $sponsor_name;
    $affiliateURLnew = site_url() . '/ref/' . $sponsor_name;
    $permalink = get_permalink(empty($_GET['page_id']) ? '' : $_GET['page_id']);
    $postidparamalink = strstr($permalink, 'page_id');
    $affiliateURL = ($postidparamalink) ? $affiliateURLold : $affiliateURLnew;
    $view_memberpage_id = $wpdb->get_var("SELECT `id` FROM `{$wpdb->prefix}posts` WHERE `post_content` LIKE '%mlm-view-child-level-member%' AND `post_type` != 'revision'");
    $mlm_general_settings = get_option('wp_mlm_general_settings');
    $mlm_no_of_level=$mlm_general_settings['mlm-level'];
    $spon_name = $wpdb->get_var("SELECT `username` FROM ".MLM_USERS." WHERE `user_id` IN(SELECT `parent_id` FROM ".MLM_USERS." WHERE `user_id` = '".$current_user->ID."')");
    $payment_status = $wpdb->get_var("SELECT `payment_status` FROM ".MLM_USERS." WHERE `user_id` = '".$current_user->ID."'");
    $total_referal = $wpdb->get_var("SELECT COUNT(sponsor_id) FROM  ".MLM_USERS." WHERE sponsor_id ='".$current_user->ID."'");
    $active_member = $wpdb->get_var("SELECT COUNT(*) FROM  ".MLM_USERS." WHERE sponsor_id='".$current_user->ID."' AND payment_status='1'");
        $non_active_member = $wpdb->get_var("SELECT COUNT(*) FROM  ".MLM_USERS." WHERE sponsor_id='".$current_user->ID."' AND payment_status='0'");
        $total_downline = totalDownlineMembers( $current_user->ID );
        $total_paiddownline = totalDownlinepaidMembers( $current_user->ID );
        //$total_unpaiddownline = totalDownlineunpaidMembers( $current_user->ID );
        $total_unpaiddownline = $total_downline - $total_paiddownline;
    ?>
    <script>
    $(document).ready(function() {

    var isMobile = {
        Android: function() {
            return navigator.userAgent.match(/Android/i);
        },
        BlackBerry: function() {
            return navigator.userAgent.match(/BlackBerry/i);
        },
        iOS: function() {
            return navigator.userAgent.match(/iPhone|iPad|iPod/i);
        },
        Opera: function() {
            return navigator.userAgent.match(/Opera Mini/i);
        },
        Windows: function() {
            return navigator.userAgent.match(/IEMobile/i);
        },
        any: function() {
            return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
        }
    };
     $(document).on("click", '.whatsapp', function() {
            if( isMobile.any() ) {


                var text = $(this).attr("data-text");
                var url = $(this).attr("data-link");
                var message = encodeURIComponent(text) + " - " + encodeURIComponent(url);
                var whatsapp_url = "whatsapp://send?text=" + message;
    //console.log(whatsapp_url);
                window.location.href = whatsapp_url;
            } else {
                alert("Please share this article in mobile device");
            }

        });
    });
    </script>
    <?php   
    if( $payment_status == 1 ) {
        $totalcommission = $wpdb->get_var("SELECT SUM(amount) FROM `{$wpdb->prefix}ume_commission` WHERE `parent_id` = '".$current_user->ID."' AND `eligibility` = '1' AND `payout_id` != '0'");
    } else {
        $totalcommission = $wpdb->get_var("SELECT SUM(amount) FROM `{$wpdb->prefix}ume_commission` WHERE `parent_id` = '".$current_user->ID."' AND `eligibility` = '0'");
    }
    $closing_bal = $wpdb->get_var("SELECT `closing_bal` FROM ".MLM_TRANSACTION." WHERE `id` = (SELECT max(`id`) FROM ".MLM_TRANSACTION." WHERE `user_id` = '".$current_user->ID."')");
    ?>

    <div class="affiliate_url">
        <h3 style="color: #ffffff !important;"><i>Affiliate URL:</i> <?php echo $affiliateURL; ?></h3>
        <a href="whatsapp://send?text=<?php echo $affiliateURL; ?>" class="whatsapp w3_whatsapp_btn w3_whatsapp_btn_medium"><i class="fa fa-whatsapp" aria-hidden="true"></i> Share on Whatsapp</a>

        <a href="http://www.facebook.com/sharer/sharer.php?u=<?php echo $affiliateURL; ?>&t=TITLE_HERE" target="_blank" class="share-popup whatsapp w3_whatsapp_btn w3_fb_btn_medium"><i class="fa fa-facebook" aria-hidden="true"></i> Share on Facebook</a>
<a href="http://www.twitter.com/intent/tweet?url=URL_HERE&via=TWITTER_HANDLE_HERE&text=TITLE_HERE" target="_blank" class="share-popup whatsapp w3_whatsapp_btn w3_twitter_btn_medium"><i class="fa fa-twitter" aria-hidden="true"></i> Share on Twitter</a>
<a href="http://plus.google.com/share?url=<?php echo $affiliateURL; ?>" target="_blank" class="share-popup whatsapp w3_whatsapp_btn w3_google_btn_medium"><i class="fa fa-plus" aria-hidden="true"></i> Share on Googleplus</a>
    </div>

<script type="text/javascript">
$(".share-popup").click(function(){
    var window_size = "width=585,height=511";
    var url = this.href;
    var domain = url.split("/")[2];
    switch(domain) {
        case "www.facebook.com":
            window_size = "width=585,height=368";
            break;
        case "www.twitter.com":
            window_size = "width=585,height=261";
            break;
        case "plus.google.com":
            window_size = "width=517,height=511";
            break;
    }
    window.open(url, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,' + window_size);
    return false;
});

0 个答案:

没有答案