Skip to content

Commit

Permalink
settings updated
Browse files Browse the repository at this point in the history
  • Loading branch information
rafasashi committed Sep 2, 2024
1 parent b9cec83 commit 5f4ea8d
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions includes/class-wordpress-plugin-template-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,37 +398,30 @@ public function settings_section( $section ) {
* @return void
*/
public function settings_page() {


// get tab name
$tab = !empty($_GET['tab']) ? sanitize_title($_GET['tab']) : key($this->settings);

// Build page HTML.
$html = '<div class="wrap" id="' . $this->parent->_token . '_settings">' . "\n";
$html .= '<h2>' . __( 'Plugin Settings', 'wordpress-plugin-template' ) . '</h2>' . "\n";

$tab = '';
//phpcs:disable
if ( isset( $_GET['tab'] ) && $_GET['tab'] ) {

$tab .= sanitize_text_field($_GET['tab']);
}
//phpcs:enable

// Show page tabs.
if ( is_array( $this->settings ) && 1 < count( $this->settings ) ) {

$html .= '<h2 class="nav-tab-wrapper">' . "\n";

$c = 0;

foreach ( $this->settings as $section => $data ) {

// Set tab class.

$class = 'nav-tab';
if ( ! isset( $_GET['tab'] ) ) { //phpcs:ignore
if ( 0 === $c ) {
$class .= ' nav-tab-active';
}
} else {
if ( isset( $_GET['tab'] ) && $section == $_GET['tab'] ) { //phpcs:ignore
$class .= ' nav-tab-active';
}

if ( $section == $tab ) {

$class .= ' nav-tab-active';
}

// Set tab link.
Expand All @@ -446,6 +439,8 @@ public function settings_page() {
$html .= '</h2>' . "\n";
}

if( $this->settings[$tab]['fields'] ){

$html .= '<form method="post" action="options.php" enctype="multipart/form-data">' . "\n";

// Get settings fields.
Expand All @@ -459,6 +454,8 @@ public function settings_page() {
$html .= '<input name="Submit" type="submit" class="button-primary" value="' . esc_attr( __( 'Save Settings', 'wordpress-plugin-template' ) ) . '" />' . "\n";
$html .= '</p>' . "\n";
$html .= '</form>' . "\n";
}

$html .= '</div>' . "\n";

echo wp_kses_normalize_entities($html); //phpcs:ignore
Expand Down

0 comments on commit 5f4ea8d

Please sign in to comment.