| 1 |
<!-- ============= |
| 2 |
PAGE HEADER |
| 3 |
============= --> |
| 4 |
|
| 5 |
<div class="ppn-section-header"> |
| 6 |
<h2 class="ppn-manage__section-title"><?php echo esc_html(get_option('powerpress_network_title')); ?></h2> |
| 7 |
<button data-ppn-action="ppnAction" data-form="manageForm" data-navigate="Create List" data-tab="groups" class="button"><?php esc_html_e('Create New Group', 'powerpress');?></button> |
| 8 |
</div> |
| 9 |
<h4 class="ppn-manage__section-desc"><?php esc_html_e('Manage the groups in your network by adding/removing podcasts.', 'powerpress');?></h4> |
| 10 |
|
| 11 |
<!-- ============= |
| 12 |
GROUPS LIST |
| 13 |
============= --> |
| 14 |
|
| 15 |
<div class="ppn-search"> |
| 16 |
<input type="text" class="ppn-search__input" placeholder="<?php esc_attr_e('Filter groups...', 'powerpress'); ?>" |
| 17 |
data-ppn-action="filterList" data-ppn-target="ppn-groups-list"> |
| 18 |
<i class="material-icons-outlined ppn-search__icon">search</i> |
| 19 |
</div> |
| 20 |
<div class="ppn-list" id="ppn-groups-list"> |
| 21 |
<div class="ppn-list__header row"> |
| 22 |
<div class="col-8"><?php esc_html_e('Group', 'powerpress');?></div> |
| 23 |
<div class="col-2"><?php esc_html_e('Group Page', 'powerpress');?></div> |
| 24 |
<div class="col-2"><?php esc_html_e('Manage', 'powerpress');?></div> |
| 25 |
</div> |
| 26 |
<?php |
| 27 |
$map = get_option('powerpress_network_map'); |
| 28 |
if (empty($props)) |
| 29 |
$props = []; |
| 30 |
|
| 31 |
// filter out entries w/o valid list_id (api status keys also filtered) |
| 32 |
$props = array_filter($props, function($item) { |
| 33 |
return is_array($item) && !empty($item['list_id']); |
| 34 |
}); |
| 35 |
|
| 36 |
$render_group = function($list) use ($map) { |
| 37 |
$title = $list['list_title'] ?? ''; |
| 38 |
$listId = $list['list_id'] ?? 0; |
| 39 |
$key = "l-{$listId}"; |
| 40 |
$link = (isset($map[$key]) && get_post_status($map[$key]) === 'publish') ? get_permalink($map[$key]) : null; |
| 41 |
$pageMissing = isset($map[$key]) && !$link; |
| 42 |
?> |
| 43 |
<div class="ppn-list__row row" data-title="<?php echo esc_attr(strtolower($title)); ?>"> |
| 44 |
<div class="col-8"> |
| 45 |
<?php echo esc_html($title); ?> |
| 46 |
</div> |
| 47 |
<div class="col-2"> |
| 48 |
<span class="ppn-list__label"><?php esc_html_e('Page', 'powerpress'); ?></span> |
| 49 |
<?php if ($pageMissing){ // linked page no longer published (draft/trash) ?> |
| 50 |
<span class="ppn-page-status"> |
| 51 |
<button type="button" |
| 52 |
class="ppn-page-status--action" |
| 53 |
data-ppn-action="ppnPageAction" |
| 54 |
data-mode="list" |
| 55 |
data-target="List" |
| 56 |
data-id="<?php echo esc_attr($listId); ?>" |
| 57 |
data-title="<?php echo esc_attr($title); ?>"> |
| 58 |
<?php esc_html_e('Create Page', 'powerpress');?> |
| 59 |
</button> |
| 60 |
</span> |
| 61 |
<?php } else if ($link === null){ // no page ever created ?> |
| 62 |
<span class="ppn-page-status"> |
| 63 |
<button type="button" |
| 64 |
class="ppn-page-status--action" |
| 65 |
data-ppn-action="ppnPageAction" |
| 66 |
data-mode="list" |
| 67 |
data-target="List" |
| 68 |
data-id="<?php echo esc_attr($listId); ?>" |
| 69 |
data-title="<?php echo esc_attr($title); ?>"> |
| 70 |
<?php esc_html_e('Create Page', 'powerpress');?> |
| 71 |
</button> |
| 72 |
</span> |
| 73 |
<?php } else { ?> |
| 74 |
<span class="ppn-page-status"><a class="ppn-page-status--linked" target="_blank" href="<?php echo esc_url($link);?>"><?php esc_html_e('View Page', 'powerpress');?></a></span> |
| 75 |
<?php } ?> |
| 76 |
</div> |
| 77 |
<div class="col-2"> |
| 78 |
<button type="button" class="ppn-icon-btn" title="<?php esc_html_e('Edit List', 'powerpress');?>" data-ppn-action="ppnAction" data-form="manageList" data-navigate="Manage List" data-tab="groups" data-set-field="listId" data-set-value="<?php echo esc_attr($listId);?>"><i class="material-icons-outlined">edit</i></button> |
| 79 |
<button type="button" class="ppn-icon-btn" title="<?php esc_html_e('Delete List', 'powerpress');?>" data-ppn-action="ppnAction" data-form="manageList" data-tab="groups" data-change="true" data-confirm="<?php echo esc_attr(__('Are you sure you want to delete this list?', 'powerpress')); ?>" data-set-field="listId" data-set-value="<?php echo esc_attr($listId);?>" data-fields="requestAction:delete"><i class="material-icons-outlined">delete</i></button> |
| 80 |
</div> |
| 81 |
</div> |
| 82 |
<?php |
| 83 |
}; |
| 84 |
|
| 85 |
powerpress_render_list_section('groups', false, $props, $render_group, false, __('No groups yet.', 'powerpress')); |
| 86 |
?> |
| 87 |
</div> |
| 88 |
|
| 89 |
<!-- ============== |
| 90 |
HIDDEN FORMS |
| 91 |
============== --> |
| 92 |
|
| 93 |
<form id="manageForm" action="#/" method="POST" hidden> <!-- Make sure to keep back slash there for WordPress --> |
| 94 |
</form> |
| 95 |
|
| 96 |
<form id="manageList" action="#" method="POST" hidden> <!-- Make sure to keep back slash there for WordPress --> |
| 97 |
<input class="requestAction" name="requestAction"> |
| 98 |
<input id="listId" name="listId" value=""> |
| 99 |
<input id="linkPageList" name="linkPageList" value=""> |
| 100 |
</form> |
| 101 |
|