-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcaladea-slack.php
94 lines (77 loc) · 2.89 KB
/
caladea-slack.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* Main plugin's file.
*
* @package WP_Slack
*/
/**
* Plugin Name: Theme.id's Caldera Form to Slack
* Plugin URI: http://caladea.com
* Description: Send notifications to Slack channels when certain on Caldera Form submission.
* Version: 0.1.1
* Author: Theme.id
* Author URI: https://theme.id
* Text Domain: caladea-slack
* Domain Path: /languages
* License: GPL v2 or later
* Requires at least: 5.3
* Tested up to: 5.3
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
require_once __DIR__ . '/includes/appsero/src/Client.php';
require_once __DIR__ . '/includes/autoloader.php';
define('CALADEA_SLACK_FILE', __FILE__);
define('CALADEA_SLACK_PATH', plugin_dir_path(CALADEA_SLACK_FILE));
define('CALADEA_SLACK_URL', plugins_url('/', CALADEA_SLACK_FILE));
Caladea_Slack_Autoloader::register( 'Caladea_Slack', trailingslashit( plugin_dir_path( __FILE__ ) ) . '/includes/' );
// Runs this plugin after all plugins are loaded.
add_action( 'plugins_loaded', 'caladea_slack_loaded');
function caladea_slack_loaded(){
if (caladea_slack_check_caldera()){
$GLOBALS['caladea_slack'] = new Caladea_Slack_Plugin();
$GLOBALS['caladea_slack']->run( __FILE__ );
}
}
function caladea_slack_check_caldera()
{
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
if (is_plugin_active('caldera-forms/caldera-core.php') || defined('CFCORE_VER')) {
return true;
}
return false;
}
add_action('admin_notices', 'caladea_slack_notification');
function caladea_slack_notification(){
$message = '<div class="notice notice-error is-dismissible">';
$message .= '<p>';
$message .= '<strong>Caldera</strong> Forms not yet activated. Please install and activated <strong>Caldera</strong> Forms first.';
$message .= '</p>';
$message .= '<p><a href="' . admin_url('plugin-install.php?s=caldera+forms&tab=search&type=term') . '">Click here</a></p>';
$message .= '</div>';
if (!caladea_slack_check_caldera()){
echo $message;
}
}
/**
* Initialize the plugin tracker
*
* @return void
*/
function appsero_init_tracker_themeid_caldera_form_to_slack() {
if ( ! class_exists( '\Appsero\Client' ) ) {
require_once __DIR__ . '/includes/appsero/src/Client.php';
}
$client = new \Appsero\Client( '445d5189-b127-457b-adc0-64c22d5b632e', "Theme.id's Caldera Form to Slack", __FILE__ );
// Active insights
$client->insights()->init();
}
appsero_init_tracker_themeid_caldera_form_to_slack();