Functions
List of the global functions included in the framework. These can be used anywhere.
get_bridge
Returns a Main Class instance based on a given namespace.
/** * @param string $namespace * * @return WPMVC\Main|null */ $main_class = get_bridge( $namespace );
Parameter | Type | Description |
$namespace | string | Project namespace. |
Returns
Returns a main class instance or null
.
resize_image
Returns the URL of a resized image.
/** * @param string $path_url Path or original url. * @param int $width Width to resize to. * @param int $height Height to resize to. * @param bool $crop (Optional) Flag that indicates if image should crop. * DEFAULT: true * @param int $id (Optional) Unique identifier for if there are * conflicts with other images. DEFAULT: null * * @return string */ $url = resize_image( $path_url, $width, $height, $crop, $id );
Parameter | Type | Description |
$path_url | string | Path or URL of the original image. |
$width | int | Width to resize to. |
$height | int | Height to resize to. |
$crop | bool | (Optional) A flag that indicates if the image should crop. DEFAULT : true |
$id | int | (Optional) Unique identifier for if there are conflicts with other images. DEFAULT: null |
Returns
Returns string
URL.
Storage
This function will create a re-sized version of the image and store it on WordPress’ uploads folder.assets_url
Returns the URL of an asset file.
/** * @param string $relative_path Relative path in assets folder. * @param string __FILE__ Current file caller (constant required). * @param string $scheme (Optional) Forces url scheme * (ie "html" or "https"). DEFAULT: null * @param bool $is_network (Option) Flag that indicates if wordpress has * a network setup. DEFAULT: false */ $url = assets_url( $relative_path, __FILE__, $scheme, $is_network ); /** * Sample */ $url = assets_url( 'img/logo.png', __FILE__ ); /** * Sample forcing HTTPS */ $url = assets_url( 'js/jquery.my-plugin.js', __FILE__, 'https' ); /** * Sample forcing HTTPS checking SSL flag */ $url = assets_url( 'js/jquery.my-plugin.js', __FILE__, is_ssl() ? 'https' : 'http' ); /** * Sample on network setups */ $url = assets_url( 'img/logo.png', __FILE__, null, true );
theme_view
Prints a view located in theme.