function wpcf_admin_common_metabox_save($cf, $button_text) { $form = array(); $form['submit-open'] = wpcf_admin_metabox_begin(__('Save', 'wpcf'), 'submitdiv', false, false); $form['submit-div-open'] = array('#type' => 'markup', '#markup' => '<div class="submitbox" id="submitpost"><div id="major-publishing-actions"><div id="publishing-action"><span class="spinner"></span>'); $form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => $button_text, '#attributes' => array('class' => 'button-primary wpcf-disabled-on-submit')); $form['submit-div-close'] = array('#type' => 'markup', '#markup' => '</div><div class="clear"></div></div></div>'); $form['submit-close'] = wpcf_admin_metabox_end(); return $form; }
function wpcf_admin_common_metabox_save($ct, $button_text, $type = 'custom-post-type') { $form = array(); if (WPCF_Roles::user_can_edit($type, $ct)) { $form['submit-open'] = wpcf_admin_metabox_begin(__('Save', 'wpcf'), 'submitdiv', false, false, '_builtin'); $form['submit-div-open'] = array('#type' => 'markup', '#markup' => '<div class="submitbox" id="submitpost"><div id="major-publishing-actions"><div id="publishing-action"><span class="spinner"></span>', '_builtin' => true); $form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => $button_text, '#attributes' => array('class' => 'button-primary wpcf-disabled-on-submit'), '_builtin' => true); /** * add data attribute for _builtin post type */ if (isset($ct['_builtin']) && $ct['_builtin']) { $form['submit']['#attributes']['data-post_type_is_builtin'] = '_builtin'; } $form['submit-div-close'] = array('#type' => 'markup', '#markup' => '</div><div class="clear"></div></div></div>', '_builtin' => true); $form['submit-close'] = wpcf_admin_metabox_end(true, '_builtin'); } return $form; }
function wpcf_admin_metabox_relationship($post_type) { $form = array(); $form['table-pr-open'] = wpcf_admin_metabox_begin(__('Post Relationship', 'wpcf'), 'relationship', 'wpcf-types-form-pr-table', false); /** * belongs/children section */ $has = wpcf_pr_admin_get_has($post_type['slug']); $belongs = wpcf_pr_admin_get_belongs($post_type['slug']); $post_types = get_post_types('', 'objects'); if (empty($has) || empty($post_type['slug'])) { $txt_has = __("Children: None", 'wpcf'); } else { $txt_has = array(); foreach ($has as $pr_key => $pr_data) { $txt_has[] = isset($post_types[$pr_key]) ? $post_types[$pr_key]->labels->singular_name : $pr_key; } $txt_has = sprintf(__("Children: %s", 'wpcf'), implode(', ', $txt_has)); } if (!empty($belongs)) { $txt_belongs = array(); foreach ($belongs as $pr_key => $pr_data) { $txt_belongs[] = isset($post_types[$pr_key]) ? $post_types[$pr_key]->labels->singular_name : $pr_key; } $txt_belongs = sprintf(__("Parent: %s", 'wpcf'), implode(', ', $txt_belongs)); } else { $txt_belongs = __("Parent: None", 'wpcf'); } // Others belonging to if (!empty($belongs)) { $txt_belongs = array(); foreach ($belongs as $pr_key => $pr_data) { $txt_belongs[] = isset($post_types[$pr_key]) ? $post_types[$pr_key]->labels->singular_name : $pr_key; } $txt_belongs = sprintf(__("Parent: %s", 'wpcf'), implode(', ', $txt_belongs)); } else { $txt_belongs = __("Parent: None", 'wpcf'); } $form['table-pr-belongs'] = array('#type' => 'markup', '#markup' => '<div style="margin: 10px 0 10px 0;"><span class="wpcf-pr-belongs-summary">' . $txt_belongs . '</span> ' . '<a href="javascript:void(0);" id="wpcf-pr-belongs-edit" class="button-secondary wpcf-pr-edit">' . __('Edit', 'wpcf') . '</a>'); $options = array(); /** * build excluded post types */ global $wpcf; $excluded_post_types = $wpcf->excluded_post_types; $excluded_post_types[] = $post_type['slug']; foreach ($post_types as $temp_post_type_slug => $temp_post_type) { if (in_array($temp_post_type_slug, $excluded_post_types) || !$temp_post_type->show_ui && !apply_filters('wpcf_show_ui_hide_in_relationships', true)) { continue; } // Check if it's in has if (isset($has[$temp_post_type_slug])) { continue; } $options[$temp_post_type_slug]['#name'] = 'ct[post_relationship][belongs][' . $temp_post_type_slug . ']'; $options[$temp_post_type_slug]['#title'] = $temp_post_type->labels->singular_name; $options[$temp_post_type_slug]['#default_value'] = isset($belongs[$temp_post_type_slug]); $options[$temp_post_type_slug]['#inline'] = true; $options[$temp_post_type_slug]['#after'] = ' '; if (is_rtl()) { $options[$temp_post_type_slug]['#before'] = '<div style="float:right;margin-left:10px;">'; $options[$temp_post_type_slug]['#after'] .= '</div>'; } } $form['table-pr-has-form'] = array('#type' => 'checkboxes', '#options' => $options, '#name' => 'ct[post_relationship]', '#before' => '<div style="display:none; margin: 10px 0 20px 0;">', '#after' => '<br /><br /><a href="javascript:void(0);" class="button-primary wpcf-pr-belongs-apply">' . __('Apply', 'wpcf') . '</a> <a href="javascript:void(0);" class="button-secondary wpcf-pr-belongs-cancel">' . __('Cancel', 'wpcf') . '</a></div></div>', '#inline' => true); $form['table-pr-has'] = array('#type' => 'markup', '#markup' => '<div style="margin: 10px 0 5px 0;"><span class="wpcf-pr-has-summary">' . $txt_has . '</span> ' . '<a href="javascript:void(0);" id="wpcf-pr-has-edit" class="button-secondary wpcf-pr-edit">' . __('Edit', 'wpcf') . '</a>'); $options = array(); foreach ($post_types as $temp_post_type_slug => $temp_post_type) { if (in_array($temp_post_type_slug, $excluded_post_types) || !$temp_post_type->show_ui && !apply_filters('wpcf_show_ui_hide_in_relationships', true)) { continue; } // Check if it already belongs if (isset($belongs[$temp_post_type_slug])) { continue; } $options[$temp_post_type_slug]['#name'] = 'ct[post_relationship][has][' . $temp_post_type_slug . ']'; $options[$temp_post_type_slug]['#title'] = $temp_post_type->labels->singular_name; $options[$temp_post_type_slug]['#default_value'] = isset($has[$temp_post_type_slug]); $options[$temp_post_type_slug]['#inline'] = true; $options[$temp_post_type_slug]['#after'] = isset($has[$temp_post_type_slug]) ? '' . '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&wpcf_action=pt_edit_fields&child=' . $temp_post_type_slug . '&parent=' . $post_type['slug'] . '&_wpnonce=' . wp_create_nonce('pt_edit_fields') . '&KeepThis=true&TB_iframe=true') . '" class="thickbox" title="' . __('Select child fields to be displayed', 'wpcf') . '">(' . __('Edit fields', 'wpcf') . ')</a> ' : '' . '<a href="javascript:void(0);" style="color:Gray;" title="' . __('Please save the page first, before you can edit the child items', 'wpcf') . '">(' . __('Edit fields', 'wpcf') . ')</a> '; if (is_rtl()) { $options[$temp_post_type_slug]['#before'] = '<div style="float:right;margin-left:10px;">'; $options[$temp_post_type_slug]['#after'] .= '</div>'; } } $form['table-pr-belongs-form'] = array('#type' => 'checkboxes', '#options' => $options, '#name' => 'ct[post_relationship]', '#before' => '<div style="display:none; margin: 10px 0 20px 0;">', '#after' => '<br /><br /><a href="javascript:void(0);" class="button-primary wpcf-pr-has-apply">' . __('Apply', 'wpcf') . '</a> <a href="javascript:void(0);" class="button-secondary wpcf-pr-has-cancel">' . __('Cancel', 'wpcf') . '</a></div></div>', '#inline' => true); $form['table-pr-explanation'] = array('#type' => 'markup', '#markup' => '<p>' . __("You can choose which fields will show when editing parent pages.", 'wpcf') . '<br />' . __("Click on the 'edit' button to select them for each parent.", 'wpcf') . '<br />' . sprintf(__('Learn about %sPost Type Relationships%s', 'wpcf'), '<a href="http://wp-types.com/documentation/user-guides/creating-post-type-relationships/" target="_blank">', ' »</a>') . '</p>'); /** * close form */ $form['table-pr-close'] = wpcf_admin_metabox_end(); /** * additional settings */ wpcf_admin_add_js_settings('wpcf_pr_has_empty_txt', '\'' . __("Children: None", 'wpcf') . '\''); wpcf_admin_add_js_settings('wpcf_pr_has_txt', '\'' . __("Children: %s", 'wpcf') . '\''); wpcf_admin_add_js_settings('wpcf_pr_belongs_empty_txt', '\'' . __("Parent: None", 'wpcf') . '\''); wpcf_admin_add_js_settings('wpcf_pr_belongs_txt', '\'' . __("Parent: %s", 'wpcf') . '\''); return $form; }
/** * Options */ function wpcf_admin_metabox_options($ct) { $form = array(); $form['table-6-open'] = wpcf_admin_metabox_begin(__('Options', 'wpcf'), 'options', 'wpcf-types-form-table'); $form['rewrite-enabled'] = array('#type' => 'checkbox', '#title' => __('Rewrite', 'wpcf'), '#name' => 'ct[rewrite][enabled]', '#description' => __('Rewrite permalinks with this format. False to prevent rewrite. Default: true and use post type as slug.', 'wpcf'), '#default_value' => !empty($ct['rewrite']['enabled']), '#inline' => true); $form['rewrite-custom'] = array('#type' => 'radios', '#name' => 'ct[rewrite][custom]', '#options' => array(__('Use the normal WordPress URL logic', 'wpcf') => 'normal', __('Use a custom URL format', 'wpcf') => 'custom'), '#default_value' => empty($ct['rewrite']['custom']) || $ct['rewrite']['custom'] != 'custom' ? 'normal' : 'custom', '#inline' => true, '#after' => '<br />'); $hidden = empty($ct['rewrite']['custom']) || $ct['rewrite']['custom'] != 'custom' ? ' class="hidden"' : ''; $form['rewrite-slug'] = array('#type' => 'textfield', '#name' => 'ct[rewrite][slug]', '#description' => __('Optional.', 'wpcf') . ' ' . __("Prepend posts with this slug - defaults to post type's name.", 'wpcf'), '#value' => isset($ct['rewrite']['slug']) ? $ct['rewrite']['slug'] : '', '#inline' => true, '#before' => '<div id="wpcf-types-form-rewrite-toggle"' . $hidden . '>', '#after' => '</div>', '#validate' => array('rewriteslug' => array('value' => 'true'))); $form['rewrite-with_front'] = array('#type' => 'checkbox', '#title' => __('Allow permalinks to be prepended with front base', 'wpcf'), '#name' => 'ct[rewrite][with_front]', '#description' => __('Example: if your permalink structure is /blog/, then your links will be: false->/news/, true->/blog/news/.', 'wpcf') . ' ' . __('Defaults to true.', 'wpcf'), '#default_value' => !empty($ct['rewrite']['with_front']), '#inline' => true); $form['rewrite-feeds'] = array('#type' => 'checkbox', '#name' => 'ct[rewrite][feeds]', '#title' => __('Feeds', 'wpcf'), '#description' => __('Defaults to has_archive value.', 'wpcf'), '#default_value' => !empty($ct['rewrite']['feeds']), '#value' => 1, '#inline' => true); $form['rewrite-pages'] = array('#type' => 'checkbox', '#name' => 'ct[rewrite][pages]', '#title' => __('Pages', 'wpcf'), '#description' => __('Defaults to true.', 'wpcf'), '#default_value' => !empty($ct['rewrite']['pages']), '#value' => 1, '#inline' => true); $show_in_menu_page = isset($ct['show_in_menu_page']) ? $ct['show_in_menu_page'] : ''; $hidden = !empty($ct['show_in_menu']) ? '' : ' class="hidden"'; $form['vars'] = array('#type' => 'checkboxes', '#name' => 'ct[vars]', '#inline' => true, '#options' => array('has_archive' => array('#name' => 'ct[has_archive]', '#default_value' => !empty($ct['has_archive']), '#title' => __('has_archive', 'wpcf'), '#description' => __('Allow custom post type to have index page.', 'wpcf') . '<br />' . __('Default: not set.', 'wpcf'), '#inline' => true), 'show_in_menu' => array('#name' => 'ct[show_in_menu]', '#default_value' => !empty($ct['show_in_menu']), '#title' => __('show_in_menu', 'wpcf'), '#description' => __('Whether to show the post type in the admin menu and where to show that menu. Note that show_ui must be true.', 'wpcf') . '<br />' . __('Default: null.', 'wpcf'), '#after' => '<div id="wpcf-types-form-showinmenu-toggle"' . $hidden . '><input type="text" name="ct[show_in_menu_page]" style="width:50%;" value="' . $show_in_menu_page . '" /><div class="description wpcf-form-description wpcf-form-description-checkbox description-checkbox">' . __('Optional.', 'wpcf') . ' ' . __("Top level page like 'tools.php' or 'edit.php?post_type=page'", 'wpcf') . '</div></div>', '#inline' => true), 'show_ui' => array('#name' => 'ct[show_ui]', '#default_value' => !empty($ct['show_ui']), '#title' => __('show_ui', 'wpcf'), '#description' => __('Generate a default UI for managing this post type.', 'wpcf') . '<br />' . __('Default: value of public argument.', 'wpcf'), '#inline' => true), 'publicly_queryable' => array('#name' => 'ct[publicly_queryable]', '#default_value' => !empty($ct['publicly_queryable']), '#title' => __('publicly_queryable', 'wpcf'), '#description' => __('Whether post_type queries can be performed from the front end.', 'wpcf') . '<br />' . __('Default: value of public argument.', 'wpcf'), '#inline' => true), 'exclude_from_search' => array('#name' => 'ct[exclude_from_search]', '#default_value' => !empty($ct['exclude_from_search']), '#title' => __('exclude_from_search', 'wpcf'), '#description' => __('Whether to exclude posts with this post type from search results.', 'wpcf') . '<br />' . __('Default: value of the opposite of the public argument.', 'wpcf'), '#inline' => true), 'hierarchical' => array('#name' => 'ct[hierarchical]', '#default_value' => !empty($ct['hierarchical']), '#title' => __('hierarchical', 'wpcf'), '#description' => __('Whether the post type is hierarchical. Allows Parent to be specified.', 'wpcf') . '<br />' . __('Default: false.', 'wpcf'), '#inline' => true), 'can_export' => array('#name' => 'ct[can_export]', '#default_value' => !empty($ct['can_export']), '#title' => __('can_export', 'wpcf'), '#description' => __('Can this post_type be exported.', 'wpcf') . '<br />' . __('Default: true.', 'wpcf'), '#inline' => true), 'show_in_nav_menus' => array('#name' => 'ct[show_in_nav_menus]', '#default_value' => !empty($ct['show_in_nav_menus']), '#title' => __('show_in_nav_menus', 'wpcf'), '#description' => __('Whether post_type is available for selection in navigation menus.', 'wpcf') . '<br />' . __('Default: value of public argument.', 'wpcf'), '#inline' => true))); $query_var = isset($ct['query_var']) ? $ct['query_var'] : ''; $hidden = !empty($ct['query_var_enabled']) ? '' : ' class="hidden"'; $form['query_var'] = array('#type' => 'checkbox', '#name' => 'ct[query_var_enabled]', '#title' => 'query_var', '#description' => __('False to prevent queries, or string value of the query var to use for this post type.', 'wpcf') . '<br />' . __('Default: true - set to $post_type.', 'wpcf'), '#default_value' => !empty($ct['query_var_enabled']), '#after' => '<div id="wpcf-types-form-queryvar-toggle"' . $hidden . '><input type="text" name="ct[query_var]" value="' . $query_var . '" style="width:50%;" /><div class="description wpcf-form-description wpcf-form-description-checkbox description-checkbox">' . __('Optional', 'wpcf') . '. ' . __('String to customize query var', 'wpcf') . '</div></div>', '#inline' => true); $form['permalink_epmask'] = array('#type' => 'textfield', '#name' => 'ct[permalink_epmask]', '#title' => __('Permalink epmask', 'wpcf'), '#description' => sprintf(__('Default value EP_PERMALINK. More info here %s.', 'wpcf'), '<a href="http://core.trac.wordpress.org/ticket/12605" target="_blank">link</a>'), '#value' => isset($ct['permalink_epmask']) ? $ct['permalink_epmask'] : '', '#inline' => true); $form['table-6-close'] = wpcf_admin_metabox_end(); return $form; }
/** * Options */ function wpcf_admin_metabox_options($data) { $form = array(); $form['table-' . __FUNCTION__ . '-open'] = wpcf_admin_metabox_begin(__('Options', 'wpcf'), 'options', 'wpcf-types-form-options-table'); $form['make-hierarchical'] = array('#type' => 'radios', '#name' => 'ct[hierarchical]', '#default_value' => empty($data['hierarchical']) || $data['hierarchical'] == 'flat' ? 'flat' : 'hierarchical', '#inline' => true, '#options' => array(__('Hierarchical - like post categories, with parent / children relationship and checkboxes to select taxonomy', 'wpcf') => 'hierarchical', __('Flat - like post tags, with a text input to enter terms', 'wpcf') => 'flat'), '#after' => '<br /><br />'); $form['rewrite-enabled'] = array('#type' => 'checkbox', '#force_boolean' => true, '#title' => __('Rewrite', 'wpcf'), '#name' => 'ct[rewrite][enabled]', '#description' => __('Rewrite permalinks with this format. Default will use $taxonomy as query var.', 'wpcf'), '#default_value' => !empty($data['rewrite']['enabled']), '#inline' => true); $hidden = empty($data['rewrite']['enabled']) ? ' class="hidden"' : ''; $form['rewrite-slug'] = array('#type' => 'textfield', '#name' => 'ct[rewrite][slug]', '#title' => __('Prepend posts with this slug', 'wpcf'), '#description' => __('Optional', 'wpcf') . '. ' . __("Prepend posts with this slug - defaults to taxonomy's name.", 'wpcf'), '#value' => isset($data['rewrite']['slug']) ? $data['rewrite']['slug'] : '', '#inline' => true, '#before' => '<div id="wpcf-types-form-rewrite-toggle"' . $hidden . '>', '#after' => '</div>', '#validate' => array('rewriteslug' => array('value' => 'true'))); $form['rewrite-with_front'] = array('#type' => 'checkbox', '#force_boolean' => true, '#title' => __('Allow permalinks to be prepended with front base', 'wpcf'), '#name' => 'ct[rewrite][with_front]', '#description' => __('Defaults to true.', 'wpcf'), '#default_value' => !empty($data['rewrite']['with_front']), '#inline' => true); $form['rewrite-hierarchical'] = array('#type' => 'checkbox', '#name' => 'ct[rewrite][hierarchical]', '#title' => __('Hierarchical URLs', 'wpcf'), '#description' => sprintf(__('True or false allow hierarchical urls (implemented in %sVersion 3.1%s).', 'wpcf'), '<a href="http://codex.wordpress.org/Version_3.1" title="Version 3.1" target="_blank">', '</a>'), '#default_value' => !empty($data['rewrite']['hierarchical']), '#inline' => true); $form['vars'] = array('#type' => 'checkboxes', '#name' => 'ct[advanced]', '#inline' => true, '#options' => array('show_ui' => array('#name' => 'ct[show_ui]', '#default_value' => !empty($data['show_ui']), '#title' => __('show_ui', 'wpcf'), '#description' => __('Whether to generate a default UI for managing this taxonomy.', 'wpcf') . '<br />' . __('Default: if not set, defaults to value of public argument.', 'wpcf'), '#inline' => true), 'show_in_nav_menus' => array('#name' => 'ct[show_in_nav_menus]', '#default_value' => !empty($data['show_in_nav_menus']), '#title' => __('show_in_nav_menus', 'wpcf'), '#description' => __('True makes this taxonomy available for selection in navigation menus.', 'wpcf') . '<br />' . __('Default: if not set, defaults to value of public argument.', 'wpcf'), '#inline' => true), 'show_tagcloud' => array('#name' => 'ct[show_tagcloud]', '#default_value' => !empty($data['show_tagcloud']), '#title' => __('show_tagcloud', 'wpcf'), '#description' => __('Whether to allow the Tag Cloud widget to use this taxonomy.', 'wpcf') . '<br />' . __('Default: if not set, defaults to value of show_ui argument.', 'wpcf'), '#inline' => true))); if (wpcf_compare_wp_version('3.5', '>=')) { $form['vars']['#options']['show_admin_column'] = array('#name' => 'ct[show_admin_column]', '#default_value' => !empty($data['show_admin_column']), '#title' => __('show_admin_column', 'wpcf'), '#description' => __('Whether to allow automatic creation of taxonomy columns on associated post-types.', 'wpcf') . '<br />' . __('Default: false.', 'wpcf'), '#inline' => true); } $query_var = isset($data['query_var']) ? $data['query_var'] : ''; $hidden = !empty($data['query_var_enabled']) ? '' : ' class="hidden"'; $form['query_var'] = array('#type' => 'checkbox', '#name' => 'ct[query_var_enabled]', '#title' => 'query_var', '#description' => __('False to prevent queries, or string to customize query var. Default will use $taxonomy as query var.', 'wpcf') . '<br />' . __('Default: $taxonomy.', 'wpcf'), '#default_value' => !empty($data['query_var_enabled']), '#after' => '<div id="wpcf-types-form-queryvar-toggle"' . $hidden . '><input type="text" name="ct[query_var]" value="' . $query_var . '" class="wpcf-form-textfield form-textfield textfield" /><div class="description wpcf-form-description wpcf-form-description-checkbox description-checkbox">' . __('Optional', 'wpcf') . '. ' . __('String to customize query var', 'wpcf') . '</div></div>', '#inline' => true); $form['update_count_callback'] = array('#type' => 'textfield', '#name' => 'ct[update_count_callback]', '#title' => 'update_count_callback', 'wpcf', '#description' => __('Function name that will be called to update the count of an associated $object_type, such as post, is updated.', 'wpcf') . '<br />' . __('Default: None.', 'wpcf'), '#value' => !empty($data['update_count_callback']) ? $data['update_count_callback'] : '', '#inline' => true); /** * close */ $form['table-' . __FUNCTION__ . '-close'] = wpcf_admin_metabox_end(); return $form; }
function wpcf_admin_metabox_module_manager($post_type, $type) { $form = array(); /** * open form */ $form['table-mm-open'] = wpcf_admin_metabox_begin(__('Module Manager', 'wpcf'), 'module_manager_post', 'wpcf-types-form-mm-table', false); /** * box content */ ob_start(); switch ($type) { case 'post': wpcf_module_inline_table_post_types(); break; case 'taxonomy': wpcf_module_inline_table_post_taxonomies(); break; default: _e('Wrong type!', 'wpcf'); break; } $markup = ob_get_contents(); ob_end_clean(); $form['table-mm'] = array('#type' => 'markup', '#markup' => $markup); /** * close form */ $form['table-mm-close'] = wpcf_admin_metabox_end(); /** * additional settings */ return $form; }
function wpcf_admin_metabox_custom_fields($ct) { $form = array(); $options = array(); $option_to_key = array(); $fields = wpcf_admin_fields_get_active_fields_by_post_type($ct['slug']); foreach ($fields as $field => $data) { if (isset($data['data']['repetitive']) && $data['data']['repetitive']) { continue; } switch ($data['type']) { case 'embed': case 'checkboxes': case 'audio': case 'file': case 'textarea': case 'video': case 'wysiwyg': continue; default: $option_to_key[$data['meta_key']] = $field; $options[$field] = array('#name' => sprintf('ct[custom_fields][%s]', esc_attr($data['meta_key'])), '#title' => sprintf('%s <small>(%s)</small>', $data['name'], $data['type']), '#value' => 1, '#inline' => true, '#before' => '<li class="menu-item-handle">', '#after' => '</li>', '#default_value' => intval(isset($ct['custom_fields']) && isset($ct['custom_fields'][$data['meta_key']]))); } } /** * get custom fields order */ $options_to_add = array(); if (isset($ct['custom_fields']) && is_array($ct['custom_fields']) && !empty($ct['custom_fields'])) { foreach ($ct['custom_fields'] as $key) { if (isset($option_to_key[$key]) && isset($options[$option_to_key[$key]])) { $options_to_add[$option_to_key[$key]] = $options[$option_to_key[$key]]; unset($options[$option_to_key[$key]]); } } } $options_to_add += $options; $form['table-custom_fields-open'] = wpcf_admin_metabox_begin(__('Custom Fields', 'wpcf'), 'custom_fields', 'wpcf-types-form-visiblity-custom-fields-table', false, true, '_builtin'); $form['table-custom_fields-description'] = array('#type' => 'checkboxes', '#options' => $options_to_add + $options, '#name' => 'wpcf[group][supports]', '#inline' => true, '_builtin' => true); if (empty($options_to_add)) { $form['table-custom_fields-description'] += array('#before' => wpautop(__('There is no custom fields assign to this post type.', 'wpcf')) . '<ul>'); } else { $form['table-custom_fields-description'] += array('#before' => wpautop(__('Check which fields should be shown on custom post list as a column.', 'wpcf')) . '<ul>'); if (count($options_to_add) > 1) { $form['table-custom_fields-description'] += array('#after' => '</ul>' . wpautop(__('Drag and drop ticked custom fields to reorder.', 'wpcf'))); } } $form['table-custom_fields-close'] = wpcf_admin_metabox_end(true, '_builtin'); return $form; }
function wpcf_admin_metabox_custom_fields($ct) { $form = array(); $options = array(); $groups = wpcf_admin_fields_get_groups('wp-types-group', true, true); foreach ($groups as $group) { $post_types = wpcf_admin_get_post_types_by_group($group['id']); if (empty($post_types) || isset($ct['wpcf-post-type']) && in_array($ct['wpcf-post-type'], $post_types)) { if (!empty($group['fields'])) { foreach ($group['fields'] as $field => $data) { if (isset($data['data']['repetitive']) && $data['data']['repetitive']) { continue; } switch ($data['type']) { case 'embed': case 'checkboxes': case 'audio': case 'file': case 'textarea': case 'video': case 'wysiwyg': continue; default: $options[$field] = array('#name' => 'ct[custom_fields][]', '#title' => sprintf('%s <small>(%s)</small>', $data['name'], $data['type']), '#value' => $data['meta_key'], '#inline' => true, '#before' => '<li>', '#after' => '</li>', '#default_value' => intval(isset($ct['custom_fields']) && in_array($data['meta_key'], $ct['custom_fields']))); } } } } } unset($groups); $form['table-custom_fields-open'] = wpcf_admin_metabox_begin(__('Custom Fields', 'wpcf'), 'custom_fields', 'wpcf-types-form-visiblity-custom-fields-table', false); $form['table-custom_fields-description'] = array('#type' => 'checkboxes', '#options' => $options, '#name' => 'wpcf[group][supports]', '#inline' => true, '#before' => wpautop(__('Check which fields should be shown on custom post list as a column.', 'wpcf')) . '<ul>', '#after' => '</ul>'); $form['table-custom_fields-close'] = wpcf_admin_metabox_end(); return $form; }