Commit inicial - WordPress Análisis de Precios Unitarios

- 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>
This commit is contained in:
root
2025-11-03 21:04:30 -06:00
commit a22573bf0b
24068 changed files with 4993111 additions and 0 deletions

View File

@@ -0,0 +1,740 @@
<?php
/**
* RCP Discounts class
*
* This class handles querying, inserting, updating, and removing discounts
* Also includes other discount helper functions
*
* @package Restrict Content Pro
* @subpackage Classes/Discounts
* @copyright Copyright (c) 2017, Pippin Williamson
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.5
*/
/**
* Class RCP_Discounts
*
* @deprecated 3.3
*/
class RCP_Discounts {
/**
* Holds the name of our discounts database table
*
* @access public
* @since 1.5
*/
public $db_name;
/**
* Holds the version number of our discounts database table
*
* @access public
* @since 1.5
*/
public $db_version;
/**
* Get things started
*
* @since 1.5
* @return void
*/
function __construct() {
$this->db_name = rcp_get_discounts_db_name();
$this->db_version = '1.3';
}
/**
* Retrieve discounts from the database
*
* @deprecated 3.3 In favour of rcp_get_discounts()
* @see rcp_get_discounts()
*
* @param array $args Query arguments.
*
* @access public
* @since 1.5
* @return array|false Array of discounts or false if none.
*/
public function get_discounts( $args = array() ) {
_deprecated_function( __METHOD__, '3.3', 'rcp_get_discounts' );
$defaults = array(
'status' => 'all',
'number' => null,
'offset' => 0,
);
$args = wp_parse_args( $args, $defaults );
$discounts = rcp_get_discounts( $args );
return ! empty( $discounts ) ? $discounts : false;
}
/**
* Count the total number of discount codes in the database
*
* @deprecated 3.3 In favour of rcp_count_discounts()
* @see rcp_count_discounts()
*
* @param array $args Query arguments to override the defaults.
*
* @access public
* @return int
*/
public function count( $args = array() ) {
_deprecated_function( __METHOD__, '3.3', 'rcp_count_discounts' );
$defaults = array(
'status' => 'all'
);
$args = wp_parse_args( $args, $defaults );
return rcp_count_discounts( $args );
}
/**
* Retrieve a specific discount from the database
*
* @deprecated 3.3 In favour of rcp_get_discount()
* @see rcp_get_discount()
*
* @param int $discount_id ID of the discount to retrieve.
*
* @access public
* @since 1.5
* @return object|null Database row or null on failure.
*/
public function get_discount( $discount_id = 0 ) {
_deprecated_function( __METHOD__, '3.3', 'rcp_get_discount' );
return rcp_get_discount( $discount_id );
}
/**
* Retrieve a specific discount from the database by field
*
* @deprecated 3.3 In favour of rcp_get_discount_by()
* @see rcp_get_discount_by()
*
* @param string $field Name of the field to check.
* @param string $value Value of the field.
*
* @access public
* @since 1.5
* @return object|null Database row or null on failure.
*/
public function get_by( $field = 'code', $value = '' ) {
_deprecated_function( __METHOD__, '3.3', 'rcp_get_discount_by' );
return rcp_get_discount_by( $field, $value );
}
/**
* Get the status of a discount
*
* @deprecated 3.3 In favour of rcp_get_discount_status()
* @see rcp_get_discount_status()
*
* @param int $discount_id ID of the discount.
*
* @access public
* @since 1.5
* @return string|false Discount status or false on failure.
*/
public function get_status( $discount_id = 0 ) {
_deprecated_function( __METHOD__, '3.3', 'rcp_get_discount_status' );
return rcp_get_discount_status( $discount_id );
}
/**
* Get the amount of a discount
*
* @deprecated 3.3 In favour of RCP_Discount::get_amount()
* @see RCP_Discount::get_amount()
*
* @param int $discount_id ID of the discount.
*
* @access public
* @since 1.5
* @return int|float
*/
public function get_amount( $discount_id = 0 ) {
_deprecated_function( __METHOD__, '3.3', 'RCP_Discount::get_amount' );
$discount = rcp_get_discount( $discount_id );
if ( $discount ) {
return $discount->get_amount();
} else {
return 0;
}
}
/**
* Get the number of times a discount has been used
*
* @deprecated 3.3 In favour of RCP_Discount::get_use_count()
* @see RCP_Discount::get_use_count()
*
* @param int $discount_id ID of the discount.
*
* @access public
* @since 1.5
* @return int
*/
public function get_uses( $discount_id = 0 ) {
_deprecated_function( __METHOD__, '3.3', 'RCP_Discount::get_use_count' );
$discount = rcp_get_discount( $discount_id );
if ( $discount ) {
return $discount->get_use_count();
} else {
return 0;
}
}
/**
* Get the maximum number of times a discount can be used
*
* @deprecated 3.3 In favour of RCP_Discount::get_max_uses()
* @see RCP_Discount::get_max_uses()
*
* @param int $discount_id ID of the discount.
*
* @access public
* @since 1.5
* @return int
*/
public function get_max_uses( $discount_id = 0 ) {
_deprecated_function( __METHOD__, '3.3', 'RCP_Discount::get_max_uses' );
$discount = rcp_get_discount( $discount_id );
if ( $discount ) {
return $discount->get_max_uses();
} else {
return 0;
}
}
/**
* Get the associated membership level for a discount
*
* @deprecated 3.0 Use `get_membership_level_ids()` instead.
* @see RCP_Discounts::get_membership_level_ids()
*
* @param int $discount_id ID of the discount.
*
* @access public
* @since 1.6
* @return int
*/
public function get_subscription_id( $discount_id = 0 ) {
_deprecated_function( __METHOD__, '3.0', 'RCP_Discount::get_membership_level_ids' );
$ids = $this->get_membership_level_ids( $discount_id );
if ( empty( $ids ) || ! isset( $ids[0] ) ) {
return 0;
}
return $ids[0];
}
/**
* Get the associated membership level(s) for a discount.
*
* @deprecated 3.3 In favour of RCP_Discount::get_membership_level_ids()
* @see RCP_Discount::get_membership_level_ids()
*
* @param int $discount_id ID of the discount.
*
* @access public
* @since 3.0
* @return array
*/
public function get_membership_level_ids( $discount_id = 0 ) {
_deprecated_function( __METHOD__, '3.3', 'RCP_Discount::get_membership_level_ids' );
$discount = rcp_get_discount( $discount_id );
if ( empty( $discount ) ) {
return array();
}
return $discount->get_membership_level_ids();
}
/**
* Checks whether a discount code has a membership level associated
*
* @deprecated 3.0 Use `has_membership_level_ids()` instead.
* @see RCP_Discounts::has_membership_level_ids()
*
* @param int $discount_id ID of the discount.
*
* @access public
* @since 1.6
* @return bool
*/
public function has_subscription_id( $discount_id = 0 ) {
_deprecated_function( __METHOD__, '3.0', 'RCP_Discount::has_membership_level_ids' );
return $this->get_subscription_id( $discount_id ) > 0;
}
/**
* Checks whether a discount code has at least one associated membership level.
*
* @deprecated 3.3 In favour of RCP_Discount::has_membership_level_ids()
* @see RCP_Discount::has_membership_level_ids()
*
* @param int $discount_id ID of the discount code.
*
* @access public
* @since 3.0
* @return bool
*/
public function has_membership_level_ids( $discount_id = 0 ) {
_deprecated_function( __METHOD__, '3.3', 'RCP_Discount::has_membership_level_ids' );
$membership_level_ids = $this->get_membership_level_ids( $discount_id );
return ( count( $membership_level_ids ) > 0 );
}
/**
* Increase the use count of a discount by 1
*
* @deprecated 3.3 In favour of RCP_Discount::increment_use_count()
* @see RCP_Discount::increment_use_count()
*
* @param int $discount_id ID of the discount.
*
* @access public
* @since 1.5
* @return void
*/
public function increase_uses( $discount_id = 0 ) {
_deprecated_function( __METHOD__, '3.3', 'RCP_Discount::increment_use_count' );
$discount = rcp_get_discount( $discount_id );
if ( ! empty( $discount ) ) {
$discount->increment_use_count();
}
}
/**
* Decrease the use count of a discount by 1
*
* @deprecated 3.3 In favour of RCP_Discount::decrement_use_count()
* @see RCP_Discount::decrement_use_count()
*
* @param int $discount_id ID of the discount.
*
* @access public
* @since 2.8
* @return void
*/
public function decrease_uses( $discount_id = 0 ) {
_deprecated_function( __METHOD__, '3.3', 'RCP_Discount::decrement_use_count' );
$discount = rcp_get_discount( $discount_id );
if ( ! empty( $discount ) ) {
$discount->decrement_use_count();
}
}
/**
* Get the expiration date of a discount
*
* @deprecated 3.3 In favour of RCP_Discount::get_expiration()
* @see RCP_Discount::get_expiration()
*
* @param int $discount_id ID of the discount.
*
* @access public
* @since 1.5
* @return string|false Expiration date, or false if it never expires.
*/
public function get_expiration( $discount_id = 0 ) {
_deprecated_function( __METHOD__, '3.3', 'RCP_Discount::get_expiration' );
$discount = rcp_get_discount( $discount_id );
if ( ! empty( $discount ) ) {
return $discount->get_expiration();
}
return false;
}
/**
* Get the discount type
*
* @deprecated 3.3 In favour of RCP_Discount::get_unit()
* @see RCP_Discount::get_unit()
*
* @param int $discount_id ID of the discount.
*
* @access public
* @since 1.5
* @return string|false
*/
public function get_type( $discount_id = 0 ) {
_deprecated_function( __METHOD__, '3.3', 'RCP_Discount::get_unit' );
$discount = rcp_get_discount( $discount_id );
if ( ! empty( $discount ) ) {
return $discount->get_unit();
}
return false;
}
/**
* Store a discount in the database
*
* @deprecated 3.3 In favour of rcp_add_discount()
* @see rcp_add_discount()
*
* @param array $args Arguments for the discount code.
*
* @access public
* @since 1.5
* @return int|WP_Error|false ID of the newly created discount code or WP_Error/false on failure.
*/
public function insert( $args = array() ) {
_deprecated_function( __METHOD__, '3.3', 'rcp_add_discount' );
$defaults = array(
'name' => '',
'description' => '',
'amount' => '0.00',
'status' => 'inactive',
'unit' => '%',
'code' => '',
'expiration' => '',
'max_uses' => 0,
'use_count' => '0',
'membership_level_ids' => array(),
'one_time' => 0
);
$args = wp_parse_args( $args, $defaults );
$discount_id = rcp_add_discount( $args );
return $discount_id;
}
/**
* Update an existing discount
*
* @deprecated 3.3 In favour of rcp_update_discount()
* @see rcp_update_discount()
*
* @param int $discount_id ID of the discount to update.
* @param array $args Array of fields/values to update.
*
* @access public
* @since 1.5
* @return bool Whether or not the update was successful.
*/
public function update( $discount_id = 0, $args = array() ) {
_deprecated_function( __METHOD__, '3.3', 'rcp_update_discount' );
$result = rcp_update_discount( $discount_id, $args );
if ( is_wp_error( $result ) ) {
return false;
}
return $result;
}
/**
* Delete a discount code
*
* @deprecated 3.3 In favour of rcp_delete_discount()
* @see rcp_delete_discount()
*
* @param int $discount_id ID of the discount to delete.
*
* @access public
* @since 1.5
* @return void
*/
public function delete( $discount_id = 0 ) {
_deprecated_function( __METHOD__, '3.3', 'rcp_delete_discount' );
rcp_delete_discount( $discount_id );
}
/**
* Check if a discount is maxed out
*
* @deprecated 3.3 In favour of RCP_Discount::is_maxed_out()
* @see RCP_Discount::is_maxed_out()
*
* @param int $discount_id ID of the discount to check.
*
* @access public
* @since 1.5
* @return bool
*/
public function is_maxed_out( $discount_id = 0 ) {
_deprecated_function( __METHOD__, '3.3', 'RCP_Discount::is_maxed_out' );
$discount = rcp_get_discount( $discount_id );
if ( ! empty( $discount ) ) {
return $discount->is_maxed_out();
}
return false;
}
/**
* Check if a discount is expired
*
* @deprecated 3.3 In favour of RCP_Discount::is_expired()
* @see RCP_Discount::is_expired()
*
* @param int $discount_id ID of the discount to check.
*
* @access public
* @since 1.5
* @return bool
*/
public function is_expired( $discount_id = 0 ) {
_deprecated_function( __METHOD__, '3.3', 'RCP_Discount::is_expired' );
$discount = rcp_get_discount( $discount_id );
if ( ! empty( $discount ) ) {
return $discount->is_expired();
}
return false;
}
/**
* Add a discount to a user's history
*
* @deprecated 3.3 In favour of RCP_Discount::store_for_user()
* @see RCP_Discount::store_for_user()
*
* @param int $user_id ID of the user to add the discount to.
* @param string $discount_code Discount code to add.
*
* @access public
* @since 1.5
* @return void
*/
public function add_to_user( $user_id = 0, $discount_code = '' ) {
_deprecated_function( __METHOD__, '3.3', 'RCP_Discount::store_for_user' );
$discount = rcp_get_discount_by( 'code', $discount_code );
if ( empty( $discount ) ) {
return;
}
$discount->store_for_user( $user_id );
}
/**
* Remove a discount from a user's history
*
* @deprecated 3.3 In favour of RCP_Discount::remove_from_user()
* @see RCP_Discount::remove_from_user()
*
* @param int $user_id ID of the user to remove the discount from.
* @param string $discount_code Discount code to remove.
*
* @access public
* @since 2.8
* @return bool Whether or not the discount was removed.
*/
public function remove_from_user( $user_id, $discount_code = '' ) {
_deprecated_function( __METHOD__, '3.3', 'RCP_Discount::remove_from_user' );
$discount = rcp_get_discount_by( 'code', $discount_code );
if ( empty( $discount ) ) {
return false;
}
return $discount->remove_from_user( $user_id );
}
/**
* Check if a user has used a discount
*
* @deprecated 3.3 In favour of rcp_user_has_used_discount()
* @see rcp_user_has_used_discount()
*
* @param int $user_id ID of the user to check.
* @param string $discount_code Discount code to check.
*
* @access public
* @since 1.5
* @return bool
*/
public function user_has_used( $user_id = 0, $discount_code = '' ) {
_deprecated_function( __METHOD__, '3.3', 'rcp_user_has_used_discount' );
return rcp_user_has_used_discount( $user_id, $discount_code );
}
/**
* Format the discount code
*
* @deprecated 3.3 In favour of rcp_discount_sign_filter()
* @see rcp_discount_sign_filter()
*
* @param int|float $amount Discount amount.
* @param string $type Type of discount - either '%' or 'flat'.
*
* @access public
* @since 1.5
* @return string
*/
public function format_discount( $amount = '', $type = '' ) {
_deprecated_function( __METHOD__, '3.3', 'rcp_discount_sign_filter' );
return rcp_discount_sign_filter( $amount, $type );
}
/**
* Calculate the discounted price
*
* @deprecated 3.3 In favour of rcp_get_discounted_price()
* @see rcp_get_discounted_price()
*
* @param int|float $base_price Full price without the discount.
* @param int|float $discount_amount Amount of the discount code.
* @param string $type Type of discount - either '%' or 'flat'.
*
* @access public
* @since 1.5
* @return int|float
*/
public function calc_discounted_price( $base_price = '', $discount_amount = '', $type = '%' ) {
_deprecated_function( __METHOD__, '3.3', 'rcp_get_discounted_price' );
return rcp_get_discounted_price( $base_price, $discount_amount, $type, false );
}
/**
* Sanitizes the discount amount
*
* @deprecated 3.3 In favour of rcp_sanitize_discount_amount()
* @see rcp_sanitize_discount_amount()
*
* @param int|float $amount The discount amount.
* @param string $type The discount type - either '%' or 'flat'.
*
* @access public
* @since 2.4.9
* @return mixed|array|WP_Error
*/
public function format_amount( $amount, $type ) {
_deprecated_function( __METHOD__, '3.3', 'rcp_sanitize_discount_amount' );
return rcp_sanitize_discount_amount( $amount, $type );
}
}

View File

@@ -0,0 +1,156 @@
<?php
/**
* Export Members Class
*
* Export members to a CSV
*
* @package Restrict Content Pro
* @subpackage Export Class
* @copyright Copyright (c) 2020, Sandhills Development, LLC
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.5
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Class RCP_Members_Export
*
* @deprecated 3.4
*/
class RCP_Members_Export extends RCP_Export {
/**
* Our export type. Used for export-type specific filters / actions
*
* @access public
* @var string
* @since 1.5
*/
public $export_type = 'members';
/**
* Set the CSV columns
*
* @access public
* @since 1.5
* @return array
*/
public function csv_cols() {
$cols = array(
'id' => __( 'Membership ID', 'rcp' ),
'user_id' => __( 'User ID', 'rcp' ),
'user_login' => __( 'User Login', 'rcp' ),
'user_email' => __( 'User Email', 'rcp' ),
'first_name' => __( 'First Name', 'rcp' ),
'last_name' => __( 'Last Name', 'rcp' ),
'subscription' => __( 'Membership Level ID', 'rcp' ),
'membership_level_name' => __( 'Membership Level Name', 'rcp' ),
'subscription_key' => __( 'Subscription Key', 'rcp' ),
'created_date' => __( 'Created Date', 'rcp' ),
'expiration' => __( 'Expiration Date', 'rcp' ),
'status' => __( 'Status', 'rcp' ),
'times_billed' => __( 'Times Billed', 'rcp' ),
'discount_codes' => __( 'Discount Codes', 'rcp' ),
'gateway' => __( 'Gateway', 'rcp' ),
'gateway_customer_id' => __( 'Gateway Customer ID', 'rcp' ),
'profile_id' => __( 'Gateway Subscription ID', 'rcp' ),
'is_recurring' => __( 'Auto Renew', 'rcp' )
);
return $cols;
}
/**
* Get the data being exported
*
* @access public
* @since 1.5
* @return array
*/
public function get_data() {
global $wpdb;
$data = array();
$subscription = isset( $_POST['rcp-subscription'] ) ? absint( $_POST['rcp-subscription'] ) : null;
$status = isset( $_POST['rcp-status'] ) ? sanitize_text_field( $_POST['rcp-status'] ) : 'active';
$offset = isset( $_POST['rcp-offset'] ) ? absint( $_POST['rcp-offset'] ) : null;
$number = isset( $_POST['rcp-number'] ) ? absint( $_POST['rcp-number'] ) : null;
$args = array(
'status' => $status,
'number' => $number,
'offset' => $offset
);
if ( ! empty( $subscription ) ) {
$args['object_id'] = $subscription;
}
$memberships = rcp_get_memberships( $args );
if( $memberships ) :
foreach ( $memberships as $membership ) {
/**
* @var RCP_Membership $membership
*/
$member = new RCP_Member( $membership->get_user_id() ); // for backwards compatibility
$discounts = get_user_meta( $membership->get_user_id(), 'rcp_user_discounts', true );
if( ! empty( $discounts ) && is_array( $discounts ) && ! $discounts instanceof stdClass ) {
foreach( $discounts as $key => $code ) {
if( ! is_string( $code ) ) {
unset( $discounts[ $key ] );
}
}
$discounts = implode( ' ', $discounts );
}
$membership_data = array(
'id' => $membership->get_id(),
'user_id' => $membership->get_user_id(),
'user_login' => $member->user_login,
'user_email' => $member->user_email,
'first_name' => $member->first_name,
'last_name' => $member->last_name,
'subscription' => $membership->get_object_id(),
'membership_level_name' => $membership->get_membership_level_name(),
'subscription_key' => $membership->get_subscription_key(),
'created_date' => $membership->get_created_date( false ),
'expiration' => $membership->get_expiration_date( false ),
'status' => $membership->get_status(),
'times_billed' => $membership->get_times_billed(),
'discount_codes' => $discounts,
'gateway' => $membership->get_gateway(),
'gateway_customer_id' => $membership->get_gateway_customer_id(),
'profile_id' => $membership->get_gateway_subscription_id(),
'is_recurring' => $membership->is_recurring()
);
/**
* @deprecated 3.0 Use `rcp_export_memberships_get_data_row` instead.
*/
$membership_data = apply_filters( 'rcp_export_members_get_data_row', $membership_data, $member );
/**
* Filters the data row.
*
* @param array $membership_data Membership data for this row.
* @param RCP_Membership $membership Membership object.
*
* @since 3.0
*/
$data[] = apply_filters( 'rcp_export_memberships_get_data_row', $membership_data, $membership );
}
endif;
$data = apply_filters( 'rcp_export_get_data', $data );
$data = apply_filters( 'rcp_export_get_data_' . $this->export_type, $data );
return $data;
}
}

View File

@@ -0,0 +1,135 @@
<?php
/**
* Export Payments Class
*
* Export payment hsitory to a CSV
*
* @package Restrict Content Pro
* @subpackage Export Class
* @copyright Copyright (c) 2017, Pippin Williamson
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.5
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Class RCP_Payments_Export
*
* @deprecated 3.4
*/
class RCP_Payments_Export extends RCP_Export {
/**
* Our export type. Used for export-type specific filters / actions
*
* @access public
* @var string
* @since 1.5
*/
public $export_type = 'payments';
/**
* Set the CSV columns
*
* @access public
* @since 1.5
* @return array
*/
public function csv_cols() {
$cols = array(
'id' => __( 'ID', 'rcp' ),
'status' => __( 'Status', 'rcp' ),
'object_type' => __( 'Purchase Type', 'rcp' ),
'object_id' => __( 'Membership Level ID', 'rcp' ),
'subscription' => __( 'Membership Level Name', 'rcp' ),
'amount' => __( 'Total Amount', 'rcp' ),
'subtotal' => __( 'Subtotal', 'rcp' ),
'credits' => __( 'Credits', 'rcp' ),
'fees' => __( 'Fees', 'rcp' ),
'discount_amount' => __( 'Discount Amount', 'rcp' ),
'discount_code' => __( 'Discount Code', 'rcp' ),
'user_id' => __( 'User ID', 'rcp' ),
'user_login' => __( 'User Login', 'rcp' ),
'user_email' => __( 'User Email', 'rcp' ),
'customer_id' => __( 'Customer ID', 'rcp' ),
'membership_id' => __( 'Membership ID', 'rcp' ),
'payment_type' => __( 'Payment Type', 'rcp' ),
'gateway' => __( 'Gateway', 'rcp' ),
'subscription_key' => __( 'Subscription Key', 'rcp' ),
'transaction_id' => __( 'Transaction ID', 'rcp' ),
'transaction_type' => __( 'Transaction Type', 'rcp' ),
'date' => __( 'Date', 'rcp' )
);
return $cols;
}
/**
* Get the data being exported
*
* @access public
* @since 1.5
* @return array
*/
public function get_data() {
global $wpdb;
$data = array();
$args = array();
if( ! empty( $_POST['rcp-year'] ) ) {
$args['date'] = array();
$args['date']['year'] = absint( $_POST['rcp-year'] );
if( ! empty( $_POST['rcp-month'] ) ) {
$args['date']['month'] = absint( $_POST['rcp-month'] );
}
}
$args['number'] = 999999;
$rcp_db = new RCP_Payments;
$payments = $rcp_db->get_payments( $args );
foreach ( $payments as $payment ) {
$user = get_userdata( $payment->user_id );
$data[] = apply_filters( 'rcp_export_payments_get_data_row', array(
'id' => $payment->id,
'status' => $payment->status,
'object_type' => $payment->object_type,
'object_id' => $payment->object_id,
'subscription' => $payment->subscription,
'amount' => $payment->amount,
'subtotal' => $payment->subtotal,
'credits' => $payment->credits,
'fees' => $payment->fees,
'discount_amount' => $payment->discount_amount,
'discount_code' => $payment->discount_code,
'user_id' => $payment->user_id,
'user_login' => isset( $user->user_login ) ? $user->user_login : '',
'user_email' => isset( $user->user_email ) ? $user->user_email : '',
'customer_id' => ! empty( $payment->customer_id ) ? $payment->customer_id : '',
'membership_id' => ! empty( $payment->membership_id ) ? $payment->membership_id : '',
'payment_type' => $payment->payment_type,
'gateway' => $payment->gateway,
'subscription_key' => $payment->subscription_key,
'transaction_id' => $payment->transaction_id,
'transaction_type' => ! empty( $payment->transaction_type ) ? $payment->transaction_type : '',
'date' => $payment->date
), $payment );
}
$data = apply_filters( 'rcp_export_get_data', $data );
$data = apply_filters( 'rcp_export_get_data_' . $this->export_type, $data );
return $data;
}
}

View File

@@ -0,0 +1,353 @@
<?php
/**
* Class for logging events and errors
*
* @deprecated 2.9 In favor of new RCP_Logging class.
*
* @package WP Logging Class
* @copyright Copyright (c) 2012, Pippin Williamson
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*/
class WP_Logging {
/**
* Class constructor.
*
* @since 1.0
*
* @access public
* @return void
*/
function __construct() {
// create the log post type
add_action( 'init', array( $this, 'register_post_type' ), -1 );
// create types taxonomy and default types
add_action( 'init', array( $this, 'register_taxonomy' ), -1 );
}
/**
* Log types
*
* Sets up the default log types and allows for new ones to be created
*
* @access private
* @since 1.0
*
* @return array
*/
public static function log_types() {
$terms = array(
'error', 'event'
);
return apply_filters( 'wp_log_types', $terms );
}
/**
* Registers the wp_log Post Type
*
* @access public
* @since 1.0
*
* @uses register_post_type()
*
* @return void
*/
public function register_post_type() {
/* logs post type */
$log_args = array(
'labels' => array( 'name' => __( 'Logs', 'rcp' ) ),
'public' => false,
'query_var' => false,
'rewrite' => false,
'capability_type' => 'post',
'supports' => array( 'title', 'editor' ),
'can_export' => false
);
register_post_type( 'wp_log', $log_args );
}
/**
* Registers the Type Taxonomy
*
* The Type taxonomy is used to determine the type of log entry
*
* @access public
* @since 1.0
*
* @uses register_taxonomy()
*
* @return void
*/
public function register_taxonomy() {
register_taxonomy( 'wp_log_type', 'wp_log' );
}
/**
* Check if a log type is valid
*
* Checks to see if the specified type is in the registered list of types
*
* @access private
* @since 1.0
*
*
* @return array
*/
public static function valid_type( $type ) {
return in_array( $type, self::log_types() );
}
/**
* Create new log entry
*
* This is just a simple and fast way to log something. Use self::insert_log()
* if you need to store custom meta data
*
* @access private
* @since 1.0
*
* @uses self::insert_log()
*
* @return int The ID of the new log entry
*/
public static function add( $title = '', $message = '', $parent = 0, $type = null ) {
$log_data = array(
'post_title' => $title,
'post_content' => $message,
'post_parent' => $parent,
'log_type' => $type
);
return self::insert_log( $log_data );
}
/**
* Stores a log entry
*
* @access private
* @since 1.0
*
* @uses wp_parse_args()
* @uses wp_insert_post()
* @uses update_post_meta()
* @uses wp_set_object_terms()
* @uses sanitize_key()
*
* @return int The ID of the newly created log item
*/
public static function insert_log( $log_data = array(), $log_meta = array() ) {
$defaults = array(
'post_type' => 'wp_log',
'post_status' => 'publish',
'post_parent' => 0,
'post_content'=> '',
'log_type' => false
);
$args = wp_parse_args( $log_data, $defaults );
do_action( 'wp_pre_insert_log' );
// store the log entry
$log_id = wp_insert_post( $args );
// set the log type, if any
if( $log_data['log_type'] && self::valid_type( $log_data['log_type'] ) ) {
wp_set_object_terms( $log_id, $log_data['log_type'], 'wp_log_type', false );
}
// set log meta, if any
if( $log_id && ! empty( $log_meta ) ) {
foreach( (array) $log_meta as $key => $meta ) {
update_post_meta( $log_id, '_wp_log_' . sanitize_key( $key ), $meta );
}
}
do_action( 'wp_post_insert_log', $log_id );
return $log_id;
}
/**
* Update and existing log item
*
* @access private
* @since 1.0
*
* @uses wp_parse_args()
* @uses wp_update_post()
* @uses update_post_meta()
*
* @return bool True if successful, false otherwise
*/
public static function update_log( $log_data = array(), $log_meta = array() ) {
do_action( 'wp_pre_update_log', $log_id );
$defaults = array(
'post_type' => 'wp_log',
'post_status' => 'publish',
'post_parent' => 0
);
$args = wp_parse_args( $log_data, $defaults );
// store the log entry
$log_id = wp_update_post( $args );
if( $log_id && ! empty( $log_meta ) ) {
foreach( (array) $log_meta as $key => $meta ) {
if( ! empty( $meta ) )
update_post_meta( $log_id, '_wp_log_' . sanitize_key( $key ), $meta );
}
}
do_action( 'wp_post_update_log', $log_id );
}
/**
* Easily retrieves log items for a particular object ID
*
* @access private
* @since 1.0
*
* @uses self::get_connected_logs()
*
* @return array
*/
public static function get_logs( $object_id = 0, $type = null, $paged = null ) {
return self::get_connected_logs( array( 'post_parent' => $object_id, 'paged' => $paged, 'log_type' => $type ) );
}
/**
* Retrieve all connected logs
*
* Used for retrieving logs related to particular items, such as a specific purchase.
*
* @access private
* @since 1.0
*
* @uses wp_parse_args()
* @uses get_posts()
* @uses get_query_var()
* @uses self::valid_type()
*
* @return array / false
*/
public static function get_connected_logs( $args = array() ) {
$defaults = array(
'post_parent' => 0,
'post_type' => 'wp_log',
'posts_per_page' => 10,
'post_status' => 'publish',
'paged' => get_query_var( 'paged' ),
'log_type' => false
);
$query_args = wp_parse_args( $args, $defaults );
if( $query_args['log_type'] && self::valid_type( $query_args['log_type'] ) ) {
$query_args['tax_query'] = array(
array(
'taxonomy' => 'wp_log_type',
'field' => 'slug',
'terms' => $query_args['log_type']
)
);
}
$logs = get_posts( $query_args );
if( $logs )
return $logs;
// no logs found
return false;
}
/**
* Retrieves number of log entries connected to particular object ID
*
* @access private
* @since 1.0
*
* @uses WP_Query()
* @uses self::valid_type()
*
* @return int
*/
public static function get_log_count( $object_id = 0, $type = null, $meta_query = null ) {
$query_args = array(
'post_parent' => $object_id,
'post_type' => 'wp_log',
'posts_per_page'=> -1,
'post_status' => 'publish'
);
if( ! empty( $type ) && self::valid_type( $type ) ) {
$query_args['tax_query'] = array(
array(
'taxonomy' => 'wp_log_type',
'field' => 'slug',
'terms' => $type
)
);
}
if( ! empty( $meta_query ) ) {
$query_args['meta_query'] = $meta_query;
}
$logs = new WP_Query( $query_args );
return (int) $logs->post_count;
}
}
$GLOBALS['wp_logs'] = new WP_Logging();

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
<?php // Silence is golden.

View File

@@ -0,0 +1,70 @@
<?php
/**
* Membership Level Functions
*
* Functions for getting non-member specific info about membership levels.
*
* @package Restrict Content Pro
* @subpackage Subscription Functions
* @copyright Copyright (c) 2017, Restrict Content Pro
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*/
/**
* Gets an array of all available membership levels
*
* @deprecated 3.4 In favour of `rcp_get_membership_levels()`
* @see rcp_get_membership_levels()
*
* @param string $status The status of membership levels we want to retrieve: active, inactive, or all
*
* @return RCP\Membership_Level[]|false Array of objects if levels exist, false otherwise
*/
function rcp_get_subscription_levels( $status = 'all' ) {
_deprecated_function( __FUNCTION__, '3.4', 'rcp_get_membership_levels' );
$args = array(
'number' => 999 // This function used to retrieve all results.
);
if ( in_array( $status, array( 'active', 'inactive' ) ) ) {
$args['status'] = $status;
}
return rcp_get_membership_levels( $args );
}
/**
* Gets all details of a specified membership level
*
* @deprecated 3.4 In favour of `rcp_get_membership_level()`
* @see rcp_get_membership_level()
*
* @param int $id The ID of the membership level to retrieve.
*
* @return object|false Object on success, false otherwise.
*/
function rcp_get_subscription_details( $id ) {
_deprecated_function( __FUNCTION__, '3.4', 'rcp_get_membership_level' );
return rcp_get_membership_level( $id );
}
/**
* Gets all details of a specific membership level
*
* @deprecated 3.4 In favour of `rcp_get_membership_level_by()`
* @see rcp_get_membership_level_by()
*
* @param string $name The name of the membership level to retrieve.
*
* @return object|false Object on success, false otherwise.
*/
function rcp_get_subscription_details_by_name( $name ) {
_deprecated_function( __FUNCTION__, '3.4', 'rcp_get_membership_level_by' );
return rcp_get_membership_level_by( 'name', $name );
}