Skip to content

Commit e870fb3

Browse files
committed
Initial Commit
0 parents  commit e870fb3

37 files changed

+8436
-0
lines changed

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
*.DS_Store
2+
.AppleDouble
3+
.LSOverride
4+
5+
# Icon must end with two \r
6+
Icon
7+
8+
9+
# Thumbnails
10+
._*
11+
12+
# Files that might appear in the root of a volume
13+
.DocumentRevisions-V100
14+
.fseventsd
15+
.Spotlight-V100
16+
.TemporaryItems
17+
.Trashes
18+
.VolumeIcon.icns
19+
.com.apple.timemachine.donotpresent
20+
21+
# Directories potentially created on remote AFP share
22+
.AppleDB
23+
.AppleDesktop
24+
Network Trash Folder
25+
Temporary Items
26+
.apdisk

LICENSE.txt

Lines changed: 339 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Gro CRM Contact to Leads plugin for WordPress
2+
3+
The Mac CRM sales platform designed for iOS and the Apple Small Business market. Use our [Gro CRM](https://www.grocrm.com) Contact-to-Leads WordPress Plug-in for your website.
4+
5+
Description
6+
-------
7+
Convert Wordpress forms into leads. Gro CRM creates an easy integration between your WordPress install(s) and your
8+
Gro CRM account! People can enter a their contact info on your site, and the lead information goes straight into Gro CRM:
9+
no more copy pasting lead info, no more missing leads: each and every one of them is in Gro CRM for you to follow up with.
10+
Download our contacts-to-leads plugin today. Learn more at <https://www.grocrm.com/developer/api/>
11+
12+
13+
License
14+
-------
15+
Copyright 2017 [Gro CRM](https://www.grocrm.com)
16+
17+
Licensed under GPLv2 or later. Details in the license file.

README.txt

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
=== Gro CRM Contact to Leads ===
2+
Contributors: grocrm
3+
Tags: crm, contact, contacts, signup, marketing, leads, contact form, contact form plugin, Gro CRM, grocrm.com, secure form, web to lead, web to contact, crm forms, crm leads, lead, leads, lead tracking, form, forms
4+
Requires at least: 4.7.3
5+
Tested up to: 4.7.3
6+
Stable tag: 1.0.0
7+
License: GPLv2 or later
8+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
9+
10+
The Mac CRM sales platform designed for iOS and the Apple Small Business market. Use our Gro CRM Contact-to-Leads WordPress Plug-in for your website.
11+
12+
== Description ==
13+
14+
Convert Wordpress forms into leads. Gro CRM creates an easy integration between your WordPress install(s) and your
15+
Gro CRM account! People can enter a their contact info on your site, and the lead information goes straight into Gro CRM:
16+
no more copy pasting lead info, no more missing leads: each and every one of them is in Gro CRM for you to follow up with.
17+
Download our contacts-to-leads plugin today.
18+
19+
== Installation ==
20+
21+
This section describes how to install the plugin and get it working.
22+
23+
1. Unzip the archive and upload the entire directory to the `/wp-content/plugins/` directory
24+
2. Activate the plugin through the 'Plugins' menu in WordPress.
25+
3. Navigate to **Settings** click **Gro CRM**.
26+
4. Enter your Gro CRM API key in the settings and click **Connect**.
27+
5. Select the default settings that you would like to use for your Gro CRM contact form.
28+
29+
You can use the following shortcode to insert a contact form on your page:
30+
31+
` [grocrm_form] `
32+
33+
If you are adding the form in a block of php code you can use the following function:
34+
35+
` grocrm_contact_form(); `
36+
37+
= Advanced =
38+
39+
If you opt to remove the css the following css classes can be used to style your forms!
40+
41+
* **.grocrm-header** This styles the header text.
42+
* **.grocrm-subheader** This styles the subheader text.
43+
* **.grocrm-field** This styles the `<div>` that contains the `<label>`, and `<input>` or `<select>` for each field.
44+
* **.grocrm-submit** This styles the submit button.
45+
* **.grocrm-error** This styles the error text.
46+
47+
== Frequently Asked Questions ==
48+
49+
= Q. Does this require a subscription? =
50+
51+
A. Yes this requires a Gro CRM subscription.
52+
53+
= Q. How can I contact you for support? =
54+
55+
A. You can email us directly at "support@grocrm.com".
56+
57+
58+
== Screenshots ==
59+
60+
1. Beautiful contact form!
61+
2. Form settings.
62+
3. Field settings.
63+
64+
== Changelog ==
65+
66+
= 1.0.0 =
67+
* Initial release
68+

admin/class-grocrm-admin.php

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
<?php
2+
3+
/**
4+
* The admin-specific functionality of the plugin.
5+
*
6+
* @link https://www.grocrm.com/
7+
* @since 1.0.0
8+
*
9+
* @package Grocrm
10+
* @subpackage Grocrm/admin
11+
*/
12+
13+
/**
14+
* The admin-specific functionality of the plugin.
15+
*
16+
* Defines the plugin name, version, and two examples hooks for how to
17+
* enqueue the admin-specific stylesheet and JavaScript.
18+
*
19+
* @package Grocrm
20+
* @subpackage Grocrm/admin
21+
* @author Gro CRM <support@grocrm.com>
22+
*/
23+
class Grocrm_Admin {
24+
25+
/**
26+
* The ID of this plugin.
27+
*
28+
* @since 1.0.0
29+
* @access private
30+
* @var string $plugin_name The ID of this plugin.
31+
*/
32+
private $plugin_name;
33+
34+
/**
35+
* The version of this plugin.
36+
*
37+
* @since 1.0.0
38+
* @access private
39+
* @var string $version The current version of this plugin.
40+
*/
41+
private $version;
42+
43+
private $login_error;
44+
45+
/**
46+
* Initialize the class and set its properties.
47+
*
48+
* @since 1.0.0
49+
* @param string $plugin_name The name of this plugin.
50+
* @param string $version The version of this plugin.
51+
*/
52+
public function __construct( $plugin_name, $version) {
53+
54+
$this->plugin_name = $plugin_name;
55+
$this->version = $version;
56+
}
57+
58+
/**
59+
* Register the stylesheets for the admin area.
60+
*
61+
* @since 1.0.0
62+
*/
63+
public function enqueue_styles() {
64+
65+
if ( 'settings_page_grocrm' == get_current_screen() -> id ) {
66+
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/grocrm-admin.css', array(), $this->version, 'all' );
67+
}
68+
}
69+
70+
/**
71+
* Register the JavaScript for the admin area.
72+
*
73+
* @since 1.0.0
74+
*/
75+
public function enqueue_scripts() {
76+
/*
77+
if ( 'settings_page_grocrm' == get_current_screen() -> id ) {
78+
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/grocrm-admin.js', array( 'jquery' ), $this->version, false );
79+
}
80+
*/
81+
}
82+
83+
public function add_plugin_admin_menu() {
84+
add_options_page( "Gro CRM Setup", "Gro CRM", "manage_options", $this->plugin_name, [$this, "display_plugin_setup_page"]);
85+
}
86+
87+
public function add_action_links($links) {
88+
$settings_link = [
89+
'<a href="' . admin_url( 'options-general.php?page=' . $this->plugin_name ) . '">' . __('Settings', $this->plugin_name) . '</a>',
90+
];
91+
92+
return array_merge($settings_link, $links);
93+
}
94+
95+
public function display_plugin_setup_page() {
96+
include_once 'partials/grocrm-admin-display.php';
97+
}
98+
99+
public function add_admin_body_class($classes) {
100+
101+
if ( 'settings_page_grocrm' == get_current_screen() -> id ) {
102+
103+
return "$classes grocrm-page";
104+
}
105+
106+
return $classes;
107+
}
108+
109+
public function request_handler() {
110+
111+
if (isset($_POST['grocrm_action'])) {
112+
switch($_POST['grocrm_action']) {
113+
case 'login':
114+
$this->login();
115+
break;
116+
case 'logout':
117+
$this->logout();
118+
break;
119+
case 'update':
120+
$this->update_settings();
121+
break;
122+
}
123+
}
124+
}
125+
126+
// Helper functions
127+
128+
private function login() {
129+
130+
if (!class_exists('GroCRM_API')) {
131+
$path = plugin_dir_path(__FILE__);
132+
require_once($path . '../api/grocrm.php');
133+
}
134+
135+
$apiKey = sanitize_text_field($_POST['grocrm_api_key']);
136+
$grocrm_api = new GroCRM_API($apiKey);
137+
138+
try {
139+
140+
$user = $grocrm_api->getUser();
141+
update_option("grocrm_user", $user);
142+
$this->update_text_field('grocrm_api_key');
143+
$this->login_error = null;
144+
145+
} catch (Exception $e) {
146+
if ($e->getCode() == 401) {
147+
$this->login_error = esc_html_e( "Whoops, those credentials are not correct!", "grocrm");
148+
} else {
149+
$this->login_error = esc_html_e( "An error has occured, please try again later", "grocrm");
150+
}
151+
}
152+
}
153+
154+
private function logout() {
155+
delete_option("grocrm_api_key");
156+
delete_option("grocrm_user");
157+
}
158+
159+
private function update_settings() {
160+
161+
$this->update_text_field('grocrm_header', true);
162+
$this->update_text_field('grocrm_subheader', true);
163+
$this->update_text_field('grocrm_submit');
164+
$this->update_text_field('grocrm_default_type');
165+
166+
167+
$defaultTags = preg_replace('/\s+/', '', sanitize_text_field($_POST["grocrm_default_tags"]));
168+
update_option( "grocrm_default_tags", $defaultTags);
169+
170+
$this->update_checkbox('grocrm_css_disabled');
171+
172+
$this->update_fields();
173+
}
174+
175+
private function update_text_field($name, $allowsHTML = false) {
176+
if ($allowsHTML) {
177+
$content = stripslashes($_POST[$name]);
178+
$content = str_replace("\r\n","<br/>", $content);
179+
update_option($name, $content);
180+
} else {
181+
update_option($name, sanitize_text_field($_POST[$name]));
182+
}
183+
}
184+
185+
private function update_checkbox($name) {
186+
187+
if (isset($_POST[$name]) && !empty($_POST[$name])) {
188+
update_option($name, true);
189+
} else {
190+
update_option($name, false);
191+
}
192+
}
193+
194+
private function update_fields() {
195+
196+
$field_keys = [];
197+
198+
foreach (grocrm_fields() as $key => $value) {
199+
200+
if ($value['required']) {
201+
$field_keys[] = $key;
202+
continue;
203+
}
204+
205+
if (isset($_POST[$key]) && !empty($_POST[$key])) {
206+
$field_keys[] = $key;
207+
}
208+
}
209+
210+
update_option("grocrm_field_keys", $field_keys);
211+
}
212+
}

0 commit comments

Comments
 (0)