コード例 #1
0
ファイル: themify-utils.php プロジェクト: tchataigner/palette
function themify_get_skins()
{
    $data = themify_get_data();
    $output = '';
    // Open Styles Folder
    $dir = dirname(__FILE__) . '/../skins';
    if (is_dir($dir)) {
        // If skin exists in /skins/ directory in theme root, select it, otherwise set to No Skin
        $current_skin = themify_get('skin');
        $parsed_skin = parse_url($current_skin, PHP_URL_PATH);
        $basedir_skin = basename(dirname($parsed_skin));
        $is_theme_skin = is_file(THEME_DIR . '/skins/' . $basedir_skin . '/' . basename($parsed_skin));
        if (!$is_theme_skin) {
            $current_skin = get_template_directory_uri() . '/themify/img/non-skin.gif';
        }
        $output = '<input type="hidden" name="skin" value="' . esc_url($current_skin) . '">';
        if (!isset($data['skin']) || '' == $data['skin'] || !$is_theme_skin) {
            $output .= '<div class="skin-preview"><a href="#"><img src="' . esc_url(get_template_directory_uri() . '/themify/img/non-skin.gif') . '" alt="' . esc_attr__('Skin', 'themify') . '" class="selected" /></a><br />' . __('No Skin', 'themify') . '</div>';
        } else {
            $output .= '<div class="skin-preview"><a href="#"><img src="' . esc_url(get_template_directory_uri() . '/themify/img/non-skin.gif') . '" alt="' . esc_attr__('Skin', 'themify') . '" /></a><br />' . __('No Skin', 'themify') . '</div>';
        }
        if ($handle = opendir($dir)) {
            // Grab Folders
            while (false !== ($dirTwo = readdir($handle))) {
                if ($dirTwo != '.' && $dirTwo != '..') {
                    // Check For Folder
                    if (is_dir(str_replace('//', '/', dirname(__FILE__) . '/') . '../skins/' . $dirTwo)) {
                        // Open Folders
                        if ($handleTwo = opendir(str_replace('//', '/', dirname(__FILE__) . '/') . '../skins/' . $dirTwo)) {
                            // Grab Files
                            while (false !== ($file = readdir($handleTwo))) {
                                $ext = substr(strrchr($file, '.'), 1);
                                // File Extension
                                if ($file == 'style.css') {
                                    $info = themify_get_skin_info(str_replace('//', '/', dirname(__FILE__) . '/') . '../skins/' . $dirTwo . '/' . $file);
                                    $fullpath = get_template_directory_uri() . '/skins/' . $dirTwo . '/' . $file;
                                    if (is_file(str_replace('//', '/', dirname(__FILE__) . '/') . '../skins/' . $dirTwo . '/screenshot.png')) {
                                        $image = get_template_directory_uri() . '/skins/' . $dirTwo . '/screenshot.png';
                                    } else {
                                        $image = get_template_directory_uri() . '/themify/img/screenshot-na.png';
                                    }
                                    if ($fullpath == themify_get('skin')) {
                                        $output .= '<div class="skin-preview"><a href="#"><img src="' . esc_url($image) . '" alt="' . esc_attr__('Skin', 'themify') . '" class="selected" id="' . esc_attr(get_template_directory_uri() . '/skins/' . $dirTwo . '/style.css') . '" /></a><br />' . $info['Skin Name'] . '</div>';
                                    } else {
                                        $output .= '<div class="skin-preview"><a href="#"><img src="' . esc_url($image) . '" alt="' . esc_attr__('Skin', 'themify') . '" id="' . esc_attr(get_template_directory_uri() . '/skins/' . $dirTwo . '/style.css') . '" /></a><br />' . $info['Skin Name'] . '</div>';
                                    }
                                }
                            }
                            closedir($handleTwo);
                        }
                    }
                }
            }
            closedir($handle);
        }
    }
    return $output;
}
コード例 #2
0
ファイル: themify-utils.php プロジェクト: rinodung/live-theme
function themify_get_skins()
{
    global $db, $config, $theme;
    $data = themify_get_data();
    $output = '<input type="hidden" name="skin" value="' . $data['skin'] . '">';
    if ($data['skin'] == '' || !isset($data['skin'])) {
        $output .= '<div class="skin-preview"><a href="#"><img src="' . get_template_directory_uri() . '/themify/img/non-skin.gif" alt="skin" id="" class="selected" /></a><br />' . __('No Skin', 'themify') . '</div>';
    } else {
        $output .= '<div class="skin-preview"><a href="#"><img src="' . get_template_directory_uri() . '/themify/img/non-skin.gif" alt="skin" id="" /></a><br />' . __('No Skin', 'themify') . '</div>';
    }
    // Open Styles Folder
    $dir = dirname(__FILE__) . '/../skins';
    if (is_dir($dir)) {
        if ($handle = opendir($dir)) {
            // Grab Folders
            while (false !== ($dirTwo = readdir($handle))) {
                if ($dirTwo != '.' && $dirTwo != '..') {
                    // Check For Folder
                    if (is_dir(str_replace('//', '/', dirname(__FILE__) . '/') . '../skins/' . $dirTwo)) {
                        // Open Folders
                        if ($handleTwo = opendir(str_replace('//', '/', dirname(__FILE__) . '/') . '../skins/' . $dirTwo)) {
                            // Grab Files
                            while (false !== ($file = readdir($handleTwo))) {
                                $ext = substr(strrchr($file, '.'), 1);
                                // File Extension
                                //echo $file;
                                if ($file == 'style.css') {
                                    $info = themify_get_skin_info(str_replace('//', '/', dirname(__FILE__) . '/') . '../skins/' . $dirTwo . '/' . $file);
                                    $fullpath = get_template_directory_uri() . '/skins/' . $dirTwo . '/' . $file;
                                    if (is_file(str_replace('//', '/', dirname(__FILE__) . '/') . '../skins/' . $dirTwo . '/screenshot.png')) {
                                        $image = get_template_directory_uri() . '/skins/' . $dirTwo . '/screenshot.png';
                                    } else {
                                        $image = get_template_directory_uri() . '/themify/img/screenshot-na.png';
                                    }
                                    if ($fullpath == $data['skin']) {
                                        $output .= '<div class="skin-preview"><a href="#"><img src="' . $image . '" alt="skin" class="selected" id="' . get_template_directory_uri() . '/skins/' . $dirTwo . '/style.css" /></a><br />' . $info['Skin Name'] . '</div>';
                                    } else {
                                        $output .= '<div class="skin-preview"><a href="#"><img src="' . $image . '" alt="skin" id="' . get_template_directory_uri() . '/skins/' . $dirTwo . '/style.css" /></a><br />' . $info['Skin Name'] . '</div>';
                                    }
                                }
                            }
                            closedir($handleTwo);
                        }
                    }
                }
            }
            closedir($handle);
        }
    }
    return $output;
}