/** * Field Template Assignment Tab Single. * * @since 1.0.0 * @access public * @param string $field_name Field name. * @param array $selected Selected value. * @return string */ private static function print_single_tabs($field_name, $selected = array()) { $output = '<div id="visibility-tabs-single" class="visibility-tabs ui-tabs visibility-tabs-' . $field_name . ' visibility-tabs-' . $field_name . '-single"><ul class="clearfix">'; /* build the tab links */ $output .= '<li><a href="#visibility-tab-single-category">' . __('Categories', 'themify-flow') . '</a></li>'; $output .= '<li><a href="#visibility-tab-single-post-types">' . __('Post Types', 'themify-flow') . '</a></li>'; $output .= '<li><a href="#visibility-tab-single-singles">' . __('Posts', 'themify-flow') . '</a></li>'; $output .= '</ul>'; // Categories Tab $output .= '<div id="visibility-tab-single-category" class="themify-visibility-options clearfix">'; $categories = get_terms('category', array('hide_empty' => true)); $output .= wp_kses_post(__('<p><small>Check which categories to apply this template to the single view of each entry filed under the category.</small></p>', 'themify-flow')); $checked = isset($selected['single']['category']['all']) ? checked($selected['single']['category']['all'], 'on', false) : ''; $output .= '<label class="label-full"><input class="tf_toggle_prop" type="checkbox" name="' . $field_name . '[single][category][all]" ' . $checked . ' />' . __('Apply to all', 'themify-flow') . '</label>'; if (count($categories) > 0) { foreach ($categories as $term) { $checked = isset($selected['single']['category'][$term->slug]) ? checked($selected['single']['category'][$term->slug], 'on', false) : ''; $output .= '<label><input type="checkbox" name="' . $field_name . '[single][category][' . $term->slug . ']" ' . $checked . ' />' . $term->name . '</label>'; } } $output .= '</div>'; // tab-single-category // Post Types tab $output .= '<div id="visibility-tab-single-post-types" class="themify-visibility-options clearfix">'; $post_types = TF_Model::get_post_types(array(), array('tf_template', 'tf_template_part')); $output .= wp_kses_post(__('<p><small>Check which post types to apply this template to the single view of each entry of their type. Note: if "Apply to all" is checked, it will apply to all single views of all other custom post types as well.</small></p>', 'themify-flow')); $checked = isset($selected['single']['post_type']['all']) ? checked($selected['single']['post_type']['all'], 'on', false) : ''; $output .= '<label class="label-full"><input class="tf_toggle_prop" type="checkbox" name="' . $field_name . '[single][post_type][all]" ' . $checked . ' />' . __('Apply to all', 'themify-flow') . '</label>'; if (count($post_types) > 0) { foreach ($post_types as $key => $type) { $checked = isset($selected['single']['post_type'][$key]) ? checked($selected['single']['post_type'][$key], 'on', false) : ''; $output .= '<label><input type="checkbox" name="' . $field_name . '[single][post_type][' . $key . ']" ' . $checked . ' />' . $type->label . '</label>'; } } $output .= '</div>'; // tab-single-post-types // Posts tab $output .= '<div id="visibility-tab-single-singles" class="themify-visibility-options clearfix">'; $query_posts = get_posts(array('post_type' => array_keys(TF_Model::get_post_types(array(), array('page', 'tf_template', 'tf_template_part'))), 'posts_per_page' => -1)); $output .= wp_kses_post(__('<p><small>Check which posts to apply this template to its single view.</small></p>', 'themify-flow')); $checked = isset($selected['single']['singular']['all']) ? checked($selected['single']['singular']['all'], 'on', false) : ''; $output .= '<label class="label-full"><input class="tf_toggle_prop" type="checkbox" name="' . $field_name . '[single][singular][all]" ' . $checked . ' />' . __('Apply to all', 'themify-flow') . '</label>'; if (count($query_posts) > 0) { foreach ($query_posts as $post_data) { $checked = isset($selected['single']['singular'][$post_data->post_type][$post_data->post_name]) ? checked($selected['single']['singular'][$post_data->post_type][$post_data->post_name], 'on', false) : ''; $output .= '<label><input type="checkbox" name="' . $field_name . '[single][singular][' . $post_data->post_type . '][' . $post_data->post_name . ']" ' . $checked . ' />' . $post_data->post_title . '</label>'; } } $output .= '</div>'; // tab-archive-taxonomies $output .= '</div>'; return $output; }