'all', 'icon' => 'all', 'label' => 'Everything', ], [ 'id' => 'publish', 'icon' => 'show', 'label' => 'Live', ], [ 'id' => 'draft', 'icon' => 'hide', 'label' => 'Hidden', ], [ 'id' => 'trash', 'icon' => 'delete', 'label' => 'Scrapped', ] ]; $permission = JVB()->roles()->getContentPlural($content); $canPublish = current_user_can("publish_{$permission}") && current_user_can('skip_moderation'); $out = '
'; if (!empty($statusFilters)) { $out .= '
'; foreach ($statusFilters as $filter) { $disabled = ($filter['id'] === 'publish' && !$canPublish) ? ' disabled' : ''; $status = esc_attr($filter['id']); $title = esc_html($filter['label']); $out .= sprintf( ' ', $status, $status, $disabled, $status, jvbIcon($filter['icon']), $title ); } if (!$canPublish) { $out .= '

Your account needs to be verified before you can publish '.$content.'.

'; } $out .= '
'; } $bulkActions = jvbGetBulkActions($content); if (!empty($bulkActions)) { $out .= '
', jvbIcon('x', ['title'=>'Cancel']) ); } $out .= '
'; return $out; } /** * Outputs available actions * mainly used by news.php * @param string $content * * @return array|array[] */ function jvbGetBulkActions(string $content):array { $bulkActions = [ 'publish' => [ 'icon' => 'show', 'label' => 'Show', 'disabled' => true, ], 'edit' => [ 'icon' => 'edit', 'label' => 'Edit', 'disabled' => true, ], 'draft' => [ 'icon' => 'hide', 'label' => 'Hide', 'disabled' => true, ], 'trash' => [ 'icon' => 'delete', 'label' => 'Scrap', 'disabled' => true, ] ]; $permission = JVB()->roles()->getContentPlural($content); if (current_user_can('skip_moderation') && current_user_can("publish_{$permission}")) { $bulkActions['publish']['disabled'] = false; } if (current_user_can("edit_{$permission}")) { $bulkActions['edit']['disabled'] = false; $bulkActions['draft']['disabled'] = false; } if (current_user_can("delete_{$permission}")) { $bulkActions['trash']['disabled'] = false; } return $bulkActions; } /** * Outputs the date filters for a content type * @param string $content * * @return string */ function jvbRenderDateFilter(string $content):string { $cache = Cache::for('date_filter')->connect('post', true); $check = $cache->get($content); if ($check) { return $check; } $postType = (str_starts_with($content, BASE)) ? $content : BASE. $content; // Get available months global $wpdb; $months = $wpdb->get_results(" SELECT DISTINCT YEAR(post_date) as year, MONTH(post_date) as month FROM $wpdb->posts WHERE post_type = '{$postType}' ORDER BY post_date DESC "); // Quick filters $out = '
'; // Custom date range $out .= '
'; $cache->set($content, $out); return $out; } /** * Renders sections based on what was set in the Content Registry * @param object $handler * @param int $ID * @param string $contentType * @param string $postType * @param bool $prefix * * @return void */ function jvbRenderSections( int $ID, string $contentType = 'post', string $postType = '', bool $prefix = false ):void { $registrar = Registrar::getInstance($postType); if (!$registrar || empty($registrar->getSections())) { return; } echo '
'; $nav = ''; echo $nav; $fields = Registrar::getFieldsFor($postType); ?>
getSections() as $slug => $section) { $tabName = ($prefix) ? $ID.'-'.$slug : $slug; $class = ($i == 0) ? ' active' : ''; ?>

$config) : ?> roles)) { echo Form::render($field, null, $config); } } else { echo Form::render($field, null, $config); } } ?>