| @@ -1,18 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * Initializes plugin | |
| 4 | - * | |
| 5 | - * @package WP_Stream; | |
| 6 | - */ | |
| 7 | - | |
| 8 | 2 | namespace WP_Stream; |
| 9 | 3 | |
| 10 | -use RuntimeException; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * Class Plugin | |
| 14 | - */ | |
| 15 | 4 | class Plugin { |
| 16 | 5 | /** |
| 17 | 6 | * Plugin version number. |
| 18 | 7 | * |
| @@ -19,9 +8,9 @@ | ||
| 19 | 8 | * TODO Maybe pass this as a constructor dependency? |
| 20 | 9 | * |
| 21 | 10 | * @const string |
| 22 | 11 | */ |
| 23 | - const VERSION = '4.2.1'; | |
| 12 | + const VERSION = '3.4.2'; | |
| 24 | 13 | |
| 25 | 14 | /** |
| 26 | 15 | * WP-CLI command |
| 27 | 16 | * |
| @@ -28,89 +17,44 @@ | ||
| 28 | 17 | * @const string |
| 29 | 18 | */ |
| 30 | 19 | const WP_CLI_COMMAND = 'stream'; |
| 31 | 20 | |
| 32 | - | |
| 33 | 21 | /** |
| 34 | - * Used to check if it's a single site, not multisite. | |
| 35 | - * | |
| 36 | - * @const string | |
| 37 | - */ | |
| 38 | - const SINGLE_SITE = 'single'; | |
| 39 | - | |
| 40 | - /** | |
| 41 | - * Used to check if it's a multisite with the plugin network enabled. | |
| 42 | - * | |
| 43 | - * @const string | |
| 44 | - */ | |
| 45 | - const MULTI_NETWORK = 'multisite-network'; | |
| 46 | - | |
| 47 | - /** | |
| 48 | - * Used to check if it's a multisite with the plugin not network enabled. | |
| 49 | - * | |
| 50 | - * @const string | |
| 51 | - */ | |
| 52 | - const MULTI_NOT_NETWORK = 'multisite-not-network'; | |
| 53 | - | |
| 54 | - /** | |
| 55 | - * Holds and manages WordPress Admin configurations. | |
| 56 | - * | |
| 57 | 22 | * @var Admin |
| 58 | 23 | */ |
| 59 | 24 | public $admin; |
| 60 | 25 | |
| 61 | 26 | /** |
| 62 | - * Holds and manages alerts. | |
| 63 | - * | |
| 64 | 27 | * @var Alerts |
| 65 | 28 | */ |
| 66 | 29 | public $alerts; |
| 67 | 30 | |
| 68 | 31 | /** |
| 69 | - * Holds and manages alerts lists. | |
| 70 | - * | |
| 71 | 32 | * @var Alerts_List |
| 72 | 33 | */ |
| 73 | 34 | public $alerts_list; |
| 74 | 35 | |
| 75 | 36 | /** |
| 76 | - * Holds and manages WordPress Abilities API integration. | |
| 77 | - * | |
| 78 | - * @var Abilities | |
| 79 | - */ | |
| 80 | - public $abilities; | |
| 81 | - | |
| 82 | - /** | |
| 83 | - * Holds and manages connectors | |
| 84 | - * | |
| 85 | 37 | * @var Connectors |
| 86 | 38 | */ |
| 87 | 39 | public $connectors; |
| 88 | 40 | |
| 89 | 41 | /** |
| 90 | - * Holds and manages DB connections. | |
| 91 | - * | |
| 92 | 42 | * @var DB |
| 93 | 43 | */ |
| 94 | 44 | public $db; |
| 95 | 45 | |
| 96 | 46 | /** |
| 97 | - * Holds and manages records. | |
| 98 | - * | |
| 99 | 47 | * @var Log |
| 100 | 48 | */ |
| 101 | 49 | public $log; |
| 102 | 50 | |
| 103 | 51 | /** |
| 104 | - * Stores and manages WordPress settings. | |
| 105 | - * | |
| 106 | 52 | * @var Settings |
| 107 | 53 | */ |
| 108 | 54 | public $settings; |
| 109 | 55 | |
| 110 | 56 | /** |
| 111 | - * Process DB migrations. | |
| 112 | - * | |
| 113 | 57 | * @var Install |
| 114 | 58 | */ |
| 115 | 59 | public $install; |
| 116 | 60 | |
| @@ -121,15 +65,8 @@ | ||
| 121 | 65 | */ |
| 122 | 66 | public $locations = array(); |
| 123 | 67 | |
| 124 | 68 | /** |
| 125 | - * IP address for the current request to be associated with the log entry. | |
| 126 | - * | |
| 127 | - * @var null|false|string Valid IP address, null if not set, false if invalid. | |
| 128 | - */ | |
| 129 | - protected $client_ip_address; | |
| 130 | - | |
| 131 | - /** | |
| 132 | 69 | * Class constructor |
| 133 | 70 | */ |
| 134 | 71 | public function __construct() { |
| 135 | 72 | $locate = $this->locate_plugin(); |
| @@ -143,15 +80,12 @@ | ||
| 143 | 80 | ); |
| 144 | 81 | |
| 145 | 82 | spl_autoload_register( array( $this, 'autoload' ) ); |
| 146 | 83 | |
| 147 | - // Load Action Scheduler. | |
| 148 | - require_once $this->locations['dir'] . '/vendor/woocommerce/action-scheduler/action-scheduler.php'; | |
| 149 | - | |
| 150 | - // Load helper functions. | |
| 84 | + // Load helper functions | |
| 151 | 85 | require_once $this->locations['inc_dir'] . 'functions.php'; |
| 152 | 86 | |
| 153 | - // Load DB helper interface/class. | |
| 87 | + // Load DB helper interface/class | |
| 154 | 88 | $driver_class = apply_filters( 'wp_stream_db_driver', '\WP_Stream\DB_Driver_WPDB' ); |
| 155 | 89 | $driver = null; |
| 156 | 90 | |
| 157 | 91 | if ( class_exists( $driver_class ) ) { |
| @@ -172,27 +106,24 @@ | ||
| 172 | 106 | esc_html__( 'Stream DB Error', 'stream' ) |
| 173 | 107 | ); |
| 174 | 108 | } |
| 175 | 109 | |
| 176 | - // Load languages. | |
| 110 | + // Load languages | |
| 177 | 111 | add_action( 'plugins_loaded', array( $this, 'i18n' ) ); |
| 178 | 112 | |
| 179 | - // Load logger class. | |
| 113 | + // Load logger class | |
| 180 | 114 | $this->log = apply_filters( 'wp_stream_log_handler', new Log( $this ) ); |
| 181 | 115 | |
| 182 | - // Set the IP address for the current request. | |
| 183 | - $this->client_ip_address = wp_stream_filter_input( INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP ); | |
| 184 | - | |
| 185 | - // Load settings and connectors after widgets_init and before the default init priority. | |
| 116 | + // Load settings and connectors after widgets_init and before the default init priority | |
| 186 | 117 | add_action( 'init', array( $this, 'init' ), 9 ); |
| 187 | 118 | |
| 188 | - // Add frontend indicator. | |
| 119 | + // Add frontend indicator | |
| 189 | 120 | add_action( 'wp_head', array( $this, 'frontend_indicator' ) ); |
| 190 | 121 | |
| 191 | - // Change DB driver after plugin loaded if any add-ons want to replace. | |
| 122 | + // Change DB driver after plugin loaded if any add-ons want to replace | |
| 192 | 123 | add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ), 20 ); |
| 193 | 124 | |
| 194 | - // Load admin area classes. | |
| 125 | + // Load admin area classes | |
| 195 | 126 | if ( is_admin() || ( defined( 'WP_STREAM_DEV_DEBUG' ) && WP_STREAM_DEV_DEBUG ) || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
| 196 | 127 | $this->admin = new Admin( $this ); |
| 197 | 128 | $this->install = $driver->setup_storage( $this ); |
| 198 | 129 | } elseif ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
| @@ -198,9 +129,9 @@ | ||
| 198 | 129 | } elseif ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
| 199 | 130 | $this->admin = new Admin( $this, $driver ); |
| 200 | 131 | } |
| 201 | 132 | |
| 202 | - // Load WP-CLI command. | |
| 133 | + // Load WP-CLI command | |
| 203 | 134 | if ( defined( 'WP_CLI' ) && WP_CLI ) { |
| 204 | 135 | \WP_CLI::add_command( self::WP_CLI_COMMAND, 'WP_Stream\CLI' ); |
| 205 | 136 | } |
| 206 | 137 | } |
| @@ -207,12 +138,12 @@ | ||
| 207 | 138 | |
| 208 | 139 | /** |
| 209 | 140 | * Autoloader for classes |
| 210 | 141 | * |
| 211 | - * @param string $class_name Fully qualified classname to be loaded. | |
| 142 | + * @param string $class | |
| 212 | 143 | */ |
| 213 | - public function autoload( $class_name ) { | |
| 214 | - if ( ! preg_match( '/^(?P<namespace>.+)\\\\(?P<autoload>[^\\\\]+)$/', $class_name, $matches ) ) { | |
| 144 | + public function autoload( $class ) { | |
| 145 | + if ( ! preg_match( '/^(?P<namespace>.+)\\\\(?P<autoload>[^\\\\]+)$/', $class, $matches ) ) { | |
| 215 | 146 | return; |
| 216 | 147 | } |
| 217 | 148 | |
| 218 | 149 | static $reflection; |
| @@ -242,9 +173,9 @@ | ||
| 242 | 173 | public function i18n() { |
| 243 | 174 | load_plugin_textdomain( 'stream', false, dirname( $this->locations['plugin'] ) . '/languages/' ); |
| 244 | 175 | } |
| 245 | 176 | |
| 246 | - /** | |
| 177 | + /* | |
| 247 | 178 | * Load Settings, Notifications, and Connectors |
| 248 | 179 | * |
| 249 | 180 | * @action init |
| 250 | 181 | */ |
| @@ -252,9 +183,9 @@ | ||
| 252 | 183 | $this->settings = new Settings( $this ); |
| 253 | 184 | $this->connectors = new Connectors( $this ); |
| 254 | 185 | $this->alerts = new Alerts( $this ); |
| 255 | 186 | $this->alerts_list = new Alerts_List( $this ); |
| 256 | - $this->abilities = new Abilities( $this ); | |
| 187 | + | |
| 257 | 188 | } |
| 258 | 189 | |
| 259 | 190 | /** |
| 260 | 191 | * Displays an HTML comment in the frontend head to indicate that Stream is activated, |
| @@ -264,10 +195,9 @@ | ||
| 264 | 195 | * |
| 265 | 196 | * @return string|void An HTML comment, or nothing if the value is filtered out. |
| 266 | 197 | */ |
| 267 | 198 | public function frontend_indicator() { |
| 268 | - /* translators: Localization not needed */ | |
| 269 | - $comment = sprintf( 'Stream WordPress user activity plugin v%s', esc_html( $this->get_version() ) ); | |
| 199 | + $comment = sprintf( 'Stream WordPress user activity plugin v%s', esc_html( $this->get_version() ) ); // Localization not needed | |
| 270 | 200 | |
| 271 | 201 | /** |
| 272 | 202 | * Filter allows the HTML output of the frontend indicator comment |
| 273 | 203 | * to be altered or removed, if desired. |
| @@ -276,9 +206,9 @@ | ||
| 276 | 206 | */ |
| 277 | 207 | $comment = apply_filters( 'wp_stream_frontend_indicator', $comment ); |
| 278 | 208 | |
| 279 | 209 | if ( ! empty( $comment ) ) { |
| 280 | - printf( "<!-- %s -->\n", esc_html( $comment ) ); | |
| 210 | + echo sprintf( "<!-- %s -->\n", esc_html( $comment ) ); // xss ok | |
| 281 | 211 | } |
| 282 | 212 | } |
| 283 | 213 | |
| 284 | 214 | /** |
| @@ -284,15 +214,17 @@ | ||
| 284 | 214 | /** |
| 285 | 215 | * Version of plugin_dir_url() which works for plugins installed in the plugins directory, |
| 286 | 216 | * and for plugins bundled with themes. |
| 287 | 217 | * |
| 218 | + * @throws \Exception | |
| 219 | + * | |
| 288 | 220 | * @return array |
| 289 | 221 | */ |
| 290 | 222 | private function locate_plugin() { |
| 291 | - $dir_url = trailingslashit( plugins_url( '', __DIR__ ) ); | |
| 292 | - $dir_path = plugin_dir_path( __DIR__ ); | |
| 223 | + $dir_url = trailingslashit( plugins_url( '', dirname( __FILE__ ) ) ); | |
| 224 | + $dir_path = plugin_dir_path( dirname( __FILE__ ) ); | |
| 293 | 225 | $dir_basename = basename( $dir_path ); |
| 294 | - $plugin_basename = trailingslashit( $dir_basename ) . 'stream.php'; | |
| 226 | + $plugin_basename = trailingslashit( $dir_basename ) . $dir_basename . '.php'; | |
| 295 | 227 | |
| 296 | 228 | return compact( 'dir_url', 'dir_path', 'dir_basename', 'plugin_basename' ); |
| 297 | 229 | } |
| 298 | 230 | |
| @@ -308,9 +240,9 @@ | ||
| 308 | 240 | /** |
| 309 | 241 | * Change plugin database driver in case driver plugin loaded after stream |
| 310 | 242 | */ |
| 311 | 243 | public function plugins_loaded() { |
| 312 | - // Load DB helper interface/class. | |
| 244 | + // Load DB helper interface/class | |
| 313 | 245 | $driver_class = apply_filters( 'wp_stream_db_driver', '\WP_Stream\DB_Driver_WPDB' ); |
| 314 | 246 | |
| 315 | 247 | if ( class_exists( $driver_class ) ) { |
| 316 | 248 | $driver = new $driver_class(); |
| @@ -338,10 +270,10 @@ | ||
| 338 | 270 | |
| 339 | 271 | /** |
| 340 | 272 | * Filter allows the network activated detection to be overridden. |
| 341 | 273 | * |
| 342 | - * @param string $is_network_activated Whether the plugin is network activated. | |
| 343 | - * @param WP_Stream\Plugin $plugin The stream plugin object. | |
| 274 | + * @param string $is_network_activated Whether the plugin is network activated | |
| 275 | + * @param WP_Stream\Plugin $plugin The stream plugin object | |
| 344 | 276 | */ |
| 345 | 277 | return apply_filters( 'wp_stream_is_network_activated', $is_network_activated, $this ); |
| 346 | 278 | } |
| 347 | 279 | |
| @@ -350,8 +282,9 @@ | ||
| 350 | 282 | * |
| 351 | 283 | * @return bool |
| 352 | 284 | */ |
| 353 | 285 | public function is_mustuse() { |
| 286 | + | |
| 354 | 287 | $stream_php = trailingslashit( WPMU_PLUGIN_DIR ) . $this->locations['plugin']; |
| 355 | 288 | |
| 356 | 289 | if ( file_exists( $stream_php ) && class_exists( 'WP_Stream\Plugin' ) ) { |
| 357 | 290 | return true; |
| @@ -357,228 +290,6 @@ | ||
| 357 | 290 | return true; |
| 358 | 291 | } |
| 359 | 292 | |
| 360 | 293 | return false; |
| 361 | - } | |
| 362 | - | |
| 363 | - /** | |
| 364 | - * Get the IP address for the current request. | |
| 365 | - * | |
| 366 | - * @return false|null|string Valid IP address, null if not set, false if invalid. | |
| 367 | - */ | |
| 368 | - public function get_client_ip_address() { | |
| 369 | - return apply_filters( 'wp_stream_client_ip_address', $this->client_ip_address ); | |
| 370 | - } | |
| 371 | - | |
| 372 | - /** | |
| 373 | - * Get the site type. | |
| 374 | - * | |
| 375 | - * This function determines the type of site based on whether it is a single site or a multisite. | |
| 376 | - * If it is a multisite, it also checks if it is network activated or not. | |
| 377 | - * | |
| 378 | - * @return string The site type | |
| 379 | - */ | |
| 380 | - public function get_site_type(): string { | |
| 381 | - | |
| 382 | - // If it's a multisite, is it network activated or not? | |
| 383 | - if ( is_multisite() ) { | |
| 384 | - return $this->is_network_activated() ? self::MULTI_NETWORK : self::MULTI_NOT_NETWORK; | |
| 385 | - } | |
| 386 | - | |
| 387 | - return self::SINGLE_SITE; | |
| 388 | - } | |
| 389 | - | |
| 390 | - /** | |
| 391 | - * Should the number of records which need to be processed be considered "large"? | |
| 392 | - * | |
| 393 | - * @param int $record_number The number of rows in the {$wpdb->prefix}_stream table to be processed. | |
| 394 | - * @return bool Whether or not this should be considered large. | |
| 395 | - */ | |
| 396 | - public function is_large_records_table( int $record_number ): bool { | |
| 397 | - /** | |
| 398 | - * Filters whether or not the number of records should be considered a large table. | |
| 399 | - * | |
| 400 | - * @since 4.1.0 | |
| 401 | - * | |
| 402 | - * @param bool $is_large_table Whether or not the number of records should be considered large. | |
| 403 | - * @param int $record_number The number of records being checked. | |
| 404 | - */ | |
| 405 | - return apply_filters( 'wp_stream_is_large_records_table', $record_number > 1000000, $record_number ); | |
| 406 | - } | |
| 407 | - | |
| 408 | - /** | |
| 409 | - * Checks if the plugin is running on a single site installation. | |
| 410 | - * | |
| 411 | - * @return bool True if the plugin is running on a single site installation, false otherwise. | |
| 412 | - */ | |
| 413 | - public function is_single_site() { | |
| 414 | - return self::SINGLE_SITE === $this->get_site_type(); | |
| 415 | - } | |
| 416 | - | |
| 417 | - /** | |
| 418 | - * Check if the plugin is activated on a multisite installation but not network activated. | |
| 419 | - * | |
| 420 | - * @return bool True if the plugin is activated on a multisite installation but not network activated, false otherwise. | |
| 421 | - */ | |
| 422 | - public function is_multisite_not_network_activated() { | |
| 423 | - return self::MULTI_NOT_NETWORK === $this->get_site_type(); | |
| 424 | - } | |
| 425 | - | |
| 426 | - /** | |
| 427 | - * Check if the plugin is activated on a multisite network. | |
| 428 | - * | |
| 429 | - * @return bool True if the plugin is network activated on a multisite, false otherwise. | |
| 430 | - */ | |
| 431 | - public function is_multisite_network_activated() { | |
| 432 | - return self::MULTI_NETWORK === $this->get_site_type(); | |
| 433 | - } | |
| 434 | - | |
| 435 | - /** | |
| 436 | - * Enqueue a script along with a stylesheet if it exists. | |
| 437 | - * | |
| 438 | - * @param string $handle Script handle. | |
| 439 | - * @param array $additional_dependencies Additional dependencies. | |
| 440 | - * @param array $data Data to pass to the script. | |
| 441 | - * | |
| 442 | - * @throws RuntimeException If built JavaScript assets are not found. | |
| 443 | - * @return void | |
| 444 | - */ | |
| 445 | - public function enqueue_asset( $handle, $additional_dependencies = array(), $data = array() ) { | |
| 446 | - // If is enqueued already, bail out. | |
| 447 | - if ( wp_script_is( $handle ) ) { | |
| 448 | - return; | |
| 449 | - } | |
| 450 | - | |
| 451 | - $path = untrailingslashit( $this->locations['dir'] ); | |
| 452 | - $url = untrailingslashit( $this->locations['url'] ); | |
| 453 | - | |
| 454 | - $script_asset_path = "$path/build/$handle.asset.php"; | |
| 455 | - | |
| 456 | - if ( ! file_exists( $script_asset_path ) ) { | |
| 457 | - throw new RuntimeException( 'Built JavaScript assets not found. Please run `npm run build`' ); | |
| 458 | - } | |
| 459 | - | |
| 460 | - $script_asset = require $script_asset_path; // phpcs:disable WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound | |
| 461 | - | |
| 462 | - wp_enqueue_script( | |
| 463 | - "wp-stream-$handle", | |
| 464 | - "$url/build/$handle.js", | |
| 465 | - array_merge( | |
| 466 | - $script_asset['dependencies'], | |
| 467 | - (array) $additional_dependencies | |
| 468 | - ), | |
| 469 | - $script_asset['version'], | |
| 470 | - true | |
| 471 | - ); | |
| 472 | - | |
| 473 | - if ( file_exists( "$path/build/$handle.css" ) ) { | |
| 474 | - wp_enqueue_style( | |
| 475 | - "wp-stream-$handle", | |
| 476 | - "$url/build/$handle.css", | |
| 477 | - array(), | |
| 478 | - $script_asset['version'] | |
| 479 | - ); | |
| 480 | - } | |
| 481 | - | |
| 482 | - if ( ! empty( $data ) ) { | |
| 483 | - wp_add_inline_script( | |
| 484 | - "wp-stream-$handle", | |
| 485 | - sprintf( 'window["%s"] = %s;', esc_attr( "wp-stream-$handle" ), wp_json_encode( $data ) ), | |
| 486 | - 'before' | |
| 487 | - ); | |
| 488 | - } | |
| 489 | - } | |
| 490 | - | |
| 491 | - /** | |
| 492 | - * Enqueue select2 script and locale file if exists. | |
| 493 | - * | |
| 494 | - * @return string Script handle. | |
| 495 | - */ | |
| 496 | - public function with_select2() { | |
| 497 | - $handle = 'wp-stream-select2'; | |
| 498 | - | |
| 499 | - // If is enqueued already, bail out. | |
| 500 | - if ( wp_script_is( $handle ) ) { | |
| 501 | - return $handle; | |
| 502 | - } | |
| 503 | - | |
| 504 | - $path = untrailingslashit( $this->locations['dir'] ); | |
| 505 | - $url = untrailingslashit( $this->locations['url'] ); | |
| 506 | - | |
| 507 | - wp_enqueue_script( | |
| 508 | - $handle, | |
| 509 | - "$url/build/select2/js/select2.full.min.js", | |
| 510 | - array( 'jquery' ), | |
| 511 | - filemtime( "$path/build/select2/js/select2.full.min.js" ), | |
| 512 | - true | |
| 513 | - ); | |
| 514 | - wp_enqueue_style( | |
| 515 | - $handle, | |
| 516 | - "$url/build/select2/css/select2.min.css", | |
| 517 | - array(), | |
| 518 | - filemtime( "$path/build/select2/css/select2.min.css" ) | |
| 519 | - ); | |
| 520 | - | |
| 521 | - $locale = get_locale(); | |
| 522 | - $lang = substr( $locale, 0, 2 ); | |
| 523 | - $search_files = array( $locale, $lang, 'en' ); | |
| 524 | - | |
| 525 | - foreach ( $search_files as $search_file ) { | |
| 526 | - if ( file_exists( "$path/build/select2/js/i18n/$search_file.js" ) ) { | |
| 527 | - wp_enqueue_script( | |
| 528 | - sanitize_title( "$handle-$search_file" ), | |
| 529 | - "$url/build/select2/js/i18n/$search_file.js", | |
| 530 | - array( $handle ), | |
| 531 | - filemtime( "$path/build/select2/js/i18n/$search_file.js" ), | |
| 532 | - true | |
| 533 | - ); | |
| 534 | - break; | |
| 535 | - } | |
| 536 | - } | |
| 537 | - | |
| 538 | - return $handle; | |
| 539 | - } | |
| 540 | - | |
| 541 | - /** | |
| 542 | - * Enqueue jquery.timeago script and locale file if exists. | |
| 543 | - * | |
| 544 | - * @return string Script handle. | |
| 545 | - */ | |
| 546 | - public function with_jquery_timeago() { | |
| 547 | - $handle = 'wp-stream-jquery-timeago'; | |
| 548 | - | |
| 549 | - // If is enqueued already, bail out. | |
| 550 | - if ( wp_script_is( $handle ) ) { | |
| 551 | - return $handle; | |
| 552 | - } | |
| 553 | - | |
| 554 | - $path = untrailingslashit( $this->locations['dir'] ); | |
| 555 | - $url = untrailingslashit( $this->locations['url'] ); | |
| 556 | - | |
| 557 | - wp_enqueue_script( | |
| 558 | - $handle, | |
| 559 | - "$url/build/timeago/js/jquery.timeago.js", | |
| 560 | - array( 'jquery' ), | |
| 561 | - filemtime( "$path/build/timeago/js/jquery.timeago.js" ), | |
| 562 | - true | |
| 563 | - ); | |
| 564 | - | |
| 565 | - $locale = get_locale(); | |
| 566 | - $lang = substr( $locale, 0, 2 ); | |
| 567 | - $search_files = array( $locale, $lang, 'en' ); | |
| 568 | - | |
| 569 | - foreach ( $search_files as $search_file ) { | |
| 570 | - if ( file_exists( "$path/build/timeago/js/locales/jquery.timeago.$search_file.js" ) ) { | |
| 571 | - wp_enqueue_script( | |
| 572 | - sanitize_title( "$handle-$search_file" ), | |
| 573 | - "$url/build/timeago/js/locales/jquery.timeago.$search_file.js", | |
| 574 | - array( $handle ), | |
| 575 | - filemtime( "$path/build/timeago/js/locales/jquery.timeago.$search_file.js" ), | |
| 576 | - true | |
| 577 | - ); | |
| 578 | - break; | |
| 579 | - } | |
| 580 | - } | |
| 581 | - | |
| 582 | - return $handle; | |
| 583 | 294 | } |
| 584 | 295 | } |