Пример #1
0
function ikit_two_ajax($action, $data = array())
{
    $data['action'] = $action;
    $ajax_url = IKIT_AJAX_URL;
    // CURL does not have a built-in root cert, so it can't perform requests
    // over https, so instead we just convert to http, because this
    // is performed as a server side method call, it is never
    // exposed and so safe to do so.
    $ajax_url = str_replace('https://', 'http://', $ajax_url);
    // XXX If using theme test drive plugin to test out the theme,
    // we need to append the theme here, as curl runs on the server
    // so does not have the session parameters that allow browsers
    // to view the test driven theme.
    if (function_exists('themedrive_is_enabled')) {
        if (themedrive_is_enabled()) {
            $ajax_url = $ajax_url . '?theme=' . IKIT_TWO_THEME_NAME;
        }
    }
    $curl_request = curl_init();
    curl_setopt($curl_request, CURLOPT_POST, true);
    curl_setopt($curl_request, CURLOPT_URL, $ajax_url);
    curl_setopt($curl_request, CURLOPT_POSTFIELDS, $data);
    curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, true);
    $curl_response = curl_exec($curl_request);
    curl_close($curl_request);
    return $curl_response;
}
function themedrive_switcher()
{
    $themes = wp_get_themes();
    $default_theme = wp_get_theme();
    if (count($themes) > 1) {
        $theme_names = array_keys($themes);
        natcasesort($theme_names);
        $ts = '<select name="td_themes">' . "\n";
        $tp = '<div id="theme_preview">
<div class="theme_links"><strong>Instant Theme Preview</strong><br/><br/>Hover over the link, reload the page if needed.<br/><ul>';
        foreach ($theme_names as $theme_name) {
            // Skip unpublished themes.
            if (isset($themes[$theme_name]['Status']) && $themes[$theme_name]['Status'] != 'publish') {
                continue;
            }
            if (themedrive_get_theme() == $theme_name || themedrive_get_theme() == '' && $theme_name == $default_theme) {
                $ts .= '        <option value="' . esc_attr($theme_name) . '" selected="selected">' . $themes[$theme_name]['Name'] . '</option>' . "\n";
            } else {
                $ts .= '        <option value="' . esc_attr($theme_name) . '">' . $themes[$theme_name]['Name'] . '</option>' . "\n";
            }
            $tp .= '<li><a href="' . trailingslashit(get_option('siteurl')) . '?theme=' . esc_url($theme_name) . '">' . $theme_name . '</a></li>';
        }
        $ts .= '    </select>' . "\n\n";
        $tp .= '</ul></div></div>';
    }
    //  echo $tp;
    echo $ts;
    if (themedrive_is_enabled()) {
        echo '<strong>Theme Test Drive is Enabled.</strong><br />';
    } else {
        echo 'Theme Test Drive is Disabled.<br />';
    }
}