__( 'Customer sign-in', 'anar-toolkit' ), 'reset' => __( 'SMS password recovery', 'anar-toolkit' ), 'two_factor' => __( 'Two-step verification', 'anar-toolkit' ), 'login_log' => __( 'Login SMS report', 'anar-toolkit' ), 'recovery' => __( 'Abandoned carts', 'anar-toolkit' ), 'orders' => __( 'Order notifications', 'anar-toolkit' ) ), \Anar\Login\Marketing\Settings::modules() ); } public static function url( $key ) { if ( in_array( $key, array( 'login', 'reset', 'two_factor' ), true ) ) { return admin_url( 'admin.php?page=anar-login-settings' . ( 'two_factor' === $key ? '§ion=security' : '' ) ); } if ( 'login_log' === $key ) { return admin_url( 'admin.php?page=anar-toolkit-commerce&tab=messages' ); } if ( 'recovery' === $key || 'orders' === $key ) { return admin_url( 'admin.php?page=anar-toolkit-commerce&tab=settings' ); } return admin_url( 'admin.php?page=anar-toolkit-' . $key ); } public function menu() { add_submenu_page( 'anar-login', __( 'Features', 'anar-toolkit' ), __( 'Features', 'anar-toolkit' ), 'manage_options', 'anar-login', array( self::class, 'render' ), 0 ); $flags = Features::all(); $commerce = new \Anar\Login\Commerce\Admin( new \Anar\Login\Commerce\Settings(), new \Anar\Login\Commerce\Repository(), new \Anar\Login\Messaging\ProviderRegistry( new Settings() ) ); if ( $flags['recovery'] || $flags['orders'] || $flags['login_log'] || Features::queue_needed() ) { add_submenu_page( 'anar-login', __( 'Commerce toolkit', 'anar-toolkit' ), __( 'Commerce toolkit', 'anar-toolkit' ), 'manage_options', 'anar-toolkit-commerce', array( $commerce, 'render' ) ); } if ( ! $flags['recovery'] && ! $flags['orders'] && ! $flags['login_log'] && ! Features::queue_needed() ) { add_submenu_page( null, __( 'Commerce toolkit', 'anar-toolkit' ), __( 'Commerce toolkit', 'anar-toolkit' ), 'manage_options', 'anar-toolkit-commerce', array( $commerce, 'render' ) ); } foreach ( Features::marketing_keys() as $key ) { if ( $flags[ $key ] && class_exists( 'WooCommerce' ) ) { add_submenu_page( 'anar-login', self::labels()[ $key ], self::labels()[ $key ], 'manage_options', 'anar-toolkit-' . $key, array( $commerce, 'render' ) ); } } add_submenu_page( 'anar-login', __( 'Connection settings', 'anar-toolkit' ), __( 'Connection settings', 'anar-toolkit' ), 'manage_options', 'anar-login-settings', array( new SettingsPage( new Settings(), new \Anar\Login\Messaging\ProviderRegistry( new Settings() ) ), 'render' ) ); add_submenu_page( 'anar-login', __( 'Other features', 'anar-toolkit' ), __( 'Other features', 'anar-toolkit' ), 'manage_options', 'anar-features-other', array( $this, 'render' ) ); } public function assets( $hook ) { if ( false !== strpos( $hook, 'anar-' ) ) { wp_enqueue_style( 'anar-features', ANAR_LOGIN_URL . 'assets/css/features.css', array(), ANAR_LOGIN_VERSION ); } } public static function render() { if ( ! current_user_can( 'manage_options' ) ) { return; } $flags = Features::all(); $labels = self::labels(); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only catalog selection. $other_first = isset( $_GET['page'] ) && 'anar-features-other' === $_GET['page']; $groups = $other_first ? array( false => __( 'Other features', 'anar-toolkit' ), true => __( 'Active features', 'anar-toolkit' ) ) : array( true => __( 'Active features', 'anar-toolkit' ), false => __( 'Other features', 'anar-toolkit' ) ); ?>


$heading ) : ?>

$label ) : if ( (bool) $flags[ $key ] !== (bool) $active ) { continue; } ?>