jetpack_require_lib

The Jetpack by WordPress.com jetpack require lib function.

Description

jetpack_require_lib( $slug ); 

Parameters (1)

0. $slug
The slug.

Usage

  1. if ( !function_exists( 'jetpack_require_lib' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/require-lib.php'; 
  3.  
  4. // The slug. 
  5. $slug = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = jetpack_require_lib($slug); 
  9.  

Defined (1)

The function is defined in the following location(s).

/require-lib.php  
  1. function jetpack_require_lib( $slug ) { 
  2. if ( !preg_match( '|^[a-z0-9/_.-]+$|i', $slug ) ) { 
  3. trigger_error( "Cannot load a library with invalid slug $slug.", E_USER_ERROR ); 
  4. return; 
  5. $basename = basename( $slug ); 
  6.  
  7. if ( defined( 'ABSPATH' ) && ! defined( 'WP_CONTENT_DIR' ) ) { 
  8. define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down 
  9.  
  10. $lib_dir = WP_CONTENT_DIR . '/lib'; 
  11.  
  12. /** 
  13. * Filter the location of the library directory. 
  14. * @since 2.5.0 
  15. * @param str $lib_dir Path to the library directory. 
  16. */ 
  17. $lib_dir = apply_filters( 'jetpack_require_lib_dir', $lib_dir ); 
  18. $choices = array( 
  19. "$lib_dir/$slug.php",  
  20. "$lib_dir/$slug/0-load.php",  
  21. "$lib_dir/$slug/$basename.php",  
  22. ); 
  23. foreach( $choices as $file_name ) { 
  24. if ( is_readable( $file_name ) ) { 
  25. require_once $file_name; 
  26. return; 
  27. trigger_error( "Cannot find a library with slug $slug.", E_USER_ERROR );