This commit is contained in:
Justin Shreve 2018-07-10 08:48:06 -04:00 committed by GitHub
parent 5bf87f4ad9
commit 71c12e6795
46 changed files with 341 additions and 341 deletions

View File

@ -11,7 +11,7 @@
[
"@wordpress/babel-plugin-makepot",
{
"output": "languages/woo-dash.pot"
"output": "languages/wc-admin.pot"
}
],
"transform-async-generator-functions"

View File

@ -1,3 +1,4 @@
/* eslint-disable */
module.exports = function( grunt ) {
'use strict';
@ -9,7 +10,7 @@ module.exports = function( grunt ) {
addtextdomain: {
options: {
textdomain: 'woo-dash',
textdomain: 'wc-admin',
},
update_all_domains: {
options: {
@ -24,8 +25,8 @@ module.exports = function( grunt ) {
options: {
domainPath: '/languages',
exclude: [ '\.git/*', 'bin/*', 'node_modules/*', 'tests/*' ],
mainFile: 'woo-dash.php',
potFilename: 'woo-dash.pot',
mainFile: 'wc-admin.php',
potFilename: 'wc-admin.pot',
potHeaders: {
poedit: true,
'x-poedit-keywordslist': true

View File

@ -1,10 +1,10 @@
# WooCommerce Dashboard
# WooCommerce Admin
This is a feature plugin for a modern, javascript-driven dashboard for WooCommerce.
This is a feature plugin for a modern, javascript-driven WooCommerce Admin experience.
## Prerequisites
[Gutenberg](https://wordpress.org/plugins/gutenberg/) and [WooCommerce](https://wordpress.org/plugins/woocommerce/) should be installed prior to activating the WooCommerce Dashboard feature plugin.
[Gutenberg](https://wordpress.org/plugins/gutenberg/) and [WooCommerce](https://wordpress.org/plugins/woocommerce/) should be installed prior to activating the WooCommerce Admin feature plugin. You also need v3 of the WooCommerce REST API via [wc-api-dev](https://github.com/woocommerce/wc-api-dev/) or [the feature branch](https://github.com/woocommerce/woocommerce/tree/feature/rest-api-v3).
For better debugging, it's also recommended you add `define( 'SCRIPT_DEBUG', true );` to your wp-config. This will load the unminified version of all libraries, and specifically the development build of React.

View File

@ -17,7 +17,7 @@ export default class extends Component {
const { query, path } = this.props;
return (
<Fragment>
<Header sections={ [ __( 'Analytics', 'woo-dash' ) ] } />
<Header sections={ [ __( 'Analytics', 'wc-admin' ) ] } />
<DatePicker query={ query } path={ path } />
<p>Example single line button - default width 100% of container</p>
<DropdownButton labels={ [ 'All Products Sold' ] } />

View File

@ -17,24 +17,24 @@ export default class extends Component {
<Fragment>
<Header
sections={ [
[ '/analytics', __( 'Analytics', 'woo-dash' ) ],
__( 'Report Title', 'woo-dash' ),
[ '/analytics', __( 'Analytics', 'wc-admin' ) ],
__( 'Report Title', 'wc-admin' ),
] }
/>
<SummaryList>
<SummaryNumber
value={ '$829.40' }
label={ __( 'Gross Revenue', 'woo-dash' ) }
label={ __( 'Gross Revenue', 'wc-admin' ) }
delta={ 29 }
/>
<SummaryNumber
value={ '$24.00' }
label={ __( 'Refunds', 'woo-dash' ) }
label={ __( 'Refunds', 'wc-admin' ) }
delta={ -10 }
selected
/>
<SummaryNumber value={ '$49.90' } label={ __( 'Coupons', 'woo-dash' ) } delta={ 15 } />
<SummaryNumber value={ '$66.39' } label={ __( 'Tax', 'woo-dash' ) } />
<SummaryNumber value={ '$49.90' } label={ __( 'Coupons', 'wc-admin' ) } delta={ 15 } />
<SummaryNumber value={ '$66.39' } label={ __( 'Tax', 'wc-admin' ) } />
</SummaryList>
</Fragment>
);

View File

@ -97,22 +97,22 @@ class RevenueReport extends Component {
const rows = this.getRowsContent( intervalStats );
const headers = [
__( 'Date', 'woo-dash' ),
__( 'Orders', 'woo-dash' ),
__( 'Gross Revenue', 'woo-dash' ),
__( 'Refunds', 'woo-dash' ),
__( 'Coupons', 'woo-dash' ),
__( 'Taxes', 'woo-dash' ),
__( 'Shipping', 'woo-dash' ),
__( 'Net Revenue', 'woo-dash' ),
__( 'Date', 'wc-admin' ),
__( 'Orders', 'wc-admin' ),
__( 'Gross Revenue', 'wc-admin' ),
__( 'Refunds', 'wc-admin' ),
__( 'Coupons', 'wc-admin' ),
__( 'Taxes', 'wc-admin' ),
__( 'Shipping', 'wc-admin' ),
__( 'Net Revenue', 'wc-admin' ),
];
return (
<Fragment>
<Header
sections={ [
[ '/analytics', __( 'Analytics', 'woo-dash' ) ],
__( 'Revenue', 'woo-dash' ),
[ '/analytics', __( 'Analytics', 'wc-admin' ) ],
__( 'Revenue', 'wc-admin' ),
] }
/>
<DatePicker query={ query } path={ path } />
@ -120,23 +120,23 @@ class RevenueReport extends Component {
<SummaryList>
<SummaryNumber
value={ formatCurrency( summaryStats.gross_revenue ) }
label={ __( 'Gross Revenue', 'woo-dash' ) }
label={ __( 'Gross Revenue', 'wc-admin' ) }
delta={ 29 }
/>
<SummaryNumber
value={ formatCurrency( summaryStats.refunds ) }
label={ __( 'Refunds', 'woo-dash' ) }
label={ __( 'Refunds', 'wc-admin' ) }
delta={ -10 }
selected
/>
<SummaryNumber
value={ formatCurrency( summaryStats.coupons ) }
label={ __( 'Coupons', 'woo-dash' ) }
label={ __( 'Coupons', 'wc-admin' ) }
delta={ 15 }
/>
<SummaryNumber
value={ formatCurrency( summaryStats.taxes ) }
label={ __( 'Taxes', 'woo-dash' ) }
label={ __( 'Taxes', 'wc-admin' ) }
/>
</SummaryList>

View File

@ -28,7 +28,7 @@ const END_DATE = 'endDate';
// 782px is the width designated by Gutenberg's `</ Popover>` component.
// * https://github.com/WordPress/gutenberg/blob/c8f8806d4465a83c1a0bc62d5c61377b56fa7214/components/popover/utils.js#L6
const isMobileViewport = () => window.innerWidth < 782;
const shortDateFormat = __( 'MM/DD/YYYY', 'woo-dash' );
const shortDateFormat = __( 'MM/DD/YYYY', 'wc-admin' );
class DateRange extends Component {
constructor( props ) {
@ -103,7 +103,7 @@ class DateRange extends Component {
value={ afterText }
type="text"
onChange={ partial( this.onInputChange, 'after' ) }
aria-label={ __( 'Start Date', 'woo-dash' ) }
aria-label={ __( 'Start Date', 'wc-admin' ) }
id="after-date-string"
aria-describedby="after-date-string-message"
/>
@ -111,17 +111,17 @@ class DateRange extends Component {
{ sprintf(
__(
"Date input describing a selected date range's start date in format %s",
'woo-dash'
'wc-admin'
),
shortDateFormat
) }
</p>
<span>{ __( 'to', 'woo-dash' ) }</span>
<span>{ __( 'to', 'wc-admin' ) }</span>
<input
value={ beforeText }
type="text"
onChange={ partial( this.onInputChange, 'before' ) }
aria-label={ __( 'End Date', 'woo-dash' ) }
aria-label={ __( 'End Date', 'wc-admin' ) }
id="before-date-string"
aria-describedby="before-date-string-message"
/>
@ -129,7 +129,7 @@ class DateRange extends Component {
{ sprintf(
__(
"Date input describing a selected date range's end date in format %s",
'woo-dash'
'wc-admin'
),
shortDateFormat
) }

View File

@ -5,36 +5,36 @@
import { __, sprintf } from '@wordpress/i18n';
export default {
calendarLabel: __( 'Calendar', 'woo-dash' ),
closeDatePicker: __( 'Close', 'woo-dash' ),
focusStartDate: __( 'Interact with the calendar and select start and end dates.', 'woo-dash' ),
clearDate: __( 'Clear Date', 'woo-dash' ),
clearDates: __( 'Clear Dates', 'woo-dash' ),
jumpToPrevMonth: __( 'Move backward to switch to the previous month.', 'woo-dash' ),
jumpToNextMonth: __( 'Move forward to switch to the next month.', 'woo-dash' ),
enterKey: __( 'Enter key', 'woo-dash' ),
leftArrowRightArrow: __( 'Right and left arrow keys', 'woo-dash' ),
upArrowDownArrow: __( 'up and down arrow keys', 'woo-dash' ),
pageUpPageDown: __( 'page up and page down keys', 'woo-dash' ),
homeEnd: __( 'Home and end keys', 'woo-dash' ),
escape: __( 'Escape key', 'woo-dash' ),
questionMark: __( 'Question mark', 'woo-dash' ),
selectFocusedDate: __( 'Select the date in focus.', 'woo-dash' ),
moveFocusByOneDay: __( 'Move backward (left) and forward (right) by one day.', 'woo-dash' ),
moveFocusByOneWeek: __( 'Move backward (up) and forward (down) by one week.', 'woo-dash' ),
moveFocusByOneMonth: __( 'Switch months.', 'woo-dash' ),
moveFocustoStartAndEndOfWeek: __( 'Go to the first or last day of a week.', 'woo-dash' ),
returnFocusToInput: __( 'Return to the date input field.', 'woo-dash' ),
calendarLabel: __( 'Calendar', 'wc-admin' ),
closeDatePicker: __( 'Close', 'wc-admin' ),
focusStartDate: __( 'Interact with the calendar and select start and end dates.', 'wc-admin' ),
clearDate: __( 'Clear Date', 'wc-admin' ),
clearDates: __( 'Clear Dates', 'wc-admin' ),
jumpToPrevMonth: __( 'Move backward to switch to the previous month.', 'wc-admin' ),
jumpToNextMonth: __( 'Move forward to switch to the next month.', 'wc-admin' ),
enterKey: __( 'Enter key', 'wc-admin' ),
leftArrowRightArrow: __( 'Right and left arrow keys', 'wc-admin' ),
upArrowDownArrow: __( 'up and down arrow keys', 'wc-admin' ),
pageUpPageDown: __( 'page up and page down keys', 'wc-admin' ),
homeEnd: __( 'Home and end keys', 'wc-admin' ),
escape: __( 'Escape key', 'wc-admin' ),
questionMark: __( 'Question mark', 'wc-admin' ),
selectFocusedDate: __( 'Select the date in focus.', 'wc-admin' ),
moveFocusByOneDay: __( 'Move backward (left) and forward (right) by one day.', 'wc-admin' ),
moveFocusByOneWeek: __( 'Move backward (up) and forward (down) by one week.', 'wc-admin' ),
moveFocusByOneMonth: __( 'Switch months.', 'wc-admin' ),
moveFocustoStartAndEndOfWeek: __( 'Go to the first or last day of a week.', 'wc-admin' ),
returnFocusToInput: __( 'Return to the date input field.', 'wc-admin' ),
keyboardNavigationInstructions: __(
`Press the down arrow key to interact with the calendar and
select a date.`,
'woo-dash'
'wc-admin'
),
chooseAvailableStartDate: ( { date } ) =>
sprintf( __( 'Select %s as a start date.', 'woo-dash' ), date ),
sprintf( __( 'Select %s as a start date.', 'wc-admin' ), date ),
chooseAvailableEndDate: ( { date } ) =>
sprintf( __( 'Select %s as an end date.', 'woo-dash' ), date ),
sprintf( __( 'Select %s as an end date.', 'wc-admin' ), date ),
chooseAvailableDate: ( { date } ) => date,
dateIsUnavailable: ( { date } ) => sprintf( __( '%s is not selectable.', 'woo-dash' ), date ),
dateIsSelected: ( { date } ) => sprintf( __( 'Selected. %s', 'woo-dash' ), date ),
dateIsUnavailable: ( { date } ) => sprintf( __( '%s is not selectable.', 'wc-admin' ), date ),
dateIsSelected: ( { date } ) => sprintf( __( 'Selected. %s', 'wc-admin' ), date ),
};

View File

@ -11,7 +11,7 @@ import './style.scss';
const Count = ( { count, label } ) => {
if ( ! label ) {
label = sprintf( __( 'Total %d', 'woo-dash' ), count );
label = sprintf( __( 'Total %d', 'wc-admin' ), count );
}
return (

View File

@ -12,8 +12,8 @@ import PropTypes from 'prop-types';
import SegmentedSelection from 'components/segmented-selection';
const compareValues = [
{ value: 'previous_period', label: __( 'Previous Period', 'woo-dash' ) },
{ value: 'previous_year', label: __( 'Previous Year', 'woo-dash' ) },
{ value: 'previous_period', label: __( 'Previous Period', 'wc-admin' ) },
{ value: 'previous_year', label: __( 'Previous Year', 'wc-admin' ) },
];
class ComparePeriods extends Component {
@ -25,7 +25,7 @@ class ComparePeriods extends Component {
selected={ compare }
onSelect={ onSelect }
name="compare"
legend={ __( 'compare to', 'woo-dash' ) }
legend={ __( 'compare to', 'wc-admin' ) }
/>
);
}

View File

@ -48,22 +48,22 @@ class DatePickerContent extends Component {
return (
<Fragment>
<H className="screen-reader-text" tabIndex="0">
{ __( 'Select date range and comparison', 'woo-dash' ) }
{ __( 'Select date range and comparison', 'wc-admin' ) }
</H>
<Section component={ false }>
<H className="woocommerce-date-picker__text">
{ __( 'select a date range', 'woo-dash' ) }
{ __( 'select a date range', 'wc-admin' ) }
</H>
<TabPanel
tabs={ [
{
name: 'period',
title: __( 'Presets', 'woo-dash' ),
title: __( 'Presets', 'wc-admin' ),
className: 'woocommerce-date-picker__tab',
},
{
name: 'custom',
title: __( 'Custom', 'woo-dash' ),
title: __( 'Custom', 'wc-admin' ),
className: 'woocommerce-date-picker__tab',
},
] }
@ -89,7 +89,7 @@ class DatePickerContent extends Component {
inValidDays="future"
/>
) }
<H className="woocommerce-date-picker__text">{ __( 'compare to', 'woo-dash' ) }</H>
<H className="woocommerce-date-picker__text">{ __( 'compare to', 'wc-admin' ) }</H>
<ComparePeriods onSelect={ onSelect } compare={ compare } />
{ isValidSelection( selectedTab ) ? (
<Link
@ -97,11 +97,11 @@ class DatePickerContent extends Component {
to={ getUpdatePath( selectedTab ) }
onClick={ onClose }
>
{ __( 'Update', 'woo-dash' ) }
{ __( 'Update', 'wc-admin' ) }
</Link>
) : (
<Button className="woocommerce-date-picker__update-btn" isPrimary disabled>
{ __( 'Update', 'woo-dash' ) }
{ __( 'Update', 'wc-admin' ) }
</Button>
) }
</Fragment>

View File

@ -72,7 +72,7 @@ class DatePicker extends Component {
const { primary, secondary } = getCurrentDates( queryWithDefaults );
return [
`${ primary.label } (${ primary.range })`,
`${ __( 'vs.', 'woo-dash' ) } ${ secondary.label } (${ secondary.range })`,
`${ __( 'vs.', 'wc-admin' ) } ${ secondary.label } (${ secondary.range })`,
];
}
@ -88,7 +88,7 @@ class DatePicker extends Component {
const { period, compare, after, before } = this.state;
return (
<Fragment>
<p>{ __( 'Date Range', 'woo-dash' ) }:</p>
<p>{ __( 'Date Range', 'wc-admin' ) }:</p>
<Dropdown
className="woocommerce-date-picker"
contentClassName="woocommerce-date-picker__content"

View File

@ -13,17 +13,17 @@ import PropTypes from 'prop-types';
import SegmentedSelection from 'components/segmented-selection';
const presetValues = [
{ value: 'today', label: __( 'Today', 'woo-dash' ) },
{ value: 'yesterday', label: __( 'Yesterday', 'woo-dash' ) },
{ value: 'week', label: __( 'Week to Date', 'woo-dash' ) },
{ value: 'last_week', label: __( 'Last Week', 'woo-dash' ) },
{ value: 'month', label: __( 'Month to Date', 'woo-dash' ) },
{ value: 'last_month', label: __( 'Last Month', 'woo-dash' ) },
{ value: 'quarter', label: __( 'Quarter to Date', 'woo-dash' ) },
{ value: 'last_quarter', label: __( 'Last Quarter', 'woo-dash' ) },
{ value: 'year', label: __( 'Year to Date', 'woo-dash' ) },
{ value: 'last_year', label: __( 'Last Year', 'woo-dash' ) },
{ value: 'custom', label: __( 'Custom', 'woo-dash' ) },
{ value: 'today', label: __( 'Today', 'wc-admin' ) },
{ value: 'yesterday', label: __( 'Yesterday', 'wc-admin' ) },
{ value: 'week', label: __( 'Week to Date', 'wc-admin' ) },
{ value: 'last_week', label: __( 'Last Week', 'wc-admin' ) },
{ value: 'month', label: __( 'Month to Date', 'wc-admin' ) },
{ value: 'last_month', label: __( 'Last Month', 'wc-admin' ) },
{ value: 'quarter', label: __( 'Quarter to Date', 'wc-admin' ) },
{ value: 'last_quarter', label: __( 'Last Quarter', 'wc-admin' ) },
{ value: 'year', label: __( 'Year to Date', 'wc-admin' ) },
{ value: 'last_year', label: __( 'Last Year', 'wc-admin' ) },
{ value: 'custom', label: __( 'Custom', 'wc-admin' ) },
];
class PresetPeriods extends Component {
@ -35,7 +35,7 @@ class PresetPeriods extends Component {
selected={ period }
onSelect={ onSelect }
name="period"
legend={ __( 'select a preset period', 'woo-dash' ) }
legend={ __( 'select a preset period', 'wc-admin' ) }
/>
);
}

View File

@ -1,11 +1,8 @@
/** @format */
/**
* External dependencies
*/
import { debounce, isArray, uniqueId } from 'lodash';
/**
* WordPress dependencies
*/
import { Component } from '@wordpress/element';
import { addAction, removeAction } from '@wordpress/hooks';
@ -30,7 +27,7 @@ export default function useFilters( hookName ) {
super( props );
this.onHooksUpdated = this.onHooksUpdated.bind( this );
this.namespace = uniqueId( 'woo-dash/use-filters/component-' );
this.namespace = uniqueId( 'wc-admin/use-filters/component-' );
this.throttledForceUpdate = debounce( () => {
this.forceUpdate();
}, ANIMATION_FRAME_PERIOD );

View File

@ -22,7 +22,7 @@ class Link extends Component {
);
}
const path = wpAdmin ? getAdminLink( to ) : getAdminLink( 'admin.php?page=woodash#' + to );
const path = wpAdmin ? getAdminLink( to ) : getAdminLink( 'admin.php?page=wcadmin#' + to );
return (
<a href={ path } { ...props }>
{ children }

View File

@ -109,7 +109,7 @@ class Pagination extends Component {
role="status"
aria-live="polite"
>
{ sprintf( __( 'Page %d of %d', 'woo-dash' ), page, this.pageCount ) }
{ sprintf( __( 'Page %d of %d', 'wc-admin' ), page, this.pageCount ) }
</span>
<div className="woocommerce-pagination__page-arrows-buttons">
<IconButton
@ -117,7 +117,7 @@ class Pagination extends Component {
disabled={ ! ( page > 1 ) }
onClick={ this.previousPage }
icon="arrow-left-alt2"
label={ __( 'Previous Page', 'woo-dash' ) }
label={ __( 'Previous Page', 'wc-admin' ) }
size={ 18 }
/>
<IconButton
@ -125,7 +125,7 @@ class Pagination extends Component {
disabled={ ! ( page < this.pageCount ) }
onClick={ this.nextPage }
icon="arrow-right-alt2"
label={ __( 'Next Page', 'woo-dash' ) }
label={ __( 'Next Page', 'wc-admin' ) }
size={ 18 }
/>
</div>
@ -143,7 +143,7 @@ class Pagination extends Component {
return (
<div className="woocommerce-pagination__page-picker">
<label htmlFor={ instanceId } className="woocommerce-pagination__page-picker-label">
{ __( 'Go to page', 'woo-dash' ) }
{ __( 'Go to page', 'wc-admin' ) }
<input
id={ instanceId }
className={ inputClass }
@ -166,7 +166,7 @@ class Pagination extends Component {
return (
<div className="woocommerce-pagination__per-page-picker">
<SelectControl
label={ __( 'Rows per page', 'woo-dash' ) }
label={ __( 'Rows per page', 'wc-admin' ) }
value={ this.props.perPage }
onChange={ this.perPageChange }
options={ [

View File

@ -11,9 +11,9 @@ import { SummaryList, SummaryNumber } from 'components/summary';
render: function() {
return (
<SummaryList>
<SummaryNumber value={ '$829.40' } label={ __( 'Gross Revenue', 'woo-dash' ) } delta={ 29 } />
<SummaryNumber value={ '$24.00' } label={ __( 'Refunds', 'woo-dash' ) } delta={ -10 } selected />
<SummaryNumber value={ '$49.90' } label={ __( 'Coupons', 'woo-dash' ) } />
<SummaryNumber value={ '$829.40' } label={ __( 'Gross Revenue', 'wc-admin' ) } delta={ 29 } />
<SummaryNumber value={ '$24.00' } label={ __( 'Refunds', 'wc-admin' ) } delta={ -10 } selected />
<SummaryNumber value={ '$49.90' } label={ __( 'Coupons', 'wc-admin' ) } />
</SummaryList>
);
}

View File

@ -12,7 +12,7 @@ import './style.scss';
const SummaryList = ( { children, label } ) => {
if ( ! label ) {
label = __( 'Performance Indicators', 'woo-dash' );
label = __( 'Performance Indicators', 'wc-admin' );
}
return (
<ul className="woocommerce-summary" aria-label={ label }>

View File

@ -9,7 +9,7 @@ import PropTypes from 'prop-types';
const SummaryNumber = ( { context, delta, label, selected, value } ) => {
if ( ! context ) {
context = __( 'vs Previous Period', 'woo-dash' );
context = __( 'vs Previous Period', 'wc-admin' );
}
const classes = classnames( 'woocommerce-summary__item', {

View File

@ -85,7 +85,7 @@ class Table extends Component {
<table className="woocommerce-table__table">
<caption id={ this.captionID } className="woocommerce-table__caption">
{ caption }
{ tabIndex === '0' && <small>{ __( '(scroll to see more)', 'woo-dash' ) }</small> }
{ tabIndex === '0' && <small>{ __( '(scroll to see more)', 'wc-admin' ) }</small> }
</caption>
<tbody>
<tr>
@ -104,8 +104,8 @@ class Table extends Component {
icon={ sortDir !== ASC ? 'arrow-up' : 'arrow-down' }
label={
sortDir !== ASC
? sprintf( __( 'Sort by %s in ascending order', 'woo-dash' ), header )
: sprintf( __( 'Sort by %s in descending order', 'woo-dash' ), header )
? sprintf( __( 'Sort by %s in ascending order', 'wc-admin' ), header )
: sprintf( __( 'Sort by %s in descending order', 'wc-admin' ), header )
}
onClick={ () => this.sortBy( i ) }
/>

View File

@ -19,19 +19,19 @@ class WidgetCharts extends Component {
render() {
return (
<Card title={ __( 'Store Charts', 'woo-dash' ) }>
<div className="woo-dash__widget">
<Card title={ __( 'Store Charts', 'wc-admin' ) }>
<div className="woocommerce-dashboard__widget">
<D3Chart
className="woo-dash__widget-bar-chart"
className="woocommerce-dashboard__widget-bar-chart"
data={ dummyOrders }
height={ 300 }
type={ 'line' }
width={ 1042 }
/>
</div>
<div className="woo-dash__widget">
<div className="woocommerce-dashboard__widget">
<D3Chart
className="woo-dash__widget-bar-chart"
className="woocommerce-dashboard__widget-bar-chart"
data={ dummyOrders }
height={ 300 }
type={ 'bar' }

View File

@ -17,7 +17,7 @@ export default class Dashboard extends Component {
render() {
return (
<Fragment>
<Header sections={ [ __( 'Dashboard', 'woo-dash' ) ] } />
<Header sections={ [ __( 'Dashboard', 'wc-admin' ) ] } />
<StorePerformance />
<Agenda />
<Charts />

View File

@ -34,25 +34,25 @@ class StorePerformance extends Component {
renderMenu() {
return (
<EllipsisMenu label={ __( 'Choose which analytics to display', 'woo-dash' ) }>
<MenuTitle>{ __( 'Display Stats:', 'woo-dash' ) }</MenuTitle>
<EllipsisMenu label={ __( 'Choose which analytics to display', 'wc-admin' ) }>
<MenuTitle>{ __( 'Display Stats:', 'wc-admin' ) }</MenuTitle>
<MenuItem onInvoke={ this.toggle( 'showCustomers' ) }>
<ToggleControl
label={ __( 'Show Customers', 'woo-dash' ) }
label={ __( 'Show Customers', 'wc-admin' ) }
checked={ this.state.showCustomers }
onChange={ this.toggle( 'showCustomers' ) }
/>
</MenuItem>
<MenuItem onInvoke={ this.toggle( 'showProducts' ) }>
<ToggleControl
label={ __( 'Show Products', 'woo-dash' ) }
label={ __( 'Show Products', 'wc-admin' ) }
checked={ this.state.showProducts }
onChange={ this.toggle( 'showProducts' ) }
/>
</MenuItem>
<MenuItem onInvoke={ this.toggle( 'showOrders' ) }>
<ToggleControl
label={ __( 'Show Orders', 'woo-dash' ) }
label={ __( 'Show Orders', 'wc-admin' ) }
checked={ this.state.showOrders }
onChange={ this.toggle( 'showOrders' ) }
/>
@ -69,22 +69,22 @@ class StorePerformance extends Component {
return (
<Card
title={ __( 'Store Performance', 'woo-dash' ) }
title={ __( 'Store Performance', 'wc-admin' ) }
menu={ this.renderMenu() }
className="woocommerce-dashboard__store-performance"
>
<SummaryList>
{ showCustomers && (
<SummaryNumber value={ '2' } label={ __( 'New Customers', 'woo-dash' ) } delta={ 15 } />
<SummaryNumber value={ '2' } label={ __( 'New Customers', 'wc-admin' ) } delta={ 15 } />
) }
{ showProducts && (
<SummaryNumber value={ totalProducts } label={ __( 'Total Products', 'woo-dash' ) } />
<SummaryNumber value={ totalProducts } label={ __( 'Total Products', 'wc-admin' ) } />
) }
{ showOrders && (
<SummaryNumber
value={ totalOrders }
selected
label={ __( 'Total Orders', 'woo-dash' ) }
label={ __( 'Total Orders', 'wc-admin' ) }
delta={ -6 }
/>
) }

View File

@ -42,20 +42,20 @@ render: function() {
'Order needs to be fulfilled',
'Orders need to be fulfilled',
2,
'woo-dash'
'wc-admin'
) }
>
<AgendaItem onClick={ noop } actionLabel={ __( 'Fulfill', 'woo-dash' ) }>Order #99</AgendaItem>
<AgendaItem onClick={ noop } actionLabel={ __( 'Fulfill', 'wc-admin' ) }>Order #99</AgendaItem>
<AgendaItem
href={ getWpAdminLink( '/edit.php?post_type=shop_order' ) }
actionLabel={ __( 'Fulfill', 'woo-dash' ) }
actionLabel={ __( 'Fulfill', 'wc-admin' ) }
>
Order #101
</AgendaItem>
</AgendaHeader>
<AgendaHeader
count={ 1 }
title={ _n( 'Order awaiting payment', 'Orders awaiting payment', 1, 'woo-dash' ) }
title={ _n( 'Order awaiting payment', 'Orders awaiting payment', 1, 'wc-admin' ) }
href={ getWpAdminLink( '/edit.php?post_status=wc-pending&post_type=shop_order' ) }
/>
</div>

View File

@ -21,7 +21,7 @@ class Agenda extends Component {
render() {
return (
<Card
title={ __( 'Your agenda', 'woo-dash' ) }
title={ __( 'Your agenda', 'wc-admin' ) }
className="woocommerce-dashboard__agenda-card"
>
<AgendaHeader
@ -30,26 +30,26 @@ class Agenda extends Component {
'Order needs to be fulfilled',
'Orders need to be fulfilled',
2,
'woo-dash'
'wc-admin'
) }
>
<AgendaItem onClick={ noop } actionLabel={ __( 'Fulfill', 'woo-dash' ) }>
<AgendaItem onClick={ noop } actionLabel={ __( 'Fulfill', 'wc-admin' ) }>
Order #99
</AgendaItem>
<AgendaItem
href={ getAdminLink( '/edit.php?post_type=shop_order' ) }
actionLabel={ __( 'Fulfill', 'woo-dash' ) }
actionLabel={ __( 'Fulfill', 'wc-admin' ) }
>
Order #101
</AgendaItem>
</AgendaHeader>
<AgendaHeader
count={ 1 }
title={ _n( 'Order awaiting payment', 'Orders awaiting payment', 1, 'woo-dash' ) }
title={ _n( 'Order awaiting payment', 'Orders awaiting payment', 1, 'wc-admin' ) }
href={ getAdminLink( '/edit.php?post_status=wc-pending&post_type=shop_order' ) }
/>
<AgendaHeader
title={ __( 'Extensions', 'woo-dash' ) }
title={ __( 'Extensions', 'wc-admin' ) }
href={ getAdminLink( '/admin.php?page=wc-addons' ) }
/>
</Card>

View File

@ -12,7 +12,7 @@ import ActivityHeader from './activity-header';
class InboxPanel extends Component {
render() {
return <ActivityHeader title={ __( 'Inbox', 'woo-dash' ) } />;
return <ActivityHeader title={ __( 'Inbox', 'wc-admin' ) } />;
}
}

View File

@ -85,25 +85,25 @@ class ActivityPanel extends Component {
return [
{
name: 'inbox',
title: __( 'Inbox', 'woo-dash' ),
title: __( 'Inbox', 'wc-admin' ),
icon: <Gridicon icon="mail" />,
unread: true,
},
{
name: 'orders',
title: __( 'Orders', 'woo-dash' ),
title: __( 'Orders', 'wc-admin' ),
icon: <Gridicon icon="pages" />,
unread: false,
},
{
name: 'stock',
title: __( 'Stock', 'woo-dash' ),
title: __( 'Stock', 'wc-admin' ),
icon: <Gridicon icon="clipboard" />,
unread: true,
},
{
name: 'reviews',
title: __( 'Reviews', 'woo-dash' ),
title: __( 'Reviews', 'wc-admin' ),
icon: <Gridicon icon="star" />,
unread: true,
},

View File

@ -30,7 +30,7 @@ function OrdersPanel( { orders } ) {
return (
<Fragment>
<ActivityHeader title={ __( 'Orders', 'woo-dash' ) } menu={ menu } />
<ActivityHeader title={ __( 'Orders', 'wc-admin' ) } menu={ menu } />
<Section>
{ isLoading ? (
<p>Loading</p>
@ -51,15 +51,15 @@ function OrdersPanel( { orders } ) {
return (
<ActivityCard
key={ i }
label={ __( 'Order', 'woo-dash' ) }
label={ __( 'Order', 'wc-admin' ) }
icon={ <Dashicon icon="format-aside" /> }
date={ order.date_created }
>
<div>{ sprintf( __( '%s placed order #%d', 'woo-dash' ), name, order.id ) }</div>
<div>{ sprintf( __( '%s placed order #%d', 'wc-admin' ), name, order.id ) }</div>
<div>
<span>
{ sprintf(
_n( '%d product', '%d products', productsCount, 'woo-dash' ),
_n( '%d product', '%d products', productsCount, 'wc-admin' ),
productsCount
) }
</span>{' '}

View File

@ -12,7 +12,7 @@ import ActivityHeader from './activity-header';
class ReviewsPanel extends Component {
render() {
return <ActivityHeader title={ __( 'Reviews', 'woo-dash' ) } />;
return <ActivityHeader title={ __( 'Reviews', 'wc-admin' ) } />;
}
}

View File

@ -12,7 +12,7 @@ import ActivityHeader from './activity-header';
class StockPanel extends Component {
render() {
return <ActivityHeader title={ __( 'Stock', 'woo-dash' ) } />;
return <ActivityHeader title={ __( 'Stock', 'wc-admin' ) } />;
}
}

View File

@ -103,7 +103,7 @@ class WordPressNotices extends Component {
this.setState( { count, notices, noticesOpen } );
// Move collapsed WordPress notifications into the main WooDash body
// Move collapsed WordPress notifications into the main wc-admin body
collapsedTargetArea.insertAdjacentElement( 'beforeend', notices );
}
@ -197,7 +197,7 @@ class WordPressNotices extends Component {
onClick={ partial( togglePanel, 'wpnotices' ) }
icon={ <Gridicon icon="my-sites" /> }
>
{ __( 'Notices', 'woo-dash' ) }
{ __( 'Notices', 'wc-admin' ) }
</IconButton>
);
}

View File

@ -23,12 +23,12 @@ const getPages = () => {
{
container: Analytics,
path: '/analytics',
wpMenu: 'toplevel_page_woodash--analytics',
wpMenu: 'toplevel_page_wc-admin--analytics',
},
{
container: AnalyticsReport,
path: '/analytics/:report',
wpMenu: 'toplevel_page_woodash--analytics',
wpMenu: 'toplevel_page_wc-admin--analytics',
},
];
@ -57,7 +57,7 @@ window.wpNavMenuClassChange = function( menuClass ) {
.removeClass( 'wp-menu-open' )
.removeClass( 'selected' )
.addClass( 'wp-not-current-submenu menu-top' );
jQuery( 'li > a[href$="admin.php?page=woodash' + window.location.hash + '"]' )
jQuery( 'li > a[href$="admin.php?page=wc-admin' + window.location.hash + '"]' )
.parent()
.addClass( 'current' );
jQuery( '#' + menuClass )

View File

@ -12,8 +12,8 @@ render: function() {
return (
<Header
sections={ [
[ '/analytics', __( 'Analytics', 'woo-dash' ) ],
__( 'Report Title', 'woo-dash' ),
[ '/analytics', __( 'Analytics', 'wc-admin' ) ],
__( 'Report Title', 'wc-admin' ),
] }
/>
);
@ -22,5 +22,5 @@ render: function() {
## Props
* `sections` (required): Used to generate breadcrumbs. Accepts a single items or an array of items. To make an item a link, wrap it in an array with a relative link (example: `[ '/analytics', __( 'Analytics', 'woo-dash' ) ]` ).
* `sections` (required): Used to generate breadcrumbs. Accepts a single items or an array of items. To make an item a link, wrap it in an array with a relative link (example: `[ '/analytics', __( 'Analytics', 'wc-admin' ) ]` ).
* `isEmbedded`: Boolean describing if the header is embedded on an existing wp-admin page. False if rendered as part of a full react page.

View File

@ -67,7 +67,7 @@ class Header extends Component {
document.title = decodeEntities(
sprintf(
__( '%1$s &lsaquo; %2$s &#8212; WooCommerce', 'woo-dash' ),
__( '%1$s &lsaquo; %2$s &#8212; WooCommerce', 'wc-admin' ),
documentTitle,
wpApiSettings.schema.name
)

View File

@ -54,8 +54,8 @@ export function getRangeLabel( after, before ) {
const isSameDay = after.isSame( before, 'day' );
const isSameYear = after.year() === before.year();
const isSameMonth = isSameYear && after.month() === before.month();
const fullDateFormat = __( 'MMM D, YYYY', 'woo-dash' );
const monthDayFormat = __( 'MMM D', 'woo-dash' );
const fullDateFormat = __( 'MMM D, YYYY', 'wc-admin' );
const monthDayFormat = __( 'MMM D', 'wc-admin' );
if ( isSameDay ) {
return after.format( fullDateFormat );
@ -250,19 +250,19 @@ export function loadLocaleData() {
if ( ! userLocale.match( /en_/ ) ) {
moment.updateLocale( userLocale, {
longDateFormat: {
L: __( 'MM/DD/YYYY', 'woo-dash' ),
LL: __( 'MMMM D, YYYY', 'woo-dash' ),
LLL: __( 'D MMMM YYYY LT', 'woo-dash' ),
LLLL: __( 'dddd, D MMMM YYYY LT', 'woo-dash' ),
LT: __( 'HH:mm', 'woo-dash' ),
L: __( 'MM/DD/YYYY', 'wc-admin' ),
LL: __( 'MMMM D, YYYY', 'wc-admin' ),
LLL: __( 'D MMMM YYYY LT', 'wc-admin' ),
LLLL: __( 'dddd, D MMMM YYYY LT', 'wc-admin' ),
LT: __( 'HH:mm', 'wc-admin' ),
},
calendar: {
lastDay: __( '[Yesterday at] LT', 'woo-dash' ),
lastWeek: __( '[Last] dddd [at] LT', 'woo-dash' ),
nextDay: __( '[Tomorrow at] LT', 'woo-dash' ),
nextWeek: __( 'dddd [at] LT', 'woo-dash' ),
sameDay: __( '[Today at] LT', 'woo-dash' ),
sameElse: __( 'L', 'woo-dash' ),
lastDay: __( '[Yesterday at] LT', 'wc-admin' ),
lastWeek: __( '[Last] dddd [at] LT', 'wc-admin' ),
nextDay: __( '[Tomorrow at] LT', 'wc-admin' ),
nextWeek: __( 'dddd [at] LT', 'wc-admin' ),
sameDay: __( '[Today at] LT', 'wc-admin' ),
sameElse: __( 'L', 'wc-admin' ),
},
week: {
dow: Number( date.dow ),

View File

@ -22,7 +22,7 @@
@include breakpoint( '>960px' ) {
#toplevel_page_woocommerce.menu-top > a:focus,
#toplevel_page_woodash--analytics.menu-top > a:focus {
#toplevel_page_wcadmin--analytics.menu-top > a:focus {
padding-bottom: 1px;
}
}

View File

@ -7,4 +7,4 @@ The generated POT template file is not included in this repository. To create th
npm run build
```
After the build completes, you'll find a `woo-dash.pot` strings file in this directory.
After the build completes, you'll find a `wc-admin.pot` strings file in this directory.

View File

@ -2,9 +2,9 @@
/**
* Returns true if we are on a JS powered admin page.
*/
function woo_dash_is_admin_page() {
function wc_admin_is_admin_page() {
global $hook_suffix;
if ( in_array( $hook_suffix, array( 'woocommerce_page_woodash' ) ) ) {
if ( in_array( $hook_suffix, array( 'woocommerce_page_wc-admin' ) ) ) {
return true;
}
return false;
@ -14,13 +14,13 @@ function woo_dash_is_admin_page() {
* Returns true if we are on a "classic" (non JS app) powered admin page.
* `wc_get_screen_ids` will also return IDs for extensions that have properly registered themselves.
*/
function woo_dash_is_embed_enabled_wc_page() {
$screen_id = woo_dash_get_current_screen_id();
function wc_admin_is_embed_enabled_wc_page() {
$screen_id = wc_admin_get_current_screen_id();
if ( ! $screen_id ) {
return false;
}
$screens = woo_dash_get_embed_enabled_screen_ids();
$screens = wc_admin_get_embed_enabled_screen_ids();
if ( in_array( $screen_id, $screens ) ) {
return true;
@ -31,51 +31,51 @@ function woo_dash_is_embed_enabled_wc_page() {
/**
* Register menu pages for the Dashboard and Analytics sections
*/
function woo_dash_register_pages(){
function wc_admin_register_pages(){
global $menu, $submenu;
// woocommerce_page_woodash
// woocommerce_page_wc-admin
add_submenu_page(
'woocommerce',
__( 'WooCommerce Dashboard', 'woo-dash' ),
__( 'Dashboard', 'woo-dash' ),
__( 'WooCommerce Dashboard', 'wc-admin' ),
__( 'Dashboard', 'wc-admin' ),
'manage_options',
'woodash',
'woo_dash_page'
'wc-admin',
'wc_admin_page'
);
// toplevel_page_wooanalytics
add_menu_page(
__( 'WooCommerce Analytics', 'woo-dash' ),
__( 'Analytics', 'woo-dash' ),
__( 'WooCommerce Analytics', 'wc-admin' ),
__( 'Analytics', 'wc-admin' ),
'manage_options',
'woodash#/analytics',
'woo_dash_page',
'wc-admin#/analytics',
'wc_admin_page',
'dashicons-chart-bar',
56 // After WooCommerce & Product menu items
);
// TODO: Remove. Test report link
add_submenu_page(
'woodash#/analytics',
__( 'Report Title', 'woo-dash' ),
__( 'Report Title', 'woo-dash' ),
'wc-admin#/analytics',
__( 'Report Title', 'wc-admin' ),
__( 'Report Title', 'wc-admin' ),
'manage_options',
'woodash#/analytics/test',
'woo_dash_page'
'wc-admin#/analytics/test',
'wc_admin_page'
);
add_submenu_page(
'woodash#/analytics',
__( 'Revenue', 'woo-dash' ),
__( 'Revenue', 'woo-dash' ),
'wc-admin#/analytics',
__( 'Revenue', 'wc-admin' ),
__( 'Revenue', 'wc-admin' ),
'manage_options',
'woodash#/analytics/revenue',
'woo_dash_page'
'wc-admin#/analytics/revenue',
'wc_admin_page'
);
}
add_action( 'admin_menu', 'woo_dash_register_pages' );
add_action( 'admin_menu', 'wc_admin_register_pages' );
/**
* This method is temporary while this is a feature plugin. As a part of core,
@ -83,92 +83,92 @@ add_action( 'admin_menu', 'woo_dash_register_pages' );
*
* It makes dashboard the top level link for 'WooCommerce' and renames the first Analytics menu item.
*/
function woo_dash_link_structure() {
function wc_admin_link_structure() {
global $submenu;
// User does not have capabilites to see the submenu
if ( ! current_user_can( 'manage_woocommerce' ) ) {
return;
}
$woodash_key = null;
$wc_admin_key = null;
foreach ( $submenu['woocommerce'] as $submenu_key => $submenu_item ) {
if ( 'woodash' === $submenu_item[2] ) {
$woodash_key = $submenu_key;
if ( 'wc-admin' === $submenu_item[2] ) {
$wc_admin_key = $submenu_key;
break;
}
}
if ( ! $woodash_key ) {
if ( ! $wc_admin_key ) {
return;
}
$dashmenu = $submenu['woocommerce'][ $woodash_key ];
$dashmenu[2] = 'admin.php?page=woodash#/';
unset( $submenu['woocommerce'][ $woodash_key ] );
$menu = $submenu['woocommerce'][ $wc_admin_key ];
$menu[2] = 'admin.php?page=wc-admin#/';
unset( $submenu['woocommerce'][ $wc_admin_key ] );
array_unshift( $submenu['woocommerce'], $dashmenu );
$submenu['woodash#/analytics'][0][0] = __( 'Overview', 'woo-dash' );
array_unshift( $submenu['woocommerce'], $menu );
$submenu['wc-admin#/analytics'][0][0] = __( 'Overview', 'wc-admin' );
}
// priority is 20 to run after https://github.com/woocommerce/woocommerce/blob/a55ae325306fc2179149ba9b97e66f32f84fdd9c/includes/admin/class-wc-admin-menus.php#L165
add_action( 'admin_head', 'woo_dash_link_structure', 20 );
add_action( 'admin_head', 'wc_admin_link_structure', 20 );
/**
* Load the assets on the Dashboard page
* Load the assets on the admin pages
*/
function woo_dash_enqueue_script(){
if ( ! woo_dash_is_admin_page() && ! woo_dash_is_embed_enabled_wc_page() ) {
function wc_admin_enqueue_script(){
if ( ! wc_admin_is_admin_page() && ! wc_admin_is_embed_enabled_wc_page() ) {
return;
}
wp_enqueue_script( WOO_DASH_APP );
wp_enqueue_style( WOO_DASH_APP );
wp_enqueue_script( WC_ADMIN_APP );
wp_enqueue_style( WC_ADMIN_APP );
}
add_action( 'admin_enqueue_scripts', 'woo_dash_enqueue_script' );
add_action( 'admin_enqueue_scripts', 'wc_admin_enqueue_script' );
function woo_dash_admin_body_class( $admin_body_class = '' ) {
function wc_admin_admin_body_class( $admin_body_class = '' ) {
global $hook_suffix;
if ( ! woo_dash_is_admin_page() && ! woo_dash_is_embed_enabled_wc_page() ) {
if ( ! wc_admin_is_admin_page() && ! wc_admin_is_embed_enabled_wc_page() ) {
return $admin_body_class;
}
$classes = explode( ' ', trim( $admin_body_class ) );
$classes[] = 'woocommerce-page';
if ( woo_dash_is_embed_enabled_wc_page() ) {
if ( wc_admin_is_embed_enabled_wc_page() ) {
$classes[] = 'woocommerce-embed-page';
}
$admin_body_class = implode( ' ', array_unique( $classes ) );
return " $admin_body_class ";
}
add_filter( 'admin_body_class', 'woo_dash_admin_body_class' );
add_filter( 'admin_body_class', 'wc_admin_admin_body_class' );
function woo_dash_admin_before_notices() {
if ( ! woo_dash_is_admin_page() && ! woo_dash_is_embed_enabled_wc_page() ) {
function wc_admin_admin_before_notices() {
if ( ! wc_admin_is_admin_page() && ! wc_admin_is_embed_enabled_wc_page() ) {
return;
}
echo '<div class="woocommerce-layout__notice-list-hide" id="wp__notice-list">';
echo '<div class="wp-header-end" id="woocommerce-layout__notice-catcher"></div>'; // https://github.com/WordPress/WordPress/blob/f6a37e7d39e2534d05b9e542045174498edfe536/wp-admin/js/common.js#L737
}
add_action( 'admin_notices', 'woo_dash_admin_before_notices', 0 );
add_action( 'admin_notices', 'wc_admin_admin_before_notices', 0 );
function woo_dash_admin_after_notices() {
if ( ! woo_dash_is_admin_page() && ! woo_dash_is_embed_enabled_wc_page() ) {
function wc_admin_admin_after_notices() {
if ( ! wc_admin_is_admin_page() && ! wc_admin_is_embed_enabled_wc_page() ) {
return;
}
echo '</div>';
}
add_action( 'admin_notices', 'woo_dash_admin_after_notices', PHP_INT_MAX );
add_action( 'admin_notices', 'wc_admin_admin_after_notices', PHP_INT_MAX );
// TODO Can we do some URL rewriting so we can figure out which page they are on server side?
function woo_dash_admin_title( $admin_title ) {
if ( ! woo_dash_is_admin_page() && ! woo_dash_is_embed_enabled_wc_page() ) {
function wc_admin_admin_title( $admin_title ) {
if ( ! wc_admin_is_admin_page() && ! wc_admin_is_embed_enabled_wc_page() ) {
return $admin_title;
}
if ( woo_dash_is_embed_enabled_wc_page() ) {
$sections = woo_dash_get_embed_breadcrumbs();
if ( wc_admin_is_embed_enabled_wc_page() ) {
$sections = wc_admin_get_embed_breadcrumbs();
$sections = is_array( $sections ) ? $sections : array( $sections );
$pieces = array();
@ -179,17 +179,17 @@ function woo_dash_admin_title( $admin_title ) {
$pieces = array_reverse( $pieces );
$title = implode( ' &lsaquo; ', $pieces );
} else {
$title = __( 'Dashboard', 'woo-dash' );
$title = __( 'Dashboard', 'wc-admin' );
}
return sprintf( __( '%1$s &lsaquo; %2$s &#8212; WooCommerce' ), $title, get_bloginfo( 'name' ) );
return sprintf( __( '%1$s &lsaquo; %2$s &#8212; WooCommerce', 'wc-admin' ), $title, get_bloginfo( 'name' ) );
}
add_filter( 'admin_title', 'woo_dash_admin_title' );
add_filter( 'admin_title', 'wc_admin_admin_title' );
/**
* Set up a div for the app to render into.
*/
function woo_dash_page(){
function wc_admin_page(){
?>
<div class="wrap">
<div id="root"></div>
@ -204,11 +204,11 @@ function woo_dash_page(){
* TODO Icon Placeholders for the ActivityPanel, when we implement the new designs.
*/
function woocommerce_embed_page_header() {
if ( ! woo_dash_is_embed_enabled_wc_page() ) {
if ( ! wc_admin_is_embed_enabled_wc_page() ) {
return;
}
$sections = woo_dash_get_embed_breadcrumbs();
$sections = wc_admin_get_embed_breadcrumbs();
$sections = is_array( $sections ) ? $sections : array( $sections );
$breadcrumbs = '';
foreach ( $sections as $section ) {
@ -220,7 +220,7 @@ function woocommerce_embed_page_header() {
<div class="woocommerce-layout">
<div class="woocommerce-layout__header is-embed-loading">
<h1 class="woocommerce-layout__header-breadcrumbs">
<span><a href="<?php echo esc_url( admin_url( 'admin.php?page=woodash#/' ) ); ?>">WooCommerce</a></span>
<span><a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-admin#/' ) ); ?>">WooCommerce</a></span>
<span><?php echo $breadcrumbs; ?></span>
</h1>
</div>

View File

@ -1,12 +1,14 @@
<?php
/**
* Registers the JS & CSS for the Dashboard
* Registers the JS & CSS for the admin and admin embed
*/
function woo_dash_register_script() {
function wc_admin_register_script() {
// Are we displaying the full React app or just embedding the header on a classic screen?
$screen_id = woo_dash_get_current_screen_id();
$screen_id = wc_admin_get_current_screen_id();
if ( in_array( $screen_id, woo_dash_get_embed_enabled_screen_ids() ) ) {
error_log( $screen_id );
if ( in_array( $screen_id, wc_admin_get_embed_enabled_screen_ids() ) ) {
$js_entry = 'dist/embedded.js';
$css_entry = 'dist/css/embedded.css';
} else {
@ -15,24 +17,24 @@ function woo_dash_register_script() {
}
wp_register_script(
WOO_DASH_APP,
woo_dash_url( $js_entry ),
WC_ADMIN_APP,
wc_admin_url( $js_entry ),
[ 'wp-components', 'wp-blocks', 'wp-element', 'wp-i18n', 'wp-date' ],
filemtime( woo_dash_dir_path( $js_entry ) ),
filemtime( wc_admin_dir_path( $js_entry ) ),
true
);
wp_register_style(
WOO_DASH_APP,
woo_dash_url( $css_entry ),
WC_ADMIN_APP,
wc_admin_url( $css_entry ),
[ 'wp-edit-blocks' ],
filemtime( woo_dash_dir_path( $css_entry ) )
filemtime( wc_admin_dir_path( $css_entry ) )
);
// Set up the text domain and translations
$locale_data = gutenberg_get_jed_locale_data( 'woo-dash' );
$content = 'wp.i18n.setLocaleData( ' . json_encode( $locale_data ) . ', "woo-dash" );';
wp_add_inline_script( WOO_DASH_APP, $content, 'before' );
$locale_data = gutenberg_get_jed_locale_data( 'wc-admin' );
$content = 'wp.i18n.setLocaleData( ' . json_encode( $locale_data ) . ', "wc-admin" );';
wp_add_inline_script( WC_ADMIN_APP, $content, 'before' );
wp_enqueue_script( 'wp-api' );
gutenberg_extend_wp_api_backbone_client();
@ -40,34 +42,34 @@ function woo_dash_register_script() {
// Settings and variables can be passed here for access in the app
$settings = array(
'adminUrl' => admin_url(),
'embedBreadcrumbs' => woo_dash_get_embed_breadcrumbs(),
'embedBreadcrumbs' => wc_admin_get_embed_breadcrumbs(),
'siteLocale' => esc_attr( get_bloginfo( 'language' ) ),
'currency' => woo_dash_currency_settings(),
'currency' => wc_admin_currency_settings(),
'date' => array(
'dow' => get_option( 'start_of_week', 0 ),
),
);
wp_add_inline_script(
WOO_DASH_APP,
WC_ADMIN_APP,
'var wcSettings = '. json_encode( $settings ) . ';',
'before'
);
// Resets lodash to wp-admin's version of lodash
wp_add_inline_script(
WOO_DASH_APP,
WC_ADMIN_APP,
'_.noConflict();',
'after'
);
}
add_action( 'admin_enqueue_scripts', 'woo_dash_register_script' );
add_action( 'admin_enqueue_scripts', 'wc_admin_register_script' );
/**
* Load plugin text domain for translations.
*/
function woo_dash_load_plugin_textdomain() {
load_plugin_textdomain( 'woo-dash', false, basename( dirname( __FILE__ ) ) . '/languages' );
function wc_admin_load_plugin_textdomain() {
load_plugin_textdomain( 'wc-admin', false, basename( dirname( __FILE__ ) ) . '/languages' );
}
add_action( 'plugins_loaded', 'woo_dash_load_plugin_textdomain' );
add_action( 'plugins_loaded', 'wc_admin_load_plugin_textdomain' );

View File

@ -6,7 +6,7 @@
*
* @return string Root path to the gutenberg custom fields plugin.
*/
function woo_dash_dir_path( $file = '' ) {
function wc_admin_dir_path( $file = '' ) {
return plugin_dir_path( dirname(__FILE__ ) ) . $file;
}
@ -17,7 +17,7 @@ function woo_dash_dir_path( $file = '' ) {
*
* @return string Fully qualified URL pointing to the desired file.
*/
function woo_dash_url( $path ) {
function wc_admin_url( $path ) {
return plugins_url( $path, dirname( __FILE__ ) );
}
@ -31,8 +31,8 @@ function woo_dash_url( $path ) {
*
* @return string Current screen ID.
*/
function woo_dash_get_current_screen_id() {
$current_screen = get_current_screen();
function wc_admin_get_current_screen_id() {
$current_screen = get_current_screen();
if ( ! $current_screen ) {
return false;
}
@ -50,8 +50,8 @@ function woo_dash_get_current_screen_id() {
*
* TODO When merging to core, we should explore a better API for defining breadcrumbs, instead of just defining an array.
*/
function woo_dash_get_embed_breadcrumbs() {
$current_screen_id = woo_dash_get_current_screen_id();
function wc_admin_get_embed_breadcrumbs() {
$current_screen_id = wc_admin_get_current_screen_id();
// If a page has a tab, we can append that to the screen ID and show another pagination level
$pages_with_tabs = array(
@ -66,123 +66,123 @@ function woo_dash_get_embed_breadcrumbs() {
}
}
$breadcrumbs = apply_filters( 'woo_dash_get_breadcrumbs', array(
'edit-shop_order' => __( 'Orders', 'woo-dash' ),
$breadcrumbs = apply_filters( 'wc_admin_get_breadcrumbs', array(
'edit-shop_order' => __( 'Orders', 'wc-admin' ),
'add-shop_order' => array(
array( '/edit.php?post_type=shop_order', __( 'Orders', 'woo-dash' ) ),
__( 'Add New', 'woo-dash' )
array( '/edit.php?post_type=shop_order', __( 'Orders', 'wc-admin' ) ),
__( 'Add New', 'wc-admin' )
),
'shop_order' => array(
array( '/edit.php?post_type=shop_order', __( 'Orders', 'woo-dash' ) ),
__( 'Edit Order', 'woo-dash' )
array( '/edit.php?post_type=shop_order', __( 'Orders', 'wc-admin' ) ),
__( 'Edit Order', 'wc-admin' )
),
'edit-shop_coupon' => __( 'Coupons', 'woo-dash' ),
'edit-shop_coupon' => __( 'Coupons', 'wc-admin' ),
'add-shop_coupon' => array(
array( 'edit.php?post_type=shop_coupon', __( 'Coupons', 'woo-dash' ) ),
__( 'Add New', 'woo-dash' )
array( 'edit.php?post_type=shop_coupon', __( 'Coupons', 'wc-admin' ) ),
__( 'Add New', 'wc-admin' )
),
'shop_coupon' => array(
array( 'edit.php?post_type=shop_coupon', __( 'Coupons', 'woo-dash' ) ),
__( 'Edit Coupon', 'woo-dash' )
array( 'edit.php?post_type=shop_coupon', __( 'Coupons', 'wc-admin' ) ),
__( 'Edit Coupon', 'wc-admin' )
),
'woocommerce_page_wc-reports' => array(
array( 'admin.php?page=wc-reports', __( 'Reports', 'woo-dash' ) )
array( 'admin.php?page=wc-reports', __( 'Reports', 'wc-admin' ) )
),
'orders-woocommerce_page_wc-reports' => array(
array( 'admin.php?page=wc-reports', __( 'Reports', 'woo-dash' ) ),
__( 'Orders', 'woo-dash' )
array( 'admin.php?page=wc-reports', __( 'Reports', 'wc-admin' ) ),
__( 'Orders', 'wc-admin' )
),
'customers-woocommerce_page_wc-reports' => array(
array( 'admin.php?page=wc-reports', __( 'Reports', 'woo-dash' ) ),
__( 'Customers', 'woo-dash' )
array( 'admin.php?page=wc-reports', __( 'Reports', 'wc-admin' ) ),
__( 'Customers', 'wc-admin' )
),
'stock-woocommerce_page_wc-reports' => array(
array( 'admin.php?page=wc-reports', __( 'Reports', 'woo-dash' ) ),
__( 'Stock', 'woo-dash' )
array( 'admin.php?page=wc-reports', __( 'Reports', 'wc-admin' ) ),
__( 'Stock', 'wc-admin' )
),
'taxes-woocommerce_page_wc-reports' => array(
array( 'admin.php?page=wc-reports', __( 'Reports', 'woo-dash' ) ),
__( 'Taxes', 'woo-dash' )
array( 'admin.php?page=wc-reports', __( 'Reports', 'wc-admin' ) ),
__( 'Taxes', 'wc-admin' )
),
'woocommerce_page_wc-settings' => array(
array( 'admin.php?page=wc-settings', __( 'Settings', 'woo-dash' ) )
array( 'admin.php?page=wc-settings', __( 'Settings', 'wc-admin' ) )
),
'general-woocommerce_page_wc-settings' => array(
array( 'admin.php?page=wc-settings', __( 'Settings', 'woo-dash' ) ),
__( 'General', 'woo-dash' ),
array( 'admin.php?page=wc-settings', __( 'Settings', 'wc-admin' ) ),
__( 'General', 'wc-admin' ),
),
'products-woocommerce_page_wc-settings' => array(
array( 'admin.php?page=wc-settings', __( 'Settings', 'woo-dash' ) ),
__( 'Products', 'woo-dash' ),
array( 'admin.php?page=wc-settings', __( 'Settings', 'wc-admin' ) ),
__( 'Products', 'wc-admin' ),
),
'tax-woocommerce_page_wc-settings' => array(
array( 'admin.php?page=wc-settings', __( 'Settings', 'woo-dash' ) ),
__( 'Tax', 'woo-dash' ),
array( 'admin.php?page=wc-settings', __( 'Settings', 'wc-admin' ) ),
__( 'Tax', 'wc-admin' ),
),
'shipping-woocommerce_page_wc-settings' => array(
array( 'admin.php?page=wc-settings', __( 'Settings', 'woo-dash' ) ),
__( 'Shipping', 'woo-dash' ),
array( 'admin.php?page=wc-settings', __( 'Settings', 'wc-admin' ) ),
__( 'Shipping', 'wc-admin' ),
),
'checkout-woocommerce_page_wc-settings' => array(
array( 'admin.php?page=wc-settings', __( 'Settings', 'woo-dash' ) ),
__( 'Payments', 'woo-dash' ),
array( 'admin.php?page=wc-settings', __( 'Settings', 'wc-admin' ) ),
__( 'Payments', 'wc-admin' ),
),
'email-woocommerce_page_wc-settings' => array(
array( 'admin.php?page=wc-settings', __( 'Settings', 'woo-dash' ) ),
__( 'Emails', 'woo-dash' ),
array( 'admin.php?page=wc-settings', __( 'Settings', 'wc-admin' ) ),
__( 'Emails', 'wc-admin' ),
),
'advanced-woocommerce_page_wc-settings' => array(
array( 'admin.php?page=wc-settings', __( 'Settings', 'woo-dash' ) ),
__( 'Advanced', 'woo-dash' ),
array( 'admin.php?page=wc-settings', __( 'Settings', 'wc-admin' ) ),
__( 'Advanced', 'wc-admin' ),
),
'woocommerce_page_wc-status' => array(
__( 'Status', 'woo-dash' ),
__( 'Status', 'wc-admin' ),
),
'status-woocommerce_page_wc-status' => array(
array( 'admin.php?page=wc-status', __( 'Status', 'woo-dash' ) ),
__( 'System Status', 'woo-dash' ),
array( 'admin.php?page=wc-status', __( 'Status', 'wc-admin' ) ),
__( 'System Status', 'wc-admin' ),
),
'tools-woocommerce_page_wc-status' => array(
array( 'admin.php?page=wc-status', __( 'Status', 'woo-dash' ) ),
__( 'Tools', 'woo-dash' ),
array( 'admin.php?page=wc-status', __( 'Status', 'wc-admin' ) ),
__( 'Tools', 'wc-admin' ),
),
'logs-woocommerce_page_wc-status' => array(
array( 'admin.php?page=wc-status', __( 'Status', 'woo-dash' ) ),
__( 'Logs', 'woo-dash' ),
array( 'admin.php?page=wc-status', __( 'Status', 'wc-admin' ) ),
__( 'Logs', 'wc-admin' ),
),
'connect-woocommerce_page_wc-status' => array(
array( 'admin.php?page=wc-status', __( 'Status', 'woo-dash' ) ),
__( 'WooCommerce Services Status', 'woo-dash' ),
array( 'admin.php?page=wc-status', __( 'Status', 'wc-admin' ) ),
__( 'WooCommerce Services Status', 'wc-admin' ),
),
'woocommerce_page_wc-addons' => __( 'Extensions', 'woo-dash' ),
'edit-product' => __( 'Products', 'woo-dash' ),
'woocommerce_page_wc-addons' => __( 'Extensions', 'wc-admin' ),
'edit-product' => __( 'Products', 'wc-admin' ),
'product_page_product_importer' => array(
array( 'edit.php?post_type=product', __( 'Products', 'woo-dash' ) ),
__( 'Import', 'woo-dash' ),
array( 'edit.php?post_type=product', __( 'Products', 'wc-admin' ) ),
__( 'Import', 'wc-admin' ),
),
'product_page_product_exporter' => array(
array( 'edit.php?post_type=product', __( 'Products', 'woo-dash' ) ),
__( 'Export', 'woo-dash' ),
array( 'edit.php?post_type=product', __( 'Products', 'wc-admin' ) ),
__( 'Export', 'wc-admin' ),
),
'add-product' => array(
array( 'edit.php?post_type=product', __( 'Products', 'woo-dash' ) ),
__( 'Add New', 'woo-dash' ),
array( 'edit.php?post_type=product', __( 'Products', 'wc-admin' ) ),
__( 'Add New', 'wc-admin' ),
),
'product' => array(
array( 'edit.php?post_type=product', __( 'Products', 'woo-dash' ) ),
__( 'Edit Product', 'woo-dash' ),
array( 'edit.php?post_type=product', __( 'Products', 'wc-admin' ) ),
__( 'Edit Product', 'wc-admin' ),
),
'edit-product_cat' => array(
array( 'edit.php?post_type=product', __( 'Products', 'woo-dash' ) ),
__( 'Categories', 'woo-dash' ),
array( 'edit.php?post_type=product', __( 'Products', 'wc-admin' ) ),
__( 'Categories', 'wc-admin' ),
),
'edit-product_tag' => array(
array( 'edit.php?post_type=product', __( 'Products', 'woo-dash' ) ),
__( 'Tags', 'woo-dash' ),
array( 'edit.php?post_type=product', __( 'Products', 'wc-admin' ) ),
__( 'Tags', 'wc-admin' ),
),
'product_page_product_attributes' => array(
array( 'edit.php?post_type=product', __( 'Products', 'woo-dash' ) ),
__( 'Attributes', 'woo-dash' ),
array( 'edit.php?post_type=product', __( 'Products', 'wc-admin' ) ),
__( 'Attributes', 'wc-admin' ),
),
) );
@ -197,12 +197,12 @@ function woo_dash_get_embed_breadcrumbs() {
}
/**
* `woo_dash_get_embed_enabled_screen_ids`, `woo_dash_get_embed_enabled_plugin_screen_ids`,
* `woo_dash_get_embed_enabled_screen_ids` should be considered temporary functions for the feature plugin.
* `wc_admin_get_embed_enabled_screen_ids`, `wc_admin_get_embed_enabled_plugin_screen_ids`,
* `wc_admin_get_embed_enabled_screen_ids` should be considered temporary functions for the feature plugin.
* This is separate from WC's screen_id functions so that extensions explictly have to opt-in to the feature plugin.
* TODO When merging to core, we should explore a better API for opting into the new header for extensions.
*/
function woo_dash_get_embed_enabled_core_screen_ids() {
function wc_admin_get_embed_enabled_core_screen_ids() {
$screens = array(
'edit-shop_order',
'shop_order',
@ -223,23 +223,23 @@ function woo_dash_get_embed_enabled_core_screen_ids() {
'edit-product_tag',
'product_page_product_attributes',
);
return apply_filters( 'woo_dash_get_embed_enabled_core_screens_ids', $screens );
return apply_filters( 'wc_admin_get_embed_enabled_core_screens_ids', $screens );
}
/**
* If any extensions want to show the new header, they can register their screen ids.
* Separate so extensions can register support for the feature plugin separately.
*/
function woo_dash_get_embed_enabled_plugin_screen_ids() {
function wc_admin_get_embed_enabled_plugin_screen_ids() {
$screens = array();
return apply_filters( 'woo_dash_get_embed_enabled_plugin_screens_ids', $screens );
return apply_filters( 'wc_admin_get_embed_enabled_plugin_screens_ids', $screens );
}
/**
* Returns core and plugin screen IDs for a list of screens the new header should be enabled on.
*/
function woo_dash_get_embed_enabled_screen_ids() {
return array_merge( woo_dash_get_embed_enabled_core_screen_ids(), woo_dash_get_embed_enabled_plugin_screen_ids() );
function wc_admin_get_embed_enabled_screen_ids() {
return array_merge( wc_admin_get_embed_enabled_core_screen_ids(), wc_admin_get_embed_enabled_plugin_screen_ids() );
}
/**
@ -253,7 +253,7 @@ function woo_dash_get_embed_enabled_screen_ids() {
* @type string $symbol Symbol for currency.
* }
*/
function woo_dash_currency_settings() {
function wc_admin_currency_settings() {
$code = get_woocommerce_currency();
return apply_filters(

View File

@ -1,5 +1,5 @@
{
"name": "woo-dash",
"name": "wc-admin",
"version": "0.1.0",
"lockfileVersion": 1,
"requires": true,

View File

@ -1,5 +1,5 @@
{
"name": "woo-dash",
"name": "wc-admin",
"version": "0.1.0",
"main": "js/index.js",
"author": "Automattic",
@ -17,7 +17,7 @@
"prestart": "npm run -s install-if-deps-outdated",
"start": "webpack --watch",
"lint": "npm run -s install-if-deps-outdated && eslint client --ext=js,jsx",
"i18n": "pot-to-php ./languages/woo-dash.pot ./languages/woo-dash.php woo-dash && grunt i18n",
"i18n": "pot-to-php ./languages/wc-admin.pot ./languages/wc-admin.php wc-admin && grunt i18n",
"precommit": "npm run -s install-if-no-packages && node bin/pre-commit-hook.js",
"prepush": "npm run -s install-if-no-packages && node bin/pre-push-hook.js",
"pretest": "npm run -s install-if-no-packages",

View File

@ -10,7 +10,7 @@
syntaxCheck="true"
>
<testsuites>
<testsuite name="Woo Dash Test Suite">
<testsuite name="WooCommerce Admin Test Suite">
<directory prefix="test-" suffix=".php">./tests/</directory>
</testsuite>
</testsuites>

View File

@ -2,7 +2,7 @@
/**
* PHPUnit bootstrap file
*
* @package Woo_Dash
* @package WC_Admin
*/
$_tests_dir = getenv( 'WP_TESTS_DIR' );
@ -24,7 +24,7 @@ require_once $_tests_dir . '/includes/functions.php';
*/
function _manually_load_plugin() {
require dirname( dirname( dirname( __FILE__ ) ) ) . '/gutenberg/gutenberg.php';
require dirname( dirname( __FILE__ ) ) . '/woo-dash.php';
require dirname( dirname( __FILE__ ) ) . '/wc-admin.php';
}
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );

View File

@ -2,7 +2,7 @@
/**
* Class SampleTest
*
* @package Woo_Dash
* @package WC_Admin
*/
/**

View File

@ -1,27 +1,27 @@
<?php
/**
* Plugin Name: Woo Dashboard
* Plugin Name: WooCommerce Admin
* Plugin URI: https://woocommerce.com/
* Description: A feature plugin for a new Dashboard view of WooCommerce
* Description: A feature plugin for a modern, javascript-driven WooCommerce admin experience.
* Author: Automattic
* Author URI: https://woocommerce.com/
* Text Domain: woo-dash
* Text Domain: woocommerce
* Domain Path: /languages
* Version: 0.1.0
*
* @package Woo_Dash
* @package WC_Admin
*/
if ( ! defined( 'WOO_DASH_APP' ) ) {
define( 'WOO_DASH_APP', 'woo-dash-app' );
if ( ! defined( 'WC_ADMIN_APP' ) ) {
define( 'WC_ADMIN_APP', 'wc-admin-app' );
}
/**
* Notify users of the plugin requirements
*/
function woo_dash_plugins_notice() {
function wc_admin_plugins_notice() {
$message = sprintf(
__( 'The WooCommerce Dashboard feature plugin requires both <a href="%1$s">Gutenberg</a> and <a href="%2$s">WooCommerce</a> to be installed and active.', 'woo-dash' ),
__( 'The WooCommerce Admin feature plugin requires both <a href="%1$s">Gutenberg</a> and <a href="%2$s">WooCommerce</a> to be installed and active.', 'wc-admin' ),
'https://wordpress.org/plugins/gutenberg/',
'https://wordpress.org/plugins/woocommerce/'
);
@ -31,12 +31,12 @@ function woo_dash_plugins_notice() {
/**
* Set up the plugin, only if we can detect both Gutenberg and WooCommerce
*/
function woo_dash_plugins_loaded() {
function wc_admin_plugins_loaded() {
if (
! ( defined( 'GUTENBERG_DEVELOPMENT_MODE' ) || defined( 'GUTENBERG_VERSION' ) ) ||
! class_exists( 'WooCommerce' )
) {
add_action( 'admin_notices', 'woo_dash_plugins_notice' );
add_action( 'admin_notices', 'wc_admin_plugins_notice' );
return;
}
@ -49,4 +49,4 @@ function woo_dash_plugins_loaded() {
// Create the Admin pages
require_once dirname( __FILE__ ) . '/lib/admin.php';
}
add_action( 'plugins_loaded', 'woo_dash_plugins_loaded' );
add_action( 'plugins_loaded', 'wc_admin_plugins_loaded' );