'; }, ); add_options_page('Apeari', 'Apeari', 'manage_options', 'apeari-settings', [ APEARI_Settings::class, 'render', ]); }); add_action('admin_enqueue_scripts', [__CLASS__, 'assets']); add_action('admin_post_apeari_settings', [APEARI_Settings::class, 'save']); add_action('admin_post_apeari_ownership', [APEARI_Ownership::class, 'submit']); add_action('admin_post_apeari_clear_history', static function () { if (!current_user_can('manage_options')) { wp_die(esc_html__('Brak dostępu.', 'apeari')); } check_admin_referer('apeari_clear_history'); APEARI_Conversations::clear(); APEARI_Privacy::erase_sessions(get_current_user_id()); wp_safe_redirect(admin_url('options-general.php?page=apeari-settings')); exit(); }); add_filter( 'plugin_action_links_' . plugin_basename(APEARI_PATH . 'apeari.php'), static fn($links) => array_merge( [ '' . esc_html__('Otwórz edytor', 'apeari') . '', '' . esc_html__('Ustawienia', 'apeari') . '', ], $links, ), ); add_action('wp_enqueue_scripts', static function () { wp_enqueue_style('apeari-gallery', APEARI_URL . 'assets/css/gallery.css', [], APEARI_VERSION); }); } public static function assets(string $hook): void { if ($hook !== 'appearance_page_apeari') { return; } wp_enqueue_media(); foreach ( ['wp-components', 'wp-block-editor', 'wp-block-library', 'wp-block-library-theme'] as $style ) { wp_enqueue_style($style); } wp_enqueue_style( 'apeari-editor', APEARI_URL . 'assets/css/editor.css', [], APEARI_VERSION . '.' . filemtime(APEARI_PATH . 'assets/css/editor.css'), ); wp_enqueue_style( 'apeari-workspace', APEARI_URL . 'assets/css/workspace.css', ['apeari-editor'], APEARI_VERSION . '.' . filemtime(APEARI_PATH . 'assets/css/workspace.css'), ); wp_enqueue_script( 'apeari-core', APEARI_URL . 'assets/js/editor/core.js', ['wp-blocks', 'wp-block-library', 'wp-i18n'], APEARI_VERSION . '.' . filemtime(APEARI_PATH . 'assets/js/editor/core.js'), true, ); wp_enqueue_script( 'apeari-native', APEARI_URL . 'assets/js/editor/native-editor.js', ['wp-element', 'wp-components', 'wp-block-editor', 'wp-block-library', 'wp-i18n'], APEARI_VERSION . '.' . filemtime(APEARI_PATH . 'assets/js/editor/native-editor.js'), true, ); wp_enqueue_script( 'apeari-tour', APEARI_URL . 'assets/js/editor/tour.js', ['wp-i18n'], APEARI_VERSION . '.' . filemtime(APEARI_PATH . 'assets/js/editor/tour.js'), true, ); wp_enqueue_script( 'apeari-editor', APEARI_URL . 'assets/js/editor/editor.js', ['apeari-core', 'apeari-native', 'apeari-tour', 'wp-i18n'], APEARI_VERSION . '.' . filemtime(APEARI_PATH . 'assets/js/editor/editor.js'), true, ); wp_add_inline_script( 'apeari-editor', 'window.APEARI_CONFIG=' . wp_json_encode([ 'api' => rest_url('apeari/v1/'), 'nonce' => wp_create_nonce('wp_rest'), 'version' => APEARI_VERSION, 'home' => home_url('/'), 'dashboard' => admin_url(), 'settings' => admin_url('options-general.php?page=apeari-settings'), 'showTour' => !get_user_meta( get_current_user_id(), 'apeari_editor_tour_seen_' . get_current_blog_id(), true, ), 'mode' => get_option('apeari_mode', 'apeari'), 'consent' => (bool) get_option('apeari_ai_consent', false), 'logo' => APEARI_URL . 'assets/images/branding/apeari-ai-transparent-v3.png', 'storageKey' => 'apeari-session-' . get_current_blog_id() . '-' . get_current_user_id(), 'blocks' => APEARI_Block_Policy::BLOCKS, ]) . ';', 'before', ); foreach (['apeari-core', 'apeari-native', 'apeari-tour', 'apeari-editor'] as $handle) { wp_set_script_translations($handle, 'apeari', APEARI_PATH . 'languages'); } } }