*/ /** * review post_type */ function aml_review_type() { $slug_base = aml_get_option('aml_slug_base'); $slug_review = aml_get_option('aml_slug_review'); $labels = array( 'name' => __('Reviews', 'amazon-library'), 'singular_name' => __('Review', 'amazon-library'), 'add_new' => __('Add New'), 'add_new_item' => __('Add New Review', 'amazon-library'), 'edit' => __('Edit'), 'edit_item' => __('Edit Review', 'amazon-library'), 'new_item' => __('New Review', 'amazon-library'), 'view' => __('View'), 'view_item' => __('View Review', 'amazon-library'), 'search_items' => __('Search Reviews', 'amazon-library'), 'not_found' => __('No reviews found', 'amazon-library'), 'not_found_in_trash' => __('No reviews found in trash', 'amazon-library'), ); $args = array( 'description' => __('A single review/use of a product (e.g. reading a book, watching a DVD, listening to music, etc)'), 'rewrite' => array('slug' => "$slug_base/$slug_review", 'pages' => false, 'feeds' => false, 'with_front' => false), 'supports' => array('title', 'author', 'editor', 'revisions'), 'show_in_menu' => 'edit.php?post_type=aml_product', 'register_meta_box_cb' => 'aml_review_boxes', 'capability_type' => 'review', 'map_meta_cap' => true, 'hierarchical' => false, 'query_var' => true, 'labels' => $labels, 'show_ui' => true, 'public' => true, ); register_post_type('aml_review', $args); add_filter('archive_template', 'aml_review_archive_template'); add_filter('single_template', 'aml_review_single_template'); } /** * review stati * * @todo restrict these stati to aml_review type */ function aml_review_stati() { $stati = aml_get_review_stati(); foreach ($stati as $name => $args) { register_post_status( $name, array( 'label' => _x($args['label'], 'post', 'amazon-library'), 'label_count' => _n_noop($args['single'] . ' (%s)', $args['plural'] . ' (%s)' ), 'public' => true, ) ); } } function aml_get_review_stati() { return array( 'added' => array('label' => 'Yet to use', 'single' => 'Added', 'plural' => 'Added'), 'onhold' => array('label' => 'On Hold', 'single' => 'Held', 'plural' => 'Held'), 'using' => array('label' => 'Currently using', 'single' => 'Using', 'plural' => 'Using'), 'finished' => array('label' => 'Finished', 'single' => 'Finished', 'plural' => 'Finished'), ); } /** * generic taxonomy for reviews (all of this just to rename 'post tags' to simply 'tags'!) */ function aml_tag_tax() { $slug_base = aml_get_option('slug_base'); $slug_tag = aml_get_option('slug_tag'); $labels = array( 'name' => _x('Tags', 'taxonomy general name', 'amazon-library'), 'singular_name' => _x('Tag', 'taxonomy singular name', 'amazon-library'), ); $capabilities = array( 'manage_terms' => 'manage_tags', 'edit_terms' => 'edit_tags', 'delete_terms' => 'edit_tags', 'assign_terms' => 'edit_reviews', ); $args = array( 'rewrite' => array('slug' => "$slug_base/$slug_tag", 'pages' => true, 'feeds' => false, 'with_front' => false), 'capabilities' => $capabilities, 'query_var' => 'aml_tag', 'hierarchical' => false, 'labels' => $labels, 'public' => true, ); register_taxonomy( 'aml_tag', 'aml_review', $args); add_filter('taxonomy_template', 'aml_tags_taxonomy_template'); } /** * callback from registering aml_review to generate meta boxes on an edit page */ function aml_review_boxes() { remove_meta_box('submitdiv', 'aml_review', 'side'); add_meta_box('aml_review_submit', __('Publish'), 'aml_submit_box', 'aml_review', 'side', 'high'); add_meta_box('aml_review_meta', __('Product', 'amazon-library'), 'aml_review_meta', 'aml_review', 'side', 'high'); } /** * Hacked post submit form (falls to WP default if not a review) * * @param object $post */ function aml_submit_box ($post) { $post_type_object = get_post_type_object($post->post_type); $can_publish = current_user_can($post_type_object->cap->publish_posts); $added = get_post_meta($post->ID, 'aml_added', true); $started = get_post_meta($post->ID, 'aml_started', true); $finish = get_post_meta($post->ID, 'aml_finished', true); $stati = aml_get_review_stati(); $stati_names = array_keys($stati); $post->post_status = (in_array($post->post_status, $stati_names)) ? $post->post_status : $stati_names[0]; ?>
' . __('Parent') . '
' . '' . $parents; } $image = ($parent) ? '' . __('Pages are similar to Posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest Pages under other Pages by making one the “Parent” of the other, creating a group of Pages.') . '
' . '' . __('Creating a Page is very similar to creating a Post, and the screens can be customized in the same way using drag and drop, the Screen Options tab, and expanding/collapsing boxes as you choose. The Page editor mostly works the same Post editor, but there are some Page-specific features in the Page Attributes box:') . '
' . '' . __('Parent - You can arrange your pages in hierarchies. For example, you could have an “About” page that has “Life Story” and “My Dog” pages under it. There are no limits to how many levels you can nest pages.') . '
' . '' . __('Template - Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you’ll see them in this dropdown menu.') . '
' . '' . __('Order - Pages are usually ordered alphabetically, but you can choose your own order by entering a number (1 for first, etc.) in this field.') . '
' . '' . __('For more information:') . '
' . '' . __('Documentation on Adding New Pages') . '
' . '' . __('Documentation on Editing Pages') . '
' . '' . __('Support Forums') . '
' ); } } /** * initialise and register the actions for review post_type */ function aml_init_review() { aml_review_type(); aml_review_stati(); if (aml_get_option('use_tags')) { aml_tag_tax(); } if (aml_get_option('use_categories')) { register_taxonomy_for_object_type('category', 'aml_review'); } add_action('manage_aml_review_posts_custom_column', 'aml_review_display_columns', 10, 2); add_action('manage_edit-aml_review_columns', 'aml_review_register_columns'); add_action('right_now_content_table_end', 'aml_review_right_now'); add_action('save_post', 'aml_review_meta_postback'); add_action('admin_head-edit.php', 'aml_page_help'); wp_enqueue_script('aml-review-script', plugins_url('/amazon-media-libraries/js/amazon.review.js')); wp_enqueue_script('aml-metadata-script', plugins_url('/amazon-media-libraries/js/jquery.metadata.js')); wp_enqueue_script('aml-rating-script', plugins_url('/amazon-media-libraries/js/jquery.rating.js')); wp_enqueue_style('aml-rating-style', plugins_url('/amazon-media-libraries/css/jquery.rating.css')); }