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 - Oxygen builder integration #1349

Merged
merged 10 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
81 changes: 81 additions & 0 deletions addons/Addons.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?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\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 47 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();
}
}
}
}
}
80 changes: 80 additions & 0 deletions addons/OxygenBuilder/Helper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

Check failure on line 1 in addons/OxygenBuilder/Helper.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 helper.php, but found Helper.php.

Check failure on line 1 in addons/OxygenBuilder/Helper.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-helper.php, but found Helper.php.
/**
* Oxygen Integration helper functions.
*
* @since xx.xx.xx
* @package EverestForms\Addons\OxygenBuilder
*/

namespace EverestForms\Addons\OxygenBuilder;

/**
* Oxygen Integration helper functions.
*
* @package EverestForms\Addons\OxygenBuilder
*
* @since xx.xx.xx
*/
class Helper {

/**
* Return if Oxygen is active.
*
* @since xx.xx.xx
*
* @return boolean
*/
public static function is_oxygen_active() {
return in_array( 'oxygen/functions.php', get_option( 'active_plugins', array() ), true );
}

/**
* Check if the current request is for oxygen editor.
*
* @since xx.xx.xx
*
* @return boolean
*/
public static function is_oxygen_editor() {
return isset( $_REQUEST['action'] ) && ( in_array( $_REQUEST['action'], array( 'oxygen', 'oxygen_ajax' ), true ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
}

/**
* Notice if the oxygen is not instaled.
*
* @since xx.xx.xx
*/
public static function print_admin_notice() {

add_action(
'admin_notices',
function() {

Check failure on line 51 in addons/OxygenBuilder/Helper.php

View workflow job for this annotation

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

Expected 1 space after FUNCTION keyword; 0 found
printf(
'<div class="notice notice-warning is-dismissible"><p><strong>%s </strong>%s</p><button type="button" class="notice-dismiss"><span class="screen-reader-text">%s</span></button></div>',
esc_html( 'Everest Forms:' ),
wp_kses_post( 'Oxygen Integration addon requires Oxygen to be installed and activated.', 'everest-forms' ),
esc_html__( 'Dismiss this notice.', 'everest-forms' )
);
}
);

return;
}

/**
* Get the form list.
*
* @since xx.xx.xx
*/
public static function get_form_list() {
$forms = evf_get_all_forms();

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

$forms[0] = esc_html__( 'Select a Form', 'everest-forms' );

return $forms;
}
}
74 changes: 74 additions & 0 deletions addons/OxygenBuilder/OxygenBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

Check failure on line 1 in addons/OxygenBuilder/OxygenBuilder.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 oxygenbuilder.php, but found OxygenBuilder.php.

Check failure on line 1 in addons/OxygenBuilder/OxygenBuilder.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-oxygenbuilder.php, but found OxygenBuilder.php.
/**
* Oxygen builder integration.
*
* @since xx.xx.xx
* @package EverestForms\Addons\OxygenBuilder\OxygenBuilder
*/

Check failure on line 7 in addons/OxygenBuilder/OxygenBuilder.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\OxygenBuilder;

use EverestForms\Traits\Singleton;
use EverestForms\Addons\OxygenBuilder\Helper;

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

use Singleton;

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

if ( ! Helper::is_oxygen_active() ) {

Helper::print_admin_notice();

return;
}

if ( ! class_exists( 'OxyEl' ) ) {
return;
}

add_action( 'oxygen_add_plus_sections', array( $this, 'add_accordion_section' ) );
add_action( 'oxygen_add_plus_everest-forms_section_content', array( $this, 'register_add_plus_subsections' ) );

new OxygenFormWidget();

}

Check failure on line 53 in addons/OxygenBuilder/OxygenBuilder.php

View workflow job for this annotation

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

Function closing brace must go on the next line following the body; found 1 blank lines before brace

/**
* Add accordin section in the elements.
*
* @since xx.xx.xx
*/
public function add_accordion_section() {
$brand_name = __( 'Everest Forms', 'everest-forms' );
\CT_Toolbar::oxygen_add_plus_accordion_section( 'everest-forms', $brand_name );
}

/**
* Add subsection.
*
* @since xx.xx.xx
*/
public function register_add_plus_subsections() {
do_action( 'oxygen_add_plus_everest-forms_form' );
}

}
58 changes: 58 additions & 0 deletions addons/OxygenBuilder/OxygenElement.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* Oxygen elements.
*
* @since xx.xx.xx
* @package EverestForms\Addons\OxygenBuilder\OxygenElement
*/

namespace EverestForms\Addons\OxygenBuilder;

/**
* Oxygen elements.
*
* @since xx.xx.xx
*/
class OxygenElement extends \OxyEl {
/**
* Init.
*
* @since xx.xx.xx
*/
public function init() {
$this->El->useAJAXControls();
}

/**
* Class names.
*
* @since xx.xx.xx
*/
public function class_names() {
return array( 'evf-oxy-element' );
}

/**
* Accordion button places.
*
* @since xx.xx.xx
*/
public function button_place() {
$button_place = $this->accordion_button_place();

if ( $button_place ) {
return 'everest-forms::' . $button_place;
}

return '';
}

/**
* Button priority.
*
* @since xx.xx.xx
*/
public function button_priority() {
return '';
}
}
Loading
Loading