0
プラグインを作ろうとしているので、管理セクションにメニュー項目を作成します。ページが開き、フォームを使用してオプションをデータベースに追加したいと考えています。WordPressのプラグインの管理パネルに設定オプションを作成する
誰かがコードを持っている場合は、それを入力してください。
ありがとうございます。
プラグインを作ろうとしているので、管理セクションにメニュー項目を作成します。ページが開き、フォームを使用してオプションをデータベースに追加したいと考えています。WordPressのプラグインの管理パネルに設定オプションを作成する
誰かがコードを持っている場合は、それを入力してください。
ありがとうございます。
例下記のザ・プラグインのオプションを作成して保存するための新しい設定APIを使用しています下の複数のコードの例がありますhttps://codex.wordpress.org/Creating_Options_Pages
上のドキュメントを参照してください:
<?php
// create custom plugin settings menu
add_action('admin_menu', 'my_cool_plugin_create_menu');
function my_cool_plugin_create_menu() {
//create new top-level menu
add_menu_page(
'My Cool Plugin Settings',
'Cool Settings',
'administrator',
__FILE__,
'my_cool_plugin_settings_page',
plugins_url('/images/icon.png', __FILE__)
);
//call register settings function
add_action('admin_init', 'register_my_cool_plugin_settings');
}
function register_my_cool_plugin_settings() {
//register our settings
register_setting('my-cool-plugin-settings-group', 'new_option_name');
register_setting('my-cool-plugin-settings-group', 'some_other_option');
register_setting('my-cool-plugin-settings-group', 'option_etc');
}
function my_cool_plugin_settings_page() { ?>
<div class="wrap">
<h1>Your Plugin Name</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">New Option Name</th>
<td><input type="text" name="new_option_name" value="<?php echo esc_attr(get_option('new_option_name')); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Some Other Option</th>
<td><input type="text" name="some_other_option" value="<?php echo esc_attr(get_option('some_other_option')); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Options, Etc.</th>
<td><input type="text" name="option_etc" value="<?php echo esc_attr(get_option('option_etc')); ?>" /></td>
</tr>
</table>
<?php submit_button(); ?>
</form>
</div>
リンクには、潜在的な解決策はいつでも歓迎ですが、[リンクの前後にコンテキストを追加する](// meta.stackoverflow.com/a/8259)、あなたの仲間のユーザーは、それが何であるか、なぜそれがターゲットサイトに到達できない場合や、永続的にオフラインになる場合は、常に重要なリンクの最も関連性の高い部分を引用してください。外部サイトへのリンク以上のものがあることを考慮に入れてください。なぜ、どのように答えが削除されますか?(// stackoverflow.com/help/deleted-answers)という理由が考えられます。 – FrankerZ
@FrankerZありがとうございます。モバイルデバイスで最も関連性の高い部分のフォーマットに問題があります。後でさらに編集します。 –