Documentation

Puzzle_Anywhere
in package

The base PuzzleAnywhere class. This handles shortcode interpolation, page re/generation and destruction, and has a variety of convenience functions.

Tags
todo

Move model-specific requests to their specific classes. For example, get_providers to PA_Provider.

Table of Contents

MENUS  = ['PuzzleAnywhere Account', 'PuzzleAnywhere Primary', 'PuzzleAnywhere Secondary Nav']
Additional PuzzleAnywhere custom menus.
PAGES  = ['subscribe' => ['shortcode' => 'subscribe', 'title' => 'Subscribe', 'content' => '[subscribe]', 'menu' => 'PuzzleAnywhere Primary'], 'featured_single_subscriptions' => ['shortcode' => 'featured_single_subscriptions', 'title' => 'Single Subscriptions', 'content' => '[featured_single_subscriptions]'], 'featured_recurring_subscriptions' => ['shortcode' => 'featured_recurring_subscriptions', 'title' => 'Recurring Subscriptions', 'content' => '[featured_recurring_subscriptions]'], 'puzzles_by_year' => ['shortcode' => 'puzzles_by_year', 'title' => 'Puzzles By Year', 'content' => '[puzzles_by_year]', 'menu' => 'PuzzleAnywhere Primary'], 'puzzles_by_provider' => ['shortcode' => 'puzzles_by_provider', 'title' => 'Puzzles By Team', 'content' => '[puzzles_by_provider]', 'menu' => 'PuzzleAnywhere Primary'], 'puzzle' => ['shortcode' => 'puzzle', 'title' => 'Puzzle', 'content' => '[puzzle]', 'meta' => array(array('name' => 'hide-header-title', 'value' => 'yes'))], 'download_puzzle' => ['shortcode' => 'download_puzzle', 'title' => 'Download Puzzle', 'content' => '[download_puzzle]'], 'buy_puzzles' => ['shortcode' => 'buy_puzzles', 'title' => 'Buy Individual Puzzles', 'content' => '[buy_puzzles]', 'menu' => 'PuzzleAnywhere Primary'], 'buy_puzzle_bundles' => ['shortcode' => 'buy_puzzle_bundles', 'title' => 'Archived Bundles', 'content' => '[buy_puzzle_bundles]', 'menu' => 'PuzzleAnywhere Primary'], 'tip_jar' => ['shortcode' => 'tip_jar', 'title' => 'Tip Jar', 'content' => '[tip_jar]', 'menu' => 'PuzzleAnywhere Primary'], 'faq' => ['title' => 'Learn More', 'view' => 'faq', 'menu' => 'PuzzleAnywhere Primary'], 'resend_puzzle' => ['title' => 'Resend Puzzle', 'view' => 'resend-puzzle', 'menu' => 'PuzzleAnywhere Secondary Nav'], 'purchase_renewal' => ['shortcode' => 'purchase_renewal', 'title' => 'Purchase Renewal', 'content' => '[purchase_renewal]'], 'renew_subscription' => ['title' => 'Renew Subscription', 'view' => 'renew-subscription', 'menu' => 'PuzzleAnywhere Secondary Nav'], 'newsletter_confirmation' => ['title' => 'Confirm Newsletter Subscription', 'shortcode' => 'newsletter_confirmation', 'content' => '[newsletter_confirmation]'], 'newsletter_unsubscribe' => ['title' => 'Unsubscribe From Newsletter', 'shortcode' => 'unsubscribe_newsletter', 'content' => '[unsubscribe_newsletter]'], 'manage_newsletters' => ['title' => 'Manage Emails', 'shortcode' => 'manage_newsletters', 'content' => '[manage_newsletters]'], 'privacy_policy' => ['title' => 'Privacy Policy', 'view' => 'privacy-policy', 'menu' => 'PuzzleAnywhere Secondary Nav'], 'contact' => ['title' => 'Contact Us', 'view' => 'contact', 'menu' => 'PuzzleAnywhere Secondary Nav'], 'sample_puzzles' => ['title' => 'Sample Puzzles', 'view' => 'sample-puzzles', 'menu' => 'PuzzleAnywhere Secondary Nav'], 'supported_apps' => ['title' => 'Supported Apps', 'view' => 'supported-apps', 'menu' => 'PuzzleAnywhere Secondary Nav'], 'reset_user_password' => ['title' => 'Reset Password', 'view' => 'reset-password'], 'free_trial' => ['content' => '[free_trial]', 'shortcode' => 'free_trial', 'title' => 'Free Trial'], 'execute_purchase' => ['shortcode' => 'execute_purchase', 'title' => 'Purchase Completed', 'content' => '[execute_purchase]', 'meta' => array(array('name' => 'hide-header-title', 'value' => 'yes'))], 'download_purchase' => ['shortcode' => 'download_purchase', 'title' => 'Download Your Purchase', 'content' => '[download_purchase]'], 'validate_free_trial' => ['shortcode' => 'validate_free_trial', 'content' => '[validate_free_trial]', 'title' => 'Free Trial Confirmation'], 'log_in' => ['shortcode' => 'log_in', 'title' => 'Log In', 'content' => '[log_in]', 'menu' => 'PuzzleAnywhere Account'], 'log_out' => ['shortcode' => 'log_out', 'title' => 'Log Out', 'content' => '[log_out]', 'menu' => 'PuzzleAnywhere Account'], 'account' => ['shortcode' => 'account', 'content' => '[account]', 'title' => 'Your Account', 'menu' => 'PuzzleAnywhere Primary'], 'enable_account' => ['title' => 'Enable Account', 'view' => 'enable-account'], 'about_us' => ['shortcode' => 'about_us', 'content' => '[about_us]', 'title' => 'About Us', 'view' => 'about-us'], 'providers' => ['shortcode' => 'featured_providers', 'content' => '[featured_providers]', 'title' => 'Teams', 'view' => 'featured-providers'], 'provider' => ['shortcode' => 'provider', 'content' => '[provider]', 'title' => 'Team', 'view' => 'provider'], 'authors' => ['shortcode' => 'authors', 'content' => '[authors]', 'title' => 'Authors', 'view' => 'authors'], 'authors-summary' => ['shortcode' => 'authors_summary', 'content' => '[authors_summary]', 'title' => 'Author Summaries', 'view' => 'authors-summary'], 'staff' => ['shortcode' => 'staff', 'content' => '[staff]', 'title' => 'Staff', 'view' => 'featured-staff'], 'home' => ['title' => 'Home', 'view' => 'default-home']]
Page items should be ordered in the default menu list order.
VIEW_SHORTCODES  = ['buy_puzzle_bundles', 'puzzle_years_picker', 'puzzle_request_form', 'renew_subscription_request_form', 'request_password_reset', 'reset_password_form', 'puzzle', 'puzzles', 'purchase_renewal', 'download_puzzle', 'sample_puzzles', 'validate_free_trial', 'newsletter_confirmation', 'execute_purchase', 'manage_newsletters', 'authors', 'authors_summary', 'featured_providers', 'provider', 'staff', 'featured_single_subscriptions', 'featured_recurring_subscriptions']
Views for shortcodes.
$api_errors  : array<string|int, string>
A collection of returned errors from the API server.
$api_result  : string
The success string returned from the API server.
$date_format  : string
Standard display date format for strftime.
$datetime_format  : string
Standard display datetime format for strftime.
$cache_expiry  : int
Cache expiry in seconds.
add_account_nav()  : string
Adds account navigation.
assemble_url()  : string
Convenience method to assemble an accessible URL.
create_page()  : null
Create PA WordPress page.
create_pages()  : null
Generate PA WordPress pages.
download_puzzle_attachment_url()  : string
Get the download puzzle attachment URL.
download_puzzle_url()  : string
Get the download puzzle URL.
empty_cache()  : mixed
Empties the existing server-based cache.
free_trial_verification_url()  : string
An absolute URL path to sign up for a free trial.
get_account_puzzle_year_uri()  : int
A convenience function to assemble the puzzle year URL for user accounts.
get_default_profile_icon()  : string
Get the default user profile image url.
get_featured_authors()  : array<string|int, PA_User>
Retrieves all featured authors.
get_featured_free_trials()  : array<string|int, array<string|int, mixed>>
Retrieves featured free trials from the API server.
get_featured_providers()  : array<string|int, PA_Provider>
Get featured providers.
get_featured_recurring_subscriptions()  : array<string|int, PA_PurchasableItem>
Retrieves featured recurring subscriptions from the API server.
get_featured_single_subscriptions()  : array<string|int, PA_PurchasableItem>
Retrieves featured one-time subscriptions from the API server.
get_featured_staff()  : array<string|int, PA_User>
Retrieves all featured staff.
get_featured_subscriptions()  : array<string|int, PA_PurchasableItem>
Retrieves featured subscriptions from the API server.
get_provider_by_slug()  : PA_Provider
Get provider by provider slug.
get_providers()  : array<string|int, mixed>
Get all available providers as PA_Provider JSON data.
get_providers_with_puzzles_by_year()  : array<string|int, PA_Provider>
Get providers with puzzles by year.
get_purchase()  : array<string|int, mixed>
Get a specific PA_Purchse record JSON data.
get_puzzle()  : PA_Puzzle|null
Get a puzzle based on puzzle ID.
get_puzzle_archive_years()  : array<string|int, int>
A convenience function to get a list of puzzle archive years.
get_puzzle_attachments()  : PA_Puzzle|null
Get puzzle attachments via PA_Puzzle based on puzzle ID.
get_puzzle_bundles()  : array<string|int, array<string|int, mixed>>
A convenience function to get a list of available puzzle bundles.
get_puzzle_by_date()  : PA_Puzzle|null
Get a puzzle based on date.
get_puzzle_by_date_json()  : PA_Puzzle|null
Get a puzzle based on date.
get_puzzle_json()  : array<string|int, mixed>
A convenience function to get a puzzle JSON object.
get_puzzle_year_uri()  : int
A convenience function to assemble the puzzle year URL.
get_puzzles_by_year()  : array<string|int, PA_Puzzle>
Retrieves a list of summarized PA_Puzzle items published in a specific year from the API server.
get_renewable_subscriptions()  : array<string|int, PA_PurchasableItem>
Get a user's renewal subscriptions based on an user-associated token.
get_sample_puzzles()  : array<string|int, array<string|int, mixed>>
A convenience function to get a list of sample puzzles.
get_subscriber_puzzle_attachments()  : PA_Puzzle
Get subscriber puzzles with attachment info.
get_support_email()  : string
Retrieve the assigned support email.
get_support_email_link()  : string
Retrieve the assigned support email mailto link.
get_tip_jar()  : array<string|int, mixed>
Get tip jar PA_PurchasableItem JSON data.
get_year_from_uri()  : int
A convenience function to retrieve the year from URI.
init()  : null
Initialize the class.
jsonapi_to_data()  : array<string|int, array<string|int, mixed>>
Converts returned JSON-API response to an array.
local_subscribe_url()  : string
Get the subscribe page permalink.
newsletter_signup_url()  : string
An absolute URL path to sign up for the main newsletter.
page_permalink()  : string
Gets the WordPress page permalink absolute URL.
paypal_subscribe_url()  : string
Get the PayPal subscribe URL.
post_free_trial()  : array<string|int, mixed>
Send a free trial request to the API server.
post_newsletter_signup()  : array<string|int, mixed>
Sign up to subscribe to the default newsletter to the API server.
post_password_reset()  : array<string|int, mixed>
Confirm a password reset request.
post_puzzle_request()  : array<string|int, mixed>
Send a resent puzzle request to the API server.
post_request_password_reset()  : object
Send a password reset request to the API server.
post_reset_password_confirmation()  : array<string|int, mixed>
Reset a user's password.
post_subscription_renewal_request()  : array<string|int, mixed>
Send a subscription renewal request to the API server.
post_trial_subscription_confirmation()  : PA_Subscription
Confirm a trial subscription signup via the API server.
purchase_url()  : string
Get the purchase URL for individual puzzles.
puzzle_info_url()  : string
Get the subscribe page permalink.
puzzles_by_year_uri()  : string
An URI to view a list of puzzles by year.
puzzles_by_year_uri_template()  : string
Assembles a relative puzzles by year URL template meant to be used in in tandem with `sprintf`.
puzzles_by_year_url()  : string
An absolute URL path to view a list of puzzles by year.
puzzles_by_year_url_template()  : string
Assembles an absolute puzzles by year URL template meant to be used in in tandem with `sprintf`.
rebuild_pages()  : null
Rebuild PA pages.
renewable_subscriptions_url()  : string
Get the renewable subscriptions page absolute URL.
request_password_reset_url()  : string
Get the request password reset page absolute URL.
resend_puzzle_url()  : string
Get the resend puzzle page absolute URL.
reset_password_url()  : string
Get the reset password page absolute URL.
resp_errored()  : bool
Denotes whether the latest response has errored.
resp_successful()  : bool
Denotes whether the latest response has been successful.
show_errors()  : null
Echoes caught errors via `self::$api_errors`.
show_errors_in_view()  : null
Echoes caught errors via `self::$api_errors`.
show_result()  : null
Convenience function to display the results and errors of a request.
status_display()  : string
Formats a passed returned request status to be humanized for display.
subscription_renewal_request_url()  : string
Get the subscription renewal request page absolute URL.
view()  : string
Renders an HTML view from a PHP view template.
get_cache()  : object
Returns a cached value using WP's `Transient` API based on the requested path.
get_cache_key()  : string
Get the cache key for the requested path.
get_cache_keys()  : array<string|int, string>
Get all stored cache keys for easier cache viewing/deletion.
get_host()  : string
Retrieves the host option from the plugin.
reset_errors()  : null
Resets class-based errors.
store_cache_key()  : mixed
Keeps a running tab of cached items.
write_cache()  : null
Writes a cache using WP's `Transient` API.

Constants

MENUS

Additional PuzzleAnywhere custom menus.

public mixed MENUS = ['PuzzleAnywhere Account', 'PuzzleAnywhere Primary', 'PuzzleAnywhere Secondary Nav']

PAGES

Page items should be ordered in the default menu list order.

public array<string|int, array<string|int, mixed>> PAGES = ['subscribe' => ['shortcode' => 'subscribe', 'title' => 'Subscribe', 'content' => '[subscribe]', 'menu' => 'PuzzleAnywhere Primary'], 'featured_single_subscriptions' => ['shortcode' => 'featured_single_subscriptions', 'title' => 'Single Subscriptions', 'content' => '[featured_single_subscriptions]'], 'featured_recurring_subscriptions' => ['shortcode' => 'featured_recurring_subscriptions', 'title' => 'Recurring Subscriptions', 'content' => '[featured_recurring_subscriptions]'], 'puzzles_by_year' => ['shortcode' => 'puzzles_by_year', 'title' => 'Puzzles By Year', 'content' => '[puzzles_by_year]', 'menu' => 'PuzzleAnywhere Primary'], 'puzzles_by_provider' => ['shortcode' => 'puzzles_by_provider', 'title' => 'Puzzles By Team', 'content' => '[puzzles_by_provider]', 'menu' => 'PuzzleAnywhere Primary'], 'puzzle' => ['shortcode' => 'puzzle', 'title' => 'Puzzle', 'content' => '[puzzle]', 'meta' => array(array('name' => 'hide-header-title', 'value' => 'yes'))], 'download_puzzle' => ['shortcode' => 'download_puzzle', 'title' => 'Download Puzzle', 'content' => '[download_puzzle]'], 'buy_puzzles' => ['shortcode' => 'buy_puzzles', 'title' => 'Buy Individual Puzzles', 'content' => '[buy_puzzles]', 'menu' => 'PuzzleAnywhere Primary'], 'buy_puzzle_bundles' => ['shortcode' => 'buy_puzzle_bundles', 'title' => 'Archived Bundles', 'content' => '[buy_puzzle_bundles]', 'menu' => 'PuzzleAnywhere Primary'], 'tip_jar' => ['shortcode' => 'tip_jar', 'title' => 'Tip Jar', 'content' => '[tip_jar]', 'menu' => 'PuzzleAnywhere Primary'], 'faq' => ['title' => 'Learn More', 'view' => 'faq', 'menu' => 'PuzzleAnywhere Primary'], 'resend_puzzle' => ['title' => 'Resend Puzzle', 'view' => 'resend-puzzle', 'menu' => 'PuzzleAnywhere Secondary Nav'], 'purchase_renewal' => ['shortcode' => 'purchase_renewal', 'title' => 'Purchase Renewal', 'content' => '[purchase_renewal]'], 'renew_subscription' => ['title' => 'Renew Subscription', 'view' => 'renew-subscription', 'menu' => 'PuzzleAnywhere Secondary Nav'], 'newsletter_confirmation' => ['title' => 'Confirm Newsletter Subscription', 'shortcode' => 'newsletter_confirmation', 'content' => '[newsletter_confirmation]'], 'newsletter_unsubscribe' => ['title' => 'Unsubscribe From Newsletter', 'shortcode' => 'unsubscribe_newsletter', 'content' => '[unsubscribe_newsletter]'], 'manage_newsletters' => ['title' => 'Manage Emails', 'shortcode' => 'manage_newsletters', 'content' => '[manage_newsletters]'], 'privacy_policy' => ['title' => 'Privacy Policy', 'view' => 'privacy-policy', 'menu' => 'PuzzleAnywhere Secondary Nav'], 'contact' => ['title' => 'Contact Us', 'view' => 'contact', 'menu' => 'PuzzleAnywhere Secondary Nav'], 'sample_puzzles' => ['title' => 'Sample Puzzles', 'view' => 'sample-puzzles', 'menu' => 'PuzzleAnywhere Secondary Nav'], 'supported_apps' => ['title' => 'Supported Apps', 'view' => 'supported-apps', 'menu' => 'PuzzleAnywhere Secondary Nav'], 'reset_user_password' => ['title' => 'Reset Password', 'view' => 'reset-password'], 'free_trial' => ['content' => '[free_trial]', 'shortcode' => 'free_trial', 'title' => 'Free Trial'], 'execute_purchase' => ['shortcode' => 'execute_purchase', 'title' => 'Purchase Completed', 'content' => '[execute_purchase]', 'meta' => array(array('name' => 'hide-header-title', 'value' => 'yes'))], 'download_purchase' => ['shortcode' => 'download_purchase', 'title' => 'Download Your Purchase', 'content' => '[download_purchase]'], 'validate_free_trial' => ['shortcode' => 'validate_free_trial', 'content' => '[validate_free_trial]', 'title' => 'Free Trial Confirmation'], 'log_in' => ['shortcode' => 'log_in', 'title' => 'Log In', 'content' => '[log_in]', 'menu' => 'PuzzleAnywhere Account'], 'log_out' => ['shortcode' => 'log_out', 'title' => 'Log Out', 'content' => '[log_out]', 'menu' => 'PuzzleAnywhere Account'], 'account' => ['shortcode' => 'account', 'content' => '[account]', 'title' => 'Your Account', 'menu' => 'PuzzleAnywhere Primary'], 'enable_account' => ['title' => 'Enable Account', 'view' => 'enable-account'], 'about_us' => ['shortcode' => 'about_us', 'content' => '[about_us]', 'title' => 'About Us', 'view' => 'about-us'], 'providers' => ['shortcode' => 'featured_providers', 'content' => '[featured_providers]', 'title' => 'Teams', 'view' => 'featured-providers'], 'provider' => ['shortcode' => 'provider', 'content' => '[provider]', 'title' => 'Team', 'view' => 'provider'], 'authors' => ['shortcode' => 'authors', 'content' => '[authors]', 'title' => 'Authors', 'view' => 'authors'], 'authors-summary' => ['shortcode' => 'authors_summary', 'content' => '[authors_summary]', 'title' => 'Author Summaries', 'view' => 'authors-summary'], 'staff' => ['shortcode' => 'staff', 'content' => '[staff]', 'title' => 'Staff', 'view' => 'featured-staff'], 'home' => ['title' => 'Home', 'view' => 'default-home']]

To create a page with dynamic content, do the following:

  1. Create a PAGES array item with a shortcode, and assign content to be the [shortcode].
  2. Add the shortcode to VIEW_SHORTCODES.
  3. Add the shortcode function to sai-puzzleanywhere.php. See subscribe for an example.

NOTE: Pages that use a view -must not rely on dynamic rendering-. In those cases, simply add the view via a shortcode, where the view is rendered via a shortcode function.

The default PuzzleAnywhere pages to be generated.

Tags
see
subscribe
see

readme.txt for a more readable breakdown of pages and shortcodes.

VIEW_SHORTCODES

Views for shortcodes.

public mixed VIEW_SHORTCODES = ['buy_puzzle_bundles', 'puzzle_years_picker', 'puzzle_request_form', 'renew_subscription_request_form', 'request_password_reset', 'reset_password_form', 'puzzle', 'puzzles', 'purchase_renewal', 'download_puzzle', 'sample_puzzles', 'validate_free_trial', 'newsletter_confirmation', 'execute_purchase', 'manage_newsletters', 'authors', 'authors_summary', 'featured_providers', 'provider', 'staff', 'featured_single_subscriptions', 'featured_recurring_subscriptions']
Tags
see

readme.txt for a more readable breakdown of pages and shortcodes.

Properties

$api_errors

A collection of returned errors from the API server.

public static array<string|int, string> $api_errors = []

An array of returned errors from the API server.

$api_result

The success string returned from the API server.

public static string $api_result = ''

The success string returned from the API server.

$date_format

Standard display date format for strftime.

public static string $date_format = 'F j, Y'

Standard display date format for strftime.

$datetime_format

Standard display datetime format for strftime.

public static string $datetime_format = 'M j, Y g:i:s A'

Standard display date format for strftime.

$cache_expiry

Cache expiry in seconds.

private static int $cache_expiry = 300

Cache expiry in seconds.

Methods

add_account_nav()

Adds account navigation.

public static add_account_nav(string $content) : string
Parameters
$content : string

Additional account navigation content.

Return values
string

The rendered account nav HTML view.

assemble_url()

Convenience method to assemble an accessible URL.

public static assemble_url(string $path) : string
Parameters
$path : string

The relative path.

Return values
string

The absolute URL for passed relative path.

create_page()

Create PA WordPress page.

public static create_page(object $page) : null
Parameters
$page : object

See properties.

Return values
null

create_pages()

Generate PA WordPress pages.

public static create_pages([mixed $pages = null ]) : null
Parameters
$pages : mixed = null
Return values
null

download_puzzle_attachment_url()

Get the download puzzle attachment URL.

public static download_puzzle_attachment_url(mixed $id, mixed $aid) : string
Parameters
$id : mixed
$aid : mixed
Return values
string

The download puzzle attachment URL.

download_puzzle_url()

Get the download puzzle URL.

public static download_puzzle_url(mixed $id) : string
Parameters
$id : mixed
Return values
string

The download puzzle URL.

empty_cache()

Empties the existing server-based cache.

public static empty_cache() : mixed
Tags
retun

null

Return values
mixed

free_trial_verification_url()

An absolute URL path to sign up for a free trial.

public static free_trial_verification_url(int $id) : string
Parameters
$id : int

The PA_Purchasable ID for the free trial.

Return values
string

The absolute URL path to sign up for a free trial.

get_account_puzzle_year_uri()

A convenience function to assemble the puzzle year URL for user accounts.

public static get_account_puzzle_year_uri(int $year) : int
Parameters
$year : int

The puzzle year.

Return values
int

The user account puzzle year URL.

get_default_profile_icon()

Get the default user profile image url.

public static get_default_profile_icon() : string
Return values
string

The user profile image url.

Retrieves all featured authors.

public static get_featured_authors() : array<string|int, PA_User>
Return values
array<string|int, PA_User>

An array of users.

Retrieves featured free trials from the API server.

public static get_featured_free_trials() : array<string|int, array<string|int, mixed>>
Tags
todo

Should return PA_PurchasableItem instead of purchasable item JSON.

Return values
array<string|int, array<string|int, mixed>>

An array of free trial PA_PurchasableItem JSON data.

Get featured providers.

public static get_featured_providers() : array<string|int, PA_Provider>
Return values
array<string|int, PA_Provider>

An array of featured providers.

Retrieves featured recurring subscriptions from the API server.

public static get_featured_recurring_subscriptions() : array<string|int, PA_PurchasableItem>
Return values
array<string|int, PA_PurchasableItem>

An array of PA_PurchasableItem items.

Retrieves featured one-time subscriptions from the API server.

public static get_featured_single_subscriptions() : array<string|int, PA_PurchasableItem>
Return values
array<string|int, PA_PurchasableItem>

An array of PA_PurchasableItem items.

Retrieves all featured staff.

public static get_featured_staff() : array<string|int, PA_User>
Return values
array<string|int, PA_User>

An array of users.

get_provider_by_slug()

Get provider by provider slug.

public static get_provider_by_slug(string $slug) : PA_Provider
Parameters
$slug : string

The provider slug.

Return values
PA_Provider

The provider.

get_providers()

Get all available providers as PA_Provider JSON data.

public static get_providers() : array<string|int, mixed>
Return values
array<string|int, mixed>

All available providers as PA_Provider JSON data.

get_providers_with_puzzles_by_year()

Get providers with puzzles by year.

public static get_providers_with_puzzles_by_year(int $year) : array<string|int, PA_Provider>
Parameters
$year : int

The requested year.

Return values
array<string|int, PA_Provider>

An array of providers with a collection of PA_Puzzle items.

get_purchase()

Get a specific PA_Purchse record JSON data.

public static get_purchase(int $purchase_id, token $token) : array<string|int, mixed>
Parameters
$purchase_id : int

The requested PA_Purchase ID.

$token : token

A PA_Purchase token to verify the request.

Return values
array<string|int, mixed>

The specific PA_Purchse record JSON data.

get_puzzle()

Get a puzzle based on puzzle ID.

public static get_puzzle(int $puzzle_id) : PA_Puzzle|null
Parameters
$puzzle_id : int

The puzzle ID

Return values
PA_Puzzle|null

The found puzzle.

get_puzzle_archive_years()

A convenience function to get a list of puzzle archive years.

public static get_puzzle_archive_years() : array<string|int, int>
Return values
array<string|int, int>

An array of years that have puzzles.

get_puzzle_attachments()

Get puzzle attachments via PA_Puzzle based on puzzle ID.

public static get_puzzle_attachments(int $puzzle_id) : PA_Puzzle|null
Parameters
$puzzle_id : int

The puzzle ID.

Return values
PA_Puzzle|null

The found puzzle.

get_puzzle_bundles()

A convenience function to get a list of available puzzle bundles.

public static get_puzzle_bundles() : array<string|int, array<string|int, mixed>>
Return values
array<string|int, array<string|int, mixed>>

An array of puzzle bundles

get_puzzle_by_date()

Get a puzzle based on date.

public static get_puzzle_by_date(string $date) : PA_Puzzle|null
Parameters
$date : string

The requested date.

Return values
PA_Puzzle|null

The found puzzle.

get_puzzle_by_date_json()

Get a puzzle based on date.

public static get_puzzle_by_date_json(string $date) : PA_Puzzle|null
Parameters
$date : string

The requested date.

Return values
PA_Puzzle|null

The found puzzle.

get_puzzle_json()

A convenience function to get a puzzle JSON object.

public static get_puzzle_json(mixed $puzzle_id) : array<string|int, mixed>
Parameters
$puzzle_id : mixed
Tags
params

int $puzzle_id The puzzle ID.

Return values
array<string|int, mixed>

A puzzle JSON data object.

get_puzzle_year_uri()

A convenience function to assemble the puzzle year URL.

public static get_puzzle_year_uri(int $year) : int
Parameters
$year : int

The puzzle year.

Return values
int

The puzzle year URL.

get_puzzles_by_year()

Retrieves a list of summarized PA_Puzzle items published in a specific year from the API server.

public static get_puzzles_by_year(int $year[, object $opts = [] ]) : array<string|int, PA_Puzzle>
Parameters
$year : int

The requested puzzle publish year.

$opts : object = []

Additional options for manipulating the request. Currently unused.

Tags
todo

Should return PA_Puzzle instead of puzzle JSON.

see

Puzzle_Anywhere::get_puzzle.

Return values
array<string|int, PA_Puzzle>

An array of PA_Puzzle summaries.

get_renewable_subscriptions()

Get a user's renewal subscriptions based on an user-associated token.

public static get_renewable_subscriptions(string $token) : array<string|int, PA_PurchasableItem>
Parameters
$token : string

The user-associated token.

Return values
array<string|int, PA_PurchasableItem>

An array of possible renewable subscriptions for the user.

get_sample_puzzles()

A convenience function to get a list of sample puzzles.

public static get_sample_puzzles() : array<string|int, array<string|int, mixed>>
Return values
array<string|int, array<string|int, mixed>>

An array of sample puzzles JSON data.

get_subscriber_puzzle_attachments()

Get subscriber puzzles with attachment info.

public static get_subscriber_puzzle_attachments(int $puzzle_id) : PA_Puzzle
Parameters
$puzzle_id : int

The puzzle ID.

Return values
PA_Puzzle

The found puzzle with attachment info.

get_support_email()

Retrieve the assigned support email.

public static get_support_email() : string
Return values
string

The support email.

Retrieve the assigned support email mailto link.

public static get_support_email_link() : string
Return values
string

The support email mailto link.

get_tip_jar()

Get tip jar PA_PurchasableItem JSON data.

public static get_tip_jar() : array<string|int, mixed>
Return values
array<string|int, mixed>

The tip jar PA_PurchasableItem JSON data.

get_year_from_uri()

A convenience function to retrieve the year from URI.

public static get_year_from_uri() : int
Return values
int

The found year.

jsonapi_to_data()

Converts returned JSON-API response to an array.

public static jsonapi_to_data(mixed $response[, object $opts = ['merge_attrs' => false] ]) : array<string|int, array<string|int, mixed>>
Parameters
$response : mixed
$opts : object = ['merge_attrs' => false]

@option bpolean $merge_attr Denotes whether the returned array should merge attributes for easier processing.

Return values
array<string|int, array<string|int, mixed>>

the processed data.

local_subscribe_url()

Get the subscribe page permalink.

public static local_subscribe_url() : string
Return values
string

The subscribe page permalink.

newsletter_signup_url()

An absolute URL path to sign up for the main newsletter.

public static newsletter_signup_url() : string
Return values
string

The absolute URL path to sign up for the main newsletter.

Gets the WordPress page permalink absolute URL.

public static page_permalink(string $title) : string
Parameters
$title : string

The page title.

Return values
string

The WordPress page permalink absolute URL.

paypal_subscribe_url()

Get the PayPal subscribe URL.

public static paypal_subscribe_url() : string
Return values
string

The PayPal subscribe URL.

post_free_trial()

Send a free trial request to the API server.

public static post_free_trial(int $id, string $email, string $token) : array<string|int, mixed>
Parameters
$id : int

The PA_PurchasableItem ID.

$email : string

The email address for the free trial.

$token : string

The generated recaptcha token.

Return values
array<string|int, mixed>

Returned success or error JSON data.

post_newsletter_signup()

Sign up to subscribe to the default newsletter to the API server.

public static post_newsletter_signup(string $email, string $token) : array<string|int, mixed>
Parameters
$email : string

The email to use to sign up for the default newsletter.

$token : string

The generated recaptcha token.

Return values
array<string|int, mixed>

Returned success or error JSON data.

post_password_reset()

Confirm a password reset request.

public static post_password_reset(string $email) : array<string|int, mixed>
Parameters
$email : string

The email for the account to confirm the password reset.

Return values
array<string|int, mixed>

Returned success or error JSON data.

post_puzzle_request()

Send a resent puzzle request to the API server.

public static post_puzzle_request(int $puzzle_id, string $email) : array<string|int, mixed>

This is paywalled, unless it's a free puzzle.

Parameters
$puzzle_id : int

The ID of the puzzle to resend.

$email : string

The email address to use to resend the puzzle to.

Return values
array<string|int, mixed>

Returned success or error JSON data.

post_request_password_reset()

Send a password reset request to the API server.

public static post_request_password_reset(string $email, string $token) : object
Parameters
$email : string

The email for the account to request a password reset.

$token : string

The generated recaptcha token.

Return values
object

Returned success or error JSON.

post_reset_password_confirmation()

Reset a user's password.

public static post_reset_password_confirmation(mixed $user_id, string $token, string $password, mixed $password_confirmation) : array<string|int, mixed>
Parameters
$user_id : mixed
$token : string

The password reset token.

$password : string

The new password, to confirm that the user didn't typo.

$password_confirmation : mixed
Return values
array<string|int, mixed>

Returned success or error JSON data.

post_subscription_renewal_request()

Send a subscription renewal request to the API server.

public static post_subscription_renewal_request(string $email) : array<string|int, mixed>
Parameters
$email : string

The email address for the reneweal request.

Return values
array<string|int, mixed>

Returned success or error JSON data.

post_trial_subscription_confirmation()

Confirm a trial subscription signup via the API server.

public static post_trial_subscription_confirmation(int $purchase_id, string $token) : PA_Subscription
Parameters
$purchase_id : int

The PA_Purchase ID for the free trial.

$token : string

The PA_Purchase token for the free trial.

Return values
PA_Subscription

The confirmed subscription record.

purchase_url()

Get the purchase URL for individual puzzles.

public static purchase_url(int $id) : string
Parameters
$id : int

The PA_Puzzle ID to purchase.

Return values
string

The purchase URL for the requested puzzle.

puzzle_info_url()

Get the subscribe page permalink.

public static puzzle_info_url(mixed $puzzle_id) : string
Parameters
$puzzle_id : mixed
Return values
string

The subscribe page permalink.

puzzles_by_year_uri()

An URI to view a list of puzzles by year.

public static puzzles_by_year_uri(int $year) : string
Parameters
$year : int

The puzzle published year.

Return values
string

The URI to view a list of puzzles by year.

puzzles_by_year_uri_template()

Assembles a relative puzzles by year URL template meant to be used in in tandem with `sprintf`.

public static puzzles_by_year_uri_template() : string
Return values
string

The relative URL puzzles by year template.

puzzles_by_year_url()

An absolute URL path to view a list of puzzles by year.

public static puzzles_by_year_url(int $year) : string
Parameters
$year : int

The puzzle published year.

Return values
string

The absolute URL path to view a list of puzzles by year.

puzzles_by_year_url_template()

Assembles an absolute puzzles by year URL template meant to be used in in tandem with `sprintf`.

public static puzzles_by_year_url_template() : string
Return values
string

The absolute URL puzzles by year template.

rebuild_pages()

Rebuild PA pages.

public static rebuild_pages([mixed $pages = null ]) : null
Parameters
$pages : mixed = null
Tags
params

array|null Specify the pages meant to be rebuilt, or all if null.

Return values
null

renewable_subscriptions_url()

Get the renewable subscriptions page absolute URL.

public static renewable_subscriptions_url(string $token) : string
Parameters
$token : string

The user subscriptions token.

Return values
string

The renewable subscriptions page absolute URL.

request_password_reset_url()

Get the request password reset page absolute URL.

public static request_password_reset_url() : string
Return values
string

The request password reset page page absolute URL.

resend_puzzle_url()

Get the resend puzzle page absolute URL.

public static resend_puzzle_url() : string
Return values
string

The resend puzzle page page absolute URL.

reset_password_url()

Get the reset password page absolute URL.

public static reset_password_url() : string
Return values
string

The request password reset page page absolute URL.

resp_errored()

Denotes whether the latest response has errored.

public static resp_errored() : bool
Return values
bool

True if errored.

resp_successful()

Denotes whether the latest response has been successful.

public static resp_successful() : bool
Return values
bool

True if successful.

show_errors()

Echoes caught errors via `self::$api_errors`.

public static show_errors() : null
Tags
see

$api_errors

see
show_result
Return values
null

The errors are echoed, not returned.

show_errors_in_view()

Echoes caught errors via `self::$api_errors`.

public static show_errors_in_view(string $view[, array<string|int, mixed> $args = [] ]) : null
Parameters
$view : string

The view to use.

$args : array<string|int, mixed> = []

The arguments to pass to the view renderer. Includes:

  • array[string] $args[ 'errors' ] Error array with strings. Defaults to self::$api_errors.
Tags
see

$api_errors

see
show_result
Return values
null

The errors are echoed, not returned.

show_result()

Convenience function to display the results and errors of a request.

public static show_result([string|null $result = null ]) : null

Note that this echoes the result -- it does not return it -- so it's meant to be used in pages or view templates.

Parameters
$result : string|null = null

A previously defined result.

Tags
see

$api_errors

see
resp_errored
see

views/result-errors.php

Return values
null

status_display()

Formats a passed returned request status to be humanized for display.

public static status_display(mixed $status) : string
Parameters
$status : mixed
Return values
string

The humanized status.

subscription_renewal_request_url()

Get the subscription renewal request page absolute URL.

public static subscription_renewal_request_url() : string
Return values
string

The subscription renewal request page page absolute URL.

view()

Renders an HTML view from a PHP view template.

public static view(string $name[, array<string|int, mixed> $args = [] ]) : string
Parameters
$name : string

The view filename to retrieve.

$args : array<string|int, mixed> = []

Optional arguments to pass off to the view. Includes:

  • boolean get_user, which will pass the stored user as pa_user to the view.
Return values
string

The rendered HTML view.

get_cache()

Returns a cached value using WP's `Transient` API based on the requested path.

private static get_cache(string $path) : object
Parameters
$path : string

The requested path.

Return values
object

A cached value using WP's Transient API.

get_cache_key()

Get the cache key for the requested path.

private static get_cache_key(string $path) : string
Parameters
$path : string

The requested path.

Return values
string

The cache key.

get_cache_keys()

Get all stored cache keys for easier cache viewing/deletion.

private static get_cache_keys() : array<string|int, string>
Return values
array<string|int, string>

The cache keys.

get_host()

Retrieves the host option from the plugin.

private static get_host() : string
Return values
string

The host option from the plugin.

reset_errors()

Resets class-based errors.

private static reset_errors() : null
Tags
see

$api_errors

Return values
null

store_cache_key()

Keeps a running tab of cached items.

private static store_cache_key(mixed $path) : mixed

Only used when displaying current cached items, or emptying the cache.

Parameters
$path : mixed
Return values
mixed

write_cache()

Writes a cache using WP's `Transient` API.

private static write_cache(string $path, string $str) : null
Parameters
$path : string

The path to use for the cache key.

$str : string

The content to write for the cached element.

Return values
null

Search results