-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFIC-settings.php
70 lines (51 loc) · 2.75 KB
/
FIC-settings.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
<?php
/*
* admin Scripts and styles for plugin
*/
function FIC_admin_style() {
wp_register_style( 'FIC_css', FICpp() . '/css/FIC.admin.css' );
wp_register_script( 'FIC_js', FICpp() . '/js/FIC.admin.js' );
if ( is_admin() ) {
wp_enqueue_style( 'FIC_css');
wp_enqueue_script( 'FIC_js');
}
}
add_action( 'admin_init', 'FIC_admin_style' );
/* Call Settings Page */
function FIC_settings_page() {
?>
<div class="wrap regenthumbs">
<h2>Funky Image Colors</h2>
<form method="post" action="" id="FIC-settings" data-ajax-images="<?php echo get_admin_url(null, '/admin-ajax.php?action=FIC_get_images'); ?>" data-ajax-run="<?php echo get_admin_url(null, '/admin-ajax.php?action=FIC_detect_image'); ?>">
<?php //settings_fields('FIC_settings'); ?>
<p>Use this tool to detect the primary color of each image in the media library and save its hex value to the attachment as metadata.</p>
<p>Alternatively, you can also run the detect on a single image by finding the image in the media library and clicking the "detect color" link.</p>
<p>To begin the process on all images, click the button below.</p>
<p>
<a href="<?php echo get_admin_url(null, '/admin-ajax.php?action=FIC_remove_colors'); ?>" id="FIC-remove-colors" class="button hide-if-no-js">Remove All Colors</a>
<input type="submit" class="button button-primary hide-if-no-js" name="FIC-detect-colors" id="FIC-detect-colors" value="Detect Colors On All Images">
</p>
<noscript><p><em>You must enable Javascript in order to proceed!</em></p></noscript>
</form>
<ul ID="FIC-console">
<?php if ( isset($_REQUEST['target_image']) && $_REQUEST['target_image'] ): ?>
<?php if (FIC_detect_single_image($_REQUEST['target_image'])): ?>
<li>Detected color for image: <?php echo $_REQUEST['target_image']; ?></li>
<?php else: ?>
<li>Error detecting color for image: <?php echo $_REQUEST['target_image']; ?></li>
<?php endif; ?>
<?php endif; ?>
</ul>
</div><!-- END Wrap -->
<?php
}
/* Save Takeover Settings */
function FIC_settings_init(){
// register_setting('FIC_settings', 'fgram_api_key');
}
add_action('admin_init', 'FIC_settings_init');
function FIC_add_settings() {
add_submenu_page( 'tools.php', 'Funky Colors', 'Funky Colors', 'manage_options', 'FIC_settings', 'FIC_settings_page' );
}
add_action('admin_menu','FIC_add_settings');
?>