-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsimple-fields-prettify.php
65 lines (47 loc) · 2.56 KB
/
simple-fields-prettify.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
<?php
/*
Plugin Name: Simple Fields Prettify
Plugin URI: http://github.com/backflip/Wordpress-Simple-Fields-Prettify
Description: Changes edit view of the fantastic Simple Fields plugin, removes dependency on external jQuery UI files, fixes an issue with sortables on field group admin page and bypasses an issue with the Custom Field Template plugin.
Version: 0.1
Author: Thomas Jaggi
Author URI: http://backflip.info
License: GLP2
*/
/* Copyright 2011 Simple Fields Prettify (thomas@backflip.info)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, 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
*/
// is_plugin_active does not work for some reason and cannot be redeclared
if (!function_exists(my_is_plugin_active)) {
function my_is_plugin_active($plugin) {
return in_array($plugin, (array) get_option('active_plugins', array()));
}
}
if (!my_is_plugin_active('simple-fields/simple_fields.php')) return;
// Add script and styles
function simple_fields_prettify_init() {
wp_register_script('simple-fields-prettify', plugins_url('/_script.js', __FILE__), array(), false, true);
wp_enqueue_script('simple-fields-prettify');
wp_register_style('simple-fields-prettify', plugins_url('/_styles.css', __FILE__));
wp_enqueue_style('simple-fields-prettify');
// Overwrite links to external jQuery UI files in order to make it work offline
wp_enqueue_script("jquery-ui-effects-core", plugins_url('/jquery-ui/effects.core.js', __FILE__));
wp_enqueue_script("jquery-ui-effects-highlight", plugins_url('/jquery-ui/effects.highlight.js', __FILE__));
}
add_action('admin_init', 'simple_fields_prettify_init');
// media_send_to_editor hooks don't play well with each other (SF 0.3.6, CFT 1.8.3)
// --> priorities changed (based on some trial and error, may break with future versions of both plugins)
if (my_is_plugin_active('custom-field-template/custom-field-template.php')) {
add_filter('media_send_to_editor', 'media_send_to_custom_field', 14);
add_filter('media_send_to_editor', 'simple_fields_media_send_to_editor', 14, 2);
}
?>