This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Settings_Page::update_settings()

Utility function, updates plugin settings


Source

File: includes/libs/admin/page/settings-page.class.php

	private function update_settings(){
		$defaults = $this->options_obj()->get_defaults();

		foreach( $defaults as $key => $val ){
			if( is_numeric( $val ) ){
				if( isset( $_POST[ $key ] ) ){
					$defaults[ $key ] = (int)$_POST[ $key ];
				}
				continue;
			}
			if( is_bool( $val ) ){
				$defaults[ $key ] = isset( $_POST[ $key ] );
				continue;
			}

			// trim strings
			if( isset( $_POST[ $key ] ) ){
				$defaults[ $key ] = trim( $_POST[ $key ] );
			}
		}

		// rewrite
		$plugin_settings = $this->options_obj()->get_options();
		$flush_rules = false;
		if( isset( $_POST['post_slug'] ) ){
			$post_slug = sanitize_title( $_POST['post_slug'] );
			if( !empty( $_POST['post_slug'] ) && $plugin_settings['post_slug'] !== $post_slug ){
				$defaults['post_slug'] = $post_slug;
				$flush_rules = true;
			}else{
				$defaults['post_slug'] = $plugin_settings['post_slug'];
			}
		}

		if( isset( $_POST['taxonomy_slug'] ) ){
			$tax_slug = sanitize_title( $_POST['taxonomy_slug'] );
			/**
			 * Check that taxonomy slug is not empty, is updated and is not the same as the post slug
			 */
			if( !empty( $_POST['taxonomy_slug'] ) && $plugin_settings['taxonomy_slug'] !== $tax_slug && $_POST['taxonomy_slug'] != $defaults['post_slug'] ){
				$defaults['taxonomy_slug'] = $tax_slug;
				$flush_rules = true;
			}else{
				$defaults['taxonomy_slug'] = $plugin_settings['taxonomy_slug'];
			}
		}

		if( isset( $_POST['tag_slug'] ) ){
			$tag_slug = sanitize_title( $_POST['tag_slug'] );
			if( !empty( $_POST['tag_slug'] ) && $plugin_settings['tag_slug'] !== $tag_slug && $_POST['tag_slug'] != $defaults['post_slug'] && $_POST['tag_slug'] != $defaults['taxonomy_slug'] ){
				$defaults['tag_slug'] = $tag_slug;
				$flush_rules = true;
			}else{
				$defaults['tag_slug'] = $plugin_settings['tag_slug'];
			}
		}

		// reset OAuth if user changes the keys
		if( isset( $_POST['vimeo_consumer_key'] ) && isset( $_POST['vimeo_secret_key'] ) ){
			if(
				($_POST['vimeo_consumer_key'] != $plugin_settings['vimeo_consumer_key']) ||
				($_POST['vimeo_secret_key'] != $plugin_settings['vimeo_secret_key'] )
			){
				$defaults['oauth_token'] = '';
				$defaults['oauth_secret'] = '';
			}
		}else{
			// if the consumer keys are not sent by POST, set the old values
			$defaults['vimeo_consumer_key'] = $plugin_settings['vimeo_consumer_key'];
			$defaults['vimeo_secret_key'] = $plugin_settings['vimeo_secret_key'];
			$defaults['oauth_token'] = $plugin_settings['oauth_token'];
		}

		$this->options_obj()->update_options( $defaults );

		if( $flush_rules ){
			// create rewrite ( soft )
			// register custom post
			Plugin::instance()->get_cpt()->register_post();
			flush_rewrite_rules();
		}

		return $defaults;
	}

Start your video site now!

Manage and coordinate your Vimeo channels, albums or videos with your WordPress website. Perfect fit for membership, portfolio, online courses or any type of video collection.

Get Vimeotheque PRO!