Skip to content

Commit a169b21

Browse files
committed
hooks & filter page updated in 3 plugins
1 parent 6610440 commit a169b21

File tree

6 files changed

+632
-53
lines changed

6 files changed

+632
-53
lines changed

docs/.vitepress/config.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export default {
168168

169169
'/comfortjobapp/': [
170170
{
171-
text: 'Comfort Resume',
171+
text: 'Comfort Job Application',
172172
collapsible: false,
173173
},
174174
{
@@ -182,13 +182,6 @@ export default {
182182
{ text: 'Code Samples', link: '/comfortjobapp/code-samples' },
183183
],
184184
},
185-
{
186-
text: 'Shortcode',
187-
collapsible: true,
188-
items: [
189-
{ text: '9 Shortcodes', link: '/comfortjobapp/shortcodes' },
190-
],
191-
},
192185
{
193186
text: 'User Guide',
194187
collapsible: true,
@@ -201,20 +194,6 @@ export default {
201194
],
202195
}
203196
],
204-
// '/comfortjobapp/': [
205-
// {
206-
// text: 'Comfort Job Application',
207-
// collapsible: true,
208-
// items: [
209-
// { text: 'How to install', link: '/comfortjobapp/how-to-install' },
210-
// { text: 'How to Translate', link: '/comfortjobapp/how-to-translate' },
211-
// { text: 'Template Override', link: '/comfortjobapp/template-override' },
212-
// { text: 'Shortcodes', link: '/comfortjobapp/shortcodes' },
213-
// { text: 'Hooks and Filters', link: '/comfortjobapp/hooks-and-filters' },
214-
// { text: 'Code Samples', link: '/comfortjobapp/code-samples' },
215-
// ],
216-
// },
217-
// ],
218197
},
219198
// you can disable the previous and next page here
220199
docFooter: {

docs/comfortjob/hooks-and-filters.md

Lines changed: 217 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,49 +21,239 @@ Hooks in Comfort Job are points in the code where developers can add custom func
2121
- register_activation_hook(__FILE__, 'activate_comfortjob');
2222
- register_deactivation_hook(__FILE__, 'deactivate_comfortjob');
2323

24+
## ComfortJob Plugin
25+
2426
### Action Hooks
2527

26-
Action hooks allow developers to execute custom functions at specific points in the plugin's code. These functions can perform actions such as displaying content, updating data, or sending notifications. Action hooks in Comfort Job are typically triggered by events such as saving a job listing or deleting a company.
28+
1. **`comfortjob_job_single_start`**
29+
- Triggered at the start of the single job template.
30+
- **Parameters**:
31+
- `$job` (array): The job data.
32+
- **Example**:
33+
```php
34+
add_action( 'comfortjob_job_single_start', function( $job ) {
35+
// Custom logic for single job start
36+
} );
37+
```
38+
39+
2. **`comfortjob_job_single_end`**
40+
- Triggered at the end of the single job template.
41+
- **Parameters**:
42+
- `$job` (array): The job data.
43+
- **Example**:
44+
```php
45+
add_action( 'comfortjob_job_single_end', function( $job ) {
46+
// Custom logic for single job end
47+
} );
48+
```
2749

28-
Here are some common action hooks in Comfort Job:
50+
3. **`comfortjob_job_details_before`**
51+
- Triggered before the job details are displayed.
52+
- **Parameters**:
53+
- `$job` (array): The job data.
54+
- **Example**:
55+
```php
56+
add_action( 'comfortjob_job_details_before', function( $job ) {
57+
// Custom logic before job details
58+
} );
59+
```
2960

30-
- `comfortjob_before_job_listing`: Triggered before a job listing is displayed on the frontend.
31-
- `comfortjob_after_job_listing`: Triggered after a job listing is displayed on the frontend.
32-
- `comfortjob_job_saved`: Triggered after a job listing is saved in the database.
61+
4. **`comfortjob_job_details_after`**
62+
- Triggered after the job details are displayed.
63+
- **Parameters**:
64+
- `$job` (array): The job data.
65+
- **Example**:
66+
```php
67+
add_action( 'comfortjob_job_details_after', function( $job ) {
68+
// Custom logic after job details
69+
} );
70+
```
3371

34-
Developers can create custom functions and hook them into these action hooks to add new functionality to Comfort Job.
72+
5. **`comfortjob_job_published`**
73+
- Triggered when a job is published.
74+
- **Parameters**:
75+
- `$job_id` (int): The ID of the published job.
76+
- `$status` (string): The status of the job.
77+
- `$user_id` (int): The ID of the user who published the job.
78+
- `$data` (array): Additional data.
79+
- **Example**:
80+
```php
81+
add_action( 'comfortjob_job_published', function( $job_id, $status, $user_id, $data ) {
82+
// Custom logic after job is published
83+
}, 10, 4 );
84+
```
85+
86+
---
3587

3688
### Filter Hooks
3789

38-
Filter hooks allow developers to modify or filter data before it is displayed or processed by the plugin. Filters in Comfort Job are used to customize the output of job listings, companies, or other data displayed by the plugin. Developers can use filter hooks to change text, alter URLs, or modify data structures.
90+
1. **`comfortjob_settings_fields`**
91+
- Filters the settings fields for the plugin.
92+
- **Parameters**:
93+
- `$fields` (array): The settings fields.
94+
- **Example**:
95+
```php
96+
add_filter( 'comfortjob_settings_fields', function( $fields ) {
97+
$fields['new_field'] = [
98+
'name' => 'new_field',
99+
'label' => 'New Field',
100+
'type' => 'text',
101+
];
102+
return $fields;
103+
} );
104+
```
39105

40-
Here are some common filter hooks in Comfort Job:
106+
2. **`comfortjob_js_translation`**
107+
- Filters the JavaScript translations for the plugin.
108+
- **Parameters**:
109+
- `$translations` (array): Translations for JavaScript.
110+
- **Example**:
111+
```php
112+
add_filter( 'comfortjob_js_translation', function( $translations ) {
113+
$translations['custom_key'] = 'Custom Value';
114+
return $translations;
115+
} );
116+
```
41117

42-
- `comfortjob_job_title`: Filters the title of a job listing.
43-
- `comfortjob_company_name`: Filters the name of a company.
44-
- `comfortjob_job_location`: Filters the location of a job listing.
118+
3. **`comfortjob_single_job`**
119+
- Filters the single job data.
120+
- **Parameters**:
121+
- `$job` (array): The job data.
122+
- `$job_id` (int): The job ID.
123+
- **Example**:
124+
```php
125+
add_filter( 'comfortjob_single_job', function( $job, $job_id ) {
126+
$job['custom_field'] = 'Custom Value';
127+
return $job;
128+
}, 10, 2 );
129+
```
45130

46-
Developers can create custom filter functions and hook them into these filter hooks to customize the output of Comfort Job.
131+
4. **`comfortjob_employer_dashboard_menus`**
132+
- Filters the employer dashboard menus.
133+
- **Parameters**:
134+
- `$menus` (array): The dashboard menus.
135+
- **Example**:
136+
```php
137+
add_filter( 'comfortjob_employer_dashboard_menus', function( $menus ) {
138+
$menus['custom_menu'] = [
139+
'title' => 'Custom Menu',
140+
'url' => 'custom-url',
141+
];
142+
return $menus;
143+
} );
144+
```
47145

48-
## Using Hooks and Filters
146+
5. **`comfortjob_default_file_mimes`**
147+
- Filters the default file MIME types for uploads.
148+
- **Parameters**:
149+
- `$mimes` (string): The default MIME types.
150+
- **Example**:
151+
```php
152+
add_filter( 'comfortjob_default_file_mimes', function( $mimes ) {
153+
return $mimes . ',application/pdf';
154+
} );
155+
```
49156

50-
To use hooks and filters in Comfort Job, developers can create custom functions in their theme's `functions.php` file or in a custom plugin. These functions should be defined with the `add_action()` or `add_filter()` functions, specifying the hook name and the custom function to be executed.
157+
---
51158

52-
For example, to add a custom function to the `comfortjob_after_job_listing` action hook, developers can use the following code:
159+
## ComfortJobPro Plugin
53160

54-
```php
55-
function my_custom_function() {
56-
// Custom code to be executed after a job listing is displayed
57-
}
58-
add_action('comfortjob_after_job_listing');
59-
```
161+
### Action Hooks
162+
163+
1. **`comfortjob_company_delete_after`**
164+
- Triggered after a company is deleted.
165+
- **Parameters**:
166+
- `$company_id` (int): The ID of the deleted company.
167+
- `$data` (array): Additional data.
168+
- **Example**:
169+
```php
170+
add_action( 'comfortjob_company_delete_after', function( $company_id, $data ) {
171+
// Custom logic after company deletion
172+
}, 10, 2 );
173+
```
60174

61-
### Custom Actions
175+
2. **`comfortjob_wpheading_wrap_right_before`**
176+
- Triggered before the settings import/export button is added.
177+
- **Example**:
178+
```php
179+
add_action( 'comfortjob_wpheading_wrap_right_before', function() {
180+
// Add custom content before the button
181+
} );
182+
```
62183

63-
- `do_action('comfortjob_before_main_content');`
64-
- `do_action('comfortjob_after_main_content');`
65-
- `do_action('comfortjob_job_single_start', $job);`
66-
- `do_action('comfortjob_job_single_end', $job);`
184+
3. **`comfortjob_settings_form_before`**
185+
- Triggered before the settings form is displayed.
186+
- **Example**:
187+
```php
188+
add_action( 'comfortjob_settings_form_before', function() {
189+
// Add custom content before the settings form
190+
} );
191+
```
192+
193+
---
67194

195+
### Filter Hooks
196+
197+
1. **`comfortjob_guest_login_forms`**
198+
- Filters the guest login forms.
199+
- **Parameters**:
200+
- `$forms` (array): The login forms.
201+
- **Example**:
202+
```php
203+
add_filter( 'comfortjob_guest_login_forms', function( $forms ) {
204+
$forms['custom_form'] = 'Custom Form HTML';
205+
return $forms;
206+
} );
207+
```
208+
209+
2. **`comfortjob_max_job_per_user`**
210+
- Filters the maximum number of jobs a user can create.
211+
- **Parameters**:
212+
- `$max` (int): Maximum number of jobs.
213+
- `$user_id` (int): The user ID.
214+
- **Example**:
215+
```php
216+
add_filter( 'comfortjob_max_job_per_user', function( $max, $user_id ) {
217+
return 10; // Set max jobs to 10
218+
}, 10, 2 );
219+
```
220+
221+
3. **`comfortjob_rest_routes`**
222+
- Filters the REST API routes for the plugin.
223+
- **Parameters**:
224+
- `$routes` (array): The REST API routes.
225+
- **Example**:
226+
```php
227+
add_filter( 'comfortjob_rest_routes', function( $routes ) {
228+
$routes['custom_route'] = 'Custom Route Handler';
229+
return $routes;
230+
} );
231+
```
232+
233+
4. **`comfortjob_login_html`**
234+
- Filters the login HTML for the plugin.
235+
- **Parameters**:
236+
- `$html` (string): The login HTML.
237+
- `$args` (array): Additional arguments.
238+
- **Example**:
239+
```php
240+
add_filter( 'comfortjob_login_html', function( $html, $args ) {
241+
return $html . '<p>Custom Login Message</p>';
242+
}, 10, 2 );
243+
```
244+
245+
5. **`comfortjob_register_html`**
246+
- Filters the registration HTML for the plugin.
247+
- **Parameters**:
248+
- `$html` (string): The registration HTML.
249+
- `$args` (array): Additional arguments.
250+
- **Example**:
251+
```php
252+
add_filter( 'comfortjob_register_html', function( $html, $args ) {
253+
return $html . '<p>Custom Registration Message</p>';
254+
}, 10, 2 );
255+
```
256+
257+
---
68258

69-
**Last modified:** December 26, 2025
259+
This documentation provides an overview of the available hooks and filters in the `ComfortJob` and `ComfortJobPro` plugins. Use these to extend or customize the functionality as needed.

docs/comfortjob/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ card: "article"
1111

1212
# Comfort Job Documentation
1313

14-
Welcome to the Comfort Job main page.
14+
ComfortJob allows you to create and manage job listings directly from your WordPress site. Employers can post jobs, and candidates can apply seamlessly.
1515

1616

0 commit comments

Comments
 (0)