Skip to content

Remove hard dependency on 'deprecated__Figuren_Theater__v2' #21

Description

@carstingaxion
### Tasks
- [ ] `Figuren_Theater`
- [ ] `Figuren_Theater\Network\Features`
- [ ] `Figuren_Theater\Network\Taxonomies`
- [ ] `Figuren_Theater\Network\Users`

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();

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions