| 1 |
<?php |
| 2 |
|
| 3 |
class PowerPressNetworkApplication extends PowerPressNetworkShortCode |
| 4 |
{ |
| 5 |
function __construct() |
| 6 |
{ |
| 7 |
parent::__construct('ppn-application'); |
| 8 |
} |
| 9 |
|
| 10 |
function ppn_shortcode($attr, $contents) |
| 11 |
{ |
| 12 |
require_once(WP_PLUGIN_DIR . '/powerpress/powerpressadmin.php'); |
| 13 |
|
| 14 |
$ctx = $this->getNetworkContext(); |
| 15 |
if (is_string($ctx)) return $ctx; |
| 16 |
|
| 17 |
$props = []; |
| 18 |
|
| 19 |
if (!empty($attr['auto-active'])) { |
| 20 |
$props['auto-active'] = true; |
| 21 |
} |
| 22 |
|
| 23 |
// read tos url from db, allow shortcode attribute as override |
| 24 |
$tosFromDb = $ctx['networkInfo']['tos_url'] ?? ''; |
| 25 |
$props['tos_url'] = !empty($attr['terms-url']) ? (string) $attr['terms-url'] : $tosFromDb; |
| 26 |
|
| 27 |
if (isset($attr['default-list'])) { |
| 28 |
$props['default-list'] = (int) $attr['default-list']; |
| 29 |
} |
| 30 |
|
| 31 |
$props['network_general'] = $ctx['general']; |
| 32 |
$props['powerpress_network'] = $ctx['networkInfo']; |
| 33 |
$props['post'] = false; |
| 34 |
|
| 35 |
return PowerPressNetwork::getHTML('forms.php', $props, null, null); |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
$GLOBALS['ppn_application'] = new PowerPressNetworkApplication(); |
| 40 |
|
| 41 |
|