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