Skip to content

Commit

Permalink
Merge branch 'staging' into add-wysiwyg-topic-page-2
Browse files Browse the repository at this point in the history
  • Loading branch information
IshKeyes authored Dec 14, 2023
2 parents cdfea8f + af2de1b commit 867a028
Show file tree
Hide file tree
Showing 26 changed files with 426 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ function phila_resource_hub_page()
function phila_resource_hub_content()
{
?>
<style>
ul{
list-style: disc;
margin-left: 2em;
}
</style>
<h1 id="resource-hub">Resource hub</h1>
<p>The following resources may be useful as you create and manage content on phila.gov. </p>
<h2 id="resources-for-site-editors">Resources for site editors</h2>
Expand All @@ -24,7 +18,7 @@ function phila_resource_hub_content()
<hr>
<p><a href="https://phila.sharepoint.com/:f:/s/Teams-OIT-PhilagovProjectTeam/EuFE222ofUBNi_XknL-R6WcBGAwpdXhlikRBTyZAXiEzKQ?e=vsRAtu">Training presentations, guidance, and tip sheets</a> </p>
<p>This is a collection of training presentations and other guidance produced by the Digital Services team. It also includes: </p>
<ul>
<ul class="resource-hub">
<li><p>Documentation for various WordPress features. </p>
</li>
<li><p>Links to City stock photos and other imagery sources for blogs. </p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ public function __construct(){

add_action( 'init', array($this, 'phila_change_post_label') );

add_action( 'init', array($this, 'phila_change_page_label') );

add_action('admin_menu', array( $this, 'phila_hide_create_in_menu' ) );

add_action( 'pre_get_posts', array( $this, 'phila_filter_menu_search_results'), 10, 2 );

add_action('admin_menu', array($this, 'add_custom_menu_separator') );


}
Expand All @@ -40,21 +44,39 @@ function admin_menu_order( $menu_ord ) {
}
return array(
'index.php',
'resource-hub',
'separator-1',
'edit.php',
'edit.php?post_type=page',
'separator1',
'edit.php?post_type=service_page',
'edit.php?post_type=department_page',
'edit.php?post_type=programs',
'edit.php?post_type=staff_directory',
'edit.php?post_type=department_page',
'edit.php?post_type=document',
'edit.php?post_type=longform_content',
'separator2',
'separator-2',
'edit.php?post_type=event_spotlight',
'edit.php?post_type=calendar',
'edit.php?post_type=site_wide_alert',
'edit.php?post_type=guides',
'edit.php?post_type=longform_content',
'edit.php?post_type=page',
'separator-3',
'edit.php?post_type=staff_directory',
'upload.php',
'separator-last',
'edit.php?post_type=calendar',
'edit.php?post_type=text-blocks',
'edit.php?post_type=service_updates',
'edit.php?post_type=site_wide_alert',
'separator-4',
'users.php',
'wpfront-user-role-editor-all-roles',
'edit-tags.php?taxonomy=category',
'edit-tags.php?taxonomy=audience',
'edit-tags.php?taxonomy=service_type&post_type=service_page',
'edit-tags.php?taxonomy=post_tag',
'separator-5',
'themes.php',
'phila_gov',
'options-general.php',
'separator-6',
'tools.php',
'plugins.php',
);
}

Expand All @@ -63,32 +85,122 @@ function phila_change_post_label() {
$labels = &$wp_post_types['post']->labels;
$labels->name = 'The latest news + events';
$labels->singular_name = 'Latest item';
$labels->add_new = 'Add new item to the latest';
$labels->add_new_item = 'Add new item';
$labels->add_new = 'Add news item';
$labels->add_new_item = 'Add news item';
$labels->edit_item = 'Edit item';
$labels->new_item = 'New item in the latest';
$labels->view_item = 'View item';
$labels->search_items = 'Search the latest';
$labels->not_found = 'Nothing found';
$labels->not_found_in_trash = 'Nothing found in trash';
$labels->all_items = 'All items';
$labels->menu_name = 'The latest';
$labels->name_admin_bar = 'The latest';
$labels->all_items = 'All news';
$labels->menu_name = 'News';
$labels->name_admin_bar = 'News';
}

function phila_change_page_label() {
global $wp_post_types;
$labels = &$wp_post_types['page']->labels;
$labels->name = 'Top-Level Pages';
$labels->singular_name = 'Top-Level Page';
$labels->add_new = 'Add top-level page';
$labels->add_new_item = 'Add top-level page';
$labels->edit_item = 'Edit top-level page';
$labels->new_item = 'New top-level page';
$labels->view_item = 'View top-level page';
$labels->search_items = 'Search top-level pages';
$labels->not_found = 'Nothing found';
$labels->not_found_in_trash = 'Nothing found in trash';
$labels->all_items = 'All top-level pages';
$labels->menu_name = 'Top-Level Pages';
$labels->name_admin_bar = 'Top-Level Pages';
}

function add_custom_menu_separator()
{
global $menu;
$separator_index = array(4, 59, 99);

foreach($separator_index as $sp) {

if (isset($menu[$sp])) {
unset($menu[$sp]);
}
}

$user = wp_get_current_user();
$allowed_roles1 = array('primary_department_editor');
$allowed_roles2 = array('secondary_philagov_settings_editor', 'secondary_philagov_closure_settings_editor', 'secondary_tag_editor');
$allowed_roles3 = array('secondary_department_blog_editor', 'secondary_blog_contributor', 'secondary_service_page_editor', 'secondary_department_page_contributror', 'secondary_department_page_editor', 'secondary_document_page_contributor', 'secondary_document_editor', 'secondary_press_release_contributor', 'secondary_press_release_editor', 'secondary_programs__initiatives_contributor', 'secondary_programs__initiatives_editor', 'secondary_service_page_editor', 'secondary_service_status_contributor', 'secondary_staff_member_editor');
$allowed_roles4 = array('primary_department_contributor');
if (array_intersect($user->roles, $allowed_roles1) && array_intersect($user->roles, $allowed_roles2)) {
$menu[997] = ['', 'read', 'separator-1', '', 'wp-menu-separator'];
$menu[998] = ['', 'read', 'separator-4', '', 'wp-menu-separator'];
$menu[999] = ['', 'read', 'separator-6', '', 'wp-menu-separator'];
} elseif (array_intersect($user->roles, $allowed_roles1) && array_intersect($user->roles, $allowed_roles3)) {
$menu[997] = ['', 'read', 'separator-1', '', 'wp-menu-separator'];
$menu[998] = ['', 'read', 'separator-2', '', 'wp-menu-separator'];
$menu[999] = ['', 'read', 'separator-4', '', 'wp-menu-separator'];
} elseif(array_intersect($user->roles, $allowed_roles4) && array_intersect($user->roles, $allowed_roles3)) {
$menu[996] = ['', 'read', 'separator-1', '', 'wp-menu-separator'];
$menu[997] = ['', 'read', 'separator-2', '', 'wp-menu-separator'];

} elseif(array_intersect($user->roles, $allowed_roles1)){
$menu[996] = ['', 'read', 'separator-1', '', 'wp-menu-separator'];
$menu[997] = ['', 'read', 'separator-2', '', 'wp-menu-separator'];
$menu[998] = ['', 'read', 'separator-3', '', 'wp-menu-separator'];
$menu[999] = ['', 'read', 'separator-4', '', 'wp-menu-separator'];
} else {
$menu[994] = ['', 'read', 'separator-1', '', 'wp-menu-separator'];
$menu[995] = ['', 'read', 'separator-2', '', 'wp-menu-separator'];
$menu[996] = ['', 'read', 'separator-3', '', 'wp-menu-separator'];
$menu[997] = ['', 'read', 'separator-4', '', 'wp-menu-separator'];
$menu[998] = ['', 'read', 'separator-5', '', 'wp-menu-separator'];
$menu[999] = ['', 'read', 'separator-6', '', 'wp-menu-separator'];
}
}

function change_admin_post_label(){
function change_admin_post_label(){

global $submenu;
$submenu['upload.php'][5][0] = 'All Media';
$submenu['upload.php'][10][0] = 'Add New Media';

// Add Menus as a Department Site submenu and program pages
add_submenu_page( 'edit.php?post_type=department_page', 'Nav Menu', 'Nav Menu', 'edit_posts', 'nav-menus.php');

add_submenu_page( 'edit.php?post_type=programs', 'Nav Menu', 'Nav Menu', 'edit_posts', 'nav-menus.php');
add_menu_page('Owners', 'Owners', 'manage_categories', 'edit-tags.php?taxonomy=category', '', 'dashicons-admin-users');
add_menu_page('Audiences', 'Audiences', 'manage_categories','edit-tags.php?taxonomy=audience', '', 'dashicons-groups');
add_menu_page('Categories', 'Categories', 'manage_categories', 'edit-tags.php?taxonomy=service_type&post_type=service_page',);
add_menu_page('Tags', 'Tags', 'manage_categories', 'edit-tags.php?taxonomy=post_tag', '', 'dashicons-tag');

add_submenu_page('edit.php', 'Announcements', 'Announcements', 'edit_posts', 'edit.php?post_type=announcement');
add_submenu_page('edit.php?post_type=service_page', 'Add Service Page', 'Add Service Page', 'manage_categories', 'post-new.php?post_type=service_page');
add_submenu_page('edit.php?post_type=programs', 'Add Program Page', 'Add Program Page', 'manage_categories', 'post-new.php?post_type=programs');
add_submenu_page('edit.php?post_type=programs', 'Nav Menu', 'Navigation Menu', 'edit_posts', 'nav-menus.php');
add_submenu_page('edit.php?post_type=department_page', 'Add Department Page', 'Add Department Page', 'manage_categories', 'post-new.php?post_type=department_page');
add_submenu_page('edit.php?post_type=department_page', 'Nav Menu', 'Navigation Menu', 'edit_posts', 'nav-menus.php');

remove_menu_page( 'edit.php?post_type=announcement' );

add_submenu_page( 'edit.php', 'Announcements', 'Announcements', 'edit_posts', 'edit.php?post_type=announcement');
remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=category');
remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=post_tag');
remove_submenu_page('edit.php?post_type=service_page', 'edit-tags.php?taxonomy=category&amp;post_type=service_page');
remove_submenu_page('edit.php?post_type=service_page', 'edit-tags.php?taxonomy=audience&amp;post_type=service_page');
remove_submenu_page('edit.php?post_type=service_page', 'edit-tags.php?taxonomy=service_type&amp;post_type=service_page');
remove_submenu_page('edit.php?post_type=programs', 'edit-tags.php?taxonomy=category&amp;post_type=programs');
remove_submenu_page('edit.php?post_type=programs', 'edit-tags.php?taxonomy=audience&amp;post_type=programs');
remove_submenu_page('edit.php?post_type=programs', 'edit-tags.php?taxonomy=service_type&amp;post_type=programs');
remove_submenu_page('edit.php?post_type=department_page', 'edit-tags.php?taxonomy=category&amp;post_type=department_page');
remove_submenu_page('edit.php?post_type=document', 'edit-tags.php?taxonomy=category&amp;post_type=document');
remove_submenu_page('edit.php?post_type=event_spotlight', 'edit-tags.php?taxonomy=category&amp;post_type=event_spotlight');
remove_submenu_page('edit.php?post_type=guides', 'edit-tags.php?taxonomy=category&amp;post_type=guides');
remove_submenu_page('edit.php?post_type=longform_content', 'edit-tags.php?taxonomy=category&amp;post_type=longform_content');
remove_submenu_page('edit.php?post_type=staff_directory', 'edit-tags.php?taxonomy=category&amp;post_type=staff_directory');
remove_submenu_page('edit.php?post_type=calendar', 'edit-tags.php?taxonomy=category&amp;post_type=calendar');
remove_submenu_page('edit.php?post_type=service_updates', 'edit-tags.php?taxonomy=category&amp;post_type=service_updates');

}


function phila_register_categories_for_pages(){

register_taxonomy_for_object_type('category', 'page');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ function create_phila_annoucement() {
),
'exclude_from_search' => true,
'show_in_rest' => true,
'rest_base' => 'announcements',
'public' => false,
'show_ui' => true,
'has_archive' => false,
Expand Down Expand Up @@ -287,6 +288,7 @@ function create_phila_posts() {
),
)
);

}
function create_phila_press_release() {
register_post_type( 'press_release',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ function hierarchical_tags() {
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_rest' => true,
'_builtin' => true,
'rest_base' => 'tags',
) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ ul#department_page-search-checklist li{
width: 75%;
}

.resource-hub{
list-style: disc;
margin-left: 2em;
}

#newpost_tag_parent,
#addtag .form-field.term-parent-wrap {
display: none;
Expand All @@ -211,4 +216,8 @@ ul#department_page-search-checklist li{
/* Override rwmb-columns attempt to make all fields width: 100% */
.rwmb-column .rwmb-input input:not([type="checkbox"]):not([type="radio"]), .rwmb-column .rwmb-input-group, .rwmb-column .rwmb-input select, .rwmb-column .rwmb-input .select2-container {
width: auto !important;
}
}

#adminmenu div.separator{
background-color: rgba(240,246,252,.6);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ function create_phila_department_pages() {
array(
'labels' => array(
'name' => __( 'Department page' ),
'menu_name' => __('Department Site'),
'menu_name' => __('Department Pages'),
'singular_name' => __( 'Department page' ),
'add_new' => __( 'Add a Page' ),
'all_items' => __( 'All Pages' ),
'all_items' => __( 'All Department Pages' ),
'add_new_item' => __( 'Add a Department Page' ),
'edit_item' => __( 'Edit Department Page' ),
'view_item' => __( 'View Department Page' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ function create_phila_event_spotlight() {
'name' => __( 'Event Spotlight page' ),
'menu_name' => __('Event Spotlight'),
'singular_name' => __( 'Event Spotlight page' ),
'add_new' => __( 'Add a Page' ),
'all_items' => __( 'All Pages' ),
'add_new' => __( 'Add Spotlight Page' ),
'all_items' => __( 'All Spotlights' ),
'add_new_item' => __( 'Add a Event Spotlight Page' ),
'edit_item' => __( 'Edit Event Spotlight Page' ),
'view_item' => __( 'View Event Spotlight Page' ),
Expand All @@ -42,7 +42,7 @@ function create_phila_event_spotlight() {
'public' => true,
'has_archive' => true,
'show_in_rest' => true,
'rest_base' => 'spotlight',
'rest_base' => 'spotlights',
'show_in_nav_menus' => true,
'menu_icon' => 'dashicons-calendar',
'hierarchical' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function create_phila_guides() {
'name' => __( 'Guides' ),
'menu_name' => __('Guides '),
'singular_name' => __( 'Guide' ),
'add_new' => __( 'Add a Guide page' ),
'add_new' => __( 'Add Guide page' ),
'all_items' => __( 'All guides' ),
'add_new_item' => __( 'Add a Page' ),
'edit_item' => __( 'Edit a Page' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ jQuery(document).ready(function($){
}

//Hide all category and tag menu items, department authors shouldn't see those.
$('a[href*="edit-tags.php"]').parent().css('display', 'none');

$('a[href="edit-tags.php?taxonomy=category&post_type=calendar"]').parent().css("display", "none");
var menuIdString = $('#menu-id').text().trim();
var allMenuIDs = menuIdString.split(' ');
var match = document.getElementById( allMenuIDs );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ function register_meta_boxes_posts($meta_boxes){
'name' => 'Date for last updated',
'id' => 'last_updated_date',
'type' => 'date',
'required' => true,
'js_options'=> array(
'dateFormat' => 'mm/dd/yy',
'maxDate' => 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ function create_phila_programs_initiatives() {
register_post_type( 'programs',
array(
'labels' => array(
'name' => __( 'Programs + Initiatives' ),
'menu_name' => __('Programs + Initiatives'),
'singular_name' => __( 'Program + Initiative' ),
'add_new' => __( 'Add a Program or Initiative' ),
'all_items' => __( 'All Programs + Initiatives' ),
'name' => __( 'Programs' ),
'menu_name' => __('Programs'),
'singular_name' => __( 'Program ' ),
'add_new' => __( 'Add a Program' ),
'all_items' => __( 'All Programs' ),
'add_new_item' => __( 'Add a Page' ),
'edit_item' => __( 'Edit a Page' ),
'view_item' => __( 'View a Page' ),
'search_items' => __( 'Search Programs + Initiatives Pages' ),
'not_found' => __( 'No Programs + Initiatives Found' ),
'not_found_in_trash' => __( 'Program + Initiative Page not found in trash' ),
'search_items' => __( 'Search Programs Pages' ),
'not_found' => __( 'No Programs Found' ),
'not_found_in_trash' => __( 'Program Page not found in trash' ),
),
'taxonomies' => array('category'),
'supports' => array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function register_template_selection_metabox_programs( $meta_boxes ){
'name' => 'Program hero image',
'type' => 'image_advanced',
'max_file_uploads' => 1,
'desc' => 'Minimum size 700px by 500px. Used on the Programs + initiatives landing page and hero header.',
'desc' => 'Minimum size 700px by 500px. Used on the Programs landing page and hero header.',
'columns' => 3,
),
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function create_phila_service_pages() {
array(
'labels' => array(
'name' => __( 'Services' ),
'menu_name' => __('Service Page'),
'menu_name' => __('Services'),
'singular_name' => __( 'Service Page' ),
'add_new' => __( 'Add a Service Page' ),
'all_items' => __( 'All Service Pages' ),
Expand Down
5 changes: 4 additions & 1 deletion wp/wp-content/plugins/phila.gov-customization/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,7 @@
require $dir. '/public/removals.php';
require $dir. '/public/rewrite-rules.php';

require $dir. '/public/controllers/v2/class-phila-site-wide-alerts-v2.php';
require $dir. '/public/controllers/v2/class-phila-site-wide-alerts-v2.php';
require $dir. '/public/controllers/v2/class-phila-announcements-v2.php';
require $dir. '/public/controllers/v2/class-phila-posts-v2.php';
require $dir. '/public/controllers/v2/class-phila-spotlights-v2.php';
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,7 @@ public function prepare_item_for_response( $post, $request ) {
}

if (isset( $schema['properties']['categories'] )) {
$categories = get_the_category($post->ID);

foreach ($categories as $category){
$trimmed_name = phila_get_owner_typography( $category );

$category->slang_name = html_entity_decode(trim($trimmed_name));
}

$post_data['categories'] = (array) $categories;
$post_data['categories'] = phila_get_the_category( $post->ID );
}

return rest_ensure_response( $post_data );
Expand Down
Loading

0 comments on commit 867a028

Please sign in to comment.