Skip to content
Snippets Groups Projects

add linting

Merged Erick Hitter requested to merge add/lint into master
2 files
+ 27
9
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 26
8
@@ -31,10 +31,14 @@ class Options {
@@ -31,10 +31,14 @@ class Options {
];
];
/**
/**
* Hooks and other preparations
* Retrieve full plugin options
 
*
 
* @return array
*/
*/
public function setup() {
private function get_all() : array {
// Hooks and such.
$options = get_option( $this->name, [] );
 
$options = wp_parse_args( $options, $this->allowed_options );
 
return $options;
}
}
/**
/**
@@ -48,9 +52,7 @@ class Options {
@@ -48,9 +52,7 @@ class Options {
return false;
return false;
}
}
$options = get_option( $this->name, [] );
$options = $this->get_all();
$options = wp_parse_args( $options, $this->allowed_options );
return $options[ $option ] ?? false;
return $options[ $option ] ?? false;
}
}
@@ -61,7 +63,23 @@ class Options {
@@ -61,7 +63,23 @@ class Options {
* @param mixed $value Option value.
* @param mixed $value Option value.
* @return bool
* @return bool
*/
*/
public function update( string $option, $value ) : bool {
public function set( string $option, $value ) : bool {
return false;
switch ( $option ) {
 
case 'host':
 
$value = esc_url( $value );
 
break;
 
 
case 'key':
 
$value = sanitize_text_field( $value );
 
break;
 
 
default:
 
return false;
 
}
 
 
$options = $this->get_all();
 
$options[ $option ] = $value;
 
 
return update_option( $this->name, $options );
}
}
}
}
Loading