Plugin Directory

Changeset 2832199


Ignore:
Timestamp:
12/12/2022 08:58:32 AM (3 years ago)
Author:
Profitshare
Message:

Fix: Update to latest Wordpress Version and PHP 8.x compatibility

Location:
wp-profitshare
Files:
44 added
6 edited

Legend:

Unmodified
Added
Removed
  • wp-profitshare/trunk/changelog.txt

    r2648394 r2832199  
    6767= 1.4.8 =
    6868Fix: Add option to change experimental links
     69
     70= 1.4.9 =
     71Fix: Update to latest Wordpress Version and PHP 8.x compatibility
  • wp-profitshare/trunk/css/admin.css

    r2648394 r2832199  
    9191    width: 320px;
    9292}
    93 
     93.ps-button-sticky-to-input .ps-important-padding{
     94    padding: 11px;
     95    line-height: inherit;
     96}
    9497.ps-hide{
    9598    display: none;
  • wp-profitshare/trunk/includes/class-conversions.php

    r1799049 r2832199  
    147147
    148148                                $selected = '';
    149                                 if( $_GET['conversions-status-filter'] == $conv_status){
     149                                if( isset($_GET['conversions-status-filter']) && $_GET['conversions-status-filter'] == $conv_status){
    150150                                    $selected = ' selected = "selected"';   
    151151                                } ?>
     
    185185
    186186                                $selected = '';
    187                                 if( $_GET['conversions-min-sum-filter'] == $min_sum){
     187                                if( isset($_GET['conversions-min-sum-filter']) && $_GET['conversions-min-sum-filter'] == $min_sum){
    188188                                    $selected = ' selected = "selected"';   
    189189                                } ?>
     
    229229        $query_has_where = false;
    230230
    231         if($_GET['advertisers-filter']){
     231        if(isset($_GET['advertisers-filter'])){
    232232            $query_has_where = true;
    233233            $query = $query . ' where advertiser_id=' . $_GET['advertisers-filter'];   
    234234        }
    235235
    236         if($_GET['conversions-status-filter']){
     236        if(isset($_GET['conversions-status-filter'])){
    237237            $query = $query . (($query_has_where) ? " and" : " where") . " order_status='" . $_GET['conversions-status-filter']."'"; 
    238238            $query_has_where = true;
    239239        }
    240240
    241         if($_GET['conversions-min-sum-filter']){
     241        if(isset($_GET['conversions-min-sum-filter'])){
    242242            $query = $query . (($query_has_where) ? " and" : " where") . " items_commision >= " . $_GET['conversions-min-sum-filter']; 
    243243            $query_has_where = true;
  • wp-profitshare/trunk/includes/functions.php

    r2648394 r2832199  
    2323     */
    2424    global $ps_api_config;
     25
    2526    $current_user = wp_get_current_user();
    2627    $country = get_user_meta($current_user->ID, 'ps_api_country', true);
    27     return $ps_api_config[$country][$param];
     28    if($country){
     29        return $ps_api_config[$country][$param];
     30    }
     31   
    2832}
    2933
     
    121125
    122126    // update db
    123     if(get_user_meta($current_user->ID, 'ps_is_api_connected', true)) {
     127    if(isset($current_user) &&  get_user_meta($current_user->ID, 'ps_is_api_connected', true)) {
    124128        ps_update_advertisers_db(true);
    125129        ps_update_conversions(true);
     
    191195    if (get_option('ps_last_check_account_balance') + 60 * 60 < time()) {
    192196        $json = ps_api_connect('affiliate-info', 'GET', array());
    193         $total = number_format($json['result']['current_affiliate_earnings'], 2);
     197        $total = number_format(0,2);
     198        if ($json['result'] && $json['result']['current_affiliate_earnings']){
     199            $total = number_format($json['result']['current_affiliate_earnings'], 2);
     200        }
    194201        update_option('ps_account_balance', $total);
    195202        update_option('ps_last_check_account_balance', time() + 60 * 60);
     
    416423    global $wpdb;
    417424    $current_user = wp_get_current_user();
    418 
     425   
    419426    if ((get_option('ps_last_advertisers_update') + 60 * 60 * 24 < time() || true  && get_user_meta($current_user->ID, 'ps_is_api_connected', true)) || $force_update) {
    420427        update_option('ps_last_advertisers_update', time());
    421428        $json = ps_api_connect('affiliate-advertisers', 'GET');
    422429
    423         foreach ($json['result'] as $res) {
    424             $adv_id = (int) $res['id'];
    425 
    426             $check = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "ps_advertisers WHERE advertiser_id='" . $adv_id . "'", OBJECT);
    427             if (!$check) {
    428 
    429                 $insert_data = array(
    430                     'advertiser_id' => $res['id'],
    431                     'name' => $res['name'],
    432                     'link' => ps_clear_url($res['url'])
    433                 );
    434                 $try = $wpdb->insert($wpdb->prefix . "ps_advertisers", $insert_data);
    435             }
    436         }
     430        if ($json && $json['result']){
     431            foreach ($json['result'] as $res) {
     432                $adv_id = (int) $res['id'];
     433
     434                $check = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "ps_advertisers WHERE advertiser_id='" . $adv_id . "'", OBJECT);
     435                if (!$check) {
     436
     437                    $insert_data = array(
     438                        'advertiser_id' => $res['id'],
     439                        'name' => $res['name'],
     440                        'link' => ps_clear_url($res['url'])
     441                    );
     442                    $try = $wpdb->insert($wpdb->prefix . "ps_advertisers", $insert_data);
     443                }
     444            }
     445        }
     446
    437447    }
    438448}
     
    548558        $links = ps_get_html_links($content);
    549559        $count_links = count($links);
    550 
    551560        if ($limit_shorten_links == 'none') {
    552561            $count_links = 0;
     
    578587        update_post_meta($postid, '_ps_limit_shorten_links', $limit_shorten_links);
    579588    }
    580 
     589   
    581590    if (isset($_POST['ps_limit_keyword_links'])) {
    582591        $limit_keywords_links = sanitize_text_field($_POST['ps_limit_keyword_links']);
     
    635644        $links = array();
    636645        foreach ($DOMDoc->getElementsByTagName('a') as $link) {
    637             $check_advertiser = $wpdb->get_results("SELECT COUNT(*) as count FROM " . $wpdb->prefix . "ps_advertisers WHERE link='" . ps_clear_url($link->getAttribute('href')) . "'", OBJECT);
     646            $linkAttribute =  $link->getAttribute('href');
     647            if (is_array($linkAttribute)){
     648                continue;
     649            }
     650            $check_advertiser = $wpdb->get_results("SELECT COUNT(*) as count FROM " . $wpdb->prefix . "ps_advertisers WHERE link='" . ps_clear_url($linkAttribute) . "'", OBJECT);
    638651            if ($check_advertiser[0]->count || strpos($link->getAttribute('href'), 'm.'))
    639652                $links[] = array(
     
    720733     */
    721734    $url = parse_url($url);
    722     $url = str_replace('www.', '', $url['host']);
    723     return $url;
     735    $url = isset($url['host']) ?  $url['host'] : '';
     736    return str_replace('www.', '', $url);
    724737}
    725738
  • wp-profitshare/trunk/readme.txt

    r2648394 r2832199  
    44Requires at least: 4.0
    55Tested up to: 5.8.2
    6 Stable tag: 1.4.8
     6Stable tag: 1.4.9
    77Contributors: Conversion.ro
    88License: GPLv2
     
    128128= 1.4.8 =
    129129Fix: Add option to change experimental links
     130
     131= 1.4.9 =
     132Fix: Update to latest Wordpress Version and PHP 8.x compatibility
  • wp-profitshare/trunk/wp-profitshare.php

    r2648394 r2832199  
    44 * Plugin URI: https://www.profitshare.ro
    55 * Description: Converts all your direct links into affiliate links in order for you to earn commissions through Profitshare.
    6  * Version: 1.4.8
     6 * Version: 1.4.9
    77 * Author: Conversion
    88 * Author URI: https://www.conversion.ro
     
    1010 */
    1111defined('ABSPATH') || exit;
    12 define('PS_VERSION', '1.4.8');
    13 define('PS_DB_VERSION', '1.4.8');
     12define('PS_VERSION', '1.4.9');
     13define('PS_DB_VERSION', '1.4.9');
    1414
    1515require_once( 'includes/functions.php' );
     
    144144                    $newText .= "<img alt='CSS tooltip image' style='float:right; width:90px; margin:0 0 10px 10px;' src='" . $link->tip_image . "'>";
    145145                }
    146                 $newText .= $link->tip_description . "<div class='ttlast'>WP Profitshare 1.4.4</div></span></a>";
     146                $newText .= $link->tip_description . "<div class='ttlast'>WP Profitshare 1.4.9</div></span></a>";
    147147            } else {
    148148                $newText = "<a class='pslinks' href='" . $link->link . "' title='" . $link->title . "' target='" . $openin . "'>" . $link->keyword . "</a>";
     
    10541054            $(this).select();
    10551055        });
    1056 
    1057         $('#ps-advertisers-filter').live('change', function(){
     1056       
     1057        $('#ps-advertisers-filter').on('change', function(){
    10581058            var advertiser_filter = $(this).val();
    10591059
     
    10661066        });
    10671067
    1068         $('#status-filter').live('change', function(){
     1068        $('#status-filter').on('change', function(){
    10691069            var status_filter = $(this).val();
    10701070
     
    11641164                            <td class="p0">
    11651165                                <div class="ps-button-sticky-to-input ps-right">
    1166                                     <input type="text" class="ps-input" name="link" placeholder="https://" id="link" class="regular-text" />
     1166                                    <input type="text" class="ps-input regular-text ps-important-padding" name="link" placeholder="https://" id="link" />
    11671167                                    <input type="submit" name="submit_link" class="ps-new-btn ps-green ps-inline" value="Get link" />
    11681168                                    <div class="ps_checkbox_big">
     
    11771177                            // generate link
    11781178                            if (isset($_POST['submit_link'])) {
    1179                                 $protocol_post = $_POST['link_type'];
     1179                                $protocol_post = isset( $_POST['link_type']) ?  $_POST['link_type'] : null;
    11801180                                $url_protocol = 'https';
    11811181
     
    11831183                                    $url_protocol = 'http';
    11841184                                } 
    1185 
    1186                                 $link = esc_sql($_POST['link']);
     1185                                $rawLink = isset($_POST['link']) ? $_POST['link'] : '';
     1186                                $link = esc_sql($rawLink);
    11871187                                $ps_shorten_link = ps_shorten_link('WP Profitshare', $link);
    11881188                                if (!$ps_shorten_link['result']) {
     
    11961196                                    <div class="ps-generated-link ps-right">
    11971197                                        <div class="ps-button-sticky-to-input ps-right">
    1198                                             <input onClick="this.setSelectionRange(0, this.value.length)" class="ps-input ps-generated-link-input" type="text" id="generated_link" value="<?php echo $url_protocol.':'.$ps_shorten_link['shorted']; ?>" />
     1198                                            <input onClick="this.setSelectionRange(0, this.value.length)" class="ps-input ps-generated-link-input ps-important-padding" type="text" id="generated_link" value="<?php echo $url_protocol.':'.$ps_shorten_link['shorted']; ?>" />
    11991199                                            <input type="submit" name="submit_link" class="ps-new-btn ps-green ps-inline" id="copy_link" value="Copy" />
    12001200                                        </div>
     
    12371237        $("[name='link_type']").bootstrapSwitch();
    12381238
    1239         $('#ps-advertisers-filter').live('change', function(){
     1239        $('#ps-advertisers-filter').on('change', function(){
    12401240            var advertiser_filter = $(this).val();
    12411241
     
    12481248        });
    12491249
    1250         $('#ps-status-filter').live('change', function(){
     1250        $('#ps-status-filter').on('change', function(){
    12511251            var status_filter = $(this).val();
    12521252
     
    12591259        });
    12601260
    1261         $('#conversions-min-sum-filter').live('change', function(){
     1261        $('#conversions-min-sum-filter').on('change', function(){
    12621262            var min_sum = $(this).val();
    12631263
Note: See TracChangeset for help on using the changeset viewer.