protected $_full_path = __FILE__;
protected $_title = 'Gravity Forms StreamSend Integration';
protected $_short_title = 'StreamSend';
+ protected $_errorFlag = false;
private static $_instance = null;
protected $streamSendFields = array(
'label' => esc_html__( 'Audience Id', 'StreamSend' ),
'type' => 'text',
'class' => 'small',
- 'feedback_callback' => array( $this, 'is_valid_setting' ),
+ 'feedback_callback' => array( $this, 'is_valid_audience' ),
)
)
)
}
public function feed_settings_fields() {
+ $settings = $this->get_plugin_settings();
+ $apiLogin = rgar($settings, 'glm_streamsend_login');
+ $apiKey = rgar($settings, 'glm_streamsend_key');
+ $ss = new StreamSend(STREAMSEND_BASE_URL, $apiLogin, $apiKey);
+// echo '<pre>', print_r($ss->listList(),true), '</pre>';
+ $lists = $ss->listList();
+ $lists = $lists->responseData->list;
+ for($i = 0; $i < count($lists); $i++){
+
+ }
+
+
return array(
array(
'title' => 'StreamSend Form Settings',
'checkbox_label' => esc_html__( 'Enable Condition', 'StreamSend' ),
'instructions' => esc_html__( 'Process this StreamSend feed if', 'StreamSend' ),
),
+ array(
+ 'name' => 'Lists',
+ 'label' => esc_html__( 'List', 'StreamSend' ),
+ 'type' => 'select',
+ 'checkbox_label' => esc_html__( 'Enable Condition', 'StreamSend' ),
+ 'instructions' => esc_html__( 'Process this StreamSend feed if', 'StreamSend' ),
+ ),
)
)
);
$apiKey = rgar($settings, 'glm_streamsend_key');
$ss = new StreamSend(STREAMSEND_BASE_URL, $apiLogin, $apiKey);
$ss->accountList();
-
+ $responseData[] = $ss->audienceList();
+ $audienceId = $responseData[0]->responseData->audience->id;
if ( $ss->responseHTTPStatus != 200){
- echo '<div class="push-alert-red" style="border-left: 1px solid #E6DB55; border-right: 1px solid #E6DB55;">';
- esc_html_e( 'Invalid Login or Key', 'gravityforms' );
+ echo '<div> ';
+ echo '<h4 style="color:red; margin: 2px;"> Invalid Login or API Key</h4>';
echo '</div>';
}
+ ?>
+ <script type="text/javascript">
+ document.addEventListener("DOMContentLoaded", function(event) {
+
+ var audienceId = "<?php echo $audienceId; ?>";
+ document.getElementById("glm_streamsend_audience").value = audienceId;
+ document.getElementById("glm_streamsend_audience").readOnly = true;
+ });
+ </script>
+ <?php
}
+ public function errorNotice(){
+ if($this->errorFlag){
+ echo '<div class="push-alert-red" style="border-left: 1px solid #E6DB55; border-right: 1px solid #E6DB55;"> ';
+ esc_html_e( 'This add-on needs to be updated. Please contact the developer.', 'gravityforms' );
+ echo '</div>';
+ }
+ }
+ public function __construct() {
+ parent::__construct();
+ }
+
public function process_feed( $feed, $entry, $form ) {
$feedName = $feed['meta']['feedName'];
$field_map = $this->get_field_map_fields( $feed, 'mappedFields' );