This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function sgf_meta_fields() { | |
$fields_array = apply_filters( 'sgf_register_fields', [] ); | |
foreach ( $fields_array as $field ) { | |
// Ensure post type exists and field name is valid | |
if ( ! $field['post_type'] || ! post_type_exists( $field['post_type'] ) || ! $field['meta_key'] || ! is_string( $field['meta_key'] ) ) { | |
return; | |
} | |
// Using Null Coalesce Operator to set defaults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {withSelect, withDispatch, useSelect} = wp.data | |
const { TextControl} = wp.components | |
const RepeaterControlHoc = ({field}) => { | |
const {meta_key, label, show_in_rest} = field | |
let arrayValues = useSelect( | |
select => select('core/editor').getEditedPostAttribute('meta')?.[meta_key] | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd /your/instllation/path/wp-content/plugins | |
// Create custom plugin | |
wp scaffold plugin wp-create-react-app-concept --activate --skip-tests | |
cd wp-create-react-app-concept | |
// We need only react-plugin.php for our demo - deleting all other files | |
ls | grep -v wp-create-react-app-concept.php | xargs rm | |
// Create React App |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WordPress React Create App | |
* Description: Load React app in WorePress Admin concept | |
* Author: Ben Broide | |
* Text Domain: react-plugin | |
* Domain Path: /languages | |
* Version: 0.1.0 | |
* | |
* @package React_Plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WordPress React Create App | |
* Description: Load React app in WorePress Admin concept | |
* Author: Ben Broide | |
* Text Domain: react-plugin | |
* Domain Path: /languages | |
* Version: 0.1.0 | |
* | |
* @package React_Plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WordPress React Create App | |
* Description: Load React app in WorePress Admin concept | |
* Author: Ben Broide | |
* Text Domain: react-plugin | |
* Domain Path: /languages | |
* Version: 0.1.0 | |
* | |
* @package React_Plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import ReactDOM from 'react-dom' | |
import './index.css' | |
import App from './App' | |
import * as serviceWorker from './serviceWorker' | |
const reactAppData = window.rpReactPlugin || {} | |
const { appSelector } = reactAppData | |
const appAnchorElement = document.querySelector(appSelector) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import ReactDOM from 'react-dom' | |
import './index.css' | |
import App from './App' | |
import * as serviceWorker from './serviceWorker' | |
const reactAppData = window.rpReactPlugin || {} | |
const { appSelector } = reactAppData | |
const appAnchorElement = document.querySelector(appSelector) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"homepage": "/wp-content/plugins/wp-create-react-app-concept/react-app/build", | |
"name": "react-app", | |
"version": "0.1.0", | |
"private": true, | |
"dependencies": { | |
"@testing-library/jest-dom": "^4.2.4", | |
"@testing-library/react": "^9.3.2", | |
"@testing-library/user-event": "^7.1.2", | |
"react": "^16.13.1", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WordPress React Create App | |
* Description: Load React app in WorePress Admin concept | |
* Author: Ben Broide | |
* Text Domain: react-plugin | |
* Domain Path: /languages | |
* Version: 0.1.0 | |
* | |
* @package React_Plugin |