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 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
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 3.0.5
* @package EverestForms\Addons\Addons
*/

namespace EverestForms\Addons;

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

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

use Singleton;

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

/**
* Get addon list.
*
* @since 3.0.5
*/
public function get_addon_list() {
/**
* Everest forms addon list.
*
* @since 3.0.5
* @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 3.0.5
*/
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 3.0.5
* @package EverestForms\Addons\OxygenBuilder
*/

namespace EverestForms\Addons\OxygenBuilder;

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

/**
* Return if Oxygen is active.
*
* @since 3.0.5
*
* @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 3.0.5
*
* @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 3.0.5
*/
public static function print_admin_notice() {

add_action(
'admin_notices',
function () {
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 3.0.5
*/
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;
}
}
72 changes: 72 additions & 0 deletions addons/OxygenBuilder/OxygenBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?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 3.0.5
* @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 3.0.5
*/
class OxygenBuilder {

use Singleton;

/**
* Constructor.
*
* @since 3.0.5
*/
public function __construct() {
$this->setup();
}
/**
* Init.
*
* @since 3.0.5
*/
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();
}

/**
* Add accordion section in the elements.
*
* @since 3.0.5
*/
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 3.0.5
*/
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

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

Check failure on line 1 in addons/OxygenBuilder/OxygenElement.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-oxygenelement.php, but found OxygenElement.php.
/**
* Oxygen elements.
*
* @since 3.0.5
* @package EverestForms\Addons\OxygenBuilder\OxygenElement
*/

namespace EverestForms\Addons\OxygenBuilder;

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

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

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

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

return '';
}

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