### Example FTP constants for root installation Source: https://docs.themeisle.com/wordpress/update-theme-failed Use these values when WordPress is installed in the root folder. Replace the placeholder paths in the previous snippet with these. ```php define( 'FTP_BASE', '/' ); define( 'FTP_CONTENT_DIR', '/wp-content/' ); define( 'FTP_PLUGIN_DIR', '/wp-content/plugins/' ); ``` -------------------------------- ### Get all URL mappings with mappings() Source: https://docs.themeisle.com/wp-landing-kit/wplk-domain Returns an array of all mappings (excluding root and fallback) as WPLK_Mapping objects. The example adds three mappings and verifies the count is 3. ```php $mapping1 = $domain->add_mapping( 'some/url', $post_id ); $mapping2 = $domain->add_mapping( 'some/other/url', $post_id_2 ); $mapping3 = $domain->add_mapping( 'some/third/url', $post_id_3 ); count( $domain->mappings() ) === 3; // TRUE ``` -------------------------------- ### Create and activate a WPLK_Domain with root post mapping and save Source: https://docs.themeisle.com/wp-landing-kit/wplk-domain Complete example: instantiate a domain, set owner, map root to a post, activate, save, and check for errors. The domain is not active until saved. ```php $domain = new WPLK_Domain( 'mydomain.com' ); $domain->set_owner( 1234 ); $domain->root()->maps_to_post( $post_id ); $domain->activate(); $saved = $domain->save(); if( is_wp_error( $saved ) ){ // …do something… } ``` -------------------------------- ### URL parameter example for wpfsAmount Source: https://docs.themeisle.com/wp-full-pay/passing-the-payment-amount-to-one-time-payment-forms Pass the payment amount in the wpfsAmount URL parameter. The amount must be in the smallest currency unit (e.g., 1000 for $10.00, 10 for ¥10). ```text https://ExampleDomain.local/one-time-payment-form/?wpfsAmount=7040 ``` -------------------------------- ### Modify setup() function arrays in wpfsm-main.php Source: https://docs.themeisle.com/wp-full-pay/manually-adding-more-membership-levels Update the rolePlans, nameRoles, and roleRanks arrays in the setup() function to include the new role. This is required for the plugin to recognize the new membership level. ```php $this->rolePlans = array( self::ROLE_BASIC => null, self::ROLE_BRONZE => null, self::ROLE_SILVER => null, self::ROLE_GOLD => null, self::ROLE_DIAMOND => null, self::ROLE_ALL_ACCESS => null ); $this->nameRoles = array(); $this->nameRoles[self::resolveRoleNameByCode(self::ROLE_NO_ACCESS)] = self::ROLE_NO_ACCESS; $this->nameRoles[self::resolveRoleNameByCode(self::ROLE_BASIC)] = self::ROLE_BASIC; $this->nameRoles[self::resolveRoleNameByCode(self::ROLE_BRONZE)] = self::ROLE_BRONZE; $this->nameRoles[self::resolveRoleNameByCode(self::ROLE_SILVER)] = self::ROLE_SILVER; $this->nameRoles[self::resolveRoleNameByCode(self::ROLE_GOLD)] = self::ROLE_GOLD; $this->nameRoles[self::resolveRoleNameByCode(self::ROLE_DIAMOND)] = self::ROLE_DIAMOND; $this->nameRoles[self::resolveRoleNameByCode(self::ROLE_ALL_ACCESS)] = self::ROLE_ALL_ACCESS; $this->roleRanks = array( self::ROLE_NO_ACCESS => 0, self::ROLE_BASIC => 1, self::ROLE_BRONZE => 2, self::ROLE_SILVER => 3, self::ROLE_GOLD => 4, self::ROLE_DIAMOND => 5, self::ROLE_ALL_ACCESS => 999999 ); ``` -------------------------------- ### URL parameter example for affiliate ID Source: https://docs.themeisle.com/wp-full-pay/adding-custom-metadata-to-payments Example URL with the 'affid' parameter to pass affiliate ID to the payment page. The parameter must remain in the address bar until the payment is submitted. ```text https://ExampleDomain.com/sell-recurring-services-inline/?wpfsPlan=price_1JmD2iKit80XPxkD8jLNNvVM&affid=partner42 ``` -------------------------------- ### Adding URL mappings with add_mapping() Source: https://docs.themeisle.com/wp-landing-kit/wplk-domain Shows the many ways to call add_mapping(): with no args, a URL path, a post ID, a post object, a callback, a RegEx flag, a WPLK_Mapping instance, an array of args, and combinations. Mappings are matched in registration order, starting from root, then added mappings, then fallback. ```php $domain = new WPLK_Domain( 'mydomain.com' ); // Pass no args and manipulate the returned instance. $mapping = $domain->add_mapping(); $mapping->set_url_path( 'some/url' ); $mapping->maps_to_post( $post_id ); // Pass only a URL path and manipulate the returned instance. $mapping = $domain->add_mapping( 'some/url' ); $mapping->maps_to_post( $post_id ); // Map a post ID to a URL path. $domain->add_mapping( 'some/url', $post_id ); // Map a post object to a URL path. $domain->add_mapping( 'some/url', get_post( $post_id ) ); // Use a callback to configure the mapping object. $domain->add_mapping( function( WPLK_Mapping $mapping){ $mapping->set_url_path( 'some/url' ); $mapping->maps_to_post( $post_id ); } ); // Use RegEx in the URL. $domain->add_mapping( 'some/url/.+', $post_id, true ); // Map using a URL path and a callback. $domain->add_mapping( 'some/url', function( WPLK_Mapping $mapping){ $mapping->maps_to_post( $post_id ); } ); // Pass a WPLK_Mapping instance. $mapping = new WPLK_Mapping( 'some/url' ); $mapping->maps_to_post( $post_id ); $domain->add_mapping( $mapping ); // Pass a WPLK_Mapping instance and configure it using a callback. $mapping = new WPLK_Mapping( 'some/url' ); $domain->add_mapping( $mapping, function( WPLK_Mapping $mapping){ $mapping->maps_to_post( $post_id ); } ); // Pass an array of WPLK_Mapping args. $domain->add_mapping( [ 'url_path' => 'some/url', 'post_type' => $post_type, 'post_id' => $post_id, ] ); // Pass an array of WPLK_Mapping args and configure using a callback. $domain->add_mapping( [ 'url_path' => 'some/url', 'post_type' => $post_type, ], function( WPLK_Mapping $mapping){ $mapping->maps_to_post( $post_id ); } ); ``` -------------------------------- ### Finding multiple mappings with find_mappings() Source: https://docs.themeisle.com/wp-landing-kit/wplk-domain Use find_mappings() with a callback to get an array of WPLK_Mapping objects that match. Excludes root and fallback mappings; returns an empty array if no matches. ```php $domain->add_mapping( 'some/url', $post_id ); $domain->add_mapping( 'some/other/url', $post_id_2 ); $domain->add_mapping( 'some/third/url', $post_id_3 ); // Search for any mappings that match. $mappings = $domain->find_mappings( function( WPLK_Mapping $mapping ){ if( $mapping->url_path === 'some/url' ){ return true; } if( $mapping->url_path === 'some/other/url' ){ return true; } return false; } ); count( $mappings ) === 2; // TRUE ``` -------------------------------- ### Handle unmapped domain requests with wp_landing_kit/unmapped_domain_requested Source: https://docs.themeisle.com/wp-landing-kit/handling-requests-made-to-inactive-or-non-existent-domains Use this action hook to respond when the plugin cannot find a domain record for the requested host name, or when the matching domain is not published. The example logs the unmatched host as an error and redirects a specific host name. ```php add_action('wp_landing_kit/unmapped_domain_requested', 'xzy_handle_unmapped_domain'); function xzy_handle_unmapped_domain($host){ // Example 1: Log the unmatched host name as an error. trigger_error("Domain host not found: $host"); // Example 2: Redirect a particular host name. if($host === 'draft-domain.com'){ wp_redirect('http://example.com'); } } ``` -------------------------------- ### Create a new WPLK_Domain object with various constructor arguments Source: https://docs.themeisle.com/wp-landing-kit/wplk-domain Shows different ways to instantiate a WPLK_Domain: passing a host name, a full URL (host extracted), no arguments (requires set_host()), or an array with optional owner_id and enforced_protocol. Instantiating does not save to the database; saving without a host returns a WP_Error. ```php // Simply pass the domain host name on instantiation. $domain = new WPLK_Domain( 'mydomain.com' ); // Note, you can also pass a full URL — the object will extract the `mydomain.com` host name in this case. $domain = new WPLK_Domain( 'http://mydomain.com/some/url' ); // Passing no args to the constructor requires the use of the set_host() method to set the actual domain host name. If // no host name is set, subsequent calls to $domain->save() will return a WP_Error object and the domain will not be // saved to the database. $domain = new WPLK_Domain; $domain->set_host( 'mydomain.com' ); // It is also possible to use an array when instantiating a new domain object. $domain = new WPLK_Domain( [ 'host' => 'mydomain.com', 'owner_id' => 1234, // optional 'enforced_protocol' => 'https', // optional ] ); ``` -------------------------------- ### Creating a new mapping with WPLK_Mapping Source: https://docs.themeisle.com/wp-landing-kit/wplk-mapping Shows two ways to instantiate: with a URL path in the constructor, or by setting the path later with set_url_path(). ```php $mapping = new WPLK_Mapping( 'some/url' ); // Setting the path outside of the constructor. $mapping = new WPLK_Mapping(); $mapping->set_url_path( 'some/url' ); ``` -------------------------------- ### getCurrencySymbolFor($currency) Source: https://docs.themeisle.com/wp-full-pay/using-the-api-of-wp-full-pay Returns the currency symbol of the provided currency. For example, for 'usd' the '$' string is returned. ```APIDOC ## getCurrencySymbolFor($currency) ### Description Returns the currency symbol of the provided currency. For example, for 'usd' the '$' string is returned. ### Method Function call ### Endpoint N/A (SDK method) ### Parameters - **$currency** (string) - Required - Three-letter, lowercase currency identifier to get the symbol for. ### Return Value - **string|null** - Symbol of the currency, or null if the currency is not found. ### Example ```php $symbol = $api->getCurrencySymbolFor('usd'); ``` ``` -------------------------------- ### CSS to customize payment button with form ID Hn5Gv7o Source: https://docs.themeisle.com/wp-full-pay/customizing-forms-with-css Example CSS when the form ID is Hn5Gv7o. ```css button#submit--Hn5Gv7o { background-color: red; /* This is an example, add your button properties */ } ``` -------------------------------- ### Test wp-cron.php directly Source: https://docs.themeisle.com/wordpress/troubleshoot-wp-cron-background-tasks-not-running Open this URL in your browser, replacing example.com with your domain. Expected result: a blank page or no visible error. ```text https://example.com/wp-cron.php?doing_wp_cron ``` -------------------------------- ### Root mapping instance handling with WPLK_Domain::root() Source: https://docs.themeisle.com/wp-landing-kit/wplk-domain Demonstrates that calling root() without args returns the same WPLK_Mapping instance, as shown by the TRUE comparison. Passing args creates a new instance and resets the root mapping, as shown by the FALSE comparison. ```php $mapping = $domain->root()->maps_to_post( $post_id ); // TRUE (objects are the same instance) $mapping === $domain->root(); ``` ```php $mapping = $domain->root()->maps_to_post( $post_id ); // This will reset the root mapping object entirely. $domain->root( [ 'post_id' => $post_id_2 ] ); // TRUE (objects are different instances) $mapping !== $domain->root(); ``` -------------------------------- ### Getting the mapping ID with id() Source: https://docs.themeisle.com/wp-landing-kit/wplk-mapping The id() method returns the mapping ID, generating it if it does not exist. The mapping_id property can also be read but is not advisable. ```php $mapping = new WPLK_Mapping( 'some/url' ); $mapping->id(); ``` -------------------------------- ### FluentCommunity portal redirect snippet Source: https://docs.themeisle.com/wp-landing-kit/mapping-virtual-routes Specific example for FluentCommunity. Redirects from a placeholder page with slug 'fluent-portal' to '/portal'. Use when mapping community.yourdomain.com to the /portal route. ```php add_action( 'template_redirect', function() { if ( is_page( 'fluent-portal' ) ) { wp_redirect( home_url( '/portal' ), 302 ); exit; } } ); ``` -------------------------------- ### new WPLK_Domain() Source: https://docs.themeisle.com/wp-landing-kit/wplk-domain Creates a new WPLK_Domain object. Can be instantiated with a host string, a full URL, no arguments (requiring set_host()), or an array of properties. ```APIDOC ## new WPLK_Domain() ### Description Creates a new WPLK_Domain object. The constructor accepts a host name, a full URL, no arguments, or an array of properties. Instantiating does not save the domain to the database. ### Method Constructor ### Signature `new WPLK_Domain( $args = '' )` ### Parameters - **$args** (string|array) - Optional - The domain host name, a full URL, or an array with keys `host`, `owner_id`, `enforced_protocol`. ### Usage Examples ```php // Pass host name $domain = new WPLK_Domain( 'mydomain.com' ); // Pass full URL $domain = new WPLK_Domain( 'http://mydomain.com/some/url' ); // No args, then set host $domain = new WPLK_Domain; $domain->set_host( 'mydomain.com' ); // Array of properties $domain = new WPLK_Domain( [ 'host' => 'mydomain.com', 'owner_id' => 1234, // optional 'enforced_protocol' => 'https', // optional ] ); ``` ### Notes - The object extracts the host name from a full URL. - If no host is set, calling `save()` will return a WP_Error and the domain will not be saved. - The domain is not added to the database until explicitly saved and activated. ``` -------------------------------- ### Retrieve a domain instance with WPLK_Domain::get_instance() Source: https://docs.themeisle.com/wp-landing-kit/wplk-domain Use WPLK_Domain::get_instance() to retrieve a domain by post ID, host name, or full URL. Returns a WPLK_Domain instance or NULL if not found. Using post ID is most performant; host name searches by title. Domains in trash are considered non-existent. ```php // Using a post ID. $domain = WPLK_Domain::get_instance( $post_id ); // Using a host name. $domain = WPLK_Domain::get_instance( 'mydomain.com' ); // Using a full URL (the host name will be extraced from the URL). $domain = WPLK_Domain::get_instance( 'http://mydomain.com/some/url' ); ``` -------------------------------- ### WPLK_Domain::root() Source: https://docs.themeisle.com/wp-landing-kit/wplk-domain Gets or sets the root mapping for a domain. When called without arguments, returns the root WPLK_Mapping instance, creating one if needed. When called with arguments, configures a new root mapping. ```APIDOC ## WPLK_Domain::root() ### Description Manages the root mapping for a domain. The root mapping specifies what happens when a user visits the domain root (e.g., `http://mydomain.com/`). ### Method Instance method ### Signature `$domain->root( ...$args )` ### Parameters - **...$args** (mixed) - Optional - Can be a post ID, `WP_Post` object, a callback function, or an array of mapping arguments. If omitted, returns the current root mapping instance. ### Return Value - Returns a `WPLK_Mapping` instance when called without arguments. - When called with arguments, it creates a new mapping instance and assigns it to the root, effectively resetting the root mapping. ### Usage Examples ```php $domain = new WPLK_Domain( 'mydomain.com' ); // Chaining mapping methods. $domain->root()->maps_to_post( $post_id ); // Passing a post ID or WP_Post object. $domain->root( $post ); // Passing a callback. $domain->root( function( WPLK_Mapping $mapping ){ $mapping->maps_to_term_archive( $term_id, true ); } ); // Passing an array of mapping args $domain->root( [ 'post_id' => $post_id ] ); ``` ### Notes - When called without args, returns the same instance on subsequent calls. - When args are passed, a new mapping instance is created and assigned, resetting the root mapping. ``` -------------------------------- ### WPLK_Mapping Constructor Source: https://docs.themeisle.com/wp-landing-kit/wplk-mapping Creates a new WPLK_Mapping object. Optionally accepts a URL path and a boolean indicating if the path is a regex pattern. ```APIDOC ## WPLK_Mapping Constructor ### Description Creates a new WPLK_Mapping object. The constructor optionally accepts a URL path and a boolean indicating if the path is a regex pattern. ### Method Constructor ### Signature `new WPLK_Mapping( string $url_path = '', bool $is_regex = false )` ### Parameters - **$url_path** (string) - Optional - The URL path to map. - **$is_regex** (bool) - Optional - Whether the path is a regex pattern. Default false. ### Example ```php $mapping = new WPLK_Mapping( 'some/url' ); $mapping = new WPLK_Mapping( 'some/url/.+', true ); ``` ```