Changeset 3301156
- Timestamp:
- 05/27/2025 05:33:55 AM (10 months ago)
- Location:
- powerkit/trunk
- Files:
-
- 2 added
- 11 edited
-
README.txt (modified) (2 diffs)
-
languages/powerkit.pot (modified) (11 diffs)
-
modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php (modified) (5 diffs)
-
modules/opt-in-forms/admin/js (added)
-
modules/opt-in-forms/admin/js/admin-powerkit-opt-in-forms.js (added)
-
modules/opt-in-forms/helpers/helper-powerkit-opt-in-forms.php (modified) (2 diffs)
-
modules/opt-in-forms/public/block/render.php (modified) (1 diff)
-
modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php (modified) (5 diffs)
-
modules/opt-in-forms/public/class-powerkit-subscription-form-block.php (modified) (3 diffs)
-
modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php (modified) (3 diffs)
-
modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php (modified) (2 diffs)
-
modules/opt-in-forms/public/js/public-powerkit-opt-in-forms.js (modified) (1 diff)
-
powerkit.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
powerkit/trunk/README.txt
r3290389 r3301156 4 4 Tested up to: 6.8 5 5 Requires PHP: 5.4 6 Stable tag: 2.9.86 Stable tag: 3.0.0 7 7 Contributors: codesupplyco 8 8 License: GPLv2 or later … … 83 83 84 84 == 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 85 94 86 95 = 2.9.8 = -
powerkit/trunk/languages/powerkit.pot
r3252063 r3301156 173 173 msgstr "" 174 174 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:15 3, modules/social-links/public/class-powerkit-social-links-block.php:80175 #: 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 176 176 msgid "Default" 177 177 msgstr "" … … 421 421 msgstr "" 422 422 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:240423 #: 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 424 424 msgid "Settings saved." 425 425 msgstr "" … … 429 429 msgstr "" 430 430 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:41431 #: 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 432 432 msgid "You do not have sufficient rights to view this page." 433 433 msgstr "" … … 437 437 msgstr "" 438 438 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:107439 #: 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 440 440 msgid "Save changes" 441 441 msgstr "" … … 689 689 msgstr "" 690 690 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:10 8, 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:106691 #: 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 692 692 msgid "Title:" 693 693 msgstr "" … … 701 701 msgstr "" 702 702 703 #: modules/author-box/public/class-powerkit-author-box-widget.php:216, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:11 2703 #: modules/author-box/public/class-powerkit-author-box-widget.php:216, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:113 704 704 msgid "Select or upload background image" 705 705 msgstr "" 706 706 707 #: modules/author-box/public/class-powerkit-author-box-widget.php:216, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:11 2707 #: modules/author-box/public/class-powerkit-author-box-widget.php:216, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:113 708 708 msgid "Set background image" 709 709 msgstr "" 710 710 711 #: modules/author-box/public/class-powerkit-author-box-widget.php:218, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:11 4711 #: modules/author-box/public/class-powerkit-author-box-widget.php:218, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:115 712 712 msgid "Background image:" 713 713 msgstr "" 714 714 715 #: modules/author-box/public/class-powerkit-author-box-widget.php:231, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:12 7, modules/post-format-ui/admin/class-powerkit-post-format-ui-admin.php:167715 #: 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 716 716 msgid "Add Image" 717 717 msgstr "" 718 718 719 #: modules/author-box/public/class-powerkit-author-box-widget.php:232, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:12 8719 #: modules/author-box/public/class-powerkit-author-box-widget.php:232, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:129 720 720 msgid "Remove Image" 721 721 msgstr "" … … 845 845 msgstr "" 846 846 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:6 2, 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:55847 #: 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 848 848 msgid "Title" 849 849 msgstr "" … … 970 970 msgstr "" 971 971 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:87972 #: modules/coming-soon/admin/class-powerkit-coming-soon-admin.php:149, modules/typekit-fonts/admin/class-powerkit-typekit-fonts-admin.php:87 973 973 msgid "- not selected -" 974 974 msgstr "" … … 1634 1634 msgstr "" 1635 1635 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:481636 #: 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 1637 1637 msgid "Opt-in Forms" 1638 1638 msgstr "" 1639 1639 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 1641 msgid "Subscription Service" 1642 msgstr "" 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 1641 1645 msgid "MailChimp" 1642 1646 msgstr "" 1643 1647 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 1649 msgid "Kit.com" 1650 msgstr "" 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 1653 msgid "MailerLite" 1654 msgstr "" 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 1657 msgid "Custom" 1658 msgstr "" 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 1645 1661 msgid "API Key" 1646 1662 msgstr "" 1647 1663 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 1665 msgid "Refresh Lists" 1666 msgstr "" 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 1649 1669 msgid "Log in to your" 1650 1670 msgstr "" 1651 1671 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:781672 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:123 1653 1673 msgid "MailChimp account" 1654 1674 msgstr "" 1655 1675 1656 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php: 651676 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:124 1657 1677 msgid "Click your profile name to expand the Account Panel, and choose Account." 1658 1678 msgstr "" 1659 1679 1660 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php: 661680 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:125 1661 1681 msgid "Click the Extras drop-down menu and choose API keys." 1662 1682 msgstr "" 1663 1683 1664 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php: 671684 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:126 1665 1685 msgid "Copy an existing API key or click the Create A Key button." 1666 1686 msgstr "" 1667 1687 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 1689 msgid "Click \"Refresh Lists\" button after entering your API key to load your audiences." 1690 msgstr "" 1691 1692 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:133 1677 1693 msgid "Default Audience" 1678 1694 msgstr "" 1679 1695 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 1697 msgid "— Select an Audience —" 1698 msgstr "" 1699 1700 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:168 1681 1701 msgid "Enable Double opt-in" 1682 1702 msgstr "" 1683 1703 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 1705 msgid "Refresh Forms" 1706 msgstr "" 1707 1708 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:192 1709 msgid "Kit.com account" 1710 msgstr "" 1711 1712 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:193 1713 msgid "Click on your profile icon and go to Settings." 1714 msgstr "" 1715 1716 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:194 1717 msgid "Navigate to the Developer section." 1718 msgstr "" 1719 1720 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:195 1721 msgid "Copy the V3 Public API Key." 1722 msgstr "" 1723 1724 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:200 1725 msgid "Default Form" 1726 msgstr "" 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 1729 msgid "— Select a Form —" 1730 msgstr "" 1731 1732 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:220 1733 msgid "Select a form from your Kit.com account. If you don't see your forms, click \"Refresh Forms\" after entering your API key." 1734 msgstr "" 1735 1736 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:239 1737 msgid "Refresh Groups" 1738 msgstr "" 1739 1740 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:246 1741 msgid "MailerLite account" 1742 msgstr "" 1743 1744 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:247 1745 msgid "Go to Integrations → API from the main menu." 1746 msgstr "" 1747 1748 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:248 1749 msgid "Copy your API key or generate a new one if needed." 1750 msgstr "" 1751 1752 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:249 1753 msgid "Click \"Refresh Groups\" button after entering your API key to load your groups." 1754 msgstr "" 1755 1756 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:255 1757 msgid "Default Group" 1758 msgstr "" 1759 1760 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:276 1761 msgid "Select a group from your MailerLite account. If you don't see your groups, click \"Refresh Groups\" after entering your API key." 1762 msgstr "" 1763 1764 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:285 1765 msgid "Custom Form" 1766 msgstr "" 1767 1768 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:291 1769 msgid "Form Action URL" 1770 msgstr "" 1771 1772 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:296 1773 msgid "Email Field Name" 1774 msgstr "" 1775 1776 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:301 1777 msgid "Name Field Name" 1778 msgstr "" 1779 1780 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:306 1781 msgid "Hidden Fields" 1782 msgstr "" 1783 1784 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:309 1785 msgid "Enter hidden fields in format: field_name=value (one per line)" 1786 msgstr "" 1787 1788 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:317 1789 msgid "Common Settings" 1790 msgstr "" 1791 1792 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:325 1685 1793 msgid "Data Privacy Checkbox Label" 1686 1794 msgstr "" 1687 1795 1688 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php: 1221796 #: modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php:326 1689 1797 msgid "Enter the contents that should display as a label for the data privacy checkbox. Leave blank to disable." 1690 1798 msgstr "" … … 1694 1802 msgstr "" 1695 1803 1696 #: modules/opt-in-forms/helpers/helper-powerkit-opt-in-forms.php: 851804 #: modules/opt-in-forms/helpers/helper-powerkit-opt-in-forms.php:119 1697 1805 msgid "This client has not been approved to access this resource." 1698 1806 msgstr "" 1699 1807 1808 #: modules/opt-in-forms/helpers/helper-powerkit-opt-in-forms.php:186 1809 msgid "Unable to connect to Kit.com API." 1810 msgstr "" 1811 1812 #: modules/opt-in-forms/helpers/helper-powerkit-opt-in-forms.php:275 1813 msgid "Unable to connect to MailerLite API." 1814 msgstr "" 1815 1816 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:108 1817 msgid "Something is wrong with your list ID." 1818 msgstr "" 1819 1820 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:112 1821 msgid "Email is invalid." 1822 msgstr "" 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 1825 msgid "You are already subscribed." 1826 msgstr "" 1827 1828 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:171 1829 msgid "You have successfully subscribed. Confirm the subscription in your mailbox." 1830 msgstr "" 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 1833 msgid "You have successfully subscribed." 1834 msgstr "" 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 1837 msgid "An error occurred while subscribing." 1838 msgstr "" 1839 1840 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:218 1841 msgid "You have successfully subscribed, confirm your subscription by email." 1842 msgstr "" 1843 1844 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:216 1845 msgid "You are already subscribed, confirm your subscription by email." 1846 msgstr "" 1847 1848 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:283 1849 msgid "Please confirm that you agree with our policies." 1850 msgstr "" 1851 1852 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:285 1853 msgid "Server error occurred. Please try again later." 1854 msgstr "" 1855 1700 1856 #. translators: MailChimp Settings. 1701 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php: 1151857 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:360 1702 1858 msgid "Please add your MailChimp Token in <object><a href=\"%s\" target=\"_blank\">Opt-In Forms Settings</a></object>." 1703 1859 msgstr "" 1704 1860 1705 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php: 1111861 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:356 1706 1862 msgid "Please select the \"List\" for your subscription form in <object><a href=\"%s\" target=\"_blank\">Opt-In Forms Settings</a></object>." 1707 1863 msgstr "" 1708 1864 1709 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php: 891865 #: 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 1710 1866 msgid "Enter your name" 1711 1867 msgstr "" 1712 1868 1713 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php: 921869 #: 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 1714 1870 msgid "Enter your email" 1715 1871 msgstr "" 1716 1872 1717 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php: 941873 #: 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 1718 1874 msgid "Subscribe" 1719 1875 msgstr "" 1720 1876 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 1879 msgid "Please add your Kit.com Token in <object><a href=\"%s\" target=\"_blank\">Opt-In Forms Settings</a></object>." 1880 msgstr "" 1881 1882 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:431 1883 msgid "Please select the Kit.com Form in <object><a href=\"%s\" target=\"_blank\">Opt-In Forms Settings</a></object>." 1884 msgstr "" 1885 1886 #. translators: MailerLite Settings. 1887 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:510 1888 msgid "Please add your MailerLite Token in <object><a href=\"%s\" target=\"_blank\">Opt-In Forms Settings</a></object>." 1889 msgstr "" 1890 1891 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:506 1892 msgid "Please select the MailerLite Group ID in <object><a href=\"%s\" target=\"_blank\">Opt-In Forms Settings</a></object>." 1893 msgstr "" 1894 1895 #. translators: Custom Settings. 1896 #: modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php:582 1897 msgid "Please set a form action URL in <object><a href=\"%s\" target=\"_blank\">Opt-In Forms Settings</a></object>." 1743 1898 msgstr "" 1744 1899 … … 1747 1902 msgstr "" 1748 1903 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 → 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 1905 msgid "List/Form/Group ID" 1906 msgstr "" 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 1909 msgid "If empty, the default ID from Settings → Opt-In Forms will be used." 1910 msgstr "" 1911 1912 #: modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:101 1770 1913 msgid "Display First Name Field" 1771 1914 msgstr "" 1772 1915 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:1671774 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:10 51916 #: 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 1917 msgid "Make sure the name field is supported by your selected service" 1918 msgstr "" 1919 1920 #: modules/opt-in-forms/public/class-powerkit-subscription-form-block.php:109 1778 1921 msgid "Color Legend" 1779 1922 msgstr "" 1780 1923 1781 #: modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:5 4, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:30, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:471924 #: 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 1782 1925 msgid "Subscription Form" 1783 1926 msgstr "" 1784 1927 1785 #: modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:6 71928 #: modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:68 1786 1929 msgid "Background image ID" 1787 1930 msgstr "" 1788 1931 1789 #: modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:7 21932 #: modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:73 1790 1933 msgid "Message" 1791 1934 msgstr "" 1792 1935 1793 #: modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php: 86, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:1661936 #: modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php:96, modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:157 1794 1937 msgid "Display first name field" 1795 1938 msgstr "" 1796 1939 1797 #: modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:4 11940 #: modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:42 1798 1941 msgid "Add a subscription form to your sidebar." 1799 1942 msgstr "" 1800 1943 1801 #: modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:13 31944 #: modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:134 1802 1945 msgid "Subscribe message:" 1803 1946 msgstr "" 1804 1947 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 1949 msgid "Subscription Service:" 1950 msgstr "" 1951 1952 #: modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php:150 1953 msgid "List/Form/Group ID:" 1807 1954 msgstr "" 1808 1955 -
powerkit/trunk/modules/opt-in-forms/admin/class-powerkit-opt-in-forms-admin.php
r2320052 r3301156 20 20 public function initialize() { 21 21 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 ); 22 55 } 23 56 … … 43 76 44 77 $this->save_options_page(); 78 79 // Get selected service. 80 $selected_service = get_option( 'powerkit_subscription_service', 'mailchimp' ); 45 81 ?> 46 82 … … 50 86 <div class="pk-settings"> 51 87 <form method="post"> 52 <h3><?php esc_html_e( 'MailChimp', 'powerkit' ); ?></h3> 53 88 89 <!-- Service Selection --> 54 90 <table class="form-table"> 55 91 <tbody> 56 <!-- API Key -->57 92 <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> 70 101 </td> 71 102 </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> 117 321 <!-- Data Privacy Checkbox Label --> 118 322 <tr> … … 149 353 150 354 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. 152 361 if ( isset( $_POST['powerkit_mailchimp_token'] ) ) { // Input var ok. 153 362 update_option( 'powerkit_mailchimp_token', sanitize_text_field( wp_unslash( $_POST['powerkit_mailchimp_token'] ) ) ); // Input var ok. 154 363 } 155 364 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. 157 366 } 158 367 if ( isset( $_POST['powerkit_mailchimp_double_optin'] ) ) { // Input var ok. … … 161 370 update_option( 'powerkit_mailchimp_double_optin', false ); 162 371 } 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. 163 404 if ( isset( $_POST['powerkit_mailchimp_privacy'] ) ) { // Input var ok. 164 405 update_option( 'powerkit_mailchimp_privacy', wp_kses( wp_unslash( $_POST['powerkit_mailchimp_privacy'] ), 'post' ) ); // Input var ok. sanitization ok. 165 406 } 407 166 408 printf( '<div id="message" class="updated fade"><p><strong>%s</strong></p></div>', esc_html__( 'Settings saved.', 'powerkit' ) ); 167 409 } 168 410 } 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 } 169 566 } -
powerkit/trunk/modules/opt-in-forms/helpers/helper-powerkit-opt-in-forms.php
r2578674 r3301156 12 12 function powerkit_mailchimp_get_privacy_text() { 13 13 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 */ 19 function powerkit_get_subscription_service() { 20 return get_option( 'powerkit_subscription_service', 'mailchimp' ); 21 } 22 23 /** 24 * Parse custom hidden fields. 25 */ 26 function 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; 14 48 } 15 49 … … 88 122 return $response; 89 123 } 124 125 /** 126 * Get headers for MailFitKit request. 127 */ 128 function 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 */ 146 function 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 */ 197 function 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 */ 224 function 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 */ 242 function 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 */ 286 function 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 25 25 'list_id' => $attributes['listId'], 26 26 'display_name' => $attributes['showName'], 27 'service' => isset( $attributes['service'] ) ? $attributes['service'] : powerkit_get_subscription_service(), 27 28 ); 28 29 -
powerkit/trunk/modules/opt-in-forms/public/class-powerkit-opt-in-forms-public.php
r2660830 r3301156 43 43 */ 44 44 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(); 46 47 47 48 $class = sprintf( 'pk-subscribe-form-%s', $params['type'] ); … … 50 51 $class .= $params['display_name'] ? ' pk-subscribe-with-name' : ''; 51 52 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 52 143 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 ) { 54 299 if ( ! $params['list_id'] || 'default' === $params['list_id'] ) { 55 300 $params['list_id'] = get_option( 'powerkit_mailchimp_list' ); … … 58 303 if ( $params['list_id'] ) { 59 304 ?> 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"> 61 306 <?php if ( $params['bg_image_id'] ) { ?> 62 307 <div class="pk-subscribe-bg"> … … 82 327 83 328 <form method="post" class="subscription"> 84 329 <input type="hidden" name="service" value="mailchimp"> 85 330 <input type="hidden" name="list_id" value="<?php echo esc_attr( $params['list_id'] ); ?>"> 86 331 … … 118 363 119 364 /** 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' ); 153 372 154 373 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 } 217 584 } 218 585 } -
powerkit/trunk/modules/opt-in-forms/public/class-powerkit-subscription-form-block.php
r2290727 r3301156 50 50 'description' => '', 51 51 'category' => 'canvas', 52 'keywords' => array( 'form', 'subscription', 'mailchimp' ),52 'keywords' => array( 'form', 'subscription', 'mailchimp', 'kit', 'mailerlite', 'custom' ), 53 53 'icon' => ' 54 54 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"> … … 77 77 'fields' => array( 78 78 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( 79 92 'key' => 'listId', 80 'label' => esc_html__( 'List ID', 'powerkit' ), 81 'help' => ' 82 <em>' . esc_html__( 'If empty, List ID from Settings → 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' ), 90 95 'section' => 'general', 91 96 'type' => 'text', … … 95 100 'key' => 'showName', 96 101 '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' ), 98 103 'section' => 'general', 99 104 'type' => 'toggle', 100 105 'default' => false, 101 106 ), 102 103 107 array( 104 108 'key' => 'colorLegend', -
powerkit/trunk/modules/opt-in-forms/public/class-powerkit-subscription-form-shortcode.php
r3191370 r3301156 27 27 'type' => 'block', 28 28 'display_name' => false, 29 'service' => powerkit_get_subscription_service(), 29 30 ), $atts ) ); 30 31 … … 73 74 ), 74 75 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( 75 88 'type' => 'input', 76 89 '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' ), 82 92 ), 83 93 array( … … 85 95 'name' => 'display_name', 86 96 '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' ), 88 98 'default' => false, 89 99 ), -
powerkit/trunk/modules/opt-in-forms/public/class-powerkit-subscription-form-widget.php
r2953867 r3301156 35 35 'type' => 'widget', 36 36 'display_name' => false, 37 'service' => powerkit_get_subscription_service(), 37 38 ) ); 38 39 … … 134 135 <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> 135 136 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> 163 154 164 155 <!-- Display first name field --> 165 156 <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'] ); ?> /> 166 157 <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> 168 159 <?php 169 160 } -
powerkit/trunk/modules/opt-in-forms/public/js/public-powerkit-opt-in-forms.js
r2239653 r3301156 9 9 10 10 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 } 11 28 12 29 // Remove messages. 13 $( form ).closest('.pk-subscribe-form-wrap').find( '.pk-alert' ).remove();30 $( formWrap ).find( '.pk-alert' ).remove(); 14 31 15 32 // Policies. 16 var privacy = $( form ).closest( '.pk-subscribe-form-wrap').find( 'input[name="pk-privacy"]' );33 var privacy = $( formWrap ).find( 'input[name="pk-privacy"]' ); 17 34 18 35 if ( $( privacy ).length > 0 && ! $( privacy ).prop( 'checked' ) ) { -
powerkit/trunk/powerkit.php
r3290389 r3301156 3 3 * Plugin Name: Powerkit 4 4 * Description: Powerkit – essential components for every WordPress site. 5 * Version: 2.9.85 * Version: 3.0.0 6 6 * Author: Code Supply Co. 7 7 * Author URI: https://codesupply.co
Note: See TracChangeset
for help on using the changeset viewer.