Wordpress 在插件的管理页面中添加提示字段
我制作了一个插件,现在我正在为它制作一个管理页面。我知道如何在管理页面中正确添加字段,但您知道如何添加“提示字段”吗 示例:Wordpress 在插件的管理页面中添加提示字段,wordpress,Wordpress,我制作了一个插件,现在我正在为它制作一个管理页面。我知道如何在管理页面中正确添加字段,但您知道如何添加“提示字段”吗 示例: 谢谢我不知道您写了多少代码,所以,简短地说,只需将文本放在带有class=“description”的p标记中,即可获得所需的格式。但看起来您可能仍然在为您的选项页面构建代码,因此我将包含以下来自Stripe Checkout插件的代码,其中显示了他们是如何做到这一点的 /** * Main function to register all of the plugin
谢谢我不知道您写了多少代码,所以,简短地说,只需将文本放在带有
class=“description”
的p
标记中,即可获得所需的格式。但看起来您可能仍然在为您的选项页面构建代码,因此我将包含以下来自Stripe Checkout插件的代码,其中显示了他们是如何做到这一点的
/**
* Main function to register all of the plugin settings
*
* @since 1.0.0
*/
function sc_register_settings() {
global $sc_options;
$sc_options = array();
$sc_settings = array(
/* Default Settings */
'default' => array(
'note' => array(
'id' => 'settings_note',
'name' => '',
'desc' => sprintf( '<a href="%s" target="_blank">%s</a>', sc_ga_campaign_url( SC_WEBSITE_BASE_URL . 'docs/shortcodes/stripe-checkout/', 'stripe_checkout', 'settings', 'docs' ), __( 'See shortcode options and examples', 'sc' ) ) . ' ' .
__( 'for', 'sc' ) . ' ' . Stripe_Checkout::get_plugin_title() . '<br/>' .
'<p class="description">' . __( 'Shortcode attributes take precedence and will always override site-wide default settings.', 'sc' ) . '</p>',
'type' => 'section'
),
'name' => array(
'id' => 'name',
'name' => __( 'Site Name', 'sc' ),
'desc' => __( 'The name of your store or website. Defaults to Site Name.' , 'sc' ),
'type' => 'text',
'size' => 'regular-text'
),
'currency' => array(
'id' => 'currency',
'name' => __( 'Currency Code', 'sc' ),
'desc' => __( 'Specify a currency using it\'s ', 'sc' ) .
sprintf( '<a href="%s" target="_blank">%s</a>', 'https://support.stripe.com/questions/which-currencies-does-stripe-support', __( '3-letter ISO Code', 'sc' ) ) . '. ' .
__( 'Defaults to USD.', 'sc' ),
'type' => 'text',
'size' => 'regular-text'
),
'image_url' => array(
'id' => 'image_url',
'name' => __( 'Image URL', 'sc' ),
'desc' => __( 'A URL pointing to a square image of your brand or product. The recommended minimum size is 128x128px.' , 'sc' ),
'type' => 'text',
'size' => 'regular-text'
),
'checkout_button_label' => array(
'id' => 'checkout_button_label',
'name' => __( 'Checkout Button Label', 'sc' ),
'desc' => __( 'The label of the payment button in the checkout form. You can use {{amount}} to display the amount.' , 'sc' ),
'type' => 'text',
'size' => 'regular-text'
),
'payment_button_label' => array(
'id' => 'payment_button_label',
'name' => __( 'Payment Button Label', 'sc' ),
'desc' => __( 'Text to display on the default blue button that users click to initiate a checkout process.' , 'sc' ),
'type' => 'text',
'size' => 'regular-text'
),
'success_redirect_url' => array(
'id' => 'success_redirect_url',
'name' => __( 'Success Redirect URL', 'sc' ),
'desc' => __( 'The URL that the user should be redirected to after a successful payment.' , 'sc' ),
'type' => 'text',
'size' => 'regular-text'
),
'disable_success_message' => array(
'id' => 'disable_success_message',
'name' => __( 'Disable Success Message', 'sc' ),
'desc' => __( 'Disable default success message.', 'sc' ) . '<br/>' .
'<p class="description">' . __( 'Useful if you are redirecting to your own success page.', 'sc' ) . '</p>',
'type' => 'checkbox'
),
'failure_redirect_url' => array(
'id' => 'failure_redirect_url',
'name' => __( 'Failure Redirect URL', 'sc' ),
'desc' => __( 'The URL that the user should be redirected to after a failed payment.' , 'sc' ),
'type' => 'text',
'size' => 'regular-text'
),
'billing' => array(
'id' => 'billing',
'name' => __( 'Enable Billing Address', 'sc' ),
'desc' => __( 'Require the user to enter their billing address during checkout.', 'sc' ) .
( class_exists( 'Stripe_Checkout_Pro' ) ? '<br/><p class="description">' . __( 'See below if you also need to require a shipping address.', 'sc' ) . '</p>' : '' ),
'type' => 'checkbox'
),
'verify_zip' => array(
'id' => 'verify_zip',
'name' => __( 'Verify Zip Code', 'sc' ),
'desc' => __( 'Verifies the zip code of the card.', 'sc' ),
'type' => 'checkbox'
),
'enable_remember' => array(
'id' => 'enable_remember',
'name' => __( 'Enable "Remember Me"', 'sc' ),
'desc' => __( 'Adds a "Remember Me" option to the checkout form to allow the user to store their credit card for future use with other sites using Stripe. ', 'sc' ) .
sprintf( '<a href="%s" target="_blank">%s</a>', 'https://stripe.com/checkout/info', __( 'See how it works', 'sc' ) ),
'type' => 'checkbox'
),
'use_bitcoin' => array(
'id' => 'use_bitcoin',
'name' => __( 'Enable Bitcoin', 'sc' ),
'desc' => sprintf( __( 'Enable accepting <a href="%s" target="_blank">Bitcoin</a> as a payment option.', 'sc' ), 'https://stripe.com/docs/guides/bitcoin' ),
'type' => 'checkbox'
),
'disable_css' => array(
'id' => 'disable_css',
'name' => __( 'Disable Plugin CSS', 'sc' ),
'desc' => __( 'If this option is checked, this plugin\'s CSS file will not be referenced.', 'sc' ),
'type' => 'checkbox'
),
'always_enqueue' => array(
'id' => 'always_enqueue',
'name' => __( 'Always Enqueue Scripts & Styles', 'sc' ),
'desc' => __( 'Enqueue this plugin\'s scripts and styles on every post and page.', 'sc' ) . '<br/>' .
'<p class="description">' . __( 'Useful if using shortcodes in widgets or other non-standard locations.', 'sc' ) . '</p>',
'type' => 'checkbox'
),
'uninstall_save_settings' => array(
'id' => 'uninstall_save_settings',
'name' => __( 'Save Settings', 'sc' ),
'desc' => __( 'Save your settings when uninstalling this plugin.', 'sc' ) . '<br/>' .
'<p class="description">' . __( 'Useful when upgrading or re-installing.', 'sc' ) . '</p>',
'type' => 'checkbox'
)
),
/* Keys settings */
'keys' => array(
'enable_live_key' => array(
'id' => 'enable_live_key',
'name' => __( 'Test or Live Mode', 'sc' ),
'desc' => '<p class="description">' . __( 'Toggle between using your Test or Live API keys.', 'sc' ) . '</p>',
'type' => 'toggle_control'
),
'note' => array(
'id' => 'api_key_note',
'name' => '',
'desc' => sprintf( '<a href="%s" target="_blank">%s</a>', 'https://dashboard.stripe.com/account/apikeys', __( 'Find your Stripe API keys here', 'sc' ) ),
'type' => 'section'
),
'test_secret_key' => array(
'id' => 'test_secret_key',
'name' => __( 'Test Secret Key', 'sc' ),
'desc' => '',
'type' => 'text',
'size' => 'regular-text'
),
'test_publish_key' => array(
'id' => 'test_publish_key',
'name' => __( 'Test Publishable Key', 'sc' ),
'desc' => '',
'type' => 'text',
'size' => 'regular-text'
),
'live_secret_key' => array(
'id' => 'live_secret_key',
'name' => __( 'Live Secret Key', 'sc' ),
'desc' => '',
'type' => 'text',
'size' => 'regular-text'
),
'live_publish_key' => array(
'id' => 'live_publish_key',
'name' => __( 'Live Publishable Key', 'sc' ),
'desc' => '',
'type' => 'text',
'size' => 'regular-text'
)
)
);
$sc_settings = apply_filters( 'sc_settings', $sc_settings );
$sc_settings_title = '';
foreach( $sc_settings as $setting => $option ) {
if( false == get_option( 'sc_settings_' . $setting ) ) {
add_option( 'sc_settings_' . $setting );
}
add_settings_section(
'sc_settings_' . $setting,
apply_filters( 'sc_settings_' . $setting . '_title', $sc_settings_title ),
'__return_false',
'sc_settings_' . $setting
);
foreach ( $sc_settings[$setting] as $option ) {
add_settings_field(
'sc_settings_' . $setting . '[' . $option['id'] . ']',
$option['name'],
function_exists( 'sc_' . $option['type'] . '_callback' ) ? 'sc_' . $option['type'] . '_callback' : 'sc_missing_callback',
'sc_settings_' . $setting,
'sc_settings_' . $setting,
sc_get_settings_field_args( $option, $setting )
);
}
register_setting( 'sc_settings_' . $setting, 'sc_settings_' . $setting, 'sc_settings_sanitize' );
$sc_options = array_merge( $sc_options, is_array( get_option( 'sc_settings_' . $setting ) ) ? get_option( 'sc_settings_' . $setting ) : array() );
}
update_option( 'sc_settings_master', $sc_options );
}
add_action( 'admin_init', 'sc_register_settings' );
/**
*注册所有插件设置的主功能
*
*@自1.0.0以来
*/
函数sc_寄存器_设置(){
全球$sc_选项;
$sc_options=array();
$sc\u设置=阵列(
/*默认设置*/
'默认'=>数组(
'注意'=>数组(
“id'=>“设置\u注意”,
'名称'=>'',
'desc'=>sprintf('',sc_ga_活动_url(sc_网站_基础_url。'docs/shortcode/stripe checkout/','stripe_checkout','settings','docs'),uuu('See shortcode options and examples','sc'))。'。
__('for','sc').”。条带检查::获取插件标题()。
“”。“(“短代码属性优先,并将始终覆盖站点范围的默认设置。”,“sc”)。
”,
'类型'=>'节'
),
'name'=>数组(
'id'=>'name',
“名称”=>u uu('Site name','sc'),
“desc'=>\(“您的商店或网站的名称。默认为网站名称。”,“sc”),
'类型'=>'文本',
“大小”=>“常规文本”
),
'货币'=>数组(
'id'=>'currency',
“名称”=>uuuuuu(‘货币代码’、‘sc’),
'desc'=>\uuuu('使用它的'sc'指定一种货币)。
斯普林特https://support.stripe.com/questions/which-currencies-does-stripe-support“,”(“三字母ISO代码”,“sc”)。”。
__(“默认为美元。”,“sc”),
'类型'=>'文本',
“大小”=>“常规文本”
),
'image_url'=>数组(
'id'=>'image\u url',
'name'=>uuuu('Image URL','sc'),
“desc'=>\(“指向您的品牌或产品的方形图像的URL。建议的最小大小为128x128px。”,“sc”),
'类型'=>'文本',
“大小”=>“常规文本”
),
“签出按钮标签”=>数组(
'id'=>'签出按钮\u标签',
'name'=>\('Checkout Button Label','sc'),
“desc'=>\(“签出表单中付款按钮的标签。您可以使用{amount}}显示金额。”,“sc”),
'类型'=>'文本',
“大小”=>“常规文本”
),
“付款按钮标签”=>数组(
“id”=>“付款按钮标签”,
“名称”=>(付款按钮标签、“sc”),
“desc'=>\”(“显示在默认蓝色按钮上的文本,用户单击该按钮可启动签出过程。”,“sc”),
'类型'=>'文本',
“大小”=>“常规文本”
),
“成功\u重定向\u url”=>数组(
'id'=>'success\u redirect\u url',
'name'=>\('Success Redirect URL','sc'),
“desc'=>”(成功付款后用户应重定向到的URL),“sc”),
'类型'=>'文本',
“大小”=>“常规文本”
),
“禁用成功消息”=>数组(
'id'=>'disable\u success\u message',
'name'=>\('Disable Success Message','sc'),
“desc'=>”(禁用默认成功消息),“sc”)。
。
“”。“(“如果您正在重定向到自己的成功页面,则很有用。”,“sc”)。
”,
'键入'=>'复选框'
),
'failure\u redirect\u url'=>数组(
'id'=>'failure\u redirect\u url',
'name'=>\('Failure Redirect URL','sc'),
“desc'=>\(“支付失败后用户应重定向到的URL”。,“sc”),
'类型'=>'文本',
“大小”=>“常规文本”
),
'计费'=>阵列(
'id'=>'billing',
'name'=>\('Enable Billing Address','sc'),
“desc'=>\(“要求用户在结账时输入他们的账单地址。”,“sc”)。
(class_存在('Stripe_Checkout_Pro')?“
”。uuuu('如果您还需要发货地址,请参见下文,'sc')。
':“”),
'键入'=>'复选框'
),
'verify_zip'=>数组(
'id'=>'verify_zip',
'name'=>\('Verify Zip Code','sc'),
“desc'=>”(验证卡的邮政编码),“sc”),
'键入'=>'复选框'
),
“启用_记住”=>数组(
'id'=>'启用\u记住',
'name'=>uuuu('Enable'memberme','sc'),
'desc'=>\uuuuuuu('在结帐表单中添加了一个“记住我”选项,允许用户存储他们的信用卡,以便将来与使用Stripe的其他网站一起使用。','sc')。
斯普林特https://stripe.com/checkout/info“,”(“看看它是如何工作的”,“sc”),
'键入'=>'复选框'
),
“使用比特币”=>数组(
'id'=>'使用比特币',
“名称”=>uuuuuuuu('Enable Bitcoin','sc'),
'