PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.1.36
Gallery : FooGallery v3.1.36
3.3.2 3.3.3 3.3.0 3.1.31 3.1.32 3.1.34 3.1.36 3.2.0 3.2.6 trunk 1.10.3 2.0.24 2.1.34 2.2.44 2.3.3 2.4.32 3.0.6 3.1.11 3.1.12 3.1.13 3.1.20 3.1.25 3.1.26 3.1.26.1 3.1.26.2
foogallery / includes / foopluginbase / views / settings.php
foogallery / includes / foopluginbase / views Last commit date
index.php 2 months ago settings.php 2 months ago
settings.php
105 lines
1 <?php
2 /*
3 Default settings page used by Foo_Plugin_Base
4 */
5 global $wp_version, $wp_settings_sections, $wp_settings_fields;
6
7 //need to make sure are included correctly
8 if ( !isset($this) || !is_subclass_of( $this, 'Foo_Plugin_Base_v2_4' ) ) {
9 throw new Exception("This settings view has not been included correctly!");
10 }
11
12 $tabs = $this->settings()->get_tabs();
13 $plugin_info = $this->get_plugin_info();
14 $plugin_slug = $plugin_info['slug'];
15 $summary = $this->apply_filters( $plugin_slug . '_admin_settings_page_summary', '' );
16
17 ?>
18 <div class="wrap" id="<?php echo esc_attr( $plugin_slug ); ?>-settings">
19 <h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
20 <?php
21 //only show the settings messages if less than WP3.5
22 if (version_compare($wp_version, '3.5') < 0) {
23 settings_errors();
24 }
25
26 if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$plugin_slug]) ) {
27 return;
28 }
29
30 if ( !empty($summary) ) {
31 echo esc_html( $summary );
32 }
33 ?>
34 <div id="<?php echo esc_attr( $plugin_slug ); ?>-settings-wrapper">
35 <div id="<?php echo esc_attr( $plugin_slug ); ?>-settings-main">
36 <form action="options.php" method="post">
37 <?php settings_fields($plugin_slug); ?>
38 <?php
39 if (!empty($tabs)) {
40 //we have tabs - woot!
41 ?>
42 <div style="float:left;height:16px;width:16px;"><!-- spacer for tabs --></div>
43 <h2 class="foo-nav-tabs nav-tab-wrapper">
44 <?php
45 //loop through the tabs to render the actual tabs at the top
46 $first = true;
47 foreach ($tabs as $tab) {
48 $class = $first ? "nav-tab nav-tab-active" : "nav-tab";
49 echo "<a href='#" . esc_attr( $tab['id'] ) . "' class='" . esc_attr( $class ) . "'>" . esc_html( $tab['title'] ) . "</a>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
50 if ( $first ) {
51 $first = false;
52 }
53 }
54 ?>
55 </h2>
56 <?php
57 //now loop through the tabs to render the content containers
58 $first = true;
59 foreach ($tabs as $tab) {
60 $style = $first ? "" : "style='display:none'";
61
62 echo "<div class='nav-container' id='" . esc_attr( $tab['id'] ) . "_tab' " . $style . ">"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
63
64 foreach ( (array) $wp_settings_sections[$plugin_slug] as $section ) {
65 if (in_array($section['id'], $tab['sections'])) {
66 echo "<h3>" . esc_html( $section['title'] ) . "</h3>\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
67 call_user_func($section['callback'], $section);
68 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$plugin_slug]) || !isset($wp_settings_fields[$plugin_slug][$section['id']]) ) {
69 continue;
70 }
71 echo '<table class="form-table">';
72 do_settings_fields($plugin_slug, $section['id']);
73 echo '</table>';
74 }
75 }
76
77 echo "</div>";
78 if ( $first ) {
79 $first = false;
80 }
81 }
82 ?>
83 <?php
84 } else {
85 //no tabs so just render the sections
86 do_settings_sections($plugin_slug);
87 }
88 ?>
89 <p class="submit">
90 <input name="submit" class="button-primary" type="submit"
91 value="<?php esc_attr_e( 'Save Changes', $plugin_slug ); ?>"/>
92 <input name="<?php echo esc_attr( $plugin_slug ); ?>[reset-defaults]"
93 onclick="return confirm('<?php esc_attr_e( 'Are you sure you want to restore all settings back to their default values?', $plugin_slug ); ?>');"
94 class="button-secondary" type="submit"
95 value="<?php esc_attr_e( 'Restore Defaults', $plugin_slug ); ?>"/>
96 <?php do_action($plugin_slug . '_admin_settings_buttons') ?>
97 </p>
98 </form>
99 </div>
100 <div id="<?php echo esc_attr( $plugin_slug ); ?>-settings-sidebar" class="postbox-container">
101 <?php do_action($plugin_slug . '_admin_settings_sidebar'); ?>
102 </div>
103 </div>
104 </div>
105