Skip to content

Commit 108e77b

Browse files
committed
Make admin settings template filterable
1 parent be2b076 commit 108e77b

File tree

2 files changed

+193
-191
lines changed

2 files changed

+193
-191
lines changed

functions/admin-settings.php

Lines changed: 4 additions & 191 deletions
Original file line numberDiff line numberDiff line change
@@ -133,195 +133,8 @@ function codeable_settings_callback() {
133133
// Hacky way to save settings without a second redirect...
134134
$_SERVER['REQUEST_URI'] = remove_query_arg( [ 'action', '_wpnonce', 'success', 'error' ] );
135135

136-
?>
137-
<div class="wrap wpcable_wrap">
138-
<form method="post" action="options.php">
139-
<?php settings_fields( 'wpcable_group' ); ?>
140-
<?php do_settings_sections( 'wpcable_group' ); ?>
141-
142-
<h2><?php esc_html_e( 'Task list', 'wpcable' ); ?></h2>
143-
<p>
144-
<?php
145-
printf(
146-
esc_html__( 'Adjust behavior of %syour task list%s.', 'wpcable' ),
147-
'<a href="' . admin_url( 'admin.php?page=codeable_tasks') . '">',
148-
'</a>'
149-
);
150-
?>
151-
</p>
152-
153-
<table class="form-table">
154-
<tbody>
155-
<tr>
156-
<th scope="row">
157-
<label class="wpcable_label" for="wpcable_cancel_after_days">
158-
<?php esc_html_e( 'Flag task as canceled', 'wpcable' ); ?>
159-
</label>
160-
</th>
161-
<td>
162-
<input type="number" name="wpcable_cancel_after_days" id="wpcable_cancel_after_days" min="14" max="720" value="<?php echo (int) $wpcable_cancel_after_days; ?>" /> days
163-
<p class="description">
164-
<?php esc_html_e( 'Adds the "canceled" flag to a task that had no activity for the given number of days. Default is 180 days.', 'wpcable' ); ?>
165-
</p>
166-
</td>
167-
</tr>
168-
<tr>
169-
<th scope="row">
170-
<label class="wpcable_label" for="wpcable_tasks_stop_at_page">
171-
<?php esc_html_e( 'Stop pulling tasks after page', 'wpcable' ); ?>
172-
</label>
173-
</th>
174-
<td>
175-
<input type="number" name="wpcable_tasks_stop_at_page" id="wpcable_tasks_stop_at_page" min="0" max="720" value="<?php echo (int) $wpcable_tasks_stop_at_page; ?>" /> pages
176-
<p class="description">
177-
<?php esc_html_e( 'Pull a specific number of pages for the tasks section. Default is 0 (pull all). We suggest setting it to 0 to retrieve ALL tasks the first time, and then set it to 1 or 2 to retrieve/update only the latest 1/2 pages.', 'wpcable' ); ?>
178-
</p>
179-
</td>
180-
</tr>
181-
</tbody>
182-
</table>
183-
184-
<hr />
185-
<h2><?php esc_html_e( 'Estimates', 'wpcable' ); ?></h2>
186-
<p>
187-
<?php
188-
printf(
189-
esc_html__( 'Customize the defaults for %syour estimates%s.', 'wpcable' ),
190-
'<a href="' . admin_url( 'admin.php?page=codeable_estimate') . '">',
191-
'</a>'
192-
);
193-
?>
194-
</p>
195-
196-
<table class="form-table">
197-
<tbody>
198-
<tr>
199-
<th scope="row">
200-
<label class="wpcable_label" for="wpcable_rate">
201-
<?php esc_html_e( 'Your hourly rate', 'wpcable' ); ?>
202-
</label>
203-
</th>
204-
<td>
205-
<input
206-
id="wpcable_rate"
207-
type="number"
208-
min="35"
209-
max="1000"
210-
style="width:80px"
211-
name="wpcable_rate"
212-
value="<?php echo (float) $wpcable_rate; ?>"
213-
/> $
214-
<p class="description">
215-
<?php esc_html_e( 'Used as default value on the estimate page', 'wpcable' ); ?>
216-
</p>
217-
</td>
218-
</tr>
219-
<tr>
220-
<th scope="row">
221-
<label class="wpcable_label" for="wpcable_fee_type">
222-
<?php esc_html_e( 'Fee calculation', 'wpcable' ); ?>
223-
</label>
224-
</th>
225-
<td>
226-
<select id="wpcable_fee_type" name="wpcable_fee_type">
227-
<option value="full" <?php selected( 'full', $wpcable_fee_type ); ?>>
228-
<?php esc_html_e( 'My rate is what I want to get paid, without any fees', 'wpcable' ); ?>
229-
</option>
230-
<option value="client" <?php selected( 'client', $wpcable_fee_type ); ?>>
231-
<?php esc_html_e( 'My rate includes my fee (10%) but not the client fee', 'wpcable' ); ?>
232-
</option>
233-
<option value="none" <?php selected( 'none', $wpcable_fee_type ); ?>>
234-
<?php esc_html_e( 'My rate includes all fees', 'wpcable' ); ?>
235-
</option>
236-
</select>
237-
<p class="description">
238-
<?php esc_html_e( 'This information is used on the estimate page', 'wpcable' ); ?>
239-
</p>
240-
</td>
241-
</tr>
242-
</tbody>
243-
</table>
244-
245-
<hr />
246-
<h2><?php esc_html_e( 'Codeable API', 'wpcable' ); ?></h2>
247-
<p>
248-
<?php esc_html_e( 'Log into your Codeable account.', 'wpcable' ); ?><br />
249-
<?php esc_html_e( 'During login this plugin obtains a user-specific auth-token which is used to fetch data from the API later. Your password is not saved anywhere!', 'wpcable' ); ?>
250-
</p>
251-
252-
<table class="form-table">
253-
<tbody>
254-
<?php if ( codeable_api_logged_in() ) : ?>
255-
<tr>
256-
<th scope="row">
257-
<label class="wpcable_label" for="wpcable_email">
258-
<?php esc_html_e( 'Account', 'wpcable' ); ?>
259-
</label>
260-
</th>
261-
<td>
262-
<p>
263-
<?php
264-
printf(
265-
__( 'You are currently logged in as %s', 'wpcable' ),
266-
'<b>' . $wpcable_email . '</b>'
267-
);
268-
?>
269-
<input type="hidden" name="wpcable_email" value="<?php echo esc_attr( $wpcable_email ); ?>" />
270-
</p>
271-
<p>
272-
<a href="<?php echo esc_url( $logout_url ); ?>" class="button" ><?php esc_html_e( 'Log out', 'wpcable' ); ?></a>
273-
<a href="<?php echo esc_url( $flush_data_url ); ?>" class="button danger" onclick="return confirm('<?php echo esc_attr( $flush_data_warning ); ?>')"><?php esc_html_e( 'Clear all data', 'wpcable' ); ?></a>
274-
</p>
275-
</td>
276-
</tr>
277-
<?php else : ?>
278-
<tr>
279-
<th scope="row">
280-
<label class="wpcable_label" for="wpcable_email">
281-
<?php esc_html_e( 'Email', 'wpcable' ); ?>
282-
</label>
283-
</th>
284-
<td>
285-
<input
286-
id="wpcable_email"
287-
type="email"
288-
name="wpcable_email"
289-
class="regular-text"
290-
value="<?php echo esc_attr( $wpcable_email ); ?>"
291-
autocomplete="email"
292-
/>
293-
<p class="description"><?php esc_html_e( 'This is the email address you use to log into app.codeable.com', 'wpcable' ); ?></p>
294-
</td>
295-
</tr>
296-
<tr>
297-
<th scope="row">
298-
<label class="wpcable_label" for="wpcable_password">
299-
<?php esc_html_e( 'Password', 'wpcable' ); ?>
300-
</label>
301-
</th>
302-
<td>
303-
<input
304-
id="wpcable_password"
305-
type="password"
306-
name="wpcable_password"
307-
class="regular-text"
308-
value=""
309-
autocomplete="password"
310-
/>
311-
<p class="description"><?php esc_html_e( 'Your Codeable password is not stored anywhere!<br />With your password we generate an auth_token, that is saved encrypted in your DB.', 'wpcable' ); ?></p>
312-
</td>
313-
</tr>
314-
<?php endif; ?>
315-
</tbody>
316-
</table>
317-
318-
<div class="action-buttons">
319-
<?php submit_button( __( 'Save Changes', 'wpcable' ) ); ?>
320-
</div>
321-
322-
</form>
323-
324-
<?php codeable_last_fetch_info(); ?>
325-
</div>
326-
<?php
136+
$admin_settings_template = apply_filters('wpcable_admin_settings_template', WPCABLE_TEMPLATE_DIR.'/admin-settings.php') ;
137+
ob_start();
138+
require_once $admin_settings_template;
139+
echo ob_get_clean();
327140
}

templates/admin-settings.php

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
<div class="wrap wpcable_wrap">
2+
<form method="post" action="options.php">
3+
<?php settings_fields( 'wpcable_group' ); ?>
4+
<?php do_settings_sections( 'wpcable_group' ); ?>
5+
6+
<h2><?php esc_html_e( 'Task list', 'wpcable' ); ?></h2>
7+
<p>
8+
<?php
9+
printf(
10+
esc_html__( 'Adjust behavior of %syour task list%s.', 'wpcable' ),
11+
'<a href="' . admin_url( 'admin.php?page=codeable_tasks') . '">',
12+
'</a>'
13+
);
14+
?>
15+
</p>
16+
17+
<table class="form-table">
18+
<tbody>
19+
<tr>
20+
<th scope="row">
21+
<label class="wpcable_label" for="wpcable_cancel_after_days">
22+
<?php esc_html_e( 'Flag task as canceled', 'wpcable' ); ?>
23+
</label>
24+
</th>
25+
<td>
26+
<input type="number" name="wpcable_cancel_after_days" id="wpcable_cancel_after_days" min="14" max="720" value="<?php echo (int) $wpcable_cancel_after_days; ?>" /> days
27+
<p class="description">
28+
<?php esc_html_e( 'Adds the "canceled" flag to a task that had no activity for the given number of days. Default is 180 days.', 'wpcable' ); ?>
29+
</p>
30+
</td>
31+
</tr>
32+
<tr>
33+
<th scope="row">
34+
<label class="wpcable_label" for="wpcable_tasks_stop_at_page">
35+
<?php esc_html_e( 'Stop pulling tasks after page', 'wpcable' ); ?>
36+
</label>
37+
</th>
38+
<td>
39+
<input type="number" name="wpcable_tasks_stop_at_page" id="wpcable_tasks_stop_at_page" min="0" max="720" value="<?php echo (int) $wpcable_tasks_stop_at_page; ?>" /> pages
40+
<p class="description">
41+
<?php esc_html_e( 'Pull a specific number of pages for the tasks section. Default is 0 (pull all). We suggest setting it to 0 to retrieve ALL tasks the first time, and then set it to 1 or 2 to retrieve/update only the latest 1/2 pages.', 'wpcable' ); ?>
42+
</p>
43+
</td>
44+
</tr>
45+
</tbody>
46+
</table>
47+
48+
<hr />
49+
<h2><?php esc_html_e( 'Estimates', 'wpcable' ); ?></h2>
50+
<p>
51+
<?php
52+
printf(
53+
esc_html__( 'Customize the defaults for %syour estimates%s.', 'wpcable' ),
54+
'<a href="' . admin_url( 'admin.php?page=codeable_estimate') . '">',
55+
'</a>'
56+
);
57+
?>
58+
</p>
59+
60+
<table class="form-table">
61+
<tbody>
62+
<tr>
63+
<th scope="row">
64+
<label class="wpcable_label" for="wpcable_rate">
65+
<?php esc_html_e( 'Your hourly rate', 'wpcable' ); ?>
66+
</label>
67+
</th>
68+
<td>
69+
<input
70+
id="wpcable_rate"
71+
type="number"
72+
min="35"
73+
max="1000"
74+
style="width:80px"
75+
name="wpcable_rate"
76+
value="<?php echo (float) $wpcable_rate; ?>"
77+
/> $
78+
<p class="description">
79+
<?php esc_html_e( 'Used as default value on the estimate page', 'wpcable' ); ?>
80+
</p>
81+
</td>
82+
</tr>
83+
<tr>
84+
<th scope="row">
85+
<label class="wpcable_label" for="wpcable_fee_type">
86+
<?php esc_html_e( 'Fee calculation', 'wpcable' ); ?>
87+
</label>
88+
</th>
89+
<td>
90+
<select id="wpcable_fee_type" name="wpcable_fee_type">
91+
<option value="full" <?php selected( 'full', $wpcable_fee_type ); ?>>
92+
<?php esc_html_e( 'My rate is what I want to get paid, without any fees', 'wpcable' ); ?>
93+
</option>
94+
<option value="client" <?php selected( 'client', $wpcable_fee_type ); ?>>
95+
<?php esc_html_e( 'My rate includes my fee (10%) but not the client fee', 'wpcable' ); ?>
96+
</option>
97+
<option value="none" <?php selected( 'none', $wpcable_fee_type ); ?>>
98+
<?php esc_html_e( 'My rate includes all fees', 'wpcable' ); ?>
99+
</option>
100+
</select>
101+
<p class="description">
102+
<?php esc_html_e( 'This information is used on the estimate page', 'wpcable' ); ?>
103+
</p>
104+
</td>
105+
</tr>
106+
</tbody>
107+
</table>
108+
109+
<hr />
110+
<h2><?php esc_html_e( 'Codeable API', 'wpcable' ); ?></h2>
111+
<p>
112+
<?php esc_html_e( 'Log into your Codeable account.', 'wpcable' ); ?><br />
113+
<?php esc_html_e( 'During login this plugin obtains a user-specific auth-token which is used to fetch data from the API later. Your password is not saved anywhere!', 'wpcable' ); ?>
114+
</p>
115+
116+
<table class="form-table">
117+
<tbody>
118+
<?php if ( codeable_api_logged_in() ) : ?>
119+
<tr>
120+
<th scope="row">
121+
<label class="wpcable_label" for="wpcable_email">
122+
<?php esc_html_e( 'Account', 'wpcable' ); ?>
123+
</label>
124+
</th>
125+
<td>
126+
<p>
127+
<?php
128+
printf(
129+
__( 'You are currently logged in as %s', 'wpcable' ),
130+
'<b>' . $wpcable_email . '</b>'
131+
);
132+
?>
133+
<input type="hidden" name="wpcable_email" value="<?php echo esc_attr( $wpcable_email ); ?>" />
134+
</p>
135+
<p>
136+
<a href="<?php echo esc_url( $logout_url ); ?>" class="button" ><?php esc_html_e( 'Log out', 'wpcable' ); ?></a>
137+
<a href="<?php echo esc_url( $flush_data_url ); ?>" class="button danger" onclick="return confirm('<?php echo esc_attr( $flush_data_warning ); ?>')"><?php esc_html_e( 'Clear all data', 'wpcable' ); ?></a>
138+
</p>
139+
</td>
140+
</tr>
141+
<?php else : ?>
142+
<tr>
143+
<th scope="row">
144+
<label class="wpcable_label" for="wpcable_email">
145+
<?php esc_html_e( 'Email', 'wpcable' ); ?>
146+
</label>
147+
</th>
148+
<td>
149+
<input
150+
id="wpcable_email"
151+
type="email"
152+
name="wpcable_email"
153+
class="regular-text"
154+
value="<?php echo esc_attr( $wpcable_email ); ?>"
155+
autocomplete="email"
156+
/>
157+
<p class="description"><?php esc_html_e( 'This is the email address you use to log into app.codeable.com', 'wpcable' ); ?></p>
158+
</td>
159+
</tr>
160+
<tr>
161+
<th scope="row">
162+
<label class="wpcable_label" for="wpcable_password">
163+
<?php esc_html_e( 'Password', 'wpcable' ); ?>
164+
</label>
165+
</th>
166+
<td>
167+
<input
168+
id="wpcable_password"
169+
type="password"
170+
name="wpcable_password"
171+
class="regular-text"
172+
value=""
173+
autocomplete="password"
174+
/>
175+
<p class="description"><?php esc_html_e( 'Your Codeable password is not stored anywhere!<br />With your password we generate an auth_token, that is saved encrypted in your DB.', 'wpcable' ); ?></p>
176+
</td>
177+
</tr>
178+
<?php endif; ?>
179+
</tbody>
180+
</table>
181+
182+
<div class="action-buttons">
183+
<?php submit_button( __( 'Save Changes', 'wpcable' ) ); ?>
184+
</div>
185+
186+
</form>
187+
188+
<?php codeable_last_fetch_info(); ?>
189+
</div>

0 commit comments

Comments
 (0)