function admin_page_contents() { if (!suwp::permalink_mode()) { $this->print_message('warning', __('To use the Permalinks Tweaker, you must disable default (query-string) permalinks in your <a href="options-permalink.php">Permalink Settings</a>.', 'seo-ultimate')); return; } $this->child_admin_form_start(); $nobase_checkboxes = array(); $taxonomies = suwp::get_taxonomies(); foreach ($taxonomies as $taxonomy) { global $wp_rewrite; $before_url = $wp_rewrite->get_extra_permastruct($taxonomy->name); $before_url = str_replace("%{$taxonomy->name}%", 'example', $before_url); $before_url = home_url(user_trailingslashit($before_url, 'category')); $after_url = home_url(user_trailingslashit('/example', 'category')); $nobase_checkboxes[] = array('setting_id' => 'nobase_' . $taxonomy->name, 'taxonomy_label' => $taxonomy->labels->name, 'example_before' => $before_url, 'example_after' => $after_url); } $this->admin_form_group_start(__('Remove the URL bases of...', 'seo-ultimate')); echo "<tr><td>\n"; $this->admin_wftable_start(array('taxonomy' => ' ', 'before' => __('Before', 'seo-ultimate'), 'arrow' => ' ', 'after' => __('After', 'seo-ultimate'))); foreach ($nobase_checkboxes as $nobase_checkbox) { echo "<tr>\n"; echo "<td class='su-permalinks-taxonomy'>"; $this->checkbox($nobase_checkbox['setting_id'], $nobase_checkbox['taxonomy_label'], false, array('output_tr' => false)); echo "</td>\n"; echo "<td class='su-permalinks-before'>" . esc_html($nobase_checkbox['example_before']) . "</td>\n"; echo "<td class='su-permalinks-arrow'>⇒</td>\n"; echo "<td class='su-permalinks-after'>" . esc_html($nobase_checkbox['example_after']) . "</td>\n"; echo "</tr>\n"; } $this->admin_wftable_end(); echo "</td></tr>\n"; $this->admin_form_group_end(); $this->dropdown('add_rule_if_conflict', array('1' => __('term archive', 'seo-ultimate'), '0' => __('page', 'seo-ultimate')), __('URL Conflict Resolution', 'seo-ultimate'), __('If a term archive and a Page with the same slug end up having the same URL because of the term’s base being removed, the URL should be given to the %s.', 'seo-ultimate')); $this->child_admin_form_end(); $this->update_rewrite_filters(); $this->flush_rewrite_rules(); }
/** * Outputs a JSON-encoded list of posts and terms on the blog. * * @since 6.0 */ function jlsuggest_autocomplete() { if (!function_exists('json_encode')) { die; } if (!current_user_can('manage_options')) { die; } $items = array(); $include = empty($_GET['types']) ? array() : explode(',', $_GET['types']); if ((!$include || in_array('home', $include)) && sustr::ihas($_GET['q'], 'home')) { $items[] = array('text' => __('Home', 'seo-ultimate'), 'isheader' => true); $items[] = array('text' => __('Blog Homepage', 'seo-ultimate'), 'value' => 'obj_home', 'selectedtext' => __('Blog Homepage', 'seo-ultimate')); } $posttypeobjs = get_post_types(array('public' => true), 'objects'); foreach ($posttypeobjs as $posttypeobj) { if ($include && !in_array('posttype', $include) && !in_array('posttype_' . $posttypeobj->name, $include)) { continue; } $stati = get_available_post_statuses($posttypeobj->name); suarr::remove_value($stati, 'auto-draft'); $stati = implode(',', $stati); $posts = get_posts(array('orderby' => 'title', 'order' => 'ASC', 'post_status' => $stati, 'numberposts' => -1, 'post_type' => $posttypeobj->name, 'post_mime_type' => isset($_GET['post_mime_type']) ? $_GET['post_mime_type'] : '', 'sentence' => 1, 's' => $_GET['q'])); if (count($posts)) { $items[] = array('text' => $posttypeobj->labels->name, 'isheader' => true); foreach ($posts as $post) { $items[] = array('text' => $post->post_title, 'value' => 'obj_posttype_' . $posttypeobj->name . '/' . $post->ID, 'selectedtext' => $post->post_title . '<span class="type"> — ' . $posttypeobj->labels->singular_name . '</span>'); } } } $taxonomyobjs = suwp::get_taxonomies(); foreach ($taxonomyobjs as $taxonomyobj) { if ($include && !in_array('taxonomy', $include) && !in_array('taxonomy_' . $posttypeobj->name, $include)) { continue; } $terms = get_terms($taxonomyobj->name, array('search' => $_GET['q'])); if (count($terms)) { $items[] = array('text' => $taxonomyobj->labels->name, 'isheader' => true); foreach ($terms as $term) { $items[] = array('text' => $term->name, 'value' => 'obj_taxonomy_' . $taxonomyobj->name . '/' . $term->term_id, 'selectedtext' => $term->name . '<span class="type"> — ' . $taxonomyobj->labels->singular_name . '</span>'); } } } if (!$include || in_array('author', $include)) { $authors = get_users(array('search' => $_GET['q'], 'fields' => array('ID', 'user_login'))); if (count($authors)) { $items[] = array('text' => __('Author Archives', 'seo-ultimate'), 'isheader' => true); foreach ($authors as $author) { $items[] = array('text' => $author->user_login, 'value' => 'obj_author/' . $author->ID, 'selectedtext' => $author->user_login . '<span class="type"> — ' . __('Author', 'seo-ultimate') . '</span>'); } } } if ($this->module_exists('internal-link-aliases') && (!$include || in_array('internal-link-alias', $include))) { $aliases = $this->get_setting('aliases', array(), 'internal-link-aliases'); $alias_dir = $this->get_setting('alias_dir', 'go', 'internal-link-aliases'); if (is_array($aliases) && count($aliases)) { $header_outputted = false; foreach ($aliases as $alias_id => $alias) { if ($alias['to']) { $h_alias_to = su_esc_html($alias['to']); $to_rel_url = "/{$alias_dir}/{$h_alias_to}/"; if (strpos($alias['from'], $_GET['q']) !== false || strpos($to_rel_url, $_GET['q']) !== false) { if (!$header_outputted) { $items[] = array('text' => __('Link Masks', 'seo-ultimate'), 'isheader' => true); $header_outputted = true; } $items[] = array('text' => $to_rel_url, 'value' => 'obj_internal-link-alias/' . $alias_id, 'selectedtext' => $to_rel_url . '<span class="type"> — ' . __('Link Mask', 'seo-ultimate') . '</span>'); } } } } } echo json_encode($items); die; }
/** * Returns tabs for taxonomy meta editing tables. * * @since 2.9 * * @param array $fields The array of meta fields that the user can edit with the tables. */ function get_taxmeta_edit_tabs($fields) { $types = suwp::get_taxonomies(); //Turn the types array into a tabs array $tabs = array(); foreach ($types as $name => $type) { if ($type->labels->name) { $tabs[] = array('title' => $type->labels->name, 'id' => 'su-' . $name, 'callback' => array('meta_edit_tab', 'term', 'su-' . $name, $name, $type->labels->singular_name, $fields)); } } return $tabs; }