__('Permastructures', 'permalink-manager'), 'function' => array('class' => 'Permalink_Manager_Permastructs', 'method' => 'output') ); return $admin_sections; } public function get_fields() { global $permalink_manager_permastructs; $all_post_types = Permalink_Manager_Helper_Functions::get_post_types_array('full'); $woocommerce_icon = ""; // 1. Get fields $fields = array( 'post_types' => array( 'section_name' => __('Post types', 'permalink-manager'), 'container' => 'row', 'fields' => array() ), 'taxonomies' => array( 'section_name' => __('Taxonomies', 'permalink-manager'), 'container' => 'row', 'append_content' => Permalink_Manager_Admin_Functions::pro_text(), 'fields' => array() ) ); // 2. Woocommerce support if(class_exists('WooCommerce')) { $fields['woocommerce'] = array( 'section_name' => "{$woocommerce_icon} " . __('WooCommerce', 'permalink-manager'), 'container' => 'row', 'append_content' => Permalink_Manager_Admin_Functions::pro_text(), 'fields' => array() ); } // 3. Append fields for all post types foreach($all_post_types as $post_type) { if($post_type['name'] == 'shop_coupon') { continue; } $fields["post_types"]["fields"][$post_type['name']] = array( 'label' => $post_type['label'], 'container' => 'row', 'input_class' => 'permastruct-field', 'post_type' => $post_type, 'type' => 'permastruct' ); } return apply_filters('permalink_manager_permastructs_fields', $fields); } /** * Get the array with settings and render the HTML output */ public function output() { global $permalink_manager_permastructs; $sidebar = sprintf('

%s

', __('Instructions', 'permalink-manager')); $sidebar .= "

"; $sidebar .= __('The current permastructures settings will be automatically applied only to the new posts & terms.'); $sidebar .= '
'; $sidebar .= sprintf(__('To apply the new format to existing posts and terms, please use "Regenerate/reset" tool after you update the permastructure settings below.', 'permalink-manager'), admin_url('tools.php?page=permalink-manager§ion=tools&subsection=regenerate_slugs')); $sidebar .= "

"; $sidebar .= sprintf('

%s

', __('Permastructure tags', 'permalink-manager')); $sidebar .= wpautop(sprintf(__('All allowed permastructure tags are listed below. Please note that some of them can be used only for particular post types or taxonomies.', 'permalink-manager'), "https://codex.wordpress.org/Using_Permalinks#Structure_Tags")); $sidebar .= Permalink_Manager_Helper_Functions::get_all_structure_tags(); return Permalink_Manager_Admin_Functions::get_the_form(self::get_fields(), '', array('text' => __( 'Save permastructures', 'permalink-manager' ), 'class' => 'primary margin-top'), $sidebar, array('action' => 'permalink-manager', 'name' => 'permalink_manager_permastructs')); } }