Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - Divi builder compatibility #1313

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
{
"presets": [
"@babel/preset-react",
[
"@babel/preset-env",
"@wordpress/default",
{
"modules": false,
"targets": {
"browsers": [
"last 2 Chrome versions",
"last 2 Firefox versions",
"last 2 Safari versions",
"last 2 iOS versions",
"last 1 Android version",
"last 1 ChromeAndroid version",
"ie 11"
]
"esmodules": true
}
}
],
"@babel/preset-typescript"
]
]
}
1 change: 0 additions & 1 deletion .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Gruntfile.js
webpack.config.js
tests/
vendor/
src/
node_modules/
none
package-lock.json
Expand Down
30 changes: 14 additions & 16 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
{
"parser": "babel-eslint",
"extends": "eslint",
"root": true,
"env": {
"es6": true,
"browser": true,
"node": true
},
"settings": {
"react": {
"version": "detect",
"max-len": [
2,
{
"code": 350
}
]
}
"globals": {
"wp": true
},
"rules": {
"max-nested-callbacks": [
"camelcase": 0,
"indent": 0,
"max-len": [
2,
4
]
}
{
"code": 485
}
],
"no-console": 1
},
"parser": "babel-eslint"
}
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ Thumbs.db
# Composer
/vendor/

# Src
/src/

# Build
build/
everest-forms.zip
Expand Down
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ module.exports = function( grunt ){
sass: {
options: {
sourcemap: 'none',
implementation: require( 'sass' )
implementation: require( 'node-sass' )
},
compile: {
files: [{
Expand Down
84 changes: 84 additions & 0 deletions addons/Addons.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

Check failure on line 1 in addons/Addons.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4 , WP Latest)

Filenames should be all lowercase with hyphens as word separators. Expected addons.php, but found Addons.php.

Check failure on line 1 in addons/Addons.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4 , WP Latest)

Class file names should be based on the class name with "class-" prepended. Expected class-addons.php, but found Addons.php.
/**
* Addons main files.
*
* @since xx.xx.xx
* @package EverestForms\Addons\Addons
*/

namespace EverestForms\Addons;

use EverestForms\Addons\OxygenBuilder\OxygenBuilder;
use EverestForms\Addons\DiviBuilder\DiviBuilder;

use EverestForms\Traits\Singleton;

/**
* Addon class.
*
* @since xx.xx.xx
*/
class Addons {

use Singleton;

/**
* Class constructor.
*
* @since xx.xx.xx
*/
public function __construct() {
add_action( 'init', array( $this, 'addons_init' ) );
}

/**
* Get addon list.
*
* @since xx.xx.xx
*/
public function get_addon_list() {
/**
* Everest forms addon list.
*
* @since xx.xx.xx
* @return array List of addon class.
*/
return apply_filters(
'everest_forms_addon_list',
array(
'oxygen-builder' => OxygenBuilder::class,

Check failure on line 49 in addons/Addons.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4 , WP Latest)

The magic class constant ClassName::class was not available in PHP 5.4 or earlier
'divi-builder' => DiviBuilder::class,

Check failure on line 50 in addons/Addons.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4 , WP Latest)

The magic class constant ClassName::class was not available in PHP 5.4 or earlier
)
);
}

/**
* Initializes the Everest Forms addons.
*
* @since xx.xx.xx
*/
public function addons_init() {

$classes = $this->get_addon_list();

if ( empty( $classes ) ) {
return;
}

$enabled_features = get_option( 'everest_forms_enabled_features', array() );

if ( empty( $enabled_features ) ) {
return;
}

foreach ( $classes as $key => $class_name ) {
$key = 'everest-forms-' . $key;
if ( in_array( $key, $enabled_features, true ) ) {

if ( class_exists( $class_name ) ) {
$class_name::init();
}
}
}
}
}
60 changes: 60 additions & 0 deletions addons/DiviBuilder/DiviBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

Check failure on line 1 in addons/DiviBuilder/DiviBuilder.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4 , WP Latest)

Filenames should be all lowercase with hyphens as word separators. Expected divibuilder.php, but found DiviBuilder.php.

Check failure on line 1 in addons/DiviBuilder/DiviBuilder.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4 , WP Latest)

Class file names should be based on the class name with "class-" prepended. Expected class-divibuilder.php, but found DiviBuilder.php.
/**
* Divi builder integration.
*
* @since xx.xx.xx
* @package EverestForms\Addons\DiviBuilder\DiviBuilder
*/

Check failure on line 7 in addons/DiviBuilder/DiviBuilder.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4 , WP Latest)

There must be exactly one blank line after the file comment
namespace EverestForms\Addons\DiviBuilder;

use EverestForms\Traits\Singleton;
use EverestForms\Addons\DiviBuilder\Helper;
use EverestForms\Addons\DiviBuilder\EverestFormsModule;

/**
* DiviBuilder.
*
* @since xx.xx.xx
*/
class DiviBuilder {

use Singleton;

/**
* Constructor.
*
* @since xx.xx.xx
*/
public function __construct() {
$this->setup();
}
/**
* Init.
*
* @since xx.xx.xx
*/
public function setup() {

if ( ! Helper::is_divi_active() ) {

Helper::print_admin_notice();

return;
}

add_action( 'et_builder_ready', array( $this, 'everest_form_register_divi_builder' ) );
}

/**
* Function to check whether the divi module is loaded or not.
*
* @since xx.xx.xx
*/
public function everest_form_register_divi_builder() {
if ( ! class_exists( 'ET_Builder_Module' ) ) {
return;
}

new EverestFormsModule();
}
}
Loading
Loading