Plugin Directory

Changeset 3301156


Ignore:
Timestamp:
05/27/2025 05:33:55 AM (10 months ago)
Author:
codesupplyco
Message:

Update version

Location:
powerkit/trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • powerkit/trunk/README.txt

    r3290389 r3301156  
    44Tested up to: 6.8
    55Requires PHP: 5.4
    6 Stable tag: 2.9.8
     6Stable tag: 3.0.0
    77Contributors: codesupplyco
    88License: GPLv2 or later
     
    8383
    8484== Changelog ==
     85
     86= 3.0.0 =
     87* Added support for Kit.com in Opt-In Forms
     88* Added support for MailerLite in Opt-In Forms
     89* Added support for Custom forms in Opt-In Forms
     90* Updated Opt-In Forms documentation with new services
     91
     92= 2.9.9 =
     93* Minor improvements
    8594
    8695= 2.9.8 =
  • powerkit/trunk/languages/powerkit.pot

    r3252063 r3301156  
    173173msgstr ""
    174174
    175 #: core/core-powerkit-helpers.php:729, core/core-powerkit-helpers.php:742, extensions/gallery/class-powerkit-gallery.php:224, extensions/gallery/class-powerkit-gallery.php:245, modules/author-box/public/class-powerkit-author-box-public.php:47, modules/basic-elements/templates/buttons.php:32, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:153, modules/social-links/public/class-powerkit-social-links-block.php:80
     175#: core/core-powerkit-helpers.php:729, core/core-powerkit-helpers.php:742, extensions/gallery/class-powerkit-gallery.php:224, extensions/gallery/class-powerkit-gallery.php:245, modules/author-box/public/class-powerkit-author-box-public.php:47, modules/basic-elements/templates/buttons.php:32, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:151, modules/social-links/public/class-powerkit-social-links-block.php:80
    176176msgid "Default"
    177177msgstr ""
     
    421421msgstr ""
    422422
    423 #: modules/class-powerkit-custom-fonts.php:646, modules/coming-soon/admin/class-powerkit-coming-soon-admin.php:217, modules/headers-footers/admin/class-powerkit-headers-footers-admin.php:105, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:166, modules/post-views/admin/class-powerkit-post-views-admin.php:231, modules/share-buttons/admin/class-powerkit-share-buttons-admin.php:623, modules/social-links/admin/class-powerkit-social-links-admin.php:303, modules/table-of-contents/admin/class-powerkit-table-of-contents-admin.php:155, modules/typekit-fonts/admin/class-powerkit-typekit-fonts-admin.php:240
     423#: modules/class-powerkit-custom-fonts.php:646, modules/coming-soon/admin/class-powerkit-coming-soon-admin.php:217, modules/headers-footers/admin/class-powerkit-headers-footers-admin.php:105, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:408, modules/post-views/admin/class-powerkit-post-views-admin.php:231, modules/share-buttons/admin/class-powerkit-share-buttons-admin.php:623, modules/social-links/admin/class-powerkit-social-links-admin.php:303, modules/table-of-contents/admin/class-powerkit-table-of-contents-admin.php:155, modules/typekit-fonts/admin/class-powerkit-typekit-fonts-admin.php:240
    424424msgid "Settings saved."
    425425msgstr ""
     
    429429msgstr ""
    430430
    431 #: extensions/connect/class-powerkit-connect.php:54, extensions/fonts/class-powerkit-fonts.php:60, modules/coming-soon/admin/class-powerkit-coming-soon-admin.php:111, modules/headers-footers/admin/class-powerkit-headers-footers-admin.php:41, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:41, modules/post-views/admin/class-powerkit-post-views-admin.php:57, modules/share-buttons/admin/class-powerkit-share-buttons-admin.php:135, modules/social-links/admin/class-powerkit-social-links-admin.php:85, modules/table-of-contents/admin/class-powerkit-table-of-contents-admin.php:41
     431#: extensions/connect/class-powerkit-connect.php:54, extensions/fonts/class-powerkit-fonts.php:60, modules/coming-soon/admin/class-powerkit-coming-soon-admin.php:111, modules/headers-footers/admin/class-powerkit-headers-footers-admin.php:41, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:74, modules/post-views/admin/class-powerkit-post-views-admin.php:57, modules/share-buttons/admin/class-powerkit-share-buttons-admin.php:135, modules/social-links/admin/class-powerkit-social-links-admin.php:85, modules/table-of-contents/admin/class-powerkit-table-of-contents-admin.php:41
    432432msgid "You do not have sufficient rights to view this page."
    433433msgstr ""
     
    437437msgstr ""
    438438
    439 #: extensions/connect/class-powerkit-connect.php:148, modules/coming-soon/admin/class-powerkit-coming-soon-admin.php:184, modules/headers-footers/admin/class-powerkit-headers-footers-admin.php:80, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:132, modules/post-views/admin/class-powerkit-post-views-admin.php:179, modules/share-buttons/admin/class-powerkit-share-buttons-admin.php:496, modules/social-links/admin/class-powerkit-social-links-admin.php:235, modules/table-of-contents/admin/class-powerkit-table-of-contents-admin.php:107
     439#: extensions/connect/class-powerkit-connect.php:148, modules/coming-soon/admin/class-powerkit-coming-soon-admin.php:184, modules/headers-footers/admin/class-powerkit-headers-footers-admin.php:80, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:336, modules/post-views/admin/class-powerkit-post-views-admin.php:179, modules/share-buttons/admin/class-powerkit-share-buttons-admin.php:496, modules/social-links/admin/class-powerkit-social-links-admin.php:235, modules/table-of-contents/admin/class-powerkit-table-of-contents-admin.php:107
    440440msgid "Save changes"
    441441msgstr ""
     
    689689msgstr ""
    690690
    691 #: modules/author-box/public/class-powerkit-author-box-widget.php:179, modules/contributors/public/class-powerkit-contributors-widget.php:95, modules/facebook/public/class-powerkit-facebook-fanpage-widget.php:137, modules/featured-categories/public/class-powerkit-featured-categories-widget.php:114, modules/instagram/public/class-powerkit-instagram-widget.php:116, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:108, modules/pinterest/public/class-powerkit-pinterest-board-widget.php:104, modules/pinterest/public/class-powerkit-pinterest-profile-widget.php:104, modules/posts/public/class-powerkit-posts-widget.php:211, modules/social-links/public/class-powerkit-social-links-widget.php:121, modules/table-of-contents/public/class-powerkit-table-of-contents-widget.php:101, modules/twitter/public/class-powerkit-twitter-widget.php:110, modules/widget-about/public/class-powerkit-widget-about-init.php:106
     691#: modules/author-box/public/class-powerkit-author-box-widget.php:179, modules/contributors/public/class-powerkit-contributors-widget.php:95, modules/facebook/public/class-powerkit-facebook-fanpage-widget.php:137, modules/featured-categories/public/class-powerkit-featured-categories-widget.php:114, modules/instagram/public/class-powerkit-instagram-widget.php:116, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:109, modules/pinterest/public/class-powerkit-pinterest-board-widget.php:104, modules/pinterest/public/class-powerkit-pinterest-profile-widget.php:104, modules/posts/public/class-powerkit-posts-widget.php:211, modules/social-links/public/class-powerkit-social-links-widget.php:121, modules/table-of-contents/public/class-powerkit-table-of-contents-widget.php:101, modules/twitter/public/class-powerkit-twitter-widget.php:110, modules/widget-about/public/class-powerkit-widget-about-init.php:106
    692692msgid "Title:"
    693693msgstr ""
     
    701701msgstr ""
    702702
    703 #: modules/author-box/public/class-powerkit-author-box-widget.php:216, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:112
     703#: modules/author-box/public/class-powerkit-author-box-widget.php:216, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:113
    704704msgid "Select or upload background image"
    705705msgstr ""
    706706
    707 #: modules/author-box/public/class-powerkit-author-box-widget.php:216, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:112
     707#: modules/author-box/public/class-powerkit-author-box-widget.php:216, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:113
    708708msgid "Set background image"
    709709msgstr ""
    710710
    711 #: modules/author-box/public/class-powerkit-author-box-widget.php:218, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:114
     711#: modules/author-box/public/class-powerkit-author-box-widget.php:218, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:115
    712712msgid "Background image:"
    713713msgstr ""
    714714
    715 #: modules/author-box/public/class-powerkit-author-box-widget.php:231, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:127, modules/post-format-ui/admin/class-powerkit-post-format-ui-admin.php:167
     715#: modules/author-box/public/class-powerkit-author-box-widget.php:231, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:128, modules/post-format-ui/admin/class-powerkit-post-format-ui-admin.php:167
    716716msgid "Add Image"
    717717msgstr ""
    718718
    719 #: modules/author-box/public/class-powerkit-author-box-widget.php:232, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:128
     719#: modules/author-box/public/class-powerkit-author-box-widget.php:232, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:129
    720720msgid "Remove Image"
    721721msgstr ""
     
    845845msgstr ""
    846846
    847 #: modules/basic-elements/templates/buttons.php:82, modules/basic-elements/templates/collapsibles.php:33, modules/basic-elements/templates/tabs.php:59, modules/inline-posts/public/class-powerkit-inline-posts-shortcode.php:139, modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:62, modules/post-format-ui/admin/class-powerkit-post-format-ui-admin.php:219, modules/social-links/admin/class-powerkit-social-links-admin.php:188, modules/table-of-contents/admin/class-powerkit-table-of-contents-admin.php:61, modules/table-of-contents/public/class-powerkit-table-of-contents-block.php:94, modules/table-of-contents/public/class-powerkit-table-of-contents-shortcode.php:55
     847#: modules/basic-elements/templates/buttons.php:82, modules/basic-elements/templates/collapsibles.php:33, modules/basic-elements/templates/tabs.php:59, modules/inline-posts/public/class-powerkit-inline-posts-shortcode.php:139, modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:63, modules/post-format-ui/admin/class-powerkit-post-format-ui-admin.php:219, modules/social-links/admin/class-powerkit-social-links-admin.php:188, modules/table-of-contents/admin/class-powerkit-table-of-contents-admin.php:61, modules/table-of-contents/public/class-powerkit-table-of-contents-block.php:94, modules/table-of-contents/public/class-powerkit-table-of-contents-shortcode.php:55
    848848msgid "Title"
    849849msgstr ""
     
    970970msgstr ""
    971971
    972 #: modules/coming-soon/admin/class-powerkit-coming-soon-admin.php:149, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:99, modules/typekit-fonts/admin/class-powerkit-typekit-fonts-admin.php:87
     972#: modules/coming-soon/admin/class-powerkit-coming-soon-admin.php:149, modules/typekit-fonts/admin/class-powerkit-typekit-fonts-admin.php:87
    973973msgid "- not selected -"
    974974msgstr ""
     
    16341634msgstr ""
    16351635
    1636 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:30, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:30, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:48
     1636#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:63, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:63, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:84
    16371637msgid "Opt-in Forms"
    16381638msgstr ""
    16391639
    1640 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:52
     1640#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:93, modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:80, modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:78
     1641msgid "Subscription Service"
     1642msgstr ""
     1643
     1644#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:96, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:108, modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:85, modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:81, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:141
    16411645msgid "MailChimp"
    16421646msgstr ""
    16431647
    1644 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:58
     1648#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:97, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:177, modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:86, modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:82, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:142
     1649msgid "Kit.com"
     1650msgstr ""
     1651
     1652#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:98, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:229, modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:87, modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:83, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:143
     1653msgid "MailerLite"
     1654msgstr ""
     1655
     1656#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:99, modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:88, modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:84, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:144
     1657msgid "Custom"
     1658msgstr ""
     1659
     1660#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:114, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:183, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:235
    16451661msgid "API Key"
    16461662msgstr ""
    16471663
    1648 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:64, modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:84, modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:78, modules/share-buttons/admin/class-powerkit-share-buttons-admin.php:473, modules/typekit-fonts/admin/class-powerkit-typekit-fonts-admin.php:62
     1664#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:117
     1665msgid "Refresh Lists"
     1666msgstr ""
     1667
     1668#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:123, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:192, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:246, modules/share-buttons/admin/class-powerkit-share-buttons-admin.php:473, modules/typekit-fonts/admin/class-powerkit-typekit-fonts-admin.php:62
    16491669msgid "Log in to your"
    16501670msgstr ""
    16511671
    1652 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:64, modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:84, modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:78
     1672#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:123
    16531673msgid "MailChimp account"
    16541674msgstr ""
    16551675
    1656 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:65
     1676#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:124
    16571677msgid "Click your profile name to expand the Account Panel, and choose Account."
    16581678msgstr ""
    16591679
    1660 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:66
     1680#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:125
    16611681msgid "Click the Extras drop-down menu and choose API keys."
    16621682msgstr ""
    16631683
    1664 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:67
     1684#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:126
    16651685msgid "Copy an existing API key or click the Create A Key button."
    16661686msgstr ""
    16671687
    1668 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:68
    1669 msgid "Name your key descriptively, so you know what application uses that key."
    1670 msgstr ""
    1671 
    1672 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:107
    1673 msgid "Invalid API Key or MailChimp access error!"
    1674 msgstr ""
    1675 
    1676 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:96
     1688#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:127
     1689msgid "Click \"Refresh Lists\" button after entering your API key to load your audiences."
     1690msgstr ""
     1691
     1692#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:133
    16771693msgid "Default Audience"
    16781694msgstr ""
    16791695
    1680 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:114
     1696#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:136
     1697msgid "— Select an Audience —"
     1698msgstr ""
     1699
     1700#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:168
    16811701msgid "Enable Double opt-in"
    16821702msgstr ""
    16831703
    1684 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:121
     1704#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:186
     1705msgid "Refresh Forms"
     1706msgstr ""
     1707
     1708#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:192
     1709msgid "Kit.com account"
     1710msgstr ""
     1711
     1712#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:193
     1713msgid "Click on your profile icon and go to Settings."
     1714msgstr ""
     1715
     1716#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:194
     1717msgid "Navigate to the Developer section."
     1718msgstr ""
     1719
     1720#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:195
     1721msgid "Copy the V3 Public API Key."
     1722msgstr ""
     1723
     1724#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:200
     1725msgid "Default Form"
     1726msgstr ""
     1727
     1728#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:203, modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:258
     1729msgid "— Select a Form —"
     1730msgstr ""
     1731
     1732#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:220
     1733msgid "Select a form from your Kit.com account. If you don't see your forms, click \"Refresh Forms\" after entering your API key."
     1734msgstr ""
     1735
     1736#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:239
     1737msgid "Refresh Groups"
     1738msgstr ""
     1739
     1740#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:246
     1741msgid "MailerLite account"
     1742msgstr ""
     1743
     1744#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:247
     1745msgid "Go to Integrations → API from the main menu."
     1746msgstr ""
     1747
     1748#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:248
     1749msgid "Copy your API key or generate a new one if needed."
     1750msgstr ""
     1751
     1752#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:249
     1753msgid "Click \"Refresh Groups\" button after entering your API key to load your groups."
     1754msgstr ""
     1755
     1756#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:255
     1757msgid "Default Group"
     1758msgstr ""
     1759
     1760#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:276
     1761msgid "Select a group from your MailerLite account. If you don't see your groups, click \"Refresh Groups\" after entering your API key."
     1762msgstr ""
     1763
     1764#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:285
     1765msgid "Custom Form"
     1766msgstr ""
     1767
     1768#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:291
     1769msgid "Form Action URL"
     1770msgstr ""
     1771
     1772#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:296
     1773msgid "Email Field Name"
     1774msgstr ""
     1775
     1776#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:301
     1777msgid "Name Field Name"
     1778msgstr ""
     1779
     1780#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:306
     1781msgid "Hidden Fields"
     1782msgstr ""
     1783
     1784#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:309
     1785msgid "Enter hidden fields in format: field_name=value (one per line)"
     1786msgstr ""
     1787
     1788#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:317
     1789msgid "Common Settings"
     1790msgstr ""
     1791
     1792#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:325
    16851793msgid "Data Privacy Checkbox Label"
    16861794msgstr ""
    16871795
    1688 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:122
     1796#: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:326
    16891797msgid "Enter the contents that should display as a label for the data privacy checkbox. Leave blank to disable."
    16901798msgstr ""
     
    16941802msgstr ""
    16951803
    1696 #: modules/opt-in-forms/helpers/helper-powerkit-opt-in-forms.php:85
     1804#: modules/opt-in-forms/helpers/helper-powerkit-opt-in-forms.php:119
    16971805msgid "This client has not been approved to access this resource."
    16981806msgstr ""
    16991807
     1808#: modules/opt-in-forms/helpers/helper-powerkit-opt-in-forms.php:186
     1809msgid "Unable to connect to Kit.com API."
     1810msgstr ""
     1811
     1812#: modules/opt-in-forms/helpers/helper-powerkit-opt-in-forms.php:275
     1813msgid "Unable to connect to MailerLite API."
     1814msgstr ""
     1815
     1816#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:108
     1817msgid "Something is wrong with your list ID."
     1818msgstr ""
     1819
     1820#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:112
     1821msgid "Email is invalid."
     1822msgstr ""
     1823
     1824#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:175, modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:214, modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:260
     1825msgid "You are already subscribed."
     1826msgstr ""
     1827
     1828#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:171
     1829msgid "You have successfully subscribed. Confirm the subscription in your mailbox."
     1830msgstr ""
     1831
     1832#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:167, modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:223, modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:220, modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:258
     1833msgid "You have successfully subscribed."
     1834msgstr ""
     1835
     1836#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:228, modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:262
     1837msgid "An error occurred while subscribing."
     1838msgstr ""
     1839
     1840#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:218
     1841msgid "You have successfully subscribed, confirm your subscription by email."
     1842msgstr ""
     1843
     1844#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:216
     1845msgid "You are already subscribed, confirm your subscription by email."
     1846msgstr ""
     1847
     1848#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:283
     1849msgid "Please confirm that you agree with our policies."
     1850msgstr ""
     1851
     1852#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:285
     1853msgid "Server error occurred. Please try again later."
     1854msgstr ""
     1855
    17001856#. translators: MailChimp Settings.
    1701 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:115
     1857#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:360
    17021858msgid "Please add your MailChimp Token in <object><a href=\"%s\" target=\"_blank\">Opt-In Forms Settings</a></object>."
    17031859msgstr ""
    17041860
    1705 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:111
     1861#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:356
    17061862msgid "Please select the \"List\" for your subscription form in <object><a href=\"%s\" target=\"_blank\">Opt-In Forms Settings</a></object>."
    17071863msgstr ""
    17081864
    1709 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:89
     1865#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:334, modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:409, modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:484, modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:562
    17101866msgid "Enter your name"
    17111867msgstr ""
    17121868
    1713 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:92
     1869#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:337, modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:412, modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:487, modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:565
    17141870msgid "Enter your email"
    17151871msgstr ""
    17161872
    1717 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:94
     1873#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:339, modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:414, modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:489, modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:567
    17181874msgid "Subscribe"
    17191875msgstr ""
    17201876
    1721 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:145
    1722 msgid "Something is wrong with your list ID."
    1723 msgstr ""
    1724 
    1725 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:149
    1726 msgid "Email is invalid."
    1727 msgstr ""
    1728 
    1729 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:187
    1730 msgid "You are already subscribed."
    1731 msgstr ""
    1732 
    1733 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:183
    1734 msgid "You have successfully subscribed. Confirm the subscription in your mailbox."
    1735 msgstr ""
    1736 
    1737 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:179
    1738 msgid "You have successfully subscribed."
    1739 msgstr ""
    1740 
    1741 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:215
    1742 msgid "Please confirm that you agree with our policies."
     1877#. translators: Kit.com Settings.
     1878#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:435
     1879msgid "Please add your Kit.com Token in <object><a href=\"%s\" target=\"_blank\">Opt-In Forms Settings</a></object>."
     1880msgstr ""
     1881
     1882#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:431
     1883msgid "Please select the Kit.com Form in <object><a href=\"%s\" target=\"_blank\">Opt-In Forms Settings</a></object>."
     1884msgstr ""
     1885
     1886#. translators: MailerLite Settings.
     1887#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:510
     1888msgid "Please add your MailerLite Token in <object><a href=\"%s\" target=\"_blank\">Opt-In Forms Settings</a></object>."
     1889msgstr ""
     1890
     1891#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:506
     1892msgid "Please select the MailerLite Group ID in <object><a href=\"%s\" target=\"_blank\">Opt-In Forms Settings</a></object>."
     1893msgstr ""
     1894
     1895#. translators: Custom Settings.
     1896#: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:582
     1897msgid "Please set a form action URL in <object><a href=\"%s\" target=\"_blank\">Opt-In Forms Settings</a></object>."
    17431898msgstr ""
    17441899
     
    17471902msgstr ""
    17481903
    1749 #: modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:80, modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:77
    1750 msgid "List ID"
    1751 msgstr ""
    1752 
    1753 #: modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:82
    1754 msgid "If empty, List ID from Settings &rarr; Opt-In Forms will be used."
    1755 msgstr ""
    1756 
    1757 #: modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:85, modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:79
    1758 msgid "Go to your Lists."
    1759 msgstr ""
    1760 
    1761 #: modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:86, modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:80
    1762 msgid "Select the desired list and in the drop-down menu and go to Settings."
    1763 msgstr ""
    1764 
    1765 #: modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:87, modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:81
    1766 msgid "Copy your list ID from the field “Unique ID for list …”."
    1767 msgstr ""
    1768 
    1769 #: modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:96
     1904#: modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:93, modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:90
     1905msgid "List/Form/Group ID"
     1906msgstr ""
     1907
     1908#: modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:94, modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:91, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:152
     1909msgid "If empty, the default ID from Settings → Opt-In Forms will be used."
     1910msgstr ""
     1911
     1912#: modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:101
    17701913msgid "Display First Name Field"
    17711914msgstr ""
    17721915
    1773 #: modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:97, modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:87, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:167
    1774 msgid "Make sure you map the field in the MailChimp settings"
    1775 msgstr ""
    1776 
    1777 #: modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:105
     1916#: modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:102, modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:97, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:158
     1917msgid "Make sure the name field is supported by your selected service"
     1918msgstr ""
     1919
     1920#: modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:109
    17781921msgid "Color Legend"
    17791922msgstr ""
    17801923
    1781 #: modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:54, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:30, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:47
     1924#: modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:55, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:30, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:48
    17821925msgid "Subscription Form"
    17831926msgstr ""
    17841927
    1785 #: modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:67
     1928#: modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:68
    17861929msgid "Background image ID"
    17871930msgstr ""
    17881931
    1789 #: modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:72
     1932#: modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:73
    17901933msgid "Message"
    17911934msgstr ""
    17921935
    1793 #: modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:86, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:166
     1936#: modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:96, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:157
    17941937msgid "Display first name field"
    17951938msgstr ""
    17961939
    1797 #: modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:41
     1940#: modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:42
    17981941msgid "Add a subscription form to your sidebar."
    17991942msgstr ""
    18001943
    1801 #: modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:133
     1944#: modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:134
    18021945msgid "Subscribe message:"
    18031946msgstr ""
    18041947
    1805 #: modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:151
    1806 msgid "List:"
     1948#: modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:139
     1949msgid "Subscription Service:"
     1950msgstr ""
     1951
     1952#: modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:150
     1953msgid "List/Form/Group ID:"
    18071954msgstr ""
    18081955
  • powerkit/trunk/modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php

    r2320052 r3301156  
    2020    public function initialize() {
    2121        add_action( 'admin_menu', array( $this, 'register_options_page' ) );
     22        add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
     23        add_action( 'wp_ajax_powerkit_refresh_kit_forms', array( $this, 'ajax_refresh_kit_forms' ) );
     24        add_action( 'wp_ajax_powerkit_refresh_mailchimp_lists', array( $this, 'ajax_refresh_mailchimp_lists' ) );
     25        add_action( 'wp_ajax_powerkit_refresh_mailerlite_groups', array( $this, 'ajax_refresh_mailerlite_groups' ) );
     26    }
     27
     28    /**
     29     * Register the JavaScript for the admin area.
     30     *
     31     * @param string $hook The current admin page.
     32     */
     33    public function admin_enqueue_scripts( $hook ) {
     34        // Only load on opt-in forms settings page.
     35        if ( 'settings_page_powerkit_opt_in_forms' !== $hook ) {
     36            return;
     37        }
     38
     39        wp_enqueue_script(
     40            'powerkit-opt-in-forms-admin',
     41            plugin_dir_url( __FILE__ ) . 'js/admin-powerkit-opt-in-forms.js',
     42            array( 'jquery' ),
     43            powerkit_get_setting( 'version' ),
     44            true
     45        );
     46
     47        // Localize the script with a nonce.
     48        wp_localize_script(
     49            'powerkit-opt-in-forms-admin',
     50            'powerkit_opt_in_forms',
     51            array(
     52                'nonce' => wp_create_nonce(),
     53            )
     54        );
    2255    }
    2356
     
    4376
    4477        $this->save_options_page();
     78
     79        // Get selected service.
     80        $selected_service = get_option( 'powerkit_subscription_service', 'mailchimp' );
    4581        ?>
    4682
     
    5086                <div class="pk-settings">
    5187                    <form method="post">
    52                         <h3><?php esc_html_e( 'MailChimp', 'powerkit' ); ?></h3>
    53 
     88
     89                        <!-- Service Selection -->
    5490                        <table class="form-table">
    5591                            <tbody>
    56                                 <!-- API Key -->
    5792                                <tr>
    58                                     <th scope="row"><label for="powerkit_mailchimp_token"><?php esc_html_e( 'API Key', 'powerkit' ); ?></label></th>
    59                                     <td><input class="regular-text" id="powerkit_mailchimp_token" name="powerkit_mailchimp_token" type="text" value="<?php echo esc_attr( get_option( 'powerkit_mailchimp_token' ) ); ?>"></td>
    60                                 </tr>
    61                                 <tr>
    62                                     <td colspan="2">
    63                                         <ol>
    64                                             <li><?php esc_html_e( 'Log in to your', 'powerkit' ); ?> <?php echo sprintf( '<a href="%1$s" target="_blank">%2$s</a>', esc_url( 'https://mailchimp.com' ), esc_html__( 'MailChimp account', 'powerkit' ) ); ?>.</li>
    65                                             <li><?php esc_html_e( 'Click your profile name to expand the Account Panel, and choose Account.', 'powerkit' ); ?></li>
    66                                             <li><?php esc_html_e( 'Click the Extras drop-down menu and choose API keys.', 'powerkit' ); ?></li>
    67                                             <li><?php esc_html_e( 'Copy an existing API key or click the Create A Key button.', 'powerkit' ); ?></li>
    68                                             <li><?php esc_html_e( 'Name your key descriptively, so you know what application uses that key.', 'powerkit' ); ?></li>
    69                                         </ol>
     93                                    <th scope="row"><label for="powerkit_subscription_service"><?php esc_html_e( 'Subscription Service', 'powerkit' ); ?></label></th>
     94                                    <td>
     95                                        <select class="regular-text" name="powerkit_subscription_service" id="powerkit_subscription_service">
     96                                            <option value="mailchimp" <?php selected( 'mailchimp', $selected_service ); ?>><?php esc_html_e( 'MailChimp', 'powerkit' ); ?></option>
     97                                            <option value="kit" <?php selected( 'kit', $selected_service ); ?>><?php esc_html_e( 'Kit.com', 'powerkit' ); ?></option>
     98                                            <option value="mailerlite" <?php selected( 'mailerlite', $selected_service ); ?>><?php esc_html_e( 'MailerLite', 'powerkit' ); ?></option>
     99                                            <option value="custom" <?php selected( 'custom', $selected_service ); ?>><?php esc_html_e( 'Custom', 'powerkit' ); ?></option>
     100                                        </select>
    70101                                    </td>
    71102                                </tr>
    72                                 <!-- Lists -->
    73                                 <tr>
    74                                     <?php
    75                                     $token = get_option( 'powerkit_mailchimp_token' );
    76 
    77                                     if ( $token ) {
    78 
    79                                         $response = null;
    80 
    81                                         $data = powerkit_mailchimp_request(
    82                                             'GET', 'lists', array(
    83                                                 'sort_field' => 'date_created',
    84                                                 'sort_dir' => 'DESC',
    85                                                 'count'    => 1000,
    86                                             )
    87                                         );
    88 
    89                                         if ( is_array( $data ) ) {
    90                                             $response .= isset( $data['type'] ) ? $data['type'] : '';
    91                                             $response .= isset( $data['title'] ) ? ':' . $data['title'] : '';
    92                                         }
    93 
    94                                         if ( is_array( $data ) && isset( $data['lists'] ) && $data['lists'] ) {
    95                                             ?>
    96                                             <th scope="row"><label for="powerkit_mailchimp_list"><?php esc_html_e( 'Default Audience', 'powerkit' ); ?></label></th>
    97                                             <td>
    98                                                 <select class="regular-text" name="powerkit_mailchimp_list" id="powerkit_mailchimp_list">
    99                                                     <option value=""><?php esc_html_e( '- not selected -', 'powerkit' ); ?></option>
    100                                                     <?php foreach ( $data['lists'] as $item ) : ?>
    101                                                         <option <?php selected( $item['id'], get_option( 'powerkit_mailchimp_list' ) ); ?> value="<?php echo esc_attr( $item['id'] ); ?>"><?php echo esc_html( $item['name'] ); ?></option>
    102                                                     <?php endforeach; ?>
    103                                                 </select>
    104                                             </td>
    105                                         <?php } else { ?>
    106                                             <td colspan="2">
    107                                                 <code><?php printf( '[%s] %s', esc_html( $response ), esc_html__( 'Invalid API Key or MailChimp access error!', 'powerkit' ) ); ?></code>
    108                                             </td>
    109                                         <?php } ?>
    110                                     <?php } ?>
    111                                 </tr>
    112                                 <!-- Enable double opt-in -->
    113                                 <tr>
    114                                     <th scope="row"><label for="powerkit_mailchimp_double_optin"><?php esc_html_e( 'Enable Double opt-in', 'powerkit' ); ?></label></th>
    115                                     <td><input class="regular-text" id="powerkit_mailchimp_double_optin" name="powerkit_mailchimp_double_optin" type="checkbox" value="true" <?php checked( (bool) get_option( 'powerkit_mailchimp_double_optin', false ) ); ?>></td>
    116                                 </tr>
     103                            </tbody>
     104                        </table>
     105
     106                        <!-- MailChimp Settings -->
     107                        <div id="mailchimp-settings" class="service-settings" <?php echo 'mailchimp' !== $selected_service ? 'style="display: none;"' : ''; ?>>
     108                            <h3><?php esc_html_e( 'MailChimp', 'powerkit' ); ?></h3>
     109
     110                            <table class="form-table">
     111                                <tbody>
     112                                    <!-- API Key -->
     113                                    <tr>
     114                                        <th scope="row"><label for="powerkit_mailchimp_token"><?php esc_html_e( 'API Key', 'powerkit' ); ?></label></th>
     115                                        <td>
     116                                            <input class="regular-text" id="powerkit_mailchimp_token" name="powerkit_mailchimp_token" type="text" value="<?php echo esc_attr( get_option( 'powerkit_mailchimp_token' ) ); ?>">
     117                                            <button type="button" id="refresh-mailchimp-lists" class="button button-secondary"><?php esc_html_e( 'Refresh Lists', 'powerkit' ); ?></button>
     118                                        </td>
     119                                    </tr>
     120                                    <tr>
     121                                        <td colspan="2">
     122                                            <ol>
     123                                                <li><?php esc_html_e( 'Log in to your', 'powerkit' ); ?> <?php printf( '<a href="%1$s" target="_blank">%2$s</a>', esc_url( 'https://mailchimp.com' ), esc_html__( 'MailChimp account', 'powerkit' ) ); ?>.</li>
     124                                                <li><?php esc_html_e( 'Click your profile name to expand the Account Panel, and choose Account.', 'powerkit' ); ?></li>
     125                                                <li><?php esc_html_e( 'Click the Extras drop-down menu and choose API keys.', 'powerkit' ); ?></li>
     126                                                <li><?php esc_html_e( 'Copy an existing API key or click the Create A Key button.', 'powerkit' ); ?></li>
     127                                                <li><?php esc_html_e( 'Click "Refresh Lists" button after entering your API key to load your audiences.', 'powerkit' ); ?></li>
     128                                            </ol>
     129                                        </td>
     130                                    </tr>
     131                                    <!-- Lists -->
     132                                    <tr>
     133                                        <th scope="row"><label for="powerkit_mailchimp_list"><?php esc_html_e( 'Default Audience', 'powerkit' ); ?></label></th>
     134                                        <td>
     135                                            <select class="regular-text" name="powerkit_mailchimp_list" id="powerkit_mailchimp_list">
     136                                                <option value=""><?php esc_html_e( '— Select an Audience —', 'powerkit' ); ?></option>
     137                                                <?php
     138                                                $saved_list_id = get_option( 'powerkit_mailchimp_list' );
     139                                                $token         = get_option( 'powerkit_mailchimp_token' );
     140
     141                                                if ( $token ) {
     142                                                    $data = powerkit_mailchimp_request(
     143                                                        'GET', 'lists', array(
     144                                                            'sort_field' => 'date_created',
     145                                                            'sort_dir' => 'DESC',
     146                                                            'count'    => 1000,
     147                                                        )
     148                                                    );
     149
     150                                                    if ( is_array( $data ) && isset( $data['lists'] ) && $data['lists'] ) {
     151                                                        foreach ( $data['lists'] as $item ) {
     152                                                            printf(
     153                                                                '<option value="%1$s" %2$s>%3$s</option>',
     154                                                                esc_attr( $item['id'] ),
     155                                                                selected( $saved_list_id, $item['id'], false ),
     156                                                                esc_html( $item['name'] . ' (' . $item['id'] . ')' )
     157                                                            );
     158                                                        }
     159                                                    }
     160                                                }
     161                                                ?>
     162                                            </select>
     163                                            <p class="description notification-area"></p>
     164                                        </td>
     165                                    </tr>
     166                                    <!-- Enable double opt-in -->
     167                                    <tr>
     168                                        <th scope="row"><label for="powerkit_mailchimp_double_optin"><?php esc_html_e( 'Enable Double opt-in', 'powerkit' ); ?></label></th>
     169                                        <td><input class="regular-text" id="powerkit_mailchimp_double_optin" name="powerkit_mailchimp_double_optin" type="checkbox" value="true" <?php checked( (bool) get_option( 'powerkit_mailchimp_double_optin', false ) ); ?>></td>
     170                                    </tr>
     171                                </tbody>
     172                            </table>
     173                        </div>
     174
     175                        <!-- Kit.com Settings -->
     176                        <div id="kit-settings" class="service-settings" <?php echo 'kit' !== $selected_service ? 'style="display: none;"' : ''; ?>>
     177                            <h3><?php esc_html_e( 'Kit.com', 'powerkit' ); ?></h3>
     178
     179                            <table class="form-table">
     180                                <tbody>
     181                                    <!-- API Key -->
     182                                    <tr>
     183                                        <th scope="row"><label for="powerkit_kit_token"><?php esc_html_e( 'API Key', 'powerkit' ); ?></label></th>
     184                                        <td>
     185                                            <input class="regular-text" id="powerkit_kit_token" name="powerkit_kit_token" type="text" value="<?php echo esc_attr( get_option( 'powerkit_kit_token' ) ); ?>">
     186                                            <button type="button" id="refresh-kit-forms" class="button button-secondary"><?php esc_html_e( 'Refresh Forms', 'powerkit' ); ?></button>
     187                                        </td>
     188                                    </tr>
     189                                    <tr>
     190                                        <td colspan="2">
     191                                            <ol>
     192                                                <li><?php esc_html_e( 'Log in to your', 'powerkit' ); ?> <?php printf( '<a href="%1$s" target="_blank">%2$s</a>', esc_url( 'https://kit.com' ), esc_html__( 'Kit.com account', 'powerkit' ) ); ?>.</li>
     193                                                <li><?php esc_html_e( 'Click on your profile icon and go to Settings.', 'powerkit' ); ?></li>
     194                                                <li><?php esc_html_e( 'Navigate to the Developer section.', 'powerkit' ); ?></li>
     195                                                <li><?php esc_html_e( 'Copy the V3 Public API Key.', 'powerkit' ); ?></li>
     196                                            </ol>
     197                                        </td>
     198                                    </tr>
     199                                    <tr>
     200                                        <th scope="row"><label for="powerkit_kit_form"><?php esc_html_e( 'Default Form', 'powerkit' ); ?></label></th>
     201                                        <td>
     202                                            <select class="regular-text" id="powerkit_kit_form" name="powerkit_kit_form">
     203                                                <option value=""><?php esc_html_e( '— Select a Form —', 'powerkit' ); ?></option>
     204                                                <?php
     205                                                $saved_form_id = get_option( 'powerkit_kit_form' );
     206                                                $forms         = function_exists( 'powerkit_kit_get_forms' ) ? powerkit_kit_get_forms() : array();
     207
     208                                                if ( ! empty( $forms ) ) {
     209                                                    foreach ( $forms as $form ) {
     210                                                        printf(
     211                                                            '<option value="%1$s" %2$s>%3$s</option>',
     212                                                            esc_attr( $form['id'] ),
     213                                                            selected( $saved_form_id, $form['id'], false ),
     214                                                            esc_html( $form['name'] . ' (' . $form['id'] . ')' )
     215                                                        );
     216                                                    }
     217                                                }
     218                                                ?>
     219                                            </select>
     220                                            <p class="description"><?php esc_html_e( 'Select a form from your Kit.com account. If you don\'t see your forms, click "Refresh Forms" after entering your API key.', 'powerkit' ); ?></p>
     221                                        </td>
     222                                    </tr>
     223                                </tbody>
     224                            </table>
     225                        </div>
     226
     227                        <!-- MailerLite Settings -->
     228                        <div id="mailerlite-settings" class="service-settings" <?php echo 'mailerlite' !== $selected_service ? 'style="display: none;"' : ''; ?>>
     229                            <h3><?php esc_html_e( 'MailerLite', 'powerkit' ); ?></h3>
     230
     231                            <table class="form-table">
     232                                <tbody>
     233                                    <!-- API Key -->
     234                                    <tr>
     235                                        <th scope="row"><label for="powerkit_mailerlite_token"><?php esc_html_e( 'API Key', 'powerkit' ); ?></label></th>
     236                                        <td>
     237                                            <textarea class="regular-text" id="powerkit_mailerlite_token" name="powerkit_mailerlite_token" rows="5"><?php echo esc_textarea( get_option( 'powerkit_mailerlite_token' ) ); ?></textarea>
     238                                            <p>
     239                                                <button type="button" id="refresh-mailerlite-groups" class="button button-secondary"><?php esc_html_e( 'Refresh Groups', 'powerkit' ); ?></button>
     240                                            </p>
     241                                        </td>
     242                                    </tr>
     243                                    <tr>
     244                                        <td colspan="2">
     245                                            <ol>
     246                                                <li><?php esc_html_e( 'Log in to your', 'powerkit' ); ?> <?php printf( '<a href="%1$s" target="_blank">%2$s</a>', esc_url( 'https://dashboard.mailerlite.com/integrations/api' ), esc_html__( 'MailerLite account', 'powerkit' ) ); ?>.</li>
     247                                                <li><?php esc_html_e( 'Go to Integrations → API from the main menu.', 'powerkit' ); ?></li>
     248                                                <li><?php esc_html_e( 'Copy your API key or generate a new one if needed.', 'powerkit' ); ?></li>
     249                                                <li><?php esc_html_e( 'Click "Refresh Groups" button after entering your API key to load your groups.', 'powerkit' ); ?></li>
     250                                            </ol>
     251                                        </td>
     252                                    </tr>
     253                                    <!-- Default Group -->
     254                                    <tr>
     255                                        <th scope="row"><label for="powerkit_mailerlite_group"><?php esc_html_e( 'Default Group', 'powerkit' ); ?></label></th>
     256                                        <td>
     257                                            <select class="regular-text" id="powerkit_mailerlite_group" name="powerkit_mailerlite_group">
     258                                                <option value=""><?php esc_html_e( '— Select a Form —', 'powerkit' ); ?></option>
     259                                                <?php
     260                                                $saved_group_id = get_option( 'powerkit_mailerlite_group' );
     261                                                $groups         = function_exists( 'powerkit_mailerlite_get_groups' ) ? powerkit_mailerlite_get_groups() : array();
     262
     263                                                if ( ! empty( $groups ) ) {
     264                                                    foreach ( $groups as $group ) {
     265                                                        printf(
     266                                                            '<option value="%1$s" %2$s>%3$s</option>',
     267                                                            esc_attr( $group['id'] ),
     268                                                            selected( (string) $saved_group_id, (string) $group['id'], false ),
     269                                                            esc_html( $group['name'] . ' (' . $group['id'] . ')' )
     270                                                        );
     271                                                    }
     272                                                }
     273                                                ?>
     274                                            </select>
     275                                            <p class="description notification-area"></p>
     276                                            <p class="description"><?php esc_html_e( 'Select a group from your MailerLite account. If you don\'t see your groups, click "Refresh Groups" after entering your API key.', 'powerkit' ); ?></p>
     277                                        </td>
     278                                    </tr>
     279                                </tbody>
     280                            </table>
     281                        </div>
     282
     283                        <!-- Custom Form Settings -->
     284                        <div id="custom-settings" class="service-settings" <?php echo 'custom' !== $selected_service ? 'style="display: none;"' : ''; ?>>
     285                            <h3><?php esc_html_e( 'Custom Form', 'powerkit' ); ?></h3>
     286
     287                            <table class="form-table">
     288                                <tbody>
     289                                    <!-- Form Action URL -->
     290                                    <tr>
     291                                        <th scope="row"><label for="powerkit_custom_form_action"><?php esc_html_e( 'Form Action URL', 'powerkit' ); ?></label></th>
     292                                        <td><input class="regular-text" id="powerkit_custom_form_action" name="powerkit_custom_form_action" type="text" value="<?php echo esc_attr( get_option( 'powerkit_custom_form_action' ) ); ?>"></td>
     293                                    </tr>
     294                                    <!-- Email Field Name -->
     295                                    <tr>
     296                                        <th scope="row"><label for="powerkit_custom_email_name"><?php esc_html_e( 'Email Field Name', 'powerkit' ); ?></label></th>
     297                                        <td><input class="regular-text" id="powerkit_custom_email_name" name="powerkit_custom_email_name" type="text" value="<?php echo esc_attr( get_option( 'powerkit_custom_email_name', 'email' ) ); ?>"></td>
     298                                    </tr>
     299                                    <!-- Name Field Name -->
     300                                    <tr>
     301                                        <th scope="row"><label for="powerkit_custom_name_field"><?php esc_html_e( 'Name Field Name', 'powerkit' ); ?></label></th>
     302                                        <td><input class="regular-text" id="powerkit_custom_name_field" name="powerkit_custom_name_field" type="text" value="<?php echo esc_attr( get_option( 'powerkit_custom_name_field', 'name' ) ); ?>"></td>
     303                                    </tr>
     304                                    <!-- Hidden Fields -->
     305                                    <tr>
     306                                        <th scope="row"><label for="powerkit_custom_hidden_fields"><?php esc_html_e( 'Hidden Fields', 'powerkit' ); ?></label></th>
     307                                        <td>
     308                                            <textarea class="regular-text" id="powerkit_custom_hidden_fields" name="powerkit_custom_hidden_fields" rows="5"><?php echo esc_html( get_option( 'powerkit_custom_hidden_fields', '' ) ); ?></textarea>
     309                                            <p class="description"><?php esc_html_e( 'Enter hidden fields in format: field_name=value (one per line)', 'powerkit' ); ?></p>
     310                                        </td>
     311                                    </tr>
     312                                </tbody>
     313                            </table>
     314                        </div>
     315
     316                        <!-- Common Settings -->
     317                        <h3><?php esc_html_e( 'Common Settings', 'powerkit' ); ?></h3>
     318
     319                        <table class="form-table">
     320                            <tbody>
    117321                                <!-- Data Privacy Checkbox Label -->
    118322                                <tr>
     
    149353
    150354        if ( isset( $_POST['save_settings'] ) ) { // Input var ok.
    151 
     355            // Subscription service.
     356            if ( isset( $_POST['powerkit_subscription_service'] ) ) { // Input var ok.
     357                update_option( 'powerkit_subscription_service', sanitize_text_field( wp_unslash( $_POST['powerkit_subscription_service'] ) ) ); // Input var ok.
     358            }
     359
     360            // MailChimp settings.
    152361            if ( isset( $_POST['powerkit_mailchimp_token'] ) ) { // Input var ok.
    153362                update_option( 'powerkit_mailchimp_token', sanitize_text_field( wp_unslash( $_POST['powerkit_mailchimp_token'] ) ) ); // Input var ok.
    154363            }
    155364            if ( isset( $_POST['powerkit_mailchimp_list'] ) ) { // Input var ok.
    156                 update_option( 'powerkit_mailchimp_list', sanitize_text_field( wp_unslash( $_POST['powerkit_mailchimp_list'] ) ) ); // Input var ok.
     365                update_option( 'powerkit_mailchimp_list', (string) sanitize_text_field( wp_unslash( $_POST['powerkit_mailchimp_list'] ) ) ); // Input var ok.
    157366            }
    158367            if ( isset( $_POST['powerkit_mailchimp_double_optin'] ) ) { // Input var ok.
     
    161370                update_option( 'powerkit_mailchimp_double_optin', false );
    162371            }
     372
     373            // Kit.com settings.
     374            if ( isset( $_POST['powerkit_kit_token'] ) ) { // Input var ok.
     375                update_option( 'powerkit_kit_token', sanitize_text_field( wp_unslash( $_POST['powerkit_kit_token'] ) ) ); // Input var ok.
     376            }
     377            if ( isset( $_POST['powerkit_kit_form'] ) ) { // Input var ok.
     378                update_option( 'powerkit_kit_form', (string) sanitize_text_field( wp_unslash( $_POST['powerkit_kit_form'] ) ) ); // Input var ok.
     379            }
     380
     381            // MailerLite settings.
     382            if ( isset( $_POST['powerkit_mailerlite_token'] ) ) { // Input var ok.
     383                update_option( 'powerkit_mailerlite_token', sanitize_text_field( wp_unslash( $_POST['powerkit_mailerlite_token'] ) ) ); // Input var ok.
     384            }
     385            if ( isset( $_POST['powerkit_mailerlite_group'] ) ) { // Input var ok.
     386                update_option( 'powerkit_mailerlite_group', (string) sanitize_text_field( wp_unslash( $_POST['powerkit_mailerlite_group'] ) ) ); // Input var ok.
     387            }
     388
     389            // Custom form settings.
     390            if ( isset( $_POST['powerkit_custom_form_action'] ) ) { // Input var ok.
     391                update_option( 'powerkit_custom_form_action', esc_url_raw( wp_unslash( $_POST['powerkit_custom_form_action'] ) ) ); // Input var ok.
     392            }
     393            if ( isset( $_POST['powerkit_custom_email_name'] ) ) { // Input var ok.
     394                update_option( 'powerkit_custom_email_name', sanitize_text_field( wp_unslash( $_POST['powerkit_custom_email_name'] ) ) ); // Input var ok.
     395            }
     396            if ( isset( $_POST['powerkit_custom_name_field'] ) ) { // Input var ok.
     397                update_option( 'powerkit_custom_name_field', sanitize_text_field( wp_unslash( $_POST['powerkit_custom_name_field'] ) ) ); // Input var ok.
     398            }
     399            if ( isset( $_POST['powerkit_custom_hidden_fields'] ) ) { // Input var ok.
     400                update_option( 'powerkit_custom_hidden_fields', sanitize_textarea_field( wp_unslash( $_POST['powerkit_custom_hidden_fields'] ) ) ); // Input var ok.
     401            }
     402
     403            // Privacy setting.
    163404            if ( isset( $_POST['powerkit_mailchimp_privacy'] ) ) { // Input var ok.
    164405                update_option( 'powerkit_mailchimp_privacy', wp_kses( wp_unslash( $_POST['powerkit_mailchimp_privacy'] ), 'post' ) ); // Input var ok. sanitization ok.
    165406            }
     407
    166408            printf( '<div id="message" class="updated fade"><p><strong>%s</strong></p></div>', esc_html__( 'Settings saved.', 'powerkit' ) );
    167409        }
    168410    }
     411
     412    /**
     413     * AJAX handler to refresh Kit.com forms
     414     */
     415    public function ajax_refresh_kit_forms() {
     416        // Check nonce.
     417        if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ) ) ) {
     418            wp_send_json_error( 'Invalid security token' );
     419        }
     420
     421        // Check for API key.
     422        if ( ! isset( $_POST['api_key'] ) || empty( $_POST['api_key'] ) ) {
     423            wp_send_json_error( 'API key is required' );
     424        }
     425
     426        $api_key = sanitize_text_field( wp_unslash( $_POST['api_key'] ) );
     427
     428        // Temporarily update the API key option.
     429        $original_key = get_option( 'powerkit_kit_token' );
     430        update_option( 'powerkit_kit_token', $api_key );
     431
     432        // Get forms using the helper function.
     433        $forms = function_exists( 'powerkit_kit_get_forms' ) ? powerkit_kit_get_forms() : array();
     434
     435        // Restore original key if this was just a test.
     436        if ( $api_key !== $original_key ) {
     437            update_option( 'powerkit_kit_token', $original_key );
     438        }
     439
     440        wp_send_json_success( $forms );
     441    }
     442
     443    /**
     444     * AJAX handler to refresh MailChimp lists
     445     */
     446    public function ajax_refresh_mailchimp_lists() {
     447        // Check nonce.
     448        if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ) ) ) {
     449            wp_send_json_error( 'Invalid security token' );
     450        }
     451
     452        // Check for API key.
     453        if ( ! isset( $_POST['api_key'] ) || empty( $_POST['api_key'] ) ) {
     454            wp_send_json_error( 'API key is required' );
     455        }
     456
     457        $api_key = sanitize_text_field( wp_unslash( $_POST['api_key'] ) );
     458
     459        // Temporarily update the API key option.
     460        $original_key = get_option( 'powerkit_mailchimp_token' );
     461        update_option( 'powerkit_mailchimp_token', $api_key );
     462
     463        // Get lists using the MailChimp API.
     464        $lists = array();
     465
     466        $data = powerkit_mailchimp_request(
     467            'GET', 'lists', array(
     468                'sort_field' => 'date_created',
     469                'sort_dir'   => 'DESC',
     470                'count'      => 1000,
     471            )
     472        );
     473
     474        if ( is_array( $data ) && isset( $data['lists'] ) && $data['lists'] ) {
     475            foreach ( $data['lists'] as $item ) {
     476                if ( isset( $item['id'] ) && isset( $item['name'] ) ) {
     477                    $lists[] = array(
     478                        'id'   => $item['id'],
     479                        'name' => $item['name'],
     480                    );
     481                }
     482            }
     483        } elseif ( is_array( $data ) && isset( $data['type'] ) && isset( $data['title'] ) ) {
     484            // API returned an error.
     485            $error_message = $data['type'] . ': ' . $data['title'];
     486            if ( isset( $data['detail'] ) ) {
     487                $error_message .= ' - ' . $data['detail'];
     488            }
     489            wp_send_json_error( $error_message );
     490        } else {
     491            wp_send_json_error( 'Unable to fetch MailChimp lists. Check your API key.' );
     492        }
     493
     494        // Restore original key if this was just a test.
     495        if ( $api_key !== $original_key ) {
     496            update_option( 'powerkit_mailchimp_token', $original_key );
     497        }
     498
     499        wp_send_json_success( $lists );
     500    }
     501
     502    /**
     503     * AJAX handler to refresh MailerLite groups
     504     */
     505    public function ajax_refresh_mailerlite_groups() {
     506        // Check nonce.
     507        if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ) ) ) {
     508            wp_send_json_error( 'Invalid security token' );
     509        }
     510
     511        // Check for API key.
     512        if ( ! isset( $_POST['api_key'] ) || empty( $_POST['api_key'] ) ) {
     513            wp_send_json_error( 'API key is required' );
     514        }
     515
     516        $api_key = sanitize_text_field( wp_unslash( $_POST['api_key'] ) );
     517
     518        // Temporarily update the API key option.
     519        $original_key = get_option( 'powerkit_mailerlite_token' );
     520        update_option( 'powerkit_mailerlite_token', $api_key );
     521
     522        // Get groups using the helper function.
     523        $groups = function_exists( 'powerkit_mailerlite_get_groups' ) ? powerkit_mailerlite_get_groups() : array();
     524
     525        // If the function is not available or no groups were found, try the direct API request.
     526        if ( empty( $groups ) ) {
     527            // Make API request to MailerLite.
     528            $response = wp_remote_get( 'https://api.mailerlite.com/api/v2/groups', array(
     529                'headers' => array(
     530                    'X-MailerLite-ApiKey' => $api_key,
     531                    'Content-Type'        => 'application/json',
     532                ),
     533            ) );
     534
     535            if ( ! is_wp_error( $response ) && 200 === wp_remote_retrieve_response_code( $response ) ) {
     536                $body = json_decode( wp_remote_retrieve_body( $response ), true );
     537
     538                if ( is_array( $body ) && ! empty( $body ) ) {
     539                    foreach ( $body as $item ) {
     540                        if ( isset( $item['id'] ) && isset( $item['name'] ) ) {
     541                            $groups[] = array(
     542                                'id'   => (string) $item['id'],
     543                                'name' => $item['name'],
     544                            );
     545                        }
     546                    }
     547                }
     548            } else {
     549                $error_message = 'Unable to fetch MailerLite groups. Check your API key.';
     550
     551                if ( is_wp_error( $response ) ) {
     552                    $error_message = $response->get_error_message();
     553                }
     554
     555                wp_send_json_error( $error_message );
     556            }
     557        }
     558
     559        // Restore original key if this was just a test.
     560        if ( $api_key !== $original_key ) {
     561            update_option( 'powerkit_mailerlite_token', $original_key );
     562        }
     563
     564        wp_send_json_success( $groups );
     565    }
    169566}
  • powerkit/trunk/modules/opt-in-forms/helpers/helper-powerkit-opt-in-forms.php

    r2578674 r3301156  
    1212function powerkit_mailchimp_get_privacy_text() {
    1313    return get_option( 'powerkit_mailchimp_privacy', esc_html__( 'By checking this box, you confirm that you have read and are agreeing to our terms of use regarding the storage of the data submitted through this form.', 'powerkit' ) );
     14}
     15
     16/**
     17 * Get selected subscription service
     18 */
     19function powerkit_get_subscription_service() {
     20    return get_option( 'powerkit_subscription_service', 'mailchimp' );
     21}
     22
     23/**
     24 * Parse custom hidden fields.
     25 */
     26function powerkit_parse_custom_fields() {
     27    $hidden_fields = get_option( 'powerkit_custom_hidden_fields', '' );
     28
     29    $fields = array();
     30
     31    if ( ! empty( $hidden_fields ) ) {
     32        $lines = explode( "\n", $hidden_fields );
     33
     34        foreach ( $lines as $line ) {
     35            $line = trim( $line );
     36            if ( empty( $line ) ) {
     37                continue;
     38            }
     39
     40            $parts = explode( '=', $line, 2 );
     41            if ( count( $parts ) === 2 ) {
     42                $fields[ trim( $parts[0] ) ] = trim( $parts[1] );
     43            }
     44        }
     45    }
     46
     47    return $fields;
    1448}
    1549
     
    88122    return $response;
    89123}
     124
     125/**
     126 * Get headers for MailFitKit request.
     127 */
     128function powerkit_kit_headers() {
     129    $token = get_option( 'powerkit_kit_token' );
     130
     131    $headers                  = array();
     132    $headers['Authorization'] = 'Bearer ' . $token;
     133    $headers['Accept']        = 'application/json';
     134    $headers['Content-Type']  = 'application/json';
     135
     136    return $headers;
     137}
     138
     139/**
     140 * Performs the underlying HTTP request for Kit.com API.
     141 *
     142 * @param string $http_verb The HTTP verb to use: get, post, put, patch, delete.
     143 * @param string $endpoint  The API endpoint to be called.
     144 * @param array  $data      Assoc array of parameters to be passed.
     145 */
     146function powerkit_kit_request( $http_verb = 'GET', $endpoint = 'forms', $data = array() ) {
     147    $token = get_option( 'powerkit_kit_token' );
     148
     149    if ( ! $token ) {
     150        return false;
     151    }
     152
     153    $url = 'https://api.convertkit.com/v3/' . ltrim( $endpoint, '/' );
     154
     155    if ( 'GET' === $http_verb ) {
     156        $url = add_query_arg( array( 'api_key' => $token ), $url );
     157    }
     158
     159    $args = array(
     160        'method'    => $http_verb,
     161        'headers'   => powerkit_kit_headers(),
     162        'timeout'   => 15,
     163        'sslverify' => true,
     164    );
     165
     166    if ( ! empty( $data ) ) {
     167        if ( in_array( $http_verb, array( 'GET', 'DELETE' ), true ) ) {
     168            $url = add_query_arg( $data, $url );
     169        } else {
     170            if ( ! isset( $data['api_key'] ) ) {
     171                $data['api_key'] = $token;
     172            }
     173            $args['body'] = wp_json_encode( $data );
     174        }
     175    }
     176
     177    // Perform request.
     178    $response = wp_remote_request( $url, $args );
     179
     180    // Process response.
     181    if ( ! is_wp_error( $response ) ) {
     182        $response = wp_remote_retrieve_body( $response );
     183
     184        $response = json_decode( $response, true );
     185    } else {
     186        powerkit_alert_warning( esc_html__( 'Unable to connect to Kit.com API.', 'powerkit' ) );
     187    }
     188
     189    return $response;
     190}
     191
     192/**
     193 * Get Kit.com Forms from API
     194 *
     195 * @return array List of forms with ID and name
     196 */
     197function powerkit_kit_get_forms() {
     198    $forms = array();
     199    $token = get_option( 'powerkit_kit_token' );
     200
     201    if ( ! $token ) {
     202        return $forms;
     203    }
     204
     205    $response = powerkit_kit_request( 'GET', 'forms', array() );
     206
     207    if ( isset( $response['forms'] ) && is_array( $response['forms'] ) ) {
     208        foreach ( $response['forms'] as $form ) {
     209            if ( isset( $form['id'] ) && isset( $form['name'] ) ) {
     210                $forms[] = array(
     211                    'id'   => $form['id'],
     212                    'name' => $form['name'],
     213                );
     214            }
     215        }
     216    }
     217
     218    return $forms;
     219}
     220
     221/**
     222 * Get headers for MailerLite request.
     223 */
     224function powerkit_mailerlite_headers() {
     225    $token = get_option( 'powerkit_mailerlite_token' );
     226
     227    $headers                        = array();
     228    $headers['X-MailerLite-ApiKey'] = $token;
     229    $headers['Accept']              = 'application/json';
     230    $headers['Content-Type']        = 'application/json';
     231
     232    return $headers;
     233}
     234
     235/**
     236 * Performs the underlying HTTP request for MailerLite API.
     237 *
     238 * @param string $http_verb The HTTP verb to use: get, post, put, patch, delete.
     239 * @param string $endpoint  The API endpoint to be called.
     240 * @param array  $data      Assoc array of parameters to be passed.
     241 */
     242function powerkit_mailerlite_request( $http_verb = 'GET', $endpoint = 'groups', $data = array() ) {
     243    $token = get_option( 'powerkit_mailerlite_token' );
     244
     245    if ( ! $token ) {
     246        return false;
     247    }
     248
     249    $url = 'https://api.mailerlite.com/api/v2/' . ltrim( $endpoint, '/' );
     250
     251    $args = array(
     252        'url'       => $url,
     253        'method'    => $http_verb,
     254        'headers'   => powerkit_mailerlite_headers(),
     255        'timeout'   => 10,
     256        'sslverify' => true,
     257    );
     258
     259    if ( ! empty( $data ) ) {
     260        if ( in_array( $http_verb, array( 'GET', 'DELETE' ), true ) ) {
     261            $url = add_query_arg( $data, $url );
     262        } else {
     263            $args['body'] = wp_json_encode( $data );
     264        }
     265    }
     266
     267    // Perform request.
     268    $response = wp_remote_request( $url, $args );
     269
     270    // Process response.
     271    if ( ! is_wp_error( $response ) ) {
     272        $response = wp_remote_retrieve_body( $response );
     273        $response = json_decode( $response, true );
     274    } else {
     275        powerkit_alert_warning( esc_html__( 'Unable to connect to MailerLite API.', 'powerkit' ) );
     276    }
     277
     278    return $response;
     279}
     280
     281/**
     282 * Get MailerLite Groups from API
     283 *
     284 * @return array List of groups with ID and name
     285 */
     286function powerkit_mailerlite_get_groups() {
     287    $groups = array();
     288    $token  = get_option( 'powerkit_mailerlite_token' );
     289
     290    if ( ! $token ) {
     291        return $groups;
     292    }
     293
     294    $response = powerkit_mailerlite_request( 'GET', 'groups', array() );
     295
     296    if ( is_array( $response ) && ! empty( $response ) ) {
     297        foreach ( $response as $group ) {
     298            if ( isset( $group['id'] ) && isset( $group['name'] ) ) {
     299                $groups[] = array(
     300                    'id'   => (string) $group['id'],
     301                    'name' => $group['name'],
     302                );
     303            }
     304        }
     305    }
     306
     307    return $groups;
     308}
  • powerkit/trunk/modules/opt-in-forms/public/block/render.php

    r2239653 r3301156  
    2525    'list_id'      => $attributes['listId'],
    2626    'display_name' => $attributes['showName'],
     27    'service'      => isset( $attributes['service'] ) ? $attributes['service'] : powerkit_get_subscription_service(),
    2728);
    2829
  • powerkit/trunk/modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php

    r2660830 r3301156  
    4343     */
    4444    public function register_subscription_form( $params = array() ) {
    45         $token = get_option( 'powerkit_mailchimp_token' );
     45
     46        $service = isset( $params['service'] ) ? $params['service'] : powerkit_get_subscription_service();
    4647
    4748        $class = sprintf( 'pk-subscribe-form-%s', $params['type'] );
     
    5051        $class .= $params['display_name'] ? ' pk-subscribe-with-name' : '';
    5152
     53        switch ( $service ) {
     54            case 'mailchimp':
     55                $this->render_mailchimp_form( $params, $class );
     56                break;
     57
     58            case 'kit':
     59                $this->render_kit_form( $params, $class );
     60                break;
     61
     62            case 'mailerlite':
     63                $this->render_mailerlite_form( $params, $class );
     64                break;
     65
     66            case 'custom':
     67                $this->render_custom_form( $params, $class );
     68                break;
     69
     70            default:
     71                $this->render_mailchimp_form( $params, $class );
     72        }
     73    }
     74
     75    /**
     76     * Subscription.
     77     *
     78     * @since    1.0.0
     79     */
     80    public function subscription() {
     81        powerkit_uuid_hash();
     82
     83        // Check wpnonce.
     84        if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'] ) ) { // Input var ok; sanitization ok.
     85            return;
     86        }
     87
     88        // Default service.
     89        $service = 'mailchimp';
     90
     91        if ( isset( $_REQUEST['service'] ) ) { // Input var ok.
     92            $service = sanitize_text_field( wp_unslash( $_REQUEST['service'] ) ); // Input var ok.
     93        }
     94
     95        if ( isset( $_REQUEST['list_id'] ) ) { // Input var ok.
     96            $list_id = sanitize_text_field( wp_unslash( $_REQUEST['list_id'] ) ); // Input var ok.
     97        }
     98
     99        if ( isset( $_REQUEST['USER'] ) ) { // Input var ok.
     100            $user = sanitize_text_field( wp_unslash( $_REQUEST['USER'] ) ); // Input var ok.
     101        }
     102
     103        if ( isset( $_REQUEST['EMAIL'] ) ) { // Input var ok.
     104            $email = sanitize_email( wp_unslash( $_REQUEST['EMAIL'] ) ); // Input var ok.
     105        }
     106
     107        if ( ! isset( $list_id ) || ! $list_id ) {
     108            wp_send_json_error( esc_html__( 'Something is wrong with your list ID.', 'powerkit' ) );
     109        }
     110
     111        if ( ! isset( $email ) || ! $email || ! filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
     112            wp_send_json_error( esc_html__( 'Email is invalid.', 'powerkit' ) );
     113        }
     114
     115        switch ( $service ) {
     116            case 'mailchimp':
     117                $this->process_mailchimp_subscription( $list_id, $email, $user );
     118                break;
     119
     120            case 'kit':
     121                $this->process_kit_subscription( $list_id, $email, $user );
     122                break;
     123
     124            case 'mailerlite':
     125                $this->process_mailerlite_subscription( $list_id, $email, $user );
     126                break;
     127
     128            default:
     129                $this->process_mailchimp_subscription( $list_id, $email, $user );
     130        }
     131    }
     132
     133    /**
     134     * Process MailChimp subscription
     135     *
     136     * @param string $list_id List ID.
     137     * @param string $email   Email address.
     138     * @param string $user    User name.
     139     */
     140    private function process_mailchimp_subscription( $list_id, $email, $user = null ) {
     141        $token = get_option( 'powerkit_mailchimp_token' );
     142
    52143        if ( $token ) {
    53 
     144            if ( get_option( 'powerkit_mailchimp_double_optin', false ) ) {
     145                $status = 'pending';
     146            } else {
     147                $status = 'subscribed';
     148            }
     149
     150            // Request parameters.
     151            $args = array(
     152                'email_address' => $email,
     153                'status'        => $status,
     154            );
     155
     156            // If display first name field.
     157            if ( isset( $user ) ) {
     158                $args['merge_fields'] = array(
     159                    'FNAME' => $user,
     160                );
     161            }
     162
     163            $result = powerkit_mailchimp_request( 'POST', "lists/$list_id/members", $args );
     164
     165            if ( isset( $result['status'] ) && 'subscribed' === $result['status'] ) {
     166
     167                wp_send_json_success( esc_html__( 'You have successfully subscribed.', 'powerkit' ) );
     168
     169            } elseif ( isset( $result['status'] ) && 'pending' === $result['status'] ) {
     170
     171                wp_send_json_success( esc_html__( 'You have successfully subscribed. Confirm the subscription in your mailbox.', 'powerkit' ) );
     172
     173            } elseif ( isset( $result['title'] ) && 'Member Exists' === $result['title'] ) {
     174
     175                wp_send_json_error( esc_html__( 'You are already subscribed.', 'powerkit' ) );
     176
     177            } else {
     178
     179                if ( isset( $result['status'] ) && isset( $result['detail'] ) && 400 <= $result['status'] ) {
     180                    $result = $result['detail'];
     181                }
     182
     183                wp_send_json_error( $result );
     184            }
     185        }
     186    }
     187
     188    /**
     189     * Process Kit.com subscription
     190     *
     191     * @param string $list_id List ID.
     192     * @param string $email   Email address.
     193     * @param string $user    User name.
     194     */
     195    private function process_kit_subscription( $list_id, $email, $user = null ) {
     196        $token = get_option( 'powerkit_kit_token' );
     197
     198        if ( $token ) {
     199            $args = array(
     200                'email' => $email,
     201            );
     202
     203            if ( isset( $user ) ) {
     204                $args['first_name'] = $user;
     205            }
     206
     207            $endpoint = 'forms/' . $list_id . '/subscribe';
     208
     209            $result = powerkit_kit_request( 'POST', $endpoint, $args );
     210
     211            if ( isset( $result['subscription'] ) ) {
     212                if ( isset( $result['subscription']['state'] ) ) {
     213                    if ( 'active' === $result['subscription']['state'] ) {
     214                        wp_send_json_success( esc_html__( 'You are already subscribed.', 'powerkit' ) );
     215                    } elseif ( 'inactive' === $result['subscription']['state'] ) {
     216                        wp_send_json_success( esc_html__( 'You are already subscribed, confirm your subscription by email.', 'powerkit' ) );
     217                    } elseif ( 'cancelled' === $result['subscription']['state'] ) {
     218                        wp_send_json_success( esc_html__( 'You have successfully subscribed, confirm your subscription by email.', 'powerkit' ) );
     219                    } else {
     220                        wp_send_json_success( esc_html__( 'You have successfully subscribed.', 'powerkit' ) );
     221                    }
     222                } else {
     223                    wp_send_json_success( esc_html__( 'You have successfully subscribed.', 'powerkit' ) );
     224                }
     225            } elseif ( isset( $result['error'] ) ) {
     226                    wp_send_json_error( (string) $result['error'] );
     227            } else {
     228                wp_send_json_error( esc_html__( 'An error occurred while subscribing.', 'powerkit' ) );
     229            }
     230        }
     231    }
     232
     233    /**
     234     * Process MailerLite subscription
     235     *
     236     * @param string $list_id List ID.
     237     * @param string $email   Email address.
     238     * @param string $user    User name.
     239     */
     240    private function process_mailerlite_subscription( $list_id, $email, $user = null ) {
     241        $token = get_option( 'powerkit_mailerlite_token' );
     242
     243        if ( $token ) {
     244            // Request parameters.
     245            $args = array(
     246                'email' => $email,
     247            );
     248
     249            // Add first name if available.
     250            if ( isset( $user ) ) {
     251                $args['name'] = $user;
     252            }
     253
     254            // Add to group.
     255            $result = powerkit_mailerlite_request( 'POST', "groups/{$list_id}/subscribers", $args );
     256
     257            if ( isset( $result['id'] ) ) {
     258                wp_send_json_success( esc_html__( 'You have successfully subscribed.', 'powerkit' ) );
     259            } elseif ( isset( $result['error'] ) && isset( $result['error']['code'] ) && 409 === $result['error']['code'] ) {
     260                wp_send_json_error( esc_html__( 'You are already subscribed.', 'powerkit' ) );
     261            } else {
     262                $error_message = isset( $result['error']['message'] ) ? $result['error']['message'] : esc_html__( 'An error occurred while subscribing.', 'powerkit' );
     263                wp_send_json_error( $error_message );
     264            }
     265        }
     266    }
     267
     268    /**
     269     * Register the stylesheets for the public-facing side of the site.
     270     */
     271    public function wp_enqueue_scripts() {
     272        // Styles.
     273        wp_enqueue_style( 'powerkit-opt-in-forms', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-opt-in-forms.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
     274
     275        // Add RTL support.
     276        wp_style_add_data( 'powerkit-opt-in-forms', 'rtl', 'replace' );
     277
     278        // Scripts.
     279        wp_enqueue_script( 'powerkit-opt-in-forms', plugin_dir_url( __FILE__ ) . 'js/public-powerkit-opt-in-forms.js', array( 'jquery' ), powerkit_get_setting( 'version' ), true );
     280
     281        wp_localize_script( 'powerkit-opt-in-forms', 'opt_in', array(
     282            'ajax_url'        => admin_url( 'admin-ajax.php' ),
     283            'warning_privacy' => esc_html__( 'Please confirm that you agree with our policies.', 'powerkit' ),
     284            'is_admin'        => current_user_can( 'edit_posts' ) || current_user_can( 'manage_options' ),
     285            'server_error'    => esc_html__( 'Server error occurred. Please try again later.', 'powerkit' ),
     286        ) );
     287    }
     288
     289    /**
     290     * Render MailChimp form
     291     *
     292     * @param array  $params     The params of form.
     293     * @param string $wrap_class Wrap class.
     294     */
     295    private function render_mailchimp_form( $params, $wrap_class ) {
     296        $token = get_option( 'powerkit_mailchimp_token' );
     297
     298        if ( $token ) {
    54299            if ( ! $params['list_id'] || 'default' === $params['list_id'] ) {
    55300                $params['list_id'] = get_option( 'powerkit_mailchimp_list' );
     
    58303            if ( $params['list_id'] ) {
    59304                ?>
    60                 <div class="pk-subscribe-form-wrap <?php echo esc_attr( $class ); ?>">
     305                <div class="pk-subscribe-form-wrap <?php echo esc_attr( $wrap_class ); ?>" data-service="mailchimp">
    61306                    <?php if ( $params['bg_image_id'] ) { ?>
    62307                        <div class="pk-subscribe-bg">
     
    82327
    83328                            <form method="post" class="subscription">
    84 
     329                                <input type="hidden" name="service" value="mailchimp">
    85330                                <input type="hidden" name="list_id" value="<?php echo esc_attr( $params['list_id'] ); ?>">
    86331
     
    118363
    119364    /**
    120      * Subscription.
    121      *
    122      * @since    1.0.0
    123      */
    124     public function subscription() {
    125         powerkit_uuid_hash();
    126 
    127         // Check wpnonce.
    128         if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'] ) ) { // Input var ok; sanitization ok.
    129             return;
    130         }
    131 
    132         if ( isset( $_REQUEST['list_id'] ) ) { // Input var ok.
    133             $list_id = sanitize_text_field( wp_unslash( $_REQUEST['list_id'] ) ); // Input var ok.
    134         }
    135 
    136         if ( isset( $_REQUEST['USER'] ) ) { // Input var ok.
    137             $user = sanitize_text_field( wp_unslash( $_REQUEST['USER'] ) ); // Input var ok.
    138         }
    139 
    140         if ( isset( $_REQUEST['EMAIL'] ) ) { // Input var ok.
    141             $email = sanitize_email( wp_unslash( $_REQUEST['EMAIL'] ) ); // Input var ok.
    142         }
    143 
    144         if ( ! isset( $list_id ) || ! $list_id ) {
    145             wp_send_json_error( esc_html__( 'Something is wrong with your list ID.', 'powerkit' ) );
    146         }
    147 
    148         if ( ! isset( $email ) || ! $email || ! filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
    149             wp_send_json_error( esc_html__( 'Email is invalid.', 'powerkit' ) );
    150         }
    151 
    152         $token = get_option( 'powerkit_mailchimp_token' );
     365     * Render Kit.com form
     366     *
     367     * @param array  $params     The params of form.
     368     * @param string $wrap_class Wrap class.
     369     */
     370    private function render_kit_form( $params, $wrap_class ) {
     371        $token = get_option( 'powerkit_kit_token' );
    153372
    154373        if ( $token ) {
    155 
    156             if ( get_option( 'powerkit_mailchimp_double_optin', false ) ) {
    157                 $status = 'pending';
    158             } else {
    159                 $status = 'subscribed';
    160             }
    161 
    162             // Request parameters.
    163             $args = array(
    164                 'email_address' => $email,
    165                 'status'        => $status,
    166             );
    167 
    168             // If display first name field.
    169             if ( isset( $user ) ) {
    170                 $args['merge_fields'] = array(
    171                     'FNAME' => $user,
    172                 );
    173             }
    174 
    175             $result = powerkit_mailchimp_request( 'POST', "lists/$list_id/members", $args );
    176 
    177             if ( isset( $result['status'] ) && 'subscribed' === $result['status'] ) {
    178 
    179                 wp_send_json_success( esc_html__( 'You have successfully subscribed.', 'powerkit' ) );
    180 
    181             } elseif ( isset( $result['status'] ) && 'pending' === $result['status'] ) {
    182 
    183                 wp_send_json_success( esc_html__( 'You have successfully subscribed. Confirm the subscription in your mailbox.', 'powerkit' ) );
    184 
    185             } elseif ( isset( $result['title'] ) && 'Member Exists' === $result['title'] ) {
    186 
    187                 wp_send_json_error( esc_html__( 'You are already subscribed.', 'powerkit' ) );
    188 
    189             } else {
    190 
    191                 if ( isset( $result['status'] ) && isset( $result['detail'] ) && 400 <= $result['status'] ) {
    192                     $result = $result['detail'];
    193                 }
    194 
    195                 wp_send_json_error( $result );
    196             }
    197         }
    198     }
    199 
    200     /**
    201      * Register the stylesheets for the public-facing side of the site.
    202      */
    203     public function wp_enqueue_scripts() {
    204         // Styles.
    205         wp_enqueue_style( 'powerkit-opt-in-forms', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-opt-in-forms.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
    206 
    207         // Add RTL support.
    208         wp_style_add_data( 'powerkit-opt-in-forms', 'rtl', 'replace' );
    209 
    210         // Scripts.
    211         wp_enqueue_script( 'powerkit-opt-in-forms', plugin_dir_url( __FILE__ ) . 'js/public-powerkit-opt-in-forms.js', array( 'jquery' ), powerkit_get_setting( 'version' ), true );
    212 
    213         wp_localize_script( 'powerkit-opt-in-forms', 'opt_in', array(
    214             'ajax_url'        => admin_url( 'admin-ajax.php' ),
    215             'warning_privacy' => esc_html__( 'Please confirm that you agree with our policies.', 'powerkit' ),
    216         ) );
     374            if ( ! $params['list_id'] || 'default' === $params['list_id'] ) {
     375                $params['list_id'] = get_option( 'powerkit_kit_form' );
     376            }
     377
     378            if ( $params['list_id'] ) {
     379                ?>
     380                <div class="pk-subscribe-form-wrap <?php echo esc_attr( $wrap_class ); ?>" data-service="kit">
     381                    <?php if ( $params['bg_image_id'] ) { ?>
     382                        <div class="pk-subscribe-bg">
     383                            <?php
     384                            echo wp_get_attachment_image( $params['bg_image_id'], apply_filters( 'powerkit_subscribe_image_size', 'large' ), false,
     385                                array( 'class' => 'pk-subscribe-image' )
     386                            );
     387                            ?>
     388                        </div>
     389                    <?php } ?>
     390
     391                    <div class="pk-subscribe-container <?php echo esc_attr( $params['bg_image_id'] ? ' pk-bg-overlay' : '' ); ?>">
     392                        <div class="pk-subscribe-data">
     393                            <?php
     394                            if ( $params['title'] ) {
     395                                echo wp_kses( $params['title'], 'pk-title' );
     396                            }
     397                            ?>
     398
     399                            <?php if ( $params['text'] ) { ?>
     400                                <p class="pk-subscribe-message <?php echo 'block' !== $params['type'] ? 'pk-font-heading' : ''; ?>"><?php echo esc_html( $params['text'] ); ?></p>
     401                            <?php } ?>
     402
     403                            <form method="post" class="subscription">
     404                                <input type="hidden" name="service" value="kit">
     405                                <input type="hidden" name="list_id" value="<?php echo esc_attr( $params['list_id'] ); ?>">
     406
     407                                <div class="pk-input-group">
     408                                    <?php if ( $params['display_name'] ) { ?>
     409                                        <input type="text" name="USER" class="user form-control" placeholder="<?php echo esc_attr( apply_filters( 'powerkit_subscribe_placeholder_name', esc_html__( 'Enter your name', 'powerkit' ) ) ); ?>">
     410                                    <?php } ?>
     411
     412                                    <input type="text" name="EMAIL" class="email form-control" placeholder="<?php echo esc_attr( apply_filters( 'powerkit_subscribe_placeholder_email', esc_html__( 'Enter your email', 'powerkit' ) ) ); ?>">
     413
     414                                    <button class="pk-subscribe-submit" type="submit"><?php echo wp_kses( apply_filters( 'powerkit_subscribe_submit', esc_html__( 'Subscribe', 'powerkit' ) ), 'post' ); ?></button>
     415                                </div>
     416
     417                                <?php wp_referer_field(); ?>
     418                            </form>
     419
     420                            <?php if ( $params['privacy'] ) { ?>
     421                                <div class="pk-privacy pk-color-secondary">
     422                                    <label><input name="pk-privacy" type="checkbox"><?php echo wp_kses( $params['privacy'], 'post' ); ?></label>
     423                                </div>
     424                            <?php } ?>
     425                        </div>
     426                    </div>
     427                </div>
     428                <?php
     429            } else {
     430                /* translators: Kit.com Settings. */
     431                powerkit_alert_warning( sprintf( __( 'Please select the Kit.com Form in <object><a href="%s" target="_blank">Opt-In Forms Settings</a></object>.', 'powerkit' ), esc_url( powerkit_get_page_url( 'opt_in_forms' ) ) ) );
     432            }
     433        } else {
     434            /* translators: Kit.com Settings. */
     435            powerkit_alert_warning( sprintf( __( 'Please add your Kit.com Token in <object><a href="%s" target="_blank">Opt-In Forms Settings</a></object>.', 'powerkit' ), esc_url( powerkit_get_page_url( 'opt_in_forms' ) ) ) );
     436        }
     437    }
     438
     439    /**
     440     * Render MailerLite form
     441     *
     442     * @param array  $params     The params of form.
     443     * @param string $wrap_class Wrap class.
     444     */
     445    private function render_mailerlite_form( $params, $wrap_class ) {
     446        $token = get_option( 'powerkit_mailerlite_token' );
     447
     448        if ( $token ) {
     449            if ( ! $params['list_id'] || 'default' === $params['list_id'] ) {
     450                $params['list_id'] = get_option( 'powerkit_mailerlite_group' );
     451            }
     452
     453            if ( $params['list_id'] ) {
     454                ?>
     455                <div class="pk-subscribe-form-wrap <?php echo esc_attr( $wrap_class ); ?>" data-service="mailerlite">
     456                    <?php if ( $params['bg_image_id'] ) { ?>
     457                        <div class="pk-subscribe-bg">
     458                            <?php
     459                            echo wp_get_attachment_image( $params['bg_image_id'], apply_filters( 'powerkit_subscribe_image_size', 'large' ), false,
     460                                array( 'class' => 'pk-subscribe-image' )
     461                            );
     462                            ?>
     463                        </div>
     464                    <?php } ?>
     465
     466                    <div class="pk-subscribe-container <?php echo esc_attr( $params['bg_image_id'] ? ' pk-bg-overlay' : '' ); ?>">
     467                        <div class="pk-subscribe-data">
     468                            <?php
     469                            if ( $params['title'] ) {
     470                                echo wp_kses( $params['title'], 'pk-title' );
     471                            }
     472                            ?>
     473
     474                            <?php if ( $params['text'] ) { ?>
     475                                <p class="pk-subscribe-message <?php echo 'block' !== $params['type'] ? 'pk-font-heading' : ''; ?>"><?php echo esc_html( $params['text'] ); ?></p>
     476                            <?php } ?>
     477
     478                            <form method="post" class="subscription">
     479                                <input type="hidden" name="service" value="mailerlite">
     480                                <input type="hidden" name="list_id" value="<?php echo esc_attr( $params['list_id'] ); ?>">
     481
     482                                <div class="pk-input-group">
     483                                    <?php if ( $params['display_name'] ) { ?>
     484                                        <input type="text" name="USER" class="user form-control" placeholder="<?php echo esc_attr( apply_filters( 'powerkit_subscribe_placeholder_name', esc_html__( 'Enter your name', 'powerkit' ) ) ); ?>">
     485                                    <?php } ?>
     486
     487                                    <input type="text" name="EMAIL" class="email form-control" placeholder="<?php echo esc_attr( apply_filters( 'powerkit_subscribe_placeholder_email', esc_html__( 'Enter your email', 'powerkit' ) ) ); ?>">
     488
     489                                    <button class="pk-subscribe-submit" type="submit"><?php echo wp_kses( apply_filters( 'powerkit_subscribe_submit', esc_html__( 'Subscribe', 'powerkit' ) ), 'post' ); ?></button>
     490                                </div>
     491
     492                                <?php wp_referer_field(); ?>
     493                            </form>
     494
     495                            <?php if ( $params['privacy'] ) { ?>
     496                                <div class="pk-privacy pk-color-secondary">
     497                                    <label><input name="pk-privacy" type="checkbox"><?php echo wp_kses( $params['privacy'], 'post' ); ?></label>
     498                                </div>
     499                            <?php } ?>
     500                        </div>
     501                    </div>
     502                </div>
     503                <?php
     504            } else {
     505                /* translators: MailerLite Settings. */
     506                powerkit_alert_warning( sprintf( __( 'Please select the MailerLite Group ID in <object><a href="%s" target="_blank">Opt-In Forms Settings</a></object>.', 'powerkit' ), esc_url( powerkit_get_page_url( 'opt_in_forms' ) ) ) );
     507            }
     508        } else {
     509            /* translators: MailerLite Settings. */
     510            powerkit_alert_warning( sprintf( __( 'Please add your MailerLite Token in <object><a href="%s" target="_blank">Opt-In Forms Settings</a></object>.', 'powerkit' ), esc_url( powerkit_get_page_url( 'opt_in_forms' ) ) ) );
     511        }
     512    }
     513
     514    /**
     515     * Render Custom form
     516     *
     517     * @param array  $params     The params of form.
     518     * @param string $wrap_class Wrap class.
     519     */
     520    private function render_custom_form( $params, $wrap_class ) {
     521        $form_action   = get_option( 'powerkit_custom_form_action' );
     522        $email_name    = get_option( 'powerkit_custom_email_name', 'email' );
     523        $name_field    = get_option( 'powerkit_custom_name_field', 'name' );
     524        $hidden_fields = powerkit_parse_custom_fields();
     525
     526        if ( $form_action ) {
     527            ?>
     528            <div class="pk-subscribe-form-wrap <?php echo esc_attr( $wrap_class ); ?>" data-service="custom">
     529                <?php if ( $params['bg_image_id'] ) { ?>
     530                    <div class="pk-subscribe-bg">
     531                        <?php
     532                        echo wp_get_attachment_image( $params['bg_image_id'], apply_filters( 'powerkit_subscribe_image_size', 'large' ), false,
     533                            array( 'class' => 'pk-subscribe-image' )
     534                        );
     535                        ?>
     536                    </div>
     537                <?php } ?>
     538
     539                <div class="pk-subscribe-container <?php echo esc_attr( $params['bg_image_id'] ? ' pk-bg-overlay' : '' ); ?>">
     540                    <div class="pk-subscribe-data">
     541                        <?php
     542                        if ( $params['title'] ) {
     543                            echo wp_kses( $params['title'], 'pk-title' );
     544                        }
     545                        ?>
     546
     547                        <?php if ( $params['text'] ) { ?>
     548                            <p class="pk-subscribe-message <?php echo 'block' !== $params['type'] ? 'pk-font-heading' : ''; ?>"><?php echo esc_html( $params['text'] ); ?></p>
     549                        <?php } ?>
     550
     551                        <form method="post" class="subscription" action="<?php echo esc_url( $form_action ); ?>" target="_blank">
     552                            <input type="hidden" name="service" value="custom">
     553
     554                            <?php if ( ! empty( $hidden_fields ) ) { ?>
     555                                <?php foreach ( $hidden_fields as $field_name => $field_value ) { ?>
     556                                    <input type="hidden" name="<?php echo esc_attr( $field_name ); ?>" value="<?php echo esc_attr( $field_value ); ?>">
     557                                <?php } ?>
     558                            <?php } ?>
     559
     560                            <div class="pk-input-group">
     561                                <?php if ( $params['display_name'] ) { ?>
     562                                    <input type="text" name="<?php echo esc_attr( $name_field ); ?>" class="user form-control" placeholder="<?php echo esc_attr( apply_filters( 'powerkit_subscribe_placeholder_name', esc_html__( 'Enter your name', 'powerkit' ) ) ); ?>">
     563                                <?php } ?>
     564
     565                                <input type="text" name="<?php echo esc_attr( $email_name ); ?>" class="email form-control" placeholder="<?php echo esc_attr( apply_filters( 'powerkit_subscribe_placeholder_email', esc_html__( 'Enter your email', 'powerkit' ) ) ); ?>">
     566
     567                                <button class="pk-subscribe-submit" type="submit"><?php echo wp_kses( apply_filters( 'powerkit_subscribe_submit', esc_html__( 'Subscribe', 'powerkit' ) ), 'post' ); ?></button>
     568                            </div>
     569                        </form>
     570
     571                        <?php if ( $params['privacy'] ) { ?>
     572                            <div class="pk-privacy pk-color-secondary">
     573                                <label><input name="pk-privacy" type="checkbox"><?php echo wp_kses( $params['privacy'], 'post' ); ?></label>
     574                            </div>
     575                        <?php } ?>
     576                    </div>
     577                </div>
     578            </div>
     579            <?php
     580        } else {
     581            /* translators: Custom Settings. */
     582            powerkit_alert_warning( sprintf( __( 'Please set a form action URL in <object><a href="%s" target="_blank">Opt-In Forms Settings</a></object>.', 'powerkit' ), esc_url( powerkit_get_page_url( 'opt_in_forms' ) ) ) );
     583        }
    217584    }
    218585}
  • powerkit/trunk/modules/opt-in-forms/public/class-powerkit-subscription-form-block.php

    r2290727 r3301156  
    5050            'description'  => '',
    5151            'category'     => 'canvas',
    52             'keywords'     => array( 'form', 'subscription', 'mailchimp' ),
     52            'keywords'     => array( 'form', 'subscription', 'mailchimp', 'kit', 'mailerlite', 'custom' ),
    5353            'icon'         => '
    5454                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
     
    7777            'fields'       => array(
    7878                array(
     79                    'key'     => 'service',
     80                    'label'   => esc_html__( 'Subscription Service', 'powerkit' ),
     81                    'section' => 'general',
     82                    'type'    => 'select',
     83                    'default' => powerkit_get_subscription_service(),
     84                    'choices' => array(
     85                        'mailchimp'  => esc_html__( 'MailChimp', 'powerkit' ),
     86                        'kit'        => esc_html__( 'Kit.com', 'powerkit' ),
     87                        'mailerlite' => esc_html__( 'MailerLite', 'powerkit' ),
     88                        'custom'     => esc_html__( 'Custom', 'powerkit' ),
     89                    ),
     90                ),
     91                array(
    7992                    'key'     => 'listId',
    80                     'label'   => esc_html__( 'List ID', 'powerkit' ),
    81                     'help'    => '
    82                         <em>' . esc_html__( 'If empty, List ID from Settings &rarr; Opt-In Forms will be used.', 'powerkit' ) . '</em>
    83                         <ol>
    84                             <li>' . esc_html__( 'Log in to your', 'powerkit' ) . ' <a href="https://mailchimp.com" target="_blank">' . esc_html__( 'MailChimp account', 'powerkit' ) . '</a></li>
    85                             <li>' . esc_html__( 'Go to your Lists.', 'powerkit' ) . '</li>
    86                             <li>' . esc_html__( 'Select the desired list and in the drop-down menu and go to Settings.', 'powerkit' ) . '</li>
    87                             <li>' . esc_html__( 'Copy your list ID from the field “Unique ID for list …”.', 'powerkit' ) . '</li>
    88                         </ol>
    89                     ',
     93                    'label'   => esc_html__( 'List/Form/Group ID', 'powerkit' ),
     94                    'help'    => esc_html__( 'If empty, the default ID from Settings → Opt-In Forms will be used.', 'powerkit' ),
    9095                    'section' => 'general',
    9196                    'type'    => 'text',
     
    95100                    'key'     => 'showName',
    96101                    'label'   => esc_html__( 'Display First Name Field', 'powerkit' ),
    97                     'help'    => esc_html__( 'Make sure you map the field in the MailChimp settings', 'powerkit' ),
     102                    'help'    => esc_html__( 'Make sure the name field is supported by your selected service', 'powerkit' ),
    98103                    'section' => 'general',
    99104                    'type'    => 'toggle',
    100105                    'default' => false,
    101106                ),
    102 
    103107                array(
    104108                    'key'     => 'colorLegend',
  • powerkit/trunk/modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php

    r3191370 r3301156  
    2727        'type'        => 'block',
    2828        'display_name' => false,
     29        'service'     => powerkit_get_subscription_service(),
    2930    ), $atts ) );
    3031
     
    7374                ),
    7475                array(
     76                    'type'    => 'select',
     77                    'name'    => 'service',
     78                    'label'   => esc_html__( 'Subscription Service', 'powerkit' ),
     79                    'default' => powerkit_get_subscription_service(),
     80                    'options' => array(
     81                        'mailchimp'  => esc_html__( 'MailChimp', 'powerkit' ),
     82                        'kit'        => esc_html__( 'Kit.com', 'powerkit' ),
     83                        'mailerlite' => esc_html__( 'MailerLite', 'powerkit' ),
     84                        'custom'     => esc_html__( 'Custom', 'powerkit' ),
     85                    ),
     86                ),
     87                array(
    7588                    'type'  => 'input',
    7689                    'name'  => 'list_id',
    77                     'label' => esc_html__( 'List ID', 'powerkit' ),
    78                     'desc'  => '1. ' . esc_html__( 'Log in to your', 'powerkit' ) . ' ' . sprintf( '<a href="%1$s" target="_blank">%2$s</a>', esc_url( 'https://mailchimp.com' ), esc_html__( 'MailChimp account', 'powerkit' ) )
    79                             . '<br>2. ' . esc_html__( 'Go to your Lists.', 'powerkit' )
    80                             . '<br>3. ' . esc_html__( 'Select the desired list and in the drop-down menu and go to Settings.', 'powerkit' )
    81                             . '<br>4. ' . esc_html__( 'Copy your list ID from the field “Unique ID for list …”.', 'powerkit' ),
     90                    'label' => esc_html__( 'List/Form/Group ID', 'powerkit' ),
     91                    'desc'  => esc_html__( 'If empty, the default ID from Settings → Opt-In Forms will be used.', 'powerkit' ),
    8292                ),
    8393                array(
     
    8595                    'name'    => 'display_name',
    8696                    'label'   => esc_html__( 'Display first name field', 'powerkit' ),
    87                     'desc'    => esc_html__( 'Make sure you map the field in the MailChimp settings', 'powerkit' ),
     97                    'desc'    => esc_html__( 'Make sure the name field is supported by your selected service', 'powerkit' ),
    8898                    'default' => false,
    8999                ),
  • powerkit/trunk/modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php

    r2953867 r3301156  
    3535            'type'         => 'widget',
    3636            'display_name' => false,
     37            'service'      => powerkit_get_subscription_service(),
    3738        ) );
    3839
     
    134135            <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>" type="text" value="<?php echo esc_attr( $params['text'] ); ?>" /></p>
    135136
    136             <!-- List -->
    137             <?php
    138             $token = get_option( 'powerkit_mailchimp_token' );
    139 
    140             if ( $token ) {
    141 
    142                 $data = powerkit_mailchimp_request( 'GET', 'lists', array(
    143                     'sort_field' => 'date_created',
    144                     'sort_dir'   => 'DESC',
    145                     'count'      => 1000,
    146                 ) );
    147 
    148                 if ( is_array( $data ) && isset( $data['lists'] ) && $data['lists'] ) {
    149                 ?>
    150 
    151                     <p><label for="<?php echo esc_attr( $this->get_field_id( 'list_id' ) ); ?>"><?php esc_html_e( 'List:', 'powerkit' ); ?></label>
    152                         <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'list_id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_name( 'list_id' ) ); ?>">
    153                             <option value="default"><?php esc_html_e( 'Default', 'powerkit' ); ?></option>
    154                             <?php foreach ( $data['lists'] as $item ) : ?>
    155                                 <option <?php selected( $item['id'], $params['list_id'] ); ?> value="<?php echo esc_attr( $item['id'] ); ?>"><?php echo esc_html( $item['name'] ); ?></option>
    156                             <?php endforeach; ?>
    157                         </select>
    158                     </p>
    159                 <?php
    160                 }
    161             }
    162             ?>
     137            <!-- Subscription Service -->
     138            <p>
     139                <label for="<?php echo esc_attr( $this->get_field_id( 'service' ) ); ?>"><?php esc_html_e( 'Subscription Service:', 'powerkit' ); ?></label>
     140                <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'service' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'service' ) ); ?>">
     141                    <option value="mailchimp" <?php selected( 'mailchimp', $params['service'] ); ?>><?php esc_html_e( 'MailChimp', 'powerkit' ); ?></option>
     142                    <option value="kit" <?php selected( 'kit', $params['service'] ); ?>><?php esc_html_e( 'Kit.com', 'powerkit' ); ?></option>
     143                    <option value="mailerlite" <?php selected( 'mailerlite', $params['service'] ); ?>><?php esc_html_e( 'MailerLite', 'powerkit' ); ?></option>
     144                    <option value="custom" <?php selected( 'custom', $params['service'] ); ?>><?php esc_html_e( 'Custom', 'powerkit' ); ?></option>
     145                </select>
     146            </p>
     147
     148            <!-- List/Form/Group ID field for all services -->
     149            <p>
     150                <label for="<?php echo esc_attr( $this->get_field_id( 'list_id' ) ); ?>"><?php esc_html_e( 'List/Form/Group ID:', 'powerkit' ); ?></label>
     151                <input class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'list_id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'list_id' ) ); ?>" type="text" value="<?php echo esc_attr( $params['list_id'] ); ?>" placeholder="<?php esc_attr_e( 'Default', 'powerkit' ); ?>">
     152                <span class="description"><?php esc_html_e( 'If empty, the default ID from Settings → Opt-In Forms will be used.', 'powerkit' ); ?></span>
     153            </p>
    163154
    164155            <!-- Display first name field -->
    165156            <p><input id="<?php echo esc_attr( $this->get_field_id( 'display_name' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'display_name' ) ); ?>" type="checkbox" <?php checked( (bool) $params['display_name'] ); ?> />
    166157            <label for="<?php echo esc_attr( $this->get_field_id( 'display_name' ) ); ?>"><?php esc_html_e( 'Display first name field', 'powerkit' ); ?></label>
    167             <span class="howto">(<?php esc_html_e( 'Make sure you map the field in the MailChimp settings', 'powerkit' ); ?>)</span></p>
     158            <span class="howto">(<?php esc_html_e( 'Make sure the name field is supported by your selected service', 'powerkit' ); ?>)</span></p>
    168159        <?php
    169160    }
  • powerkit/trunk/modules/opt-in-forms/public/js/public-powerkit-opt-in-forms.js

    r2239653 r3301156  
    99
    1010        var form = $( this );
     11        var formWrap = $( form ).closest('.pk-subscribe-form-wrap');
     12        var service = formWrap.data('service') || 'mailchimp';
     13
     14        // If form is custom, let the native form submission happen
     15        if (service === 'custom') {
     16            // Check privacy first
     17            var privacy = $( formWrap ).find( 'input[name="pk-privacy"]' );
     18
     19            if ( $( privacy ).length > 0 && ! $( privacy ).prop( 'checked' ) ) {
     20                e.preventDefault();
     21                $( privacy ).parent().after( '<p class="pk-alert pk-alert-warning">' + window.opt_in.warning_privacy + '</p>' );
     22                return false;
     23            }
     24
     25            // Continue with the native form submission
     26            return true;
     27        }
    1128
    1229        // Remove messages.
    13         $( form ).closest('.pk-subscribe-form-wrap').find( '.pk-alert' ).remove();
     30        $( formWrap ).find( '.pk-alert' ).remove();
    1431
    1532        // Policies.
    16         var privacy = $( form ).closest( '.pk-subscribe-form-wrap' ).find( 'input[name="pk-privacy"]' );
     33        var privacy = $( formWrap ).find( 'input[name="pk-privacy"]' );
    1734
    1835        if ( $( privacy ).length > 0 && ! $( privacy ).prop( 'checked' ) ) {
  • powerkit/trunk/powerkit.php

    r3290389 r3301156  
    33 * Plugin Name:       Powerkit
    44 * Description:       Powerkit – essential components for every WordPress site.
    5  * Version:           2.9.8
     5 * Version:           3.0.0
    66 * Author:            Code Supply Co.
    77 * Author URI:        https://codesupply.co
Note: See TracChangeset for help on using the changeset viewer.