-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path12-step-meeting-list-feedback-enhancement.php
92 lines (75 loc) · 3.44 KB
/
12-step-meeting-list-feedback-enhancement.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
<?php
/**
* Plugin Name: 12 Step Meeting List Feedback Enhancement
* Plugin URI: https://wordpress.org/plugins/12-step-meeting-list-feedback-enhancement/
* Description: This '12 Step Meeting List' plugin add-on enhances the feedback feature found on the meetings detail page. It provides a formatted solution to guide user feedback, giving a consistent, auditable, and accurate view of what the feedback submitter is wanting added, changed, or removed in the 12 Step Meeting List.
* Version: 1.0.3
* Requires PHP: 5.6
* Requires 12 Step Meeting List Version: 3.12.0
* Tested up to: 5.9
* Author: Code for Recovery
* Author URI: https://github.com/code4recovery/12-step-meeting-list-feedback-enhancement
* Text Domain: 12-step-meeting-list-feedback-enhancement
* Updated: February 16, 2022
*/
//define constants
if (!defined('TSMLFE_CONTACT_EMAIL')) {
define('TSMLFE_CONTACT_EMAIL', '[email protected]');
}
if (!defined('TSMLFE_VERSION')) {
define('TSMLFE_VERSION', '1.0.3');
}
if (!defined('TSMLFE_PLUGIN_DIR')) {
define('TSMLFE_PLUGIN_DIR', plugin_dir_path(__FILE__));
}
if (!defined('TSMLFE_PLUGIN_TEMPLATE_DIR')) {
define( 'TSMLFE_PLUGIN_TEMPLATE_DIR', TSMLFE_PLUGIN_DIR . '/templates/' );
}
// force use of template from plugin folder
function TSMLFE_include_from_plugin( $template ) {
$our_post_types = array( 'tsml_meeting', 'tsml_location', 'tsml_group' );
if( ! is_singular( $our_post_types) ){
return $template;
}
$meetings_template = '';
$meetings_template = TSMLFE_PLUGIN_TEMPLATE_DIR . 'single-meetings.php';
if( file_exists( $meetings_template ) ) {
$template = $meetings_template;
}
return $template;
}
add_filter( 'template_include', 'TSMLFE_include_from_plugin', 99 );
include TSMLFE_PLUGIN_DIR . '/includes/ajax-override.php';
// ***************** Start of Version Check code *************************
/**
* Plugin Activation hook function to check for Minimum 12 Step Meeting List version
*/
function activate( ) {
$tsml_min_version = '3.12'; //Minimum version of 12 Step Meeting List required for this plugin
$tsml_cur_version = get_option('tsml_version', '');
if (!validatedVersion( $tsml_cur_version, $tsml_min_version )) {
$flag = '12 Step Meeting List';
_e("<div class='bg-warning text-dark'>An error occurred. Correct TSML_VERSION not available!</div>", '12-step-meeting-list-feedback-enhancement');
}
else { // All is good
return;
}
deactivate_plugins( basename( __FILE__ ) );
wp_die('<p>The <strong>12 Step Meeting List Feedback Enhancement</strong> plugin requires the '.$flag.' plugin <strong>version '.$tsml_min_version.'</strong> or greater be installed.</p>','Plugin Activation Error', array( 'response'=>200, 'back_link'=>TRUE ) );
}
function validatedVersion($tsml_cur_version, $tsml_min_version)
{
if (version_compare($tsml_cur_version, $tsml_min_version, '<')) {
echo '12 Step Meeting List plugin version: ' . $tsml_cur_version . "\n\n";
return false;
}
return true;
}
// ****************** End of Version Check code *************************
//tell wp what to do when plugin is activated and uninstalled
if (function_exists('register_activation_hook'))
register_activation_hook(__FILE__, 'activate');
if (function_exists('register_deactivation_hook'))
register_deactivation_hook(__FILE__, 'deactivate');
if (function_exists('register_uninstall_hook'))
register_uninstall_hook(__FILE__, 'uninstall');