function wpbc_check_locale_for_ajax()
{
    add_bk_filter('wpdev_check_for_active_language', 'wpdev_check_for_active_language');
    // Add Hook for ability  to check  the content for active lanaguges
    if (isset($_POST['wpdev_active_locale'])) {
        // Reload locale according request parameter
        global $l10n;
        if (isset($l10n['booking'])) {
            unset($l10n['booking']);
        }
        if (!defined('WPDEV_BK_LOCALE_RELOAD')) {
            define('WPDEV_BK_LOCALE_RELOAD', $_POST['wpdev_active_locale']);
        }
        // Reload locale settings, its required for the correct  dates format
        if (isset($l10n['default'])) {
            unset($l10n['default']);
        }
        // Unload locale
        add_filter('locale', 'getBookingLocale', 999);
        // Set filter to load the locale of the Booking Calendar
        load_default_textdomain();
        // Load default locale
        global $wp_locale;
        $wp_locale = new WP_Locale();
        // Reload class
        loadLocale(WPDEV_BK_LOCALE_RELOAD);
    }
}
 public function __construct()
 {
     add_shortcode('jQuery Archive List', array($this, 'filter'));
     add_filter('widget_text', 'do_shortcode');
     if (function_exists("load_plugin_textdomain")) {
         load_plugin_textdomain('jalw_i18n', null, basename(dirname(__FILE__)) . '/lang');
     }
     load_default_textdomain();
     parent::WP_Widget('jal_widget', 'jQuery Archive List Widget', array('description' => __(__('A widget for displaying an archive list with some effects.', 'jalw_i18n'))));
 }
 public function set_language($lang)
 {
     global $sitepress, $woocommerce;
     $sitepress->switch_lang($lang, true);
     $this->locale = $sitepress->get_locale($lang);
     add_filter('plugin_locale', array($this, 'set_locale'), 10, 2);
     unload_textdomain('woocommerce');
     unload_textdomain('woocommerce-germanized');
     unload_textdomain('woocommerce-germanized-pro');
     unload_textdomain('default');
     $woocommerce->load_plugin_textdomain();
     WC_germanized()->load_plugin_textdomain();
     do_action('woocommerce_gzd_wpml_lang_changed', $lang);
     load_default_textdomain();
     global $wp_locale;
     $wp_locale = new WP_Locale();
 }
 /**
  * Init all the things!
  */
 public function __construct()
 {
     // Init Localisation
     load_default_textdomain();
     load_plugin_textdomain($this::TEXT_DOMAIN, false, dirname(plugin_basename(dirname(__FILE__))) . '/lang');
     // Add admin menu pages
     add_action('admin_menu', [&$this, 'addMenuItems']);
     add_action('admin_init', ['Recras\\Settings', 'registerSettings']);
     add_action('admin_init', ['Recras\\Editor', 'addButtons']);
     add_action('init', [&$this, 'setBaseUrl']);
     add_filter('mce_external_languages', ['Recras\\Editor', 'loadTranslations']);
     add_action('admin_enqueue_scripts', [$this, 'loadAdminScripts']);
     add_action('wp_enqueue_scripts', [$this, 'loadScripts']);
     // Clear caches
     add_action('admin_post_clear_arrangement_cache', ['Recras\\Arrangement', 'clearCache']);
     add_action('admin_post_clear_contactform_cache', ['Recras\\ContactForm', 'clearCache']);
     add_action('admin_post_clear_product_cache', ['Recras\\Products', 'clearCache']);
     $this->addShortcodes();
 }
Example #5
0
 /**
  * Reload text domains with order locale.
  *
  * @param string $language Language slug (e.g. en, de )
  */
 public function switchLanguage($language)
 {
     if (class_exists('Polylang')) {
         global $locale, $polylang, $woocommerce;
         static $cache;
         // Polylang string translations cache object to avoid loading the same translations object several times
         // Cache object not found. Create one...
         if (empty($cache)) {
             $cache = new \PLL_Cache();
         }
         //$current_language = pll_current_language( 'locale' );
         // unload plugin's textdomains
         unload_textdomain('default');
         unload_textdomain('woocommerce');
         // set locale to order locale
         $locale = apply_filters('locale', $language);
         $polylang->curlang->locale = $language;
         // Cache miss
         if (false === ($mo = $cache->get($language))) {
             $mo = new \PLL_MO();
             $mo->import_from_db($GLOBALS['polylang']->model->get_language($language));
             $GLOBALS['l10n']['pll_string'] =& $mo;
             // Add to cache
             $cache->set($language, $mo);
         }
         // (re-)load plugin's textdomain with order locale
         load_default_textdomain($language);
         $woocommerce->load_plugin_textdomain();
         $wp_locale = new \WP_Locale();
     }
 }
Example #6
0
function wpdev_bk_ajax_responder()
{
    global $wpdb;
    $action = $_POST['ajax_action'];
    if (isset($_POST['wpdev_active_locale'])) {
        // Reload locale according request parameter
        global $l10n;
        if (isset($l10n['wpdev-booking'])) {
            unset($l10n['wpdev-booking']);
        }
        if (!defined('WPDEV_BK_LOCALE_RELOAD')) {
            define('WPDEV_BK_LOCALE_RELOAD', $_POST['wpdev_active_locale']);
        }
        // Reload locale settings, its required for the correct  dates format
        if (isset($l10n['default'])) {
            unset($l10n['default']);
        }
        // Unload locale
        add_filter('locale', 'getBookingLocale', 999);
        // Set filter to load the locale of the Booking Calendar
        load_default_textdomain();
        // Load default locale
        global $wp_locale;
        $wp_locale = new WP_Locale();
        // Reload class
        loadLocale(WPDEV_BK_LOCALE_RELOAD);
    }
    switch ($action) {
        case 'INSERT_INTO_TABLE':
            wpdev_check_nonce_in_admin_panel($action);
            wpdev_bk_insert_new_booking();
            die;
            break;
        case 'UPDATE_READ_UNREAD':
            wpdev_check_nonce_in_admin_panel();
            make_bk_action('check_multiuser_params_for_client_side_by_user_id', $_POST['user_id']);
            $is_read_or_unread = $_POST["is_read_or_unread"];
            if ($is_read_or_unread == 1) {
                $is_new = '1';
            } else {
                $is_new = '0';
            }
            $id_of_new_bookings = $_POST["booking_id"];
            $arrayof_bookings_id = explode('|', $id_of_new_bookings);
            $user_id = $_POST["user_id"];
            renew_NumOfNewBookings($arrayof_bookings_id, $is_new, $user_id);
            //debuge($arrayof_bookings_id, 'all_array');
            ?>
  <script type="text/javascript">
                    <?php 
            foreach ($arrayof_bookings_id as $bk_id) {
                if ($bk_id == 'all') {
                    $bk_id = 0;
                }
                if ($is_new == '1') {
                    ?>
                                set_booking_row_unread(<?php 
                    echo $bk_id;
                    ?>
);
                            <?php 
                } else {
                    ?>
                                set_booking_row_read(<?php 
                    echo $bk_id;
                    ?>
);                                
                            <?php 
                }
                ?>
                    <?php 
            }
            ?>
                    <?php 
            if ($is_new == '1') {
                ?>
                    //    var my_num = parseInt(jQuery('.bk-update-count').text()) + parseInt(1<?php 
                echo '*' . count($arrayof_bookings_id);
                ?>
);
                    <?php 
            } else {
                ?>
                    //    var my_num = parseInt(jQuery('.bk-update-count').text()) - parseInt(1<?php 
                echo '*' . count($arrayof_bookings_id);
                ?>
);
                    <?php 
            }
            ?>
                    //jQuery('.bk-update-count').html( my_num );
                    document.getElementById('ajax_message').innerHTML = '<?php 
            if ($is_new == '1') {
                echo __('Set as Read', 'wpdev-booking');
            } else {
                echo __('Set as Unread', 'wpdev-booking');
            }
            ?>
';
                    jQuery('#ajax_message').fadeOut(1000);
                </script> <?php 
            die;
            break;
        case 'UPDATE_APPROVE':
            wpdev_check_nonce_in_admin_panel();
            make_bk_action('check_multiuser_params_for_client_side_by_user_id', $_POST['user_id']);
            // Approve or Reject
            $is_approve_or_pending = $_POST["is_approve_or_pending"];
            if ($is_approve_or_pending == 1) {
                $is_approve_or_pending = '1';
            } else {
                $is_approve_or_pending = '0';
            }
            // Booking ID
            $booking_id = $_POST["booking_id"];
            $approved_id = explode('|', $booking_id);
            if (!isset($_POST["denyreason"])) {
                $_POST["denyreason"] = '';
            }
            $denyreason = $_POST["denyreason"];
            $is_send_emeils = $_POST["is_send_emeils"];
            if (count($approved_id) > 0 && $approved_id !== false) {
                $approved_id_str = join(',', $approved_id);
                $approved_id_str = wpbc_clean_string_for_db($approved_id_str);
                if (false === $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}bookingdates SET approved = %s WHERE booking_id IN ({$approved_id_str})", $is_approve_or_pending))) {
                    ?>
 <script type="text/javascript"> document.getElementById('ajax_message').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
                    bk_error('Error during updating to DB', __FILE__, __LINE__);
                    ?>
</div>'; </script> <?php 
                    die;
                }
                renew_NumOfNewBookings(explode(',', $approved_id_str));
                if ($is_approve_or_pending == '1') {
                    sendApproveEmails($approved_id_str, $is_send_emeils, $denyreason);
                    $all_bk_id_what_canceled = apply_bk_filter('cancel_pending_same_resource_bookings_for_specific_dates', false, $approved_id_str);
                    //debuge($pending_bookings);
                } else {
                    sendDeclineEmails($approved_id_str, $is_send_emeils, $denyreason);
                }
                ?>
  <script type="text/javascript">
                        <?php 
                foreach ($approved_id as $bk_id) {
                    if ($is_approve_or_pending == '1') {
                        ?>
                                    set_booking_row_approved_in_timeline(<?php 
                        echo $bk_id;
                        ?>
);
                                    set_booking_row_approved(<?php 
                        echo $bk_id;
                        ?>
);
                                    set_booking_row_read(<?php 
                        echo $bk_id;
                        ?>
);
                                <?php 
                    } else {
                        ?>
                                    set_booking_row_pending_in_timeline(<?php 
                        echo $bk_id;
                        ?>
);
                                    set_booking_row_pending(<?php 
                        echo $bk_id;
                        ?>
);
                                <?php 
                    }
                    ?>
                        <?php 
                }
                ?>
                        document.getElementById('ajax_message').innerHTML = '<?php 
                if ($is_approve_or_pending == '1') {
                    echo __('Set as Approved', 'wpdev-booking');
                } else {
                    echo __('Set as Pending', 'wpdev-booking');
                }
                ?>
';
                        jQuery('#ajax_message').fadeOut(1000);
                    </script> <?php 
                die;
            }
            break;
        case 'DELETE_APPROVE':
            wpdev_check_nonce_in_admin_panel();
            make_bk_action('check_multiuser_params_for_client_side_by_user_id', $_POST['user_id']);
            $booking_id = $_POST["booking_id"];
            // Booking ID
            if (!isset($_POST["denyreason"])) {
                $_POST["denyreason"] = '';
            }
            $denyreason = $_POST["denyreason"];
            if ($denyreason == __('Reason for cancellation here', 'wpdev-booking') || $denyreason == __('Reason of cancellation here', 'wpdev-booking') || $denyreason == 'Reason of cancel here') {
                $denyreason = '';
            }
            $is_send_emeils = $_POST["is_send_emeils"];
            $approved_id = explode('|', $booking_id);
            if (count($approved_id) > 0 && $approved_id != false && $approved_id != '') {
                $approved_id_str = join(',', $approved_id);
                $approved_id_str = wpbc_clean_string_for_db($approved_id_str);
                sendDeclineEmails($approved_id_str, $is_send_emeils, $denyreason);
                if (false === $wpdb->query("DELETE FROM {$wpdb->prefix}bookingdates WHERE booking_id IN ({$approved_id_str})")) {
                    ?>
 <script type="text/javascript"> document.getElementById('ajax_message').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
                    bk_error('Error during deleting dates at DB', __FILE__, __LINE__);
                    ?>
</div>'; </script> <?php 
                    die;
                }
                if (false === $wpdb->query("DELETE FROM {$wpdb->prefix}booking WHERE booking_id IN ({$approved_id_str})")) {
                    ?>
 <script type="text/javascript"> document.getElementById('ajax_message').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
                    bk_error('Error during deleting reservation at DB', __FILE__, __LINE__);
                    ?>
</div>'; </script> <?php 
                    die;
                }
                ?>
                    <script type="text/javascript">
                        <?php 
                foreach ($approved_id as $bk_id) {
                    ?>
                            set_booking_row_deleted_in_timeline(<?php 
                    echo $bk_id;
                    ?>
);
                            set_booking_row_deleted(<?php 
                    echo $bk_id;
                    ?>
);
                        <?php 
                }
                ?>
                        document.getElementById('ajax_message').innerHTML = '<?php 
                echo __('Deleted', 'wpdev-booking');
                ?>
';
                        jQuery('#ajax_message').fadeOut(1000);
                    </script>
                <?php 
                die;
            }
            break;
        case 'DELETE_BY_VISITOR':
            wpdev_check_nonce_in_admin_panel($action);
            make_bk_action('wpdev_delete_booking_by_visitor');
            break;
        case 'SAVE_BK_COST':
            wpdev_check_nonce_in_admin_panel();
            make_bk_action('wpdev_save_bk_cost');
            break;
        case 'SEND_PAYMENT_REQUEST':
            wpdev_check_nonce_in_admin_panel();
            make_bk_action('wpdev_send_payment_request');
            break;
        case 'CHANGE_PAYMENT_STATUS':
            wpdev_check_nonce_in_admin_panel();
            make_bk_action('wpdev_change_payment_status');
            break;
        case 'UPDATE_BK_RESOURCE_4_BOOKING':
            wpdev_check_nonce_in_admin_panel();
            make_bk_action('wpdev_updating_bk_resource_of_booking');
            break;
        case 'UPDATE_REMARK':
            wpdev_check_nonce_in_admin_panel();
            make_bk_action('wpdev_updating_remark');
            break;
        case 'DELETE_BK_FORM':
            wpdev_check_nonce_in_admin_panel();
            make_bk_action('wpdev_delete_booking_form');
            break;
        case 'USER_SAVE_WINDOW_STATE':
            wpdev_check_nonce_in_admin_panel();
            update_user_option($_POST['user_id'], 'booking_win_' . $_POST['window'], $_POST['is_closed']);
            die;
            break;
        case 'CALCULATE_THE_COST':
            wpdev_check_nonce_in_admin_panel($action);
            make_bk_action('wpdev_ajax_show_cost');
            die;
            break;
        case 'BOOKING_SEARCH':
            wpdev_check_nonce_in_admin_panel($action);
            make_bk_action('wpdev_ajax_booking_search');
            die;
            break;
        case 'CHECK_BK_NEWS':
            wpdev_check_nonce_in_admin_panel();
            wpdev_ajax_check_bk_news();
            die;
            break;
        case 'CHECK_BK_FEATURES':
            wpdev_check_nonce_in_admin_panel();
            wpdev_ajax_check_bk_news('info/features/');
            die;
            break;
        case 'CHECK_BK_VERSION':
            wpdev_check_nonce_in_admin_panel();
            wpdev_ajax_check_bk_version();
            die;
            break;
        case 'SAVE_BK_LISTING_FILTER':
            wpdev_check_nonce_in_admin_panel();
            make_bk_action('wpdev_ajax_save_bk_listing_filter');
            die;
            break;
        case 'DELETE_BK_LISTING_FILTER':
            wpdev_check_nonce_in_admin_panel();
            make_bk_action('wpdev_ajax_delete_bk_listing_filter');
            die;
            break;
        case 'EXPORT_BOOKINGS_TO_CSV':
            wpdev_check_nonce_in_admin_panel();
            make_bk_action('wpdev_ajax_export_bookings_to_csv');
            die;
        default:
            wpdev_check_nonce_in_admin_panel();
            if (function_exists('wpdev_pro_bk_ajax')) {
                wpdev_pro_bk_ajax();
            }
            die;
    }
}
Example #7
0
 /**
  * Get all possible translations for a String based on the given Languages and Domains
  *
  * WARNING: This function is slow because it deals with files, so don't overuse it!
  * Differently from the `get_i18n_strings` method this will not use any domain that's not specified.
  *
  * @todo Include support for the `load_theme_textdomain` + `load_muplugin_textdomain`
  *
  * @param  array  $strings          An array of strings (required)
  * @param  array  $languages        Which l10n to fetch the string (required)
  * @param  array  $domains          Possible Domains to re-load
  *
  * @return array                    A multi level array with the possible translations for the given strings
  */
 public function get_i18n_strings_for_domains($strings, $languages, $domains = array('default'))
 {
     foreach ($languages as $language) {
         $this->_locale = $language;
         foreach ((array) $domains as $domain => $file) {
             // Configure the language
             add_filter('locale', array($this, '_set_locale'));
             // Reload it with the correct language
             unload_textdomain($domain);
             if ('default' === $domain) {
                 load_default_textdomain();
             } else {
                 Tribe__Main::instance()->load_text_domain($domain, $file);
             }
             // Loop on the strings the build the possible translations
             foreach ($strings as $key => $value) {
                 $value = is_array($value) ? reset($value) : $value;
                 if (!is_string($value)) {
                     continue;
                 }
                 // Make sure we have an Array
                 $strings[$key] = (array) $strings[$key];
                 // Grab the possible strings for Default and Any other domain
                 if ('default' === $domain) {
                     $strings[$key][] = __($value);
                     $strings[$key][] = __(strtolower($value));
                     $strings[$key][] = __(ucfirst($value));
                 } else {
                     $strings[$key][] = __($value, $domain);
                     $strings[$key][] = __(strtolower($value), $domain);
                     $strings[$key][] = __(ucfirst($value), $domain);
                 }
             }
             // Set back to the default language
             remove_filter('locale', array($this, '_set_locale'));
             // Reload it with the correct language
             unload_textdomain($domain);
             if ('default' === $domain) {
                 load_default_textdomain();
             } else {
                 Tribe__Main::instance()->load_text_domain($domain, $file);
             }
         }
     }
     // Prevent Empty Strings and Duplicates
     foreach ($strings as $key => $value) {
         $strings[$key] = array_filter(array_unique(array_map('sanitize_title_with_dashes', (array) $value)));
     }
     return $strings;
 }
 /**
  * Site language fix 2. Runs after language dropdown.
  * Sets the `return_original` to false.
  */
 public function site_language_fix_2()
 {
     $this->return_original = false;
     load_default_textdomain(get_locale());
 }
Example #9
0
/**
 * Redirect to the About WordPress page after a successful upgrade.
 *
 * This function is only needed when the existing install is older than 3.4.0.
 *
 * @since 3.3.0
 *
 * @global string $wp_version
 * @global string $pagenow
 * @global string $action
 *
 * @param string $new_version
 */
function _redirect_to_about_wordpress($new_version)
{
    global $wp_version, $pagenow, $action;
    if (version_compare($wp_version, '3.4-RC1', '>=')) {
        return;
    }
    // Ensure we only run this on the update-core.php page. The Core_Upgrader may be used in other contexts.
    if ('update-core.php' != $pagenow) {
        return;
    }
    if ('do-core-upgrade' != $action && 'do-core-reinstall' != $action) {
        return;
    }
    // Load the updated default text localization domain for new strings.
    load_default_textdomain();
    // See do_core_upgrade()
    show_message(__('WordPress updated successfully'));
    // self_admin_url() won't exist when upgrading from <= 3.0, so relative URLs are intentional.
    show_message('<span class="hide-if-no-js">' . sprintf(__('Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%2$s">here</a>.'), $new_version, 'about.php?updated') . '</span>');
    show_message('<span class="hide-if-js">' . sprintf(__('Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.'), $new_version, 'about.php?updated') . '</span>');
    echo '</div>';
    ?>
<script type="text/javascript">
window.location = 'about.php?updated';
</script>
	<?php 
    // Include admin-footer.php and exit.
    include ABSPATH . 'wp-admin/admin-footer.php';
    exit;
}
Example #10
0
</p>

<h1><?php 
        _e('Information needed');
        ?>
</h1>
<p><?php 
        _e('Please provide the following information. Don&#8217;t worry, you can always change these settings later.');
        ?>
</p>

<?php 
        display_setup_form();
        break;
    case 2:
        if (!empty($language) && load_default_textdomain($language)) {
            $loaded_language = $language;
            $GLOBALS['wp_locale'] = new WP_Locale();
        } else {
            $loaded_language = 'en_US';
        }
        if (!empty($wpdb->error)) {
            wp_die($wpdb->error->get_error_message());
        }
        display_header();
        // Fill in the data we gathered
        $weblog_title = isset($_POST['weblog_title']) ? trim(wp_unslash($_POST['weblog_title'])) : '';
        $user_name = isset($_POST['user_name']) ? trim(wp_unslash($_POST['user_name'])) : '';
        $admin_password = isset($_POST['admin_password']) ? wp_unslash($_POST['admin_password']) : '';
        $admin_password_check = isset($_POST['admin_password2']) ? wp_unslash($_POST['admin_password2']) : '';
        $admin_email = isset($_POST['admin_email']) ? trim(wp_unslash($_POST['admin_email'])) : '';
Example #11
0
 /**
  * Get all possible translations for a String based on the given Languages and Domains
  *
  * WARNING: This function is slow because it deals with files, so don't overuse it!
  *
  * @todo Include support for the `load_theme_textdomain` + `load_muplugin_textdomain`
  *
  * @param  array  $strings          An array of strings (required)
  * @param  array  $languages        Which l10n to fetch the string (required)
  * @param  array  $domains          Possible Domains to re-load
  * @param  string $default_language The default language to avoid re-doing that
  *
  * @return array                    A multi level array with the possible translations for the given strings
  */
 public function get_i18n_strings($strings, $languages, $domains = array(), $default_language = 'en_US')
 {
     $domains = wp_parse_args($domains, array('default' => true, 'the-events-calendar' => $this->pluginDir . 'lang/'));
     foreach ($languages as $language) {
         foreach ((array) $domains as $domain => $file) {
             // Configure the language
             $this->_locale = $language;
             add_filter('locale', array($this, '_set_locale'));
             // Reload it with the correct language
             unload_textdomain($domain);
             if ('default' === $domain) {
                 load_default_textdomain();
             } else {
                 load_plugin_textdomain($domain, false, $file);
             }
             // Loop on the strings the build the possible translations
             foreach ($strings as $key => $value) {
                 $value = is_array($value) ? reset($value) : $value;
                 if (!is_string($value)) {
                     continue;
                 }
                 // Make sure we have an Array
                 $strings[$key] = (array) $strings[$key];
                 // Grab the possible strings for Default and Any other domain
                 if ('default' === $domain) {
                     $strings[$key][] = __($value);
                     $strings[$key][] = __(strtolower($value));
                     $strings[$key][] = __(ucfirst($value));
                 } else {
                     $strings[$key][] = __($value, $domain);
                     $strings[$key][] = __(strtolower($value), $domain);
                     $strings[$key][] = __(ucfirst($value), $domain);
                 }
             }
             // Set back to the default language
             remove_filter('locale', array($this, '_set_locale'));
             // Reload it with the correct language
             unload_textdomain($domain);
             if ('default' === $domain) {
                 load_default_textdomain();
             } else {
                 load_plugin_textdomain($domain, false, $file);
             }
         }
     }
     // Prevent Empty Strings and Duplicates
     foreach ($strings as $key => $value) {
         $strings[$key] = array_filter(array_unique(array_map('sanitize_title_with_dashes', $value)));
     }
     return $strings;
 }
 function change_email_language($lang)
 {
     global $sitepress, $woocommerce;
     $sitepress->switch_lang($lang, true);
     $this->locale = $sitepress->get_locale($lang);
     unload_textdomain('woocommerce');
     unload_textdomain('default');
     $woocommerce->load_plugin_textdomain();
     load_default_textdomain();
     global $wp_locale;
     $wp_locale = new WP_Locale();
 }
Example #13
0
             if (!is_array($value)) {
                 $value = trim($value);
             }
             $value = wp_unslash($value);
         }
         update_option($option, $value);
     }
     /*
      * Switch translation in case WPLANG was changed.
      * The global $locale is used in get_locale() which is
      * used as a fallback in get_user_locale().
      */
     unset($GLOBALS['locale']);
     $user_language_new = get_user_locale();
     if ($user_language_old !== $user_language_new) {
         load_default_textdomain($user_language_new);
     }
 }
 /**
  * Handle settings errors and return to options page
  */
 // If no settings errors were registered add a general 'updated' message.
 if (!count(get_settings_errors())) {
     add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated');
 }
 set_transient('settings_errors', get_settings_errors(), 30);
 /**
  * Redirect back to the settings page that was submitted
  */
 $goback = add_query_arg('settings-updated', 'true', wp_get_referer());
 wp_redirect($goback);
 /**
  * Load translations for a given locale.
  *
  * When switching to a locale, translations for this locale must be loaded from scratch.
  *
  * @since 4.7.0
  * @access private
  *
  * @global Mo[] $l10n An array of all currently loaded text domains.
  *
  * @param string $locale The locale to load translations for.
  */
 private function load_translations($locale)
 {
     global $l10n;
     $domains = $l10n ? array_keys($l10n) : array();
     load_default_textdomain($locale);
     foreach ($domains as $domain) {
         if ('default' === $domain) {
             continue;
         }
         $mofile = $l10n[$domain]->get_filename();
         unload_textdomain($domain);
         if ($mofile) {
             load_textdomain($domain, $mofile);
         }
         get_translations_for_domain($domain);
     }
 }
/**
 * Load the textdomain for Babble's content language.
 *
 */
function bbl_load_content_textdomain()
{
    load_default_textdomain(bbl_get_current_content_lang_code());
    $GLOBALS['wp_locale'] = new WP_Locale();
}
Example #16
0
/**
 * Load Localization System
 * 多语言系统初始化
 *
 * @param string $setlang Pre-set language.
 * @return string Locale text for link.
 */
function localization_load($setlang = null)
{
    global $locale, $localetype;
    $language = '';
    if ($setlang != null) {
        $language = $setlang;
    } elseif (!empty($_GET['language'])) {
        $language = preg_replace('/[^a-zA-Z_]/', '', $_GET['language']);
    } elseif (isset($_SESSION['language'])) {
        $language = preg_replace('/[^a-zA-Z_]/', '', $_SESSION['language']);
    } else {
        $language = get_locale();
    }
    if ($language == 'Detect') {
        $language = get_locale();
    }
    if (!empty($language)) {
        $locale = check_languages(array($language));
        $link_text = 'language=' . $locale;
    } else {
        $link_text = '';
    }
    load_default_textdomain($locale);
    return $link_text;
}
Example #17
0
File: yze.php Project: ydhl/yangzie
function switch_to_en()
{
    global $language;
    $language = "en";
    load_default_textdomain();
    display_home_wizard();
}
Example #18
0
 * Creates a cookies directory with proper permissions.
 */
_mkdir($app->config('cookies.savepath'));
/**
 * Creates a node directory with proper permissions.
 */
_mkdir($app->config('cookies.savepath') . 'nodes' . DS . 'etsis' . DS);
/**
 * Creates a file directory with proper permissions.
 */
_mkdir($app->config('file.savepath'));
/**
 * Creates a cron directory with proper permissions.
 */
_mkdir(cronDir());
/**
 * Creates the cron directory with proper permissions to store
 * cronjob information.
 */
_mkdir(cronDir() . 'cron/logs/');
/**
 * Error log setting
 */
etsis_set_environment();
/**
 * Loads the default textdomain.
 * 
 * @since 6.1.09
 */
load_default_textdomain('edutrac-sis', APP_PATH . 'languages' . DS);
/**
 * Redirect to the About WordPress page after a successful upgrade.
 *
 * This function is only needed when the existing install is older than 3.3.0.
 *
 * @since 3.3.0
 *
 */
function _redirect_to_about_wordpress( $new_version ) {
	global $wp_version, $pagenow, $action;

	if ( version_compare( $wp_version, '3.3', '>=' ) )
		return;

	// Ensure we only run this on the update-core.php page. wp_update_core() could be called in other contexts.
	if ( 'update-core.php' != $pagenow )
		return;

 	if ( 'do-core-upgrade' != $action && 'do-core-reinstall' != $action )
 		return;

	// Load the updated default text localization domain for new strings
	load_default_textdomain();

	// See do_core_upgrade()
	show_message( __('WordPress updated successfully') );
	show_message( '<span class="hide-if-no-js">' . sprintf( __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%s">here</a>.' ), $new_version, esc_url( admin_url( 'about.php?updated' ) ) ) . '</span>' );
	show_message( '<span class="hide-if-js">' . sprintf( __( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ), $new_version, esc_url( admin_url( 'about.php?updated' ) ) ) . '</span>' );
	echo '</div>';
	?>
<script type="text/javascript">
window.location = '<?php echo admin_url( 'about.php?updated' ); ?>';
</script>
	<?php

	// Include admin-footer.php and exit
	include(ABSPATH . 'wp-admin/admin-footer.php');
	exit();
}
 /**
  * Switches the translations according to the given locale.
  *
  * @since 4.6.0
  *
  * @param string $locale The locale.
  *
  * @return string $locale |false
  */
 public function switch_to_locale($locale)
 {
     $current_locale = get_locale();
     if ($current_locale === $locale) {
         return $locale;
     }
     if (!in_array($locale, get_available_languages())) {
         return false;
     }
     // add here so not to record duplicate switches
     $this->locales[] = $locale;
     /**
      * @global MO[] $l10n
      */
     global $l10n;
     // return early if on no language to switch from
     if (null === $l10n) {
         return false;
     }
     $textdomains = array_keys($l10n);
     if (!$this->has_translations_for_locale($current_locale)) {
         foreach ($textdomains as $textdomain) {
             $this->translations[$current_locale][$textdomain] = get_translations_for_domain($textdomain);
         }
     }
     $this->remove_filters();
     $this->add_filter_for_locale($locale);
     if ($this->has_translations_for_locale($locale)) {
         foreach ($textdomains as $textdomain) {
             if (isset($this->translations[$locale][$textdomain])) {
                 $l10n[$textdomain] = $this->translations[$locale][$textdomain];
             }
         }
     } else {
         foreach ($l10n as $textdomain => $mo) {
             if ('default' === $textdomain) {
                 load_default_textdomain();
                 continue;
             }
             unload_textdomain($textdomain);
             if ($mofile = $mo->get_filename()) {
                 load_textdomain($textdomain, $mofile);
             }
             $this->translations[$locale][$textdomain] = get_translations_for_domain($textdomain);
         }
     }
     /**
      * @global WP_Locale $wp_locale
      */
     $GLOBALS['wp_locale'] = new WP_Locale();
     return $locale;
 }
 * WordPress Widget Factory Object
 * @global object $wp_widget_factory
 * @since 2.8.0
 */
$GLOBALS['wp_widget_factory'] = new WP_Widget_Factory();
/**
 * WordPress User Roles
 * @global object $wp_roles
 * @since 2.0.0
 */
$GLOBALS['wp_roles'] = new WP_Roles();
do_action('setup_theme');
// Define the template related constants.
wp_templating_constants();
// Load the default text localization domain.
load_default_textdomain();
$locale = get_locale();
$locale_file = WP_LANG_DIR . "/{$locale}.php";
if (0 === validate_file($locale) && is_readable($locale_file)) {
    require $locale_file;
}
unset($locale_file);
// Pull in locale data after loading text domain.
require_once ABSPATH . WPINC . '/locale.php';
/**
 * WordPress Locale object for loading locale domain date and various strings.
 * @global object $wp_locale
 * @since 2.1.0
 */
$GLOBALS['wp_locale'] = new WP_Locale();
// Load the functions for the active theme, for both parent and child theme if applicable.
Example #22
0
function polyglot_init()
{
    global $polyglot_settings, $locale;
    if ($polyglot_settings['initialized']) {
        return;
    }
    $content = $_SERVER['REQUEST_URI'];
    $languages = implode('|', $polyglot_settings['knownlangs']);
    if (!$polyglot_settings['use_helpers_in_uri']) {
        $find = array("/^(.*)\\/({$languages})\\/?(.*)\$/i");
    } else {
        $find = array("/^(.*)\\/{$polyglot_settings['uri_helpers']['lang_pref']}\\/({$languages})\\/?(.*)\$/i", "/^(.*)\\/{$polyglot_settings['uri_helpers']['lang_view']}\\/({$languages})\\/?(.*)\$/i");
    }
    $replace = array('', '');
    if (preg_match($find[0], $content, $matches)) {
        $content = $matches[1] . "/" . $matches[3];
        $_GET['lang_pref'] = $matches[2];
    }
    if ($polyglot_settings['use_helpers_in_uri'] && preg_match($find[1], $content, $matches)) {
        $content = $matches[1] . "/" . $matches[3];
        $_GET['lang_view'] = $matches[2];
    }
    $_SERVER['REQUEST_URI'] = $content;
    $_SERVER['PATH_INFO'] = preg_replace($find, $replace, $_SERVER['PATH_INFO']);
    $_SERVER['PHP_SELF'] = preg_replace($find, $replace, $_SERVER['PHP_SELF']);
    //let's check if user has chosen the preferred language
    if (isset($_GET['lang_pref'])) {
        $_GET['lang_pref'] = strtolower($_GET['lang_pref']);
        if (in_array($_GET['lang_pref'], $polyglot_settings['knownlangs'])) {
            setcookie($polyglot_settings['lang_pref_cookie'], $_GET['lang_pref'], time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
            $polyglot_settings['lang_pref'] = $_GET["lang_pref"];
        }
    } elseif (isset($_GET['lang_view'])) {
        $polyglot_settings['lang_pref'] = strtolower($_GET['lang_view']);
    } elseif (isset($_COOKIE[$polyglot_settings['lang_pref_cookie']])) {
        $polyglot_settings['lang_pref'] = strtolower(trim($_COOKIE[$polyglot_settings['lang_pref_cookie']]));
    }
    /**
    This part should be removed but for some reason it's needed on some installations:(
    */
    /*if($polyglot_settings['lang_rewrite'] && !$polyglot_settings['i_have_manually_edited_my_htaccess_file']){
    					if(preg_match('/\/lang\/(..)/i',$_SERVER['REQUEST_URI'],$matches)){
    						$polyglot_settings['lang_pref']=$matches[1];
    					}
    					
    					if(preg_match('/\/lang-pref\/(..)/i',$_SERVER['REQUEST_URI'],$matches)){
    						$polyglot_settings['lang_pref']=$matches[1];
    						setcookie($polyglot_settings['lang_pref_cookie'], $polyglot_settings['lang_pref'], time() + 30000000, COOKIEPATH);
    					}
    }*/
    /*
    If the Polyglot is supposed to change the global language settings then... let's do that!
    */
    if ($polyglot_settings['lang_change_locale']) {
        $polyglot_foo = isset($polyglot_settings['wplang'][$polyglot_settings['lang_pref']]) ? $polyglot_settings['wplang'][$polyglot_settings['lang_pref']] : $polyglot_settings['lang_pref'];
        if (!defined('WPLANG')) {
            //just try
            define('WPLANG', $polyglot_foo);
        }
        if ($locale != $polyglot_foo) {
            $locale = $polyglot_foo;
            //echo $polyglot_settings['lang_pref'];
            load_default_textdomain();
        }
    }
    $polyglot_settings['initialized'] = true;
    return;
}
 public function test_multiple_switches_to_site_locale_and_user_locale()
 {
     global $wp_locale_switcher;
     $site_locale = get_locale();
     $user_id = $this->factory()->user->create(array('role' => 'administrator', 'locale' => 'en_GB'));
     wp_set_current_user($user_id);
     set_current_screen('dashboard');
     $locale_switcher = clone $wp_locale_switcher;
     $wp_locale_switcher = new WP_Locale_Switcher();
     $wp_locale_switcher->init();
     $user_locale = get_user_locale();
     load_default_textdomain($user_locale);
     require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php';
     switch_to_locale('de_DE');
     switch_to_locale($site_locale);
     $expected = i18n_plugin_test();
     restore_current_locale();
     $wp_locale_switcher = $locale_switcher;
     set_current_screen('front');
     $this->assertSame('en_US', get_locale());
     $this->assertSame('This is a dummy plugin', $expected);
 }
 /**
  * Load translations for a given locale.
  *
  * When switching to a locale, translations for this locale must be loaded from scratch.
  *
  * @since 4.7.0
  * @access private
  *
  * @global Mo[] $l10n An array of all currently loaded text domains.
  *
  * @param string $locale The locale to load translations for.
  */
 private function load_translations($locale)
 {
     global $l10n;
     $domains = $l10n ? array_keys($l10n) : array();
     load_default_textdomain($locale);
     foreach ($domains as $domain) {
         if ('default' === $domain) {
             continue;
         }
         unload_textdomain($domain);
         get_translations_for_domain($domain);
     }
 }
Example #25
0
<input name="noapi" type="hidden" value="1" /><?php 
        }
        ?>
	<input type="hidden" name="language" value="<?php 
        echo esc_attr($language);
        ?>
" />
	<p class="step"><input name="submit" type="submit" value="<?php 
        echo htmlspecialchars(__('Submit'), ENT_QUOTES);
        ?>
" class="button button-large" /></p>
</form>
<?php 
        break;
    case 2:
        load_default_textdomain($language);
        $GLOBALS['wp_locale'] = new WP_Locale();
        $dbname = trim(wp_unslash($_POST['dbname']));
        $uname = trim(wp_unslash($_POST['uname']));
        $pwd = trim(wp_unslash($_POST['pwd']));
        $dbhost = trim(wp_unslash($_POST['dbhost']));
        $prefix = trim(wp_unslash($_POST['prefix']));
        $step_1 = 'setup-config.php?step=1';
        $install = 'install.php';
        if (isset($_REQUEST['noapi'])) {
            $step_1 .= '&amp;noapi';
        }
        if (!empty($language)) {
            $step_1 .= '&amp;language=' . $language;
            $install .= '?language=' . $language;
        } else {
 function change_email_language($product_id)
 {
     global $sitepress, $woocommerce;
     $lang = get_post_meta($product_id, '_auction_wpml_language', true);
     if ($lang) {
         $sitepress->switch_lang($lang, true);
         unload_textdomain('woocommerce');
         unload_textdomain('default');
         $woocommerce->load_plugin_textdomain();
         load_default_textdomain();
         global $wp_locale;
         $wp_locale = new WP_Locale();
     }
 }