_dealer_settings::dealership_options_page_init()


Source

File: includes/class-dealership-options.php

			$sites = get_sites( array( 'network' => 1, 'limit' => 1000 ) );
			foreach( $sites as $site )
			{
				switch_to_blog( $site->blog_id );
				global $wp_rewrite;
				$wp_rewrite->init(); //important...
				$wp_rewrite->flush_rules();
				restore_current_blog();
			}
		}
	}

	/**
	 * register_javascript
	 * 
	 * Registers a JavaScript file that powers the settings page.
	 *
	 * @return void
	 */
	function register_javascript()
	{
		wp_register_script(
			'invp_page_settings',
			plugins_url( '/js/page-settings.min.js', INVP_PLUGIN_FILE_PATH ),
			array( 'jquery' )
		);
	}
	
	/**
	 * add_options_page
	 * 
	 * Adds an options page to the dashboard to hold all this plugin's settings.
	 *
	 * @return void
	 */
	public function add_options_page()
	{
		if ( post_type_exists( INVP::POST_TYPE ) )
		{
			add_submenu_page('edit.php?post_type=' . INVP::POST_TYPE,
				__( 'Options', 'inventory-presser' ), // page_title
				__( 'Options', 'inventory-presser' ), // menu_title
				'manage_options', // capability
				'dealership-options', // menu_slug
				array( $this, 'options_page_content' ) // function
			);
			return;
		}

		add_options_page(
			__( 'Inventory Presser', 'inventory-presser' ), // page_title
			__( 'Inventory Presser', 'inventory-presser' ), // menu_title
			'manage_options', // capability
			'dealership-options', // menu_slug
			array( $this, 'options_page_content' ) // function
		);
	}
	
	/**
	 * add_settings
	 * 
	 * Registers sections and settings using the Settings API.
	 *
	 * @return void
	 */
	public function add_settings()
	{
		register_setting(
			'dealership_options_option_group', // option_group
			INVP::OPTION_NAME, // option_name
			array( $this, 'sanitize_options' ) // sanitize_callback
		);

		/**
		 * SECTION Settings
		 */
		add_settings_section(
			'dealership_options_setting_section', // id
			__( 'General', 'inventory-presser' ), // title
			'__return_empty_string', // callback
			'dealership-options-admin' // page
		);

		//Price Display
		add_settings_field(
			'price_display', // id
			__( 'Price Display', 'inventory-presser' ), // title
			array( $this, 'callback_price_display' ), // callback
			'dealership-options-admin', // page
			'dealership_options_setting_section' // section
		);

		//[x] Include sold vehicles
		add_settings_field(
			'include_sold_vehicles', // id
			__( 'Sold Vehicles', 'inventory-presser' ), // title
			array( $this, 'callback_include_sold_vehicles' ), // callback
			'dealership-options-admin', // page
			'dealership_options_setting_section' // section
		);

		//[x] Show all taxonomies under Vehicles menu in Dashboard
		add_settings_field(
			'show_all_taxonomies', // id
			__( 'Show All Taxonomies', 'inventory-presser' ), // title
			array( $this, 'callback_show_all_taxonomies' ), // callback
			'dealership-options-admin', // page
			'dealership_options_setting_section' // section
		);

		//[x] Skip trash when deleting vehicles and delete permanently
		add_settings_field(
			'skip_trash', // id
			__( 'Skip Trash', 'inventory-presser' ), // title
			array( $this, 'callback_skip_trash' ), // callback
			'dealership-options-admin', // page
			'dealership_options_setting_section' // section
		);

		/**
		 * SECTION Listings
		 */
		add_settings_section(
			'dealership_options_section_listings', // id
			__( 'Listings', 'inventory-presser' ), // title
			'__return_empty_string', // callback
			'dealership-options-admin' // page
		);

		//Sort vehicles by [Field] in [Ascending] order
		add_settings_field(
			'sort_vehicles_by', // id
			__( 'Sort Vehicles By', 'inventory-presser' ), // title
			array( $this, 'callback_sort_vehicles_by' ), // callback
			'dealership-options-admin', // page
			'dealership_options_section_listings' // section
		);

		/**
		 * Create an additional inventory archive at pmgautosales.com/[cash-deals]
		 * that contains vehicles that have a value for field [Down Payment]
		 */
		add_settings_field(