@@ -48,8 +48,8 @@ public function __construct() {
4848
4949 /**
5050 * Add menues and hooks
51- *
52- add_action( 'admin_menu ', array( $this, 'add_settings' ) );
51+ *
52+ add_action( 'admin_init ', array( $this, 'add_settings' ) );
5353 add_action( 'admin_menu', array( $this, 'menu_page' ) );
5454 add_action( 'admin_menu', array( $this, 'sub_menu_page' ) );
5555 add_filter( 'set-screen-option', array( $this, 'set_screen' ), 10, 3 );
@@ -102,9 +102,9 @@ public function sub_menu_page() {
102102
103103 //Set screen option
104104 public function set_screen ($ status , $ option , $ value ) {
105-
105+
106106 if ( 'option_name_per_page ' == $ option ) return $ value ; // Related to PLUGIN_TABLE()
107- //return $status;
107+ //return $status;
108108 }
109109
110110
@@ -136,8 +136,8 @@ public function menu_page_callback() { ?>
136136 * Following is the settings form
137137 */ ?>
138138 <form method="post" action="">
139- <?php settings_fields ("addPdfsId " );
140- do_settings_sections ("addPdfs " );
139+ <?php settings_fields ("settings_name " );
140+ do_settings_sections ("settings_name " );
141141 submit_button ( __ ( 'Save ' , 'textdomain ' ), 'primary ' , 'id ' ); ?>
142142 </form>
143143
@@ -177,25 +177,31 @@ public function help_tabs() {
177177 //Add different types of settings and corrosponding sections
178178 public function add_settings () {
179179
180- add_settings_section ( 'SettingsId ' , __ ( 'Section Name ' , 'textdomain ' ), array ( $ this ,'SectionCb ' ), 'SettingsName ' );
181- register_setting ( 'SettingsId ' , 'SettingsField ' );
182- add_settings_field ( 'SettingsFieldName ' , __ ( 'Field Name ' , 'textdomain ' ), array ( $ this , 'SettingsFieldCb ' ), 'SettingsName ' , 'SettingsId ' );
180+ add_settings_section ( 'settings_id ' , __ ( 'Section Name ' , 'textdomain ' ), array ( $ this ,'section_cb ' ), 'settings_name ' );
181+ register_setting ( 'settings_name ' , 'settings_field ' );
182+ add_settings_field ( 'settings_field_name ' , __ ( 'Field Name ' , 'textdomain ' ), array ( $ this , 'settings_field_cb ' ), 'settings_name ' , 'settings_id ' );
183183 }
184184
185185
186186
187187 //Section description
188- public function SectionCb () {
188+ public function section_cb () {
189189
190190 echo '<p class="description"> ' . __ ( 'Set up settings ' , 'textdomain ' ) . '</p> ' ;
191191 }
192192
193193
194194
195195 //Field explanation
196- public function SettingsFieldCb () {
196+ public function settings_field_cb () {
197197
198- echo '<input type="text" class="medium-text" name="SettingsFieldName" id="SettingsFieldName" value=" ' . get_option ('SettingsFieldName ' ) . '" placeholder=" ' . __ ( 'Enter Value ' , 'textdomain ' ) . '" required /> ' ;
198+ //Choose any one from input, textarea, select or checkbox
199+ /**
200+ echo '<input type="text" class="medium-text" name="settings_field_name" id="settings_field_name" value="' . get_option('settings_field_name') . '" placeholder="' . __( 'Enter Value', 'textdomain' ) . '" required />';
201+ echo '<textarea name="settings_field_name" id="settings_field_name" value="' . get_option('settings_field_name') . '>'. __( 'Enter Value', 'textdomain' ) . '</textarea>';
202+ echo '<select name="settings_field_name" id="settings_field_name"><option value="value" ' . selected( 'value', get_option('settings_field_name'), false) . '>Value</option></select>';
203+ echo '<input type="checkbox" id="settings_field_name" name="settings_field_name" value="1"' . checked( 1, get_option('settings_field_name'), false ) . '/>';
204+ */
199205 }
200206 }
201- } ?>
207+ } ?>
0 commit comments