This repository has been archived by the owner on Jun 29, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
elasticpress_admin.php
84 lines (72 loc) · 2.76 KB
/
elasticpress_admin.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
<?php
/**
* Plugin Name: ElasticPress Admin Search
* Plugin URI: http://github.com/10up/ElasticPress-Admin
* Description: Extend Elasticsearch coverage to replace Admin search. Requires ElasticPress.
* Version: 0.1.0
* Author: Aaron Holbrook, 10up
* Author URI: http://10up.com
* License: GPLv2+
* Text Domain: epa
* Domain Path: /languages
*/
/**
* Copyright (c) 2014 Aaron Holbrook, 10up (email : info@10up.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 or, at
* your discretion, any later version, as published by the Free
* Software Foundation.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* Built using grunt-wp-plugin
* Copyright (c) 2013 10up, LLC
* https://github.com/10up/grunt-wp-plugin
*/
/**
* This plugin requires ElasticPress
* http://github.com/10up/ElasticPress
*
* Deactivate if ElasticPress is not running
*/
function epa_activate_check() {
if ( class_exists( 'EP_ElasticPress' ) ) {
// Useful global constants
define( 'EPA_VERSION', '0.1.0' );
define( 'EPA_URL', plugin_dir_url( __FILE__ ) );
define( 'EPA_PATH', dirname( __FILE__ ) . '/' );
require_once( EPA_PATH . 'includes/class-epa-integration.php' );
} else {
// ElasticPress was unable to be found, deactivate plugin
// @todo need to think through use cases here - if we have subsites activated, different admin notices
// @todo also - need to think through dependency situation for network/subsites
add_action( 'network_admin_notices', 'epa_deactivate_dependency_requirement' );
add_action( 'admin_notices', 'epa_deactivate_dependency_requirement' );
add_action( 'admin_init', 'epa_deactivate_plugin' );
}
}
add_action( 'plugins_loaded', 'epa_activate_check', 8 );
/**
* Display notice requiring main ElasticPress requirement
*/
function epa_deactivate_dependency_requirement() {
echo '<div class="error"><p><strong>ElasticPress Admin</strong> requires <a href="http://github.com/10up/ElasticPress">ElasticPress</a>; the plug-in has been <strong>deactivated</strong>.</p></div>';
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
}
/**
* Action to deactivate plugin. Used if main ElasticPress plugin is not currently active
*/
function epa_deactivate_plugin() {
deactivate_plugins( plugin_basename( __FILE__ ) );
}