- изменить размер ввода, вход выглядит как textarea, не может использовать textarea, потому что не удалось определить $ textarea в функции sanitize (Uncaught ArgumentCountError: слишком мало аргументов для функции)?
- Когда я изменяю высоту, она показывает большую площадь, но те же цифры для ввода
- Изменение размера ввода, ввод выглядит как textarea, не может использовать textarea, потому что не может определить $ textarea в функции sanitize (Uncaught ArgumentCountError: слишком мало аргументов для функции)?
- Когда я изменяю высоту, появляется большая область, но те же цифры для ввода
class adsBoxSettings
{
private $options;
public function __construct()
{
add_action( 'admin_menu', array( $this, 'add_ads_box_menu_page' ) );
add_action( 'admin_init', array( $this, 'ads_box_page_init' ) );
}
/**
* Add settings page
* The page will appear in "Settings" menu dropdown
*/
public function add_ads_box_menu_page()
{
add_submenu_page(
'custom-settings-page',
'ads_box Custom Settings',
'Ads Box',
'manage_options',
'ads_box-custom_settings',
array( $this, 'create_ads_box_admin_page' ),);
}
/**
* Options page callback
*/
public function create_ads_box_admin_page()
{
// Set class property
$this->options = get_option( 'ads_box_custom_settings' );
?>
<div class="wrap">
<form method="post" action="options.php">
<?php
// This prints out all hidden setting fields
settings_fields( 'ads_box_custom_settings_group' );
do_settings_sections( 'ads_box-custom_settings' );
submit_button();
?>
</form>
</div>
<?php
}
/**
* Register and add settings
*/
public function ads_box_page_init()
{
register_setting(
'ads_box_custom_settings_group', // Option group
'ads_box_custom_settings', // Option name
array( $this, 'sanitize' ) // Sanitize
);
add_settings_section(
'ads_box_custom_settings_section', // ID
'Fotter Custom Settings', // Title
array( $this, 'ads_box_custom_settings_section' ), // Callback
'ads_box-custom_settings' // Page
);
add_settings_field(
'ads_box_custom_head_js', // ID
'Head Javascript', // Title
array( $this, 'ads_box_custom_head_js_html' ), // Callback
'ads_box-custom_settings', // Page
'ads_box_custom_settings_section'
);
add_settings_field(
'ads_box_content',
'ads_box content:',
array( $this, 'ads_box_content_html' ),
'ads_box-custom_settings', // Page
'ads_box_custom_settings_section'
);
}
public function sanitize( $input)
{
$sanitized_input= array();
if( isset( $input['ads_box_content'] ) )
$sanitized_input['ads_box_content'] = sanitize_text_field( $input['ads_box_content'] );
if( isset( $input['ads_box_custom_head_js'] ) )
$sanitized_input['ads_box_custom_head_js'] = sanitize_text_field( $input['ads_box_custom_head_js'] );
return $sanitized_input;
}
public function ads_box_custom_settings_section()
{
print('Some text');
}
public function ads_box_custom_head_js_html()
{
printf(
'<textarea type="text" id="ads_box_custom_head_js" name="ads_box_custom_settings[ads_box_custom_head_js]" value="%s" ></textarea>',
isset( $this->options['ads_box_custom_head_js'] ) ? esc_attr( $this->options['ads_box_custom_head_js']) : ''
);
}
public function ads_box_content_html()
{
printf(
'<input type="text" placeholder="Enter ads_box content" minlength="8" maxlength="500" size="120" id="ads_box_content" name="ads_box_custom_settings[ads_box_content]" value="%s" />',
isset( $this->options['ads_box_content'] ) ? esc_attr( $this->options['ads_box_content']) : ''
);
}
}