Skip to content

Commit

Permalink
Merge branch 'options-fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
jjgrainger committed Mar 13, 2014
2 parents 64154bd + 0c69acc commit 3c0d2ef
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 43 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

##### v1.2.1
* reduce the defaults within the class
* replace contents of `options_merge` function with `array_replace_recursive`

##### v1.2.0
* allow taxonomies to be sorted with the `sortable()` method
* use of `.gitattributes` to make package lighter when deploying for production.
Expand All @@ -11,7 +15,6 @@
* ability to use dashicons with `menu_icon()` method
* removed old custom icon functions


##### v1.0.1
* fixed issue with registering taxonomies
* fixed issue with options merge, now accepts boolean
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WP Custom Post Type Class v1.2.0
# WP Custom Post Type Class v1.2.1

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

Expand Down
42 changes: 1 addition & 41 deletions src/CPT.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,44 +264,7 @@ function set($var, $value) {

function options_merge($defaults, $options) {

// set the new array as defaults
$new_array = $defaults;

// return the value if it is false
if($options === false) return false;

// foreach new option to be added
foreach($options as $key => $value) {

// if isset in the defaults array
if(isset($defaults[$key])) {

// if this option is a nested array
if(is_array($defaults[$key])) {

// repeat the process
$new_array[$key] = $this->options_merge($defaults[$key], $options[$key]);

// else if the value is not an array
} else {

// overide with user submitted option
$new_array[$key] = $options[$key];

}

// else if the default has not been set
} else {

// add it to the option
$new_array[$key] = $value;

}

}

// return the new array
return $new_array;
return array_replace_recursive($defaults, $options);

}

Expand Down Expand Up @@ -503,9 +466,6 @@ function register_post_type() {
$defaults = array(
'labels' => $labels,
'public' => true,
'hierarchical' => false,
'menu_position' => 5,
'supports' => array('title', 'editor', 'thumbnail'),
'rewrite' => array(
'slug' => $slug,
)
Expand Down

0 comments on commit 3c0d2ef

Please sign in to comment.