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

Remove hard dependency on 'deprecated__Figuren_Theater__v2' #21

Open
4 tasks
Tracked by #1
carstingaxion opened this issue Oct 16, 2023 · 0 comments
Open
4 tasks
Tracked by #1

Remove hard dependency on 'deprecated__Figuren_Theater__v2' #21

carstingaxion opened this issue Oct 16, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@carstingaxion
Copy link
Member

carstingaxion commented Oct 16, 2023

Tasks

Figuren_Theater

function remove_columns_from_lists() : void {
if ( ! Figuren_Theater\FT::site()->has_feature( [ FeaturesRepo\Feature__core__contenthub::SLUG ] ) ) {
remove_action( 'admin_init', 'Distributor\\SyndicatedPostUI\\setup_columns' );
}
}

Figuren_Theater\Network\Taxonomies

function get_import_args_from_source( int $source_feed_id ) : array {
// 1. get sourced 'ft_link' post,
// which is the parent of the 'fp_feed' that is sourcing this post
$ft_link = get_post_parent( get_post( $source_feed_id ) );
// 2. get sourced 'ft_link_shadow'-term-id
$tax_shadow = Taxonomies\TAX_Shadow::init();
$ft_link_term = $tax_shadow->get_associated_term(
$ft_link,
Taxonomies\Taxonomy__ft_link_shadow::NAME
);
// 3. translate 'utility-tax' terms at the source
// into post-fields of the import
// $args = get_post_fields_from_utility_terms( $source_feed_id ) + [
$args = [
'tax_input' => [
Taxonomies\Taxonomy__ft_link_shadow::NAME => [ $ft_link_term->term_id ],
],
];
return $args;
}

Figuren_Theater\Network\Features

function register_post_type_args( array $args ) : array {
$cuc = current_user_can( 'manage_sites' );
$args['public'] = false; // WHY is this 'true' by default?
$args['supports'] = [ 'title', 'post-formats' ];
$args['show_ui'] = $cuc;
$args['show_in_menu'] = $cuc;
$args['menu_icon'] = 'dashicons-rss';
$args['menu_position'] = 100;
$args['taxonomies'] = $args['taxonomies'] ?? [];
$args['taxonomies'][] = Features\UtilityFeaturesManager::TAX;
return $args;
}

Figuren_Theater\Network\Users

function fp_post_args( array $new_post_args, $post, int $source_feed_id ) : array {
$import_args = get_import_args_from_source( $source_feed_id );
// Set some defaults.
$import_args['comment_status'] = 'closed';
$import_args['ping_status'] = 'closed';
// set author to machine user, if non set.
$new_post_args['post_author'] ?: Users\ft_bot::id();
// Strip (maybe) filled excerpt
// if we can auto-generate it.
if ( ! empty( $new_post_args['post_content'] ) && ! empty( $new_post_args['post_excerpt'] ) ) {
unset( $new_post_args['post_excerpt'] );
}
$new_post_args = wp_parse_args( $import_args, $new_post_args );
return wp_slash( $new_post_args );
}

function push_pull_default_args( array $new_post_args, WP_Post $original_post ) : array {
// Set author to machine user.
$new_post_args['post_author'] = Users\ft_bot::id();

@carstingaxion carstingaxion added the bug Something isn't working label Oct 17, 2023
@carstingaxion carstingaxion changed the title Remove hard dependency on 'deprecated__Figuren_Theater__v2' using Taxonomies\... Remove hard dependency on 'deprecated__Figuren_Theater__v2' Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant