Пример #1
0
/**
 * Single achievement slug field.
 *
 * @since Achievements (3.6)
 */
function dpa_admin_setting_callback_achievement_slug()
{
    ?>

	<input name="_dpa_singular_root_slug" id="_dpa_singular_root_slug" type="text" class="regular-text code" value="<?php 
    echo esc_attr(dpa_get_singular_root_slug());
    ?>
"<?php 
    dpa_maybe_admin_setting_disabled('_dpa_singular_root_slug');
    ?>
 required />

<?php 
}
Пример #2
0
 /**
  * Set up the post types for: achievement, achievement_progress
  *
  * @since Achievements (3.0)
  */
 public function register_post_types()
 {
     $cpt = $labels = $rewrite = $supports = array();
     /**
      * If the plugin's been activated network-wide, only allow the normal access and behaviour on the DPA_DATA_STORE site.
      * This prevents the admin controls showing up on the wrong site's wp-admin, as well as the overhead of unused rewrite rules.
      *
      * The problem with this is that the post type needs to be registered all on sites in a multisite all the time, otherwise
      * achievements can't be awarded. See _update_blog_date_on_post_publish() which tries to create (in our case) a
      * "dpa-progress" post.
      *
      * The solution to this is $post_type_is_public. If it's false, the post type is registered, but it's hidden from the admin,
      * isn't publicly queryable, doesn't create rewrite rules, and so on. If it's set to true, the post type behaves as normal.
      */
     $post_type_is_public = is_multisite() && dpa_is_running_networkwide() && get_current_blog_id() !== DPA_DATA_STORE ? false : true;
     // CPT labels
     $labels['achievement'] = array('add_new' => _x('Add New', 'achievement', 'achievements'), 'add_new_item' => __('Add New Achievement', 'achievements'), 'all_items' => __('All Achievements', 'achievements'), 'edit' => _x('Edit', 'achievement', 'achievements'), 'edit_item' => __('Edit Achievement', 'achievements'), 'menu_name' => __('Achievements', 'achievements'), 'name' => __('Achievements', 'achievements'), 'new_item' => __('New Achievement', 'achievements'), 'not_found' => __('No achievements found.', 'achievements'), 'not_found_in_trash' => __('No achievements found in Trash.', 'achievements'), 'search_items' => __('Search Achievements', 'achievements'), 'singular_name' => __('Achievement', 'achievements'), 'view' => __('View Achievement', 'achievements'), 'view_item' => __('View Achievement', 'achievements'));
     // CPT rewrite
     $rewrite['achievement'] = array('ep_mask' => 0, 'feed' => false, 'feeds' => false, 'pages' => true, 'slug' => dpa_get_singular_root_slug(), 'with_front' => false);
     // CPT supports
     $supports['achievement'] = array('editor', 'excerpt', 'revisions', 'thumbnail', 'title');
     $supports['achievement_progress'] = array('author');
     // CPT filter
     $cpt['achievement'] = apply_filters('dpa_register_post_type_achievement', array('capabilities' => dpa_get_achievement_caps(), 'capability_type' => array('achievement', 'achievements'), 'delete_with_user' => false, 'description' => _x('Achievements types (e.g. new post, new site, new user)', 'Achievement post type description', 'achievements'), 'has_archive' => $post_type_is_public ? dpa_get_root_slug() : false, 'labels' => $labels['achievement'], 'public' => $post_type_is_public, 'rewrite' => $rewrite['achievement'], 'register_meta_box_cb' => 'dpa_admin_setup_metaboxes', 'show_in_menu' => $post_type_is_public, 'show_ui' => dpa_current_user_can_see(dpa_get_achievement_post_type()), 'supports' => $supports['achievement'], 'taxonomies' => array('category')));
     $cpt['achievement_progress'] = apply_filters('dpa_register_post_type_achievement_progress', array('capabilities' => dpa_get_achievement_progress_caps(), 'capability_type' => array('achievement_progress', 'achievement_progresses'), 'delete_with_user' => true, 'description' => _x('Achievement Progress (e.g. unlocked achievements for a user, progress on an achievement for a user)', 'Achievement Progress post type description', 'achievements'), 'public' => false, 'query_var' => false, 'rewrite' => false, 'supports' => $supports['achievement_progress']));
     // Register Achievement post type
     register_post_type(dpa_get_achievement_post_type(), $cpt['achievement']);
     // Register Achievement Progress post type
     register_post_type(dpa_get_progress_post_type(), $cpt['achievement_progress']);
 }