/** * Constructor * @access public * @since 1.0.0 */ public function __construct($taxonomy) { $this->taxonomy = $taxonomy; // get the taxonomy object - need to get it after init but before admin_menu $this->tax_obj = get_taxonomy($taxonomy); // Remove old taxonomy meta box add_action('admin_menu', array($this, 'remove_meta_box')); // Add new taxonomy meta box add_action('add_meta_boxes', array($this, 'add_meta_box')); // change checkboxes to radios & trigger get_terms() filter add_filter('wp_terms_checklist_args', array($this, 'filter_terms_checklist_args')); // Switch ajax callback for adding a non-hierarchical term if (!Radio_Buttons_for_Taxonomies()->is_version('4.4.0')) { remove_action('wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term'); add_action('wp_ajax_add-' . $taxonomy, array($this, 'add_non_hierarchical_term')); } // never save more than 1 term add_action('save_post', array($this, 'save_single_term')); add_action('edit_attachment', array($this, 'save_single_term')); // hack global taxonomy to switch all radio taxonomies to hierarchical on edit screen add_action('load-edit.php', array($this, 'make_hierarchical')); // add nonce to quick edit/bulk edit add_action('quick_edit_custom_box', array($this, 'quick_edit_nonce')); }
"> <?php settings_fields('radio_button_for_taxonomies_options'); ?> <?php $options = get_option('radio_button_for_taxonomies_options'); ?> <fieldset> <legend><?php esc_html_e('Select taxonomies to convert to radio buttons', 'radio-buttons-for-taxonomies'); ?> </legend> <?php $taxonomies = Radio_Buttons_for_Taxonomies()->get_all_taxonomies(); if (!empty($taxonomies)) { foreach ($taxonomies as $i => $taxonomy) { $checked = checked(isset($options['taxonomies']) && is_array($options['taxonomies']) && in_array($i, $options['taxonomies']), 1, false); $id = "rbt_{$i}"; ?> <p> <label for="<?php echo $id; ?> "> <input type="checkbox" name="radio_button_for_taxonomies_options[taxonomies][]" value="<?php echo $i; ?>
* * @wp-hook mlp_mutually_exclusive_taxonomies * @param array $taxonomies * @return array */ public function multilingualpress_support(array $taxonomies) { $remote_options = get_option('radio_button_for_taxonomies_options', array()); if (empty($remote_options['taxonomies'])) { return $taxonomies; } $all_taxonomies = array_merge((array) $remote_options['taxonomies'], $taxonomies); return array_unique($all_taxonomies); } } // end class } /** * Launch the whole plugin * Returns the main instance of WC to prevent the need to use globals. * * @since 1.6 * @return Radio_Buttons_for_Taxonomies */ function Radio_Buttons_for_Taxonomies() { return Radio_Buttons_for_Taxonomies::instance(); } // Global for backwards compatibility. $GLOBALS['Radio_Buttons_for_Taxonomies'] = Radio_Buttons_for_Taxonomies();