PHPackages                             arraypress/edd-register-log-views - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. arraypress/edd-register-log-views

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

arraypress/edd-register-log-views
=================================

A library for easily registering custom log views in Easy Digital Downloads

051PHP

Since Dec 4Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/arraypress/edd-register-log-views)[ Packagist](https://packagist.org/packages/arraypress/edd-register-log-views)[ RSS](/packages/arraypress-edd-register-log-views/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

EDD Custom Log Views Registration Library
=========================================

[](#edd-custom-log-views-registration-library)

A comprehensive PHP library for registering custom log views and order log links in Easy Digital Downloads. This library provides a robust solution for programmatically creating and managing log views with custom capabilities and flexible organization.

Features
--------

[](#features)

- 🚀 Easy registration of custom log views
- 🔗 Order detail page log link integration
- 🔒 Capability-based access control
- 📁 Automatic file path management
- 🎯 Flexible view organization
- 🛠️ Simple helper functions
- ✅ Type safety with strict typing

Requirements
------------

[](#requirements)

- PHP 7.4 or higher
- WordPress 6.7.1 or higher
- Easy Digital Downloads 3.0 or higher

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require arraypress/edd-register-log-views
```

Basic Usage
-----------

[](#basic-usage)

### Registering a Custom Log View

[](#registering-a-custom-log-view)

```
edd_register_custom_log_view( [
    'id'         => 'audio_stats',
    'title'      => 'Audio Stats',
    'class_name' => 'Audio_Stats_Log_Table',
    'file'       => 'admin/logs/class-audio-stats-log-table.php',
    'capability' => 'view_shop_reports'
] );
```

### Adding an Order Log Link

[](#adding-an-order-log-link)

```
edd_register_log_order_link( [
    'id'    => 'audio-stats',
    'label' => __( 'View Audio Stats', 'your-plugin' ),
    'view'  => 'audio_stats'
] );
```

Configuration Options
---------------------

[](#configuration-options)

### Custom Log View Options

[](#custom-log-view-options)

OptionTypeRequiredDescriptionidstringYesUnique identifier for the log viewtitlestringYesDisplay text in the log views menuclass\_namestringYesFully qualified class name for the list tablefilestringYesPath to the class file (relative to base path)capabilitystringNoRequired capability (defaults to 'view\_shop\_reports')base\_pathstringNoCustom base path for file location### Order Log Link Options

[](#order-log-link-options)

OptionTypeRequiredDescriptionidstringYesUnique identifier for the log linklabelstringYesText to display for the linkviewstringYesThe log view parameter to link tourl\_callbackcallableNoCustom callback to generate URLdisplay\_callbackcallableNoCallback to conditionally display linkcapabilitystringNoRequired capability (defaults to 'view\_shop\_reports')Advanced Usage
--------------

[](#advanced-usage)

### Custom URL Callback

[](#custom-url-callback)

```
edd_register_log_order_link( [
    'id'           => 'custom-logs',
    'label'        => 'Custom Logs',
    'view'         => 'custom_view',
    'url_callback' => function( $order ) {
        return add_query_arg( [
            'page'     => 'custom-page',
            'order_id' => $order->id
        ], admin_url( 'admin.php' ) );
    }
] );
```

### Conditional Display

[](#conditional-display)

```
edd_register_log_order_link( [
    'id'               => 'audio-stats',
    'label'            => 'Audio Stats',
    'view'             => 'audio_stats',
    'display_callback' => function( $order ) {
        // Only show if order has audio products
        foreach ( $order->items as $item ) {
            $download = edd_get_download( $item->product_id );
            if ( has_audio_files( $download ) ) {
                return true;
            }
        }
        return false;
    }
] );
```

Direct Class Usage
------------------

[](#direct-class-usage)

For more control, you can use the classes directly:

```
use ArrayPress\EDD\Register\LogViewsManager;
use ArrayPress\EDD\Register\LogOrderLink;

// Get manager instances
$log_views = edd_custom_log_views();
$order_links = edd_log_order_links();

// Register views
$log_views->register( [
    'id'         => 'custom_logs',
    'title'      => 'Custom Logs',
    'class_name' => 'Custom_Logs_Table',
    'file'       => 'class-custom-logs-table.php'
] );

// Register links
$order_links->register( [
    'id'    => 'custom-link',
    'label' => 'Custom Link',
    'view'  => 'custom_logs'
] );
```

File Organization
-----------------

[](#file-organization)

By default, the library looks for log table classes relative to your plugin's root directory:

```
your-plugin/
├── admin/
│   └── logs/
│       └── class-audio-stats-log-table.php
├── includes/
└── your-plugin.php

```

You can customize this by providing a custom `base_path` in the view configuration.

Complete Example
----------------

[](#complete-example)

```
