コード例 #1
0
/**
 * Renders 'widefat' table.
 */
function wpcf_admin_ctt_list()
{
    $custom_types = get_option('wpcf-custom-types', array());
    $custom_taxonomies = get_option('wpcf-custom-taxonomies', array());
    if (empty($custom_types) && empty($custom_taxonomies)) {
        echo '<p>' . __('Custom Post Types are user-defined content types. Custom Taxonomies are used to categorize your content.', 'wpcf') . ' ' . __('You can read more about Custom Post Types and Taxonomies in this tutorial. <a href="http://wp-types.com/learn/custom-post-types/" target="_blank">http://wp-types.com/learn/custom-post-types/</a>', 'wpcf') . '</p>';
    }
    echo '<br /><a class="button-secondary" href="' . admin_url('admin.php?page=wpcf-edit-type') . '">' . __('Add Custom Post Type', 'wpcf') . '</a>' . '&nbsp;&nbsp;<a class="button-secondary" href="' . admin_url('admin.php?page=wpcf-edit-tax') . '">' . __('Add Custom Taxonomy', 'wpcf') . '</a><br /><br />';
    if (!empty($custom_types)) {
        $rows = array();
        $header = array('name' => __('Post Type Name', 'wpcf'), 'description' => __('Description', 'wpcf'), 'active' => __('Active', 'wpcf'), 'tax' => __('Taxonomies', 'wpcf'));
        foreach ($custom_types as $post_type => $type) {
            $name = '';
            $name .= '<a href="' . admin_url('admin.php?page=wpcf-edit-type&amp;wpcf-post-type=' . $post_type) . '">' . $type['labels']['name'] . '</a>';
            $name .= '<br />';
            $name .= '<a href="' . admin_url('admin.php?page=wpcf-edit-type&amp;wpcf-post-type=' . $post_type) . '">' . __('Edit', 'wpcf') . '</a> | ';
            $name .= empty($type['disabled']) ? wpcf_admin_custom_types_get_ajax_deactivation_link($post_type) . ' | ' : wpcf_admin_custom_types_get_ajax_activation_link($post_type) . ' | ';
            $name .= '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&amp;' . 'wpcf_action=delete_post_type&amp;wpcf-post-type=' . $post_type . '&amp;wpcf_ajax_update=wpcf_list_ajax_response_' . $post_type) . '&amp;_wpnonce=' . wp_create_nonce('delete_post_type') . '&amp;wpcf_warning=' . __('Are you sure?', 'wpcf') . '" class="wpcf-ajax-link" id="wpcf-list-delete-' . $post_type . '">' . __('Delete Permanently', 'wpcf') . '</a>';
            $name .= '<div id="wpcf_list_ajax_response_' . $post_type . '"></div>';
            $rows[$post_type]['name'] = $name;
            $rows[$post_type]['description'] = isset($type['description']) ? htmlspecialchars(stripslashes($type['description']), ENT_QUOTES) : '';
            $rows[$post_type]['active-' . $post_type] = !empty($type['disabled']) ? __('No', 'wpcf') : __('Yes', 'wpcf');
            $output = !empty($type['taxonomies']) ? implode(', ', array_keys($type['taxonomies'])) : __('None', 'wpcf');
            $rows[$post_type]['tax'] = $output;
        }
        // Render table
        wpcf_admin_widefat_table('wpcf_types_list', $header, $rows);
    }
    if (!empty($custom_taxonomies)) {
        $rows = array();
        $header = array('name' => __('Taxonomy Name', 'wpcf'), 'description' => __('Description', 'wpcf'), 'active' => __('Active', 'wpcf'), 'post_types' => __('Post Types', 'wpcf'));
        foreach ($custom_taxonomies as $taxonomy => $data) {
            $name = '';
            $name .= '<a href="' . admin_url('admin.php?page=wpcf-edit-tax&amp;wpcf-tax=' . $taxonomy) . '">' . $data['labels']['name'] . '</a>';
            $name .= '<br />';
            $name .= '<a href="' . admin_url('admin.php?page=wpcf-edit-tax&amp;wpcf-tax=' . $taxonomy) . '">' . __('Edit', 'wpcf') . '</a> | ';
            $name .= empty($data['disabled']) ? wpcf_admin_custom_taxonomies_get_ajax_deactivation_link($taxonomy) . ' | ' : wpcf_admin_custom_taxonomies_get_ajax_activation_link($taxonomy) . ' | ';
            $name .= '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&amp;' . 'wpcf_action=delete_taxonomy&amp;wpcf-tax=' . $taxonomy . '&amp;wpcf_ajax_update=wpcf_list_ajax_response_' . $taxonomy) . '&amp;_wpnonce=' . wp_create_nonce('delete_taxonomy') . '&amp;wpcf_warning=' . __('Are you sure?', 'wpcf') . '" class="wpcf-ajax-link" id="wpcf-list-delete-' . $taxonomy . '">' . __('Delete Permanently', 'wpcf') . '</a>';
            $name .= '<div id="wpcf_list_ajax_response_' . $taxonomy . '"></div>';
            $rows[$taxonomy]['name'] = $name;
            $rows[$taxonomy]['description'] = isset($data['description']) ? htmlspecialchars(stripslashes($data['description']), ENT_QUOTES) : '';
            $rows[$taxonomy]['active-' . $taxonomy] = !empty($data['disabled']) ? __('No', 'wpcf') : __('Yes', 'wpcf');
            $output = !empty($data['supports']) ? implode(', ', array_keys($data['supports'])) : __('None', 'wpcf');
            $rows[$taxonomy]['post_types'] = $output;
        }
        // Render table
        echo '<br />';
        wpcf_admin_widefat_table('wpcf_tax_list', $header, $rows);
    }
}
コード例 #2
0
ファイル: fields-list.php プロジェクト: sandum150/cheltuieli
/**
 * Renders 'widefat' table.
 */
function wpcf_admin_fields_list()
{
    $groups = wpcf_admin_fields_get_groups();
    if (empty($groups)) {
        echo '<p>' . __("To use custom fields, please create a group to hold them.", 'wpcf') . '</p>';
        echo '<br /><a class="button-primary" href="' . admin_url('admin.php?page=wpcf-edit') . '">' . __('Add a custom fields group', 'wpcf') . '</a><br /><br />';
    } else {
        echo '<br /><a class="button-secondary" href="' . admin_url('admin.php?page=wpcf-edit') . '">' . __('Add a custom fields group', 'wpcf') . '</a><br /><br />';
        $rows = array();
        $header = array('group_name' => __('Group name', 'wpcf'), 'group_description' => __('Description', 'wpcf'), 'group_active' => __('Active', 'wpcf'), 'group_post_types' => __('Post types', 'wpcf'), 'group_taxonomies' => __('Taxonomies', 'wpcf'));
        foreach ($groups as $group) {
            // Set 'name' column
            $name = '';
            $name .= '<a href="' . admin_url('admin.php?page=wpcf-edit&amp;group_id=' . $group['id']) . '">' . $group['name'] . '</a>';
            $name .= '<br />';
            $name .= '<a href="' . admin_url('admin.php?page=wpcf-edit&amp;group_id=' . $group['id']) . '">' . __('Edit', 'wpcf') . '</a> | ';
            $name .= $group['is_active'] ? wpcf_admin_fields_get_ajax_deactivation_link($group['id']) . ' | ' : wpcf_admin_fields_get_ajax_activation_link($group['id']) . ' | ';
            $name .= '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&amp;' . 'wpcf_action=delete_group&amp;group_id=' . $group['id'] . '&amp;wpcf_ajax_update=wpcf_list_ajax_response_' . $group['id']) . '&amp;_wpnonce=' . wp_create_nonce('delete_group') . '&amp;wpcf_warning=' . __('Are you sure?', 'wpcf') . '" class="wpcf-ajax-link" ' . 'id="wpcf-list-delete-' . $group['id'] . '">' . __('Delete Permanently', 'wpcf') . '</a>';
            $name .= '<div id="wpcf_list_ajax_response_' . $group['id'] . '"></div>';
            $rows[$group['id']]['name'] = $name;
            $rows[$group['id']]['raw_name'] = $group['name'];
            $rows[$group['id']]['description'] = $group['description'];
            $rows[$group['id']]['active-' . $group['id']] = $group['is_active'] ? __('Yes', 'wpcf') : __('No', 'wpcf');
            $rows[$group['id']]['status'] = $group['is_active'] ? 'active' : 'inactive';
            // Set 'post_tpes' column
            $post_types = wpcf_admin_get_post_types_by_group($group['id']);
            $rows[$group['id']]['post_types'] = empty($post_types) ? __('All post types', 'wpcf') : implode(', ', $post_types);
            // Set 'taxonomies' column
            $taxonomies = wpcf_admin_get_taxonomies_by_group($group['id']);
            $output = '';
            if (empty($taxonomies)) {
                $output = __('None', 'wpcf');
            } else {
                foreach ($taxonomies as $taxonomy => $terms) {
                    $output .= '<em>' . $taxonomy . '</em>: ';
                    $terms_output = array();
                    foreach ($terms as $term_id => $term) {
                        $terms_output[] = $term['name'];
                    }
                    $output .= implode(', ', $terms_output) . '<br />';
                }
            }
            $rows[$group['id']]['tax'] = $output;
        }
        uasort($rows, 'wpcf_admin_fields_list_sort');
        // Render table
        wpcf_admin_widefat_table('wpcf_groups_list', $header, $rows);
    }
    do_action('wpcf_groups_list_table_after');
}
コード例 #3
0
ファイル: fields-list.php プロジェクト: adisonc/MaineLearning
/**
 * Renders 'widefat' table.
 */
function wpcf_admin_fields_list()
{
    $groups = wpcf_admin_fields_get_groups();
    if (empty($groups)) {
        echo '<p>' . __("Custom Fields (also known as post-meta) are information attached to WordPress posts. This data can then be queried and filtered in your database. With Types you can create Custom Field Groups which are then attached to any post type (including Posts, Pages and Custom Post Types) or taxonomy.", 'wpcf') . '<br /><br />' . __('You can read more about Custom Fields in this tutorial: <a href="http://wp-types.com/user-guides/using-custom-fields/" target="_blank">http://wp-types.com/user-guides/using-custom-fields/ &raquo;</a>.', 'wpcf') . '</p>';
    }
    echo '<br /><a class="button-secondary" href="' . admin_url('admin.php?page=wpcf-edit') . '">' . __('Add a custom fields group', 'wpcf') . '</a><br /><br />';
    if (!empty($groups)) {
        $rows = array();
        $header = array('group_name' => __('Group name', 'wpcf'), 'group_description' => __('Description', 'wpcf'), 'group_active' => __('Active', 'wpcf'), 'group_post_types' => __('Post types', 'wpcf'), 'group_taxonomies' => __('Taxonomies', 'wpcf'));
        foreach ($groups as $group) {
            // Set 'name' column
            $name = '';
            $name .= '<a href="' . admin_url('admin.php?page=wpcf-edit&amp;group_id=' . $group['id']) . '">' . $group['name'] . '</a>';
            $name .= '<br />';
            $name .= '<a href="' . admin_url('admin.php?page=wpcf-edit&amp;group_id=' . $group['id']) . '">' . __('Edit', 'wpcf') . '</a> | ';
            $name .= $group['is_active'] ? wpcf_admin_fields_get_ajax_deactivation_link($group['id']) . ' | ' : wpcf_admin_fields_get_ajax_activation_link($group['id']) . ' | ';
            $name .= '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&amp;' . 'wpcf_action=delete_group&amp;group_id=' . $group['id'] . '&amp;wpcf_ajax_update=wpcf_list_ajax_response_' . $group['id']) . '&amp;_wpnonce=' . wp_create_nonce('delete_group') . '&amp;wpcf_warning=' . __('Are you sure?', 'wpcf') . '" class="wpcf-ajax-link" ' . 'id="wpcf-list-delete-' . $group['id'] . '">' . __('Delete Permanently', 'wpcf') . '</a>';
            $name .= '<div id="wpcf_list_ajax_response_' . $group['id'] . '"></div>';
            $rows[$group['id']]['name'] = $name;
            $rows[$group['id']]['description'] = $group['description'];
            $rows[$group['id']]['active-' . $group['id']] = $group['is_active'] ? __('Yes', 'wpcf') : __('No', 'wpcf');
            // Set 'post_tpes' column
            $post_types = wpcf_admin_get_post_types_by_group($group['id']);
            $rows[$group['id']]['post_types'] = empty($post_types) ? __('None', 'wpcf') : implode(', ', $post_types);
            // Set 'taxonomies' column
            $taxonomies = wpcf_admin_get_taxonomies_by_group($group['id']);
            $output = '';
            if (empty($taxonomies)) {
                $output = __('None', 'wpcf');
            } else {
                foreach ($taxonomies as $taxonomy => $terms) {
                    $output .= '<em>' . $taxonomy . '</em>: ';
                    $terms_output = array();
                    foreach ($terms as $term_id => $term) {
                        $terms_output[] = $term['name'];
                    }
                    $output .= implode(', ', $terms_output) . '<br />';
                }
            }
            $rows[$group['id']]['tax'] = $output;
        }
        // Render table
        wpcf_admin_widefat_table('wpcf_groups_list', $header, $rows);
    }
    do_action('wpcf_groups_list_table_after');
}
コード例 #4
0
/**
 * Renders 'widefat' table.
 */
function wpcf_admin_usermeta_list()
{
    $post_type = 'wp-types-user-group';
    $groups = wpcf_admin_fields_get_groups('wp-types-user-group');
    if (empty($groups)) {
        echo '<p>' . __("User Fields, also known as user-meta, are additional fields that belong to user profiles.", 'wpcf') . '</p>';
    }
    echo '<br /><a class="button-secondary" href="' . admin_url('admin.php?page=wpcf-edit-usermeta') . '">' . __('Add a user meta group', 'wpcf') . '</a><br /><br />';
    if (!empty($groups)) {
        $rows = array();
        $header = array('group_name' => __('Group name', 'wpcf'), 'group_description' => __('Description', 'wpcf'), 'group_active' => __('Active', 'wpcf'), 'group_post_types' => __('Available for', 'wpcf'));
        foreach ($groups as $group) {
            // Set 'name' column
            $name = '';
            $name .= '<a href="' . admin_url('admin.php?page=wpcf-edit-usermeta&amp;group_id=' . $group['id']) . '">' . $group['name'] . '</a>';
            $name .= '<br />';
            $name .= '<a href="' . admin_url('admin.php?page=wpcf-edit-usermeta&amp;group_id=' . $group['id']) . '">' . __('Edit', 'wpcf') . '</a> | ';
            $name .= $group['is_active'] ? wpcf_admin_usermeta_get_ajax_deactivation_link($group['id']) . ' | ' : wpcf_admin_usermeta_get_ajax_activation_link($group['id']) . ' | ';
            $name .= '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&amp;' . 'wpcf_action=delete_usermeta_group&amp;group_id=' . $group['id'] . '&amp;wpcf_ajax_update=wpcf_list_ajax_response_' . $group['id']) . '&amp;_wpnonce=' . wp_create_nonce('delete_usermeta_group') . '&amp;wpcf_warning=' . __('Are you sure?', 'wpcf') . '" class="wpcf-ajax-link" ' . 'id="wpcf-list-delete-' . $group['id'] . '">' . __('Delete Permanently', 'wpcf') . '</a>';
            $name .= '<div id="wpcf_list_ajax_response_' . $group['id'] . '"></div>';
            $rows[$group['id']]['name'] = $name;
            $rows[$group['id']]['description'] = $group['description'];
            $rows[$group['id']]['active-' . $group['id']] = $group['is_active'] ? __('Yes', 'wpcf') : __('No', 'wpcf');
            $show_for = wpcf_admin_get_groups_showfor_by_group($group['id']);
            if (function_exists('wpcf_access_register_caps')) {
                $show_for = __('This groups visibility is also controlled by the Access plugin.', 'wpcf');
            } else {
                $show_for = count($show_for) == 0 ? __('Displayed for all users roles', 'wpcf') : ucwords(implode($show_for, ', '));
            }
            $rows[$group['id']]['group_post_types'] = $show_for;
        }
        // Render table
        wpcf_admin_widefat_table('wpcf_groups_list', $header, $rows);
    }
    do_action('wpcf_groups_list_table_after');
}