# stockpack/3.7.1/src/class-stockpacksettings.php

StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more, version 3.7.1. 140 lines.

- Page: https://pluginprobe.com/plugins/stockpack/3.7.1/code/src/class-stockpacksettings.php
- Raw: https://pluginprobe.com/plugins/stockpack/3.7.1/raw/src/class-stockpacksettings.php
- Modified: 2026-09-01T13:28:48+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/stockpack/3.7.1/code/src/class-stockpacksettings.php#L10-L20`.

```php
<?php

/**
 * Class StockpackSettings
 *
 * Fetches settings (decouple from admin)
 */
class StockpackSettings {
    /**
     * @var Singleton The reference the *Singleton* instance of this class
     */
    private static $instance;

    /**
     * @var WeDevs_Settings_API
     */
    public $settings_api;

    /**
     * Returns the *Singleton* instance of this class.
     *
     * @return Singleton The *Singleton* instance.
     */
    public static function get_instance() {
        if ( null === self::$instance ) {
            self::$instance = new self();
        }

        return self::$instance;
    }

    /**
     * Stockpack constructor.
     */
    protected function __construct() {

    }

    public function get_license_state() {
        return $this->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;
    }

}

```
