- WordPress core y plugins - Tema Twenty Twenty-Four configurado - Plugin allow-unfiltered-html.php simplificado - .gitignore configurado para excluir wp-config.php y uploads 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
155 lines
3.1 KiB
PHP
Executable File
155 lines
3.1 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Membership Level
|
|
*
|
|
* @package rcp-rest-api
|
|
* @copyright Copyright (c) 2018, Restrict Content Pro team
|
|
* @license GPL2+
|
|
* @since 1.1
|
|
*/
|
|
|
|
class RCP_REST_API_Level {
|
|
|
|
/**
|
|
* @var int ID of the membership level.
|
|
*/
|
|
public $id = 0;
|
|
|
|
/**
|
|
* @var string Membership level name.
|
|
*/
|
|
public $name = '';
|
|
|
|
/**
|
|
* @var string Description.
|
|
*/
|
|
public $description = '';
|
|
|
|
/**
|
|
* @var int Duration of the membership period. 0 for unlimited.
|
|
*/
|
|
public $duration = 0;
|
|
|
|
/**
|
|
* @var string Duration unit.
|
|
*/
|
|
public $duration_unit = 'month';
|
|
|
|
/**
|
|
* @var int Duration of the integrated trial. 0 for none.
|
|
*/
|
|
public $trial_duration = 0;
|
|
|
|
/**
|
|
* @var string Duration unit for the integrated trial.
|
|
*/
|
|
public $trial_duration_unit = 'day';
|
|
|
|
/**
|
|
* @var int Price of the membership level. 0 for free.
|
|
*/
|
|
public $price = 0;
|
|
|
|
/**
|
|
* @var int Signup fee amount.
|
|
*/
|
|
public $fee = 0;
|
|
|
|
/**
|
|
* @var int List order.
|
|
*/
|
|
public $list_order = 0;
|
|
|
|
/**
|
|
* @var int Access level granted to members of this level.
|
|
*/
|
|
public $level = 0;
|
|
|
|
/**
|
|
* @var string Membership level status - "active" or "inactive".
|
|
*/
|
|
public $status = 'inactive';
|
|
|
|
/**
|
|
* @var string User role granted to members of this level.
|
|
*/
|
|
public $role = 'subscriber';
|
|
|
|
/**
|
|
* RCP_REST_API_Level constructor.
|
|
*
|
|
* @param int $_id
|
|
*
|
|
* @access public
|
|
* @since 1.1
|
|
*/
|
|
public function __construct( $_id = 0 ) {
|
|
$this->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;
|
|
|
|
}
|
|
|
|
} |