| @@ -7,31 +7,98 @@ | ||
| 7 | 7 | * @since 1.0.0 |
| 8 | 8 | * |
| 9 | 9 | * @package Automatic_YouTube_Gallery |
| 10 | 10 | */ |
| 11 | + | |
| 12 | +$gallery_settings = get_option( 'ayg_gallery_settings' ); | |
| 13 | +$player_settings = get_option( 'ayg_player_settings' ); | |
| 14 | + | |
| 15 | +$active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $this->tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; | |
| 16 | +$active_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : ''; | |
| 17 | +$active_theme = $gallery_settings['theme']; | |
| 18 | +$player_type = isset( $player_settings['player_type'] ) ? $player_settings['player_type'] : 'youtube'; | |
| 19 | + | |
| 20 | +$sections = array(); | |
| 21 | +foreach ( $this->sections as $section ) { | |
| 22 | + $tab = $section['tab']; | |
| 23 | + | |
| 24 | + if ( ! isset( $sections[ $tab ] ) ) { | |
| 25 | + $sections[ $tab ] = array(); | |
| 26 | + } | |
| 27 | + | |
| 28 | + $sections[ $tab ][] = $section; | |
| 29 | +} | |
| 11 | 30 | ?> |
| 12 | 31 | |
| 13 | -<div id="ayg-settings" class="wrap ayg-settings ayg-settings-theme-<?php echo esc_attr( $active_theme ); ?> ayg-settings-pagination_type-<?php echo esc_attr( $pagination_type ); ?>"> | |
| 14 | - <h2 class="nav-tab-wrapper"> | |
| 32 | +<div id="ayg-settings" class="ayg ayg-settings theme-<?php echo esc_attr( $active_theme ); ?> player_type-<?php echo esc_attr( $player_type ); ?> wrap"> | |
| 33 | + <?php settings_errors(); ?> | |
| 34 | + | |
| 35 | + <h2 class="nav-tab-wrapper wp-clearfix"> | |
| 15 | 36 | <?php |
| 16 | - $settings_url = admin_url( 'admin.php?page=automatic-youtube-gallery-settings' ); | |
| 17 | - | |
| 18 | 37 | foreach ( $this->tabs as $tab => $title ) { |
| 19 | - $class = ( $tab == $active_tab ) ? 'nav-tab nav-tab-active' : 'nav-tab'; | |
| 20 | - printf( '<a href="%s" class="%s">%s</a>', esc_url( add_query_arg( 'tab', $tab, $settings_url ) ), $class, $title ); | |
| 38 | + $url = add_query_arg( 'tab', $tab, admin_url( 'admin.php?page=automatic-youtube-gallery-settings' ) ); | |
| 39 | + | |
| 40 | + foreach ( $sections[ $tab ] as $section ) { | |
| 41 | + $url = add_query_arg( 'section', $section['id'], $url ); | |
| 42 | + | |
| 43 | + if ( $tab == $active_tab && empty( $active_section ) ) { | |
| 44 | + $active_section = $section['id']; | |
| 45 | + } | |
| 46 | + | |
| 47 | + break; | |
| 48 | + } | |
| 49 | + | |
| 50 | + $classes = array( 'nav-tab' ); | |
| 51 | + if ( $tab == $active_tab ) $classes[] = 'nav-tab-active'; | |
| 52 | + | |
| 53 | + printf( | |
| 54 | + '<a href="%s" class="%s">%s</a>', | |
| 55 | + esc_url( $url ), | |
| 56 | + implode( ' ', $classes ), | |
| 57 | + esc_html( $title ) | |
| 58 | + ); | |
| 21 | 59 | } |
| 22 | 60 | ?> |
| 23 | 61 | </h2> |
| 24 | 62 | |
| 25 | - <?php settings_errors(); ?> | |
| 63 | + <?php | |
| 64 | + $section_links = array(); | |
| 65 | + | |
| 66 | + foreach ( $sections[ $active_tab ] as $section ) { | |
| 67 | + $page = $section['page']; | |
| 68 | + | |
| 69 | + $url = add_query_arg( | |
| 70 | + array( | |
| 71 | + 'tab' => $active_tab, | |
| 72 | + 'section' => $page | |
| 73 | + ), | |
| 74 | + admin_url( 'admin.php?page=automatic-youtube-gallery-settings' ) | |
| 75 | + ); | |
| 76 | + | |
| 77 | + if ( ! isset( $section_links[ $page ] ) ) { | |
| 78 | + $section_links[ $page ] = sprintf( | |
| 79 | + '<a href="%s" class="%s">%s</a>', | |
| 80 | + esc_url( $url ), | |
| 81 | + ( $section['id'] == $active_section ? 'current' : '' ), | |
| 82 | + ( isset( $section['menu_title'] ) ? esc_html( $section['menu_title'] ) : esc_html( $section['title'] ) ) | |
| 83 | + ); | |
| 84 | + } | |
| 85 | + } | |
| 86 | + | |
| 87 | + if ( count( $section_links ) > 1 ) : ?> | |
| 88 | + <ul class="ayg-margin-bottom subsubsub"><li><?php echo implode( ' | </li><li>', $section_links ); ?></li></ul> | |
| 89 | + <div class="clear"></div> | |
| 90 | + <?php endif; ?> | |
| 26 | 91 | |
| 27 | 92 | <form method="post" action="options.php"> |
| 28 | 93 | <?php |
| 29 | - settings_fields( "ayg_{$active_tab}_settings" ); | |
| 30 | - do_settings_sections( "ayg_{$active_tab}_settings" ); | |
| 94 | + $page_hook = $active_section; | |
| 95 | + | |
| 96 | + settings_fields( $page_hook ); | |
| 97 | + do_settings_sections( $page_hook ); | |
| 31 | 98 | ?> |
| 32 | 99 | |
| 33 | - <?php if ( 'general' == $active_tab ) : ?> | |
| 100 | + <?php if ( 'general' == $active_tab && 'ayg_general_settings' == $active_section ) : ?> | |
| 34 | 101 | <table id="ayg-table-delete-cache" class="form-table"> |
| 35 | 102 | <tbody> |
| 36 | 103 | <tr> |
| 37 | 104 | <th scope="row"> |