diff --git a/src/class.settings-api.php b/src/class.settings-api.php index e73d470..c789e8c 100755 --- a/src/class.settings-api.php +++ b/src/class.settings-api.php @@ -97,6 +97,8 @@ function add_field( $section, $field ) { * registers them to WordPress and ready for use. */ function admin_init() { + if( ! is_array( $this->settings_sections ) ) + return ; //register settings sections foreach ( $this->settings_sections as $section ) { if ( false == get_option( $section['id'] ) ) { @@ -115,6 +117,8 @@ function admin_init() { add_settings_section( $section['id'], $section['title'], $callback, $section['id'] ); } + if( ! is_array($this->settings_fields) ) + return ; //register settings fields foreach ( $this->settings_fields as $section => $field ) { foreach ( $field as $option ) { @@ -140,6 +144,7 @@ function admin_init() { 'min' => isset( $option['min'] ) ? $option['min'] : '', 'max' => isset( $option['max'] ) ? $option['max'] : '', 'step' => isset( $option['step'] ) ? $option['step'] : '', + 'post_type' => isset( $option['post_type'] ) ? $option['post_type'] : 'page', ); add_settings_field( "{$section}[{$name}]", $label, $callback, $section, $section, $args ); @@ -415,12 +420,16 @@ function callback_color( $args ) { function callback_pages( $args ) { $dropdown_args = array( - 'selected' => esc_attr($this->get_option($args['id'], $args['section'], $args['std'] ) ), - 'name' => $args['section'] . '[' . $args['id'] . ']', - 'id' => $args['section'] . '[' . $args['id'] . ']', - 'echo' => 0 + 'selected' => esc_attr($this->get_option($args['id'], $args['section'], $args['std'] ) ), + 'name' => $args['section'] . '[' . $args['id'] . ']', + 'id' => $args['section'] . '[' . $args['id'] . ']', + 'echo' => 0, + 'post_type' => $args['post_type'], + 'hierarchical' => true, + 'show_option_none' => '— Select —', ); $html = wp_dropdown_pages( $dropdown_args ); + $html .= $this->get_field_description( $args ); echo $html; } @@ -502,6 +511,9 @@ function get_option( $option, $section, $default = '' ) { function show_navigation() { $html = '