get_container_attributes() ); ?>>
print_elements( $elements_data ); ?>
sprintf( esc_html__( '%s Settings', 'elementor' ), static::get_title() ),
];
}
/**
* @since 2.0.0
* @access public
*/
public function get_post() {
return $this->post;
}
/**
* @since 2.0.0
* @access public
*/
public function get_permalink() {
return get_permalink( $this->get_main_id() );
}
/**
* @since 2.0.8
* @access public
*/
public function get_content( $with_css = false ) {
return Plugin::$instance->frontend->get_builder_content( $this->post->ID, $with_css );
}
/**
* @since 2.0.0
* @access public
*/
public function delete() {
if ( 'revision' === $this->post->post_type ) {
$deleted = wp_delete_post_revision( $this->post );
} else {
$deleted = wp_delete_post( $this->post->ID );
}
return $deleted && ! is_wp_error( $deleted );
}
public function force_delete() {
$deleted = wp_delete_post( $this->post->ID, true );
return $deleted && ! is_wp_error( $deleted );
}
/**
* On import update dynamic content (e.g. post and term IDs).
*
* @since 3.8.0
*
* @param array $config The config of the passed element.
* @param array $data The data that requires updating/replacement when imported.
* @param array|null $controls The available controls.
*
* @return array Element data.
*/
public static function on_import_update_dynamic_content( array $config, array $data, $controls = null ) : array {
foreach ( $config as &$element_config ) {
$element_instance = Plugin::$instance->elements_manager->create_element_instance( $element_config );
if ( is_null( $element_instance ) ) {
continue;
}
if ( $element_instance->has_own_method( 'on_import_replace_dynamic_content' ) ) {
// TODO: Remove this check in the future.
$element_config = $element_instance::on_import_replace_dynamic_content( $element_config, $data['post_ids'] );
} else {
$element_config = $element_instance::on_import_update_dynamic_content( $element_config, $data, $element_instance->get_controls() );
}
$element_config['elements'] = static::on_import_update_dynamic_content( $element_config['elements'], $data );
}
return $config;
}
/**
* Save editor elements.
*
* Save data from the editor to the database.
*
* @since 2.0.0
* @access protected
*
* @param array $elements
*/
protected function save_elements( $elements ) {
$editor_data = $this->get_elements_raw_data( $elements );
// We need the `wp_slash` in order to avoid the unslashing during the `update_post_meta`
$json_value = wp_slash( wp_json_encode( $editor_data ) );
// Don't use `update_post_meta` that can't handle `revision` post type
$is_meta_updated = update_metadata( 'post', $this->post->ID, '_elementor_data', $json_value );
/**
* Before saving data.
*
* Fires before Elementor saves data to the database.
*
* @since 1.0.0
*
* @param string $status Post status.
* @param int|bool $is_meta_updated Meta ID if the key didn't exist, true on successful update, false on failure.
*/
do_action( 'elementor/db/before_save', $this->post->post_status, $is_meta_updated );
Plugin::$instance->db->save_plain_text( $this->post->ID );
$elements_iteration_actions = $this->get_elements_iteration_actions();
if ( $elements_iteration_actions ) {
$this->iterate_elements( $elements, $elements_iteration_actions, 'save' );
}
/**
* After saving data.
*
* Fires after Elementor saves data to the database.
*
* @since 1.0.0
*
* @param int $post_id The ID of the post.
* @param array $editor_data Sanitize posted data.
*/
do_action( 'elementor/editor/after_save', $this->post->ID, $editor_data );
}
/**
* @since 2.0.0
* @access public
*
* @param int $user_id Optional. User ID. Default value is `0`.
*
* @return bool|int
*/
public function get_autosave_id( $user_id = 0 ) {
if ( ! $user_id ) {
$user_id = get_current_user_id();
}
$autosave = Utils::get_post_autosave( $this->post->ID, $user_id );
if ( $autosave ) {
return $autosave->ID;
}
return false;
}
public function save_version() {
if ( ! defined( 'IS_ELEMENTOR_UPGRADE' ) ) {
// Save per revision.
$this->update_meta( '_elementor_version', ELEMENTOR_VERSION );
/**
* Document version save.
*
* Fires when document version is saved on Elementor.
* Will not fire during Elementor Upgrade.
*
* @since 2.5.12
*
* @param \Elementor\Core\Base\Document $this The current document.
*
*/
do_action( 'elementor/document/save_version', $this );
}
}
/**
* @since 2.3.0
* @access public
*/
public function save_template_type() {
return $this->update_main_meta( self::TYPE_META_KEY, $this->get_name() );
}
/**
* @since 2.3.0
* @access public
*/
public function get_template_type() {
return $this->get_main_meta( self::TYPE_META_KEY );
}
/**
* @since 2.0.0
* @access public
*
* @param string $key Meta data key.
*
* @return mixed
*/
public function get_main_meta( $key ) {
return get_post_meta( $this->get_main_id(), $key, true );
}
/**
* @since 2.0.4
* @access public
*
* @param string $key Meta data key.
* @param string $value Meta data value.
*
* @return bool|int
*/
public function update_main_meta( $key, $value ) {
return update_post_meta( $this->get_main_id(), $key, $value );
}
/**
* @since 2.0.4
* @access public
*
* @param string $key Meta data key.
* @param string $value Optional. Meta data value. Default is an empty string.
*
* @return bool
*/
public function delete_main_meta( $key, $value = '' ) {
return delete_post_meta( $this->get_main_id(), $key, $value );
}
/**
* @since 2.0.0
* @access public
*
* @param string $key Meta data key.
*
* @return mixed
*/
public function get_meta( $key ) {
return get_post_meta( $this->post->ID, $key, true );
}
/**
* @since 2.0.0
* @access public
*
* @param string $key Meta data key.
* @param mixed $value Meta data value.
*
* @return bool|int
*/
public function update_meta( $key, $value ) {
// Use `update_metadata` in order to work also with revisions.
return update_metadata( 'post', $this->post->ID, $key, $value );
}
/**
* @since 2.0.3
* @access public
*
* @param string $key Meta data key.
* @param string $value Meta data value.
*
* @return bool
*/
public function delete_meta( $key, $value = '' ) {
// Use `delete_metadata` in order to work also with revisions.
return delete_metadata( 'post', $this->post->ID, $key, $value );
}
/**
* @since 2.0.0
* @access public
*/
public function get_last_edited() {
$post = $this->post;
$autosave_post = $this->get_autosave();
if ( $autosave_post ) {
$post = $autosave_post->get_post();
}
$date = date_i18n( _x( 'M j, H:i', 'revision date format', 'elementor' ), strtotime( $post->post_modified ) );
$display_name = get_the_author_meta( 'display_name', $post->post_author );
if ( $autosave_post || 'revision' === $post->post_type ) {
/* translators: 1: Saving date, 2: Author display name. */
$last_edited = sprintf( esc_html__( 'Draft saved on %1$s by %2$s', 'elementor' ), '