@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 ) { $last_edited = sprintf( /* translators: 1: Saving date, 2: Author display name. */ esc_html__( 'Draft saved on %1$s by %2$s', 'elementor' ), '', $display_name ); } else { $last_edited = sprintf( /* translators: 1: Editing date, 2: Author display name. */ esc_html__( 'Last edited on %1$s by %2$s', 'elementor' ), '', $display_name ); } return $last_edited; } /** * @return bool */ public function is_saving() { return $this->is_saving; } /** * @param $is_saving * * @return $this */ public function set_is_saving( $is_saving ) { $this->is_saving = $is_saving; return $this; } /** * @since 2.0.0 * @access public * * @param array $data * * @throws \Exception If the post does not exist. */ public function __construct( array $data = [] ) { if ( $data ) { if ( empty( $data['post_id'] ) ) { $this->post = new \WP_Post( (object) [] ); } else { $this->post = get_post( $data['post_id'] ); if ( ! $this->post ) { throw new \Exception( sprintf( 'Post ID #%s does not exist.', $data['post_id'] ), Exceptions::NOT_FOUND ); } } // Each Control_Stack is based on a unique ID. $data['id'] = $data['post_id']; if ( ! isset( $data['settings'] ) ) { $data['settings'] = []; } $saved_settings = get_post_meta( $this->post->ID, '_elementor_page_settings', true ); if ( ! empty( $saved_settings ) && is_array( $saved_settings ) ) { $data['settings'] += $saved_settings; } } parent::__construct( $data ); } /* * Get Export Data * * Filters a document's data on export * * @since 3.2.0 * @access public * * @return array The data to export */ public function get_export_data() { $content = Plugin::$instance->db->iterate_data( $this->get_elements_data(), function( $element_data ) { $element_data['id'] = Utils::generate_random_string(); $element = Plugin::$instance->elements_manager->create_element_instance( $element_data ); // If the widget/element does not exist, like a plugin that creates a widget but deactivated. if ( ! $element ) { return null; } return $this->process_element_import_export( $element, 'on_export' ); } ); return [ 'content' => $content, 'settings' => $this->get_data( 'settings' ), 'metadata' => $this->get_export_metadata(), ]; } public function get_export_summary() { return [ 'title' => $this->post->post_title, 'doc_type' => $this->get_name(), 'thumbnail' => get_the_post_thumbnail_url( $this->post ), ]; } /* * Get Import Data * * Filters a document's data on import * * @since 3.2.0 * @access public * * @return array The data to import */ public function get_import_data( array $data ) { $data['content'] = Plugin::$instance->db->iterate_data( $data['content'], function( $element_data ) { $element = Plugin::$instance->elements_manager->create_element_instance( $element_data ); // If the widget/element isn't exist, like a plugin that creates a widget but deactivated if ( ! $element ) { return null; } return $this->process_element_import_export( $element, 'on_import' ); } ); if ( ! empty( $data['settings'] ) ) { $template_model = new Page_Model( [ 'id' => 0, 'settings' => $data['settings'], ] ); $page_data = $this->process_element_import_export( $template_model, 'on_import' ); $data['settings'] = $page_data['settings']; } return $data; } /** * Import * * Allows to import an external data to a document * * @since 3.2.0 * @access public * * @param array $data */ public function import( array $data ) { $data = $this->get_import_data( $data ); $this->save( [ 'elements' => $data['content'], 'settings' => $data['settings'], ] ); if ( $data['import_settings']['thumbnail'] ) { $attachment = Plugin::$instance->templates_manager->get_import_images_instance()->import( [ 'url' => $data['import_settings']['thumbnail'] ] ); set_post_thumbnail( $this->get_main_post(), $attachment['id'] ); } if ( ! empty( $data['metadata'] ) ) { foreach ( $data['metadata'] as $key => $value ) { $this->update_meta( $key, $value ); } } } public function process_element_import_export( Controls_Stack $element, $method, $element_data = null ) { if ( null === $element_data ) { $element_data = $element->get_data(); } if ( method_exists( $element, $method ) ) { // TODO: Use the internal element data without parameters. $element_data = $element->{$method}( $element_data ); } foreach ( $element->get_controls() as $control ) { $control_class = Plugin::$instance->controls_manager->get_control( $control['type'] ); // If the control isn't exist, like a plugin that creates the control but deactivated. if ( ! $control_class ) { return $element_data; } // Do not add default value to the final settings, if there is no value at the // data before the methods `on_import` or `on_export` called. $has_value = isset( $element_data['settings'][ $control['name'] ] ); if ( $has_value && method_exists( $control_class, $method ) ) { $element_data['settings'][ $control['name'] ] = $control_class->{$method}( $element_data['settings'][ $control['name'] ], $control ); } // On Export, check if the control has an argument 'export' => false. if ( 'on_export' === $method && isset( $control['export'] ) && false === $control['export'] ) { unset( $element_data['settings'][ $control['name'] ] ); } } return $element_data; } protected function get_export_metadata() { $metadata = get_post_meta( $this->get_main_id() ); foreach ( $metadata as $meta_key => $meta_value ) { if ( is_protected_meta( $meta_key, 'post' ) ) { unset( $metadata[ $meta_key ] ); continue; } $metadata[ $meta_key ] = $meta_value[0]; } return $metadata; } protected function get_remote_library_config() { $config = [ 'type' => 'block', 'default_route' => 'templates/blocks', 'category' => $this->get_name(), 'autoImportSettings' => false, ]; return $config; } /** * @since 2.0.4 * @access protected * * @param $settings */ protected function save_settings( $settings ) { $page_settings_manager = SettingsManager::get_settings_managers( 'page' ); $page_settings_manager->ajax_before_save_settings( $settings, $this->post->ID ); $page_settings_manager->save_settings( $settings, $this->post->ID ); } /** * @since 2.1.3 * @access protected */ protected function print_elements( $elements_data ) { // Collect all data updaters that should be updated on runtime. $runtime_elements_iteration_actions = $this->get_runtime_elements_iteration_actions(); if ( $runtime_elements_iteration_actions ) { $this->iterate_elements( $elements_data, $runtime_elements_iteration_actions, 'render' ); } foreach ( $elements_data as $element_data ) { $element = Plugin::$instance->elements_manager->create_element_instance( $element_data ); if ( ! $element ) { continue; } $element->print_element(); } } protected function register_document_controls() { $this->start_controls_section( 'document_settings', [ 'label' => esc_html__( 'General Settings', 'elementor' ), 'tab' => Controls_Manager::TAB_SETTINGS, ] ); $this->add_control( 'post_title', [ 'label' => esc_html__( 'Title', 'elementor' ), 'type' => Controls_Manager::TEXT, 'default' => $this->post->post_title, 'label_block' => true, ] ); $post_type_object = get_post_type_object( $this->post->post_type ); $can_publish = $post_type_object && current_user_can( $post_type_object->cap->publish_posts ); $is_published = self::STATUS_PUBLISH === $this->post->post_status || self::STATUS_PRIVATE === $this->post->post_status; if ( $is_published || $can_publish || ! Plugin::$instance->editor->is_edit_mode() ) { $statuses = $this->get_post_statuses(); if ( 'future' === $this->get_main_post()->post_status ) { $statuses['future'] = esc_html__( 'Future', 'elementor' ); } $this->add_control( 'post_status', [ 'label' => esc_html__( 'Status', 'elementor' ), 'type' => Controls_Manager::SELECT, 'default' => $this->get_main_post()->post_status, 'options' => $statuses, ] ); } $this->end_controls_section(); } protected function get_post_statuses() { return get_post_statuses(); } protected function get_have_a_look_url() { return $this->get_permalink(); } public function handle_revisions_changed( $post_has_changed, $last_revision, $post ) { // In case default, didn't determine the changes. if ( ! $post_has_changed ) { $last_revision_id = $last_revision->ID; $last_revision_document = Plugin::instance()->documents->get( $last_revision_id ); $post_document = Plugin::instance()->documents->get( $post->ID ); $last_revision_settings = $last_revision_document->get_settings(); $post_settings = $post_document->get_settings(); // TODO: Its better to add crc32 signature for each revision and then only compare one part of the checksum. $post_has_changed = $last_revision_settings !== $post_settings; } return $post_has_changed; } private function add_handle_revisions_changed_filter() { add_filter( 'wp_save_post_revision_post_has_changed', [ $this, 'handle_revisions_changed' ], 10, 3 ); } private function remove_handle_revisions_changed_filter() { remove_filter( 'wp_save_post_revision_post_has_changed', [ $this, 'handle_revisions_changed' ] ); } private function get_runtime_elements_iteration_actions() { $runtime_elements_iteration_actions = []; $elements_iteration_actions = $this->get_elements_iteration_actions(); foreach ( $elements_iteration_actions as $elements_iteration_action ) { if ( $elements_iteration_action->is_action_needed() ) { $runtime_elements_iteration_actions[] = $elements_iteration_action; } } return $runtime_elements_iteration_actions; } private function iterate_elements( $elements, $elements_iteration_actions, $mode ) { $unique_page_elements = []; foreach ( $elements_iteration_actions as $elements_iteration_action ) { $elements_iteration_action->set_mode( $mode ); } Plugin::$instance->db->iterate_data( $elements, function( array $element_data ) use ( &$unique_page_elements, $elements_iteration_actions ) { $element_type = 'widget' === $element_data['elType'] ? $element_data['widgetType'] : $element_data['elType']; $element = Plugin::$instance->elements_manager->create_element_instance( $element_data ); if ( $element ) { if ( ! in_array( $element_type, $unique_page_elements, true ) ) { $unique_page_elements[] = $element_type; foreach ( $elements_iteration_actions as $elements_iteration_action ) { $elements_iteration_action->unique_element_action( $element ); } } foreach ( $elements_iteration_actions as $elements_iteration_action ) { $elements_iteration_action->element_action( $element ); } } return $element_data; } ); foreach ( $elements_iteration_actions as $elements_iteration_action ) { $elements_iteration_action->after_elements_iteration(); } } private function get_elements_iteration_actions() { if ( ! $this->elements_iteration_actions ) { $this->elements_iteration_actions[] = new Assets_Iteration_Action( $this ); } return $this->elements_iteration_actions; } }
Fatal error: Uncaught Error: Class 'Elementor\Core\Base\Document' not found in /home/sportuga/public_html/wp-content/plugins/elementor/includes/plugin.php:712 Stack trace: #0 /home/sportuga/public_html/wp-content/plugins/elementor/includes/plugin.php(647): Elementor\Plugin->init_components() #1 /home/sportuga/public_html/wp-includes/class-wp-hook.php(324): Elementor\Plugin->init('') #2 /home/sportuga/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #3 /home/sportuga/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #4 /home/sportuga/public_html/wp-settings.php(695): do_action('init') #5 /home/sportuga/public_html/wp-config.php(102): require_once('/home/sportuga/...') #6 /home/sportuga/public_html/wp-load.php(50): require_once('/home/sportuga/...') #7 /home/sportuga/public_html/wp-blog-header.php(13): require_once('/home/sportuga/...') #8 /home/sportuga/public_html/index.php(17): require('/home/sportuga/...') #9 {main} thrown in /home/sportuga/public_html/wp-content/plugins/elementor/includes/plugin.php on line 712