-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathamc-activities-shortcode.php
131 lines (118 loc) · 4.8 KB
/
amc-activities-shortcode.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
/**
* The plugin bootstrap file
*
* This file is read by WordPress to generate the plugin information in the plugin
* admin area. This file also includes all of the dependencies used by the plugin,
* registers the activation and deactivation functions, and defines a function
* that starts the plugin.
*
* @link https://graybirch.solutions
* @since 1.0.0
*
* @package amc-activities-shortcode
*
* @wordpress-plugin
* Plugin Name: AMC Activities Shortcode
* Plugin URI: https://github.com/graybirchsolutions/amc-activities-shortcode
* Description: Display events from the AMC Activities Database via shortcode. Events are retrieved from the AMC Activities Database using a simple HTTP query. Activities are formatted and displayed in the page or post as events. <strong>Usage: [amc_activities chapter=id committee=id activity=id limit=n]</strong>. Chapter is the only required parameter, all other parameters are optional. Limit defaults to 10. For additional documentation - including Chapter, Committee and Activity IDs, please see the <a href="https://github.com/graybirchsolutions/amc-activities-shortcode/wiki">AMC Activities Shortcode Project Wiki</a>.
* Version: 2.0.3
* Author: gray birch solutions
* Author URI: https://graybirch.solutions/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
// If this file is called directly, abort.
if (!defined('WPINC')) {
die;
}
define('AMC_ACTIVITIES_BASENAME', plugin_basename(__FILE__));
define('AMC_ACTIVITIES_ROOT', dirname(plugin_basename(__FILE__)));
define('AMC_ACTIVITIES_FILE', basename(plugin_basename(__FILE__)));
define('AMC_ACTIVITIES_DIR_URL', plugin_dir_url(__FILE__));
define('AMC_ACTIVITIES_DIR_PATH', plugin_dir_path(__FILE__));
define('AMC_ACTIVITIES_PUBLIC_DIR_URL', AMC_ACTIVITIES_DIR_URL . 'public/');
define('AMC_ACTIVITIES_VERSION', '2.0.3');
define('AMC_ACTIVITIES_ASSET_VERSION', '2.0.3');
define('AMC_ACTIVITIES_BASE_URL', 'https://activities.outdoors.org/xml/index.cfm');
define('AMC_ACTIVITIES_BASE_EVENT_URL', 'https://activities.outdoors.org/search/index.cfm/action/details/id/');
define('AMC_API_ROOT', 'AMCActivities/1.0');
/**
* The core plugin class that is used to define internationalization,
* admin-specific hooks, and public-facing site hooks.
*/
require plugin_dir_path(__FILE__) . 'includes/AMCActivitiesClass.php';
/**
* Activation Hook & Notices
*/
register_activation_hook(__FILE__, 'on_activation');
/**
* The activation hook.
*
* @since 2.0.3
* Checks for allow_url_fopen in php settings. Sets transient to trigger
* an admin notice later.
*
* Note: Don't try to deactivate the plugin in the hook. Appears that
* the hook fires before the plugin is actually activated in WP.
*/
function on_activation()
{
if (ini_get("allow_url_fopen") == "1") {
set_transient('amc-activation-success', true, 5);
} else {
set_transient('amc-activation-error', true, 5);
}
}
/**
* Admin notices. Triggered via transient from activation hook.
* @since 2.0.3
*/
add_action('admin_notices', 'activation_error_msg');
add_action('admin_notices', 'activation_success_msg');
function activation_error_msg()
{
if (get_transient('amc-activation-error')) {
?>
<div class="notice notice-error is-dismissible">
<p>
Error! The AMC Activities Shortcode plugin requires the option <b>allow_url_fopen</b> to be turned <b>On</b> in your host's php.ini settings.
The plugin has been deactivated.
</p>
<p>Please contact your server admin or hosting provider if you are not certain how to modify your site php.ini settings.</p>
</div>
<?php
// Might be a better place to deactivate the plugin on activation error, but this seems to work consistently and avoids more hooks.
include_once ABSPATH . '/wp-admin/includes/plugin.php';
deactivate_plugins(plugin_basename(__FILE__));
}
}
function activation_success_msg()
{
if (get_transient('amc-activation-success')) {
?>
<div class="notice notice-success is-dismissible">
<p>
The AMC Activities Shortcode plugin is ready for action. Please visit the
<a href="https://github.com/graybirchsolutions/amc-activities-shortcode/wiki">Project Wiki</a> if you need help getting started.
</p>
</div>
<?php
}
}
/**
* Begins execution of the plugin.
*
* Since everything within the plugin is registered via hooks,
* then kicking off the plugin from this point in the file does
* not affect the page life cycle.
*
* @since 1.0.0
*/
function amc_activities_boot()
{
$plugin = new \AMCActivities\AMCActivitiesClass();
$plugin->run();
}
// kick off
amc_activities_boot();