500)throw new RuntimeException('Invalid page placement.');$ids=[];foreach($r['pages'] as $id){if(!is_int($id)||get_post_type($id)!=='page'||get_post_status($id)!=='publish')throw new RuntimeException('Select published pages.');$ids[]=$id;}$out[$type]=['enabled'=>$r['enabled'],'scope'=>$r['scope'],'pages'=>array_values(array_unique($ids))];} update_option('yooty_floating_placement',$out,false); } $pages=get_posts(['post_type'=>'page','post_status'=>'publish','numberposts'=>500,'orderby'=>'title','order'=>'ASC']);return ['floating'=>get_option('yooty_floating_placement',[]),'pages'=>array_map(static fn($p)=>['id'=>$p->ID,'title'=>get_the_title($p)],$pages)]; } add_action('wp_footer',static function(){ if(is_admin()||is_feed()||is_preview())return; $settings=get_option('yooty_floating_placement',[]);foreach(yooty_wp_float_types() as $type){$r=$settings[$type]??[];if(empty($r['enabled']))continue;if(($r['scope']??'all')==='selected'&&!in_array(get_queried_object_id(),$r['pages']??[],true))continue;echo do_shortcode('[yooty_widget type="'.$type.'"]');} },5); add_action('init',static function(){ wp_register_script('yooty-widget-block',plugins_url('blocks.js',__FILE__),['wp-blocks','wp-element','wp-components','wp-block-editor'],'0.6.0',true); register_block_type('yooty/widget',['api_version'=>3,'editor_script'=>'yooty-widget-block','attributes'=>['type'=>['type'=>'string','default'=>'booking'],'display'=>['type'=>'string','default'=>'inline'],'mode'=>['type'=>'string','default'=>''],'view'=>['type'=>'string','default'=>''],'surface'=>['type'=>'string','default'=>''],'appearance'=>['type'=>'string','default'=>'']],'render_callback'=>static function($attrs){$type=$attrs['type']??'booking';if(!isset(yooty_growth_widget_catalog()[$type]))return '';$args='';foreach(['display'=>['inline','modal'],'mode'=>['calculator','booking'],'view'=>['classic','visual','scroll'],'surface'=>['flat','glass','transparent'],'appearance'=>['auto','light','dark']] as $key=>$allowed){if(in_array($attrs[$key]??'', $allowed,true))$args.=' '.$key.'="'.$attrs[$key].'"';}return do_shortcode('[yooty_widget type="'.$type.'"'.$args.']');}]); }); add_action('elementor/widgets/register',static function($manager){ if(!class_exists('Elementor\\Widget_Base'))return;require_once __DIR__.'/elementor-widget.php';$manager->register(new Yooty_Elementor_Widget()); });