diff --git a/modules/async-notifications/async-notifications.php b/modules/async-notifications/async-notifications.php index 4ebdea0d..d35cf3b0 100644 --- a/modules/async-notifications/async-notifications.php +++ b/modules/async-notifications/async-notifications.php @@ -78,7 +78,6 @@ public function __construct() 'enabled' => 'on', ], 'options_page' => false, - 'autoload' => true, ]; // Apply a filter to the default options diff --git a/modules/editorial-metadata/editorial-metadata.php b/modules/editorial-metadata/editorial-metadata.php index f2998115..f33db636 100644 --- a/modules/editorial-metadata/editorial-metadata.php +++ b/modules/editorial-metadata/editorial-metadata.php @@ -380,7 +380,7 @@ public function add_admin_scripts() $terms = $this->get_editorial_metadata_terms(); $viewable_terms = []; foreach ($terms as $term) { - if ($term->viewable) { + if (!empty($term->post_types_column) && in_array($current_post_type, $term->post_types_column)) { $viewable_terms[] = $term; } } @@ -740,6 +740,12 @@ private function get_postmeta_value($term, $post_id) */ public function get_editorial_metadata_terms($filter_args = []) { + + if (empty($filter_args['viewable'])) { + // viewable has been removed, use post type instead + unset($filter_args['viewable']); + } + // Try to fetch from internal object cache $arg_hash = md5(serialize($filter_args)); if (isset($this->editorial_metadata_terms_cache[$arg_hash])) { @@ -762,7 +768,6 @@ public function get_editorial_metadata_terms($filter_args = []) $unencoded_description = $this->get_unencoded_description($term->description); $defaults = [ 'description' => '', - 'viewable' => false, 'position' => false, 'show_in_calendar_form' => false, ]; @@ -843,7 +848,7 @@ public function filter_manage_posts_columns($posts_columns = '', $post_type = 'p $screen = get_current_screen(); if ($screen) { add_filter("manage_{$screen->id}_sortable_columns", [$this, 'filter_manage_posts_sortable_columns']); - $terms = $this->get_editorial_metadata_terms(['viewable' => true]); + $terms = $this->get_editorial_metadata_terms(); foreach ($terms as $term) { if (isset($term->post_types_column) && is_array($term->post_types_column) && in_array($post_type, $term->post_types_column)) { // Prefixing slug with module slug because it isn't stored prefixed and we want to avoid collisions @@ -866,7 +871,7 @@ public function filter_manage_posts_columns($posts_columns = '', $post_type = 'p */ public function filter_manage_posts_sortable_columns($sortable_columns) { - $terms = $this->get_editorial_metadata_terms(['viewable' => true, 'type' => 'date']); + $terms = $this->get_editorial_metadata_terms(['type' => 'date']); foreach ($terms as $term) { // Prefixing slug with module slug because it isn't stored prefixed and we want to avoid collisions $key = $this->module->slug . '-' . $term->slug; @@ -934,7 +939,7 @@ public function filterCalendarPostData($data, $post) return $data; } - $terms = $this->get_editorial_metadata_terms(['viewable' => true]); + $terms = $this->get_editorial_metadata_terms(); $post_type = $post->post_type; foreach ($terms as $term) { @@ -976,7 +981,7 @@ public function filterCalendarPostData($data, $post) */ public function filter_story_budget_term_columns($term_columns) { - $terms = $this->get_editorial_metadata_terms(['viewable' => true]); + $terms = $this->get_editorial_metadata_terms(); foreach ($terms as $term) { // Prefixing slug with module slug because it isn't stored prefixed and we want to avoid collisions $key = $this->module->slug . '-' . $term->slug; @@ -1063,7 +1068,6 @@ private function update_editorial_metadata_term($term_id, $args) 'select_type' => isset($old_term->select_type) ? $old_term->select_type : '', 'select_default' => isset($old_term->select_default) ? $old_term->select_default : '', 'select_options' => isset($old_term->select_options) ? $old_term->select_options : '', - 'viewable' => $old_term->viewable, 'post_types' => isset($old_term->post_types) ? $old_term->post_types : '', 'show_in_calendar_form' => isset($old_term->show_in_calendar_form) ? $old_term->show_in_calendar_form : false, 'post_types_column' => isset($old_term->post_types_column) ? $old_term->post_types_column : '', @@ -1080,7 +1084,6 @@ private function update_editorial_metadata_term($term_id, $args) 'select_type' => $new_args['select_type'], 'select_default' => $new_args['select_default'], 'select_options' => $new_args['select_options'], - 'viewable' => $new_args['viewable'], 'show_in_calendar_form' => $new_args['show_in_calendar_form'], 'post_types' => $new_args['post_types'], 'post_types_column' => $new_args['post_types_column'], @@ -1118,7 +1121,6 @@ private function insert_editorial_metadata_term($args) 'select_type' => '', 'select_default' => '', 'select_options' => '', - 'viewable' => false, 'show_in_calendar_form' => false, 'post_types' => [], 'post_types_column' => [], @@ -1136,7 +1138,6 @@ private function insert_editorial_metadata_term($args) 'select_type' => $args['select_type'], 'select_default' => $args['select_default'], 'select_options' => $args['select_options'], - 'viewable' => $args['viewable'], 'show_in_calendar_form' => $args['show_in_calendar_form'], 'post_types' => $args['post_types'], 'post_types_column' => $args['post_types_column'], @@ -1195,8 +1196,6 @@ public function get_link($args = []) // Add other things we may need depending on the action switch ($args['action']) { - case 'make-viewable': - case 'make-hidden': case 'delete-term': $args['nonce'] = wp_create_nonce($args['action']); break; @@ -1325,11 +1324,6 @@ public function handle_add_editorial_metadata() if (empty($_POST['metadata_type']) || ! isset($metadata_types[$_POST['metadata_type']])) { $_REQUEST['form-errors']['type'] = esc_html__('Please select a valid metadata type.', 'publishpress'); } - // Metadata viewable needs to be a valid Yes or No - $term_viewable = false; - if (isset($_POST['metadata_viewable']) && $_POST['metadata_viewable'] == 'yes') { - $term_viewable = true; - } // Metadata show_in_calendar_form needs to be a valid Yes or No $term_show_in_calendar_form = false; @@ -1353,7 +1347,6 @@ public function handle_add_editorial_metadata() 'select_type' => $term_select_type, 'select_default' => $term_select_default, 'select_options' => $term_select_options, - 'viewable' => $term_viewable, 'show_in_calendar_form' => $term_show_in_calendar_form, 'post_types' => $term_post_types, 'post_types_column' => $term_post_types_column, @@ -1480,11 +1473,6 @@ public function handle_edit_editorial_metadata() 'publishpress' ); } - // Make sure the viewable state is valid - $new_viewable = false; - if (isset($_POST['viewable']) && $_POST['viewable'] == 'yes') { - $new_viewable = true; - } // Make sure the show_in_calendar_form state is valid $new_show_in_calendar_form = false; @@ -1509,7 +1497,6 @@ public function handle_edit_editorial_metadata() 'select_type' => $term_select_type, 'select_default' => $term_select_default, 'select_options' => $term_select_options, - 'viewable' => $new_viewable, 'show_in_calendar_form' => $new_show_in_calendar_form, 'post_types' => $term_post_types, 'post_types_column' => $term_post_types_column, @@ -1556,11 +1543,6 @@ public function handle_change_editorial_metadata_visibility() $term_id = (int)$_GET['term-id']; $args = []; - if ($_GET['action'] == 'make-viewable') { - $args['viewable'] = true; - } elseif ($_GET['action'] == 'make-hidden') { - $args['viewable'] = false; - } $return = $this->update_editorial_metadata_term($term_id, $args); @@ -1847,12 +1829,6 @@ public function render_admin_page() $description = (isset($_POST['description'])) ? stripslashes( sanitize_textarea_field($_POST['description']) ) : $term->description; - if ($term->viewable) { - $viewable = 'yes'; - } else { - $viewable = 'no'; - } - $viewable = (isset($_POST['viewable'])) ? sanitize_key(stripslashes($_POST['viewable'])) : $viewable; if ($term->show_in_calendar_form) { $show_in_calendar_form = 'yes'; @@ -2070,30 +2046,6 @@ class="select_dropdown_default" - - - - esc_html__('No', 'publishpress'), - 'yes' => esc_html__('Yes', 'publishpress'), - ]; ?> - '; - ?> - settings->helper_print_error_or_description( - 'viewable', - esc_html__( - 'If enabled, this field can be seen on the Content Calendar screens.', - 'publishpress' - ) - ); ?> - - @@ -2405,34 +2357,7 @@ class="select_dropdown_default" - -
- - esc_html__('No', 'publishpress'), - 'yes' => esc_html__('Yes', 'publishpress'), - ]; - $current_metadata_viewable = (isset($_POST['metadata_viewable']) && in_array( - $_POST['metadata_viewable'], - array_keys($metadata_viewable_options) - )) ? sanitize_key($_POST['metadata_viewable']) : 'no'; ?> - - '; - ?> - settings->helper_print_error_or_description( - 'viewable', - esc_html__( - 'If enabled, this field can be seen on the Content Calendar screens.', - 'publishpress' - ) - ); ?> -
+
@@ -2628,8 +2553,7 @@ public function get_columns() 'name' => esc_html__('Name', 'publishpress'), 'post_types' => esc_html__('Post Types', 'publishpress'), 'type' => esc_html__('Field Type', 'publishpress'), - 'description' => esc_html__('Description', 'publishpress'), - 'viewable' => esc_html__('Viewable', 'publishpress') + 'description' => esc_html__('Description', 'publishpress') ]; return $columns; @@ -2687,12 +2611,6 @@ public function column_default($item, $column_name) } else { return '-'; } - case 'viewable': - if ($item->viewable) { - return esc_html__('Yes', 'publishpress'); - } else { - return esc_html__('No', 'publishpress'); - } break; default: break; @@ -2747,25 +2665,7 @@ public function column_name($item) $actions = []; $actions['edit'] = "" . esc_html__('Edit', 'publishpress') . ""; - if ($item->viewable) { - $actions['change-visibility make-hidden'] = '' . esc_html__('Make Hidden', 'publishpress') . ''; - } else { - $actions['change-visibility make-viewable'] = '' . esc_html__('Make Viewable', 'publishpress') . ''; - } + $actions['delete delete-status'] = "" . esc_html__('Delete', 'publishpress') . ""; $out .= $this->row_actions($actions, false); diff --git a/modules/settings/settings.php b/modules/settings/settings.php index 7ba903d0..8f1cdfd7 100644 --- a/modules/settings/settings.php +++ b/modules/settings/settings.php @@ -457,14 +457,18 @@ public function options_page_controller() } //force notification tab if dependent tab is enabled + if ($mod_data->slug == 'async-notifications' && $mod_data->options->enabled === 'on') { + $all_modules['notifications']->options->enabled = 'on'; + } + if (isset($mod_data->notification_options)) { if ($all_modules['notifications']->options->enabled === 'on') { $all_modules['improved_notifications']->options->enabled = 'on'; - $all_modules['async_notifications']->options->enabled = 'on'; + //$all_modules['async_notifications']->options->enabled = 'on'; $all_modules['notifications']->options->enabled = 'on'; } else { $all_modules['improved_notifications']->options->enabled = 'off'; - $all_modules['async_notifications']->options->enabled = 'off'; + //$all_modules['async_notifications']->options->enabled = 'off'; $all_modules['notifications']->options->enabled = 'off'; } break;