Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2024-11-27+3 #199

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions wp-content/plugins/feed-import/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,22 @@ function date_gmt() {
return $date->format('Y-m-d H:i:s');
}

function category() {
return apply_filters('feed_import_post_category', '', $this);
function categories() {
// Returns an array of category names.
return apply_filters('feed_import_post_categories', [], $this);
}

function post_category() {
// The wp_insert_post and wp_update_post functions expect an array of
// term IDs, so we convert a more useful string to that format at the
// very last minute.
if (empty($this->category())) {
// term IDs, so we convert our category names to term IDs at the very
// last minute.
if (empty($this->categories())) {
return [];
}
$term = get_term_by('name', $this->category(), 'category');
return [$term->term_id];
return array_map(function($name) {
$term = get_term_by('name', $name, 'category');
return $term->term_id;
}, $this->categories());
}

function attach_image() {
Expand Down
6 changes: 3 additions & 3 deletions wp-content/themes/mediasanctuary/acf/group_67471a8d19703.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
"name": "special_episode",
"aria-label": "",
"type": "true_false",
"instructions": "",
"instructions": "Make sure to add special episodes to the 'Stories' category.",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"message": "Special Episode (display with stories)",
"message": "This is a special episode",
"default_value": 0,
"allow_in_bindings": 0,
"ui_on_text": "",
Expand All @@ -29,7 +29,7 @@
"name": "special_episode_title",
"aria-label": "",
"type": "text",
"instructions": "",
"instructions": "Override the 'HMM_MM-DD-YYYY' title.",
"required": 0,
"conditional_logic": [
[
Expand Down
18 changes: 9 additions & 9 deletions wp-content/themes/mediasanctuary/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,6 @@ function is_story_post($post) {
return true;
}
}
$special_episode = get_field('special_episode', $post);
if (!empty($special_episode)) {
return true;
}
return false;
}

Expand Down Expand Up @@ -435,19 +431,23 @@ function audio_player() {
];
}, 10, 2);

add_filter('feed_import_post_category', function($category, $post) {
add_filter('feed_import_post_categories', function($categories, $post) {
if (preg_match('/^HMM/i', $post->data['title'])) {
return 'Hudson Mohawk Magazine Episodes';
$categories = ['Hudson Mohawk Magazine Episodes'];
if (get_field('special_episode', $post->id)) {
$categories[] = 'Stories';
}
return $categories;
}
return 'Stories';
return ['Stories'];
}, 10, 2);

function feed_import_post_date($date, $post) {
$category = $post->category();
$categories = $post->categories();
$four_days = 60 * 60 * 24 * 4;
$timezone = $date->getTimezone();

if ($category == 'Stories' &&
if (in_array('Stories', $categories) &&
current_time('u') - $date->getTimestamp() < $four_days) {
// If the track's timestamp is within 4 days, we should schedule
// it for the next weekday at 6pm.
Expand Down