Admin_Apple_Settings::fetch_settings PHP Method

fetch_settings() public method

Creates a new \Apple_Exporter\Settings instance and loads it with WordPress' saved settings.
public fetch_settings ( )
    public function fetch_settings()
    {
        if (is_null($this->loaded_settings)) {
            $settings = new Settings();
            $wp_settings = get_option(self::$option_name);
            // If this option doesn't exist, either the site has never installed this plugin
            // or they may be using an old version with individual options.
            // To be safe, attempt to migrate values.
            // This will happen only once.
            if (false === $wp_settings) {
                $wp_settings = $this->migrate_settings($settings);
            }
            foreach ($settings->all() as $key => $value) {
                $wp_value = empty($wp_settings[$key]) ? $value : $wp_settings[$key];
                $settings->set($key, $wp_value);
            }
            $this->loaded_settings = $settings;
        }
        return apply_filters('apple_news_loaded_settings', $this->loaded_settings);
    }

Usage Example

    /**
     * HTML to display after the section.
     *
     * @return string
     * @access public
     */
    public function after_section()
    {
        ?>
			</div>
			<div class="apple-news-settings-preview">
				<?php 
        // Build sample content
        $settings = new Admin_Apple_Settings();
        $title = sprintf('<h1 class="apple-news-title apple-news-component">%s</h1>', __('Sample Article', 'apple-news'));
        $cover = sprintf('<div class="apple-news-cover">%s</div>', __('Cover', 'apple-news'));
        // Build the byline
        $author = __('John Doe', 'apple-news');
        $date = date('M j, Y g:i A');
        $export = new Apple_Actions\Index\Export($settings->fetch_settings());
        $byline = sprintf('<div class="apple-news-byline apple-news-component">%s</div>', $export->format_byline(null, $author, $date));
        // Get the order of the top components
        $component_order = self::get_value('meta_component_order');
        foreach ($component_order as $component) {
            echo wp_kses(${$component}, self::$allowed_html);
        }
        ?>
				<div class="apple-news-component">
				<p><span class="apple-news-dropcap">L</span>orem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sagittis, <a href="#">augue vitae iaculis euismod</a>, libero nulla pellentesque quam, non venenatis massa odio id dolor.</p>
				<div class="apple-news-pull-quote">Lorem ipsum dolor sit amet.</div>
				<p>Praesent eget odio vel sapien scelerisque euismod. Phasellus eros sapien, rutrum ac nibh nec, tristique commodo neque.</p>
				<h2>Quisque efficitur</h2>
				<p>Quisque efficitur sit amet ex et venenatis. Morbi nisi nisi, ornare id iaculis eget, pulvinar ac dolor.</p>
				<p>In eu la	cus porttitor, pellentesque diam et, tristique elit. Mauris justo odio, efficitur sit amet aliquet id, aliquam placerat turpis.</p>
				</div>
			</div>
		</div>
		<?php 
    }
All Usage Examples Of Admin_Apple_Settings::fetch_settings