Skip to content

Commit 53a6d3a

Browse files
committed
Added a Gravity Flow Step Type for OpenAI. Credit: @Idealien
1 parent b4ba413 commit 53a6d3a

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

gravityforms-openai.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@
2929
require plugin_dir_path( __FILE__ ) . 'class-gwiz-gf-openai.php';
3030

3131
GFAddOn::register( 'GWiz_GF_OpenAI' );
32-
}, 5 );
32+
}, 0 ); // Load before Gravity Flow
33+
34+
/*
35+
* Gravity Flow compatibility.
36+
*/
37+
add_action( 'gravityflow_loaded', function() {
38+
require_once( gwiz_gf_openai()->get_base_path() . '/includes/class-gravity-flow-step-feed-gwiz-gf-openai.php' );
39+
40+
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_GWiz_GF_OpenAI() );
41+
} );
3342

3443
/**
3544
* Returns an instance of the GWiz_GF_OpenAI class
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
defined( 'ABSPATH' ) || die();
3+
4+
class Gravity_Flow_Step_Feed_GWiz_GF_OpenAI extends Gravity_Flow_Step_Feed_Add_On {
5+
/**
6+
* The step type.
7+
*
8+
* @var string
9+
*/
10+
public $_step_type = 'gwiz_gf_openai';
11+
12+
/**
13+
* The name of the class used by the add-on.
14+
*
15+
* @var string
16+
*/
17+
protected $_class_name = 'GWiz_GF_OpenAI';
18+
19+
/**
20+
* Returns the step label.
21+
*
22+
* @return string
23+
*/
24+
public function get_label() {
25+
return 'OpenAI';
26+
}
27+
28+
/**
29+
* Returns the step icon.
30+
*/
31+
public function get_icon_url() {
32+
return gwiz_gf_openai()->get_base_url() . '/icon.svg';
33+
}
34+
35+
/**
36+
* Returns the feed name.
37+
*
38+
* @param array $feed The Emma feed properties.
39+
*
40+
* @return string
41+
*/
42+
public function get_feed_label( $feed ) {
43+
$label = $feed['meta']['feed_name'];
44+
45+
return $label;
46+
}
47+
}

0 commit comments

Comments
 (0)