Esempio n. 1
0
function xt_ajax_api_app()
{
    $app = xt_is_ready();
    $result = array('code' => 0, 'msg' => '', 'result' => array());
    if (empty($app)) {
        $appKey = intval(trim($_POST['appKey']));
        $appSecret = esc_html(trim($_POST['appSecret']));
        if (!empty($appKey) && !empty($appSecret)) {
            $platform = get_option(XT_OPTION_PLATFORM);
            $app = $platform['xt'];
            $app['appKey'] = $appKey;
            $app['appSecret'] = $appSecret;
            $platform['xt'] = $app;
            update_option(XT_OPTION_PLATFORM, $platform);
            update_option(XT_OPTION_INSTALLED, 1);
            //            $api = new XTClient($app['appKey'], $app['appSecret']);
            //            $api->execute('updatePages', $_REQUEST);
            exit(json_encode($result));
        }
        $result['code'] = 500;
        $result['msg'] = '未指定appKey';
    } else {
        $result['code'] = 500;
        $result['msg'] = '当前站点已经加入新淘客WordPress平台(站点更换域名请联系客服)';
    }
    exit(json_encode($result));
}
Esempio n. 2
0
function xt_admin_notices()
{
    global $wpdb;
    $option_env = get_option(XT_OPTION_ENV);
    $env = IS_BAE ? 'BAE' : (IS_SAE ? 'SAE' : 'VPS');
    if (empty($option_env)) {
        update_option(XT_OPTION_ENV, $env);
    } else {
        if ($env != $option_env) {
            update_option(XT_OPTION_ENV, $env);
        }
    }
    $permalink_structure = get_option('permalink_structure');
    if (empty($permalink_structure)) {
        add_action('admin_notices', 'xt_admin_notice_permalink_structure');
        return true;
    }
    //HOME
    $base = xt_base();
    if (!empty($base)) {
        $home_id = $wpdb->get_var("SELECT id FROM `" . $wpdb->posts . "` WHERE `post_name` = '" . $base . "'\tAND `post_type` != 'revision'");
        if (empty($home_id)) {
            require_once XT_PLUGIN_DIR . '/xt-core/xt-installer-functions.php';
            $home_id = xt_install_home();
        }
    }
    //MENUS
    $global = get_option(XT_OPTION_GLOBAL);
    if (!$global['isMenu']) {
        require_once XT_PLUGIN_DIR . '/xt-core/xt-installer-functions.php';
        xt_install_menu($global);
    }
    $isInstalled = get_option(XT_OPTION_INSTALLED);
    if (!$isInstalled) {
        add_action('admin_notices', 'xt_admin_notice_installing');
    } else {
        if (!file_exists(get_template_directory() . '/xt-page.php')) {
            if (!@copy(XT_THEME_PATH . '/xt-page.php', get_template_directory() . '/xt-page.php')) {
                add_action('admin_notices', 'xt_admin_notice_template');
                return true;
            }
        }
        $app = xt_is_ready();
        if (empty($app)) {
            add_action('admin_notices', 'xt_admin_notice_app');
            return true;
        }
        $app = xt_taobao_is_ready();
        if (empty($app)) {
            add_action('admin_notices', 'xt_admin_notice_app_taobao');
            return true;
        }
        if (!isset($app['tkpid']) || empty($app['tkpid'])) {
            add_action('admin_notices', 'xt_admin_notice_app_taobao_tkpid');
            return true;
        }
        if (!isset($app['s8pid']) || empty($app['s8pid'])) {
            add_action('admin_notices', 'xt_admin_notice_app_taobao_s8pid');
            return true;
        }
        //        $app = xt_taobao_is_session_ready();
        //        if (empty($app)) {
        //            add_action('admin_notices', 'xt_admin_notice_app_taobao_session');
        //            return true;
        //        }
        $app = xt_paipai_is_ready();
        if (empty($app)) {
            add_action('admin_notices', 'xt_admin_notice_app_paipai');
            return true;
        }
        $app = xt_paipai_is_session_ready();
        if (empty($app)) {
            add_action('admin_notices', 'xt_admin_notice_app_paipai_session');
            return true;
        }
    }
}