WordPress.org

Forums

Radio Taxonomy
you cannot compare a boolian with a string in get_taxonomies, causing probl (3 posts)

  1. davidchoy
    Member
    Posted 3 years ago #

    In function set_taxonomies of radio-taxonomy, in the version of wordpress I'm using, you cannot compare the default boolian, "show_ui" with the string "radio" in get_taxonomies.

    I have a quick and (dirty?) fix:

    //OLD:
    //$this->taxonomies = get_taxonomies(array('show_ui' => 'radio'), 'objects');

    //NEW:
    //updated becuase $temp_tax->show_ui == 'radio' evaluates to true even if show_ui == 1, becuase show_ui is a bool!!!!
    $this->taxonomies = array();
    $temp_taxonomies = get_taxonomies(array('show_ui' => 'radio'), 'objects');
    foreach ($temp_taxonomies as $temp_tax) {
    if ( $temp_tax->show_ui.'' == 'radio') { //covert show_ui to string! it is a bool!
    $this->taxonomies[] = $temp_tax;
    }
    }

    Let me know if you use this or have other ideas.

    http://wordpress.org/extend/plugins/radio-taxonomy/

  2. Mitchell Bundy
    Member
    Plugin Author

    Posted 3 years ago #

    Thanks a lot! I'll have a look at it sometime this tonight and make an update sometime this week.

  3. Travis Smith
    Member
    Posted 2 years ago #

    There is an easier solution (IMHO). Just create a new argument ('type') when registering the taxonomy:

    function set_taxonomies() {
    	global $wp_taxonomies;
    	$this->taxonomies = get_taxonomies(array( 'type' => 'radio' ), 'objects');
    	print_r($this->taxonomies);
    	// Now that we know which taxonomies we're dealing with, let's set show_ui to true and remove the meta box.
    	foreach ($this->taxonomies as $tax) {
    		//$wp_taxonomies[$tax->name]->show_ui = true; // No longer needed
    		// Default show_none to false
    		if (!isset($wp_taxonomies[$tax->name]->show_none)) $wp_taxonomies[$tax->name]->show_none = false;
    	}
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Radio Taxonomy
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic