| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Settings Form. |
| 5 |
* |
| 6 |
* @link https://plugins360.com |
| 7 |
* @since 1.0.0 |
| 8 |
* |
| 9 |
* @package Automatic_YouTube_Gallery |
| 10 |
*/ |
| 11 |
|
| 12 |
$gallery_settings = ayg_get_option( 'ayg_gallery_settings' ); |
| 13 |
$player_settings = ayg_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 |
} |
| 30 |
?> |
| 31 |
|
| 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 |
<h1><?php esc_html_e( 'Plugin Settings', 'automatic-youtube-gallery' ); ?></h1> |
| 34 |
|
| 35 |
<?php settings_errors(); ?> |
| 36 |
|
| 37 |
<h2 class="nav-tab-wrapper wp-clearfix"> |
| 38 |
<?php |
| 39 |
foreach ( $this->tabs as $tab => $title ) { |
| 40 |
$url = add_query_arg( 'tab', $tab, admin_url( 'admin.php?page=automatic-youtube-gallery-settings' ) ); |
| 41 |
|
| 42 |
foreach ( $sections[ $tab ] as $section ) { |
| 43 |
$url = add_query_arg( 'section', $section['id'], $url ); |
| 44 |
|
| 45 |
if ( $tab == $active_tab && empty( $active_section ) ) { |
| 46 |
$active_section = $section['id']; |
| 47 |
} |
| 48 |
|
| 49 |
break; |
| 50 |
} |
| 51 |
|
| 52 |
$classes = array( 'nav-tab' ); |
| 53 |
if ( $tab == $active_tab ) $classes[] = 'nav-tab-active'; |
| 54 |
|
| 55 |
printf( |
| 56 |
'<a href="%s" class="%s">%s</a>', |
| 57 |
esc_url( $url ), |
| 58 |
implode( ' ', $classes ), |
| 59 |
esc_html( $title ) |
| 60 |
); |
| 61 |
} |
| 62 |
?> |
| 63 |
</h2> |
| 64 |
|
| 65 |
<?php |
| 66 |
$section_links = array(); |
| 67 |
|
| 68 |
foreach ( $sections[ $active_tab ] as $section ) { |
| 69 |
$page = $section['page']; |
| 70 |
|
| 71 |
$url = add_query_arg( |
| 72 |
array( |
| 73 |
'tab' => $active_tab, |
| 74 |
'section' => $page |
| 75 |
), |
| 76 |
admin_url( 'admin.php?page=automatic-youtube-gallery-settings' ) |
| 77 |
); |
| 78 |
|
| 79 |
if ( ! isset( $section_links[ $page ] ) ) { |
| 80 |
$section_links[ $page ] = sprintf( |
| 81 |
'<a href="%s" class="%s">%s</a>', |
| 82 |
esc_url( $url ), |
| 83 |
( $section['id'] == $active_section ? 'current' : '' ), |
| 84 |
( isset( $section['menu_title'] ) ? esc_html( $section['menu_title'] ) : esc_html( $section['title'] ) ) |
| 85 |
); |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
if ( count( $section_links ) > 1 ) : ?> |
| 90 |
<ul class="subsubsub"><li><?php echo implode( ' | </li><li>', $section_links ); ?></li></ul> |
| 91 |
<div class="clear"></div> |
| 92 |
<?php endif; ?> |
| 93 |
|
| 94 |
<form method="post" action="options.php"> |
| 95 |
<?php |
| 96 |
$page_hook = $active_section; |
| 97 |
|
| 98 |
settings_fields( $page_hook ); |
| 99 |
do_settings_sections( $page_hook ); |
| 100 |
?> |
| 101 |
|
| 102 |
<?php if ( 'general' == $active_tab && 'ayg_general_settings' == $active_section ) : ?> |
| 103 |
<table id="ayg-table-delete-cache" class="ayg-form form-table"> |
| 104 |
<tbody> |
| 105 |
<tr> |
| 106 |
<th scope="row"> |
| 107 |
<label><?php esc_html_e( 'Delete Cache', 'automatic-youtube-gallery' ); ?></label> |
| 108 |
</th> |
| 109 |
<td> |
| 110 |
<div class="ayg-form-actions"> |
| 111 |
<input type="submit" id="ayg-button-delete-cache" class="button-secondary" value="<?php esc_attr_e( 'Delete Cache', 'automatic-youtube-gallery' ); ?>" /> |
| 112 |
<span class="ayg-form-status"></span> |
| 113 |
</div> |
| 114 |
|
| 115 |
<p class="description"><?php esc_html_e( 'Delete all of the YouTube API data cached by the plugin.', 'automatic-youtube-gallery' ); ?></p> |
| 116 |
</td> |
| 117 |
</tr> |
| 118 |
</tbody> |
| 119 |
</table> |
| 120 |
<?php endif; ?> |
| 121 |
|
| 122 |
<?php submit_button(); ?> |
| 123 |
</form> |
| 124 |
</div> |
| 125 |
|