Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #21700

    On register-shortcodes.php: http://pastebin.com/6YnseKCg

    On editor_plugin.js: http://pastebin.com/dch88AHk

    What should happen is my new thin HR should show up. And it does. But now that it shows up, none of the others show up in the layout. For example, in the original horizontal rule I now see “<div class=”hr”></div>” in the browser, which is wrong because it’s not styled at all. If I comment out my new edition on register-shortcodes.php everything works again but my new HR is missing.

    #112776

    Hi,

    Please show a live site. You can use http://www.goo.gl to mask the url to your site. With chunks of code like that it is hard to give any meaningful answer.

    Sorry for the weekend delay in answering.

    Thanks,

    Nick

    #112777

    Nick:

    Shown in this url you’ll see that I’ve set up a page with sections of the respective hr shortcode. Currently, only the new one shows up. This is how the current function looks: http://pastebin.com/6YnseKCg

    However, if I comment out line 13 – 17 the other HRs will show up properly and mine will be broken.

    http://goo.gl/2Flb0

    #112778

    Hi,

    Is there a particular reason you want to create a shortcode? You can simply drop the html directly into your posts or wherever and add the css. Shortcodes like HR only benefit people clueless about html , otherwise all they do when used is slow down your page as databases and processing power is used to figure out what’s going on..

    1) There is HR function called : function avia_advanced_hr($text = “”, $class = “”) on line 233 -258 of functions.php file. Replace that entire function with the one below

    if (!function_exists('avia_advanced_hr')) {
    function avia_advanced_hr($text = "", $class = "")
    {
    $output = "";
    if ($text !== false && "thin" !== $text) {
    $output.= '<div class="hr hr_flag ' . $class . '">';
    $output.= ' <div class="primary-background hr_color">';
    $output.= ' <span class="flag-text on-primary-color">' . $text . '</span>';
    $output.= ' </div>';
    $output.= '</div>';
    } elseif ("thin" == $text) {
    $output.= '<div class="fi-hr hr_flag">';
    $output.= ' <span class="hr-seperator extralight-border"></span>';
    $output.= '</div>';
    } else {
    $output.= '<div class="hr hr_flag ' . $text . '">';
    $output.= ' <span class="primary-background seperator-addon"></span>';
    $output.= '</div>';
    }
    return $output;
    }
    }

    2) In register-shortcodes.php , inside the avia_sc_hr function please find the code below on line 57

    and **overwrite line 57** with these 2 lines below

    if (isset($atts[0]) && trim($atts[0]) == 'thin')  $toplink = 'thin';
    if (isset($atts[0]) && trim($atts[0]) == 'top') $top = 'top';

    You can execute the shortcode like this

    [hr thin]

    Thanks,

    Nick’

    #112779

    Hi Nick,

    In register-shortcodes.php: http://pastebin.com/VJHxff0t

    In functions.php: http://pastebin.com/TFLX1w4b

    I want to think I followed your instructions but there are two issues: http://goo.gl/2Flb0

    1. The shortcode hr_thin isn’t registered.

    2. It looks like a div isn’t being closed which is causing the grey background to show up in the post entry area.

    #112780

    Hi Rabx,

    Indeed there was a slight miscommunication and the fault is entirely mine. The shortcode would be executed like this [hr thin] (no underscore) and please look at my above post http://www.kriesi.at/support/topic/adding-custom-hr#post-103910 as I optimized the function as well as added an additional line to the function you were examining before. I tested it , and it works.

    Instead of creating a whole new shortcode, we simply are using a new attribute of the hr shortcode in the same manner that [hr top] does.

    Thanks,

    Nick

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Adding custom HR’ is closed to new replies.