Overview

Classes

  • xu
  • Xu\Foundation\Foundation
  • Xu\Foundation\Jsonable
  • Xu\Model\Collection
  • Xu\Model\Model

Functions

  • xu
  • xu_add_option
  • xu_attachment_url_to_postid
  • xu_cache_delete
  • xu_cache_delete_group
  • xu_cache_get
  • xu_cache_key
  • xu_camel_case
  • xu_clean_attachment_cache
  • xu_clean_nav_menu_cache
  • xu_clean_post_cache
  • xu_contains
  • xu_convert_to_string
  • xu_current_attachment_url_to_postid
  • xu_current_url
  • xu_current_url_to_postid
  • xu_dashify
  • xu_delete_option
  • xu_delete_site_transient
  • xu_delete_transient
  • xu_doing_ajax
  • xu_ends_with
  • xu_get_class_name
  • xu_get_model
  • xu_get_option
  • xu_get_option_name
  • xu_get_option_post_id
  • xu_get_posts
  • xu_get_site_transient
  • xu_get_top_parent_post
  • xu_get_top_parent_post_type
  • xu_get_top_parent_post_type_object
  • xu_get_transient
  • xu_is_empty
  • xu_is_http_method
  • xu_is_json
  • xu_is_post_type
  • xu_is_wp
  • xu_is_xml
  • xu_post_exists
  • xu_register_large_option_post_type
  • xu_snake_case
  • xu_starts_with
  • xu_strip_spaces
  • xu_studly_case
  • xu_update_option
  • xu_url_to_postid
  • xu_valid_personnummer
  • xu_wp_get_attachment_image
  • xu_wp_get_attachment_image_sizes
  • xu_wp_get_attachment_image_src
  • xu_wp_get_attachment_image_srcset
  • xu_wp_get_attachment_url
  • xu_wp_nav_menu
  • Overview
  • Class
  1: <?php
  2: 
  3: namespace Xu\Foundation;
  4: 
  5: use Exception;
  6: use Frozzare\Tank\Container;
  7: use InvalidArgumentException;
  8: 
  9: class Foundation extends Container {
 10: 
 11:     /**
 12:      * Foundation instance.
 13:      *
 14:      * @var \Xu\Foundation\Foundation
 15:      */
 16:     protected static $instance;
 17: 
 18:     /**
 19:      * The constructor.
 20:      */
 21:     public function __construct() {
 22:         $this->require_files();
 23:         $this->boot();
 24:     }
 25: 
 26:     /**
 27:      * Boot the foundation.
 28:      */
 29:     public function boot() {
 30:         xu_register_large_option_post_type();
 31:     }
 32: 
 33:     /**
 34:      * Call function.
 35:      *
 36:      * @param  string $method
 37:      * @param  mixed $args
 38:      *
 39:      * @throws \Exception if function does not exists.
 40:      *
 41:      * @return mixed
 42:      */
 43:     public function fn( $method, $args ) {
 44:         $method = $this->get_fn_name( $method );
 45: 
 46:         if ( ! is_array( $args ) ) {
 47:             $args = [$args];
 48:         }
 49: 
 50:         if ( ! function_exists( $method ) ) {
 51:             throw new Exception( sprintf( '`%s` function does not exists', $method ) );
 52:         }
 53: 
 54:         return call_user_func_array( $method, $args );
 55:     }
 56: 
 57:     /**
 58:      * Get method that should be called.
 59:      *
 60:      * @param  string $fn
 61:      *
 62:      * @return string
 63:      */
 64:     protected function get_fn_name( $fn ) {
 65:         return 'xu_' . preg_replace( '/^xu\_/', '', $fn );
 66:     }
 67: 
 68:     /**
 69:      * Get foundation instance.
 70:      *
 71:      * @return \Xu\Foundation\Foundation
 72:      */
 73:     public static function get_instance() {
 74:         if ( ! isset( self::$instance ) ) {
 75:             return self::$instance = new self;
 76:         }
 77: 
 78:         return self::$instance;
 79:     }
 80: 
 81:     /**
 82:      * Require library files.
 83:      */
 84:     protected function require_files() {
 85:         $files = [
 86:             'helpers.php',
 87:             'lib/cache.php',
 88:             'lib/clean.php',
 89:             'lib/conditional.php',
 90:             'lib/http.php',
 91:             'lib/media.php',
 92:             'lib/menu.php',
 93:             'lib/option.php',
 94:             'lib/post.php',
 95:             'lib/rewrite.php',
 96:             'lib/string.php',
 97:             'lib/transient.php',
 98:             'lib/utils.php',
 99:             'model/helpers.php'
100:         ];
101: 
102:         foreach ( $files as $file ) {
103:             if ( strpos( $file, '/' ) !== false ) {
104:                 $file = '../' . $file;
105:             }
106: 
107:             if ( file_exists( __DIR__ . '/' . $file ) ) {
108:                 require_once __DIR__ . '/' . $file;
109:             }
110:         }
111: 
112:         unset( $file );
113:     }
114: }
115: 
API documentation generated by ApiGen