Exemplo n.º 1
0
function qtranxf_activation_hook()
{
    //qtranxf_dbg_log('qtranxf_activation_hook: ', __FILE__);
    //global $q_config;
    if (version_compare(PHP_VERSION, '5.2.0') < 0) {
        // Deactivate ourself
        $plugin_dir = qtranxf_plugin_dirname();
        $lang_dir = $plugin_dir . '/lang';
        load_plugin_textdomain('qtranslate', false, $lang_dir);
        $msg = sprintf(__('Plugin %s requires PHP version %s at least. This server instance runs PHP version %s. A PHP version %s or higher is recommended. The plugin has not been activated.', 'qtranslate'), '<a href="https://wordpress.org/plugins/qtranslate-x/" style="color:blue" target="_blank">qTranslate&#8209;X</a>', '5.2.0', PHP_VERSION, '5.4.0');
        deactivate_plugins($plugin_dir . '/qtranslate.php');
        wp_die($msg);
    }
    require_once QTRANSLATE_DIR . '/admin/qtx_admin_options.php';
    require_once QTRANSLATE_DIR . '/admin/qtx_import_export.php';
    // Check if other qTranslate forks are activated.
    if (is_plugin_active('mqtranslate/mqtranslate.php')) {
        qtranxf_admin_notice_deactivate_plugin('mqTranslate', 'mqtranslate/mqtranslate.php');
    }
    if (is_plugin_active('qtranslate/qtranslate.php')) {
        update_option('qtranslate_qtrans_compatibility', '1');
        qtranxf_admin_notice_deactivate_plugin('qTranslate', 'qtranslate/qtranslate.php');
    }
    if (is_plugin_active('qtranslate-xp/ppqtranslate.php')) {
        qtranxf_admin_notice_deactivate_plugin('qTranslate Plus', 'qtranslate-xp/ppqtranslate.php');
    }
    if (is_plugin_active('ztranslate/ztranslate.php')) {
        qtranxf_admin_notice_deactivate_plugin('zTranslate', 'ztranslate/ztranslate.php');
    }
    $next_thanks = get_option('qtranslate_next_thanks');
    $check_qtranslate_forks = $next_thanks === false;
    if ($next_thanks !== false && $next_thanks < time() + 7 * 24 * 60 * 60) {
        $next_thanks = time() + rand(10, 20) * 24 * 60 * 60;
        update_option('qtranslate_next_thanks', $next_thanks);
    }
    $messages = qtranxf_update_admin_notice('next_thanks');
    $default_language = get_option('qtranslate_default_language');
    $first_install = $default_language === false;
    if ($first_install) {
        qtranxf_default_default_language();
        $ver = qtranxf_version_int();
        update_option('qtranslate_version_previous', $ver);
        $check_qtranslate_forks = true;
    } else {
        $ver = get_option('qtranslate_version_previous');
        if (!$ver) {
            update_option('qtranslate_version_previous', 29000);
        }
        if (!isset($messages['initial-install'])) {
            $messages = qtranxf_update_option_admin_notices($messages, 'initial-install');
        }
    }
    // @since 3.3.7
    if ($check_qtranslate_forks) {
        // possibly first install after a fork
        if (get_option('qtranslate_qtrans_compatibility') === false) {
            //to prevent most of fatal errors on upgrade
            if (file_exists(WP_PLUGIN_DIR . '/qtranslate/qtranslate.php') || file_exists(WP_PLUGIN_DIR . '/mqtranslate/mqtranslate.php') || file_exists(WP_PLUGIN_DIR . '/ztranslate/ztranslate.php') || file_exists(WP_PLUGIN_DIR . '/qtranslate-xp/ppqtranslate.php')) {
                update_option('qtranslate_qtrans_compatibility', '1');
            }
        }
    }
    //clear file debug-qtranslate.log
    //$f=null; //qtranxf_dbg
    $f = WP_CONTENT_DIR . '/debug-qtranslate.log';
    if (file_exists($f)) {
        if (WP_DEBUG) {
            $fh = fopen($f, "a+");
            ftruncate($fh, 0);
            fclose($fh);
        } else {
            unlink($f);
        }
    }
    /**
     * @since 3.4
     */
    do_action('qtranslate_activation_hook');
    qtranxf_update_config_files();
}
Exemplo n.º 2
0
function qtranxf_activation_hook()
{
    qtranxf_clear_debug_log();
    //qtranxf_dbg_log('qtranxf_activation_hook: ', __FILE__);
    if (version_compare(PHP_VERSION, '5.2.0') < 0) {
        // Deactivate ourself
        $plugin_dir = qtranxf_plugin_dirname();
        $lang_dir = $plugin_dir . '/lang';
        load_plugin_textdomain('qtranslate', false, $lang_dir);
        $msg = sprintf(__('Plugin %s requires PHP version %s at least. This server instance runs PHP version %s. A PHP version %s or higher is recommended. The plugin has not been activated.', 'qtranslate'), '<a href="https://wordpress.org/plugins/qtranslate-x/" style="color:blue" target="_blank">qTranslate&#8209;X</a>', '5.2.0', PHP_VERSION, '5.4.0');
        deactivate_plugins($plugin_dir . '/qtranslate.php');
        wp_die($msg);
    }
    require_once QTRANSLATE_DIR . '/admin/qtx_admin_options_update.php';
    // Check if other qTranslate forks are activated.
    if (is_plugin_active('mqtranslate/mqtranslate.php')) {
        qtranxf_admin_notice_deactivate_plugin('mqTranslate', 'mqtranslate/mqtranslate.php');
    }
    if (is_plugin_active('qtranslate/qtranslate.php')) {
        update_option('qtranslate_qtrans_compatibility', '1');
        qtranxf_admin_notice_deactivate_plugin('qTranslate', 'qtranslate/qtranslate.php');
    }
    if (is_plugin_active('qtranslate-xp/ppqtranslate.php')) {
        qtranxf_admin_notice_deactivate_plugin('qTranslate Plus', 'qtranslate-xp/ppqtranslate.php');
    }
    if (is_plugin_active('ztranslate/ztranslate.php')) {
        qtranxf_admin_notice_deactivate_plugin('zTranslate', 'ztranslate/ztranslate.php');
    }
    $ts = time();
    $next_thanks = get_option('qtranslate_next_thanks');
    $check_qtranslate_forks = $next_thanks === false;
    if ($next_thanks !== false && $next_thanks < $ts + 7 * 24 * 60 * 60) {
        $next_thanks = $ts + rand(10, 20) * 24 * 60 * 60;
        update_option('qtranslate_next_thanks', $next_thanks);
    }
    $messages = qtranxf_update_admin_notice('next_thanks');
    $default_language = get_option('qtranslate_default_language');
    $ver_cur = qtranxf_version_int();
    $first_install = $default_language === false;
    if ($first_install) {
        qtranxf_default_default_language();
        update_option('qtranslate_version_previous', $ver_cur);
        $check_qtranslate_forks = true;
        if (isset($messages['initial-install'])) {
            $messages = qtranxf_update_option_admin_notices($messages, 'initial-install');
        }
    } else {
        $ver_prv = get_option('qtranslate_version_previous');
        if (!$ver_prv) {
            update_option('qtranslate_version_previous', 29000);
        }
        if (!isset($messages['initial-install'])) {
            $messages = qtranxf_update_option_admin_notices($messages, 'initial-install');
        }
    }
    $vers = get_option('qtranslate_versions', array());
    if (!isset($vers[$ver_cur])) {
        $vers[$ver_cur] = $ts;
    }
    $vers['l'] = $ts;
    update_option('qtranslate_versions', $vers);
    qtranxf_sync_language_config();
    // @since 3.3.7
    if ($check_qtranslate_forks) {
        // possibly first install after a fork
        if (get_option('qtranslate_qtrans_compatibility') === false) {
            //to prevent most of fatal errors on upgrade
            if (file_exists(WP_PLUGIN_DIR . '/qtranslate/qtranslate.php') || file_exists(WP_PLUGIN_DIR . '/mqtranslate/mqtranslate.php') || file_exists(WP_PLUGIN_DIR . '/ztranslate/ztranslate.php') || file_exists(WP_PLUGIN_DIR . '/qtranslate-xp/ppqtranslate.php')) {
                update_option('qtranslate_qtrans_compatibility', '1');
            }
        }
    }
    /**
     * A chance to execute activation actions specifically for this plugin.
     * @since 3.4
     */
    do_action('qtranslate_activation_hook');
    qtranxf_update_config_files();
}