Skip to content

Instantly share code, notes, and snippets.

@luizlopescom
Created September 5, 2020 14:57
Show Gist options
  • Select an option

  • Save luizlopescom/92215337cf0aeab930d3780b7b98aad5 to your computer and use it in GitHub Desktop.

Select an option

Save luizlopescom/92215337cf0aeab930d3780b7b98aad5 to your computer and use it in GitHub Desktop.

Revisions

  1. luizlopescom created this gist Sep 5, 2020.
    68 changes: 68 additions & 0 deletions wp_shortcodes
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,68 @@
    <?php
    /**
    * Add useful shortcodes
    *
    */

    // Exit if accessed directly.
    defined( 'ABSPATH' ) || exit;


    //Site name
    function sitename_shortcode( $atts ){
    return get_bloginfo( 'name' );
    }
    add_shortcode( 'sitename', 'sitename_shortcode' );


    //Date shortcodes
    function year_shortcode() {
    $year = date('Y');
    return $year;
    }
    add_shortcode('year', 'year_shortcode');

    //Copyright
    function copyright_shortcode( $atts ){
    return '©';
    }
    add_shortcode( 'copyright', 'copyright_shortcode' );
    add_shortcode( 'c', 'copyright_shortcode' );

    //Registered
    function registered_shortcode( $atts ){
    return '®';
    }
    add_shortcode( 'registered', 'registered_shortcode' );
    add_shortcode( 'r', 'registered_shortcode' );

    //Trademark
    function trademark_shortcode( $atts ){
    return '™';
    }
    add_shortcode( 'trademark', 'trademark_shortcode' );
    add_shortcode( 'tm', 'trademark_shortcode' );


    //FontAwwesome Icons Shortcodes
    function fa_user_plus_shortcode() {
    return '<i class="fa fa-user-plus" aria-hidden="true"></i>';
    }
    add_shortcode('fa_user_plus', 'fa_user_plus_shortcode');

    function fa_mail_shortcode() {
    return '<i class="fa fa-envelope-o" aria-hidden="true"></i>';
    }
    add_shortcode('fa_mail', 'fa_mail_shortcode');

    function fa_phone_shortcode() {
    return '<i class="fa fa-phone" aria-hidden="true"></i>';
    }
    add_shortcode('fa_phone', 'fa_phone_shortcode');

    function fa_pin_shortcode() {
    return '<i class="fa fa-map-marker" aria-hidden="true"></i>';
    }
    add_shortcode('fa_map', 'fa_pin_shortcode');