Giter VIP home page Giter VIP logo

Comments (2)

 avatar commented on July 26, 2024 1

Fabio, thanks for the heads up here. We were doing other work on the addon and merged some of this in in this pull request here: d188663

I'm still using the old ->data['entries'] method if you have < 100 lists just to be sure to not disrupt other users. Although the foreach method does work for < 100 lists as well. Thanks again.

from pmpro-aweber.

lazza87 avatar lazza87 commented on July 26, 2024

Resolved!
I have changed this piece of code in pmpro-aweber.php from:

function pmproaw_option_users_lists()
{
    global $pmproaw_lists;
    $options = get_option('pmproaw_options');

    if(isset($options['users_lists']) && is_array($options['users_lists']))
        $selected_lists = $options['users_lists'];
    else
        $selected_lists = array();

    if(!empty($pmproaw_lists))
    {

        echo "<select multiple='yes' name=\"pmproaw_options[users_lists][]\">";

        foreach($pmproaw_lists as $list)
        {
            echo "<option value='" . $list['id'] . "' ";
            if(in_array($list['id'], $selected_lists))
                echo "selected='selected'";
            echo ">" . $list['name'] . "</option>";
        }

        echo "</select>";

    }
    else
    {
        echo "No lists found.";
    }
}

function pmproaw_option_double_opt_in()
{
    $options = get_option('pmproaw_options');
    ?>
    <select name="pmproaw_options[double_opt_in]">
        <option value="0" <?php selected($options['double_opt_in'], 0);?>>No</option>
        <option value="1" <?php selected($options['double_opt_in'], 1);?>>Yes</option>
    </select>
    <?php
}

function pmproaw_option_memberships_lists($level)
{
    global $pmproaw_lists;
    $options = get_option('pmproaw_options');

    $level = $level[0]; //WP stores this in the first element of an array

    if(isset($options['level_' . $level->id . '_lists']) && is_array($options['level_' . $level->id . '_lists']))
        $selected_lists = $options['level_' . $level->id . '_lists'];
    else
        $selected_lists = array();

    if(!empty($pmproaw_lists))
    {
        echo "<select multiple='yes' name=\"pmproaw_options[level_" . $level->id . "_lists][]\">";
        foreach($pmproaw_lists as $list)
        {
            echo "<option value='" . $list['id'] . "' ";
            if(in_array($list['id'], $selected_lists))
                echo "selected='selected'";
            echo ">" . $list['name'] . "</option>";
        }

        echo "</select>";
    }
    else
    {
        echo "No lists found.";
    }
}

to:

function pmproaw_option_users_lists()
{
    global $pmproaw_lists;
    $options = get_option('pmproaw_options');

    if(isset($options['users_lists']) && is_array($options['users_lists']))
        $selected_lists = $options['users_lists'];
    else
        $selected_lists = array();

    if(!empty($pmproaw_lists))
    {

        echo "<select multiple='yes' name=\"pmproaw_options[users_lists][]\">";

        $pmproaw_aweber_api = new AWeberAPI(PMPROAW_CONSUMER_KEY, PMPROAW_CONSUMER_SECRET);
        $pmproaw_aweber_account = $pmproaw_aweber_api->getAccount($options['access_key'], $options['access_secret']);

        foreach($pmproaw_aweber_account->lists as $offset => $list)
        {
            echo "<option value='" . $list->id . "' ";
            if(in_array($list->id, $selected_lists))
                echo "selected='selected'";
            echo ">" . $list->name . "</option>";
        }

        echo "</select>";

    }
    else
    {
        echo "No lists found.";
    }
}

function pmproaw_option_double_opt_in()
{
    $options = get_option('pmproaw_options');
    ?>
    <select name="pmproaw_options[double_opt_in]">
        <option value="0" <?php selected($options['double_opt_in'], 0);?>>No</option>
        <option value="1" <?php selected($options['double_opt_in'], 1);?>>Yes</option>
    </select>
    <?php
}

function pmproaw_option_memberships_lists($level)
{
    global $pmproaw_lists;
    $options = get_option('pmproaw_options');

    $level = $level[0]; //WP stores this in the first element of an array

    if(isset($options['level_' . $level->id . '_lists']) && is_array($options['level_' . $level->id . '_lists']))
        $selected_lists = $options['level_' . $level->id . '_lists'];
    else
        $selected_lists = array();

    if(!empty($pmproaw_lists))
    {
        echo "<select multiple='yes' name=\"pmproaw_options[level_" . $level->id . "_lists][]\">";

        $pmproaw_aweber_api = new AWeberAPI(PMPROAW_CONSUMER_KEY, PMPROAW_CONSUMER_SECRET);
        $pmproaw_aweber_account = $pmproaw_aweber_api->getAccount($options['access_key'], $options['access_secret']);

        foreach($pmproaw_aweber_account->lists as $offset => $list)
        {
            echo "<option value='" . $list->id . "' ";
            if(in_array($list->id, $selected_lists))
                echo "selected='selected'";
            echo ">" . $list->name . "</option>";
        }

        echo "</select>";
    }
    else
    {
        echo "No lists found.";
    }
}

from pmpro-aweber.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.