setup( $_id ); } /** * Initialize the membership level object * * @param int $_id * * @access public * @since 1.1 * @return void */ public function setup( $_id = 0 ) { if ( empty( $_id ) ) { return; } $db = new RCP_Levels(); $level = $db->get_level( $_id ); if ( $level ) { foreach ( $level as $key => $value ) { $this->$key = $value; } } } /** * Sanitize membership level arguments for update / new queries. * * @param array $args * * @access public * @since 1.1 * @return array */ public function sanitize_level_args( $args = array() ) { $whitelist = array( 'name', // Name of the membership level. 'description', // Description of the level. 'duration', // Integer length of the level or "unlimited". 'duration_unit', // Duration unit, such as "day", "month", "year". 'trial_duration', // Integer length of the integrated free trial, or `0` for none. 'trial_duration_unit', // Trial duration unit, such as "day", "month", "year". 'price', // Integer or float price for the level. `0` for free. 'fee', // Integer or float signup fee. 'list_order', // Determines where in the list the level appears. 'level', // Associated access level (integer). 'status', // Active or inactive. 'role' // Associated user role granted to members of this level. ); foreach ( $args as $key => $value ) { // Do not allow empty values if ( empty( $key ) || empty( $value ) || ! in_array( $key, $whitelist ) ) { unset( $args[ $key ] ); } } return $args; } }