# Plugin documentation for Developers

updated (2025-04-08) for version 1.0.4

## Plugin API

The plugin provides several interfaces and methods for developers to interact with it via code. Here are the suggested methods for interacting with the plugin when developing a related plugin or wp theme:

### 1. Interface: `ExodoxLogin`

The main class of the plugin "ExodoxLogin" grant access to a few methods for use in a wp theme or related plugin.

You can obtain a valid object instance of the class using the `Exodox()` function. Methods can then be called on contained api objects in the style of `Exodox()->functions->get_the_lock_status()`

#### API Methods:

#### Functions

`Exodox()->functions` currently give access to the following functions. Some of the functions require the optional api key to be sett in the plugin settings. 

- `get_host_user_info()`: Retrieves the user information regarding the currently linked publisher (requires the api key).
- `lock_url($url, $price, $duration)`: locks a url using the currently linked publisher (requires the api key).
- `update_locked_url($url, $price, $duration)`: update the lock of a locked url using the currently linked publisher (requires the api key).
- `lock_post($post_id, $price, $duration)`: locks a post using the currently linked publisher (requires the api key).
- `update_locked_post($post_id, $price, $duration)`: update the lock of a locked post using the currently linked publisher (requires the api key).
- `get_host_user_info()`: Retrieves the user information regarding the currently linked publisher (requires the api key).
- `is_path_locked($path)`: Checks if a path is locked, using the current url as the default.
- `get_the_lock_status()`: Retrieves the lock status of the current url for the current user.
- `get_locked_path_data($path)`: Retrieves the lock data of the path. warning: this function relies on the cache of locked paths and will always return null if the path has not been checked first by another function
- `is_post_locked($post)`: Checks if a post is locked.
- `get_the_post_lock_status($post)`: Retrieves the lock status of the post.
- `get_locked_post_data($post)`: Retrieves the lock data of the post. warning: this function relies on the cache of locked paths and will always return null if the path has not been checked first by another function

#### Example 1:
```php
	if (class_exists('ExodoxLogin')) {
		$is_exodox_locked = Exodox()->functions->is_post_locked($post);
	} else {
		$is_exodox_locked = false;
	}
```

#### Example 2:
```php
	if (class_exists('ExodoxLogin')) {
		$is_exodox_locked = Exodox()->functions->get_the_post_lock_status($post);
	} else {
		$is_exodox_locked = 'not-locked';
	}
```

#### Example 3:
```php
	if (class_exists('ExodoxLogin')) {
		$responce = Exodox()->functions->lock_post($post_id,1000,$days * 86400000);
	}

	if ( isset($response['error']) ) {
		// print $response['error'] message
	} else {
		//success!
	}
```

### 2. Interface: `Template System `

The Exodox wp plugin uses a template system similar to the what is used in many other wp plugins. When the plugin needs to print some html it checks the "templates" folder for a html template file. Many of the templates files can be overridden by placing a file under "yourtheme/exodox/" with the same name and file structure.  

#### Public templates:

- `redirect-lock/locked-page`
- `redirect-lock/locked-page-footer`
- `redirect-lock/locked-page-header`
- `lock/action-button`
- `lock/top-message`
- `lock/shortcuts`
- `lock/price-info`
- `lock/bottom-message`
- `lock/post-image`
- `js/js-timer`
