Skip to content

Commit 5ceeaf1

Browse files
committed
code and sample pages updated
1 parent a169b21 commit 5ceeaf1

File tree

4 files changed

+340
-28
lines changed

4 files changed

+340
-28
lines changed

docs/comfortjob/code-samples.md

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,94 @@ site_name: "Comfort HRM"
88
image: "https://comforthrm.com/assets/images/seo.png"
99
card: "article"
1010
---
11-
# Code Samples
11+
12+
# Comfort Job Plugin – Code Samples
13+
14+
## Add a Job Programmatically
15+
16+
```php
17+
use Comfort\Job\Helpers\ComfortJobHelpers;
18+
19+
// Add a new job
20+
$job_data = [
21+
'title' => 'Software Engineer',
22+
'description' => 'We are looking for a skilled software engineer.',
23+
'status' => 'published',
24+
'salary' => '5000',
25+
'company_id' => 1,
26+
];
27+
$new_job = ComfortJobHelpers::addJob($job_data);
28+
```
29+
30+
## Fetch Job Listings
31+
32+
```php
33+
use Comfort\Job\Helpers\ComfortJobHelpers;
34+
35+
// Get all published jobs
36+
$jobs = ComfortJobHelpers::getJobs([
37+
'status' => 'published',
38+
'limit' => 10,
39+
]);
40+
```
41+
42+
## Export Job Data
43+
44+
```php
45+
use Comfort\Job\Helpers\ComfortJobHelpers;
46+
47+
// Export job data to JSON
48+
$job_id = 123;
49+
$job_data = ComfortJobHelpers::getJob($job_id);
50+
$json_data = json_encode($job_data, JSON_PRETTY_PRINT);
51+
file_put_contents('job_' . $job_id . '.json', $json_data);
52+
```
53+
54+
---
55+
56+
# Comfort Job Pro Addon – Code Samples
57+
58+
## Bookmark a Job
59+
60+
```php
61+
use Comfort\JobPro\Helpers\JobProHelpers;
62+
63+
// Bookmark a job for a user
64+
$user_id = get_current_user_id();
65+
$job_id = 123;
66+
$result = JobProHelpers::bookmarkJob($user_id, $job_id);
67+
```
68+
69+
## Manage Company Pages
70+
71+
```php
72+
use Comfort\JobPro\Helpers\JobProHelpers;
73+
74+
// Create a company manager page
75+
JobProHelpers::create_pages();
76+
```
77+
78+
## Add Custom Dashboard Menus
79+
80+
```php
81+
use Comfort\JobPro\Helpers\JobProHelpers;
82+
83+
// Add a custom menu to the employer dashboard
84+
add_filter('comfortjob_employer_dashboard_menus', function($menus) {
85+
$menus['custom_menu'] = [
86+
'title' => 'Custom Menu',
87+
'url' => admin_url('admin.php?page=custom_menu'),
88+
];
89+
return $menus;
90+
});
91+
```
92+
93+
---
94+
95+
For more details, refer to the plugin documentation or explore the helper classes:
96+
97+
- [`ComfortJobHelpers`]
98+
- [`JobProHelpers`]
1299

13100

14101

docs/comfortjobapp/code-samples.md

Lines changed: 136 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,142 @@ image: "https://comforthrm.com/assets/images/seo.png"
99
card: "article"
1010

1111
---
12-
# Code Samples
1312

13+
# Code Samples for ComfortJobApp & ComfortJobAppPro
14+
15+
## ComfortJobApp Plugin
16+
17+
### 1. Apply Job Form Hooks
18+
19+
Add custom content before and after the job application form using action hooks.
20+
21+
```php
22+
do_action( 'comfortjobapp_apply_job_form_before', $form_id, $job_id, $job, $fields );
23+
?>
24+
<form method="post" id="comfortjobapp-apply-form" enctype="multipart/form-data" class="cbx_form_wrapper">
25+
<?php do_action( 'comfortjobapp_apply_job_form_start', $form_id, $job_id, $job, $fields ); ?>
26+
<input type="hidden" name="job_id" value="<?php echo intval( $job['id'] ); ?>" />
27+
<?php do_action( 'comfortjobapp_apply_job_form_end', $form_id, $job_id, $job, $fields ); ?>
28+
</form>
29+
<?php
30+
do_action( 'comfortjobapp_apply_job_form_after', $form_id, $job_id, $job, $fields );
31+
```
32+
33+
### 2. Get Application Forms
34+
35+
Retrieve a list of application forms for the current user.
36+
37+
```
38+
<?php
39+
$forms = comfortjobapp_get_application_forms([
40+
'limit' => 10,
41+
'page' => 1,
42+
'created_by' => get_current_user_id(),
43+
]);
44+
45+
foreach ( $forms as $form ) {
46+
echo esc_html( $form['title'] );
47+
}
48+
```
49+
### 3. Enqueue Public Scripts
50+
Enqueue public-facing scripts and pass JS translations.
51+
52+
```
53+
<?php
54+
$forms = comfortjobapp_get_application_forms([
55+
'limit' => 10,
56+
'page' => 1,
57+
'created_by' => get_current_user_id(),
58+
]);
59+
60+
foreach ( $forms as $form ) {
61+
echo esc_html( $form['title'] );
62+
}
63+
```
64+
65+
### 4. Delete an Application
66+
Delete an application by ID.
67+
```
68+
<?php
69+
comfortjobapp_delete_application( $application_id );
70+
```
71+
72+
### 5. Delete a Form
73+
74+
```php
75+
// Delete a form by ID (ComfortJobApp)
76+
$result = comfortjobapp_delete_form($form_id);
77+
```
78+
79+
## ComfortJobAppPro Plugin
80+
81+
### 1. Add Employer Dashboard Menu
82+
Add a custom menu to the employer dashboard.
83+
84+
```
85+
<?php
86+
add_filter( 'comfortjobapp_employer_dashboard_menus', function( $menus ) {
87+
$menus['custom_menu'] = [
88+
'title' => esc_html__( 'My Custom Menu', 'comfortjobapppro' ),
89+
'type' => 'callback',
90+
'callback' => 'custom_menu_callback',
91+
];
92+
return $menus;
93+
} );
94+
95+
function custom_menu_callback() {
96+
echo '<h2>' . esc_html__( 'Welcome to My Custom Menu', 'comfortjobapppro' ) . '</h2>';
97+
}
98+
```
99+
100+
### 2. Filter Application Steps
101+
Modify the application steps for the job application process.
102+
103+
```
104+
<?php
105+
add_filter( 'comfortjobapp_steps', function( $steps ) {
106+
$steps['custom_step'] = esc_html__( 'Custom Step', 'comfortjobapppro' );
107+
return $steps;
108+
} );
109+
```
110+
111+
### 3. Custom Email Notification
112+
Customize the email notification sent to applicants.
113+
114+
```
115+
<?php
116+
add_filter( 'comfortjobapp_email_template', function( $template, $application ) {
117+
$template['subject'] = esc_html__( 'Thank you for applying!', 'comfortjobapppro' );
118+
$template['body'] = sprintf(
119+
esc_html__( 'Dear %s, thank you for applying for the %s position.', 'comfortjobapppro' ),
120+
$application['candidate_name'],
121+
$application['job_title']
122+
);
123+
return $template;
124+
}, 10, 2 );
125+
```
126+
127+
### 4. Export Application Data
128+
Export application data in JSON format.
129+
130+
```
131+
<?php
132+
add_action( 'admin_post_export_applications', function() {
133+
$applications = ComfortJobApp::query()->get()->toArray();
134+
$json_data = json_encode( $applications, JSON_PRETTY_PRINT );
135+
136+
header( 'Content-Type: application/json' );
137+
header( 'Content-Disposition: attachment; filename="applications.json"' );
138+
echo $json_data;
139+
exit;
140+
} );
141+
142+
```
143+
144+
For more details, see the plugin documentation or explore the helpers in:
145+
146+
- [`ComfortJobAppHelpers`]
147+
- [`comfortjobapp-functions.php`]
148+
- [`ComfortJobAppProMisc`]
14149

15150

docs/comfortjobapp/hooks-and-filters.md

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,8 @@ card: "article"
1414

1515
### Action Hooks
1616

17-
1. **`comfortjobapp_single_application_details_email`**
18-
- Triggered to display the application details email section.
19-
- **Parameters**:
20-
- `$application_id` (int): The ID of the application.
21-
- `$application_data` (array): The application data.
22-
- **Example**:
23-
```php
24-
add_action( 'comfortjobapp_single_application_details_email', function( $application_id, $application_data ) {
25-
// Custom logic for application email details
26-
}, 10, 2 );
27-
```
28-
29-
2. **`comfortjobapp_single_application_details_url`**
30-
- Triggered to display the application details URL section.
31-
- **Parameters**:
32-
- `$application_id` (int): The ID of the application.
33-
- `$application_data` (array): The application data.
34-
- **Example**:
35-
```php
36-
add_action( 'comfortjobapp_single_application_details_url', function( $application_id, $application_data ) {
37-
// Custom logic for application URL details
38-
}, 10, 2 );
39-
```
4017

41-
3. **`comfortjobapp_wpheading_wrap_right_before`**
18+
1. **`comfortjobapp_wpheading_wrap_right_before`**
4219
- Triggered before the settings import/export button is added.
4320
- **Example**:
4421
```php
@@ -47,7 +24,7 @@ card: "article"
4724
} );
4825
```
4926

50-
4. **`comfortjobapp_admin_enqueue_scripts`**
27+
2. **`comfortjobapp_admin_enqueue_scripts`**
5128
- Triggered to enqueue admin scripts and styles.
5229
- **Example**:
5330
```php

0 commit comments

Comments
 (0)