MP_BaseLeadSettings::save_leads_fields( int $post_id )

Save comment lead field.


Parameters Parameters

$post_id

(int) (Required) post id


Top ↑

Source Source

File: mortgage-platform/Inc/Base/MP_BaseLeadSettings.php

	public function save_leads_fields( $post_id ) {

		if ( ! isset( $_POST[ MortgagePlatform::$prefix . 'comment' ] ) ||
			 ! isset( $_POST[ MortgagePlatform::$prefix . 'address' ] ) ||
			 ! isset( $_POST[ MortgagePlatform::$prefix . 'city' ] ) ||
			 ! isset( $_POST[ MortgagePlatform::$prefix . 'state' ] ) ||
			 ! isset( $_POST[ MortgagePlatform::$prefix . 'zip' ] ) ||
			 ! isset( $_POST[ MortgagePlatform::$prefix . 'country' ] )
		) {
			return;
		}
		if ( ! wp_verify_nonce( $_POST[ MortgagePlatform::$prefix . 'leads' ], plugin_basename( __FILE__ ) ) ) {
			return;
		}
		if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
			return;
		}
		if ( ! current_user_can( 'edit_post', $post_id ) ) {
			return;
		}

		$field_name = sanitize_text_field( $_POST[ MortgagePlatform::$prefix . 'comment' ] );
		$address    = array(
			'address' => sanitize_text_field( $_POST[ MortgagePlatform::$prefix . 'address' ] ),
			'city'    => sanitize_text_field( $_POST[ MortgagePlatform::$prefix . 'city' ] ),
			'state'   => sanitize_text_field( $_POST[ MortgagePlatform::$prefix . 'state' ] ),
			'zip'     => sanitize_text_field( $_POST[ MortgagePlatform::$prefix . 'zip' ] ),
			'country' => sanitize_text_field( $_POST[ MortgagePlatform::$prefix . 'country' ] ),
		);

		update_post_meta( $post_id, MortgagePlatform::$prefix . 'comment', $field_name );
		update_post_meta( $post_id, MortgagePlatform::$prefix . 'address', $address );

	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.