Plugin Directory

Changeset 3462731


Ignore:
Timestamp:
02/16/2026 05:10:53 PM (6 weeks ago)
Author:
filterdigital
Message:

Update to version 3.4.2 from GitHub

Location:
personalizewp
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • personalizewp/tags/3.4.2/README.txt

    r3458877 r3462731  
    44Requires at least: 6.2.0
    55Tested up to: 6.9
    6 Stable tag: 3.4.1
     6Stable tag: 3.4.2
    77Requires PHP: 7.4
    88License: GPL v3
     
    181181
    182182== Changelog ==
     183
     184= 3.4.2 =
     185
     186* Bug fix: Remove reliance on current admin user when getting all Membership Teams, causing most of the Teams to not show.
     187* Bug fix: Ensure invalid Membership Team IDs are not stored against visitors.
     188* Enhancement: Clear any invalid Membership Team IDs that might be stored against visitors.
    183189
    184190= 3.4.1 =
  • personalizewp/tags/3.4.2/includes/class-db-manager.php

    r3458877 r3462731  
    3939     * @var int
    4040     */
    41     const DB_VERSION = 341; // Increment with each change in db
     41    const DB_VERSION = 342; // Increment with each change in db
    4242
    4343    /**
     
    140140        }
    141141
    142         if ( $current_db_version < 341 ) {
    143             $this->upgrade_341( $current_db_version );
     142        if ( $current_db_version < 342 ) {
     143            $this->upgrade_342( $current_db_version );
    144144        }
    145145
     
    371371
    372372    /**
    373      * Executes changes made in 3.4.1.
    374      *
    375      * @since 3.4.1
     373     * Executes changes made in 3.4.2.
     374     *
     375     * @since 3.4.2
    376376     *
    377377     * @param int $db_version The old (current) database version.
     
    379379     * @return void
    380380     */
    381     private function upgrade_341( $db_version ) {
    382         global $wpdb;
    383 
    384         if ( $db_version < 341 ) {
     381    private function upgrade_342( $db_version ) {
     382        global $wpdb;
     383
     384        if ( $db_version < 342 ) {
    385385
    386386            // Check for use of Teams, no need to run if not. Cannot check for our Teams class as this upgrade runs early.
     
    393393            }
    394394
    395             // 1: Get all Visitor IDs with corresponding WP User ID meta, without a teams meta field ID
     395            // 0: Remove any potential invalid zero IDs on membership teams.
     396            $num_deleted = $wpdb->query(
     397                $wpdb->prepare(
     398                    'DELETE FROM %i WHERE meta_key = %s AND meta_value = 0',
     399                    $wpdb->prefix . 'pwp_contacts_meta',
     400                    'wc_memberships_team_id'
     401                )
     402            );
     403
     404            // 1: Get all Visitor IDs with corresponding WP User ID meta, without a teams meta field ID.
    396405            $visitor_ids = $wpdb->get_col(
    397406                $wpdb->prepare(
  • personalizewp/tags/3.4.2/includes/integrations/woocommerce/class-woocommerce-memberships-teams.php

    r3458877 r3462731  
    153153    public function get_team_by_id( int $team_id ) {
    154154
    155         if ( empty( $team_id ) || ! function_exists( 'wc_memberships_for_teams_get_team' ) ) {
     155        if ( empty( $team_id ) ) {
    156156            return null;
    157157        }
     
    174174    public function get_membership_teams(): array {
    175175
    176         if ( ! function_exists( 'wc_memberships_for_teams_get_teams' ) ) {
     176        if ( ! function_exists( 'wc_memberships_for_teams' ) ) {
    177177            return array();
    178178        }
     
    184184
    185185        // Start afresh.
    186         $this->teams = array();
    187         $_teams      = wc_memberships_for_teams_get_teams();
    188         foreach ( $_teams as $team ) {
    189             $_id                 = $team->get_id();
    190             $this->teams[ $_id ] = array(
    191                 'ID'         => $_id,
     186        $this->teams   = array();
     187        $teams_handler = wc_memberships_for_teams()->get_teams_handler_instance();
     188        $_teams_query  = new \WP_Query(
     189            array(
     190                'post_type'        => 'wc_memberships_team',
     191                'status'           => 'any',
     192                'fields'           => 'ids',
     193                'posts_per_page'   => -1,
     194                'nopaging'         => true,
     195                'suppress_filters' => false,
     196            )
     197        );
     198        foreach ( $_teams_query->posts as $team_id ) {
     199            $team = $teams_handler->get_team( $team_id );
     200            if ( ! $team ) {
     201                continue;
     202            }
     203            $this->teams[ $team_id ] = array(
     204                'ID'         => $team_id,
    192205                'team_name'  => $team->get_name(),
    193206                'team_email' => '', // Not currently supported
     
    820833     *
    821834     * @param int $user_id ID of WordPress User
    822      * @return int ID of Membership Team, or zero if none found or error
     835     * @return int ID of Membership Team, or null if none found or error
    823836     */
    824837    public function get_membership_team_id_by_user_id( $user_id ) {
    825838
    826839        if ( ! function_exists( 'wc_memberships_for_teams_get_teams' ) ) {
    827             return 0;
    828         }
     840            return null;
     841        }
     842
     843        $team_id = null;
    829844
    830845        // Note: Cannot use 'owner' within role restriction as it overrides the query, excluding the other roles.
    831846        $teams = wc_memberships_for_teams_get_teams( $user_id, array( 'role' => array( 'manager', 'member' ) ), null, true );
    832 
    833         $team_id = 0;
    834         $team    = array_shift( $teams ); // There should only be 1 result.
    835         if ( $team instanceof Team ) {
    836             $team_id = $team->get_id();
    837         }
    838 
    839         return (int) $team_id;
     847        if ( is_array( $teams ) ) {
     848            $team = array_shift( $teams ); // There should only be 1 result.
     849            if ( $team instanceof Team ) {
     850                $team_id = (int) $team->get_id();
     851            }
     852        }
     853
     854        return $team_id;
    840855    }
    841856
     
    861876
    862877        $team_id = $this->get_membership_team_id_by_user_id( $user_id );
     878        if ( empty( $team_id ) ) {
     879            return;
     880        }
    863881
    864882        // Add/update new meta data
  • personalizewp/tags/3.4.2/personalizewp.php

    r3458877 r3462731  
    1111 * Plugin URI:        https://personalizewp.com/
    1212 * Description:       Add powerful personalization features to your WordPress site. Show different content to different visitors based on their behavior, profile, location, and more.
    13  * Version:           3.4.1
     13 * Version:           3.4.2
    1414 * Author:            Filter
    1515 * Author URI:        https://filter.agency/
     
    4040 * Current plugin version.
    4141 */
    42 define( 'PERSONALIZEWP_VERSION', '3.4.1' );
     42define( 'PERSONALIZEWP_VERSION', '3.4.2' );
    4343
    4444// Load autoloader.
  • personalizewp/trunk/README.txt

    r3458877 r3462731  
    44Requires at least: 6.2.0
    55Tested up to: 6.9
    6 Stable tag: 3.4.1
     6Stable tag: 3.4.2
    77Requires PHP: 7.4
    88License: GPL v3
     
    181181
    182182== Changelog ==
     183
     184= 3.4.2 =
     185
     186* Bug fix: Remove reliance on current admin user when getting all Membership Teams, causing most of the Teams to not show.
     187* Bug fix: Ensure invalid Membership Team IDs are not stored against visitors.
     188* Enhancement: Clear any invalid Membership Team IDs that might be stored against visitors.
    183189
    184190= 3.4.1 =
  • personalizewp/trunk/includes/class-db-manager.php

    r3458877 r3462731  
    3939     * @var int
    4040     */
    41     const DB_VERSION = 341; // Increment with each change in db
     41    const DB_VERSION = 342; // Increment with each change in db
    4242
    4343    /**
     
    140140        }
    141141
    142         if ( $current_db_version < 341 ) {
    143             $this->upgrade_341( $current_db_version );
     142        if ( $current_db_version < 342 ) {
     143            $this->upgrade_342( $current_db_version );
    144144        }
    145145
     
    371371
    372372    /**
    373      * Executes changes made in 3.4.1.
    374      *
    375      * @since 3.4.1
     373     * Executes changes made in 3.4.2.
     374     *
     375     * @since 3.4.2
    376376     *
    377377     * @param int $db_version The old (current) database version.
     
    379379     * @return void
    380380     */
    381     private function upgrade_341( $db_version ) {
    382         global $wpdb;
    383 
    384         if ( $db_version < 341 ) {
     381    private function upgrade_342( $db_version ) {
     382        global $wpdb;
     383
     384        if ( $db_version < 342 ) {
    385385
    386386            // Check for use of Teams, no need to run if not. Cannot check for our Teams class as this upgrade runs early.
     
    393393            }
    394394
    395             // 1: Get all Visitor IDs with corresponding WP User ID meta, without a teams meta field ID
     395            // 0: Remove any potential invalid zero IDs on membership teams.
     396            $num_deleted = $wpdb->query(
     397                $wpdb->prepare(
     398                    'DELETE FROM %i WHERE meta_key = %s AND meta_value = 0',
     399                    $wpdb->prefix . 'pwp_contacts_meta',
     400                    'wc_memberships_team_id'
     401                )
     402            );
     403
     404            // 1: Get all Visitor IDs with corresponding WP User ID meta, without a teams meta field ID.
    396405            $visitor_ids = $wpdb->get_col(
    397406                $wpdb->prepare(
  • personalizewp/trunk/includes/integrations/woocommerce/class-woocommerce-memberships-teams.php

    r3458877 r3462731  
    153153    public function get_team_by_id( int $team_id ) {
    154154
    155         if ( empty( $team_id ) || ! function_exists( 'wc_memberships_for_teams_get_team' ) ) {
     155        if ( empty( $team_id ) ) {
    156156            return null;
    157157        }
     
    174174    public function get_membership_teams(): array {
    175175
    176         if ( ! function_exists( 'wc_memberships_for_teams_get_teams' ) ) {
     176        if ( ! function_exists( 'wc_memberships_for_teams' ) ) {
    177177            return array();
    178178        }
     
    184184
    185185        // Start afresh.
    186         $this->teams = array();
    187         $_teams      = wc_memberships_for_teams_get_teams();
    188         foreach ( $_teams as $team ) {
    189             $_id                 = $team->get_id();
    190             $this->teams[ $_id ] = array(
    191                 'ID'         => $_id,
     186        $this->teams   = array();
     187        $teams_handler = wc_memberships_for_teams()->get_teams_handler_instance();
     188        $_teams_query  = new \WP_Query(
     189            array(
     190                'post_type'        => 'wc_memberships_team',
     191                'status'           => 'any',
     192                'fields'           => 'ids',
     193                'posts_per_page'   => -1,
     194                'nopaging'         => true,
     195                'suppress_filters' => false,
     196            )
     197        );
     198        foreach ( $_teams_query->posts as $team_id ) {
     199            $team = $teams_handler->get_team( $team_id );
     200            if ( ! $team ) {
     201                continue;
     202            }
     203            $this->teams[ $team_id ] = array(
     204                'ID'         => $team_id,
    192205                'team_name'  => $team->get_name(),
    193206                'team_email' => '', // Not currently supported
     
    820833     *
    821834     * @param int $user_id ID of WordPress User
    822      * @return int ID of Membership Team, or zero if none found or error
     835     * @return int ID of Membership Team, or null if none found or error
    823836     */
    824837    public function get_membership_team_id_by_user_id( $user_id ) {
    825838
    826839        if ( ! function_exists( 'wc_memberships_for_teams_get_teams' ) ) {
    827             return 0;
    828         }
     840            return null;
     841        }
     842
     843        $team_id = null;
    829844
    830845        // Note: Cannot use 'owner' within role restriction as it overrides the query, excluding the other roles.
    831846        $teams = wc_memberships_for_teams_get_teams( $user_id, array( 'role' => array( 'manager', 'member' ) ), null, true );
    832 
    833         $team_id = 0;
    834         $team    = array_shift( $teams ); // There should only be 1 result.
    835         if ( $team instanceof Team ) {
    836             $team_id = $team->get_id();
    837         }
    838 
    839         return (int) $team_id;
     847        if ( is_array( $teams ) ) {
     848            $team = array_shift( $teams ); // There should only be 1 result.
     849            if ( $team instanceof Team ) {
     850                $team_id = (int) $team->get_id();
     851            }
     852        }
     853
     854        return $team_id;
    840855    }
    841856
     
    861876
    862877        $team_id = $this->get_membership_team_id_by_user_id( $user_id );
     878        if ( empty( $team_id ) ) {
     879            return;
     880        }
    863881
    864882        // Add/update new meta data
  • personalizewp/trunk/personalizewp.php

    r3458877 r3462731  
    1111 * Plugin URI:        https://personalizewp.com/
    1212 * Description:       Add powerful personalization features to your WordPress site. Show different content to different visitors based on their behavior, profile, location, and more.
    13  * Version:           3.4.1
     13 * Version:           3.4.2
    1414 * Author:            Filter
    1515 * Author URI:        https://filter.agency/
     
    4040 * Current plugin version.
    4141 */
    42 define( 'PERSONALIZEWP_VERSION', '3.4.1' );
     42define( 'PERSONALIZEWP_VERSION', '3.4.2' );
    4343
    4444// Load autoloader.
Note: See TracChangeset for help on using the changeset viewer.