Example #1
0
/**
 * Returns the theme rewrite slug used for single themes.
 *
 * @since  1.0.0
 * @access public
 * @return string
 */
function thds_get_theme_rewrite_slug()
{
    $rewrite_base = thds_get_rewrite_base();
    $theme_base = thds_get_theme_rewrite_base();
    $slug = $theme_base ? trailingslashit($rewrite_base) . $theme_base : $rewrite_base;
    return apply_filters('thds_get_theme_rewrite_slug', $slug);
}
    /**
     * Theme rewrite base field callback.
     *
     * @since  1.0.0
     * @access public
     * @return void
     */
    public function field_theme_rewrite_base()
    {
        ?>

		<label>
			<code><?php 
        echo esc_url(home_url(thds_get_rewrite_base() . '/'));
        ?>
</code>
			<input type="text" class="regular-text code" name="thds_settings[theme_rewrite_base]" value="<?php 
        echo esc_attr(thds_get_theme_rewrite_base());
        ?>
" />
		</label>
	<?php 
    }
Example #3
0
/**
 * If a theme has `%portfolio_subject%` or `%portfolio_feature%` in its permalink structure,
 * it must have a term set for the taxonomy.  This function is a callback on `save_post`
 * that checks if a term is set.  If not, it forces the first term of the taxonomy to be
 * the selected term.
 *
 * @since  1.0.0
 * @access public
 * @param  int    $post_id
 * @return void
 */
function thds_force_term_selection($post_id)
{
    if (thds_is_theme($post_id)) {
        $theme_base = thds_get_theme_rewrite_base();
        $subject_tax = thds_get_subject_taxonomy();
        if (false !== strpos($theme_base, "%{$subject_tax}%")) {
            thds_set_term_if_none($post_id, $subject_tax, thds_get_default_subject());
        }
    }
}