Plugin Directory

Changeset 2685416


Ignore:
Timestamp:
02/26/2022 07:08:42 PM (3 years ago)
Author:
devikas301
Message:

tested with latest WP version

Location:
basic-url-shortcodes/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • basic-url-shortcodes/trunk/readme.txt

    r2685415 r2685416  
    1111== Description ==
    1212Sometimes you want to put the base URL (that of the blog, or that of the active template) in your content editor. Times when the template customising isn't quite flexible enough.
    13 With this plugin you can use [home_url] to output the base URL of the blog (as set in your Settings). Or, you can use [theme_url_template] to output the URL of the active template.
     13With this plugin you can use [home_url] to output the base URL of the blog (as set in your Settings). Or, you can use [theme_url_template] to output the URL of the active template. And You can use the [UPLOAD_URL] to output the URL of the upload folder.
    1414
    15 For example `<img src="[home_url]/test.png" />` in your editor might output `<img src="http://localhost/wp-demo/test.png" />` (if http://localhost/wp-demo is what you have configured as your blog URL in Settings).
     15For example `<img src="[UPLOAD_URL]/2022/02/test.png />` in your editor might output `<img src="http://localhost/wp-demo/wp-content/uploads/2022/02/test.png" />` (if http://localhost/wp-demo is what you have configured as your blog URL in Settings).
    1616
    1717The supported short codes are as follows:
    1818* [home_url] - the configured blog URL (set in Settings). E.g. http://localhost/wp-demo
    1919* [theme_url_template] - the URL of the active template. E.g. http://localhost/wp-demo/wp-content/themes/mytheme
     20* [UPLOAD_URL] - the URL of the upload folder. E.g. http://localhost/wp-demo/wp-content/uploads
    2021
    2122== Installation ==
  • basic-url-shortcodes/trunk/ro_burl_short_codes.php

    r1699763 r2685416  
    33    Plugin Name: BASIC URL ShortCodes
    44    Plugin URI: https://wordpress.org/plugins/basic-url-shortcodes/
    5     Description: Adds support for a [home_url] and [theme_url_template] short-codes for use in your post/page editor.
    6     Version: 4.0
     5    Description: Adds support for a [home_url], [theme_url_template] and [UPLOAD_URL] short-codes for use in your post/page editor.
     6    Version: 4.0.1
    77    Author: Vikas Sharma
    88    Author URI: https://profiles.wordpress.org/devikas301
     
    1010
    1111// [home_url]
    12 function ro_home_url_function() {
    13     return get_bloginfo( "url" );
     12function roHomeUrlFunction(){
     13    return get_bloginfo("url");
    1414}
    15 add_shortcode('home_url', 'ro_home_url_function');
     15add_shortcode('home_url','roHomeUrlFunction');
    1616
    1717// [theme_url_template]
    18 function ro_url_template_function() {
    19     if( get_theme_root_uri() && get_template() ) {
    20         return get_theme_root_uri() . "/" . get_template();
     18function roUrlTemplateFunction(){
     19    if(get_theme_root_uri() && get_template()){
     20        return get_theme_root_uri()."/".get_template();
    2121    } else {
    2222        return "";
    2323    }
    2424}
    25 add_shortcode('theme_url_template', 'ro_url_template_function');
     25add_shortcode('theme_url_template','roUrlTemplateFunction');
     26
     27// [UPLOAD_URL]
     28function roUploadUrlFunction(){
     29    $upload_dir = wp_upload_dir();
     30    if(!empty($upload_dir['baseurl'])){
     31        return $upload_dir['baseurl'];
     32    } else {
     33        return "";
     34    }
     35}
     36add_shortcode('UPLOAD_URL', 'roUploadUrlFunction');
    2637?>
Note: See TracChangeset for help on using the changeset viewer.