admin->css_url ) . 'chosen.css', array(), '20121006' ); wp_enqueue_script( 'dpa_chosen_js', trailingslashit( achievements()->admin->javascript_url ) . 'chosen-jquery-min.js', array( 'jquery' ), '20121006' ); // General styles for the post type admin screen. wp_enqueue_script( 'dpa_admin_js', trailingslashit( achievements()->admin->javascript_url ) . 'achievements-min.js', array( 'jquery', 'dpa_chosen_js' ), '20121006' ); wp_enqueue_style( 'dpa_admin_css', trailingslashit( achievements()->admin->css_url ) . 'achievements.css', array(), '20121006' ); } /** * Achievements metabox * * Contains fields to set the karma points, pick between action/event, and the list of events. * * @param WP_Post $post The post being added or edited * @since Achievements (3.0) */ function dpa_achievement_metabox( $post ) { // Get all events grouped by the extension which provided them $events = dpa_get_all_events_details(); // Get existing values (if this is an edit) $existing_points = dpa_get_achievement_points( $post->ID ); $existing_target = dpa_get_achievement_target( $post->ID ); $existing_events = wp_get_post_terms( $post->ID, dpa_get_event_tax_id(), array( 'fields' => 'ids', ) ); $existing_type = ( empty( $existing_events ) && ! empty( $_GET['action'] ) && 'edit' == $_GET['action'] ) ? 'award' : 'event'; // Ensure sane defaults if ( empty( $existing_points ) ) $existing_points = 0; if ( empty( $existing_target ) ) $existing_target = 1; ?>
> >

award is given by a site admin, whereas an event is unlocked automatically when its criteria have been met.", 'dpa' ) ?>

'', 'title' => __( 'Title', 'dpa' ), 'achievement_type' => _x( 'Type', 'Type of the achievement; award or badge', 'dpa' ), 'karma' => __( 'Karma Points', 'dpa' ), 'date' => __( 'Date', 'dpa' ), ); return apply_filters( 'dpa_achievements_posts_columns', $columns ); } /** * Outputs the content for the custom columns on the achievement post type index screen * * @param string $column * @param int $post_id * @since Achievements (3.0) */ function dpa_achievement_custom_column( $column, $post_id ) { if ( 'karma' == $column ) { dpa_achievement_points( $post_id ); } elseif ( 'achievement_type' == $column ) { $existing_events = wp_get_post_terms( $post_id, dpa_get_event_tax_id(), array( 'fields' => 'ids', ) ); $existing_type = empty( $existing_events ) ? __( 'Award', 'dpa' ) : __( 'Event', 'dpa' ); echo $existing_type; } } /** * Set the "achievement type" and "karma" columns as sortable on the achievement post type index screen * * @param array $columns * @return array * @since Achievements (3.0) */ function dpa_achievement_sortable_columns( $columns ) { $columns['karma'] = 'karma'; $columns['achievement_type'] = 'achievement_type'; return apply_filters( 'dpa_achievement_sortable_columns', $columns ); } /** * Contextual help for the new/edit achievement CPT screen * * @since Achievements (3.0) */ function dpa_achievement_new_contextual_help() { // Bail out if we're not on the right screen if ( dpa_get_achievement_post_type() != get_current_screen()->post_type ) return; // Most of this was copied from wpcore $customise_display = '

' . __( 'The title field and the big achievement Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to hide or reveal more boxes (Featured Image, Achievements, Slug) or to choose a 1- or 2-column layout for this screen.', 'dpa' ) . '

'; get_current_screen()->add_help_tab( array( 'id' => 'customise-display', 'title' => __( 'Customizing This Display', 'dpa' ), 'content' => $customise_display, ) ); $title_and_editor = '

' . __( 'Title - Enter a title for your achievement. After you enter a title, you’ll see the permalink below, which you can edit.', 'dpa' ) . '

'; $title_and_editor .= '

' . __( 'Achievement editor - Enter the text for your achievement. There are two modes of editing: Visual and Text. Choose the mode by clicking on the appropriate tab. Visual mode gives you a WYSIWYG editor. Click the last icon in the row to get a second row of controls. The Text mode allows you to enter HTML along with your achievement text. Line breaks will be converted to paragraphs automatically. You can insert media files by clicking the icons above the achievement editor and following the directions. You can go to the distraction-free writing screen via the Fullscreen icon in Visual mode (second to last in the top row) or the Fullscreen button in Text mode (last in the row). Once there, you can make buttons visible by hovering over the top area. Exit Fullscreen back to the regular achievement editor.', 'dpa' ) . '

'; get_current_screen()->add_help_tab( array( 'id' => 'title-post-editor', 'title' => __( 'Title and Achievement Editor', 'dpa' ), 'content' => $title_and_editor, ) ); $inserting_media = '

' . __( 'You can upload and insert media (images, audio, documents, etc.) by clicking the Add Media button. You can select from the images and files already uploaded to the Media Library, or upload new media to add to your achievement. To create an image gallery, select the images to add and click the “Create a new gallery” button.', 'dpa' ) . '

'; $inserting_media .= '

' . sprintf( __( 'You can also embed media from many popular websites including Twitter, YouTube, Flickr and others by pasting the media URL on its own line into the content of your post/page. Please refer to the WordPress Codex to learn more about embeds.', 'dpa' ), esc_url( 'http://codex.wordpress.org/Embeds' ) ) . '

'; get_current_screen()->add_help_tab( array( 'id' => 'inserting-media', 'title' => __( 'Inserting Media', 'dpa' ), 'content' => $inserting_media, ) ); $publish_box = '

' . __( 'Several boxes on this screen contain settings for how your achievement will be published, including:', 'dpa' ) . '

'; $publish_box .= ''; get_current_screen()->add_help_tab( array( 'id' => 'publish-box', 'title' => __( 'Publish Settings', 'dpa' ), 'content' => $publish_box, ) ); $achievements_box = '

' . __( 'Karma points - set the number of points (called karma) given to a user when they unlock an achievement.', 'dpa' ) . '

'; $achievements_box .= '

' . __( 'Type - there are two types of achievement, Award and Event. An Award is given by a site admin, whereas an Event is unlocked automatically when its criteria have been met.', 'dpa' ) . '

'; $achievements_box .= '

' . __( 'Event Achievements - this field appears when you create an Event achievement. Use the dropdown box to choose the events that you want to trigger this achievement.', 'dpa' ) . '

'; $achievements_box .= '

' . __( 'Events repeat - for Event achievements, set the number of times the events need to occur before the achievement is awarded.', 'dpa' ) . '

'; get_current_screen()->add_help_tab( array( 'id' => 'achievement-box', 'title' => __( 'Achievements Box', 'dpa' ), 'content' => $achievements_box, ) ); get_current_screen()->set_help_sidebar( '

' . __( 'For more information:', 'dpa' ) . '

' . '

' . __( 'Achievements Website', 'dpa' ) . '

' . '

' . __( 'Support Forums', 'dpa' ) . '

' ); } /** * Contextual help for the achievement CPT index screen * * @since Achievements (3.0) */ function dpa_achievement_index_contextual_help() { // Bail out if we're not on the right screen if ( dpa_get_achievement_post_type() != get_current_screen()->post_type ) return; // Most of this was copied from wpcore get_current_screen()->add_help_tab( array( 'id' => 'overview', 'title' => __( 'Overview', 'dpa' ), 'content' => '

' . __( 'This screen provides access to all of your achievements. You can customize the display of this screen to suit your workflow.', 'dpa' ) . '

' ) ); get_current_screen()->add_help_tab( array( 'id' => 'screen-content', 'title' => __( 'Screen Content', 'dpa' ), 'content' => '

' . __( 'You can customize the display of this screen’s contents in a number of ways:', 'dpa' ) . '

' . '' ) ); get_current_screen()->add_help_tab( array( 'id' => 'action-links', 'title' => __( 'Available Actions' ), 'content' => '

' . __( 'Hovering over a row in the achievements list will display action links that allow you to manage your achievement. You can perform the following actions:', 'dpa' ) . '

' . '' ) ); get_current_screen()->set_help_sidebar( '

' . __( 'For more information:', 'dpa' ) . '

' . '

' . __( 'Achievements Website', 'dpa' ) . '

' . '

' . __( 'Support Forums', 'dpa' ) . '

' ); }