Skip to content

Commit

Permalink
Fix #54
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Dec 10, 2024
1 parent b5477d3 commit 399f6d3
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions classes/admin/class-page-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public function add_admin_page_content() {
public function get_settings() {
$settings = [];
foreach ( \progress_planner()->get_page_types()->get_page_types() as $page_type ) {
if ( ! $this->should_show_setting( $page_type['slug'] ) ) {
continue;
}

$value = '_no_page_needed';
if ( \progress_planner()->get_page_types()->is_page_needed( $page_type['slug'] ) ) {
$type_pages = \progress_planner()->get_page_types()->get_posts_by_type( 'any', $page_type['slug'] );
Expand All @@ -74,6 +78,27 @@ public function get_settings() {
return apply_filters( 'progress_planner_settings', $settings );
}

/**
* Determine whether the setting for a page-type should be shown or not.
*
* @param string $page_type The page-type slug.
*
* @return bool
*/
public function should_show_setting( $page_type ) {
static $lessons;
if ( ! $lessons ) {
$lessons = \progress_planner()->get_lessons()->get_items();
}
foreach ( $lessons as $lesson ) {
if ( $lesson['settings']['id'] === $page_type ) {
return 'no' !== $lesson['settings']['show_in_settings'];
}
}

return false;
}

/**
* Store the settings form options.
*
Expand Down

0 comments on commit 399f6d3

Please sign in to comment.