こんにちは、新しいハチですwordpress
。ワードプレスでページ オプションを使用して単純なワードプレス プラグインを作成するにはどうすればよいかを知る必要があります。
管理パネルとフロント エンドでフッター テキストを編集するためのデモが必要です
以下のコードを使用して、管理フッター テキストを動的に変更します。以下のコードを.php
wordpress プラグイン ディレクトリにファイルとして保存します。
<?php
/*
Plugin Name: Fancy Search Box For Your Theme
Plugin URI: http://svarun.in/
Description: Fancy Search Form
Version: 1.0.5
Author: Varun
Author URI: http://svarun.in
License: GPL
*/
register_activation_hook(__FILE__,'footer_word_install');
register_deactivation_hook( __FILE__, 'footer_word_remove' );
function footer_word_install() {
add_option("footer_word_data", 'Default', '', 'yes');
}
function footer_word_remove() {
delete_option('footer_word_data');
}
if (is_admin()) {
add_action('admin_menu', 'footer_word_admin_menu');
function footer_word_admin_menu() {
add_options_page('footer word', 'footer word', 'administrator',
'footer-world', 'footer_word_html_page');
}
}
function footer_word_html_page() {
?>
<div>
<h2>footer_word Options</h2>
<form method="post" action="options.php">
<?php wp_nonce_field('update-options'); ?>
<table width="510">
<tr valign="top">
<th width="92" scope="row">Enter Text</th>
<td width="406">
<input name="footer_word_data" type="text" id="footer_word_data" value="<?php echo get_option('footer_word_data'); ?>" />
</td>
</tr>
</table>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="footer_word_data" />
<p>
<input type="submit" value="<?php _e('Save Changes') ?>" />
</p>
</form>
</div>
<?php
}
function change_footer_admin() {
echo get_option('footer_word_data');
}
add_filter('admin_footer_text', 'change_footer_admin');
?>