Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
fix react render error
wrap runtime data in plugin array
  • Loading branch information
circlecube committed Aug 23, 2023
1 parent b22a2e4 commit feab5f6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
12 changes: 7 additions & 5 deletions inc/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ public static function runtime() {
global $nfd_module_container;

$runtime = array(
'url' => HOSTGATOR_BUILD_URL,
'version' => HOSTGATOR_PLUGIN_VERSION,
'assets' => HOSTGATOR_PLUGIN_URL . 'assets/',
'brand' => $nfd_module_container->plugin()->brand,
'region' => $nfd_module_container->plugin()->region,
'plugin' => array(
'url' => HOSTGATOR_BUILD_URL,
'version' => HOSTGATOR_PLUGIN_VERSION,
'assets' => HOSTGATOR_PLUGIN_URL . 'assets/',
'brand' => $nfd_module_container->plugin()->brand,
'region' => $nfd_module_container->plugin()->region,
),
);

return $runtime;
Expand Down
1 change: 1 addition & 0 deletions src/app/data/store.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createContext, useMemo } from '@wordpress/element';
import { NewfoldRuntime } from '@newfold-labs/wp-module-runtime';

import apiFetch from '@wordpress/api-fetch';

Expand Down
2 changes: 1 addition & 1 deletion src/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import './stylesheet.scss';

import AppStore, { AppStoreProvider } from './data/store';
import { Root } from "@newfold/ui-component-library";
import { NewfoldRuntime } from "@newfold-labs/wp-module-runtime";
import { useLocation, HashRouter as Router } from 'react-router-dom';
import { NewfoldRuntime } from '@newfold-labs/wp-module-runtime';
import { __ } from '@wordpress/i18n';
import { SnackbarList, Spinner } from '@wordpress/components';
import classnames from 'classnames';
Expand Down
6 changes: 3 additions & 3 deletions src/app/pages/home/webContentSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const WebContentSection = () => {
<ActionField
label={__("Blog", "wp-plugin-hostgator")}
buttonLabel={__("New Post", "wp-plugin-hostgator")}
href={HGWP.admin + 'post-new.php'}
href={window.NewfoldRuntime.admin_url + 'post-new.php'}
className={"hgwp-app-home-blog-action"}
>
{__('Write a new blog post.', 'wp-plugin-hostgator')}
Expand All @@ -20,7 +20,7 @@ const WebContentSection = () => {
<ActionField
label={__("Pages", "wp-plugin-hostgator")}
buttonLabel={__("New Page", "wp-plugin-hostgator")}
href={HGWP.admin + 'post-new.php?post_type=page'}
href={window.NewfoldRuntime.admin_url + 'post-new.php?post_type=page'}
className={"hgwp-app-home-pages-action"}
>
{__('Add fresh pages to your website.', 'wp-plugin-hostgator')}
Expand All @@ -29,7 +29,7 @@ const WebContentSection = () => {
<ActionField
label={__("Categories", "wp-plugin-hostgator")}
buttonLabel={__("Manage Categories", "wp-plugin-hostgator")}
href={HGWP.admin + 'edit-tags.php?taxonomy=category'}
href={window.NewfoldRuntime.admin_url + 'edit-tags.php?taxonomy=category'}
className={"hgwp-app-home-categories-action"}
>
{__('Organize existing content into categories.', 'wp-plugin-hostgator')}
Expand Down
1 change: 1 addition & 0 deletions src/app/pages/marketplace/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import apiFetch from '@wordpress/api-fetch';
import { useState, useEffect } from '@wordpress/element';
import { useLocation } from 'react-router-dom';
import classnames from 'classnames';
import { Page } from "../../components/page";
import { SectionContainer, SectionHeader, SectionContent } from "../../components/section";
import { NewfoldRuntime } from "@newfold-labs/wp-module-runtime";
Expand Down
11 changes: 6 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import './webpack-public-path';

import App from './app';
import domReady from '@wordpress/dom-ready';
import { render } from '@wordpress/element';
import { createRoot } from '@wordpress/element';

const WP_ADM_PAGE_ROOT_ELEMENT = 'hwa-app';
const HG_ASCI = `
Expand Down Expand Up @@ -44,10 +44,11 @@ const HG_ASCI = `
console.log(HG_ASCI);

const HGWPRender = () => {
const DOM_ELEMENT = document.getElementById(WP_ADM_PAGE_ROOT_ELEMENT);
if (null !== DOM_ELEMENT && 'undefined' !== typeof render) {
render(<App />, DOM_ELEMENT);
const DOM_ELEMENT = document.getElementById( WP_ADM_PAGE_ROOT_ELEMENT );
if ( null !== DOM_ELEMENT && 'undefined' !== typeof createRoot ) {
const root = createRoot( DOM_ELEMENT );
root.render( <App /> );
}
};

domReady(HGWPRender);
domReady( HGWPRender );

0 comments on commit feab5f6

Please sign in to comment.