From af6e16cdb5f4f0d5d0ff006821109b477f61bb63 Mon Sep 17 00:00:00 2001 From: Jared Rethman Date: Mon, 25 Mar 2024 19:53:14 -0500 Subject: [PATCH 001/557] feat(wizards): new dashboard config and localize script --- includes/wizards/class-dashboard.php | 282 +++++++++++++++++++-------- 1 file changed, 205 insertions(+), 77 deletions(-) diff --git a/includes/wizards/class-dashboard.php b/includes/wizards/class-dashboard.php index 1e390116c2..ee8fb818ee 100644 --- a/includes/wizards/class-dashboard.php +++ b/includes/wizards/class-dashboard.php @@ -46,90 +46,178 @@ public function __construct() { } /** - * Get the information required to build the dashboard. - * Each tier of the dashboard is an array. - * Each card within the tier is an array of [slug, name, url, description]. + * Get Dashboard data * - * @return array + * @return [] */ - protected function get_dashboard() { - $dashboard = [ - [ - 'slug' => 'site-design', - 'name' => Wizards::get_name( 'site-design' ), - 'url' => Wizards::get_url( 'site-design' ), - 'description' => esc_html__( 'Customize the look and feel of your site', 'newspack' ), - ], - [ - 'slug' => 'reader-revenue', - 'name' => Wizards::get_name( 'reader-revenue' ), - 'url' => Wizards::get_url( 'reader-revenue' ), - 'description' => esc_html__( 'Generate revenue from your customers', 'newspack' ), - ], - [ - 'slug' => 'advertising', - 'name' => Wizards::get_name( 'advertising' ), - 'url' => Wizards::get_url( 'advertising' ), - 'description' => esc_html__( 'Monetize your content through ads', 'newspack' ), - ], - [ - 'slug' => 'syndication', - 'name' => Wizards::get_name( 'syndication' ), - 'url' => Wizards::get_url( 'syndication' ), - 'description' => esc_html__( 'Distribute your content across multiple websites', 'newspack' ), - ], - [ - 'slug' => 'analytics', - 'name' => Wizards::get_name( 'analytics' ), - 'url' => Wizards::get_url( 'analytics' ), - 'description' => esc_html__( 'Track traffic and activity', 'newspack' ), + public function get_dashboard() { + return [ + 'audience_development' => [ + 'title' => __( 'Audience development', 'newspack-plugin' ), + 'desc' => __( 'Engage your readers more deeply with tools to build customer relationships that drive towards sustainable revenue.', 'newspack-plugin' ), + 'cards' => [ + [ + 'icon' => 'settings', + 'title' => __( 'Configuration', 'newspack-plugin' ), + 'desc' => __( 'Manage your audience development setup.', 'newspack-plugin' ), + 'href' => '#', // @TODO + ], + [ + 'icon' => 'megaphone', + 'title' => __( 'Campaigns', 'newspack-plugin' ), + 'desc' => __( 'Coordinate prompts across your site to drive metrics.', 'newspack-plugin' ), + 'href' => '#', // @TODO + ], + [ + 'icon' => 'gift', + 'title' => __( 'Donations', 'newspack-plugin' ), + 'desc' => __( 'Bring in revenue through voluntary gifts.', 'newspack-plugin' ), + 'href' => '#', // @TODO + ], + [ + 'icon' => 'payment', + 'title' => __( 'Subscriptions', 'newspack-plugin' ), + 'desc' => __( 'Gate your site\'s content behind a paywall.', 'newspack-plugin' ), + 'href' => '#', // @TODO + ], + ], ], - [ - 'slug' => 'seo', - 'name' => Wizards::get_name( 'seo' ), - 'url' => Wizards::get_url( 'seo' ), - 'description' => esc_html__( 'Configure basic SEO settings', 'newspack' ), + 'newsletters' => [ + 'title' => __( 'Newsletters', 'newspack-plugin' ), + 'desc' => __( 'Engage your readers directly in their email inbox.', 'newspack-plugin' ), + 'dependencies' => [ + 'newspack-newsletters', + ], + 'cards' => [ + [ + 'icon' => 'mail', + 'title' => __( 'All Newsletters', 'newspack-plugin' ), + 'desc' => __( 'See all newsletters you’ve sent out, and start new ones.', 'newspack-plugin' ), + 'href' => admin_url( 'edit.php?post_type=newspack_nl_cpt' ), + ], + [ + 'icon' => 'ad', + 'title' => __( 'Advertising', 'newspack-plugin' ), + 'desc' => __( 'Get advertising revenue from your newsletters.', 'newspack-plugin' ), + 'href' => '#', // @TODO + ], + [ + 'icon' => 'tool', + 'title' => __( 'Settings', 'newspack-plugin' ), + 'desc' => __( 'Configure tracking and other newsletter settings.', 'newspack-plugin' ), + 'href' => '#', // @TODO + ], + ], ], - [ - 'slug' => 'health-check', - 'name' => Wizards::get_name( 'health-check' ), - 'url' => Wizards::get_url( 'health-check' ), - 'description' => esc_html__( 'Verify and correct site health issues', 'newspack' ), + 'advertising' => [ + 'title' => __( 'Advertising', 'newspack-plugin' ), + 'desc' => __( 'Sell space on your site to fund your operations.', 'newspack-plugin' ), + 'dependencies' => [ + 'newspack-ads', + ], + 'cards' => [ + [ + 'icon' => 'ad', + 'title' => __( 'Display Ads', 'newspack-plugin' ), + 'desc' => __( 'Sell programmatic advertising on your site to drive revenue.', 'newspack-plugin' ), + 'href' => admin_url( 'admin.php?page=newspack-advertising-wizard#/' ), + ], + [ + 'icon' => 'currencyDollar', + 'title' => __( 'Sponsors', 'newspack-plugin' ), + 'desc' => __( 'Sell sponsored content directly to purchasers.', 'newspack-plugin' ), + 'href' => admin_url( 'edit.php?post_type=newspack_spnsrs_cpt' ), + ], + ], ], - [ - 'slug' => 'engagement', - 'name' => Wizards::get_name( 'engagement' ), - 'url' => Wizards::get_url( 'engagement' ), - 'description' => esc_html__( 'Newsletters, social, recirculation', 'newspack' ), + 'listings' => [ + 'title' => __( 'Listings', 'newspack-plugin' ), + 'desc' => __( 'Build databases of reusable or user-generated content to use on your site.', 'newspack-plugin' ), + 'dependencies' => [ + 'newspack-listings', + ], + 'cards' => [ + [ + 'icon' => 'blockPostDate', + 'title' => __( 'Events', 'newspack-plugin' ), + 'desc' => __( 'Easily use the same event information across multiple posts.', 'newspack-plugin' ), + 'href' => admin_url( 'edit.php?post_type=newspack_lst_event' ), + ], + [ + 'icon' => 'store', + 'title' => __( 'Marketplace Listings', 'newspack-plugin' ), + 'desc' => __( 'Allow users to list items and services for sale.', 'newspack-plugin' ), + 'href' => admin_url( 'edit.php?post_type=newspack_lst_mktplce' ), + ], + [ + 'icon' => 'postList', + 'title' => __( 'Generic Listing', 'newspack-plugin' ), + 'desc' => __( 'Manage any structured data for use in posts.', 'newspack-plugin' ), + 'href' => admin_url( 'edit.php?post_type=newspack_lst_generic' ), + ], + [ + 'icon' => 'mapMarker', + 'title' => __( 'Places', 'newspack-plugin' ), + 'desc' => __( 'Create a database of places in your coverage area.', 'newspack-plugin' ), + 'href' => admin_url( 'edit.php?post_type=newspack_lst_place' ), + ], + [ + 'icon' => 'tool', + 'title' => __( 'Settings', 'newspack-plugin' ), + 'desc' => __( 'Configure the way that Listings work on your site.', 'newspack-plugin' ), + 'href' => admin_url( 'admin.php?page=newspack-listings-settings-admin' ), + ], + ], + ], - [ - 'slug' => 'popups', - 'name' => Wizards::get_name( 'popups' ), - 'url' => Wizards::get_url( 'popups' ), - 'description' => esc_html__( 'Reach your readers with configurable campaigns', 'newspack' ), - ], - [ - 'slug' => 'connections', - 'name' => Wizards::get_name( 'connections' ), - 'url' => Wizards::get_url( 'connections' ), - 'description' => esc_html__( 'Connections to third-party services', 'newspack' ), + // @TODO HUB vs NODE + 'network' => [ + 'title' => __( 'Network', 'newspack-plugin' ), + 'desc' => __( 'Manage the way your site\'s content flows across your publishing network.', 'newspack-plugin' ), + 'dependencies' => [ + 'newspack-network', + ], + 'cards' => 'node' === get_option( 'newspack_network_site_role', '' ) ? [ + [ + 'icon' => 'tool', + 'title' => __( 'Settings', 'newspack-plugin' ), + 'desc' => __( 'Configure how Newspack Network functions.', 'newspack-plugin' ), + 'href' => '#', // @TODO + ], + ] : [ + [ + 'icon' => 'positionCenterCenter', + 'title' => __( 'Nodes', 'newspack-plugin' ), + 'desc' => __( 'Manage which sites are part of your content network.', 'newspack-plugin' ), + 'href' => admin_url( 'edit.php?post_type=newspack_hub_nodes' ), + ], + [ + 'icon' => 'rotateRight', + 'title' => __( 'Subscriptions', 'newspack-plugin' ), + 'desc' => __( 'View all subscriptions across your network.', 'newspack-plugin' ), + 'href' => admin_url( 'edit.php?post_type=np_hub_subscriptions' ), + ], + [ + 'icon' => 'currencyDollar', + 'title' => __( 'Orders', 'newspack-plugin' ), + 'desc' => __( 'View all payments across your network.', 'newspack-plugin' ), + 'href' => admin_url( 'edit.php?post_type=np_hub_orders' ), + ], + [ + 'icon' => 'formatListBullets', + 'title' => __( 'Event Log', 'newspack-plugin' ), + 'desc' => __( 'Troubleshoot issues by viewing all events across your network.', 'newspack-plugin' ), + 'href' => admin_url( 'admin.php?page=newspack-network-event-log' ), + ], + [ + 'icon' => 'tool', + 'title' => __( 'Settings', 'newspack-plugin' ), + 'desc' => __( 'Configure how Newspack Network functions.', 'newspack-plugin' ), + 'href' => '#', // @TODO + ], + ], ], ]; - - /** - * Filters the dashboard items. - * - * @param array $dashboard { - * Dashboard items. - * - * @type string $slug Slug. - * @type string $name Displayed name. - * @type string $url URL to redirect to. - * @type string $description Item description. - * @type bool $is_externam If true, the URL will be opened in a new window. Optional. - * } - */ - return apply_filters( 'newspack_plugin_dashboard_items', $dashboard ); } /** @@ -183,7 +271,47 @@ public function enqueue_scripts_and_styles() { NEWSPACK_PLUGIN_VERSION, true ); - wp_localize_script( 'newspack-dashboard', 'newspack_dashboard', $this->get_dashboard() ); + $theme_mods = get_theme_mods(); + $logo = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' ); + wp_localize_script( + 'newspack-dashboard', + 'newspack_dashboard', + [ + 'settings' => [ + 'logo' => false === $logo ? [] : $logo, + 'headerBgColor' => $theme_mods['header_color_hex'], + ], + 'sections' => $this->get_dashboard(), + 'plugins' => get_plugins(), + 'siteActions' => [ + 'readerActivation' => [ + 'dependencies' => [ + 'woocommerce' => [ + 'label' => __( 'Woocommerce', 'newspack-plugin' ), + 'isActive' => is_plugin_active( 'woocommerce/woocommerce.php' ), + ], + ], + ], + 'googleAdManager' => [ + 'isAvailable' => OAuth::is_proxy_configured( 'google' ), + 'dependencies' => [ + 'newspack-ads' => [ + 'label' => __( 'Newspack Ads', 'newspack-plugin' ), + 'isActive' => is_plugin_active( 'newspack-ads/newspack-ads.php' ), + ], + ], + ], + 'googleAnalytics' => [ + 'dependencies' => [ + 'google-site-kit' => [ + 'label' => __( 'Google Site Kit', 'newspack-plugin' ), + 'isActive' => is_plugin_active( 'google-site-kit/google-site-kit.php' ), + ], + ], + ], + ], + ] + ); wp_enqueue_script( 'newspack-dashboard' ); wp_register_style( From 512e19749b9ceb26a9fef36e10eef7a35b65f318 Mon Sep 17 00:00:00 2001 From: Jared Rethman Date: Mon, 25 Mar 2024 21:03:18 -0500 Subject: [PATCH 002/557] feat: dashboard & section initial --- assets/components/src/footer/index.js | 2 +- assets/components/src/wizard/index.js | 8 ++-- .../wizards/dashboard/components/sections.tsx | 29 ++++++++++++ assets/wizards/dashboard/index.js | 41 ----------------- assets/wizards/dashboard/index.tsx | 44 +++++++++++++++++++ assets/wizards/dashboard/types/index.d.ts | 28 ++++++++++++ webpack.config.js | 10 +++-- 7 files changed, 113 insertions(+), 49 deletions(-) create mode 100644 assets/wizards/dashboard/components/sections.tsx delete mode 100644 assets/wizards/dashboard/index.js create mode 100644 assets/wizards/dashboard/index.tsx create mode 100644 assets/wizards/dashboard/types/index.d.ts diff --git a/assets/components/src/footer/index.js b/assets/components/src/footer/index.js index 1083b7620c..1179001672 100644 --- a/assets/components/src/footer/index.js +++ b/assets/components/src/footer/index.js @@ -14,7 +14,7 @@ import { ExternalLink } from '@wordpress/components'; import { PatronsLogo } from '../'; import './style.scss'; -const Footer = ( { simple } ) => { +const Footer = ( { simple = undefined } ) => { const { components_demo: componentsDemo = false, support = false, diff --git a/assets/components/src/wizard/index.js b/assets/components/src/wizard/index.js index e43572f4ad..9c3e313c81 100644 --- a/assets/components/src/wizard/index.js +++ b/assets/components/src/wizard/index.js @@ -34,11 +34,11 @@ const { HashRouter, Redirect, Route, Switch } = Router; const Wizard = ( { sections = [], - apiSlug, headerText, - subHeaderText, - hasSimpleFooter, - className, + apiSlug = undefined, + subHeaderText = undefined, + hasSimpleFooter = undefined, + className = undefined, renderAboveSections, requiredPlugins = [], } ) => { diff --git a/assets/wizards/dashboard/components/sections.tsx b/assets/wizards/dashboard/components/sections.tsx new file mode 100644 index 0000000000..8d17afe8a3 --- /dev/null +++ b/assets/wizards/dashboard/components/sections.tsx @@ -0,0 +1,29 @@ +/** + * Newspack - Dashboard, Sections + * + * Component for outputting sections with grid and cards + */ +import { __ } from '@wordpress/i18n'; +import { Fragment } from '@wordpress/element'; +/* eslint import/namespace: ['error', { allowComputed: true }] */ + +const { + newspack_dashboard: { sections: dashSections }, +} = window; + +export default [ + { + label: __( 'Dashboard', 'newspack' ), + path: '/', + render: () => { + const dashSectionsKeys = Object.keys( dashSections ); + return dashSectionsKeys.map( sectionKey => { + return ( + +

{ dashSections[ sectionKey ].title }

+
+ ); + } ); + }, + }, +]; diff --git a/assets/wizards/dashboard/index.js b/assets/wizards/dashboard/index.js deleted file mode 100644 index 750c9bc17a..0000000000 --- a/assets/wizards/dashboard/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* global newspack_dashboard */ - -import '../../shared/js/public-path'; - -/** - * WordPress dependencies. - */ -import { Fragment, render } from '@wordpress/element'; - -/** - * Internal dependencies. - */ -import { GlobalNotices, Footer, Grid, NewspackIcon, Notice } from '../../components/src'; -import DashboardCard from './views/dashboardCard'; -import './style.scss'; - -const Dashboard = ( { items } ) => { - return ( - - - { newspack_aux_data.is_debug_mode && } -
-
-
- -
-
-
- -
- - { items.map( card => ( - - ) ) } - -
-