There is the following code:

$tabs = array( 'vk', 'facebook', 'instagram' ); $saved = false; if(isset($_POST['plugin_hidden']) && $_POST['plugin_hidden'] == 'Y') { $plugin_source_tabs = $_POST['plugin_source_tabs']; update_option('plugin_source_tabs', $plugin_source_tabs); $saved = true; } else { $plugin_source_tabs = get_option('plugin_source_tabs', $tab_defaults); } ?> <?php if ($saved): ?> <div class="updated"><p><strong><?php _e('Options saved.' ); ?></strong></p></div> <?php endif; ?> <?php echo "<h2>" . __( 'Plugin', 'plugin_settings' ) . "</h2>"; ?> <form name="oscimp_form" method="post" action="<?php echo str_replace('%7E', '~', $_SERVER['REQUEST_URI']); ?>"> <input type="hidden" name="plugin_hidden" value="Y"> <h3>Options</h3> <p> <h3>Source tabs</h3> <select name="plugin_source_tabs[]" multiple="" size="3" style="width: 120px;"> <?php $selected = in_array('all', $plugin_source_tabs) ? 'selected="selected"' : ''; echo '<option ' . $selected . ' value="all">All tabs</option>'; foreach ($tabs as $tab) { $selected = in_array($tab, $plugin_source_tabs) ? 'selected="selected"' : ''; echo '<option ' . $selected . ' value="' . $tab . '">' . $tab . '</option>'; } ?> </select> <p class="submit"> <?php submit_button(); ?> </p> </form> 

Tell me, is there an internal mechanism for adding new settings in the wp admin panel and correct rendering? I want to refactor, but then, due to ignorance of the nuances of wp, it can turn out badly.

Maybe you can somehow "nicely" separate the logic from the output tags?

  • you can write your module or plugin and let everything you want there - Lieutenant Jim Dangle
  • That is not the question. - Timur Musharapov

1 answer 1

Apparently, this is done in all plugins. There is no correct separation.