diff --git a/wp/wp-content/plugins/phila.gov-customization/admin/admin-documentation.php b/wp/wp-content/plugins/phila.gov-customization/admin/admin-documentation.php index f12ce79418..c49086abff 100644 --- a/wp/wp-content/plugins/phila.gov-customization/admin/admin-documentation.php +++ b/wp/wp-content/plugins/phila.gov-customization/admin/admin-documentation.php @@ -10,12 +10,6 @@ function phila_resource_hub_page() function phila_resource_hub_content() { ?> -
The following resources may be useful as you create and manage content on phila.gov.
Training presentations, guidance, and tip sheets
This is a collection of training presentations and other guidance produced by the Digital Services team. It also includes:
-Documentation for various WordPress features.
Links to City stock photos and other imagery sources for blogs.
diff --git a/wp/wp-content/plugins/phila.gov-customization/admin/class-phila-gov-admin-menu.php b/wp/wp-content/plugins/phila.gov-customization/admin/class-phila-gov-admin-menu.php index cc9b4a705e..ceee902185 100644 --- a/wp/wp-content/plugins/phila.gov-customization/admin/class-phila-gov-admin-menu.php +++ b/wp/wp-content/plugins/phila.gov-customization/admin/class-phila-gov-admin-menu.php @@ -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') ); } @@ -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', ); } @@ -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&post_type=service_page'); + remove_submenu_page('edit.php?post_type=service_page', 'edit-tags.php?taxonomy=audience&post_type=service_page'); + remove_submenu_page('edit.php?post_type=service_page', 'edit-tags.php?taxonomy=service_type&post_type=service_page'); + remove_submenu_page('edit.php?post_type=programs', 'edit-tags.php?taxonomy=category&post_type=programs'); + remove_submenu_page('edit.php?post_type=programs', 'edit-tags.php?taxonomy=audience&post_type=programs'); + remove_submenu_page('edit.php?post_type=programs', 'edit-tags.php?taxonomy=service_type&post_type=programs'); + remove_submenu_page('edit.php?post_type=department_page', 'edit-tags.php?taxonomy=category&post_type=department_page'); + remove_submenu_page('edit.php?post_type=document', 'edit-tags.php?taxonomy=category&post_type=document'); + remove_submenu_page('edit.php?post_type=event_spotlight', 'edit-tags.php?taxonomy=category&post_type=event_spotlight'); + remove_submenu_page('edit.php?post_type=guides', 'edit-tags.php?taxonomy=category&post_type=guides'); + remove_submenu_page('edit.php?post_type=longform_content', 'edit-tags.php?taxonomy=category&post_type=longform_content'); + remove_submenu_page('edit.php?post_type=staff_directory', 'edit-tags.php?taxonomy=category&post_type=staff_directory'); + remove_submenu_page('edit.php?post_type=calendar', 'edit-tags.php?taxonomy=category&post_type=calendar'); + remove_submenu_page('edit.php?post_type=service_updates', 'edit-tags.php?taxonomy=category&post_type=service_updates'); } + function phila_register_categories_for_pages(){ register_taxonomy_for_object_type('category', 'page'); diff --git a/wp/wp-content/plugins/phila.gov-customization/admin/class-phila-gov-custom-post-types.php b/wp/wp-content/plugins/phila.gov-customization/admin/class-phila-gov-custom-post-types.php index bcb35b712b..23b10d5424 100644 --- a/wp/wp-content/plugins/phila.gov-customization/admin/class-phila-gov-custom-post-types.php +++ b/wp/wp-content/plugins/phila.gov-customization/admin/class-phila-gov-custom-post-types.php @@ -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, @@ -287,6 +288,7 @@ function create_phila_posts() { ), ) ); + } function create_phila_press_release() { register_post_type( 'press_release', diff --git a/wp/wp-content/plugins/phila.gov-customization/admin/class-phila-gov-custom-taxonomies.php b/wp/wp-content/plugins/phila.gov-customization/admin/class-phila-gov-custom-taxonomies.php index b0da9749d9..545c498ccb 100644 --- a/wp/wp-content/plugins/phila.gov-customization/admin/class-phila-gov-custom-taxonomies.php +++ b/wp/wp-content/plugins/phila.gov-customization/admin/class-phila-gov-custom-taxonomies.php @@ -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', ) ); } } diff --git a/wp/wp-content/plugins/phila.gov-customization/admin/css/admin.css b/wp/wp-content/plugins/phila.gov-customization/admin/css/admin.css index 4d765adfb9..7cafde25ab 100644 --- a/wp/wp-content/plugins/phila.gov-customization/admin/css/admin.css +++ b/wp/wp-content/plugins/phila.gov-customization/admin/css/admin.css @@ -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; @@ -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; -} \ No newline at end of file +} + +#adminmenu div.separator{ + background-color: rgba(240,246,252,.6); + } \ No newline at end of file diff --git a/wp/wp-content/plugins/phila.gov-customization/admin/departments/class-phila-gov-cpt-departments.php b/wp/wp-content/plugins/phila.gov-customization/admin/departments/class-phila-gov-cpt-departments.php index 0b0a036b2b..0a9bb08c25 100644 --- a/wp/wp-content/plugins/phila.gov-customization/admin/departments/class-phila-gov-cpt-departments.php +++ b/wp/wp-content/plugins/phila.gov-customization/admin/departments/class-phila-gov-cpt-departments.php @@ -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' ), diff --git a/wp/wp-content/plugins/phila.gov-customization/admin/event-spotlight/class-phila-gov-cpt-event-spotlight.php b/wp/wp-content/plugins/phila.gov-customization/admin/event-spotlight/class-phila-gov-cpt-event-spotlight.php index f1d17c41b7..5abb9b84d4 100644 --- a/wp/wp-content/plugins/phila.gov-customization/admin/event-spotlight/class-phila-gov-cpt-event-spotlight.php +++ b/wp/wp-content/plugins/phila.gov-customization/admin/event-spotlight/class-phila-gov-cpt-event-spotlight.php @@ -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' ), @@ -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, diff --git a/wp/wp-content/plugins/phila.gov-customization/admin/guides/class-phila-gov-cpt-guides.php b/wp/wp-content/plugins/phila.gov-customization/admin/guides/class-phila-gov-cpt-guides.php index 3ec5874d72..a026ceaa35 100644 --- a/wp/wp-content/plugins/phila.gov-customization/admin/guides/class-phila-gov-cpt-guides.php +++ b/wp/wp-content/plugins/phila.gov-customization/admin/guides/class-phila-gov-cpt-guides.php @@ -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' ), diff --git a/wp/wp-content/plugins/phila.gov-customization/admin/js/admin-department-author.js b/wp/wp-content/plugins/phila.gov-customization/admin/js/admin-department-author.js index 0fa1b9a513..1946e38ef1 100644 --- a/wp/wp-content/plugins/phila.gov-customization/admin/js/admin-department-author.js +++ b/wp/wp-content/plugins/phila.gov-customization/admin/js/admin-department-author.js @@ -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 ); diff --git a/wp/wp-content/plugins/phila.gov-customization/admin/meta-boxes/class-phila-gov-post.php b/wp/wp-content/plugins/phila.gov-customization/admin/meta-boxes/class-phila-gov-post.php index 1e0a7c7e11..4a5b620105 100644 --- a/wp/wp-content/plugins/phila.gov-customization/admin/meta-boxes/class-phila-gov-post.php +++ b/wp/wp-content/plugins/phila.gov-customization/admin/meta-boxes/class-phila-gov-post.php @@ -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 diff --git a/wp/wp-content/plugins/phila.gov-customization/admin/programs-initiatives/class-phila-gov-cpt-programs.php b/wp/wp-content/plugins/phila.gov-customization/admin/programs-initiatives/class-phila-gov-cpt-programs.php index d4694a59fb..af605ef5bb 100644 --- a/wp/wp-content/plugins/phila.gov-customization/admin/programs-initiatives/class-phila-gov-cpt-programs.php +++ b/wp/wp-content/plugins/phila.gov-customization/admin/programs-initiatives/class-phila-gov-cpt-programs.php @@ -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( diff --git a/wp/wp-content/plugins/phila.gov-customization/admin/programs-initiatives/class-phila-gov-program-register-templates.php b/wp/wp-content/plugins/phila.gov-customization/admin/programs-initiatives/class-phila-gov-program-register-templates.php index b55bec4419..35608a245e 100644 --- a/wp/wp-content/plugins/phila.gov-customization/admin/programs-initiatives/class-phila-gov-program-register-templates.php +++ b/wp/wp-content/plugins/phila.gov-customization/admin/programs-initiatives/class-phila-gov-program-register-templates.php @@ -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( diff --git a/wp/wp-content/plugins/phila.gov-customization/admin/service-page/class-phila-gov-cpt-service-page.php b/wp/wp-content/plugins/phila.gov-customization/admin/service-page/class-phila-gov-cpt-service-page.php index 9909890509..fb6c52a476 100644 --- a/wp/wp-content/plugins/phila.gov-customization/admin/service-page/class-phila-gov-cpt-service-page.php +++ b/wp/wp-content/plugins/phila.gov-customization/admin/service-page/class-phila-gov-cpt-service-page.php @@ -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' ), diff --git a/wp/wp-content/plugins/phila.gov-customization/index.php b/wp/wp-content/plugins/phila.gov-customization/index.php index ada255fd66..30b81765bf 100644 --- a/wp/wp-content/plugins/phila.gov-customization/index.php +++ b/wp/wp-content/plugins/phila.gov-customization/index.php @@ -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'; \ No newline at end of file +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'; diff --git a/wp/wp-content/plugins/phila.gov-customization/public/controllers/class-phila-documents.php b/wp/wp-content/plugins/phila.gov-customization/public/controllers/class-phila-documents.php index f1f218bbb2..0160c88dd5 100644 --- a/wp/wp-content/plugins/phila.gov-customization/public/controllers/class-phila-documents.php +++ b/wp/wp-content/plugins/phila.gov-customization/public/controllers/class-phila-documents.php @@ -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 ); diff --git a/wp/wp-content/plugins/phila.gov-customization/public/controllers/class-phila-posts.php b/wp/wp-content/plugins/phila.gov-customization/public/controllers/class-phila-posts.php index ada6535402..d463ce0a88 100644 --- a/wp/wp-content/plugins/phila.gov-customization/public/controllers/class-phila-posts.php +++ b/wp/wp-content/plugins/phila.gov-customization/public/controllers/class-phila-posts.php @@ -355,30 +355,11 @@ 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); } if (isset( $schema['properties']['archived'] )) { - $archived = rwmb_meta('phila_archive_post', '', $post->ID); - $phila_template = rwmb_meta('phila_template_select', '', $post->ID); - $post_is_old = false; - if (date('Y-m-d', strtotime('-2 years')) > $post->post_date) { // if posts are 2 years old - $post_is_old = true; - } - if ((((empty( $archived ) || !isset($archived) || $archived == 'default') && $post_is_old) || $archived == 'archive_now') && ($phila_template == 'post' || $phila_template == '')) { - $archived = true; - } else { - $archived = false; - } - $post_data['archived'] = (bool) $archived; + $post_data['archived'] = phila_get_archive_status($post->ID); } if (isset( $schema['properties']['updated_at'] )) { diff --git a/wp/wp-content/plugins/phila.gov-customization/public/controllers/class-phila-programs.php b/wp/wp-content/plugins/phila.gov-customization/public/controllers/class-phila-programs.php index 8f4d9471a1..e404cabfe4 100644 --- a/wp/wp-content/plugins/phila.gov-customization/public/controllers/class-phila-programs.php +++ b/wp/wp-content/plugins/phila.gov-customization/public/controllers/class-phila-programs.php @@ -327,15 +327,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 ); } if (isset( $schema['properties']['audiences'] )) { diff --git a/wp/wp-content/plugins/phila.gov-customization/public/controllers/class-phila-staff-members.php b/wp/wp-content/plugins/phila.gov-customization/public/controllers/class-phila-staff-members.php index faba86b868..aeeec6a33f 100644 --- a/wp/wp-content/plugins/phila.gov-customization/public/controllers/class-phila-staff-members.php +++ b/wp/wp-content/plugins/phila.gov-customization/public/controllers/class-phila-staff-members.php @@ -209,15 +209,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 ); diff --git a/wp/wp-content/plugins/phila.gov-customization/public/controllers/v2/class-phila-announcements-v2.php b/wp/wp-content/plugins/phila.gov-customization/public/controllers/v2/class-phila-announcements-v2.php new file mode 100644 index 0000000000..1260e2566d --- /dev/null +++ b/wp/wp-content/plugins/phila.gov-customization/public/controllers/v2/class-phila-announcements-v2.php @@ -0,0 +1,13 @@ + 'get_phila_announcement_categories' )); +register_rest_field( 'announcement', 'tags', array( 'get_callback' => 'get_phila_announcement_tags' )); + +function get_phila_announcement_categories ( $post ) { + return phila_get_the_category($post['id']); +} + +function get_phila_announcement_tags ( $post ) { + return get_the_tags($post['id']); +} \ No newline at end of file diff --git a/wp/wp-content/plugins/phila.gov-customization/public/controllers/v2/class-phila-posts-v2.php b/wp/wp-content/plugins/phila.gov-customization/public/controllers/v2/class-phila-posts-v2.php new file mode 100644 index 0000000000..9b5fb2e02d --- /dev/null +++ b/wp/wp-content/plugins/phila.gov-customization/public/controllers/v2/class-phila-posts-v2.php @@ -0,0 +1,116 @@ + 'get_archive_status' )); +register_rest_field( 'post', 'categories', array( 'get_callback' => 'get_phila_categories' )); +register_rest_field( 'post', 'template', array( 'get_callback' => 'get_phila_template' )); +register_rest_field( 'post', 'tags', array( 'get_callback' => 'get_phila_tags' )); +register_rest_field( 'post', 'featured_media', array( 'get_callback' => 'get_phila_featured_media' )); + +add_filter( 'rest_post_query', 'filter_post_by_archived', 10, 2 ); +add_filter( 'rest_post_query', 'filter_post_by_featured', 10, 2 ); +add_filter( 'rest_post_query', 'filter_post_by_language', 10, 2 ); +add_filter( 'rest_post_query', 'filter_post_by_template', 10, 2 ); + +function get_phila_template( $post ) { + return phila_get_selected_template($post['id'], true, true); +} + +function get_archive_status( $post ) { + return phila_get_archive_status($post['id']); +} + +function get_phila_categories ( $post ) { + return phila_get_the_category($post['id']); +} + +function get_phila_tags ( $post ) { + return get_the_tags($post['id']); +} + +function get_phila_featured_media ( $post ) { + $featured_image_id = get_post_thumbnail_id($post['id']); + if ( $featured_image_id !== 0) { + $medium_featured_image_url = wp_get_attachment_image_src($featured_image_id, 'medium')[0]; + return $medium_featured_image_url; + } + return null; + +} + +function filter_post_by_archived( $args, $request ) { + $archived = $request->get_param( 'archived' ); + + if ( empty( $archived )) { + return $args; + } + + if ( $archived === 'true' ) { + $archived = 'archive_now'; + } else if ( $archived === 'false' ){ + $archived = 'default'; + } + + $args['meta_query'][] = array( + 'key' => 'phila_archive_post', + 'value' => $archived, + 'compare' => '=', + ); + + return $args; +} + +function filter_post_by_featured( $args, $request ) { + $featured = $request->get_param( 'featured' ); + + if ( empty( $featured )) { + return $args; + } + + if ( $featured == 'true') { + $featured = 1; + } else if ( $featured == 'false' ){ + $featured = 0; + } + + $args['meta_query'][] = array( + 'key' => 'phila_is_feature', + 'value' => $featured, + 'compare' => '=', + ); + + return $args; +} + +function filter_post_by_language( $args, $request ) { + $lang = $request->get_param( 'language' ); + + if ( empty( $lang )) { + return $args; + } + + $args['meta_query'][] = array( + 'key' => 'phila_select_language', + 'value' => $lang, + 'compare' => '=', + ); + + return $args; +} + +//add filter for template +function filter_post_by_template($args, $request) { + $template = $request->get_param( 'template' ); + + if ( empty( $template )) { + return $args; + } + + $args['meta_query'][] = array( + 'key' => 'phila_template_select', + 'value' => $template, + 'compare' => '=', + ); + + return $args; +} \ No newline at end of file diff --git a/wp/wp-content/plugins/phila.gov-customization/public/controllers/v2/class-phila-spotlights-v2.php b/wp/wp-content/plugins/phila.gov-customization/public/controllers/v2/class-phila-spotlights-v2.php new file mode 100644 index 0000000000..be93fac4d9 --- /dev/null +++ b/wp/wp-content/plugins/phila.gov-customization/public/controllers/v2/class-phila-spotlights-v2.php @@ -0,0 +1,41 @@ + 'get_phila_spotlights_categories' )); +register_rest_field( 'event_spotlight', 'active', array( 'get_callback' => 'get_phila_spotlights_active' )); + +// add filter functionality +add_filter( 'rest_event_spotlight_query', 'filter_spotlight_by_active', 10, 2 ); + +function get_phila_spotlights_categories ( $post ) { + return phila_get_the_category($post['id']); +} + +function get_phila_spotlights_active( $post ) { + $is_active = rwmb_meta('spotlight_is_active', '', $post['id']); + return (bool) $is_active; +} + +function filter_spotlight_by_active( $args, $request ) { + $active = $request->get_param( 'active' ); + + if ( empty( $active )) { + return $args; + } + + if ( $active === 'true' ) { + $active = 1; + } else if ( $active === 'false' ){ + $active = 0; + } + + $args['meta_query'] = array( + array( + 'key' => 'spotlight_is_active', + 'value' => $active, + 'compare' => '=', + ), + ); + + return $args; +} \ No newline at end of file diff --git a/wp/wp-content/themes/phila.gov-theme/css/scss/base/_global-nav.scss b/wp/wp-content/themes/phila.gov-theme/css/scss/base/_global-nav.scss index 94f780509e..63179763de 100644 --- a/wp/wp-content/themes/phila.gov-theme/css/scss/base/_global-nav.scss +++ b/wp/wp-content/themes/phila.gov-theme/css/scss/base/_global-nav.scss @@ -11,7 +11,7 @@ .global-nav { @include secondary-font(400); position: relative; - z-index: 1000; + z-index: 998; ul { font-size: 14px; diff --git a/wp/wp-content/themes/phila.gov-theme/functions.php b/wp/wp-content/themes/phila.gov-theme/functions.php index b336fb66fb..a9107c1905 100644 --- a/wp/wp-content/themes/phila.gov-theme/functions.php +++ b/wp/wp-content/themes/phila.gov-theme/functions.php @@ -140,9 +140,6 @@ function phila_content_image_sizes_attr( $sizes, $size ) { return $sizes; } - - - add_filter('pre_get_document_title', 'phila_filter_title'); function phila_filter_title( $title ){ @@ -1249,7 +1246,7 @@ function phila_get_item_meta_desc( $bloginfo = true ){ * **/ -function phila_get_selected_template( $post_id = null, $modify_response = true ){ +function phila_get_selected_template( $post_id = null, $modify_response = true, $deprecate_featured_template = false ){ $user_selected_template = rwmb_meta( 'phila_template_select', $args = array(), $post_id ); @@ -1258,11 +1255,13 @@ function phila_get_selected_template( $post_id = null, $modify_response = true ) } if ($modify_response == true ){ //used to force "featured" template type. The user doesn't select this value from the normal template dropdpown and this can be applied to any post, press release or other item. - $old_feature = get_post_meta( $post_id, 'phila_show_on_home', true); - $new_feature = get_post_meta( $post_id, 'phila_is_feature', true ); + if (!$deprecate_featured_template) { + $old_feature = get_post_meta( $post_id, 'phila_show_on_home', true); + $new_feature = get_post_meta( $post_id, 'phila_is_feature', true ); - if ( $old_feature != 0 || $new_feature != 0 ){ - $user_selected_template = 'featured'; + if ( $old_feature != 0 || $new_feature != 0 ){ + $user_selected_template = 'featured'; + } } //clean up the data by assigning "phila_post" to "post" if(get_post_type($post_id) == 'phila_post') { @@ -1273,6 +1272,34 @@ function phila_get_selected_template( $post_id = null, $modify_response = true ) return $user_selected_template; } + +function phila_get_archive_status( $post_id ) { + $archived = rwmb_meta('phila_archive_post', '', $post_id); + $phila_template = rwmb_meta('phila_template_select', '', $post_id); + $post_is_old = false; + if (date('Y-m-d', strtotime('-2 years')) > get_the_date('Y-m-d', $post_id)) { // if posts are 2 years old + $post_is_old = true; + } + if ((((empty( $archived ) || !isset($archived) || $archived == 'default') && $post_is_old) || $archived == 'archive_now') && ($phila_template == 'post' || $phila_template == '')) { + $archived = true; + } else { + $archived = false; + } + return (bool) $archived; +} + +function phila_get_the_category( $post_id ) { + $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)); + } + + return (array) $categories; +} + /** * Do the math to determine the correct column span for X items on a 24 column grid. * @@ -2200,7 +2227,7 @@ function force_type_private($post, $postarr) { function set_environment() { global $phila_environment; - if (isset($_SERVER['HTTP_HOST'])) { + if (isset($_SERVER['HTTP_HOST'])) { if(strpos($_SERVER['HTTP_HOST'],'staging') !== false) { $phila_environment = 'staging'; diff --git a/wp/wp-content/themes/phila.gov-theme/js/dev/local-storage.js b/wp/wp-content/themes/phila.gov-theme/js/dev/local-storage.js index f2db5a5d24..0fc5ec3d8b 100644 --- a/wp/wp-content/themes/phila.gov-theme/js/dev/local-storage.js +++ b/wp/wp-content/themes/phila.gov-theme/js/dev/local-storage.js @@ -57,6 +57,49 @@ module.exports = $(function(){ english:'Chinese', native:'中文' } + case 'ar': + case 'ara': + return { + english:'Arabic', + native:'عربي' + } + case 'ht': + case 'hat': + return { + english:'Haitian Creole', + native:'Ayisyen' + } + case 'fr': + case 'fre': + case 'fra': + return { + english:'French', + native:'Français' + } + case 'sw': + case 'swa': + return { + english:'Swahili', + native:'Kiswahili' + } + case 'pt': + case 'por': + return { + english:'Portuguese', + native:'Português' + } + case 'ru': + case 'rus': + return { + english:'Russian', + native:'русский' + } + case 'vi': + case 'vie': + return { + english:'Vietnamese', + native:'Tiếng Việt' + } default: return { english:'English', diff --git a/wp/wp-content/themes/phila.gov-theme/js/dev/translations.js b/wp/wp-content/themes/phila.gov-theme/js/dev/translations.js index 35914d36c2..ce989fb46e 100644 --- a/wp/wp-content/themes/phila.gov-theme/js/dev/translations.js +++ b/wp/wp-content/themes/phila.gov-theme/js/dev/translations.js @@ -180,3 +180,4 @@ module.exports = $(function () { //END Translation Bar }); + diff --git a/wp/wp-content/themes/phila.gov-theme/partials/departments/phila_staff_directory_loop.php b/wp/wp-content/themes/phila.gov-theme/partials/departments/phila_staff_directory_loop.php index de3f3f187a..0556bcee9c 100644 --- a/wp/wp-content/themes/phila.gov-theme/partials/departments/phila_staff_directory_loop.php +++ b/wp/wp-content/themes/phila.gov-theme/partials/departments/phila_staff_directory_loop.php @@ -87,7 +87,7 @@ // Leadership Contact Info $staff_leadership_output .= '