Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.

Commit 3c0d2ef

Browse files
committed
Merge branch 'options-fix'
2 parents 64154bd + 0c69acc commit 3c0d2ef

File tree

3 files changed

+6
-43
lines changed

3 files changed

+6
-43
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
##### v1.2.1
4+
* reduce the defaults within the class
5+
* replace contents of `options_merge` function with `array_replace_recursive`
6+
37
##### v1.2.0
48
* allow taxonomies to be sorted with the `sortable()` method
59
* use of `.gitattributes` to make package lighter when deploying for production.
@@ -11,7 +15,6 @@
1115
* ability to use dashicons with `menu_icon()` method
1216
* removed old custom icon functions
1317

14-
1518
##### v1.0.1
1619
* fixed issue with registering taxonomies
1720
* fixed issue with options merge, now accepts boolean

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# WP Custom Post Type Class v1.2.0
1+
# WP Custom Post Type Class v1.2.1
22

33
A single class to help you build more advanced custom post types quickly.
44

src/CPT.php

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -264,44 +264,7 @@ function set($var, $value) {
264264

265265
function options_merge($defaults, $options) {
266266

267-
// set the new array as defaults
268-
$new_array = $defaults;
269-
270-
// return the value if it is false
271-
if($options === false) return false;
272-
273-
// foreach new option to be added
274-
foreach($options as $key => $value) {
275-
276-
// if isset in the defaults array
277-
if(isset($defaults[$key])) {
278-
279-
// if this option is a nested array
280-
if(is_array($defaults[$key])) {
281-
282-
// repeat the process
283-
$new_array[$key] = $this->options_merge($defaults[$key], $options[$key]);
284-
285-
// else if the value is not an array
286-
} else {
287-
288-
// overide with user submitted option
289-
$new_array[$key] = $options[$key];
290-
291-
}
292-
293-
// else if the default has not been set
294-
} else {
295-
296-
// add it to the option
297-
$new_array[$key] = $value;
298-
299-
}
300-
301-
}
302-
303-
// return the new array
304-
return $new_array;
267+
return array_replace_recursive($defaults, $options);
305268

306269
}
307270

@@ -503,9 +466,6 @@ function register_post_type() {
503466
$defaults = array(
504467
'labels' => $labels,
505468
'public' => true,
506-
'hierarchical' => false,
507-
'menu_position' => 5,
508-
'supports' => array('title', 'editor', 'thumbnail'),
509469
'rewrite' => array(
510470
'slug' => $slug,
511471
)

0 commit comments

Comments
 (0)