Skip to content

Commit fa0874e

Browse files
author
Guido W. Pettinari
committed
Funzione SettingsPage::get_option()
1 parent b608a5f commit fa0874e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/class-settings-page.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,24 @@ protected function view_template_tabs() {
115115
$this->api->show_forms();
116116
echo '</div>';
117117
}
118+
119+
/**
120+
* Ritorna il valore di un'opzione a partire dalla sua sezione
121+
* e dal suo nome
122+
*
123+
* @param string $option settings field name
124+
* @param string $section the section name this field belongs to
125+
* @param string $default default text if it's not found
126+
* @return string
127+
*/
128+
public static function get_option( $option, $section, $default = '' ) {
129+
130+
$options = get_option( $section );
131+
132+
if ( isset( $options[$option] ) ) {
133+
return $options[$option];
134+
}
135+
136+
return $default;
137+
}
118138
}

0 commit comments

Comments
 (0)