cat = strtoupper(trim($snapqueryarray['cat'])); } else { if (is_category()) { $nav->cat = get_query_var('cat'); } elseif (is_tag()) { $nav->tag = get_query_var('tag_id'); } } if (isset($snapqueryarray['child'])) { $nav->ifchildren = true; } else { $nav->ifchildren = false; } if (isset($snapqueryarray['menu'])) { $nav->menustyle = $snapqueryarray['menu']; } if (isset($snapqueryarray['firstload'])) { $nav->firstload = strtoupper(trim($snapqueryarray['firstload'])); } if (isset($_GET['cp'])) { $nav->first_letters = $_GET['cp']; } elseif (isset($_GET['snap'])) { if ($_GET['snap'] == 'misc') { $nav->first_letters = '#'; } else { $nav->first_letters = urldecode($_GET['snap']); } } $results = $nav->navigation(); return $results; } class wp_snap_core { var $cat; var $tag; var $ifchildren; var $first_letters; var $menustyle; var $firstload; function current_url($fancyurl, $fancyurlname = '') { $url = "http://" . $_SERVER['HTTP_HOST']; if ($fancyurl == 1 && get_option('permalink_structure') !== '') { $url .= preg_replace('@' . $fancyurlname . '.*@', '', $_SERVER['REQUEST_URI']); } else { $url .= preg_replace('@[\?\&]snap.*@', '', $_SERVER['REQUEST_URI']); } return $url; } function accents($str) { $str = htmlentities($str); $str = preg_replace('/&([a-zA-Z])(uml|acute|grave|circ|tilde);/','$1',$str); return html_entity_decode($str); } function navigation() { global $wpdb, $wp_query, $user_ID, $gengo, $wp_version; // Define variables $wp_snap_options = array( 'menu' => get_option('key_snap_menu'), 'menumisc' => get_option('key_snap_menumisc'), 'recent' => get_option('key_snap_recent'), 'csscls1' => get_option('key_snap_csscls1'), 'csscls2' => get_option('key_snap_csscls2'), 'tab1' => get_option('key_snap_tab1'), 'fancyurl' => get_option('key_snap_fancyurl'), 'fancyurlname' => get_option('key_snap_fancyurlname')); $ver = (float)$wp_version; $url = wp_snap_core::current_url($wp_snap_options['fancyurl'],$wp_snap_options['fancyurlname']); $date = gmdate('Y-m-d H:i:59'); $sch = array('"e;', '&apost;', ' '); $rst = array('"', '\'', ''); // '" $exclude[0] = str_replace($sch, $rst, get_option('key_snap_exclude')); $excsch = array('/[\|]+[0-9A-Z]+[\|]*|[\|]*[0-9A-Z]+[\|]+/i', '/^[0-9A-Z]+$/i'); $excrst = array('|', ''); $exclude[1] = preg_replace($excsch, $excrst, $exclude[0]); $excsch = array('/[\|]+[^0-9A-Z]+[\|]*|[\|]*[^0-9A-Z]+[\|]+/i', '/^[^0-9A-Z]+$/i'); $excrst = array('|', ''); $exclude[2] = preg_replace($excsch, $excrst, $exclude[0]); $tempstr['1']['0'] = '#' . __('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'wp-snap'); $tempstr['1']['1'] = '#' . __('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'wp-snap'); $tempstr['2']['0'] = '#' . __('A-DE-HI-LM-PQ-TU-Z', 'wp-snap'); $tempstr['2']['1'] = '#' . __('0-9A-DE-HI-LM-PQ-TU-Z', 'wp-snap'); $tempstr['2']['2'] = '#'; $tempstr['2']['3'] = __('0123456789', 'wp-snap'); $tempstr['2']['4'] = __('ABCD', 'wp-snap'); $tempstr['2']['5'] = __('EFGH', 'wp-snap'); $tempstr['2']['6'] = __('IJKL', 'wp-snap'); $tempstr['2']['7'] = __('MNOP', 'wp-snap'); $tempstr['2']['8'] = __('QRST', 'wp-snap'); $tempstr['2']['9'] = __('UVWXYZ', 'wp-snap'); $tempstr['3']['0'] = '#' . __('A-MN-Z', 'wp-snap'); $tempstr['3']['1'] = '#' . __('0-9A-MN-Z', 'wp-snap'); $tempstr['3']['2'] = '#'; $tempstr['3']['3'] = __('0123456789', 'wp-snap'); $tempstr['3']['4'] = __('ABCDEFGHIJKLM', 'wp-snap'); $tempstr['3']['5'] = __('NOPQRSTUVWXYZ', 'wp-snap'); if (empty($this->menustyle)) { $this->menustyle = $wp_snap_options['menu']; } // Database query if ($ver < 2.3) { if (!empty($this->cat)) { $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id)"; if (get_query_var('cat') == NULL) { $join .= " LEFT JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID)"; } if ($this->cat !== 'ALL') { $where = " AND $wpdb->post2cat.category_id IN (" . $this->cat . ", "; if ($this->ifchildren == TRUE) { $where .= get_category_children($this->cat, '', ', '); } $where = substr($where, 0, -2); $where .= ")"; } } $where .= " AND (post_type = 'post' AND (post_status = 'publish'"; if (is_admin()) { $where .= " OR post_status = 'future' OR post_status = 'draft'"; } if ( is_user_logged_in() ) { if (current_user_can('read_private_posts')) { $where .= " OR post_status = 'private'"; } else { $where .= " OR post_author = $user_ID AND post_status = 'private'"; } } // Gengo support (hopefully) if (isset($gengo)) { $where .= " AND $wpdb->posts.ID = $wpdb->post2lang.post_ID AND $wpdb->post2lang.language_id = $gengo->language_preference_id AND $wpdb->post2lang.language_id = $wpdb->languages.language_id"; $from = ", $wpdb->post2lang, $wpdb->languages"; } } else { if (!empty($this->cat)) { $join = " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)"; if ($this->cat !== 'ALL') { $where = " AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->term_taxonomy.term_id IN ('" . $this->cat . "', "; if ($this->ifchildren == TRUE) { $where .= "'" . implode("', '", get_term_children($this->cat, 'category')) . "'"; } else { $where = substr($where, 0, -2); } $where .= ")"; } } elseif (!empty($this->tag)) { $join = " INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)"; $where = " AND $wpdb->term_taxonomy.taxonomy = 'post_tag' AND $wpdb->term_taxonomy.term_id IN ('" . $this->tag . "')"; } $where .= " AND (post_type = 'post' AND (post_status = 'publish'"; if (is_admin()) { $where .= " OR post_status = 'future' OR post_status = 'draft' OR post_status = 'pending'"; } if (is_user_logged_in()) { $where .= current_user_can("read_private_" . get_query_var('post_type') . "s") ? " OR post_status = 'private'" : " OR post_author = $user_ID AND post_status = 'private'"; } } $where .= '))'; $groupby = " GROUP BY $wpdb->posts.ID"; $request = "SELECT SQL_CALC_FOUND_ROWS $wpdb->posts.* FROM $wpdb->posts" . $from . $join . " WHERE 1=1" . $where . $groupby . " ORDER BY post_date DESC"; $request = apply_filters('posts_request', $request); $all_posts = $wpdb->get_results($request); // Create a string containing the first letters of the post titles retrieved above for ($i=0; $i < count($all_posts); $i++) { $word_results[$i] = preg_replace('/^(' . $exclude[1] . ')+((' . $exclude[2] . ')[\s]+)*|^(' . $exclude[2] . ')[\s]+/i', '', wp_snap_core::accents($all_posts[$i]->post_title)); } // Performs a "natural sort" then re-orders the array's key values to match the new order natcasesort($word_results); $word_results = array_values($word_results); foreach ($word_results as $word_result) { $first_letter_all_posts .= strtoupper(substr($word_result, 0, 1)); } // If no query is found in the url, select first post title letter if ($this->first_letters == NULL && $this->firstload !== 'RECENT') { if ($this->firstload == 'NONE') { $this->first_letters = ' '; } elseif ($this->firstload == 'ALL') { $this->first_letters = '#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; } elseif ((preg_match('/[^0-9A-Z]+/i', substr($first_letter_all_posts, 0, 1))) || (($wp_snap_options['menumisc'] == '1') && (preg_match('/[^A-Z]+/i', substr($first_letter_all_posts, 0, 1))))) { $this->first_letters = '#'; } elseif ($this->menustyle == '1') { for ($i=0; $i < strlen($first_letter_all_posts); $i++) $temp_letter[$i] = substr($first_letter_all_posts, $i, 1); natsort($temp_letter); $temp_letter = array_values($temp_letter); $this->first_letters = $temp_letter['0']; } else { for ($i=3; $i < count($tempstr[$this->menustyle]); $i++) if (strstr($tempstr[$this->menustyle][$i], substr($first_letter_all_posts, 0, 1))) $this->first_letters = $tempstr[$this->menustyle][$i]; } } if ($this->firstload == 'RECENT' && $this->first_letters == NULL) { for ($i=0; $i < count($all_posts); $i++) { if ($wp_snap_options['recent'] <= $i) { $all_posts[$i] = NULL; } } } else { // Resorts $wp_snap_posttitles, taking excluded words into account for ($i=0; $i < count($all_posts); $i++) { if (preg_replace('/^(' . $exclude[1] . ')+((' . $exclude[2] . ')[\s]+)*|^(' . $exclude[2] . ')[\s]+/i', '', wp_snap_core::accents($all_posts[$i]->post_title)) !== $word_results[$i]) { $wp_snap_holdtitle = $all_posts[$i]; for ($j=$i+1; $j < count($all_posts); $j++) { if (preg_replace('/^(' . $exclude[1] . ')+((' . $exclude[2] . ')[\s]+)*|^(' . $exclude[2] . ')[\s]+/i', '', wp_snap_core::accents($all_posts[$j]->post_title)) == $word_results[$i]) { $all_posts[$i] = $all_posts[$j]; $all_posts[$j] = $wp_snap_holdtitle; break; } } } if (($wp_snap_options['menumisc'] == '2' && $this->first_letters == '#' && preg_match('/^[0-9A-Z]+/i', substr($word_results[$i], 0, 1))) || ($wp_snap_options['menumisc'] == '1' && $this->first_letters == '#' && preg_match('/^[A-Z]+/i', substr($word_results[$i], 0, 1))) || ($this->first_letters !== '#' && preg_match('/^[^' . $this->first_letters . ']+/i', substr($word_results[$i], 0, 1)))) { $all_posts[$i] = NULL; } } } foreach ($all_posts as $key => $value) { if ($value == NULL) { unset($all_posts[$key]); } } $all_posts = array_values($all_posts); // Creates where statement needed to modify the wordpress loop $wp_query->post_count = count($all_posts); $wp_query->posts = $all_posts; // Test for post titles beginning with numbers $numlogic = '0'; $numtest = '0'; for ($i = 0; $i < strlen($first_letter_all_posts); $i++) { if (is_numeric(substr($first_letter_all_posts, $i, 1))) { $numlogic = '1'; $numtest = '1'; } } if ($wp_snap_options['menumisc'] == '1') { $numtest = '0'; } // Create tabs based on number input in admin menu $num_tabs = ''; for ($y = 0; $y < $wp_snap_options['tab1']; $y++) { $num_tabs .= "\t"; } // Insert ordered list tag for navigational menu, include class information $results = $num_tabs . '' . "\n"; } else { $results .= ">\n"; } // Check if ALL posts are to be displayed on first load if ($this->firstload == 'ALL') { $results .= $num_tabs . "\tfirst_letters == '#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') { $results .= ' class="' . $wp_snap_options['csscls2'] . '"'; } else { $results .= '>first_letters !== '#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') { $results .= ''; } $results .= "\n"; } // Test to see if non-alphanumeric characters were used in titles if (($numlogic == '0' || $wp_snap_options['menumisc'] == '2') && (preg_match('/[0-9A-Z]+/i', substr($first_letter_all_posts, 0, 1)))) { $tempstr[$this->menustyle][$numtest] = str_replace('#', '', $tempstr[$this->menustyle][$numtest]); } else { $wp_snap_misc = TRUE; } // Create navigational menu list items switch ($this->menustyle) { case 1: for ($i = 0; $i < strlen($tempstr[$this->menustyle][$numtest]); $i++) { $l = substr($tempstr[$this->menustyle][$numtest], $i, 1); $nav_entry_test = FALSE; $results .= $num_tabs . "\tfirst_letters) $results .= ' class="' . $wp_snap_options['csscls2'] . '"'; $nav_entry = '>' . $l . "\n"; for ($y = 0; $y < strlen($first_letter_all_posts); $y++) { if ($nav_entry_test !== TRUE && ($l == substr($first_letter_all_posts, $y, 1) || ($l == '#' && preg_match('/[^0-9A-Z]+/i', substr($first_letter_all_posts, 0, 1))) || ($l == '#' && $wp_snap_options['menumisc'] == '1' && preg_match('/[^A-Z]+/i', substr($first_letter_all_posts, 0, 1))))) { $nav_entry = '>' . $l . "\n"; } else { if (strstr($url, '?')) { $nav_entry .= '&'; } else { $nav_entry .= '?'; } $nav_entry .= 'snap='; if ($l == '#') { $nav_entry .= 'misc'; } else { $nav_entry .= $l; } $nav_entry .= '">' . $l . "\n"; } $nav_entry_test = TRUE; } } $results .= $nav_entry;; } break; case 2: case 3: // Create a count that will allow $tempstr to be used in creating the URL query if (substr($tempstr[$this->menustyle][$numtest], 0, 1) == '#') { $wp_snap_count = 2; } else { $wp_snap_count = 4 - $numtest; } for ($i = 0; $i < strlen($tempstr[$this->menustyle][$numtest]); $i = $i + $wp_snap_adv) { if ($tempstr[$this->menustyle][$wp_snap_count] == '#') { $l = '#'; $wp_snap_adv = 1; } else { $l = substr($tempstr[$this->menustyle][$numtest], $i, 3); $wp_snap_adv = 3; } $results .= $num_tabs . "\tfirst_letters, substr($l, 0, 1))) { $results .= ' class="' . $wp_snap_options['csscls2'] . '"'; } $nav_entry = '>' . $l . "\n"; if (preg_match('/[' . $first_letter_all_posts . ']+/i', $tempstr[$this->menustyle][$wp_snap_count]) || ($l == '#' && preg_match('/[^0-9A-Z]+/i', $first_letter_all_posts)) || ($l == '#' && $wp_snap_options['menumisc'] == '1' && preg_match('/[^A-Z]+/i', $first_letter_all_posts))) { $nav_entry = '>' . $l . "\n"; } else { if (strstr($url, '?')) { $nav_entry .= '&'; } else { $nav_entry .= '?'; } $nav_entry .= 'snap='; if ($l == '#') { $nav_entry .= 'misc'; } else { $nav_entry .= $tempstr[$this->menustyle][$wp_snap_count]; } $nav_entry .= '">' . $l . "\n"; } } $results .= $nav_entry; if ($wp_snap_count == 2) { $wp_snap_count = 4 - $numtest; } else { ++$wp_snap_count; } } break; } $results .= $num_tabs . "\n"; return $results; } } function wp_snap_load_language() { load_plugin_textdomain('wp-snap','/wp-content/plugins/wp-snap/languages/'); } function wp_snap_fancy_url($var = 'REQUEST_URI') { $req = $_SERVER[$var]; $fancyurlname = get_option('key_snap_fancyurlname'); if (preg_match('!^(.*/)' . $fancyurlname . '-([A-Za-z0-9]*)/?(.*)?$!', $req, $match)) { if ($match[2] == '') { $_GET['cp'] = '#'; } else { $_GET['cp'] = $match[2]; } $req = $match[1] . $match[3]; $_SERVER[$var] = $req; } if (($var !== 'PATH_INFO') && isset($_SERVER['PATH_INFO'])) { wp_snap_fancy_url('PATH_INFO'); } } function wp_snap_add_option_page() { if (function_exists('add_options_page')) add_submenu_page('plugins.php', 'WP-SNAP!', 'WP-SNAP!', 8, basename(__FILE__), 'wp_snap_options_subpanel'); } function wp_snap_options_subpanel() { if (isset($_POST['info_update'])) { $whitespace = array(" ", "\t", "\n", "\r", "\0", "\x0B"); $snap_fancyurl = strip_tags(str_replace($whitespace, '', $_POST['key_snap_fancyurlname'])); check_admin_referer('wp_snap_update_options'); update_option('key_snap_menu', (int) $_POST['key_snap_menu']); update_option('key_snap_menumisc', (int) $_POST['key_snap_menumisc']); update_option('key_snap_recent', (int) $_POST['key_snap_recent']); update_option('key_snap_csscls1', (string) $_POST['key_snap_csscls1']); update_option('key_snap_csscls2', (string) $_POST['key_snap_csscls2']); update_option('key_snap_exclude', $_POST['key_snap_exclude']); update_option('key_snap_fancyurl', (int) $_POST['key_snap_fancyurl']); if (!empty($snap_fancyurl)) { update_option('key_snap_fancyurlname', (string) $snap_fancyurl); } update_option('key_snap_tab1', (int) $_POST['key_snap_tab1']); echo '

Options successfully updated.

'; } ?>

WP-SNAP! v0.8.6

this plugin\'s page.', 'wp-snap'); ?>

Menu Style controls how the user will navigate post titles. Three styles are provided to choose from. Numbers will only appear in the menu if post titles beginning with numbers exist and Group Posts is turned off. Recent Posts controls how many recent posts will be displayed when the plugin is first called (if the recent posts feature is called).', 'wp-snap'); ?>

CSS Class Name fields add a class attribute to <ol> and/or <li> HTML tags.', 'wp-snap'); ?>

Ignore During Alphabetizing allows the user to filter out words, letters and characters such as the, a, or quotation marks from the alphabetization process. This function is not case sensitive. For instance, if "the" is added to the ignore list, the post title "The Last Samurai" would be found under L instead of T. Multiple items can be filtered, but must contain no literal spaces between entries and be seperated with a pipe. To ignore a quotation mark or apostrophe, you must use the following: "e; or &apost;. For example: the|a|an|"e;|&apost;', 'wp-snap'); ?>





Display
<ol>
<li>
()

Fancy URLs should be activated if the Wordpress installation is using a custom URI permalink structure. The Fancy URL Name used in the URI may also be customized.', 'wp-snap'); ?>

Tabs option is purely for aesthetic purposes — it allows you to specify how far to indent the ordered list generated by WP-SNAP! so that it matches up with the rest of your HTML code.', 'wp-snap'); ?>