0

私のプラグインでは、カスタム投稿タイプを作成し、サブスクライバーと管理者の役割の両方に機能を定義しました。

バックエンドにアクセスして、管理者ロールの機能のリストにある機能を見ると、追加したすべての機能がチェックされています。

ただし、管理者としてログインし、「pp_zoekertje」タイプの投稿をゴミ箱に移動しようとすると、wordpress から移動が許可されていないと表示されます。

もちろん、stackexchange や他のさまざまなサイトを検索しましたが、見つけられる唯一の解決策は、私が既に行っていることを正確に行うように指示することです。

どんな助けでも大歓迎です。

function create_pp_zoekertje_post_type(){
register_post_type('pp_zoekertje',
    array(
        'labels' => array(
            'name' => 'Zoekertjes',
            'singular_name' => 'Zoekertje',
            'add_new' => __('Nieuw Zoekertje'),
            'add_new_item' => __( 'Nieuw Zoekertje' ),
            'edit' => __( 'Bewerk' ),
            'edit_item' => __( 'Bewerk Zoekertje' ),
            'new_item' => __( 'Nieuw Zoekertje' ),
            'view' => __( 'Bekijk' ),
            'view_item' => __( 'Bekijk Zoekertje' ),
            'search_items' => __( 'Zoek Zoekertjes' ),
            'not_found' => __( 'Geen zoekertjes gevonden' ),
            'not_found_in_trash' => __( 'Geen zoekertjes gevonden in prullenbak' ),
            ),
        'public' => true,
        'has_archive' => true,
        'show_ui' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'hierarchical' => false,
        'query_var' => true,
        'supports' => array(
            'title',
            'editor',
            'revisions',
        ),
        'map_meta_cap' => true,
        'capability_type' => 'pp_zoekertje',
        'capabilities' => array(
            'edit_post' => 'edit_pp_zoekertje',
            'edit_posts' => 'edit_pp_zoekertjes',
            'edit_others_posts' => 'edit_others_pp_zoekertjes',
            'publish_posts' => 'publish_pp_zoekertjes',
            'edit_published_posts' => 'edit_published_pp_zoekertjes',
            'read_post' => 'read_pp_zoekertje',
            'read_private_posts' => 'read_private_pp_zoekertjes',
            'delete_post' => 'delete_pp_zoekertje',
            'delete_others_posts' => 'delete_others_pp_zoekertjes'
        ),
//            'taxonomies' => array('pp_zoekertje_taxonomy','category'),
    )
);

$subscriber_role = get_role('subscriber');
$subscriber_role->add_cap('edit_pp_zoekertje');
$subscriber_role->add_cap('edit_pp_zoekertjes');
$subscriber_role->add_cap('publish_pp_zoekertjes');
$subscriber_role->add_cap('read_pp_zoekertje');
$subscriber_role->add_cap('read_private_pp_zoekertjes');
$subscriber_role->add_cap('delete_pp_zoekertje');
}

function poppunt_classifieds_search_Init() {
    create_pp_zoekertje_post_type();
    if (!is_admin()) {
        wp_enqueue_script('jquery');
        wp_enqueue_script( 'poppunt-classifieds-handlebars', plugins_url( '/js/handlebars.js', __FILE__ ));
    }
}
add_action('init', 'poppunt_classifieds_search_Init');

add_action('admin_init', 'plugin_admin_init');
function plugin_admin_init(){
    $administrator_role = get_role('administrator');
    $administrator_role->add_cap('edit_pp_zoekertje');
    $administrator_role->add_cap('edit_pp_zoekertjes');
    $administrator_role->add_cap('edit_others_pp_zoekertjes');
    $administrator_role->add_cap('publish_pp_zoekertjes');
    $administrator_role->add_cap('read_pp_zoekertje');
    $administrator_role->add_cap('read_private_pp_zoekertjes');
    $administrator_role->add_cap('delete_pp_zoekertje');
    $administrator_role->add_cap('edit_published_pp_zoekertjes');
    $administrator_role->add_cap('delete_others_pp_zoekertjes');

    register_setting( 'pp_options', 'pp-options', 'pp_plugin_options_validate' );

    add_settings_section('pp_options_main', 'Algemene instellingen', 'pp_options_main_output', 'pp_options_menu');

    add_settings_field(
        'pp_zoekertjes_option_input_page',
        __('Pagina met invulformulier voor zoekertje (toevoegen/bewerken)'),
        'pp_zoekertjes_option_input_page',
        'pp_options_menu',
        'pp_options_main');

    add_settings_field(
        'pp_zoekertjes_option_my_ads_page',
        __('Mijn zoekertjes pagina'),
        'pp_zoekertjes_option_my_ads_page',
        'pp_options_menu',
        'pp_options_main');
}
4

1 に答える 1

0

コードでカスタム機能を作成する代わりに、次のプラグインを使用することを好みます。インストールが簡単で、これは非常に役立ちます。 プラグインのダウンロードはこちら

于 2013-10-24T12:06:57.720 に答える