| 1 |
<?php |
| 2 |
// TODO: not currently rendered, can probably match the managelist.php pattern? |
| 3 |
|
| 4 |
// ====== |
| 5 |
// INIT |
| 6 |
// ====== |
| 7 |
|
| 8 |
$availablePages = get_pages(); |
| 9 |
$programMapKey = 'p-' . $props['program_info']['program_id']; |
| 10 |
$programNetworkMap = get_option('powerpress_network_map', []); |
| 11 |
$linkedProgramPageId = $programNetworkMap[$programMapKey] ?? 0; |
| 12 |
|
| 13 |
$programId = $props['program_info']['program_id']; |
| 14 |
$programTitle = $props['program_info']['program_title']; |
| 15 |
|
| 16 |
// resolve page link from map |
| 17 |
$pageLink = '(not set)'; |
| 18 |
$hasPageLink = false; |
| 19 |
if ($linkedProgramPageId && get_post_status($linkedProgramPageId) === 'publish') { |
| 20 |
$pageLink = get_permalink($linkedProgramPageId); |
| 21 |
$hasPageLink = true; |
| 22 |
} |
| 23 |
|
| 24 |
// ========== |
| 25 |
// BACK URL |
| 26 |
// ========== |
| 27 |
|
| 28 |
$backPage = urlencode(powerpress_admin_get_page()); |
| 29 |
$backUrl = admin_url("admin.php?page={$backPage}&status=Select+Choice&tab=shows"); |
| 30 |
?> |
| 31 |
|
| 32 |
<!-- ============= |
| 33 |
PAGE HEADER |
| 34 |
============= --> |
| 35 |
|
| 36 |
<div class="ppn-page-header"> |
| 37 |
<div> |
| 38 |
<h1 class="ppn-page-title"><?php esc_html_e('Podcast Network', 'powerpress');?></h1> |
| 39 |
<h4 class="ppn-page-subtitle"><?php esc_html_e('Build and manage your podcast network.','powerpress');?></h4> |
| 40 |
</div> |
| 41 |
</div> |
| 42 |
|
| 43 |
<div class="tabs-container"> |
| 44 |
<form method="POST" action="#/" id="manageForm"> <!-- Make sure to keep back slash there for WordPress --> |
| 45 |
</form> |
| 46 |
|
| 47 |
<!-- ================== |
| 48 |
PROGRAM SETTINGS |
| 49 |
================== --> |
| 50 |
|
| 51 |
<div class="row"> |
| 52 |
<div class="col-md-6"> |
| 53 |
<div class="flex-row p-2 d-block"> |
| 54 |
<h2 class="ppn-manage__section-title m-0 p-2"><?php echo esc_html($programTitle); ?></h2> |
| 55 |
<h4 class="ppn-manage__section-desc p-2"><?php esc_html_e('Manage page linking for this show.', 'powerpress');?></h4> |
| 56 |
</div> |
| 57 |
<div class="settingBox w-100"> |
| 58 |
|
| 59 |
<h4 class="ppn-manage__field-label"><?php esc_html_e('Show Page Link', 'powerpress'); ?></h4> |
| 60 |
<div id="ppn-page-link-row" class="ppn-page-link-row"> |
| 61 |
<input id="ppn-page-link-input" class="ppn-manage__page-link" type="text" value="<?php echo $pageLink; ?>" readonly> |
| 62 |
<?php if ($hasPageLink) { ?> |
| 63 |
<a href="<?php echo esc_url($pageLink); ?>" target="_blank" class="ppn-page-link-view" title="<?php esc_attr_e('View page', 'powerpress'); ?>"><i class="material-icons-outlined">open_in_new</i></a> |
| 64 |
<a href="<?php echo esc_url(get_edit_post_link($linkedProgramPageId)); ?>" target="_blank" class="ppn-page-link-view" title="<?php esc_attr_e('Edit page', 'powerpress'); ?>"><i class="material-icons-outlined">edit</i></a> |
| 65 |
<?php } ?> |
| 66 |
</div> |
| 67 |
<div class="d-flex gap-sm" style="margin-top: 8px;"> |
| 68 |
<?php if ($hasPageLink) { ?> |
| 69 |
<button id="ppn-link-page-btn" type="button" class="button" data-ppn-action="ppnDialog" data-ppn-dialog="selectPageBox"><?php esc_html_e('Change Page', 'powerpress'); ?></button> |
| 70 |
<button type="submit" form="unlinkPageForm" class="button ppn-button-danger" onclick="return confirm('<?php $t = esc_js($programTitle); echo esc_js("Are you sure you want to unlink this page from {$t}?"); ?>')"><?php esc_html_e('Unlink Page', 'powerpress'); ?></button> |
| 71 |
<button type="submit" form="removeProgramForm" class="button ppn-button-danger" onclick="return confirm('<?php $t = esc_js($programTitle); echo esc_js("Are you sure you want to remove '{$t}'?"); ?>')"><?php esc_html_e('Remove Program', 'powerpress'); ?></button> |
| 72 |
<?php } else { ?> |
| 73 |
<button id="ppn-link-page-btn" type="button" class="button" data-ppn-action="ppnDialog" data-ppn-dialog="selectPageBox"><?php esc_html_e('Select or Create Page', 'powerpress'); ?></button> |
| 74 |
<?php } ?> |
| 75 |
</div> |
| 76 |
|
| 77 |
</div> |
| 78 |
|
| 79 |
<!-- hidden forms for destructive actions --> |
| 80 |
<?php if ($hasPageLink) { ?> |
| 81 |
<form method="POST" id="unlinkPageForm" action="<?php echo esc_url("?page=" . urlencode(powerpress_admin_get_page()) . "&status=Manage+Program&tab=shows"); ?>"> |
| 82 |
<input type="hidden" name="target" value="Program" /> |
| 83 |
<input type="hidden" name="targetId" value="<?php echo esc_attr($programId); ?>" /> |
| 84 |
<input type="hidden" name="redirectUrl" value="false" /> |
| 85 |
<input type="hidden" name="pageAction" value="unlink" /> |
| 86 |
<?php wp_nonce_field('powerpress', '_ppn_nonce'); ?> |
| 87 |
</form> |
| 88 |
<form method="POST" id="removeProgramForm" action="<?php echo esc_url("?page=" . urlencode(powerpress_admin_get_page()) . "&status=Select+Choice&tab=shows"); ?>"> |
| 89 |
<input type="hidden" name="target" value="program" /> |
| 90 |
<input type="hidden" name="targetId" value="<?php echo esc_attr($programId); ?>" /> |
| 91 |
<input type="hidden" name="requestAction" value="delete" /> |
| 92 |
<input type="hidden" name="redirectUrl" value="false" /> |
| 93 |
<input type="hidden" name="changeOrCreate" value="true" /> |
| 94 |
<input type="hidden" name="pageAction" value="clearSiteCache" /> |
| 95 |
<input type="hidden" name="clearSiteCache" value="true" /> |
| 96 |
<?php wp_nonce_field('powerpress', '_ppn_nonce'); ?> |
| 97 |
</form> |
| 98 |
<?php } ?> |
| 99 |
</div> |
| 100 |
|
| 101 |
<div class="col-md-6"> |
| 102 |
<div class="settingBox w-100"> |
| 103 |
<h4 class="ppn-manage__field-label"><?php esc_html_e('Available Shortcode', 'powerpress');?></h4> |
| 104 |
<p class="description"><code><?php echo esc_html($props['program_info']['shortcode']); ?></code></p> |
| 105 |
<p class="description"><?php esc_html_e('This shortcode is automatically placed on the linked page to display the show.', 'powerpress'); ?></p> |
| 106 |
</div> |
| 107 |
</div> |
| 108 |
</div> |
| 109 |
|
| 110 |
<!-- ============ |
| 111 |
ACTION BAR |
| 112 |
============ --> |
| 113 |
|
| 114 |
<div class="flex-row d-flex justify-content-end gap-md p-3 align-items-center"> |
| 115 |
<a href="<?php echo esc_url($backUrl); ?>" class="button"> |
| 116 |
<?php esc_html_e('Back', 'powerpress');?> |
| 117 |
</a> |
| 118 |
</div> |
| 119 |
|
| 120 |
<!-- ==================== |
| 121 |
PAGE SELECT DIALOG |
| 122 |
==================== --> |
| 123 |
|
| 124 |
<?php |
| 125 |
$pageSelectFormId = $hasPageLink ? 'changeForm' : 'selectForm'; |
| 126 |
powerpress_render_network_page_select([ |
| 127 |
'form_id' => $pageSelectFormId, |
| 128 |
'shortcode_id' => 'ppn-program-shortcode', |
| 129 |
'shortcode' => $props['program_info']['shortcode'], |
| 130 |
'target' => 'Program', |
| 131 |
'target_id' => $programId, |
| 132 |
'create_id' => $programId, |
| 133 |
'create_title' => $programTitle, |
| 134 |
'selected_page' => $linkedProgramPageId, |
| 135 |
'edit_url' => $hasPageLink ? get_edit_post_link($linkedProgramPageId) : '', |
| 136 |
'pages' => $availablePages, |
| 137 |
]); |
| 138 |
?> |
| 139 |
|
| 140 |
<div class="clear"></div> |
| 141 |
<form method="POST" action="#/" id="manageForm"> <!-- Make sure to keep back slash there for WordPress --> |
| 142 |
</form> |
| 143 |
</div> |
| 144 |
|