Skip to content

Commit

Permalink
use wordpress' react always #3239
Browse files Browse the repository at this point in the history
  • Loading branch information
Shelob9 committed Jan 3, 2020
1 parent b57fa6e commit ce36995
Show file tree
Hide file tree
Showing 24 changed files with 14,072 additions and 28,078 deletions.
2 changes: 1 addition & 1 deletion assets/build/css/caldera-forms-front.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/css/caldera-forms-front.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/caldera-forms-front.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! GENERATED SOURCE FILE caldera-forms - v1.8.9 - 2019-12-31 */var resBaldrickTriggers;
/*! GENERATED SOURCE FILE caldera-forms - v1.8.9 - 2020-01-03 */var resBaldrickTriggers;

jQuery(function($){
function fieldErrors(fields, $form, $notice) {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/entry-viewer-2.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! GENERATED SOURCE FILE caldera-forms - v1.8.9 - 2019-12-31 *//**
/*! GENERATED SOURCE FILE caldera-forms - v1.8.9 - 2020-01-03 *//**
* API Client for Caldera Forms API for a single form
*
* @since 1.5.0
Expand Down
2 changes: 1 addition & 1 deletion assets/js/parsley.min.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! GENERATED SOURCE FILE caldera-forms - v1.8.9 - 2019-12-31 *//*!
/*! GENERATED SOURCE FILE caldera-forms - v1.8.9 - 2020-01-03 *//*!
* Parsley.js
* Version 2.8.1 - built Sat, Feb 3rd 2018, 2:27 pm
* http://parsleyjs.org
Expand Down
2 changes: 1 addition & 1 deletion assets/js/vue.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! GENERATED SOURCE FILE caldera-forms - v1.8.9 - 2019-12-31 *//*!
/*! GENERATED SOURCE FILE caldera-forms - v1.8.9 - 2020-01-03 *//*!
* Vue.js v2.1.6
* (c) 2014-2016 Evan You
* Released under the MIT License.
Expand Down
53 changes: 19 additions & 34 deletions classes/render/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,6 @@ public static function get_core_scripts()
'privacy' => self::make_url('privacy'),
'render' => self::make_url('render'),
'legacy-bundle' => self::make_url('legacy-bundle'),
'cf-react' => trailingslashit( CFCORE_URL ) . 'dist/react.min.js',
'cf-react-dom' => trailingslashit( CFCORE_URL ) . 'dist/react-dom.min.js',
];

return $script_urls;
Expand Down Expand Up @@ -498,10 +496,6 @@ public static function enqueue_style($style)
public static function enqueue_script($script, $depts = ['jquery'])
{

if( 'cf-react' === $script ){
wp_enqueue_script($script);
return;
}
if( 'render' === $script ||$script === self::make_slug('render') ){
if (is_admin() ) {
$load_render = false;
Expand Down Expand Up @@ -597,13 +591,14 @@ public static function make_url($name, $script = true)
}

$manifest = self::get_webpack_manifest();

if ($script) {
if (
in_array($name, [
'blocks',
'pro',
'privacy',
'legacy-bundle'
'legacy-bundle',
])
|| empty($manifest)
|| ! array_key_exists("{$name}.js",$manifest)
Expand All @@ -618,7 +613,7 @@ public static function make_url($name, $script = true)
'blocks',
'pro',
'privacy',
'legacy-bundle'
'legacy-bundle',
])
|| empty($manifest)
|| ! array_key_exists("{$name}.css",$manifest)
Expand Down Expand Up @@ -706,32 +701,20 @@ public static function cf_dependencies($tag){
}
$tags = [self::make_slug( 'legacy-bundle' )];
}else {
if ($tag === "blocks") {
$tags = ["wp-blocks"];
} else if($tag === "render") {
if (! Caldera_Forms_Admin::is_main_page()) {
$root_path = CFCORE_PATH;
$name = 'render';
$deps_path = "{$root_path}clients/{$name}/build/index.min.deps.json";
$tags = file_exists($deps_path) ? (array)json_decode(file_get_contents( $deps_path) ) : [];

}
//this should not be needed, but it seams to be only way to get react on the page
foreach ($tags as $t ){
wp_enqueue_script($t);
}
}elseif( 'admin-client' === $tag ){
$tags = [
'lodash',
'cf-react',
'cf-react-dom',
'wp-polyfill',
'wp-keycodes'
];
wp_enqueue_script('lodash' );
//Get the json file listing dependencies for this client.
//Generate with wordpress-scripts by running `yarn build:clients` or `yarn build`.
$root_path = CFCORE_PATH;
if( 'admin-client' === $tag ){
$name = 'admin';
}else{
$name = $tag;
}

}
$deps_path = "{$root_path}clients/{$name}/build/index.min.asset.json";
$assets = file_exists($deps_path) ? (array)json_decode(file_get_contents($deps_path)) : [];
//If file exists it SHOULD have key "dependencies" with a list of tags.
$tags = is_array($assets) && isset($assets['dependencies']) ? $assets['dependencies'] : [];
}

foreach ( $tags as $_tag ){
if( ! wp_script_is($_tag, 'registered')){
Expand All @@ -741,6 +724,10 @@ public static function cf_dependencies($tag){
break;
}
}
//this should not be needed, but it seams to be only way to get react on the page
foreach ($tags as $t) {
wp_enqueue_script($t);
}

return $tags;
}
Expand Down Expand Up @@ -882,8 +869,6 @@ protected static function register_script($script_key, $script_url, $depts = ['j
return;
} elseif ('editor' == $script_key) {
$depts = ['jquery', 'wp-color-picker'];
} elseif( 'privacy' === $script_key ) {
$depts = ['cf-react','cf-react-dom'];
} else {
//no needd...
}
Expand Down
4 changes: 2 additions & 2 deletions clients/admin/MainDashboard/DashboardPanels/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class DashboardPanels extends Component {
<div className={"caldera-grid"}>
<Panel header={__("Welcome To Caldera Forms", "caldera-forms")}>
<PanelBody
title={__("aaaaaDocumentation", "caldera-forms")}
title={__("Documentation", "caldera-forms")}
icon="welcome-widgets-menus"
initialOpen={false}
>
Expand All @@ -54,7 +54,7 @@ export default class DashboardPanels extends Component {
</PanelRow>
</PanelBody>
<PanelBody
title={__("G@et more!", "caldera-forms")}
title={__("Get More!", "caldera-forms")}
icon="thumbs-up"
initialOpen={true}
>
Expand Down
2 changes: 1 addition & 1 deletion clients/admin/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import './index.scss';
import jQuery from 'jquery'
import React,{Component,Fragment} from 'react';
import {render} from "react-dom";
import {render} from "@wordpress/element";
import domReady from '@wordpress/dom-ready';
import MainDashboard from './MainDashboard/MainDashboard';
window._lodash = window._;
Expand Down
Loading

0 comments on commit ce36995

Please sign in to comment.