PATH:
var
/
www
/
clients
/
client1
/
web1
/
web
/
wp-content
/
sitepress-multilingual-cms
/
classes
<?php /** * Class for handling a unique ID of the site. * * @author OnTheGo Systems */ class WPML_Site_ID { /** * The name prefix of the option where the ID is stored. */ const SITE_ID_KEY = 'WPML_SITE_ID'; /** * The default scope. */ const SITE_SCOPES_GLOBAL = 'global'; /** * Memory cache of the IDs. * * @var array */ private $site_ids = array(); /** * Read and, if needed, generate the site ID based on the scope. * * @param string $scope Defaults to "global". * Use a different value when the ID is used for specific scopes. * * @param bool $create_new Forces the creation of a new ID. * * @return string|null The generated/stored ID or null if it wasn't possible to generate/store the value. */ public function get_site_id( $scope = self::SITE_SCOPES_GLOBAL, $create_new = false ) { $generate = ! $this->read_value( $scope ) || $create_new; if ( $generate && ! $this->generate_site_id( $scope ) ) { return null; } return $this->get_from_cache( $scope ); } /** * Geenrates the ID. * * @param string $scope The scope of the ID. * * @return bool */ private function generate_site_id( $scope ) { $site_url = get_site_url(); $site_uuid = uuid_v5( $site_url, wp_generate_uuid4() ); $time_uuid = uuid_v5( time(), wp_generate_uuid4() ); return $this->write_value( uuid_v5( $site_uuid, $time_uuid ), $scope ); } /** * Read the value from cache, if present, or from the DB. * * @param string $scope The scope of the ID. * * @return string */ private function read_value( $scope ) { if ( ! $this->get_from_cache( $scope ) ) { $this->site_ids[ $scope ] = get_option( $this->get_option_key( $scope ), null ); } return $this->site_ids[ $scope ]; } /** * Writes the value in DB and cache. * * @param string $value The value to write. * @param string $scope The scope of the ID. * * @return bool */ private function write_value( $value, $scope ) { if ( update_option( $this->get_option_key( $scope ), $value, false ) ) { $this->site_ids[ $scope ] = $value; return true; } return false; } /** * Gets the options key name based on the scope. * * @param string $scope The scope of the ID. * * @return string */ private function get_option_key( $scope ) { return self::SITE_ID_KEY . ':' . $scope; } /** * Gets the value from the memory cache. * * @param string $scope The scope of the ID. * * @return mixed|null */ private function get_from_cache( $scope ) { if ( array_key_exists( $scope, $this->site_ids ) && $this->site_ids[ $scope ] ) { return $this->site_ids[ $scope ]; } return null; } }
[+]
wpml-wp
[+]
ajax
[-] class-wpml-tm-translators-dropdown.php
[edit]
[+]
translation-priorities
[-] class-wpml-tm-promotions.php
[edit]
[+]
hooks
[+]
ICL-20-migration
[+]
templates
[+]
action-filter-loader
[-] class-wpml-translation-proxy-api.php
[edit]
[+]
wpml-st
[+]
utilities
[-] class-wpml-tm-translated-field.php
[edit]
[+]
requirements
[+]
sticky-posts
[-] class-wpml-tm-page.php
[edit]
[+]
icl
[+]
display-as-translated
[+]
custom-field-translation
[+]
language
[+]
ATE
[+]
shortcodes
[+]
translate_link_targets
[+]
core-abstract-classes
[+]
full-site-editing
[+]
settings
[-] class-wpml-file.php
[edit]
[+]
xliff
[+]
reset
[+]
REST-hooks
[+]
comments
[+]
plugins
[+]
templating
[+]
container
[+]
taxonomy
[+]
cookie
[-] class-wpml-tm-requirements.php
[edit]
[+]
translation-dashboard
[+]
helpers
[+]
translation-feedback
[+]
admin-language-switcher
[-] class-wpml-tm-troubleshooting-clear-ts.php
[edit]
[+]
jobs
[+]
compatibility
[+]
wp-core-hooks
[+]
post-edit-screen
[-] class-wpml-tm-troubleshooting-clear-ts-ui.php
[edit]
[+]
translation-jobs
[+]
logging
[+]
roles
[+]
media
[-] class-wpml-active-plugin-provider.php
[edit]
[+]
media-translation
[-] class-wpml-config-update.php
[edit]
[+]
seo
[+]
options
[+]
Installer
[-] class-wpml-tm-ajax-factory-2.php
[edit]
[+]
automatic-translation
[+]
troubleshoot
[+]
records
[-] class-wpml-translate-independently.php
[edit]
[+]
abstract
[-] class-wpml-tm-resources-factory.php
[edit]
[+]
post-types
[+]
wp-cli
[+]
translation-proxy
[-] class-wpml-tm-loader.php
[edit]
[-] class-wpml-config-update-integrator.php
[edit]
[-] class-wpml-theme-localization-type.php
[edit]
[+]
taxonomy-term-translation
[+]
setup
[+]
language-switcher
[+]
translation-mode
[+]
jobs-deadline
[+]
database-queries
[+]
utils
[+]
translation-basket
[-] ISitePress.php
[edit]
[-] class-wpml-current-screen.php
[edit]
[-] class-wpml-tm-ajax-factory.php
[edit]
[+]
admin-bar
[+]
canonicals
[+]
custom-xml-config
[-] class-wpml-db-chunk.php
[edit]
[+]
url-handling
[+]
admin-resources
[+]
theme-plugin-localization
[+]
ui-elements
[+]
languages
[+]
wizard
[-] LanguageNegotiation.php
[edit]
[-] class-wpml-browser-redirect.php
[edit]
[+]
menu
[-] class-wpml-mo-file-search.php
[edit]
[+]
query-filtering
[+]
translation-management
[+]
filters
[-] class-wpml-xmlrpc.php
[edit]
[-] class-wpml-site-id.php
[edit]
[+]
block-editor
[+]
icl-to-ate-migration
[+]
translations
[+]
user-language
[+]
..
[+]
menu-elements
[+]
translation-batch
[-] class-wpml-tm-api.php
[edit]
[-] class-wpml-translation-management.php
[edit]
[-] class-wpml-translation-job-factory.php
[edit]
[+]
xml-config
[+]
REST
[+]
editor
[+]
admin-menu
[+]
localization
[+]
tp-client
[+]
translation-roles
[-] Geolocalization.php
[edit]
[+]
wp
[+]
API
[+]
twig-extensions
[+]
troubleshooting
[+]
privacy
[+]
user
[-] class-wpml-tm-service-activation-ajax.php
[edit]
[+]
widgets
[+]
super-globals
[+]
emails
[+]
words-count
[+]
support
[+]
post-translation
[+]
browser-language-redirect
[+]
request-handling
[+]
notices
[+]
upgrade