Editor::after_save( array $args = array() )

Description #

Action to do after post is saved.

Add uploaded images to post meta and delete post meta on delete.

Parameters #

  • $args
    array (Optional) Array of arguments. Default value: array()

Changelog #

VersionDescription
4.1.8Introduced.

Source #

File: lib/form/class-editor.php

	public function after_save( $args = array() ) {
		parent::after_save();

		if ( empty( $args ) || empty( $args['post_id'] ) || empty( $this->images ) ) {
			return;
		}

		// Add images to post meta.
		foreach ( $this->images as $img ) {
			add_post_meta( $args['post_id'], 'anspress-image', $img );
		}

		// Delete file from session.
		anspress()->session->delete( 'files' );
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment