LLMS_Admin_Metabox::save( int $post_id )

Save field data.


Description Description

Loops through fields and saves the data to postmeta.

Called by $this->save_actions().

This function is dumb. If the fields need to output error messages or do validation override this method and create a custom save method to accommodate the validations or conditions.


Top ↑

Parameters Parameters

$post_id

(int) (Required) WP Post ID of the post being saved.


Top ↑

Return Return

(int) -1 When no user or user is missing required capabilities or when there's no or invalid nonce. 0 during inline saves or ajax requests or when no fields are found for the metabox. 1 if fields were found. This doesn't mean there weren't errors during saving.


Top ↑

Source Source

File: includes/abstracts/abstract.llms.admin.metabox.php

		if ( current_user_can( $this->capability, $this->post->ID ) ) {

			add_meta_box(
				$this->id,
				$this->title,
				array( $this, 'output' ),
				$this->get_screens(),
				$this->context,
				$this->priority,
				is_callable( $this->callback_args ) ? ( $this->callback_args )() : $this->callback_args
			);

		}

	}

	/**
	 * Save field data.
	 *
	 * Loops through fields and saves the data to postmeta.
	 *
	 * Called by $this->save_actions().
	 *
	 * This function is dumb. If the fields need to output error messages or do validation override
	 * this method and create a custom save method to accommodate the validations or conditions.
	 *
	 * @since 3.0.0
	 * @since 3.14.1 Unknown.
	 * @since 3.35.0 Added nonce verification before processing data; only access `$_POST` data via `llms_filter_input()`.
	 * @since 3.36.0 Allow quotes when sanitizing some special fields that store a shortcode.
	 * @since 3.36.1 Check metabox capability during saves.
	 *               Return an `int` depending on return condition.
	 *               Automatically add `FILTER_REQUIRE_ARRAY` flag when sanitizing a `multi` field.
	 * @since 3.37.12 Move field sanitization and updates to the `save_field()` method.
	 * @since 6.0.0 Allow skipping the saving of a field.
	 *
	 * @param int $post_id WP Post ID of the post being saved.

Top ↑

Changelog Changelog

Changelog
Version Description
3.37.12 Move field sanitization and updates to the save_field() method.
3.36.1 Check metabox capability during saves. Return an int depending on return condition. Automatically add FILTER_REQUIRE_ARRAY flag when sanitizing a multi field.
3.36.0 Allow quotes when sanitizing some special fields that store a shortcode.
3.35.0 Added nonce verification before processing data; only access $_POST data via llms_filter_input().
3.14.1 Unknown.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.