DSWallets
Interfaces, Classes, Traits and Enums
Table of Contents
- db_paywall_cb() : mixed
- shortcode_subscription_extend() : string
- The `[wallets_paywall_extend]` shortcode allows users to pay and subscribe or extend their subscriptions.
- shortcode_subscription_expires() : string
- The `[wallets_paywall_expires]` shortcode displays the date/time on which the specified subscription will expire for the current user.
- shortcode_subscription_remaining() : string
- The `[wallets_paywall_remaining]` shortcode displays the time remaining for the user on the specified subscription.
- shortcode_subscription_if() : string
- shortcode_subscription_if_not() : string
- load_subscriptions() : array<string|int, mixed>
- Takes an array of subscription post_ids and instantiates them into an array of Subscription objects.
- get_subscription_ids() : array<string|int, mixed>
- paywall_interval_text() : string
- Convert a duration in seconds to human readable.
- get_sub_transaction_ids_by_tag_after_time() : array<string|int, mixed>
- Gets subscription transactions with a specific currency, tag, and created after a specific timestamp.
Functions
db_paywall_cb()
db_paywall_cb() : mixed
Return values
mixed —shortcode_subscription_extend()
The `[wallets_paywall_extend]` shortcode allows users to pay and subscribe or extend their subscriptions.
shortcode_subscription_extend(array<string|int, mixed> $atts, string $content, string $tag) : string
The shortcode displays a UI that lists the possible subscriptions and currencies.
When a subscription is selected, the user is informed as to the status of their subscription, and the price of extending this subscription using the selected currency.
When a currency is selected, the user is displayed their available balance on this currency, as well as the price of extending the selected subscription using this currency.
If the available balance is not sufficient to pay for extending the selected subscription, then it is shown in red and the payment button is disabled.
Parameters
- $atts : array<string|int, mixed>
-
-
[sub_id]
If specified, this is thepost_id
of the subscription that should be selected by default. -
[text_pay]
Text displayed on button for subscriptions that do expire. Default:Pay %1$s and extend %2$s by %3$d %4$s
-
[text_pay_once]
Text displayed on button for subscriptions that do not expire. Default:Pay %1$s and subscribe as %2$s
-
[template]
Specialized template part. If you set template="foo", it will load thetemplates/extend-foo.php
file.
-
- $content : string
-
No content as this shortcode is not nested.
- $tag : string
-
Equal to
wallets_paywall_extend
Return values
string —HTML
shortcode_subscription_expires()
The `[wallets_paywall_expires]` shortcode displays the date/time on which the specified subscription will expire for the current user.
shortcode_subscription_expires(array<string|int, mixed> $atts, string $content, string $tag) : string
The value updates dynamically by polling the WP-REST API.
Alternative templates:
template="timestamp"
displays the expiry time in UNIX timestamp format, but only if there is one.
Parameters
- $atts : array<string|int, mixed>
-
-
[sub_id]
If specified, this is thepost_id
of the subscription that should be selected by default. -
[template]
Specialized template part. If you set template="timestamp", it will load thetemplates/expires-timestamp.php
file.
-
- $content : string
-
No content as this shortcode is not nested.
- $tag : string
-
Equal to
wallets_paywall_expires
Return values
string —HTML
shortcode_subscription_remaining()
The `[wallets_paywall_remaining]` shortcode displays the time remaining for the user on the specified subscription.
shortcode_subscription_remaining(array<string|int, mixed> $atts, string $content, string $tag) : string
Parameters
- $atts : array<string|int, mixed>
-
-
[sub_id]
If specified, this is thepost_id
of the subscription that should be selected by default. -
[template]
Specialized template part. If you set template="foo", it will load thetemplates/remaining-foo.php
file. -
[details]
If set to an integer, this many time units will be shown, starting from the largest. The remaining units will be omitted.
-
- $content : string
-
No content as this shortcode is not nested.
- $tag : string
-
Equal to
wallets_paywall_remaining
Return values
string —HTML
shortcode_subscription_if()
shortcode_subscription_if(mixed $atts, string $content, string $tag) : string
Parameters
- $atts : mixed
- $content : string
- $tag : string
Return values
string —shortcode_subscription_if_not()
shortcode_subscription_if_not(mixed $atts, string $content, string $tag) : string
Parameters
- $atts : mixed
- $content : string
- $tag : string
Return values
string —load_subscriptions()
Takes an array of subscription post_ids and instantiates them into an array of Subscription objects.
load_subscriptions(array<string|int, mixed> $post_ids) : array<string|int, mixed>
If a subscription cannot be loaded due to Subscription::load() throwing (i.e. bad DB data), then the error will be logged and the rest of the subscriptions will be loaded.
Parameters
- $post_ids : array<string|int, mixed>
-
The array of integer post_ids
Return values
array<string|int, mixed> —The array of Subscription objects.
get_subscription_ids()
get_subscription_ids() : array<string|int, mixed>
Return values
array<string|int, mixed> —paywall_interval_text()
Convert a duration in seconds to human readable.
paywall_interval_text(int $seconds[, int $detail = 2 ]) : string
Parameters
- $seconds : int
-
The duration.
- $detail : int = 2
-
How many non-zero units to display, starting to count from larger units first. 0 means show all.
Return values
string —The human-readable text, ready to display.
get_sub_transaction_ids_by_tag_after_time()
Gets subscription transactions with a specific currency, tag, and created after a specific timestamp.
get_sub_transaction_ids_by_tag_after_time(int $sub_id, string $after) : array<string|int, mixed>
Useful for the admin dashboard stats.
Parameters
- $sub_id : int
- $after : string
-
Example: -1 days, -7 days, -1 months.
Return values
array<string|int, mixed> —The transactions found.