Changeset 1577511
- Timestamp:
- 01/18/2017 07:19:36 PM (9 years ago)
- Location:
- taxonomy-taxi/trunk
- Files:
-
- 6 edited
-
_plugin.php (modified) (1 diff)
-
lib/Taxonomy_Taxi/Edit.php (modified) (4 diffs)
-
lib/Taxonomy_Taxi/Settings.php (modified) (2 diffs)
-
lib/Taxonomy_Taxi/Settings_Page.php (modified) (1 diff)
-
lib/Taxonomy_Taxi/Sql.php (modified) (3 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
taxonomy-taxi/trunk/_plugin.php
r1564588 r1577511 4 4 * Plugin URI: http://wordpress.org/plugins/taxonomy-taxi/ 5 5 * Description: Show custom taxonomies in /wp-admin/edit.php automatically 6 * Version: .9.9. 56 * Version: .9.9.6 7 7 * Author: postpostmodern, pinecone-dot-website 8 8 * Author URI: http://rack.and.pinecone.website -
taxonomy-taxi/trunk/lib/Taxonomy_Taxi/Edit.php
r1564588 r1577511 45 45 $key = array_search( 'categories', $keys ); 46 46 47 // if that doesnt work put before post comments 48 if( !$key ) 49 $key = array_search( 'comments', $keys ); 50 47 51 // if that doesnt work put before date 48 52 if( !$key ) 49 $key = array_search( 'date', $keys ) ;53 $key = array_search( 'date', $keys ) ? array_search( 'date', $keys ) - 1 : FALSE; 50 54 51 // arbitary placement in table if it cant find date or category55 // arbitary placement in table if it cant find category, comments, or date 52 56 if( !$key ) 53 57 $key = max( 1, count($keys) ); … … 65 69 66 70 $headings = array_merge( $a, $b, $c ); 67 71 68 72 return $headings; 69 73 } … … 158 162 /** 159 163 * 164 * @param string 160 165 * @return array 161 166 */ 162 public static function get_taxonomies(){ 163 return self::$taxonomies; 167 public static function get_taxonomies( $post_type ){ 168 if( !isset(self::$taxonomies[$post_type]) ) 169 self::set_taxonomies( $post_type ); 170 171 return self::$taxonomies[$post_type]; 164 172 } 165 173 … … 168 176 */ 169 177 protected static function set_taxonomies( $post_type ){ 170 self::$taxonomies = get_object_taxonomies( $post_type, 'objects' );178 self::$taxonomies[$post_type] = get_object_taxonomies( $post_type, 'objects' ); 171 179 } 172 180 } -
taxonomy-taxi/trunk/lib/Taxonomy_Taxi/Settings.php
r1564588 r1577511 4 4 5 5 class Settings{ 6 // @todo implement caching6 // save user settings to prevent multiple calls to get_option 7 7 protected static $settings = array(); 8 8 … … 26 26 */ 27 27 public static function get_all_for_post_type( $post_type = '' ){ 28 $taxonomies = get_object_taxonomies( $post_type, 'objects' ); 29 $saved = self::get_saved( $post_type ); 28 if( !isset(self::$settings[$post_type]) ){ 29 $taxonomies = get_object_taxonomies( $post_type, 'objects' ); 30 $saved = self::get_saved( $post_type ); 30 31 31 $checked = array_keys(array_diff_key($taxonomies, array_flip($saved)) );32 $checked = array_keys(array_diff_key($taxonomies, array_flip($saved)) ); 32 33 33 $settings = array(); 34 foreach( $taxonomies as $tax => $props ){ 35 $view_all = array_filter( array( 36 $props->labels->all_items, 37 $props->name 38 ) ); 34 $settings = array(); 35 foreach( $taxonomies as $tax => $props ){ 36 $view_all = array_filter( array( 37 $props->labels->all_items, 38 $props->name 39 ) ); 40 41 $settings[$tax] = (object) array( 42 'checked' => in_array( $tax, $checked ), 43 'label' => $props->label, 44 'query_var' => $props->query_var, 45 'name' => $tax, 46 'view_all' => reset( $view_all ) 47 ); 48 } 49 50 self::$settings[$post_type] = $settings; 51 } 39 52 40 $settings[$tax] = (object) array( 41 'checked' => in_array( $tax, $checked ), 42 'label' => $props->label, 43 'query_var' => $props->query_var, 44 'name' => $tax, 45 'view_all' => reset( $view_all ) 46 ); 47 } 48 49 return $settings; 53 return self::$settings[$post_type]; 50 54 } 51 55 -
taxonomy-taxi/trunk/lib/Taxonomy_Taxi/Settings_Page.php
r1564588 r1577511 103 103 */ 104 104 public static function save( $form_data ){ 105 foreach( $form_data as $post_type => &$options ){ 105 $post_types = get_post_types( array( 106 'show_ui' => TRUE 107 ), 'objects' ); 108 109 $saved = array(); 110 111 foreach( $post_types as $post_type => $object ){ 106 112 $all = get_object_taxonomies( $post_type, 'names' ); 113 $user_input = isset($form_data[$post_type]) ? $form_data[$post_type] : array(); 107 114 108 $ options = array_diff( $all, $options);115 $saved[$post_type] = array_diff( $all, $user_input ); 109 116 } 110 117 111 return $ form_data;118 return $saved; 112 119 } 113 120 } -
taxonomy-taxi/trunk/lib/Taxonomy_Taxi/Sql.php
r1564588 r1577511 22 22 */ 23 23 public static function posts_fields( $sql, &$wp_query ){ 24 foreach( Edit::get_taxonomies( ) as $tax ){24 foreach( Edit::get_taxonomies($wp_query->query_vars['post_type']) as $tax ){ 25 25 $tax = esc_sql( $tax->name ); 26 26 … … 83 83 public static function posts_orderby( $sql, &$wp_query ){ 84 84 global $wpdb; 85 86 if( isset($wp_query->query_vars['orderby']) && array_key_exists($wp_query->query_vars['orderby'], Edit::get_taxonomies( )) )85 86 if( isset($wp_query->query_vars['orderby']) && array_key_exists($wp_query->query_vars['orderby'], Edit::get_taxonomies($wp_query->query_vars['post_type'])) ) 87 87 $sql = $wp_query->query_vars['orderby']."_slugs ".$wp_query->query_vars['order']." /* Taxonomy_Taxi posts_orderby */"; 88 88 … … 100 100 $taxonomies = array(); 101 101 102 foreach( Edit::get_taxonomies( ) as $tax ){102 foreach( Edit::get_taxonomies($post->post_type) as $tax ){ 103 103 $tax_name = esc_sql( $tax->name ); 104 104 -
taxonomy-taxi/trunk/readme.txt
r1564588 r1577511 2 2 Contributors: postpostmodern, pinecone-dot-io 3 3 Donate link: https://cash.me/$EricEaglstun 4 Tags: custom taxonomies, taxonomy 4 Tags: custom taxonomies, taxonomy, term 5 5 Requires at least: 3.9 6 6 Tested up to: 4.7 … … 9 9 == Description == 10 10 Automatically display custom taxonomy information in wp-admin/edit.php 11 Not tested with versions pre- 3.2- requires PHP 5.311 - requires PHP 5.3 12 12 13 13 == Installation == … … 17 17 18 18 == Changelog == 19 = .9.9.6 = 20 * Fix saving options with all taxonomies deselected 21 19 22 = .9.9.2 = 20 23 * Support media library list
Note: See TracChangeset
for help on using the changeset viewer.