$this->get_main_id(),
'action' => 'elementor',
'floating_element' => get_post_meta(
$this->get_main_id(),
static::FLOATING_ELEMENTS_TYPE_META_KEY,
true
),
],
admin_url( 'post.php' )
);
}
public function print_content() {
$plugin = \Elementor\Plugin::$instance;
if ( $plugin->preview->is_preview_mode( $this->get_main_id() ) ) {
// PHPCS - the method builder_wrapper is safe.
echo $plugin->preview->builder_wrapper( '' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} else {
// PHPCS - the method get_content is safe.
echo $this->get_content(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
public function get_location() {
return self::get_property( 'location' );
}
public static function get_type() {
return Floating_Buttons_Module::FLOATING_BUTTONS_DOCUMENT_TYPE;
}
public static function register_post_fields_control( $document ) {}
public static function register_hide_title_control( $document ) {}
public static function get_preview_as_default() {
return '';
}
public static function get_preview_as_options() {
return array_merge(
[
'' => esc_html__( 'Select...', 'elementor-pro' ),
],
Archive::get_preview_as_options(),
Single::get_preview_as_options()
);
}
public function get_name() {
return Floating_Buttons_Module::FLOATING_BUTTONS_DOCUMENT_TYPE;
}
public function filter_admin_row_actions( $actions ) {
unset( $actions['edit'] );
unset( $actions['inline hide-if-no-js'] );
$built_with_elementor = $this->add_built_with_elementor( [] );
if ( isset( $actions['trash'] ) ) {
$delete = $actions['trash'];
unset( $actions['trash'] );
$actions['trash'] = $delete;
}
return $built_with_elementor + $actions;
}
public function add_built_with_elementor( $actions ) {
if ( $this->is_built_with_elementor() && $this->is_editable_by_current_user() ) {
$edit_url = $this->get_edit_url();
if ( ! $this->get_post()->post_content ) {
$edit_url .= '#library';
}
$actions['edit_with_elementor'] = sprintf(
'%2$s',
$edit_url,
esc_html__( 'Edit with Elementor', 'elementor-pro' )
);
}
return $actions;
}
public static function get_title() {
return esc_html__( 'Floating Element', 'elementor-pro' );
}
public static function get_plural_title() {
return esc_html__( 'Floating Elements', 'elementor-pro' );
}
public static function get_create_url() {
return parent::get_create_url();
}
public function save( $data ) {
if ( empty( $data['settings']['template'] ) ) {
$data['settings']['template'] = Page_Templates_Module::TEMPLATE_CANVAS;
}
return parent::save( $data );
}
protected function register_controls() {
parent::register_controls();
$latest_posts = get_posts( [
'posts_per_page' => 1,
'post_type' => 'page',
] );
if ( ! empty( $latest_posts ) ) {
$this->update_control(
'preview_type',
[
'default' => 'single/page',
]
);
$this->update_control(
'preview_id',
[
'default' => $latest_posts[0]->ID,
]
);
}
}
public function admin_columns_content( $column_name ) {
if ( 'elementor_library_type' === $column_name ) {
$admin_filter_url = admin_url( Source_Local::ADMIN_MENU_SLUG . '&elementor_library_type=' . $this->get_name() );
$meta = static::get_floating_element_type( $this->get_main_id() );
printf( '%s', $admin_filter_url, Floating_Buttons_Module::get_floating_elements_types()[ $meta ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
protected function get_remote_library_config() {
$config = [
'type' => 'floating_button',
'default_route' => 'templates/floating-buttons',
'autoImportSettings' => true,
];
return array_replace_recursive( parent::get_remote_library_config(), $config );
}
}