function wpcf7_load_textdomain($locale = null) { global $l10n; $domain = 'contact-form-7'; if (get_locale() == $locale) { $locale = null; } if (empty($locale)) { if (is_textdomain_loaded($domain)) { return true; } else { return load_plugin_textdomain($domain, false, $domain . '/languages'); } } else { $mo_orig = $l10n[$domain]; unload_textdomain($domain); $mofile = $domain . '-' . $locale . '.mo'; $path = WP_PLUGIN_DIR . '/' . $domain . '/languages'; if ($loaded = load_textdomain($domain, $path . '/' . $mofile)) { return $loaded; } else { $mofile = WP_LANG_DIR . '/plugins/' . $mofile; return load_textdomain($domain, $mofile); } $l10n[$domain] = $mo_orig; } return false; }
public function init() { $this->title($this->tab); if (!is_textdomain_loaded('debug-bar-actions-and-filters-addon')) { load_plugin_textdomain('debug-bar-actions-and-filters-addon', false, dirname(plugin_basename(__FILE__)) . '/languages'); } add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts')); add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); }
function __construct() { //@see https://core.trac.wordpress.org/ticket/10527 if (!is_textdomain_loaded('breadcrumb-navxt')) { load_plugin_textdomain('breadcrumb-navxt', false, 'breadcrumb-navxt/languages'); } $ops = array('classname' => 'widget_breadcrumb_navxt', 'description' => __('Adds a breadcrumb trail to your sidebar', 'breadcrumb-navxt')); parent::__construct('bcn_widget', 'Breadcrumb NavXT', $ops); }
/** * @ticket 21319 */ function test_is_textdomain_loaded_for_no_translations() { $this->assertFalse(load_textdomain('wp-tests-domain', DIR_TESTDATA . '/non-existent-file')); $this->assertFalse(is_textdomain_loaded('wp-tests-domain')); $this->assertInstanceOf('NOOP_Translations', get_translations_for_domain('wp-tests-domain')); // Ensure that we don't confuse NOOP_Translations to be a loaded text domain. $this->assertFalse(is_textdomain_loaded('wp-tests-domain')); $this->assertFalse(unload_textdomain('wp-tests-domain')); }
public function __construct() { //@see https://core.trac.wordpress.org/ticket/10527 if (!is_textdomain_loaded('breadcrumb-navxt')) { load_plugin_textdomain('breadcrumb-navxt', false, 'breadcrumb-navxt/languages'); } $this->trail =& $this->breadcrumbs; //Initilize with default option values $this->opt = array('bmainsite_display' => true, 'Hmainsite_template' => bcn_breadcrumb::get_default_template(), 'Hmainsite_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor, 'bhome_display' => true, 'Hhome_template' => bcn_breadcrumb::get_default_template(), 'Hhome_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor, 'bblog_display' => true, 'Hblog_template' => bcn_breadcrumb::get_default_template(), 'Hblog_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor, 'hseparator' => ' > ', 'blimit_title' => false, 'amax_title_length' => 20, 'bcurrent_item_linked' => false, 'Hpost_page_template' => bcn_breadcrumb::get_default_template(), 'Hpost_page_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor, 'apost_page_root' => get_option('page_on_front'), 'Hpaged_template' => __('<span property="itemListElement" typeof="ListItem"><span property="name">Page %htitle%</span><meta property="position" content="%position%"></span>', 'breadcrumb-navxt'), 'bpaged_display' => false, 'Hpost_post_template' => bcn_breadcrumb::get_default_template(), 'Hpost_post_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor, 'apost_post_root' => get_option('page_for_posts'), 'bpost_post_taxonomy_display' => true, 'Spost_post_taxonomy_type' => 'category', 'Hpost_attachment_template' => bcn_breadcrumb::get_default_template(), 'Hpost_attachment_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor, 'H404_template' => bcn_breadcrumb::default_template_no_anchor, 'S404_title' => __('404', 'breadcrumb-navxt'), 'Hsearch_template' => __('<span property="itemListElement" typeof="ListItem"><span property="name">Search results for '<a property="item" typeof="WebPage" title="Go to the first page of search results for %title%." href="%link%" class="%type%">%htitle%</a>'</span><meta property="position" content="%position%"></span>', 'breadcrumb-navxt'), 'Hsearch_template_no_anchor' => __('<span property="itemListElement" typeof="ListItem"><span property="name">Search results for '%htitle%'</span><meta property="position" content="%position%"></span>', 'breadcrumb-navxt'), 'Htax_post_tag_template' => __('<span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="Go to the %title% tag archives." href="%link%" class="%type%"><span property="name">%htitle%</span></a><meta property="position" content="%position%"></span>', 'breadcrumb-navxt'), 'Htax_post_tag_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor, 'Htax_post_format_template' => __('<span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="Go to the %title% archives." href="%link%" class="%type%"><span property="name">%htitle%</span></a><meta property="position" content="%position%"></span>', 'breadcrumb-navxt'), 'Htax_post_format_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor, 'Hauthor_template' => __('<span property="itemListElement" typeof="ListItem"><span property="name">Articles by: <a title="Go to the first page of posts by %title%." href="%link%" class="%type%">%htitle%</a>', 'breadcrumb-navxt'), 'Hauthor_template_no_anchor' => __('<span property="itemListElement" typeof="ListItem"><span property="name">Articles by: %htitle%</span><meta property="position" content="%position%"></span>', 'breadcrumb-navxt'), 'Sauthor_name' => 'display_name', 'Htax_category_template' => __('<span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="Go to the %title% category archives." href="%link%" class="%type%"><span property="name">%htitle%</span></a><meta property="position" content="%position%"></span>', 'breadcrumb-navxt'), 'Htax_category_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor, 'Hdate_template' => __('<span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="Go to the %title% archives." href="%link%" class="%type%"><span property="name">%htitle%</span></a><meta property="position" content="%position%"></span>', 'breadcrumb-navxt'), 'Hdate_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor); }
function test_load_unload_textdomain() { $this->assertFalse(is_textdomain_loaded('wp-tests-domain')); $this->assertFalse(unload_textdomain('wp-tests-domain')); $file = DIR_TESTDATA . '/pomo/simple.mo'; $this->assertTrue(load_textdomain('wp-tests-domain', $file)); $this->assertTrue(is_textdomain_loaded('wp-tests-domain')); $this->assertTrue(unload_textdomain('wp-tests-domain')); $this->assertFalse(is_textdomain_loaded('wp-tests-domain')); }
/** * @ticket 34114 */ public function test_theme_translation_should_be_translated_without_calling_load_theme_textdomain() { add_filter('locale', array($this, 'filter_set_locale_to_german')); switch_theme('internationalized-theme'); include_once get_stylesheet_directory() . '/functions.php'; $is_textdomain_loaded_before = is_textdomain_loaded('internationalized-theme'); $expected_output = i18n_theme_test(); $is_textdomain_loaded_after = is_textdomain_loaded('internationalized-theme'); unload_textdomain('internationalized-theme'); remove_filter('locale', array($this, 'filter_set_locale_to_german')); $this->assertFalse($is_textdomain_loaded_before); $this->assertSame('Das ist ein Dummy Theme', $expected_output); $this->assertTrue($is_textdomain_loaded_after); }
function bogo_languages() { static $languages = array(); static $textdomain_loaded = false; if ($languages && $textdomain_loaded) { return apply_filters('bogo_languages', $languages); } $languages = array('af' => __('Afrikaans', 'bogo'), 'am' => __('Amharic', 'bogo'), 'an' => __('Aragonese', 'bogo'), 'ar' => __('Arabic', 'bogo'), 'as' => __('Assamese', 'bogo'), 'az' => __('Azerbaijani', 'bogo'), 'be_BY' => __('Belarusian', 'bogo'), 'bg_BG' => __('Bulgarian', 'bogo'), 'bn_BD' => __('Bangla', 'bogo'), 'bn_IN' => __('Indian Bengali', 'bogo'), 'bo' => __('Tibetan', 'bogo'), 'bs_BA' => __('Bosnian', 'bogo'), 'ca' => __('Catalan', 'bogo'), 'ckb' => __('Central Kurdish', 'bogo'), 'co' => __('Corsican', 'bogo'), 'cs_CZ' => __('Czech', 'bogo'), 'cy' => __('Welsh', 'bogo'), 'da_DK' => __('Danish', 'bogo'), 'de_DE' => __('German', 'bogo'), 'de_DE_formal' => __('German (Formal)', 'bogo'), 'de_CH' => __('German (Switzerland)', 'bogo'), 'dv' => __('Dhivehi', 'bogo'), 'el' => __('Greek', 'bogo'), 'en_US' => __('English (United States)', 'bogo'), 'en_AU' => __('English (Australia)', 'bogo'), 'en_CA' => __('English (Canada)', 'bogo'), 'en_GB' => __('English (UK)', 'bogo'), 'eo' => __('Esperanto', 'bogo'), 'es_ES' => __('Spanish (Spain)', 'bogo'), 'es_CL' => __('Spanish (Chile)', 'bogo'), 'es_CO' => __('Spanish (Colombia)', 'bogo'), 'es_MX' => __('Spanish (Mexico)', 'bogo'), 'es_PE' => __('Spanish (Peru)', 'bogo'), 'es_VE' => __('Spanish (Venezuela)', 'bogo'), 'et' => __('Estonian', 'bogo'), 'eu' => __('Basque', 'bogo'), 'fa_IR' => __('Persian', 'bogo'), 'fi' => __('Finnish', 'bogo'), 'fo' => __('Faroese', 'bogo'), 'fr_FR' => __('French (France)', 'bogo'), 'fy' => __('Frisian', 'bogo'), 'ga' => __('Irish', 'bogo'), 'gd' => __('Scottish Gaelic', 'bogo'), 'gl_ES' => __('Galician', 'bogo'), 'gu' => __('Gujarati', 'bogo'), 'haz' => __('Hazaragi', 'bogo'), 'he_IL' => __('Hebrew', 'bogo'), 'hi_IN' => __('Hindi', 'bogo'), 'hr' => __('Croatian', 'bogo'), 'ht' => __('Haitian', 'bogo'), 'hu_HU' => __('Hungarian', 'bogo'), 'hy' => __('Armenian', 'bogo'), 'id_ID' => __('Indonesian', 'bogo'), 'is_IS' => __('Icelandic', 'bogo'), 'it_IT' => __('Italian', 'bogo'), 'ja' => __('Japanese', 'bogo'), 'jv_ID' => __('Javanese', 'bogo'), 'ka_GE' => __('Georgian', 'bogo'), 'kk' => __('Kazakh', 'bogo'), 'km_KH' => __('Khmer', 'bogo'), 'kn' => __('Kannada', 'bogo'), 'ko_KR' => __('Korean', 'bogo'), 'li' => __('Limburgish', 'bogo'), 'lo' => __('Lao', 'bogo'), 'lt_LT' => __('Lithuanian', 'bogo'), 'lv' => __('Latvian', 'bogo'), 'mg_MG' => __('Malagasy', 'bogo'), 'mk_MK' => __('Macedonian', 'bogo'), 'ml_IN' => __('Malayalam', 'bogo'), 'mn' => __('Mongolian', 'bogo'), 'mr' => __('Marathi', 'bogo'), 'ms_MY' => __('Malay', 'bogo'), 'mt_MT' => __('Maltese', 'bogo'), 'my_MM' => __('Burmese', 'bogo'), 'nb_NO' => __('Norwegian (Bokmål)', 'bogo'), 'ne_NP' => __('Nepali', 'bogo'), 'ni_ID' => __('Nias', 'bogo'), 'nl_NL' => __('Dutch', 'bogo'), 'nn_NO' => __('Norwegian (Nynorsk)', 'bogo'), 'oci' => __('Occitan', 'bogo'), 'os' => __('Ossetic', 'bogo'), 'pa_IN' => __('Punjabi', 'bogo'), 'pl_PL' => __('Polish', 'bogo'), 'ps' => __('Pashto', 'bogo'), 'pt_BR' => __('Portuguese (Brazil)', 'bogo'), 'pt_PT' => __('Portuguese (Portugal)', 'bogo'), 'ro_RO' => __('Romanian', 'bogo'), 'ru_RU' => __('Russian', 'bogo'), 'sa_IN' => __('Sanskrit', 'bogo'), 'si_LK' => __('Sinhala', 'bogo'), 'sk_SK' => __('Slovak', 'bogo'), 'sl_SI' => __('Slovenian', 'bogo'), 'so_SO' => __('Somali', 'bogo'), 'sq' => __('Albanian', 'bogo'), 'sr_RS' => __('Serbian', 'bogo'), 'sv_SE' => __('Swedish', 'bogo'), 'su_ID' => __('Sundanese', 'bogo'), 'sw' => __('Swahili', 'bogo'), 'ta_IN' => __('Tamil', 'bogo'), 'te' => __('Telugu', 'bogo'), 'tg' => __('Tajik', 'bogo'), 'th' => __('Thai', 'bogo'), 'tl' => __('Tagalog', 'bogo'), 'tr_TR' => __('Turkish', 'bogo'), 'tt_RU' => __('Tatar', 'bogo'), 'ug_CN' => __('Uighur', 'bogo'), 'uk' => __('Ukrainian', 'bogo'), 'ur' => __('Urdu', 'bogo'), 'uz_UZ' => __('Uzbek', 'bogo'), 'vi' => __('Vietnamese', 'bogo'), 'zh_CN' => __('Chinese (China)', 'bogo'), 'zh_TW' => __('Chinese (Taiwan)', 'bogo')); if (is_textdomain_loaded('bogo')) { $textdomain_loaded = true; } asort($languages, SORT_STRING); return apply_filters('bogo_languages', $languages); }
private function __construct() { if (defined('DOING_CRON') || !current_user_can('backwpup') || !is_admin_bar_showing() || !get_site_option('backwpup_cfg_showadminbar')) { return; } //load text domain if (!is_textdomain_loaded('backwpup')) { load_plugin_textdomain('backwpup', FALSE, BackWPup::get_plugin_data('BaseName') . '/languages'); } //add admin bar. Works only in init add_action('admin_bar_menu', array($this, 'adminbar'), 100); //admin css add_action('wp_head', array('BackWPup_Admin', 'admin_head')); }
/** * Constructor. */ public function init() { if (!class_exists('Debug_Bar_Pretty_Output') && class_exists('Debug_Bar_Panel')) { require_once plugin_dir_path(__FILE__) . 'inc/debug-bar-pretty-output/class-debug-bar-pretty-output.php'; } if (!class_exists('Debug_Bar_List_PHP_Classes')) { require_once plugin_dir_path(__FILE__) . 'inc/debug-bar-pretty-output/class-debug-bar-list-php-classes.php'; } if (!is_textdomain_loaded(self::DBC_NAME)) { load_plugin_textdomain(self::DBC_NAME, false, dirname(plugin_basename(__FILE__)) . '/languages'); } add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts')); add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); }
/** * Fix for WooCommerce so it can handle custom admin language without breaking non-admin pages. * * @return bool If true set_language will use site language, otherwise custom language. */ public function fix_woocommerce() { // Check if WooCommerce is active. $active_plugins = get_option('active_plugins'); if (is_multisite()) { $active_plugins = array_merge($active_plugins, array_keys(get_site_option('active_sitewide_plugins'))); } if (!in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', $active_plugins), true)) { return false; } if (function_exists('is_ajax') && is_ajax() || !empty($_GET['wc-ajax'])) { return true; } // @codingStandardsIgnoreStart - Ignore rule against processing postdata without nonce if (isset($_POST['wc_order_action'])) { return true; } // @codingStandardsIgnoreEnd // Do not translate WooCommerce when creating pages or upgrade langs if (!empty($_GET['page']) && $_GET['page'] === 'wc-settings' && !empty($_GET['install_woocommerce_pages']) || !empty($_GET['page']) && $_GET['page'] === 'wc-status' && !empty($_GET['action']) && $_GET['action'] === 'install_pages' || !empty($_GET['page']) && $_GET['page'] === 'wc-status' && !empty($_GET['action']) && $_GET['action'] === 'translation_upgrade') { return true; } // Set WooCommerce permalinks to site language if not set. Will otherwise break permalinks. $this->return_original = true; $permalinks = get_option('woocommerce_permalinks'); if (empty($permalinks)) { $permalinks = []; } $was_loaded = false; if (empty($permalinks['category_base']) || empty($permalinks['tag_base'])) { if (is_textdomain_loaded('woocommerce')) { $was_loaded = true; } load_plugin_textdomain('woocommerce', false, WP_PLUGIN_DIR . '/woocommerce/i18n/languages'); if (empty($permalinks['category_base'])) { $permalinks['category_base'] = _x('product-category', 'slug', 'woocommerce'); } if (empty($permalinks['tag_base'])) { $permalinks['tag_base'] = _x('product-tag', 'slug', 'woocommerce'); } update_option('woocommerce_permalinks', $permalinks); unload_textdomain('woocommerce'); } $this->return_original = false; // Reload WooCommerce textdomain if ($was_loaded) { load_plugin_textdomain('woocommerce', false, WP_PLUGIN_DIR . '/woocommerce/i18n/languages'); } }
public function init() { // bail if the plugin is in network mode if ($this->args['network']) { return; } // gPlugin Local: // if ( ! is_textdomain_loaded( GPLUGIN_TEXTDOMAIN ) ) // load_plugin_textdomain( GPLUGIN_TEXTDOMAIN, FALSE, 'gplugin/languages' ); // Parent Plugin Local: if (!is_textdomain_loaded($this->args['domain'])) { $this->load_textdomain(); } // init here to help filtering the templates if (isset($this->constants['class_mustache'])) { call_user_func(array($this->constants['class_mustache'], 'init')); } }
/** * * Set needed filters and actions and load all needed * * @return \BackWPup_Admin */ public function __construct() { //Load text domain if (!is_textdomain_loaded('backwpup')) { load_plugin_textdomain('backwpup', FALSE, BackWPup::get_plugin_data('BaseName') . '/languages'); } //Add menu pages add_filter('backwpup_admin_pages', array($this, 'admin_page_jobs'), 2); add_filter('backwpup_admin_pages', array($this, 'admin_page_editjob'), 3); add_filter('backwpup_admin_pages', array($this, 'admin_page_logs'), 4); add_filter('backwpup_admin_pages', array($this, 'admin_page_backups'), 5); add_filter('backwpup_admin_pages', array($this, 'admin_page_settings'), 6); add_filter('backwpup_admin_pages', array($this, 'admin_page_about'), 20); //Add Menu if (is_multisite()) { add_action('network_admin_menu', array($this, 'admin_menu')); } else { add_action('admin_menu', array($this, 'admin_menu')); } //add Plugin links add_filter('plugin_row_meta', array($this, 'plugin_links'), 10, 2); //add more actions add_action('admin_init', array($this, 'admin_init')); //add more actions add_action('admin_head', array($this, 'admin_head')); //Save Form posts general add_action('admin_post_backwpup', array($this, 'save_post_form')); //Admin Footer Text replacement add_filter('admin_footer_text', array($this, 'admin_footer_text'), 100); add_filter('update_footer', array($this, 'update_footer'), 100); //User Profile fields add_action('show_user_profile', array($this, 'user_profile_fields')); add_action('edit_user_profile', array($this, 'user_profile_fields')); add_action('profile_update', array($this, 'save_profile_update')); add_filter('editable_roles', array($this, 'editable_roles')); add_filter('manage_users_columns', array($this, 'manage_users_columns')); add_filter('manage_users_custom_column', array($this, 'manage_users_custom_column'), 10, 3); //Change Backup message on core updates add_filter('gettext', array($this, 'gettext'), 10, 3); //Plugin banner free /*if ( ! class_exists( 'BackWPup_Pro', FALSE ) ) add_action( 'admin_notices', array( $this, 'get_pro_banner' ) );*/ }
/** * * This starts or restarts the job working * * @param string $start_type Start types are 'runnow', 'runnowalt', 'cronrun', 'runext', 'runcli' * @param array|int $job_id The id of job of a job to start */ private function create($start_type, $job_id = 0) { global $wpdb; /* @var wpdb $wpdb */ //check startype if (!in_array($start_type, array('runnow', 'runnowalt', 'cronrun', 'runext', 'runcli'), true)) { return; } if ($job_id) { $this->job = BackWPup_Option::get_job($job_id); } else { return; } $this->start_time = current_time('timestamp'); $this->lastmsg = __('Starting job', 'backwpup'); //set Logfile $log_folder = get_site_option('backwpup_cfg_logfolder'); $log_folder = BackWPup_File::get_absolute_path($log_folder); $this->logfile = $log_folder . 'backwpup_log_' . BackWPup::get_plugin_data('hash') . '_' . date('Y-m-d_H-i-s', current_time('timestamp')) . '.html'; //write settings to job BackWPup_Option::update($this->job['jobid'], 'lastrun', $this->start_time); BackWPup_Option::update($this->job['jobid'], 'logfile', $this->logfile); //Set current logfile BackWPup_Option::update($this->job['jobid'], 'lastbackupdownloadurl', ''); //Set needed job values $this->timestamp_last_update = microtime(true); $this->exclude_from_backup = explode(',', trim($this->job['fileexclude'])); $this->exclude_from_backup = array_unique($this->exclude_from_backup); //setup job steps $this->steps_data['CREATE']['CALLBACK'] = ''; $this->steps_data['CREATE']['NAME'] = __('Job Start', 'backwpup'); $this->steps_data['CREATE']['STEP_TRY'] = 0; //ADD Job types file /* @var $job_type_class BackWPup_JobTypes */ $job_need_dest = false; if ($job_types = BackWPup::get_job_types()) { foreach ($job_types as $id => $job_type_class) { if (in_array($id, $this->job['type'], true) && $job_type_class->creates_file()) { $this->steps_todo[] = 'JOB_' . $id; $this->steps_data['JOB_' . $id]['NAME'] = $job_type_class->info['description']; $this->steps_data['JOB_' . $id]['STEP_TRY'] = 0; $this->steps_data['JOB_' . $id]['SAVE_STEP_TRY'] = 0; $job_need_dest = true; } } } //add destinations and create archive if a job where files to backup if ($job_need_dest) { //Create manifest file $this->steps_todo[] = 'CREATE_MANIFEST'; $this->steps_data['CREATE_MANIFEST']['NAME'] = __('Creates manifest file', 'backwpup'); $this->steps_data['CREATE_MANIFEST']['STEP_TRY'] = 0; $this->steps_data['CREATE_MANIFEST']['SAVE_STEP_TRY'] = 0; //Add archive creation and backup filename on backup type archive if ($this->job['backuptype'] == 'archive') { //get Backup folder if destination folder set if (in_array('FOLDER', $this->job['destinations'], true)) { $this->backup_folder = $this->job['backupdir']; //check backup folder if (!empty($this->backup_folder)) { $this->backup_folder = BackWPup_File::get_absolute_path($this->backup_folder); $this->job['backupdir'] = $this->backup_folder; } } //set temp folder to backup folder if not set because we need one if (!$this->backup_folder || $this->backup_folder == '/') { $this->backup_folder = BackWPup::get_plugin_data('TEMP'); } //Create backup archive full file name $this->backup_file = $this->generate_filename($this->job['archivename'], $this->job['archiveformat']); //add archive create $this->steps_todo[] = 'CREATE_ARCHIVE'; $this->steps_data['CREATE_ARCHIVE']['NAME'] = __('Creates archive', 'backwpup'); $this->steps_data['CREATE_ARCHIVE']['STEP_TRY'] = 0; $this->steps_data['CREATE_ARCHIVE']['SAVE_STEP_TRY'] = 0; } //ADD Destinations /* @var BackWPup_Destinations $dest_class */ foreach (BackWPup::get_registered_destinations() as $id => $dest) { if (!in_array($id, $this->job['destinations'], true) || empty($dest['class'])) { continue; } $dest_class = BackWPup::get_destination($id); if ($dest_class->can_run($this->job)) { if ($this->job['backuptype'] == 'sync') { if ($dest['can_sync']) { $this->steps_todo[] = 'DEST_SYNC_' . $id; $this->steps_data['DEST_SYNC_' . $id]['NAME'] = $dest['info']['description']; $this->steps_data['DEST_SYNC_' . $id]['STEP_TRY'] = 0; $this->steps_data['DEST_SYNC_' . $id]['SAVE_STEP_TRY'] = 0; } } else { $this->steps_todo[] = 'DEST_' . $id; $this->steps_data['DEST_' . $id]['NAME'] = $dest['info']['description']; $this->steps_data['DEST_' . $id]['STEP_TRY'] = 0; $this->steps_data['DEST_' . $id]['SAVE_STEP_TRY'] = 0; } } } } //ADD Job type no file if ($job_types = BackWPup::get_job_types()) { foreach ($job_types as $id => $job_type_class) { if (in_array($id, $this->job['type'], true) && !$job_type_class->creates_file()) { $this->steps_todo[] = 'JOB_' . $id; $this->steps_data['JOB_' . $id]['NAME'] = $job_type_class->info['description']; $this->steps_data['JOB_' . $id]['STEP_TRY'] = 0; $this->steps_data['JOB_' . $id]['SAVE_STEP_TRY'] = 0; } } } $this->steps_todo[] = 'END'; $this->steps_data['END']['NAME'] = __('End of Job', 'backwpup'); $this->steps_data['END']['STEP_TRY'] = 1; //must write working data $this->write_running_file(); //set log level $this->log_level = get_site_option('backwpup_cfg_loglevel', 'normal_translated'); if (!in_array($this->log_level, array('normal_translated', 'normal', 'debug_translated', 'debug'), true)) { $this->log_level = 'normal_translated'; } //create log file $head = ''; $info = ''; $head .= "<!DOCTYPE html>" . PHP_EOL; $head .= "<html lang=\"" . str_replace('_', '-', get_locale()) . "\">" . PHP_EOL; $head .= "<head>" . PHP_EOL; $head .= "<meta charset=\"" . get_bloginfo('charset') . "\" />" . PHP_EOL; $head .= "<title>" . sprintf(__('BackWPup log for %1$s from %2$s at %3$s', 'backwpup'), $this->job['name'], date_i18n(get_option('date_format')), date_i18n(get_option('time_format'))) . "</title>" . PHP_EOL; $head .= "<meta name=\"robots\" content=\"noindex, nofollow\" />" . PHP_EOL; $head .= "<meta name=\"copyright\" content=\"Copyright © 2012 - " . date('Y') . " Inpsyde GmbH\" />" . PHP_EOL; $head .= "<meta name=\"author\" content=\"Inpsyde GmbH\" />" . PHP_EOL; $head .= "<meta name=\"generator\" content=\"BackWPup " . BackWPup::get_plugin_data('Version') . "\" />" . PHP_EOL; $head .= "<meta http-equiv=\"cache-control\" content=\"no-cache\" />" . PHP_EOL; $head .= "<meta http-equiv=\"pragma\" content=\"no-cache\" />" . PHP_EOL; $head .= "<meta name=\"date\" content=\"" . date('c') . "\" />" . PHP_EOL; $head .= str_pad('<meta name="backwpup_errors" content="0" />', 100) . PHP_EOL; $head .= str_pad('<meta name="backwpup_warnings" content="0" />', 100) . PHP_EOL; $head .= "<meta name=\"backwpup_jobid\" content=\"" . $this->job['jobid'] . "\" />" . PHP_EOL; $head .= "<meta name=\"backwpup_jobname\" content=\"" . esc_attr($this->job['name']) . "\" />" . PHP_EOL; $head .= "<meta name=\"backwpup_jobtype\" content=\"" . implode('+', $this->job['type']) . "\" />" . PHP_EOL; $head .= str_pad('<meta name="backwpup_backupfilesize" content="0" />', 100) . PHP_EOL; $head .= str_pad('<meta name="backwpup_jobruntime" content="0" />', 100) . PHP_EOL; $head .= '</head>' . PHP_EOL; $head .= '<body style="margin:0;padding:3px;font-family:monospace;font-size:12px;line-height:15px;background-color:black;color:#c0c0c0;white-space:nowrap;">' . PHP_EOL; $info .= sprintf(_x('[INFO] %1$s %2$s; A project of Inpsyde GmbH', 'Plugin name; Plugin Version; plugin url', 'backwpup'), BackWPup::get_plugin_data('name'), BackWPup::get_plugin_data('Version'), __('http://backwpup.com', 'backwpup')) . '<br />' . PHP_EOL; $info .= sprintf(_x('[INFO] WordPress %1$s on %2$s', 'WordPress Version; Blog url', 'backwpup'), BackWPup::get_plugin_data('wp_version'), esc_attr(site_url('/'))) . '<br />' . PHP_EOL; $level = __('Normal', 'backwpup'); $translated = ''; if ($this->is_debug()) { $level = __('Debug', 'backwpup'); } if (is_textdomain_loaded('backwpup')) { $translated = __('(translated)', 'backwpup'); } $info .= sprintf(__('[INFO] Log Level: %1$s %2$s', 'backwpup'), $level, $translated) . '<br />' . PHP_EOL; $job_name = esc_attr($this->job['name']); if ($this->is_debug()) { $job_name .= '; ' . implode('+', $this->job['type']); } $info .= sprintf(__('[INFO] BackWPup job: %1$s', 'backwpup'), $job_name) . '<br />' . PHP_EOL; if ($this->is_debug()) { $current_user = wp_get_current_user(); $info .= sprintf(__('[INFO] Runs with user: %1$s (%2$d) ', 'backwpup'), $current_user->user_login, $current_user->ID) . '<br />' . PHP_EOL; } if ($this->job['activetype'] === 'wpcron') { //check next run $cron_next = wp_next_scheduled('backwpup_cron', array('id' => $this->job['jobid'])); if (!$cron_next || $cron_next < time()) { wp_unschedule_event($cron_next, 'backwpup_cron', array('id' => $this->job['jobid'])); $cron_next = BackWPup_Cron::cron_next($this->job['cron']); wp_schedule_single_event($cron_next, 'backwpup_cron', array('id' => $this->job['jobid'])); $cron_next = wp_next_scheduled('backwpup_cron', array('id' => $this->job['jobid'])); } //output scheduling if ($this->is_debug()) { if (!$cron_next) { $cron_next = __('Not scheduled!', 'backwpup'); } else { $cron_next = date_i18n('D, j M Y @ H:i', $cron_next + get_option('gmt_offset') * 3600, true); } $info .= sprintf(__('[INFO] Cron: %s; Next: %s ', 'backwpup'), $this->job['cron'], $cron_next) . '<br />' . PHP_EOL; } } elseif ($this->job['activetype'] == 'link' && $this->is_debug()) { $info .= __('[INFO] BackWPup job start with link is active', 'backwpup') . '<br />' . PHP_EOL; } elseif ($this->job['activetype'] == 'easycron' && $this->is_debug()) { $info .= __('[INFO] BackWPup job start with EasyCron.com', 'backwpup') . '<br />' . PHP_EOL; //output scheduling if ($this->is_debug()) { $cron_next = BackWPup_Cron::cron_next($this->job['cron']); $cron_next = date_i18n('D, j M Y @ H:i', $cron_next + get_option('gmt_offset') * 3600, true); $info .= sprintf(__('[INFO] Cron: %s; Next: %s ', 'backwpup'), $this->job['cron'], $cron_next) . '<br />' . PHP_EOL; } } elseif ($this->is_debug()) { $info .= __('[INFO] BackWPup no automatic job start configured', 'backwpup') . '<br />' . PHP_EOL; } if ($this->is_debug()) { if ($start_type == 'cronrun') { $info .= __('[INFO] BackWPup job started from wp-cron', 'backwpup') . '<br />' . PHP_EOL; } elseif ($start_type == 'runnow' || $start_type == 'runnowalt') { $info .= __('[INFO] BackWPup job started manually', 'backwpup') . '<br />' . PHP_EOL; } elseif ($start_type == 'runext') { $info .= __('[INFO] BackWPup job started from external url', 'backwpup') . '<br />' . PHP_EOL; } elseif ($start_type == 'runcli') { $info .= __('[INFO] BackWPup job started form commandline interface', 'backwpup') . '<br />' . PHP_EOL; } $bit = ''; if (PHP_INT_SIZE === 4) { $bit = ' (32bit)'; } if (PHP_INT_SIZE === 8) { $bit = ' (64bit)'; } $info .= __('[INFO] PHP ver.:', 'backwpup') . ' ' . PHP_VERSION . $bit . '; ' . PHP_SAPI . '; ' . PHP_OS . '<br />' . PHP_EOL; $info .= sprintf(__('[INFO] Maximum PHP script execution time is %1$d seconds', 'backwpup'), ini_get('max_execution_time')) . '<br />' . PHP_EOL; if (php_sapi_name() != 'cli') { $job_max_execution_time = get_site_option('backwpup_cfg_jobmaxexecutiontime'); if (!empty($job_max_execution_time)) { $info .= sprintf(__('[INFO] Script restart time is configured to %1$d seconds', 'backwpup'), $job_max_execution_time) . '<br />' . PHP_EOL; } } $info .= sprintf(__('[INFO] MySQL ver.: %s', 'backwpup'), $wpdb->get_var("SELECT VERSION() AS version")) . '<br />' . PHP_EOL; if (isset($_SERVER['SERVER_SOFTWARE'])) { $info .= sprintf(__('[INFO] Web Server: %s', 'backwpup'), $_SERVER['SERVER_SOFTWARE']) . '<br />' . PHP_EOL; } if (function_exists('curl_init')) { $curlversion = curl_version(); $info .= sprintf(__('[INFO] curl ver.: %1$s; %2$s', 'backwpup'), $curlversion['version'], $curlversion['ssl_version']) . '<br />' . PHP_EOL; } $info .= sprintf(__('[INFO] Temp folder is: %s', 'backwpup'), BackWPup::get_plugin_data('TEMP')) . '<br />' . PHP_EOL; } if ($this->is_debug()) { $logfile = $this->logfile; } else { $logfile = basename($this->logfile); } $info .= sprintf(__('[INFO] Logfile is: %s', 'backwpup'), $logfile) . '<br />' . PHP_EOL; if (!empty($this->backup_file) && $this->job['backuptype'] === 'archive') { if ($this->is_debug()) { $backupfile = $this->backup_folder . $this->backup_file; } else { $backupfile = $this->backup_file; } $info .= sprintf(__('[INFO] Backup file is: %s', 'backwpup'), $backupfile) . '<br />' . PHP_EOL; } else { $info .= sprintf(__('[INFO] Backup type is: %s', 'backwpup'), $this->job['backuptype']) . '<br />' . PHP_EOL; } //output info on cli if (php_sapi_name() == 'cli' && defined('STDOUT')) { fwrite(STDOUT, strip_tags($info)); } if (!file_put_contents($this->logfile, $head . $info, FILE_APPEND)) { $this->logfile = ''; $this->log(__('Could not write log file', 'backwpup'), E_USER_ERROR); } //test for destinations if ($job_need_dest) { $desttest = false; foreach ($this->steps_todo as $deststeptest) { if (substr($deststeptest, 0, 5) == 'DEST_') { $desttest = true; break; } } if (!$desttest) { $this->log(__('No destination correctly defined for backup! Please correct job settings.', 'backwpup'), E_USER_ERROR); $this->steps_todo = array('END'); } } //test backup folder if (!empty($this->backup_folder)) { $folder_message = BackWPup_File::check_folder($this->backup_folder, true); if (!empty($folder_message)) { $this->log($folder_message, E_USER_ERROR); $this->steps_todo = array('END'); } } //Set start as done $this->steps_done[] = 'CREATE'; }
/** * Load Plugin Translation * * @return bool Text domain loaded */ public static function load_text_domain() { if (is_textdomain_loaded('backwpup')) { return TRUE; } return load_plugin_textdomain('backwpup', false, dirname(plugin_basename(__FILE__)) . '/languages'); }
/** * A Helper method to load text domain * First it tries to load the wp-content/languages translation then if falls to the * try to load $dir language files * * @param string $domain The text domain that will be loaded * @param string $dir What directory should be used to try to load if the default doenst work * * @return bool If it was able to load the text domain */ public function load_text_domain($domain, $dir = false) { // Added safety just in case this runs twice... if (is_textdomain_loaded($domain) && !is_a($GLOBALS['l10n'][$domain], 'NOOP_Translations')) { return true; } $locale = get_locale(); $mofile = WP_LANG_DIR . '/plugins/' . $domain . '-' . $locale . '.mo'; /** * Allows users to filter which file will be loaded for a given text domain * Be careful when using this filter, it will apply across the whole plugin suite. * * @param string $mofile The path for the .mo File * @param string $domain Which plugin domain we are trying to load * @param string $locale Which Language we will load * @param string|bool $dir If there was a custom directory passed on the method call */ $mofile = apply_filters('tribe_load_text_domain', $mofile, $domain, $locale, $dir); $loaded = load_plugin_textdomain($domain, false, $mofile); if ($dir !== false && !$loaded) { return load_plugin_textdomain($domain, false, $dir); } return $loaded; }
/** * Load textdomain for internationalization. * * @since 1.0 * @access public * * @uses is_textdomain_loaded() To check if translation is loaded. * @uses load_plugin_textdomain() To load translation file. * @uses plugin_basename() To get plugin's file name. */ public function load_textdomain() { /* If translation isn't loaded, load it */ if (!is_textdomain_loaded('nmi')) { load_plugin_textdomain('nmi', false, dirname(plugin_basename(__FILE__)) . '/languages'); } }
/** * @ticket 37113 */ public function test_should_allow_unloading_of_text_domain() { add_filter('locale', array($this, 'filter_set_locale_to_german')); require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php'; $expected_output_before = i18n_plugin_test(); $is_textdomain_loaded_before = is_textdomain_loaded('internationalized-plugin'); unload_textdomain('internationalized-plugin'); remove_filter('locale', array($this, 'filter_set_locale_to_german')); $expected_output_after = i18n_plugin_test(); $is_textdomain_loaded_after = is_textdomain_loaded('internationalized-plugin'); add_filter('locale', array($this, 'filter_set_locale_to_german')); load_textdomain('internationalized-plugin', WP_LANG_DIR . '/plugins/internationalized-plugin-de_DE.mo'); $expected_output_final = i18n_plugin_test(); $is_textdomain_loaded_final = is_textdomain_loaded('internationalized-plugin'); unload_textdomain('internationalized-plugin'); remove_filter('locale', array($this, 'filter_set_locale_to_german')); // Text domain loaded just in time. $this->assertSame('Das ist ein Dummy Plugin', $expected_output_before); $this->assertTrue($is_textdomain_loaded_before); // Text domain unloaded. $this->assertSame('This is a dummy plugin', $expected_output_after); $this->assertFalse($is_textdomain_loaded_after); // Text domain loaded manually again. $this->assertSame('Das ist ein Dummy Plugin', $expected_output_final); $this->assertTrue($is_textdomain_loaded_final); }
/** * Filters 'gettext' to change the translations used for the each of the extensions' textdomains. This filter * makes it possible for the theme's MO file to translate the framework's extensions. * * @since 1.3.0 * @access private * @param string $translated The translated text. * @param string $text The original, untranslated text. * @param string $domain The textdomain for the text. * @return string $translated */ function hybrid_extensions_gettext($translated, $text, $domain) { /* Check if the current textdomain matches one of the framework extensions. */ if (in_array($domain, array('breadcrumb-trail', 'custom-field-series', 'post-stylesheets', 'theme-layouts'))) { /* If the theme supports the extension, switch the translations. */ if (current_theme_supports($domain)) { /* If the framework mofile is loaded, use its translations. */ if (is_textdomain_loaded('hybrid-core')) { $translations =& get_translations_for_domain('hybrid-core'); } elseif (is_textdomain_loaded(hybrid_get_parent_textdomain())) { $translations =& get_translations_for_domain(hybrid_get_parent_textdomain()); } /* If translations were found, translate the text. */ if (!empty($translations)) { $translated = $translations->translate($text); } } } return $translated; }
/** * Load translations. * * @since 2.6.0 * * (@internal Uses `load_theme_textdomain()` rather than `load_plugin_textdomain()` to * get round the different ways of handling the path and deprecated notices being thrown * and such. For plugins, the actual file name will be corrected by a filter.}} * * {@internal IMPORTANT! If this function changes, review the regex in the custom TGMPA * generator on the website.}} */ public function load_textdomain() { if (is_textdomain_loaded('tgmpa')) { return; } if (false !== strpos(__FILE__, WP_PLUGIN_DIR) || false !== strpos(__FILE__, WPMU_PLUGIN_DIR)) { // Plugin, we'll need to adjust the file name. add_action('load_textdomain_mofile', array($this, 'correct_plugin_mofile'), 10, 2); load_theme_textdomain('tgmpa', dirname(__FILE__) . '/languages'); remove_action('load_textdomain_mofile', array($this, 'correct_plugin_mofile'), 10); } else { load_theme_textdomain('tgmpa', dirname(__FILE__) . '/languages'); } }
function test_override_load_textdomain_custom_mofile() { add_filter('override_load_textdomain', array($this, '_override_load_textdomain_filter'), 10, 3); $load_textdomain = load_textdomain('wp-tests-domain', WP_LANG_DIR . '/plugins/internationalized-plugin-de_DE.mo'); remove_filter('override_load_textdomain', array($this, '_override_load_textdomain_filter')); $is_textdomain_loaded = is_textdomain_loaded('wp-tests-domain'); unload_textdomain('wp-tests-domain'); $is_textdomain_loaded_after = is_textdomain_loaded('wp-tests-domain'); $this->assertTrue($load_textdomain); $this->assertTrue($is_textdomain_loaded); $this->assertFalse($is_textdomain_loaded_after); }
/** * @param int $jobid */ public static function start_wp_cron($jobid = 0) { if (!defined('DOING_CRON') || !DOING_CRON) { return; } //load text domain if needed if (!is_textdomain_loaded('backwpup') && !get_site_option('backwpup_cfg_jobnotranslate')) { load_plugin_textdomain('backwpup', FALSE, BackWPup::get_plugin_data('BaseName') . '/languages'); } if (!empty($jobid)) { //check folders if (!self::check_folder(get_site_option('backwpup_cfg_logfolder')) || !self::check_folder(BackWPup::get_plugin_data('TEMP'), TRUE)) { return; } } // Should be preventing doubled running job's on http requests $random = rand(1, 9) * 100000; usleep($random); //get running job $backwpup_job_object = self::get_working_data(); //start/restart class if (empty($backwpup_job_object) && !empty($jobid)) { //schedule restart event wp_schedule_single_event(time() + 60, 'backwpup_cron', array('id' => 'restart')); //start job $backwpup_job_object = new self(); $backwpup_job_object->create('cronrun', (int) $jobid); } if (is_object($backwpup_job_object) && $backwpup_job_object instanceof BackWPup_Job) { $backwpup_job_object->run(); } }
/** * Hook to insert the report user on BP blog post and activity * * @global type $l10n * @global type $post * @param type $id * @param type $type */ function wangguard_bp_report_button($id = '', $type = '') { if (!is_user_logged_in()) { return; } if (!$type && !is_single()) { $type = 'activity'; } elseif (!$type && is_single()) { $type = 'blogpost'; } if (function_exists("is_textdomain_loaded")) { if (!is_textdomain_loaded("wangguard")) { load_textdomain("wangguard", PLUGINDIR . "/wangguard/languages/wangguard-" . WPLANG . ".mo"); } } else { global $l10n; if (!isset($l10n['wangguard'])) { load_textdomain("wangguard", PLUGINDIR . " /wangguard/languages/wangguard-" . WPLANG . ".mo"); } } if ($type == 'activity') { $activity = bp_activity_get_specific(array('activity_ids' => bp_get_activity_id())); if (!empty($activity['activities'][0])) { $user_id = $activity['activities'][0]->user_id; $user_object = new WP_User($user_id); if (empty($user_object->ID)) { return; } if (!wangguard_is_admin($user_object)) { if (true || !bp_like_is_liked(bp_get_activity_id(), 'activity')) { ?> <a href="javascript:void(0)" class="button wangguard-user-report" rel="<?php echo $user_object->ID; ?> " title="<?php echo __('Report user', 'wangguard'); ?> "><?php echo __('Report user', 'wangguard'); ?> </a> <?php } } } } elseif ($type == 'blogpost') { global $post; if (empty($post->post_author)) { return; } $user_id = $post->post_author; $user_object = new WP_User($user_id); if (empty($user_object->ID)) { return; } if (!wangguard_is_admin($user_object)) { if (true || !bp_like_is_liked($id, 'blogpost')) { ?> <div class="activity-list"><div class="activity-meta"><a href="javascript:void(0)" class="button wangguard-user-report" rel="<?php echo $user_object->ID; ?> " title="<?php echo __('Report user', 'wangguard'); ?> "><?php echo __('Report user', 'wangguard'); ?> </a></div></div> <?php } } } }
/** * Load Plugin Translation */ public static function load_text_domain() { $domain = 'backwpup'; if (is_textdomain_loaded($domain)) { return; } $locale = apply_filters('plugin_locale', get_locale(), $domain); $mofile = $domain . '-' . $locale . '.mo'; // load translation from WordPress plugins language folder if (load_textdomain($domain, WP_LANG_DIR . '/plugins/' . $mofile)) { return; } // load translation from plugin folder load_textdomain($domain, dirname(__FILE__) . '/languages/' . $mofile); }
/** * Try to get translation details from cache, otherwise retrieve them, then parse them. * * @access private */ private function translation_details() { $set = $this->find_or_initialize_translation_details(); $this->translation_exists = !is_null($set); $this->translation_loaded = is_textdomain_loaded($this->textdomain); $this->parse_translation_set($set); }
/** * Sanitizes plugin data, optionally adds markup, optionally translates. * * @since 2.7.0 * @access private * @see get_plugin_data() */ function _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup = true, $translate = true) { // Sanitize the plugin filename to a WP_PLUGIN_DIR relative path $plugin_file = plugin_basename($plugin_file); // Translate fields if ($translate) { if ($textdomain = $plugin_data['TextDomain']) { if (!is_textdomain_loaded($textdomain)) { if ($plugin_data['DomainPath']) { load_plugin_textdomain($textdomain, false, dirname($plugin_file) . $plugin_data['DomainPath']); } else { load_plugin_textdomain($textdomain, false, dirname($plugin_file)); } } } elseif ('hello.php' == basename($plugin_file)) { $textdomain = 'default'; } if ($textdomain) { foreach (array('Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version') as $field) { $plugin_data[$field] = translate($plugin_data[$field], $textdomain); } } } // Sanitize fields $allowed_tags = $allowed_tags_in_links = array('abbr' => array('title' => true), 'acronym' => array('title' => true), 'code' => true, 'em' => true, 'strong' => true); $allowed_tags['a'] = array('href' => true, 'title' => true); // Name is marked up inside <a> tags. Don't allow these. // Author is too, but some plugins have used <a> here (omitting Author URI). $plugin_data['Name'] = wp_kses($plugin_data['Name'], $allowed_tags_in_links); $plugin_data['Author'] = wp_kses($plugin_data['Author'], $allowed_tags); $plugin_data['Description'] = wp_kses($plugin_data['Description'], $allowed_tags); $plugin_data['Version'] = wp_kses($plugin_data['Version'], $allowed_tags); $plugin_data['PluginURI'] = esc_url($plugin_data['PluginURI']); $plugin_data['AuthorURI'] = esc_url($plugin_data['AuthorURI']); $plugin_data['Title'] = $plugin_data['Name']; $plugin_data['AuthorName'] = $plugin_data['Author']; // Apply markup if ($markup) { if ($plugin_data['PluginURI'] && $plugin_data['Name']) { $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '">' . $plugin_data['Name'] . '</a>'; } if ($plugin_data['AuthorURI'] && $plugin_data['Author']) { $plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>'; } $plugin_data['Description'] = wptexturize($plugin_data['Description']); if ($plugin_data['Author']) { $plugin_data['Description'] .= ' <cite>' . sprintf(__('By %s.'), $plugin_data['Author']) . '</cite>'; } } return $plugin_data; }
function test_plugin_load_textdomain() { add_filter('locale', array($this, '_set_locale_to_hebrew')); $this->plugin->load_plugin_textdomain(); $this->assertTrue(is_textdomain_loaded('wp-tutorial-maker')); }
/** * Whether or not the language has been loaded already. * * @since 0.3.0 * @access public * @return bool */ public function is_loaded() { return is_textdomain_loaded($this->text_domain); }
/** * Loads the theme's textdomain. * * Translation files are not inherited from the parent theme. Todo: if this fails for the * child theme, it should probably try to load the parent theme's translations. * * @since 3.4.0 * @access public * * @return True if the textdomain was successfully loaded or has already been loaded. False if * no textdomain was specified in the file headers, or if the domain could not be loaded. */ public function load_textdomain() { if (isset($this->textdomain_loaded)) { return $this->textdomain_loaded; } $textdomain = $this->get('TextDomain'); if (!$textdomain) { $this->textdomain_loaded = false; return false; } if (is_textdomain_loaded($textdomain)) { $this->textdomain_loaded = true; return true; } $path = $this->get_stylesheet_directory(); if ($domainpath = $this->get('DomainPath')) { $path .= $domainpath; } $this->textdomain_loaded = load_theme_textdomain($textdomain, $path); return $this->textdomain_loaded; }
/** * Load textdomain for internationalization. * * @since 1.0 * @access public * * @uses is_textdomain_loaded() To check if translation is loaded. * @uses load_plugin_textdomain() To load translation file. */ public function load_textdomain() { /* If translation isn't loaded, load it */ if (!is_textdomain_loaded('nav-menu-images')) { load_plugin_textdomain('nav-menu-images', false, dirname($this->plugin_basename) . '/languages'); } }