-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-footer-text.php
86 lines (70 loc) · 2.25 KB
/
wp-footer-text.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
<?php
if (!function_exists('wpplugin_custom_admin_footer')) {
function wpplugin_custom_admin_footer($footer)
{
$new_footer = get_option('wp_footer_text_field');
if ($new_footer !== '') {
return $new_footer;
}
return $footer;
}
}
add_filter('admin_footer_text', 'wpplugin_custom_admin_footer', 10, 1);
// create custom plugin settings menu
add_action('admin_menu', 'wp_footer_text_seting_page');
if (!function_exists('wp_footer_text_seting_page')) {
function wp_footer_text_seting_page()
{
//create new top-level menu
add_menu_page('WP Footer Text', 'WpFooter Text', 'administrator', 'wp-footer-text', 'wp_footer_text_settings_page', 'dashicons-text');
//call register settings function
add_action('admin_init', 'register_wp_footer_text_plugin_settings');
}
}
if (!function_exists('')) {
function register_wp_footer_text_plugin_settings()
{
//register our settings
register_setting('my-cool-plugin-settings-group', 'wp_footer_text_field');
}
}
if (!function_exists('')) {
function wp_footer_text_settings_page()
{
?>
<div class="wrap">
<h1>WP Footer Text</h1>
<form method="post" action="options.php">
<?php settings_fields('my-cool-plugin-settings-group');?>
<?php do_settings_sections('my-cool-plugin-settings-group');?>
<table class="form-table">
<tr valign="top">
<th scope="row">Footer Text Here</th>
<td>
<textarea name="wp_footer_text_field" id="wpf-textarea" cols="120" rows="8"><?php echo get_option('wp_footer_text_field'); ?></textarea>
</td>
</tr>
</table>
<?php submit_button();?>
</form>
</div>
<?php }
}
add_filter('plugin_action_links_wpfootertext-main/index.php', 'wp_footer_text_settings_link');
function wp_footer_text_settings_link($links)
{
// Build and escape the URL.
$url = esc_url(add_query_arg(
'page',
'wp-footer-text',
get_admin_url() . 'admin.php'
));
// Create the link.
$settings_link = "<a href='$url'>" . __('Settings') . '</a>';
// Adds the link to the end of the array.
array_push(
$links,
$settings_link
);
return $links;
} //end wp_footer_text_settings_link()