get_option( 'license_state', 'stockpack_advanced' ); } public function add_license_state_to_filename() { return $this->get_option( 'add_license_state_to_filename', 'stockpack_advanced' ); } public function get_safe_search() { return $this->get_option( 'safe_search', 'stockpack_basics' ); } public function get_file_name_change_setting() { return $this->get_option( 'file_name_change', 'stockpack_basics' ); } public function get_premium_providers_caption_setting() { return $this->get_option( 'caption_premium_providers', 'stockpack_advanced' ); } public function get_standard_fields_caption_setting() { return $this->get_option( 'caption_standard_fields', 'stockpack_advanced' ); } public function get_featured_caption_setting() { return $this->get_option( 'caption_featured_image', 'stockpack_advanced' ); } public function get_url_debugging_setting() { return $this->get_option( 'url_debugging', 'stockpack_debug' ); } public function get_selected_providers_setting() { return $this->get_option( 'providers', 'stockpack_basics', array( 'Adobe Stock'=> 'Adobe Stock', 'Deposit Photos'=> 'Deposit Photos', 'Freepik'=> 'Freepik', 'Magnific AI'=> 'Magnific AI', 'Getty'=> 'Getty', 'iStock'=> 'iStock', 'Pixabay' => 'Pixabay', 'Pexels' => 'Pexels', 'Unsplash' => 'Unsplash', ) ); } public function get_available_search_provider_slugs() { $slugs = array(); foreach ( (array) $this->get_selected_providers_setting() as $provider ) { $slug = strtolower( str_replace( ' ', '_', trim( $provider ) ) ); if ( '' === $slug || 'magnific_ai' === $slug ) { continue; } $slugs[] = $slug; } return $slugs; } public function get_selected_ai_models() { $selected = $this->get_option( 'ai_models', 'stockpack_basics', null ); return is_array( $selected ) ? array_keys( array_filter( $selected ) ) : null; } /** * @return mixed */ public function get_api_key() { $api_key = $this->get_option( 'auth_token', 'stockpack_basics' ); if ( ! $api_key && defined( 'STOCKPACK_TOKEN' ) ) { return STOCKPACK_TOKEN; } return $api_key; } /** * Get the value of a settings field * * @param string $option settings field name * @param string $section the section name this field belongs to * @param string $default default text if it's not found * * @return mixed */ private function get_option( $option, $section, $default = '' ) { $options = get_option( $section, array() ); if ( isset( $options[ $option ] ) ) { return $options[ $option ]; } return $default; } }