Example #1
0
/**
 * Display our copy-able code for registered taxonomies.
 *
 * @since 1.0.0
 * @since 1.2.0 Added $cptui_taxonomies parameter.
 * @since 1.2.0 Added $single parameter.
 *
 * @param array $cptui_taxonomies Array of taxonomies to render.
 * @param bool  $single           Whether or not we are rendering a single taxonomy.
 *
 * @return string Taxonomy registration text for use elsewhere.
 */
function cptui_get_taxonomy_code($cptui_taxonomies = array(), $single = false)
{
    if (!empty($cptui_taxonomies)) {
        $callback = 'cptui_register_my_taxes';
        if ($single) {
            $key = key($cptui_taxonomies);
            $callback = 'cptui_register_my_taxes_' . str_replace('-', '_', $cptui_taxonomies[$key]['name']);
        }
        ?>
add_action( 'init', '<?php 
        echo $callback;
        ?>
' );
function <?php 
        echo $callback;
        ?>
() {
<?php 
        foreach ($cptui_taxonomies as $tax) {
            echo cptui_get_single_taxonomy_registery($tax) . "\n";
        }
        ?>
// End <?php 
        echo $callback;
        ?>
()
}
<?php 
    } else {
        _e('No taxonomies to display at this time', 'custom-post-type-ui');
    }
}
Example #2
0
/**
 * Display our copy-able code for registered taxonomies.
 *
 * @since 1.0.0
 *
 * @return string Taxonomy registration text for use elsewhere.
 */
function cptui_get_taxonomy_code()
{
    $cptui_taxonomies = get_option('cptui_taxonomies');
    if (!empty($cptui_taxonomies)) {
        ?>
add_action( 'init', 'cptui_register_my_taxes' );
function cptui_register_my_taxes() {
<?php 
        foreach ($cptui_taxonomies as $tax) {
            echo cptui_get_single_taxonomy_registery($tax) . "\n";
        }
        ?>
// End cptui_register_my_taxes
}
<?php 
    } else {
        _e('No taxonomies to display at this time', 'cpt-plugin');
    }
}