id ) ) { return; } self::$screen = $page; add_action( $screen->id, array( __CLASS__, 'open' ), 0 ); add_action( $screen->id, array( __CLASS__, 'close' ), PHP_INT_MAX ); } public static function will_render() { return '' !== self::$screen; } public static function rendered() { return self::$rendered; } public static function body_class( $classes ) { return self::will_render() ? $classes . ' kconv-workspace-page kconv-navigation-page' : $classes; } public static function assets() { if ( ! self::will_render() ) { return; } wp_enqueue_style( 'kconv-workspace-navigation', KCONV_URL . 'assets/workspace-navigation.css', array( 'kconv-workspace', 'kconv-readability', 'kconv-onboarding' ), KCONV_VERSION ); wp_enqueue_script( 'kconv-workspace-navigation', KCONV_URL . 'assets/workspace-navigation.js', array( 'kconv-onboarding' ), KCONV_VERSION, true ); wp_localize_script( 'kconv-workspace-navigation', 'KCONV_Navigation', array( 'expand' => __( 'Expand menu', 'killerconversions' ), 'collapse' => __( 'Collapse menu', 'killerconversions' ), ) ); } private static function compact() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only layout selection on an already registered page; no state change or output of the parameter. $edit = isset( $_GET['edit'] ) && is_scalar( $_GET['edit'] ) ? sanitize_text_field( wp_unslash( $_GET['edit'] ) ) : ''; return 'killerconversions' === self::$screen && '' !== $edit; } private static function current() { $map = array( 'killerconversions' => 'forms', 'kconv-start' => 'start', 'kconv-entries' => 'entries', 'kconv-pro-delivery' => 'delivery', 'kconv-conversions' => 'measure', 'kconv-review' => 'review', 'kconv-privacy-emails' => 'privacy', 'kconv-storage' => 'storage', 'kconv-connection-test' => 'connection', 'kconv-team' => 'team', 'kconv-handover' => 'handover', 'kconv-more-plugins' => 'more', 'kconv-license' => 'license', 'killerconversions-pro-updates' => 'license', 'kconv-pro-support' => 'support' ); return isset( $map[ self::$screen ] ) ? $map[ self::$screen ] : 'discover'; } public static function open() { if ( self::$wrapped || ! self::will_render() ) { return; } self::$wrapped = true; echo '
' . esc_html__( 'Skip to workspace content', 'killerconversions' ) . ''; self::render( self::current(), self::compact() ); echo '
'; } public static function close() { if ( ! self::$wrapped ) { return; } echo '
'; self::$wrapped = false; } /** Balanced navigation fragment, also usable by existing renderers outside the page hook. */ public static function render( $current = 'forms', $compact = false ) { if ( self::$rendered || ! self::allowed() ) { return; } self::$rendered = true; $state = KCONV_Presentation::state(); $edition = 'unlocked' === $state ? __( 'PRO', 'killerconversions' ) : ( 'locked' === $state ? __( 'PRO ยท ACTIVATE', 'killerconversions' ) : ( 'mismatch' === $state ? __( 'UPDATE REQUIRED', 'killerconversions' ) : __( 'FREE', 'killerconversions' ) ) ); echo '
' . esc_html( $edition ) . '
'; if ( $compact ) { echo '' . esc_html__( 'Forms', 'killerconversions' ) . '' . esc_html__( '/ Form builder', 'killerconversions' ) . ''; } if ( current_user_can( 'manage_options' ) && in_array( $state, array( 'free', 'locked', 'mismatch' ), true ) ) { $action = KCONV_Presentation::action(); echo '' . esc_html( 'locked' === $state ? __( 'Activate your license', 'killerconversions' ) : $action['label'] ) . '' . esc_html__( ' (opens in a new tab)', 'killerconversions' ) . ''; } KCONV_Onboarding::toolbar( true ); echo '
'; } private static function links() { $admin = current_user_can( 'manage_options' ); $view = KCONV_Core::can( 'kconv_view_entries' ); $pro = KCONV_Presentation::unlocked(); $groups = array( 'workspace' => array(), 'settings' => array(), 'advanced' => array(), 'discover' => array() ); $items = array( array( 'workspace', 'start', 'kconv-start', __( 'Start here', 'killerconversions' ), 'admin-home', $admin ), array( 'workspace', 'forms', 'killerconversions', __( 'Forms', 'killerconversions' ), 'feedback', $admin ), array( 'workspace', 'entries', 'kconv-entries', __( 'Inbox', 'killerconversions' ), 'email-alt', $view ), array( 'workspace', 'measure', 'kconv-conversions', __( 'Insights', 'killerconversions' ), 'chart-area', $pro && $view ), array( 'workspace', 'review', 'kconv-review', __( 'Review workflow', 'killerconversions' ), 'clipboard', $pro && $view ), array( 'settings', 'delivery', 'kconv-pro-delivery', __( 'Delivery', 'killerconversions' ), 'email', KCONV_Core::can( 'kconv_manage_delivery' ) ), array( 'settings', 'privacy', 'kconv-privacy-emails', __( 'Privacy & emails', 'killerconversions' ), 'privacy', $admin ), array( 'settings', 'license', 'kconv-license', __( 'Licence & updates', 'killerconversions' ), 'admin-network', $admin && current_user_can( 'update_plugins' ) ), array( 'advanced', 'storage', 'kconv-storage', __( 'Storage', 'killerconversions' ), 'database', $admin ), array( 'advanced', 'connection', 'kconv-connection-test', __( 'Connection test', 'killerconversions' ), 'admin-links', $pro && $admin ), array( 'advanced', 'team', 'kconv-team', __( 'Team access', 'killerconversions' ), 'groups', $pro && $admin ), array( 'advanced', 'handover', 'kconv-handover', __( 'Client handover', 'killerconversions' ), 'portfolio', $pro && $admin ), array( 'discover', 'discover', 'kconv-pro-discovery', $pro ? __( 'Workflow examples', 'killerconversions' ) : __( 'Explore Pro', 'killerconversions' ), 'star-filled', $admin ), array( 'discover', 'more', 'kconv-more-plugins', __( 'More Plugins', 'killerconversions' ), 'screenoptions', $admin ), ); global $_registered_pages; foreach ( $items as $item ) { $parent = 'killerconversions' === $item[2] ? '' : 'killerconversions'; if ( $item[5] && ! empty( $_registered_pages[ get_plugin_page_hookname( $item[2], $parent ) ] ) ) { $groups[ $item[0] ][ $item[1] ] = array( $item[2], $item[3], $item[4] ); } } return $groups; } private static function link( $key, $link, $current, $compact ) { $selected = $key === $current; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only active navigation marker; no state change or output of the request value. if ( 'discover' === $key && 'kconv-pro-discovery' === self::$screen && ! KCONV_Pro_Discovery::pro_ready() && ! KCONV_Pro_Discovery::previews_hidden() && isset( $_GET['preview'] ) && is_string( $_GET['preview'] ) ) { $selected = false; } echo '' . esc_html( $link[1] ) . '' . ( $compact ? '' . esc_html__( ' (opens in a new tab)', 'killerconversions' ) . '' : '' ) . ''; } }