Example #1
0
function ap_get_theme_url($file)
{
    // checks if the file exists in the theme first,
    // otherwise serve the file from the plugin
    if ($theme_file = locate_template(array('anspress/' . $file))) {
        $template_url = get_template_directory_uri() . '/anspress/' . $file;
    } else {
        $template_url = ANSPRESS_THEME_URL . '/' . ap_get_theme() . '/' . $file;
    }
    return $template_url;
}
Example #2
0
/**
 * Get url to a file
 * Used for enqueue CSS or JS.
 *
 * @param  string $file   File name.
 * @param  mixed  $plugin Plugin path, if calling from AnsPress extension.
 * @return string
 * @since  2.0
 */
function ap_get_theme_url($file, $plugin = false)
{
    $child_path = get_stylesheet_directory() . '/anspress/' . $file;
    $parent_path = get_template_directory() . '/anspress/' . $file;
    // Checks if the file exists in the theme first.
    // Otherwise serve the file from the plugin.
    if (file_exists($child_path)) {
        $template_url = get_stylesheet_directory_uri() . '/anspress/' . $file;
    } elseif (file_exists($parent_path)) {
        $template_url = get_template_directory_uri() . '/anspress/' . $file;
    } elseif ($plugin !== false) {
        $template_url = $plugin . 'theme/' . $file;
    } else {
        $template_url = ANSPRESS_THEME_URL . '/' . ap_get_theme() . '/' . $file;
    }
    return $template_url;
}