-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmarketo.php
1979 lines (1622 loc) · 91.6 KB
/
marketo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
Plugin Name: Gravity Forms Marketo Add-On
Plugin URI: https://katz.co/plugins/marketo/
Description: Integrates Gravity Forms with Marketo allowing form submissions to be automatically sent to your Marketo account
Version: 1.3.7.3
Author: Katz Web Services, Inc.
Author URI: https://katz.co
------------------------------------------------------------------------
Copyright 2014 Katz Web Services, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
add_action('init', array('GFMarketo', 'init'));
register_activation_hook( __FILE__, array("GFMarketo", "add_permissions"));
class GFMarketo {
private static $name = "Gravity Forms Marketo Add-On";
private static $path = "gravity-forms-marketo/marketo.php";
private static $url = "http://www.gravityforms.com";
private static $slug = "gravity-forms-marketo";
private static $version = "1.3.7.3";
private static $min_gravityforms_version = "1.3.9";
private static $is_debug = NULL;
private static $settings = array(
"endpoint" => '',
"user_id" => '',
"encryption_key" => false,
"subdomain" => '',
"sync_type" => 'munchkin',
"add_munchkin_js" => true,
"fill_munchkin" => true,
"debug" => false,
);
//Plugin starting point. Will load appropriate files
public static function init(){
global $pagenow;
load_plugin_textdomain('gravity-forms-marketo', FALSE, '/gravity-forms-marketo/languages' );
if($pagenow === 'plugins.php') {
add_action("admin_notices", array('GFMarketo', 'is_gravity_forms_installed'), 10);
}
if(self::is_gravity_forms_installed(false, false) === 0){
add_action('after_plugin_row_' . self::$path, array('GFMarketo', 'plugin_row') );
return;
}
add_filter('plugin_action_links', array('GFMarketo', 'settings_link'), 10, 2 );
if(!self::is_gravityforms_supported()){
return;
}
if(is_admin()){
//loading translations
load_plugin_textdomain('gravity-forms-marketo', FALSE, '/gravity-forms-marketo/languages' );
//creates a new Settings page on Gravity Forms' settings screen
if(self::has_access("gravityforms_marketo")){
RGForms::add_settings_page("Marketo", array("GFMarketo", "settings_page"), self::get_base_url() . "/images/marketo_wordpress_icon_32.png");
}
}
//integrating with Members plugin
if(function_exists('members_get_capabilities'))
add_filter('members_get_capabilities', array("GFMarketo", "members_get_capabilities"));
//creates the subnav left menu
add_filter("gform_addon_navigation", array('GFMarketo', 'create_menu'));
if(self::is_marketo_page()){
//enqueueing sack for AJAX requests
wp_enqueue_script(array("sack"));
wp_enqueue_script("gforms_gravityforms", GFCommon::get_base_url() . "/js/gravityforms.js", null, GFCommon::$version);
wp_enqueue_style("gforms_css", GFCommon::get_base_url() . "/css/forms.css", null, GFCommon::$version);
//loading data lib
require_once(self::get_base_path() . "/data.php");
self::setup_tooltips();
//runs the setup when version changes
self::setup();
}
else if(in_array(RG_CURRENT_PAGE, array("admin-ajax.php"))){
//loading data class
require_once(self::get_base_path() . "/data.php");
add_action('wp_ajax_rg_update_feed_active', array('GFMarketo', 'update_feed_active'));
add_action('wp_ajax_gf_select_marketo_form', array('GFMarketo', 'select_marketo_form'));
}
else{
//handling post submission.
add_action( 'gform_after_submission', array( 'GFMarketo', 'export'), 10, 2);
}
add_action('gform_entry_info', array('GFMarketo', 'entry_info_link_to_marketo'), 1, 2);
add_filter('gform_save_field_value', array('GFMarketo', 'save_field_value'), 10, 4);
add_filter('gform_entry_post_save', array('GFMarketo', 'gform_entry_post_save'), 1, 2);
add_filter('gform_replace_merge_tags', array('GFMarketo', 'replace_merge_tag'), 1, 7);
add_action("gform_custom_merge_tags", array('GFMarketo', "_deprecated_add_merge_tags"), 1, 4);
add_action("gform_admin_pre_render", array('GFMarketo', "add_merge_tags"));
add_filter('gform_pre_render', array('GFMarketo', 'merge_tag_gform_pre_render_filter'), 1, 4);
add_action('gform_enqueue_scripts', array('GFMarketo', 'add_munchkin_js'), 10, 2 );
add_action('wp_footer', array('GFMarketo', 'add_munchkin_js'));
}
/**
* Get the Munchkin ID from the Endpoint URL setting
* @return string Munchkin ID
*/
static function get_munchkin_id() {
return preg_replace('/https?:\/\/(.*?)\..+/ism', '$1', self::get_setting('endpoint'));
}
/**
* Add the Munchkin tracking code to the site's footer or when Gravity Forms is output
*
* @param array|null $form Gravity Forms form array, if triggered by `gform_enqueue_scripts`
* @param boolean $ajax Gravity Forms is ajax boolean, if triggered by `gform_enqueue_scripts`
*/
static function add_munchkin_js($form = array(), $ajax = false) {
if(!self::get_setting('add_munchkin_js')) { return; }
if(function_exists('marketo_tracker')) {
if(current_user_can('manage_options')) { echo "\n".'<!-- Gravity Forms Marketo Addon did not load the munchkin cookie because the Marketo Tracker plugin is activated. -->'."\n\n"; }
return;
}
if(did_action( 'gf_marketo_add_munchkin_js' )) { return; }
//loading data class
require_once(self::get_base_path() . "/data.php");
$feeds = GFMarketoData::get_feeds();
if(!empty($form) && !empty($form['id'])) {
foreach($feeds as $feed) {
if(floatval($feed['id']) !== floatval($form['id'])) { continue; }
}
}
// Enqueue munchkin.js & init (since 1.3.7.1)
wp_enqueue_script( 'munchkin-js', 'https://ssl-munchkin.marketo.net/js/munchkin.js', array('jquery'), '44633', true );
wp_enqueue_script( 'marketo-js', plugins_url('includes/marketo.js', __FILE__), array('munchkin-js'), '', true );
wp_localize_script( 'marketo-js', 'marketo_vars', array( 'munchkin_id' => self::get_munchkin_id() ) );
do_action('gf_marketo_add_munchkin_js');
}
/**
* Process the {munchkin} merge tag before the field is saved into GF database
*/
static function save_field_value($value, $lead, $field, $form) {
return self::replace_merge_tag($value);
}
/**
* Replace {munchkin} with the cookie value, if cookie exists
*/
static function replace_merge_tag($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true, $nl2br = false, $format = false) {
$custom_merge_tag = '{munchkin}';
$cookie = self::get_munchkin_cookie();
if(strpos($text, $custom_merge_tag) === false || empty($cookie)) {
return $text;
}
$text = str_replace($custom_merge_tag, $cookie, $text);
return $text;
}
/**
* Add Marketo {munchkin} merge tag
*
* The new way of adding merge tags since GF 1.7
*
* @param array $form Current GF form array
* @deprecated
*/
static function _deprecated_add_merge_tags($merge_tags, $form_id, $fields, $element_id) {
if(version_compare(GFCommon::$version, '1.7', "<")) {
$merge_tags[] = array('label' => __('Munchkin Cookie Data', 'gravity-forms-marketo'), 'tag' => '{munchkin}');
}
return $merge_tags;
}
/**
* Add Marketo {munchkin} merge tag
*
* The new way of adding merge tags since GF 1.7
*
* @param array $form Current GF form array
*/
function add_merge_tags($form){
?>
<script>
gform.addFilter("gform_merge_tags", "marketo_add_merge_tags");
function marketo_add_merge_tags(mergeTags, elementId, hideAllFields, excludeFieldTypes, isPrepop, option){
mergeTags["custom"].tags.push({ tag: '{munchkin}', label: '<?php echo str_replace("'", "\'", __('Munchkin Cookie Data')); ?>' });
return mergeTags;
}
</script>
<?php
//return the form object from the php hook
return $form;
}
static function merge_tag_gform_pre_render_filter($form){
foreach($form['fields'] as &$field) {
if( array_key_exists( 'defaultValue', $field ) ) {
$field['defaultValue'] = self::replace_merge_tag($field['defaultValue'] );
}
}
return $form;
}
static function get_munchkin_cookie() {
return isset($_COOKIE['_mkto_trk']) ? $_COOKIE['_mkto_trk'] : NULL;
}
/**
* If a form has a parameter named "munchkin", fill in the data with the cookie data.
*
* Looks for a field with the inputName "munchkin", then fills it with $_COOKIE['_mkto_trk'];
*
* @param array $lead GF Lead
* @param array $form GF Form
* @return array modified $lead
*/
static function gform_entry_post_save($lead, $form) {
if(!self::get_setting('fill_munchkin')) { return $lead; }
// get all HTML fields on the current page
foreach($form['fields'] as &$field) {
if(trim(rtrim(rgar($field, 'inputName'))) === 'munchkin') {
$lead[$field['id']] = self::get_munchkin_cookie();
}
}
// Replace the variables in the content, since the stupid `gform_replace_merge_tags` won't do it.
foreach($lead as &$input) {
$input = self::replace_merge_tag($input, $form, $lead, false, false);
}
return $lead;
}
public static function is_gravity_forms_installed($asd = '', $echo = true) {
global $pagenow, $page; $message = '';
$installed = 0;
$name = self::$name;
if(!class_exists('RGForms')) {
if(file_exists(WP_PLUGIN_DIR.'/gravityforms/gravityforms.php')) {
$installed = 1;
$message .= __(sprintf('%sGravity Forms is installed but not active. %sActivate Gravity Forms%s to use the %s plugin.%s', '<p>', '<strong><a href="'.wp_nonce_url(admin_url('plugins.php?action=activate&plugin=gravityforms/gravityforms.php'), 'activate-plugin_gravityforms/gravityforms.php').'">', '</a></strong>', $name,'</p>'), 'gravity-forms-marketo');
} else {
$message .= <<<EOD
<p><a href="http://katz.si/gravityforms?con=banner" title="Gravity Forms Contact Form Plugin for WordPress"><img src="http://gravityforms.s3.amazonaws.com/banners/728x90.gif" alt="Gravity Forms Plugin for WordPress" width="728" height="90" style="border:none;" /></a></p>
<h3><a href="http://katz.si/gravityforms" target="_blank">Gravity Forms</a> is required for the $name</h3>
<p>You do not have the Gravity Forms plugin installed. <a href="http://katz.si/gravityforms">Get Gravity Forms</a> today.</p>
EOD;
}
if(!empty($message) && $echo) {
echo '<div id="message" class="updated">'.$message.'</div>';
}
} else {
return true;
}
return $installed;
}
public static function plugin_row(){
if(!self::is_gravityforms_supported()){
$message = sprintf(__("%sGravity Forms%s is required. %sPurchase it today!%s"), "<a href='http://katz.si/gravityforms'>", "</a>", "<a href='http://katz.si/gravityforms'>", "</a>");
self::display_plugin_message($message, true);
}
}
public static function display_plugin_message($message, $is_error = false){
$style = '';
if($is_error)
$style = 'style="background-color: #ffebe8;"';
echo '</tr><tr class="plugin-update-tr"><td colspan="5" class="plugin-update"><div class="update-message" ' . $style . '>' . $message . '</div></td>';
}
public static function update_feed_active(){
check_ajax_referer('rg_update_feed_active','rg_update_feed_active');
$id = $_POST["feed_id"];
$feed = GFMarketoData::get_feed($id);
GFMarketoData::update_feed($id, $feed["form_id"], $_POST["is_active"], $feed["meta"]);
}
//-------------- Automatic upgrade ---------------------------------------------------
static function settings_link( $links, $file ) {
static $this_plugin;
if( ! $this_plugin ) $this_plugin = plugin_basename(__FILE__);
if ( $file == $this_plugin ) {
$settings_link = '<a href="' . admin_url( 'admin.php?page=gf_marketo' ) . '" title="' . __('Select the Gravity Form you would like to integrate with Marketo. Contacts generated by this form will be automatically added to your Marketo account.', 'gravity-forms-marketo') . '">' . __('Feeds', 'gravity-forms-marketo') . '</a>';
array_unshift( $links, $settings_link ); // before other links
$settings_link = '<a href="' . admin_url( 'admin.php?page=gf_settings&addon=Marketo' ) . '" title="' . __('Configure your Marketo settings.', 'gravity-forms-marketo') . '">' . __('Settings', 'gravity-forms-marketo') . '</a>';
array_unshift( $links, $settings_link ); // before other links
}
return $links;
}
//Returns true if the current page is an Feed pages. Returns false if not
private static function is_marketo_page(){
global $plugin_page; $current_page = '';
$marketo_pages = array("gf_marketo");
if(isset($_GET['page'])) {
$current_page = trim(strtolower($_GET["page"]));
}
return (in_array($plugin_page, $marketo_pages) || in_array($current_page, $marketo_pages));
}
//Creates or updates database tables. Will only run when version changes
private static function setup(){
if(get_site_option("gf_marketo_version") != self::$version)
GFMarketoData::update_table();
update_site_option("gf_marketo_version", self::$version);
}
static function setup_tooltips() {
//loading Gravity Forms tooltips
require_once(GFCommon::get_base_path() . "/tooltips.php");
add_action("admin_print_scripts", 'print_tooltip_scripts');
add_filter('gform_tooltips', array('GFMarketo', 'tooltips'));
}
//Adds feed tooltips to the list of tooltips
public static function tooltips($tooltips){
$marketo_tooltips = array(
"marketo_contact_list" => "<h6>" . __("Marketo List", "gravity-forms-marketo") . "</h6>" . __("Select the Marketo list you would like to add your contacts to.", "gravity-forms-marketo"),
"marketo_gravity_form" => "<h6>" . __("Gravity Form", "gravity-forms-marketo") . "</h6>" . __("Select the Gravity Form you would like to integrate with Marketo. Contacts generated by this form will be automatically added to your Marketo account.", "gravity-forms-marketo"),
"marketo_map_fields" => "<h6>" . __("Map Fields", "gravity-forms-marketo") . "</h6>" . __("Associate your Marketo attributes to the appropriate Gravity Form fields by selecting.", "gravity-forms-marketo"),
"marketo_optin_condition" => "<h6>" . __("Opt-In Condition", "gravity-forms-marketo") . "</h6>" . __("When the opt-in condition is enabled, form submissions will only be exported to Marketo when the condition is met. When disabled all form submissions will be exported.", "gravity-forms-marketo"),
"marketo_tag" => "<h6>" . __("Entry Tags", "gravity-forms-marketo") . "</h6>" . __("Add these tags to every entry (in addition to any conditionally added tags below).", "gravity-forms-marketo"),
"marketo_tag_optin_condition" => "<h6>" . __("Conditionally Added Tags", "gravity-forms-marketo") . "</h6>" . __("Tags will be added to the entry when the conditions specified are met. Does not override the 'Entry Tags' setting above (which are applied to all entries).", "gravity-forms-marketo"),
);
return array_merge($tooltips, $marketo_tooltips);
}
//Creates Marketo left nav menu under Forms
public static function create_menu($menus){
// Adding submenu if user has access
$permission = self::has_access("gravityforms_marketo");
if(!empty($permission))
$menus[] = array("name" => "gf_marketo", "label" => __("Marketo", "gravity-forms-marketo"), "callback" => array("GFMarketo", "marketo_page"), "permission" => $permission);
return $menus;
}
public static function is_debug() {
if(is_null(self::$is_debug)) {
self::$is_debug = self::get_setting('debug') && current_user_can('manage_options') && !is_admin();
}
return self::$is_debug;
}
static public function get_setting($key) {
$settings = self::get_settings();
return isset($settings[$key]) ? (empty($settings[$key]) ? false : $settings[$key]) : false;
}
static public function get_settings() {
$settings = get_site_option("gf_marketo_settings");
if(!empty($settings)) {
self::$settings = $settings;
} else {
$settings = self::$settings;
}
return $settings;
}
public static function settings_page(){
if(isset($_POST["uninstall"])){
check_admin_referer("uninstall", "gf_marketo_uninstall");
self::uninstall();
?>
<div class="updated fade" style="padding:20px;"><?php _e(sprintf("Gravity Forms Marketo Add-On has been successfully uninstalled. It can be re-activated from the %splugins page%s.", "<a href='plugins.php'>","</a>"), "gravity-forms-marketo")?></div>
<?php
return;
}
else if(isset($_POST["gf_marketo_submit"])){
check_admin_referer("update", "gf_marketo_update");
$settings = array(
"endpoint" => stripslashes($_POST["gf_marketo_endpoint"]),
"user_id" => stripslashes($_POST["gf_marketo_user_id"]),
"encryption_key" => stripslashes($_POST["gf_marketo_encryption_key"]),
"subdomain" => stripslashes($_POST["gf_marketo_subdomain"]),
"sync_type" => stripslashes($_POST["gf_marketo_sync_type"]),
"add_munchkin_js" => isset($_POST["gf_marketo_add_munchkin_js"]),
"fill_munchkin" => isset($_POST["gf_marketo_fill_munchkin"]),
"debug" => isset($_POST["gf_marketo_debug"]),
);
update_site_option("gf_marketo_settings", $settings);
}
else{
$settings = self::get_settings();
}
?>
<img alt="<?php _e("Marketo Logo", "gravity-forms-marketo") ?>" src="<?php echo self::get_base_url()?>/images/marketo-logo.jpg" style="margin:0 0 15px 0; display:block;" width="161" height="70" />
<?php
if(!get_site_option( 'gf_marketo_settings' )) {
include_once(plugin_dir_path(__FILE__).'register.php');
flush();
}
$soap = self::check_soap();
if(!$soap) {
?>
<h2><?php _e('SOAP Required', 'gravity-forms-marketo'); ?></h2>
<p style="font-size:1.2em"><?php _e('This plugin requires your server to have SOAP installed and enabled. Contact your web host to have them enable SOAP for your account.'); ?></p>
<?php
return;
}
$valid = self::test_api(true);
$get_timezone = wp_get_timezone_string();
?>
<style type="text/css">ol li, li.ol-decimal { list-style: decimal outside; }</style>
<form method="post" action="<?php echo add_query_arg(array('settings-updated' => true), remove_query_arg(array('refresh', 'retrieveListNames', '_wpnonce'))); ?>">
<?php wp_nonce_field("update", "gf_marketo_update") ?>
<h2><?php _e("Marketo Account Information", "gravity-forms-marketo") ?></h2>
<?php
if($get_timezone === 'UTC') {
echo '<div class="updated inline">';
printf(wpautop(__('Your website timezone is UTC. This may be because your timezone is not compatible with this plugin. Please check your %sWordPress Timezone settings%s and confirm the settings are accurate. If possible, use the location setting instead of the UTC offset setting.', 'gravity-forms-marketo')), '<a href="">', '</a>');
echo '</div>';
}
?>
<table class="form-table" style="clear:none; width:auto;">
<tr>
<th scope="row"><label for="gf_marketo_endpoint"><?php _e("Marketo SOAP Endpoint URL", "gravity-forms-marketo"); ?></label> </th>
<td><input type="text" id="gf_marketo_endpoint" class="text code" size="50" name="gf_marketo_endpoint" placeholder="https://example.mktoapi.com/soap/mktows/2_1" value="<?php esc_attr_e(@$settings["endpoint"]); ?>"/></td>
</tr>
<tr>
<th scope="row"><label for="gf_marketo_user_id"><?php _e("Marketo User ID <span class='howto'>Access Key</span>", "gravity-forms-marketo"); ?></label> </th>
<td><input type="text" id="gf_marketo_user_id" class="text code" size="50" name="gf_marketo_user_id" placeholder="exampleusername_1234123456123A1B2CD34" value="<?php esc_attr_e(@$settings["user_id"]); ?>"/></td>
</tr>
<tr>
<th scope="row"><label for="gf_marketo_encryption_key"><?php _e("Marketo Encryption Key <span class='howto'>Secret Key</span>", "gravity-forms-marketo"); ?></label> </th>
<td><input type="text" id="gf_marketo_encryption_key" class="text code" size="50" name="gf_marketo_encryption_key" placeholder="19406578945682347776244128566478864311865A48" value="<?php esc_attr_e(@$settings["encryption_key"]); ?>"/></td>
</tr>
<tr>
<th scope="row"><label><?php _e("Lead Identifier", "gravity-forms-marketo"); ?></label> </th>
<td>
<label for="gf_marketo_sync_type_munchkin"><input type="radio" id="gf_marketo_sync_type_munchkin" class="radio" name="gf_marketo_sync_type" value="munchkin" <?php checked(@$settings["sync_type"] !== 'email', true); ?>" /> <?php _e('Munchkin Cookie', 'gravity-forms-marketo'); ?></label>
<label for="gf_marketo_sync_type_email" style="padding-left:1em;"><input type="radio" id="gf_marketo_sync_type_email" class="radio" name="gf_marketo_sync_type" value="email" <?php checked(@$settings["sync_type"] === 'email', true); ?> /> <?php _e('Email Address', 'gravity-forms-marketo'); ?></label>
</td>
</tr>
<tr>
<th scope="row"><label for="gf_marketo_subdomain"><?php _e("Marketo Subdomain", "gravity-forms-marketo"); ?></label> </th>
<td><input type="text" id="gf_marketo_subdomain" class="text code" size="50" name="gf_marketo_subdomain" placeholder="app-ab12" value="<?php esc_attr_e(@$settings["subdomain"]); ?>"/></td>
</tr>
<tr>
<th scope="row"><label for="gf_marketo_add_munchkin_js"><?php _e("Add Munchkin Javascript", "gravity-forms-marketo"); ?></label> </th>
<td><input type="checkbox" id="gf_marketo_add_munchkin_js" class="checkbox" name="gf_marketo_add_munchkin_js" <?php checked(!empty($settings["add_munchkin_js"])); ?> /> <span class="howto"><?php _e('Add the Munchkin tracking javascript to each page of the website?', 'gravity-forms-marketo'); ?></span></td>
</tr>
<tr>
<th scope="row"><label for="gf_marketo_fill_munchkin"><?php _e("Fill Munchkin Data", "gravity-forms-marketo"); ?></label></th>
<td>
<input type="checkbox" id="gf_marketo_fill_munchkin" class="checkbox" name="gf_marketo_fill_munchkin" <?php checked(!empty($settings["fill_munchkin"])); ?> /> <label for="gf_marketo_fill_munchkin" class="description block"><?php _e('Allow populating fields with Munchkin tracking data.', 'gravity-forms-marketo'); ?></label>
<div class="howto"><?php printf(__('To implement, either: %sSet the input Default Value to %s{munchkin}%s, or%sSet the "Input" > "Advanced" > "Allow Field to be Populated Dynamically" > "Parameter Name" to %smunchkin%s.%sIt is recommended to make fields with Munchkin data "Admin Only"%s.' , 'gravity-forms-marketo'), '<ol class="ol-decimal"><li>', '<code>', '</code>', '</li><li>', '<code>', '</code>', '</li></ol> <em>', '</em>'); ?></div>
</td>
</tr>
<tr>
<th scope="row"><label for="gf_marketo_debug"><?php _e("Debug Form Submissions for Administrators", "gravity-forms-marketo"); ?></label> </th>
<td><input type="checkbox" id="gf_marketo_debug" class="checkbox" name="gf_marketo_debug" <?php checked(!empty($settings["debug"])); ?> /> <span class="howto"><?php _e('Helpful debugging data is shown to logged-in users who have capability to manage plugin options.', 'gravity-forms-marketo'); ?></span></td>
</tr>
<tr>
<td colspan="2" >
<input type="submit" name="gf_marketo_submit" class="button-primary button button-large" value="<?php _e("Save Settings", "gravity-forms-marketo") ?>" />
</td>
</tr>
</table>
<form action="" method="post">
<?php
flush();
wp_nonce_field("uninstall", "gf_marketo_uninstall") ?>
<?php if(GFCommon::current_user_can_any("gravityforms_marketo_uninstall")){ ?>
<div class="hr-divider"></div>
<h3><?php _e("Uninstall Marketo Add-On", "gravity-forms-marketo") ?></h3>
<div class="delete-alert"><?php _e("Warning! This operation deletes ALL Marketo Feeds.", "gravity-forms-marketo") ?>
<?php
$uninstall_button = '<input type="submit" name="uninstall" value="' . __("Uninstall Marketo Add-On", "gravity-forms-marketo") . '" class="button" onclick="return confirm(\'' . __("Warning! ALL Marketo Feeds will be deleted. This cannot be undone. \'OK\' to delete, \'Cancel\' to stop", "gravity-forms-marketo") . '\');"/>';
echo apply_filters("gform_marketo_uninstall_button", $uninstall_button);
?>
</div>
<?php } ?>
</form>
<?php
}
public static function marketo_page(){
$view = isset($_GET["view"]) ? $_GET["view"] : '';
if($view == "edit")
self::edit_page($_GET["id"]);
else
self::list_page();
}
//Displays the Marketo feeds list page
private static function list_page(){
if(!self::is_gravityforms_supported()){
die(__(sprintf("The Marketo Add-On requires Gravity Forms %s. Upgrade automatically on the %sPlugin page%s.", self::$min_gravityforms_version, "<a href='plugins.php'>", "</a>"), "gravity-forms-marketo"));
}
if(isset($_POST["action"]) && $_POST["action"] == "delete"){
check_admin_referer("list_action", "gf_marketo_list");
$id = absint($_POST["action_argument"]);
GFMarketoData::delete_feed($id);
?>
<div class="updated fade" style="padding:6px"><?php _e("Feed deleted.", "gravity-forms-marketo") ?></div>
<?php
}
else if (!empty($_POST["bulk_action"])){
check_admin_referer("list_action", "gf_marketo_list");
$selected_feeds = $_POST["feed"];
if(is_array($selected_feeds)){
foreach($selected_feeds as $feed_id)
GFMarketoData::delete_feed($feed_id);
}
?>
<div class="updated fade" style="padding:6px"><?php _e("Feeds deleted.", "gravity-forms-marketo") ?></div>
<?php
}
?>
<div class="wrap">
<img alt="<?php _e("Marketo Feeds", "gravity-forms-marketo") ?>" src="<?php echo self::get_base_url()?>/images/marketo-logo.jpg" style="margin:15px 7px 0 0; display:block;" width="161" height="70" />
<h2><?php _e("Marketo Feeds", "gravity-forms-marketo"); ?>
<a class="button add-new-h2" href="admin.php?page=gf_marketo&view=edit&id=0"><?php _e("Add New", "gravity-forms-marketo") ?></a>
</h2>
<div class="updated" id="message" style="margin-top:20px;">
<p><?php printf(__('Do you like this free plugin? %sPlease review it on WordPress.org%s!', 'gravity-forms-marketo'), '<a href="http://katz.si/gfratemarketo">', '</a>'); ?></p>
</div>
<div class="clear"></div>
<ul class="subsubsub" style="margin-top:0;">
<li><a href="<?php echo admin_url('admin.php?page=gf_settings&addon=Marketo'); ?>"><?php _e('Marketo Settings', 'gravity-forms-marketo'); ?></a> |</li>
<li><a href="<?php echo admin_url('admin.php?page=gf_marketo'); ?>" class="current"><?php _e('Marketo Feeds', 'gravity-forms-marketo'); ?></a></li>
</ul>
<form id="feed_form" method="post">
<?php wp_nonce_field('list_action', 'gf_marketo_list') ?>
<input type="hidden" id="action" name="action"/>
<input type="hidden" id="action_argument" name="action_argument"/>
<div class="tablenav">
<div class="alignleft actions" style="padding:8px 0 7px; 0">
<label class="hidden" for="bulk_action"><?php _e("Bulk action", "gravity-forms-marketo") ?></label>
<select name="bulk_action" id="bulk_action">
<option value=''> <?php _e("Bulk action", "gravity-forms-marketo") ?> </option>
<option value='delete'><?php _e("Delete", "gravity-forms-marketo") ?></option>
</select>
<?php
echo '<input type="submit" class="button" value="' . __("Apply", "gravity-forms-marketo") . '" onclick="if( jQuery(\'#bulk_action\').val() == \'delete\' && !confirm(\'' . __("Delete selected feeds? ", "gravity-forms-marketo") . __("\'Cancel\' to stop, \'OK\' to delete.", "gravity-forms-marketo") .'\')) { return false; } return true;"/>';
?>
</div>
</div>
<table class="widefat fixed" cellspacing="0">
<thead>
<tr>
<th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
<th scope="col" id="active" class="manage-column check-column"></th>
<th scope="col" class="manage-column"><?php _e("Form", "gravity-forms-marketo") ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
<th scope="col" id="active" class="manage-column check-column"></th>
<th scope="col" class="manage-column"><?php _e("Form", "gravity-forms-marketo") ?></th>
</tr>
</tfoot>
<tbody class="list:user user-list">
<?php
$settings = GFMarketoData::get_feeds();
if(is_array($settings) && !empty($settings)){
foreach($settings as $setting){
?>
<tr class='author-self status-inherit' valign="top">
<th scope="row" class="check-column"><input type="checkbox" name="feed[]" value="<?php echo $setting["id"] ?>"/></th>
<td><img src="<?php echo self::get_base_url() ?>/images/active<?php echo intval($setting["is_active"]) ?>.png" alt="<?php echo $setting["is_active"] ? __("Active", "gravity-forms-marketo") : __("Inactive", "gravity-forms-marketo");?>" title="<?php echo $setting["is_active"] ? __("Active", "gravity-forms-marketo") : __("Inactive", "gravity-forms-marketo");?>" onclick="ToggleActive(this, <?php echo $setting['id'] ?>); " /></td>
<td class="column-title">
<a href="admin.php?page=gf_marketo&view=edit&id=<?php echo $setting["id"] ?>" title="<?php _e("Edit", "gravity-forms-marketo") ?>"><?php echo $setting["form_title"] ?></a>
<div class="row-actions">
<span class="edit">
<a title="Edit this setting" href="admin.php?page=gf_marketo&view=edit&id=<?php echo $setting["id"] ?>" title="<?php _e("Edit", "gravity-forms-marketo") ?>"><?php _e("Edit", "gravity-forms-marketo") ?></a>
|
</span>
<span class="edit">
<a title="<?php _e("Delete", "gravity-forms-marketo") ?>" href="javascript: if(confirm('<?php _e("Delete this feed? ", "gravity-forms-marketo") ?> <?php _e("\'Cancel\' to stop, \'OK\' to delete.", "gravity-forms-marketo") ?>')){ DeleteSetting(<?php echo $setting["id"] ?>);}"><?php _e("Delete", "gravity-forms-marketo")?></a>
|
</span>
<span class="edit">
<a title="<?php _e("Edit Form", "gravity-forms-marketo") ?>" href="<?php echo add_query_arg(array('page' => 'gf_edit_forms', 'id' => $setting['form_id']), admin_url('admin.php')); ?>"><?php _e("Edit Form", "gravity-forms-marketo")?></a>
|
</span>
<span class="edit">
<a title="<?php _e("Preview Form", "gravity-forms-marketo") ?>" href="<?php echo add_query_arg(array('gf_page' => 'preview', 'id' => $setting['form_id']), site_url()); ?>"><?php _e("Preview Form", "gravity-forms-marketo")?></a>
</span>
</div>
</td>
</tr>
<?php
}
}
else {
$valid = self::test_api();
if(!empty($valid)){
?>
<tr>
<td colspan="4" style="padding:20px;">
<?php _e(sprintf("You don't have any Marketo feeds configured. Let's go %screate one%s!", '<a href="'.admin_url('admin.php?page=gf_marketo&view=edit&id=0').'">', "</a>"), "gravity-forms-marketo"); ?>
</td>
</tr>
<?php
} else{
?>
<tr>
<td colspan="4" style="padding:20px;">
<?php _e(sprintf("To get started, please configure your %sMarketo Settings%s.", '<a href="admin.php?page=gf_settings&addon=Marketo">', "</a>"), "gravity-forms-marketo"); ?>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</form>
</div>
<script>
function DeleteSetting(id){
jQuery("#action_argument").val(id);
jQuery("#action").val("delete");
jQuery("#feed_form")[0].submit();
}
function ToggleActive(img, feed_id){
var is_active = img.src.indexOf("active1.png") >=0
if(is_active){
img.src = img.src.replace("active1.png", "active0.png");
jQuery(img).attr('title','<?php _e("Inactive", "gravity-forms-marketo") ?>').attr('alt', '<?php _e("Inactive", "gravity-forms-marketo") ?>');
}
else{
img.src = img.src.replace("active0.png", "active1.png");
jQuery(img).attr('title','<?php _e("Active", "gravity-forms-marketo") ?>').attr('alt', '<?php _e("Active", "gravity-forms-marketo") ?>');
}
var mysack = new sack("<?php echo admin_url("admin-ajax.php")?>" );
mysack.execute = 1;
mysack.method = 'POST';
mysack.setVar( "action", "rg_update_feed_active" );
mysack.setVar( "rg_update_feed_active", "<?php echo wp_create_nonce("rg_update_feed_active") ?>" );
mysack.setVar( "feed_id", feed_id );
mysack.setVar( "is_active", is_active ? 0 : 1 );
mysack.encVar( "cookie", document.cookie, false );
mysack.onError = function() { alert('<?php _e("Ajax error while updating feed", "gravity-forms-marketo" ) ?>' )};
mysack.runAJAX();
return true;
}
</script>
<?php
}
/**
* Setup the Marketo API client using the plugin settings
* @return boolean| [description]
*/
public static function get_api($return_exceptions = false){
// Setup the client
$accessKey = self::get_setting('user_id');
$secretKey = self::get_setting('encryption_key');
$soapEndPoint = self::get_setting('endpoint');
$debug = self::get_setting('debug');
if(!self::check_soap()) { return false; }
if(!empty($soapEndPoint)) {
$parsed = @parse_url($soapEndPoint);
if(isset($parsed['host'])) {
$soapHost = $parsed['host'];
}
}
if(empty($accessKey) || empty($secretKey) || empty($soapEndPoint)) {
return false;
}
if(!class_exists("MarketoClient"))
require_once(plugin_dir_path(__FILE__)."api/Marketo_SOAP_PHP_Client.php");
try {
$client = new MarketoClient($accessKey, $secretKey, $soapEndPoint, $debug);
$client->setTimeZone(wp_get_timezone_string());
if(defined('DOING_AJAX') || !current_user_can('manage_options') || is_admin()) {
$client->setDebug(false);
}
if(current_user_can( 'manage_options' ) && isset($_GET['debug'])) {
$client->setDebug(true);
}
} catch(Exception $e) {
if($return_exceptions) { return $e; }
return false;
}
return $client;
}
static function check_soap() {
return(extension_loaded('soap') || class_exists("SOAPClient"));
}
private static function test_api($echo = false) {
$works = true; $message = ''; $class = '';
$endpoint = self::get_setting('endpoint');
$user_id = self::get_setting('user_id');
$encryption_key = self::get_setting('encryption_key');
if(empty($endpoint) && empty($encryption_key)) {
$works = false;
} elseif(empty($encryption_key)) {
$message = wpautop(__('Your Encryption Key is required, please <label for="gf_marketo_encryption_key"><a>enter your Encryption Key below</a></label>.', 'gravity-forms-marketo'));
$works = false;
} elseif(empty($user_id)) {
$message = wpautop(sprintf(__('Your User ID is required, please %senter your User ID below%s.', 'gravity-forms-marketo'), '<label for="gf_marketo_user_id"><a>', '</a></label>'));
$works = false;
} else {
$api = self::get_api(true);
try {
$campaigns = $api->getCampaignsForSource();
} catch(Exception $e) {
$message = $api->getMessage();
$works = false;
}
if(!empty($api) && is_a($api, 'Exception')) {
$message = wpautop(str_replace('[', __('Error key: [', 'gravity-forms-marketo'), str_replace(']', ']<br />Error message: ', $api->getMessage())));
$works = false;
} else if(is_wp_error($campaigns)) {
$message = sprintf(__('There was an error: %s', 'gravity-forms-marketo'), $campaigns->get_error_message());
$works = false;
} else {
$message = __('Your configuration appears to be working.', 'gravity-forms-marketo');
$works = true;
}
}
if($message && $echo && !defined('DOING_AJAX')) {
$class = empty($class) ? ($works ? "updated inline" : "error inline") : $class;
echo sprintf('<div id="message" class="%s" style="display:block!important">%s</div>', $class, wpautop($message));
}
return $works;
}
static function r($content, $die = false) {
echo '<pre>'.print_r($content, true).'</pre>';
if($die) { die(); }
}
private static function edit_page(){
if(isset($_REQUEST['cache'])) {
delete_site_transient('gf_marketo_default_fields');
delete_site_transient('gf_marketo_custom_fields');
}
?>
<style type="text/css">
label span.howto { cursor: default; }
.marketo_col_heading, .marketo_tag_optin_condition_fields { padding-bottom: .5em; border-bottom: 1px solid #ccc; }
.marketo_col_heading { font-weight:bold; width:50%; }
.marketo_tag_optin_condition_fields { margin-bottom: .5em; }
#marketo_field_list table, #marketo_tag_optin table { width: 500px; border-collapse: collapse; margin-top: 1em; }
.marketo_field_cell {padding: 6px 17px 0 0; margin-right:15px; vertical-align: text-top; font-weight: normal;}
ul.marketo_checkboxes { max-height: 120px; overflow-y: auto;}
ul.marketo_map_field_groupId_checkboxes { max-height: 300px; }
.gfield_required{color:red;}
.feeds_validation_error{ background-color:#FFDFDF;}
.feeds_validation_error td{ margin-top:4px; margin-bottom:6px; padding-top:6px; padding-bottom:6px; border-top:1px dotted #C89797; border-bottom:1px dotted #C89797}
.left_header{float:left; width:200px; padding-right: 20px;}
#marketo_field_list .left_header { margin-top: 1em; }
.margin_vertical_10{margin: 20px 0;}
#gf_marketo_list { margin-left:220px; padding-top: 1px }
#marketo_doubleoptin_warning{padding-left: 5px; padding-bottom:4px; font-size: 10px;}
</style>
<script>
var form = Array();
</script>
<div class="wrap">
<img alt="<?php _e("Marketo Feeds", "gravity-forms-marketo") ?>" src="<?php echo self::get_base_url()?>/images/marketo-logo.jpg" style="display:block; margin:15px 7px 0 0;" width="161" height="70"/>
<h2><?php _e("Marketo Feeds", "gravity-forms-marketo"); ?></h2>
<ul class="subsubsub">
<li><a href="<?php echo admin_url('admin.php?page=gf_settings&addon=Marketo'); ?>"><?php _e('Marketo Settings', 'gravity-forms-marketo'); ?></a> |</li>
<li><a href="<?php echo admin_url('admin.php?page=gf_marketo'); ?>"><?php _e('Marketo Feeds', 'gravity-forms-marketo'); ?></a></li>
</ul>
<div class="clear"></div>
<?php
//getting Marketo API
$api = self::get_api();
//ensures valid credentials were entered in the settings page
if(($api === false) || is_string($api)) {
?>
<div class="error" id="message" style="margin-top:20px;"><?php echo wpautop(sprintf(__("We are unable to login to Marketo with the provided username and API key. Please make sure they are valid in the %sSettings Page%s", "gravity-forms-marketo"), "<a href='?page=gf_settings&addon=Marketo'>", "</a>")); ?></div>
<?php
return;
}
//getting setting id (0 when creating a new one)
$id = !empty($_POST["marketo_setting_id"]) ? $_POST["marketo_setting_id"] : absint($_GET["id"]);
$config = empty($id) ? array("meta" => array(), "is_active" => true) : GFMarketoData::get_feed($id);
//getting merge vars
$merge_vars = array();
//updating meta information
if(isset($_POST["gf_marketo_submit"])){
$objectType = $list_names = array();
list($list_id, $list_name) = explode("|:|", stripslashes($_POST["gf_marketo_list"]));
$config["meta"]["contact_list_id"] = $list_id;
$config["meta"]["contact_list_name"] = $list_name;
$config["form_id"] = absint($_POST["gf_marketo_form"]);
$is_valid = true;
$merge_vars = self::get_fields();
$field_map = array();
foreach($merge_vars as $key => $var){
$field_name = "marketo_map_field_" . $var['tag'];
if(isset($_POST[$field_name])) {
if(is_array($_POST[$field_name])) {
foreach($_POST[$field_name] as $k => $v) {
$_POST[$field_name][$k] = stripslashes($v);
}
$mapped_field = $_POST[$field_name];
} else {
$mapped_field = stripslashes($_POST[$field_name]);
}
}
if(!empty($mapped_field)){
$field_map[$var['tag']] = $mapped_field;
}
else{
unset($field_map[$var['tag']]);
if(!empty($var['req'])) {
$is_valid = false;
}
}
unset($_POST["{$field_name}"]);
}
$field_map['CustomFields'] = array();
if( isset($_POST['marketo_custom_field'] ) ) {
foreach( (array)$_POST['marketo_custom_field'] as $key => $value) {
if(!empty($key)) {
$field_map['CustomFields'][esc_attr($key)] = stripslashes($value);
}
}
}
$config["meta"]["field_map"] = $field_map;
$config["meta"]["optin_enabled"] = !empty($_POST["marketo_optin_enable"]) ? true : false;
$config["meta"]["optin_field_id"] = $config["meta"]["optin_enabled"] ? isset($_POST["marketo_optin_field_id"]) ? @$_POST["marketo_optin_field_id"] : '' : "";
$config["meta"]["optin_operator"] = $config["meta"]["optin_enabled"] ? isset($_POST["marketo_optin_operator"]) ? @$_POST["marketo_optin_operator"] : '' : "";
$config["meta"]["optin_value"] = $config["meta"]["optin_enabled"] ? @$_POST["marketo_optin_value"] : "";
$config["meta"]["tag_optin_enabled"] = !empty($_POST["marketo_tag_optin_enable"]) ? true : false;
$config["meta"]["tag_optin_field_id"] = !empty($config["meta"]["tag_optin_enabled"]) ? isset($_POST["marketo_tag_optin_field_id"]) ? @$_POST["marketo_tag_optin_field_id"] : '' : "";
$config["meta"]["tag_optin_operator"] = !empty($config["meta"]["tag_optin_enabled"]) ? isset($_POST["marketo_tag_optin_operator"]) ? @$_POST["marketo_tag_optin_operator"] : '' : "";
$config["meta"]["tag_optin_tags"] = !empty($config["meta"]["tag_optin_enabled"]) ? @$_POST["tag_optin_tags"] : "";
$config["meta"]["tag_optin_value"] = !empty($config["meta"]["tag_optin_enabled"]) ? @$_POST["marketo_tag_optin_value"] : "";
if($is_valid){
$id = GFMarketoData::update_feed($id, $config["form_id"], $config["is_active"], $config["meta"]);
?>
<div id="message" class="updated fade" style="margin-top:10px;"><p><?php echo sprintf(__("Feed Updated. %sback to list%s", "gravity-forms-marketo"), "<a href='?page=gf_marketo'>", "</a>") ?></p>
<input type="hidden" name="marketo_setting_id" value="<?php echo $id ?>"/>
</div>
<?php
}
else{
?>
<div class="error" style="padding:6px"><?php echo __("Feed could not be updated. Please enter all required information below.", "gravity-forms-marketo") ?></div>
<?php
}
}
self::setup_tooltips();
?>
<form method="post" action="<?php echo remove_query_arg('refresh'); ?>">
<input type="hidden" name="marketo_setting_id" value="<?php echo $id ?>"/>
<div class="margin_vertical_10">
<label for="gf_marketo_list" class="left_header"><?php _e("Marketo Campaign", "gravity-forms-marketo"); ?> <?php gform_tooltip("marketo_contact_list") ?></label>
<?php
//getting all contact lists
$campaigns = $api->getCampaignsForSource();
if (empty($campaigns)){
if(is_array($campaigns)) {
echo '<img src="'.plugins_url('images/campaigntrigger.png', __FILE__).'" alt="Campaign is Requested Trigger" width="562" height="138" />';
echo _e('<span class="howto" style="max-width:500px; margin-left:230px"><strong>No lists were loaded.</strong> Campaigns are only available to the API if they are active campaigns and have a "Campaign is Requested" trigger configured where the Source is "Web Service API".</span>', 'gravity-forms-marketo');
} else {
echo __("Could not load Marketo contact lists.", "gravity-forms-marketo");
}
?><script>
jQuery(document).ready(function() {
jQuery("#marketo_field_group, #marketo_form_container").slideUp();
});
</script><?php
}