diff --git a/Plugins/WordPress/README.md b/Plugins/WordPress/README.md index 60c8015..1ae745a 100644 --- a/Plugins/WordPress/README.md +++ b/Plugins/WordPress/README.md @@ -1,6 +1,6 @@ #Wordpress plugin -version 2.0, 2014-04-07 [changelog](#changelog) +version 2.1, 2014-05-09 [changelog](#changelog) ##INFO @@ -9,7 +9,7 @@ This plug-in enables installation of a GetResponse fully customizable sign up fo ##AUTHORS -GetResponse +GetResponse, Grzegorz Struczynski [Implix](http://implix.com) [Dev Getresponse](http://dev.getresponse.com) @@ -59,6 +59,14 @@ You can embed your web form in the sidebar or in a lightbox. In order to use a l ##CHANGELOG +version v2.1, 2014-05-09 + +* Added subscribe via the registration page +* Campaign names and Web Forms are now sorted by name +* Added checking if curl extension is set and curl_init method is callable +* Removed typo and deprecated unused params +* Tested up to: 3.9.1 + version v2.0, 2014-04-07 * Integration is based on API Key; diff --git a/Plugins/WordPress/getresponse-integration.php b/Plugins/WordPress/getresponse-integration.php index 6b55f68..39daabe 100644 --- a/Plugins/WordPress/getresponse-integration.php +++ b/Plugins/WordPress/getresponse-integration.php @@ -3,7 +3,7 @@ Plugin Name: GetResponse Integration Plugin Plugin URI: http://wordpress.org/extend/plugins/getresponse-integration/ Description: This plug-in enables installation of a GetResponse fully customizable sign up form on your WordPress site or blog. Once a web form is created and added to the site the visitors are automatically added to your GetResponse contact list and sent a confirmation email. The plug-in additionally offers sign-up upon leaving a comment. -Version: 2.0 +Version: 2.1 Author: GetResponse Author: Grzegorz Struczynski Author URI: http://getresponse.com/ @@ -25,9 +25,9 @@ class Gr_Integration { /** - * URL + * Db Prefix **/ - var $GrOptionDbPrefix = 'GrIntegrationOptions_'; // plugin db prefix + var $GrOptionDbPrefix = 'GrIntegrationOptions_'; /** * Billing fields - custom fields map @@ -55,7 +55,7 @@ function Gr_Integration() { add_action('admin_menu', array(&$this, 'Init')); // settings link in plugin page - if (is_admin()) { + if (is_admin()) { add_filter( 'plugin_action_links', array(&$this, 'AddPluginActionLink'), 10, 2 ); } @@ -65,6 +65,11 @@ function Gr_Integration() { add_action('comment_form',array(&$this,'AddCheckboxToComment')); add_action('comment_post',array(&$this,'GrabEmailFromComment')); } + // on/off registration form + if ( get_option($this->GrOptionDbPrefix . 'registration_on')) { + add_action('register_form',array(&$this,'AddCheckboxToRegistrationForm')); + add_action('register_post',array(&$this,'GrabEmailFromRegistrationForm')); + } // on/off checkout for WooCommerce if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { @@ -78,6 +83,12 @@ function Gr_Integration() { } // register widget and css file add_action( 'widgets_init', array( $this, 'register_widgets' ) ); + add_action( 'plugins_loaded', array( $this, 'GrLangs') ); + add_action( 'init', array( $this, 'GrButtons') ); + add_action( 'admin_head', array( $this, 'GrJsShortcodes')); + + // register shortcode + add_shortcode( 'grwebform', array( $this, 'showWebformShortCode') ); } /** @@ -124,12 +135,36 @@ function PluginName() { return $this_plugin; } + /** + * Sort method + * @param $data + * @param $sortKey + * @param int $sort_flags + * @return array + */ + static function SortByKeyValue($data, $sortKey, $sort_flags=SORT_ASC) { + if (empty($data) or !is_object($data) or empty($sortKey)) return $data; + + $ordered = array(); + foreach ($data as $key => $value) { + $ordered[$value->$sortKey] = $value; + $ordered[$value->$sortKey]->id = $key; + } + + ksort($ordered, $sort_flags); + + return array_values($ordered); + } + /** * Admin page settings */ function AdminOptionsPage() { - $woocommerce = 'off'; + //Check if curl extension is set and curl_init method is callable + $this->checkCurlExtension(); + + $woocommerce = 'off'; if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { $woocommerce = 'on'; } @@ -137,20 +172,30 @@ function AdminOptionsPage() { $apikey = isset($_POST['api_key']) ? $_POST['api_key'] : get_option($this->GrOptionDbPrefix . 'api_key'); if ( !empty($apikey)) { - $api = new GetResponse($apikey); + $api = new GetResponseIntegration($apikey); + + // api errors + $ping = $api->ping(); + if (is_array($ping) && isset($ping['type']) && $ping['type'] == 'error') + { + echo $ping['msg']; + return; + } - if ($api->ping()) { + if (isset($ping->result->ping)) { update_option($this->GrOptionDbPrefix . 'api_key', $apikey); // admin page settings if ( isset($_POST['comment_campaign']) || isset($_POST['checkout_campaign']) ) { $post_fields = array( - 'comment_campaign', 'checkout_campaign', 'comment_on', 'comment_label', 'comment_checked', 'checkout_checked', 'sync_order_data', 'fields_prefix' + 'comment_campaign', 'checkout_campaign', 'comment_on', 'comment_label', 'comment_checked', 'checkout_checked', 'sync_order_data', 'fields_prefix', + 'registration_campaign', 'registration_campaign', 'registration_on', 'registration_label', 'registration_checked' ); foreach ($post_fields as $field) { - update_option($this->GrOptionDbPrefix . $field, $_POST[$field]); + $val = isset($_POST[$field]) ? $_POST[$field] : null; + update_option($this->GrOptionDbPrefix . $field, $val); } // woocommerce settings @@ -162,8 +207,7 @@ function AdminOptionsPage() {

- biling_fields as $value => $bf) { @@ -185,9 +229,7 @@ function AdminOptionsPage() { else { ?>
-

- -

+

GrOptionDbPrefix . 'api_key', $apikey); - update_option($this->GrOptionDbPrefix . 'api_crypto', null); } ?> @@ -238,11 +279,11 @@ function AdminOptionsPage() {
GrOptionDbPrefix . 'api_key') == '') {?>style="display: none;"> +

-

' . __('Go to Widgets site', 'Gr_Integration') . '';?> @@ -256,6 +297,7 @@ function AdminOptionsPage() { GrOptionDbPrefix . 'comment_on'); + $registration_type = get_option($this->GrOptionDbPrefix . 'registration_on'); ?>

@@ -268,9 +310,12 @@ function AdminOptionsPage() { GrOptionDbPrefix . 'comment_campaign'); $checkout_campaign = get_option($this->GrOptionDbPrefix . 'checkout_campaign'); + $registration_campaign = get_option($this->GrOptionDbPrefix . 'registration_campaign'); // API Instance $api = $this->GetApiInstance(); - $campaigns = $api->getCampaigns(); + if ($api) { + $campaigns = $api->getCampaigns(); + } ?>

GrOptionDbPrefix . 'comment_on') != 1) {?>style="display: none;"> @@ -278,13 +323,21 @@ function AdminOptionsPage() {

SortByKeyValue($campaigns, 'name'); + } + // check if no errors + if ( !empty($campaigns) and false === (is_array($campaigns) and isset($campaigns['type']) and $campaigns['type'] == 'error')) { ?> + +

+ +

+ +

+ + +

+ +
GrOptionDbPrefix . 'registration_on') != 1) {?>style="display: none;"> + +

+ + + + +

+ + +

+ + +

+ + +

+ + GrOptionDbPrefix . 'registration_checked', '') == 1) { ?>checked="checked"/> +

+
+ + + GrOptionDbPrefix . 'checkout_on'); @@ -339,12 +451,13 @@ function AdminOptionsPage() { GrOptionDbPrefix . 'comment_checked'); - var_dump($checked); ?>

- checked="checked"/> + checked="checked"/> GrOptionDbPrefix . 'comment_label');?>


GrOptionDbPrefix . 'checkout_checked'); ?>

- checked="checked" /> -

GrOptionDbPrefix . 'registration_checked'); + ?> +

+ checked="checked" /> + +


+ GetApiInstance(); if ($api) { $customs = array(); + $campaign = get_option($this->GrOptionDbPrefix . 'checkout_campaign'); if (get_option($this->GrOptionDbPrefix . 'sync_order_data') == true) { - $campaign = get_option($this->GrOptionDbPrefix . 'checkout_campaign'); foreach ($this->biling_fields as $custom_name => $custom_field) { $custom = get_option($this->GrOptionDbPrefix . $custom_name); if ($custom && !empty($_POST[$custom_field['value']])) { @@ -573,7 +702,7 @@ function GrabEmailFromCheckoutPage() { * Grab email from checkout form - paypal express */ function GrabEmailFromCheckoutPagePE() { - if ($_POST['checkout_checkbox'] == 1 ) { + if ($_POST['gr_checkout_checkbox'] == 1 ) { $api = $this->GetApiInstance(); if ($api) { $campaign = get_option($this->GrOptionDbPrefix . 'checkout_campaign'); @@ -586,7 +715,7 @@ function GrabEmailFromCheckoutPagePE() { * Grab email from comment form */ function GrabEmailFromComment() { - if ( $_POST['comment_checkbox'] == 1 AND isset($_POST['email']) ) { + if ( $_POST['gr_comment_checkbox'] == 1 AND isset($_POST['email']) ) { $api = $this->GetApiInstance(); if ($api) { $campaign = get_option($this->GrOptionDbPrefix . 'comment_campaign'); @@ -594,7 +723,20 @@ function GrabEmailFromComment() { } } } - + + /** + * Grab email from registration form + */ + function GrabEmailFromRegistrationForm() { + if ( $_POST['gr_registration_checkbox'] == 1 AND isset($_POST['user_email']) ) { + $api = $this->GetApiInstance(); + if ($api) { + $campaign = get_option($this->GrOptionDbPrefix . 'registration_campaign'); + $api->addContact($campaign, $_POST['user_login'], $_POST['user_email']); + } + } + } + /** * Display GetResponse blog 10 RSS links */ @@ -603,7 +745,7 @@ function GrRss() { $lang = get_bloginfo("language") == 'pl-PL' ? 'pl' : 'com'; $feed_url = 'http://blog.getresponse.' . $lang . '/feed'; - $num = 10; // numbers of feeds: + $num = 12; // numbers of feeds: include_once(ABSPATH . WPINC . '/feed.php'); $rss = fetch_feed( $feed_url ); @@ -643,15 +785,21 @@ function GrRss() { * GetResponse MCE buttons */ function GrButtons() { - add_filter( "mce_external_plugins", array('Gr_Integration', 'GrAddButtons') ); - add_filter( 'mce_buttons', array('Gr_Integration', 'GrRegisterButtons') ); + add_filter( 'mce_buttons', array(&$this, 'GrRegisterButtons') ); + add_filter( "mce_external_plugins", array(&$this, 'GrAddButtons') ); } /** * GetResponse MCE plugin */ function GrAddButtons( $plugin_array ) { - $plugin_array['gr'] = untrailingslashit( plugins_url( '/', __FILE__ ) ) . '/js/gr-plugin.js'; + global $wp_version; + + if ($wp_version >= 3.9) + $plugin_array['GrShortcodes'] = untrailingslashit( plugins_url( '/', __FILE__ ) ) . '/js/gr-plugin.js'; + else + $plugin_array['GrShortcodes'] = untrailingslashit( plugins_url( '/', __FILE__ ) ) . '/js/gr-plugin_3_8.js'; + return $plugin_array; } @@ -659,7 +807,11 @@ function GrAddButtons( $plugin_array ) { * Display GetResponse MCE buttons */ function GrRegisterButtons( $buttons ) { - array_push( $buttons, 'webform' ); + array_push( + $buttons, + 'separator', + 'GrShortcodes' + ); return $buttons; } @@ -667,24 +819,29 @@ function GrRegisterButtons( $buttons ) { * Display GetResponse MCE buttons */ function GrJsShortcodes() { - $GrOptionDbPrefix = 'GrIntegrationOptions_'; $api_key = get_option($GrOptionDbPrefix . 'api_key'); - $api = new GetResponse($api_key); - $campaigns = $api->getCampaigns(); - - if ( !empty($campaigns)) { + if (!empty($api_key)) { + $api = new GetResponseIntegration($api_key); + $campaigns = $api->getCampaigns(); $webforms = $api->getWebforms(); - } - $my_campaigns = json_encode($campaigns); - $my_webforms = json_encode($webforms); - ?> - - SortByKeyValue($webforms, 'name'); + } + else { + $campaigns = null; + $webforms = null; + } + $my_campaigns = json_encode($campaigns); + $my_webforms = json_encode($webforms); + ?> + + GrOptionDbPrefix . 'api_key'); - $apiInstance = new GetResponse($api_key); - return $apiInstance; + if ( !empty($api_key)) { + $apiInstance = new GetResponseIntegration($api_key); + return $apiInstance; + } + else { + return false; + } } /** @@ -702,13 +864,18 @@ function GetApiInstance() { function GrLangs() { load_plugin_textdomain( 'Gr_Integration', false, plugin_basename( dirname( __FILE__ ) ) . "/langs" ); } -} -add_shortcode( 'grwebform', array('Gr_Integration', 'showWebformShortCode') ); - -add_action( 'plugins_loaded', array('Gr_Integration', 'GrLangs') ); -add_action( 'init', array('Gr_Integration', 'GrButtons') ); -add_action( 'admin_head', array('Gr_Integration', 'GrJsShortcodes')); + /** + * Check if curl extension is set and curl_init method is callable + */ + function checkCurlExtension() { + if ( !extension_loaded('curl') or !is_callable('curl_init')) { + echo "

cURL Error !

"; + echo '

GetResponse Integration Plugin requires PHP cURL extension

'; + return; + } + } +} //Gr_Integration /** * Init plugin diff --git a/Plugins/WordPress/js/gr-plugin.js b/Plugins/WordPress/js/gr-plugin.js index e30471e..491f0b4 100644 --- a/Plugins/WordPress/js/gr-plugin.js +++ b/Plugins/WordPress/js/gr-plugin.js @@ -1,34 +1,39 @@ (function() { - tinymce.create('tinymce.plugins.GrShortcodes', { + tinymce.PluginManager.add('GrShortcodes', function(editor, url) { - init : function(ed, url) { - }, - createControl : function(n, cm) { + function getValues() { + var wf = []; - if (n=='webform'){ - var mlb = cm.createListBox('GR Web Form Shortcode', { - title : 'GR Web Form Shortcode', - onselect : function(v) { - if (tinyMCE.activeEditor.selection.getContent() == '' && v != null){ - var shortcode = '[grwebform url="' + v + '" css="on"/]'; - tinyMCE.activeEditor.selection.setContent( shortcode ) - } - } - }); + if (my_webforms != null) { + for (var i in my_webforms) { - if (my_webforms != null && my_campaigns != null) { - for (var i in my_webforms) { - mlb.add(my_webforms[i].name + ' (' + my_campaigns[my_webforms[i].campaign].name + ')', my_webforms[i].url); - } - } - else { - mlb.add('No webforms', null); - } + var webforms = {}; + var webform_name = (my_campaigns != null) ? my_webforms[i].name + ' (' + my_campaigns[my_webforms[i].campaign].name + ')' : my_webforms[i].name; + + webforms.text = webform_name; + webforms.url = my_webforms[i].url; - return mlb; + wf.push(webforms); + } + } + else { + return [{text:"No web forms", url:null}]; } - return null; + return wf; } + + editor.addButton('GrShortcodes', { + type: 'listbox', + title: 'GetResponse Web form integration', + text: 'GR Web form', + values: getValues(), + onselect: function(v) { + if (v.control.settings.url != null && v.control.settings.text != 'No web forms') { + var shortcode = '[grwebform url="' + v.control.settings.url + '" css="on"/]'; + editor.insertContent(shortcode); + } + } + }); }); - tinymce.PluginManager.add('gr', tinymce.plugins.GrShortcodes); + })(); \ No newline at end of file diff --git a/Plugins/WordPress/js/gr-plugin_3_8.js b/Plugins/WordPress/js/gr-plugin_3_8.js new file mode 100644 index 0000000..e0786e6 --- /dev/null +++ b/Plugins/WordPress/js/gr-plugin_3_8.js @@ -0,0 +1,38 @@ +(function() { + tinymce.create('tinymce.plugins.GrShortcodes', { + + init : function(ed, url) { + }, + createControl : function(n, cm) { + if (n=='GrShortcodes'){ + var mlb = cm.createListBox('GR Web Form Shortcode', { + title : 'GR Web Form Shortcode', + onselect : function(v) { + if (tinyMCE.activeEditor.selection.getContent() == '' && v != null){ + var shortcode = '[grwebform url="' + v + '" css="on"/]'; + tinyMCE.activeEditor.selection.setContent( shortcode ) + } + } + }); + + if (my_webforms != null && my_campaigns != null) { + for (var i in my_webforms) { + mlb.add(my_webforms[i].name + ' (' + my_campaigns[my_webforms[i].campaign].name + ')', my_webforms[i].url); + } + } + else if (my_webforms != null) { + for (var i in my_webforms) { + mlb.add(my_webforms[i].name, my_webforms[i].url); + } + } + else { + mlb.add('No webforms', null); + } + + return mlb; + } + return null; + } + }); + tinymce.PluginManager.add('GrShortcodes', tinymce.plugins.GrShortcodes); +})(); \ No newline at end of file diff --git a/Plugins/WordPress/langs/Gr_Integration-pl_PL.mo b/Plugins/WordPress/langs/Gr_Integration-pl_PL.mo index 8f5e649..35d2d30 100644 Binary files a/Plugins/WordPress/langs/Gr_Integration-pl_PL.mo and b/Plugins/WordPress/langs/Gr_Integration-pl_PL.mo differ diff --git a/Plugins/WordPress/langs/Gr_Integration-pl_PL.po b/Plugins/WordPress/langs/Gr_Integration-pl_PL.po index 4d2594e..b73d662 100644 --- a/Plugins/WordPress/langs/Gr_Integration-pl_PL.po +++ b/Plugins/WordPress/langs/Gr_Integration-pl_PL.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: getresponse-integration\n" -"POT-Creation-Date: 2014-04-07 08:38+0100\n" -"PO-Revision-Date: 2014-04-07 08:39+0100\n" +"POT-Creation-Date: 2014-05-08 15:01+0100\n" +"PO-Revision-Date: 2014-05-08 15:02+0100\n" "Last-Translator: \n" "Language-Team: GetResponse\n" "Language: pl_PL\n" @@ -17,43 +17,39 @@ msgstr "" "X-Poedit-KeywordsList: _e;__\n" "X-Poedit-SearchPath-0: ../.\n" -#: .././getresponse-integration.php:89 .././getresponse-integration.php:90 +#: .././getresponse-integration.php:100 .././getresponse-integration.php:101 msgid "GetResponse" msgstr "GetResponse" -#: .././getresponse-integration.php:109 +#: .././getresponse-integration.php:120 msgid "Settings" msgstr "Ustawienia" -#: .././getresponse-integration.php:163 +#: .././getresponse-integration.php:208 msgid "Settings saved" msgstr "Ustawienia zapisane" -#: .././getresponse-integration.php:188 .././getresponse-integration.php:200 +#: .././getresponse-integration.php:232 .././getresponse-integration.php:242 msgid "Settings error" msgstr "Błąd podczas zapisu" -#: .././getresponse-integration.php:188 +#: .././getresponse-integration.php:232 msgid " - Invalid API Key" msgstr " - Niepoprawny klucz API" -#: .././getresponse-integration.php:189 -msgid ", or crypto" -msgstr ", lub krypto" - -#: .././getresponse-integration.php:200 +#: .././getresponse-integration.php:242 msgid " - API Key can't be empty." msgstr " - pole z Kluczem API nie może być puste" -#: .././getresponse-integration.php:213 +#: .././getresponse-integration.php:254 msgid "GetResponse Plugin Settings" msgstr "Ustawienia GetResponse" -#: .././getresponse-integration.php:223 +#: .././getresponse-integration.php:264 msgid "API Key:" msgstr "Klucz API:" -#: .././getresponse-integration.php:229 +#: .././getresponse-integration.php:270 msgid "" "Enter your API key. You can find it on your GetResponse profile in Account " "Details -> GetResponse API" @@ -61,15 +57,15 @@ msgstr "" "Wprowadź klucz API. Możesz go znaleźć w Twoim koncie GetResponse: Ustawienia " "konta -> GetResponse API" -#: .././getresponse-integration.php:237 .././getresponse-integration.php:425 +#: .././getresponse-integration.php:278 .././getresponse-integration.php:538 msgid "Save" msgstr "Zapisz" -#: .././getresponse-integration.php:242 +#: .././getresponse-integration.php:284 msgid "Subscribe via Web Form" msgstr "Zapis przez Formularz Zapisu" -#: .././getresponse-integration.php:247 +#: .././getresponse-integration.php:288 msgid "" "To activate a GetResponse Web Form widget drag it to a sidebar or click on " "it." @@ -77,75 +73,92 @@ msgstr "" "Aby aktywować Formularze Zapisu GetResponse, przeciąnij wtyczkę lub kliknij " "w nią." -#: .././getresponse-integration.php:248 +#: .././getresponse-integration.php:289 msgid "Go to Widgets site" msgstr "Przejdź do Wtyczek" -#: .././getresponse-integration.php:253 +#: .././getresponse-integration.php:294 msgid "Subscribe via Comment" msgstr "Zapis przez komentarz" -#: .././getresponse-integration.php:261 +#: .././getresponse-integration.php:303 msgid "Comment integration:" msgstr "Integracja z komentarzami" -#: .././getresponse-integration.php:263 .././getresponse-integration.php:331 +#: .././getresponse-integration.php:305 .././getresponse-integration.php:382 +#: .././getresponse-integration.php:443 msgid "Off" msgstr "Wyłączona" -#: .././getresponse-integration.php:264 .././getresponse-integration.php:332 +#: .././getresponse-integration.php:306 .././getresponse-integration.php:383 +#: .././getresponse-integration.php:444 msgid "On" msgstr "Włączona" -#: .././getresponse-integration.php:265 +#: .././getresponse-integration.php:307 msgid "(allow subscriptions when visitors comment)" msgstr "(pozwala na zapis, gdy goście komentują)" -#: .././getresponse-integration.php:279 +#: .././getresponse-integration.php:324 .././getresponse-integration.php:390 msgid "Target Campaign:" msgstr "Kampania:" -#: .././getresponse-integration.php:291 .././getresponse-integration.php:352 +#: .././getresponse-integration.php:344 .././getresponse-integration.php:403 +#: .././getresponse-integration.php:465 msgid "No Campaigns." msgstr "Brak kampanii" -#: .././getresponse-integration.php:298 .././getresponse-integration.php:359 +#: .././getresponse-integration.php:351 .././getresponse-integration.php:410 +#: .././getresponse-integration.php:472 msgid "Additional text:" msgstr "Dodatkowy tekst:" -#: .././getresponse-integration.php:299 .././getresponse-integration.php:360 +#: .././getresponse-integration.php:352 .././getresponse-integration.php:411 +#: .././getresponse-integration.php:473 msgid "Sign up to our newsletter!" msgstr "Zapisz się do naszego newslettera!" -#: .././getresponse-integration.php:304 +#: .././getresponse-integration.php:357 .././getresponse-integration.php:416 msgid "Subscribe checkbox checked by default" msgstr "Zapisanie do kampanii zaznaczone domyślnie" -#: .././getresponse-integration.php:325 +#: .././getresponse-integration.php:376 +msgid "Subscribe via Registration Page" +msgstr "Zapis na stronie rejestracji" + +#: .././getresponse-integration.php:380 +msgid "Registration integration:" +msgstr "Integracja z formularzem zapisu" + +#: .././getresponse-integration.php:384 +msgid "(allow subscriptions at the registration page)" +msgstr "(pozwala na zapis na stronie rejestracji)" + +#: .././getresponse-integration.php:437 msgid "Subscribe via Checkout Page" msgstr "Zapis na stronie z płatnościami" -#: .././getresponse-integration.php:329 +#: .././getresponse-integration.php:441 msgid "Checkout integration:" msgstr "Integracja ze stroną płatności" -#: .././getresponse-integration.php:333 +#: .././getresponse-integration.php:445 msgid "(allow subscriptions at the checkout stage)" msgstr "(pozwala na zapis na stronie płatności)" -#: .././getresponse-integration.php:339 +#: .././getresponse-integration.php:451 msgid "Target campaign:" msgstr "Kampania:" -#: .././getresponse-integration.php:365 +#: .././getresponse-integration.php:478 msgid "Sign up box checked by default" msgstr "Formularz zapisu zaznaczony domyślnie" -#: .././getresponse-integration.php:371 +#: .././getresponse-integration.php:484 msgid "Map custom fields:" msgstr "Zmapuj pola:" -#: .././getresponse-integration.php:377 +#: .././getresponse-integration.php:490 msgid "" "Check to update customer details. Each input can be max. 32 characters and " "include lowercase, a-z letters, digits or underscores. Incorrect or empty " @@ -155,11 +168,11 @@ msgstr "" "znaków i składać się z małych liter a-z, liczb lub podkreśleń. Niepoprawne " "lub puste wpisy nie będą dodane." -#: .././getresponse-integration.php:428 +#: .././getresponse-integration.php:541 msgid "Web Form Shortcode" msgstr "Kod Formularza Zapisu" -#: .././getresponse-integration.php:429 +#: .././getresponse-integration.php:542 msgid "" "With the GetResponse Wordpress plugin, you can use shortcodes to place web " "forms in blog posts. Simply place the following tag in your post wherever " @@ -169,7 +182,7 @@ msgstr "" "umieścić formularz zapisu na blogu. Wystarczy umieścić następujący tag w " "poście, w którym ma pojawić się formularz zapisu:" -#: .././getresponse-integration.php:433 +#: .././getresponse-integration.php:546 msgid "" "Set the CSS parameter to ON, and the web form will be displayed in " "GetResponse format; set it to OFF, and the web form will be displayed in the " @@ -191,10 +204,17 @@ msgstr "Wyświetl Formularz Zapisu GetResponse na Twojej stronie" msgid "Web Form:" msgstr "Formularz Zapisu:" -#: .././lib/class-gr-widget-webform.php:107 +#: .././lib/class-gr-widget-webform.php:100 +msgid "No Webforms" +msgstr "Brak Formularzy" + +#: .././lib/class-gr-widget-webform.php:106 msgid "Use Wordpress CSS styles" msgstr "Użyj stylów CSS z Wordpressa" -#: .././lib/class-gr-widget-webform.php:113 +#: .././lib/class-gr-widget-webform.php:112 msgid "API key is not set." msgstr "Klucz API nie jest ustawiony." + +#~ msgid ", or crypto" +#~ msgstr ", lub krypto" diff --git a/Plugins/WordPress/lib/GrApi.class.php b/Plugins/WordPress/lib/GrApi.class.php index a9200b5..7d6e4cb 100644 --- a/Plugins/WordPress/lib/GrApi.class.php +++ b/Plugins/WordPress/lib/GrApi.class.php @@ -5,18 +5,15 @@ * @author Grzeogrz Struczynski * http://getresponse.com */ -class GetResponse +class GetResponseIntegration { public $apiKey; private $apiUrl = 'http://api2.getresponse.com'; public function __construct($apiKey = null) { - if ( !extension_loaded('curl')) { - trigger_error('GetResponsePHP requires PHP cURL', E_USER_ERROR); - } if (is_null($apiKey)) { - trigger_error('API key must be supplied', E_USER_ERROR); + return array('type' => 'error', 'msg' => 'API key must be supplied'); } $this->apiKey = $apiKey; @@ -25,15 +22,13 @@ public function __construct($apiKey = null) { public function ping() { $request = $this->request('ping'); $response = $this->execute($request); - if ( !$response->error) { - return $response->result->ping; - } + return $response; } public function getCampaigns() { $request = $this->request('get_campaigns'); $response = $this->execute($request); - if ( !$response->error) { + if ( !is_array($response) && !$response->error) { return $response->result; } } @@ -41,7 +36,7 @@ public function getCampaigns() { public function getWebforms($campaigns_id = array()) { $request = $this->request('get_webforms', array('campaigns' => $campaigns_id)); $response = $this->execute($request); - if ( !$response->error) { + if ( !is_array($response) && !$response->error) { return $response->result; } } @@ -49,7 +44,7 @@ public function getWebforms($campaigns_id = array()) { public function getWebform($webform_id) { $request = $this->request('get_webform', array('webform' => $webform_id)); $response = $this->execute($request); - if ( !$response->error) { + if ( !is_array($response) && !$response->error) { return $response->result; } } @@ -57,7 +52,7 @@ public function getWebform($webform_id) { public function getContact($email_address, $campaign_id) { $request = $this->request('get_contacts', array ( 'email' => array( 'EQUALS' => $email_address), 'campaigns' => array($campaign_id) )); $response = $this->execute($request); - if ( !$response->error) { + if ( !is_array($response) && !$response->error) { return $response->result; } } @@ -65,12 +60,13 @@ public function getContact($email_address, $campaign_id) { public function setContactCustoms($contact_id, $customs) { $request = $this->request('set_contact_customs', array('contact' => $contact_id, 'customs' => $customs)); $response = $this->execute($request); - if ( !$response->error) { + if ( !is_array($response) && !$response->error) { return $response->result; } } public function addContact($campaign, $name, $email, $cycle_day = 0, $customs = array()) { + $c = array(); $params = array( 'campaign' => $campaign, 'name' => $name, @@ -79,18 +75,21 @@ public function addContact($campaign, $name, $email, $cycle_day = 0, $customs = 'ip' => $_SERVER['REMOTE_ADDR'] ); + // default ref + $c[] = array('name' => 'ref', 'content' => 'wordpress'); if ( !empty($customs)) { foreach($customs as $key => $val) { - $c[] = array('name' => $key, 'content' => $val); + if (!empty($key) && !empty($val)) + $c[] = array('name' => $key, 'content' => $val); } - $params['customs'] = $c; } + $params['customs'] = $c; $request = $this->request('add_contact', $params); $response = $this->execute($request); // contact already added to campaign - if ( !empty($customs) && isset($response->error) && preg_match('[Contact already added to target campaign]', $response->error->message)) { + if ( !empty($customs) && !is_array($response) && isset($response->error) && preg_match('[Contact already added to target campaign]', $response->error->message)) { $contact_id = $this->getContact($email, $campaign); $contact_id = array_pop(array_keys((array)$contact_id)); if ($contact_id && !empty($params['customs'])) { @@ -119,13 +118,14 @@ private function execute($request) { curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = json_decode(curl_exec($ch)); if (curl_error($ch)) { - trigger_error(curl_error($ch), E_USER_ERROR); + return array('type' => 'error', 'msg' => curl_error($ch)); } $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ( !(($httpCode == '200') || ($httpCode == '204'))) { - trigger_error('API call failed. Server returned status code ' . $httpCode, E_USER_ERROR); + return array('type' => 'error', 'msg' => 'API call failed. Server returned status code ' . $httpCode); } + curl_close($ch); return $response; } -} \ No newline at end of file +} // class GetResponseIntegration \ No newline at end of file diff --git a/Plugins/WordPress/lib/class-gr-widget-webform.php b/Plugins/WordPress/lib/class-gr-widget-webform.php index 555842d..53026d9 100644 --- a/Plugins/WordPress/lib/class-gr-widget-webform.php +++ b/Plugins/WordPress/lib/class-gr-widget-webform.php @@ -33,11 +33,8 @@ public function widget( $args, $instance ) { $style_id = $instance['style']; $api_key = get_option($this->GrOptionDbPrefix . 'api_key'); - $account_type = get_option($this->GrOptionDbPrefix . 'account_type'); - $api_crypto = get_option($this->GrOptionDbPrefix . 'api_crypto'); - if ( !empty($api_key)) { - $api = new GetResponse($api_key, $account_type, $api_crypto); + $api = new GetResponseIntegration($api_key); $webform = $api->getWebform($webform_id); } @@ -51,9 +48,12 @@ public function widget( $args, $instance ) { $form .= '

'; } - echo $args['before_widget']; - echo __( $form, 'text_domain' ); - echo $args['after_widget']; + if (!empty($form)) + { + echo $args['before_widget']; + echo __( $form, 'text_domain' ); + echo $args['after_widget']; + } } /** @@ -69,11 +69,8 @@ public function form( $instance ) { $select = ($instance) ? esc_attr($instance['select']) : ''; $style = ($instance) ? esc_attr($instance['style']) : ''; $api_key = get_option($this->GrOptionDbPrefix . 'api_key'); - $account_type = get_option($this->GrOptionDbPrefix . 'account_type'); - $api_crypto = get_option($this->GrOptionDbPrefix . 'api_crypto'); - if ( !empty($api_key)) { - $api = new GetResponse($api_key, $account_type, $api_crypto); + $api = new GetResponseIntegration($api_key); $campaigns = $api->getCampaigns(); if ( !empty($campaigns)) { @@ -82,31 +79,33 @@ public function form( $instance ) { $campaign_id[$cid] = $campaign->name; } $webforms = $api->getWebforms(); + $webforms = Gr_Integration::SortByKeyValue($webforms, 'name'); } } ?>

+ +

/>

- diff --git a/Plugins/WordPress/readme.txt b/Plugins/WordPress/readme.txt index 779f915..75491df 100644 --- a/Plugins/WordPress/readme.txt +++ b/Plugins/WordPress/readme.txt @@ -2,8 +2,8 @@ Contributors: GetResponse Tags: getresponse, email, newsletter, signup, marketing, plugin, widget, mailing list, subscriber, contacts, subscribe form, woocommerce Requires at least: 3.3.0 -Tested up to: 3.8.1 -Stable tag: 2.0 +Tested up to: 3.9.1 +Stable tag: 2.1 The GetResponse Integration plugin allows you to quickly and easily add a sign-up form to your site. @@ -46,16 +46,61 @@ You can find it on your GetResponse profile in Account Details -> GetResponse AP == Screenshots == -1. Widgets view -2. Plugin settings view -3. WYSIWYG editor view +1. Widgets +2. Plugin settings +3. WYSIWYG editor 4. Webform view 5. Site view -6. Leave a comment view +6. Leave a comment == Changelog == += v2.1 = + +* Added subscribe via the registration page +* Campaign names and Web Forms are now sorted by name +* Added checking if curl extension is set and curl_init method is callable +* Removed typo and deprecated unused params +* Tested up to: 3.9.1 + += v2.0.7 = + +* Fixed Class name changed in class-gr-widget-webform + += v2.0.6 = + +* Class name changed from GetResponse to GetResponseIntegration, in some cases caused error: Cannot redeclare class GetResponse + += v2.0.5 = + +* Tested up to: 3.9 +* Shortcode updated to TinyMCE 4 + += v2.0.4 = + +* Changelog updated +* Screenshot updated +* Default ref custom (ref => wordpress) added to API request + += v2.0.3 = + +* Fixed typo, Thanks to @Reza +* Tested up to: 3.8.3 + += v2.0.2 = + +* Fixed curl error notification +* Trigger error deleted + += v2.0.1 = + +* Fixed Strict standards: non-static method +* Fixed empty variables +* Fixed empty campaigns notice +* Register actions moved to constructor +* Tested up to: 3.8.2 + = v2.0 = * Integration is based on API Key; diff --git a/Plugins/WordPress/screenshot-1.png b/Plugins/WordPress/screenshot-1.png index 6dcc1f4..84d4616 100644 Binary files a/Plugins/WordPress/screenshot-1.png and b/Plugins/WordPress/screenshot-1.png differ diff --git a/Plugins/WordPress/screenshot-2.png b/Plugins/WordPress/screenshot-2.png index 9a8192a..4500806 100644 Binary files a/Plugins/WordPress/screenshot-2.png and b/Plugins/WordPress/screenshot-2.png differ diff --git a/Plugins/WordPress/screenshot-3.png b/Plugins/WordPress/screenshot-3.png index d8e7e38..88b833a 100644 Binary files a/Plugins/WordPress/screenshot-3.png and b/Plugins/WordPress/screenshot-3.png differ diff --git a/Plugins/WordPress/uninstall.php b/Plugins/WordPress/uninstall.php index e2471c7..ce45782 100644 --- a/Plugins/WordPress/uninstall.php +++ b/Plugins/WordPress/uninstall.php @@ -7,13 +7,16 @@ $GrOptionDbPrefix = 'GrIntegrationOptions_'; delete_option($GrOptionDbPrefix . 'api_key'); -delete_option($GrOptionDbPrefix . 'account_type'); -delete_option($GrOptionDbPrefix . 'api_crypto'); delete_option($GrOptionDbPrefix . 'widget'); delete_option($GrOptionDbPrefix . 'comment_campaign'); -delete_option($GrOptionDbPrefix . 'checkout_campaign'); delete_option($GrOptionDbPrefix . 'comment_on'); delete_option($GrOptionDbPrefix . 'comment_label'); +delete_option($GrOptionDbPrefix . 'comment_checked'); +delete_option($GrOptionDbPrefix . 'registration_campaign'); +delete_option($GrOptionDbPrefix . 'registration_on'); +delete_option($GrOptionDbPrefix . 'registration_label'); +delete_option($GrOptionDbPrefix . 'registration_checked'); +delete_option($GrOptionDbPrefix . 'checkout_campaign'); delete_option($GrOptionDbPrefix . 'checkout_on'); delete_option($GrOptionDbPrefix . 'checkout_label'); delete_option($GrOptionDbPrefix . 'checkout_checked');