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

Add ideas board functionality #1160

Draft
wants to merge 21 commits into
base: trunk
Choose a base branch
from
Draft
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
38 changes: 38 additions & 0 deletions wp-content/plugins/wporg-learn/inc/post-meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function register() {
register_lesson_plan_meta();
register_workshop_meta();
register_misc_meta();
register_idea_meta();
}

/**
Expand Down Expand Up @@ -144,6 +145,43 @@ function register_workshop_meta() {
);
}

/**
* Register post meta keys for ideas.
*/
function register_idea_meta() {
$post_type = 'wporg_idea';

register_post_meta(
$post_type,
'vote_count',
array(
'description' => __( 'The number of votes recieved for this idea.', 'wporg_learn' ),
'type' => 'integer',
'single' => true,
'sanitize_callback' => 'absint',
'show_in_rest' => true,
)
);

register_post_meta(
$post_type,
'voted_users',
array(
'description' => __( 'An array of users who have already voted for this idea.', 'wporg_learn' ),
'type' => 'array',
'single' => false,
'show_in_rest' => array(
'schema' => array(
'type' => 'array',
'items' => array(
'type' => 'string',
),
),
),
)
);
}

/**
* Register other post meta keys.
*
Expand Down
77 changes: 77 additions & 0 deletions wp-content/plugins/wporg-learn/inc/post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
function register() {
register_lesson_plan();
register_workshop();
register_ideas();
}

/**
Expand Down Expand Up @@ -156,6 +157,82 @@ function register_workshop() {
register_post_type( 'wporg_workshop', $args );
}

/**
* Register an Ideas post type.
*/
function register_ideas() {

$labels = array(
'name' => _x( 'Ideas', 'Post Type General Name', 'wporg_learn' ),
'singular_name' => _x( 'Idea', 'Post Type Singular Name', 'wporg_learn' ),
'menu_name' => __( 'Ideas', 'wporg_learn' ),
'name_admin_bar' => __( 'Idea', 'wporg_learn' ),
'archives' => __( 'Idea Archives', 'wporg_learn' ),
'attributes' => __( 'Idea Attributes', 'wporg_learn' ),
'parent_item_colon' => __( 'Parent Idea:', 'wporg_learn' ),
'all_items' => __( 'All Ideas', 'wporg_learn' ),
'add_new_item' => __( 'Add New Idea', 'wporg_learn' ),
'add_new' => __( 'Add New', 'wporg_learn' ),
'new_item' => __( 'New Idea', 'wporg_learn' ),
'edit_item' => __( 'Edit Idea', 'wporg_learn' ),
'update_item' => __( 'Update Idea', 'wporg_learn' ),
'view_item' => __( 'View Idea', 'wporg_learn' ),
'view_items' => __( 'View Ideas', 'wporg_learn' ),
'search_items' => __( 'Search Ideas', 'wporg_learn' ),
'not_found' => __( 'No ideas found', 'wporg_learn' ),
'not_found_in_trash' => __( 'No ideas found in Trash', 'wporg_learn' ),
'featured_image' => __( 'Featured Image', 'wporg_learn' ),
'set_featured_image' => __( 'Set featured image', 'wporg_learn' ),
'remove_featured_image' => __( 'Remove featured image', 'wporg_learn' ),
'use_featured_image' => __( 'Use as featured image', 'wporg_learn' ),
'insert_into_item' => __( 'Insert into idea', 'wporg_learn' ),
'uploaded_to_this_item' => __( 'Uploaded to this idea', 'wporg_learn' ),
'items_list' => __( 'Ideas list', 'wporg_learn' ),
'items_list_navigation' => __( 'Ideas list navigation', 'wporg_learn' ),
'filter_items_list' => __( 'Filter ideas list', 'wporg_learn' ),
);

$supports = array(
'comments',
'custom-fields',
'editor',
'revisions',
'title',
'wporg-internal-notes',
'author',
);

$args = array(
'label' => __( 'Idea', 'wporg_learn' ),
'description' => __( 'Ideas submitted by site users', 'wporg_learn' ),
'labels' => $labels,
'supports' => $supports,
'taxonomies' => array(),
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 8,
'menu_icon' => 'dashicons-lightbulb',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => 'ideas',
'rewrite' => array(
'slug' => 'idea',
'with_front' => false,
),
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'map_meta_cap' => true,
'show_in_rest' => true,
);

register_post_type( 'wporg_idea', $args );

}

/**
* Create an array representation of a workshop's content template.
*
Expand Down
90 changes: 90 additions & 0 deletions wp-content/plugins/wporg-learn/inc/taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ function register() {
register_wp_version();
register_included_content();
register_topic();
register_idea_status();
register_idea_type();
}

/**
Expand Down Expand Up @@ -528,6 +530,94 @@ function register_included_content() {
register_taxonomy( 'wporg_included_content', $post_types, $args );
}

/**
* Register the Idea Status taxonomy.
*/
function register_idea_status() {
$labels = array(
'name' => _x( 'Statuses', 'Taxonomy General Name', 'wporg-learn' ),
'singular_name' => _x( 'Status', 'Taxonomy Singular Name', 'wporg-learn' ),
'menu_name' => __( 'Status', 'wporg-learn' ),
'all_items' => __( 'All Statuses', 'wporg-learn' ),
'parent_item' => __( 'Parent Status', 'wporg-learn' ),
'parent_item_colon' => __( 'Parent Status:', 'wporg-learn' ),
'new_item_name' => __( 'New Status Name', 'wporg-learn' ),
'add_new_item' => __( 'Add Status', 'wporg-learn' ),
'edit_item' => __( 'Edit Status', 'wporg-learn' ),
'update_item' => __( 'Update Status', 'wporg-learn' ),
'view_item' => __( 'View Status', 'wporg-learn' ),
'separate_items_with_commas' => __( 'Separate Statuses with commas', 'wporg-learn' ),
'add_or_remove_items' => __( 'Add or remove Statuses', 'wporg-learn' ),
'choose_from_most_used' => __( 'Choose from the most used', 'wporg-learn' ),
'popular_items' => __( 'Popular Statuses', 'wporg-learn' ),
'search_items' => __( 'Search Statuses', 'wporg-learn' ),
'not_found' => __( 'Not Found', 'wporg-learn' ),
'no_terms' => __( 'No Statuses', 'wporg-learn' ),
'items_list' => __( 'Statuses list', 'wporg-learn' ),
'items_list_navigation' => __( 'Statuses list navigation', 'wporg-learn' ),
);

$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => false,
'show_in_rest' => true,
'capabilities' => array(
'assign_terms' => 'edit_any_learn_content',
),
);

register_taxonomy( 'wporg_idea_status', array( 'wporg_idea' ), $args );
}

/**
* Register the Idea Type taxonomy.
*/
function register_idea_type() {
$labels = array(
'name' => _x( 'Types', 'Taxonomy General Name', 'wporg-learn' ),
'singular_name' => _x( 'Type', 'Taxonomy Singular Name', 'wporg-learn' ),
'menu_name' => __( 'Type', 'wporg-learn' ),
'all_items' => __( 'All Types', 'wporg-learn' ),
'parent_item' => __( 'Parent Type', 'wporg-learn' ),
'parent_item_colon' => __( 'Parent Type:', 'wporg-learn' ),
'new_item_name' => __( 'New Type Name', 'wporg-learn' ),
'add_new_item' => __( 'Add Type', 'wporg-learn' ),
'edit_item' => __( 'Edit Type', 'wporg-learn' ),
'update_item' => __( 'Update Type', 'wporg-learn' ),
'view_item' => __( 'View Type', 'wporg-learn' ),
'separate_items_with_commas' => __( 'Separate Types with commas', 'wporg-learn' ),
'add_or_remove_items' => __( 'Add or remove Types', 'wporg-learn' ),
'choose_from_most_used' => __( 'Choose from the most used', 'wporg-learn' ),
'popular_items' => __( 'Popular Types', 'wporg-learn' ),
'search_items' => __( 'Search Types', 'wporg-learn' ),
'not_found' => __( 'Not Found', 'wporg-learn' ),
'no_terms' => __( 'No Types', 'wporg-learn' ),
'items_list' => __( 'Types list', 'wporg-learn' ),
'items_list_navigation' => __( 'Types list navigation', 'wporg-learn' ),
);

$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => false,
'show_in_rest' => true,
'capabilities' => array(
'assign_terms' => 'edit_any_learn_content',
),
);

register_taxonomy( 'wporg_idea_type', array( 'wporg_idea' ), $args );
}

/**
* Add icon field for Category and Audience
*/
Expand Down
71 changes: 71 additions & 0 deletions wp-content/themes/pub/wporg-learn-2020/archive-wporg_idea.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
/**
* The template for displaying archive pages.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package WordPressdotorg\Theme
*/

namespace WordPressdotorg\Theme;

use WP_Post;

global $wp_query;

/** @var WP_Post $post */

get_header();
get_template_part( 'template-parts/component', 'breadcrumbs' );
?>

<main id="main" class="site-main">

<section>
<div class="section-heading section-heading--with-space">
<?php the_archive_title( '<h1 class="section-heading_title h2">', '</h1>' ); ?>
</div>
<hr>
<?php if ( is_post_type_archive( 'wporg_idea' ) ) : ?>
<div class="section-intro">
<div class="row between gutters">
<p class="col-8"><?php esc_html_e( 'Content ideas can be submitted by any learner. Browse the ideas submitted by others, vote on the ones you like, and suggest your own topics for future content development.', 'wporg-learn' ); ?></p>
<?php get_template_part( 'template-parts/component', 'archive-search' ); ?>
</div>
</div>
<hr>
<?php get_template_part( 'template-parts/component', 'ideas-filters' ); ?>
<?php endif; ?>

<div class="lp-archive-items row gutters between">
<div class="card-grid col-8">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) :
the_post();
get_template_part(
'template-parts/component',
'card',
wporg_learn_get_card_template_args( get_the_ID() )
);
endwhile; ?>
<?php else : ?>
<p class="not-found">
<?php echo esc_html( get_post_type_object( 'wporg_idea' )->labels->not_found ); ?>
</p>
<?php endif; ?>
</div>

<div class="col-4 idea-page_sidebar">
<?php get_template_part( 'template-parts/component', 'ideas-form' ); ?>
</div>
</div>

<?php the_posts_pagination(); ?>

</section>

<hr>

</main>

<?php get_footer();
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
@import "content-icon";
@import "featured-workshop";
@import "filter-drawer";
@import "idea-page";
@import "meetings-plugin";
@import "notice";
@import "page-lesson-plan";
Expand Down
Loading