-
Notifications
You must be signed in to change notification settings - Fork 1
/
easy-reservations-reviews.php
139 lines (128 loc) · 5.34 KB
/
easy-reservations-reviews.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
132
133
134
135
136
137
138
139
<?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://cmsminds.com
* @since 1.0.0
* @package Easy_Reservations_Reviews
*
* @wordpress-plugin
* Plugin Name: Reviews for Boat Rental Plugin
* Plugin URI: https://github.com/cmsminds/easy-reservations-reviews
* Description: Allow your customers to review their experience with your boat bookings.
* Version: 1.0.0
* Author: cmsMinds
* Author URI: https://cmsminds.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: easy-reservations-reviews
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
/**
* Currently plugin version.
* Start at version 1.0.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
define( 'ERSRVR_PLUGIN_VERSION', '1.0.0' );
// Plugin path.
if ( ! defined( 'ERSRVR_PLUGIN_PATH' ) ) {
define( 'ERSRVR_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
}
// Plugin URL.
if ( ! defined( 'ERSRVR_PLUGIN_URL' ) ) {
define( 'ERSRVR_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
}
/**
* The code that runs during plugin activation.
* This action is documented in includes/class-easy-reservations-reviews-activator.php
*/
function activate_easy_reservations_reviews() {
require_once ERSRVR_PLUGIN_PATH . 'includes/class-easy-reservations-reviews-activator.php';
Easy_Reservations_Reviews_Activator::activate();
}
register_activation_hook( __FILE__, 'activate_easy_reservations_reviews' );
/**
* The code that runs during plugin deactivation.
* This action is documented in includes/class-easy-reservations-reviews-deactivator.php
*/
function deactivate_easy_reservations_reviews() {
require_once ERSRVR_PLUGIN_PATH . 'includes/class-easy-reservations-reviews-deactivator.php';
Easy_Reservations_Reviews_Deactivator::deactivate();
}
register_deactivation_hook( __FILE__, 'deactivate_easy_reservations_reviews' );
/**
* 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 run_easy_reservations_reviews() {
// The core plugin class that is used to define internationalization, admin-specific hooks, and public-facing site hooks.
require ERSRVR_PLUGIN_PATH . 'includes/class-easy-reservations-reviews.php';
$easy_reservations_reviews_plugin = new Easy_Reservations_Reviews();
$easy_reservations_reviews_plugin->run();
}
/**
* This initiates the plugin.
* Checks for the required plugins to be installed and active.
*
* @since 1.0.0
*/
function ersrvr_plugins_loaded_callback() {
$is_ersrvr_active = in_array( 'boat-rental-system/easy-reservations.php', get_option( 'active_plugins' ), true );
if ( current_user_can( 'activate_plugins' ) && false === $is_ersrvr_active ) {
add_action( 'admin_notices', 'ersrvr_admin_notices_callback' );
} else {
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'ersrvr_plugin_actions_callback' );
run_easy_reservations_reviews();
}
}
add_action( 'plugins_loaded', 'ersrvr_plugins_loaded_callback' );
/**
* Show admin notice for the required plugins not active or installed.
*
* @since 1.0.0
*/
function ersrvr_admin_notices_callback() {
$this_plugin_data = get_plugin_data( __FILE__ );
$this_plugin = $this_plugin_data['Name'];
$ersrv_plugin = 'Boat Rental Plugin for WordPress';
?>
<div class="error">
<p>
<?php
/* translators: 1: %s: strong tag open, 2: %s: strong tag close, 3: %s: this plugin, 4: %s: woocommerce plugin, 5: anchor tag for woocommerce plugin, 6: anchor tag close */
echo wp_kses_post( sprintf( __( '%1$s%3$s%2$s is ineffective as it requires %1$s%4$s%2$s to be installed and active. Click %5$shere%6$s to install or activate it.', 'wc-quick-buy' ), '<strong>', '</strong>', esc_html( $this_plugin ), esc_html( $ersrv_plugin ), '<a target="_blank" href="' . admin_url( 'plugin-install.php?s=woocommerce&tab=search&type=term' ) . '">', '</a>' ) );
?>
</p>
</div>
<?php
}
/**
* This function adds custom plugin actions.
*
* @param array $links Links array.
* @return array
* @since 1.0.0
*/
function ersrvr_plugin_actions_callback( $links ) {
$this_plugin_links = array(
'<a title="' . __( 'Settings', 'easy-reservations-reviews' ) . '" href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=easy-reservations§ion=reviews' ) ) . '">' . __( 'Settings', 'easy-reservations-reviews' ) . '</a>',
'<a title="' . __( 'Docs', 'easy-reservations-reviews' ) . '" href="javascript:void(0);">' . __( 'Docs', 'easy-reservations-reviews' ) . '</a>',
'<a title="' . __( 'Support', 'easy-reservations-reviews' ) . '" href="javascript:void(0);">' . __( 'Support', 'easy-reservations-reviews' ) . '</a>',
'<a title="' . __( 'Changelog', 'easy-reservations-reviews' ) . '" href="javascript:void(0);">' . __( 'Changelog', 'easy-reservations-reviews' ) . '</a>',
);
return array_merge( $this_plugin_links, $links );
}