Forum Replies Created

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter mayaboni

    (@mayaboni)

    Can I at least make all external links open in new tab using that make_clickable() function?

    Thread Starter mayaboni

    (@mayaboni)

    I need to customize urls opening in one page that will warn user he is leaving my site, so i have link holder also, and output link, that same after he proced will go into iframe document(page).

    Yes, I know I can make warning on another way, but this is the only way I want to do it.

    I saw it somewhere and I am in love with this way of openning external urls.

    Thread Starter mayaboni

    (@mayaboni)

    Ok.

    I have new function that I made before I discovered make_clickable().

    Here it is:

    function url_auto( $atts, $content = null ) {
    $url_pattern = "/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/";
    $text = get_the_content();
    $cnt = substr($text, 0, strpos($text, '/', strpos($text, '/')+2));
    $cnt = str_replace('http://www.', '', $cnt);
    $cnt = str_replace('http://', '', $cnt);
    $cnt = str_replace('www.', '', $cnt);
    $replace = '<a href="$1" target="_blank">$2</a>';
    $text= preg_replace($url_pattern, $replace, $text);
    echo $text;
    }
    
    add_filter( 'the_content', 'url_auto' );

    Is it possible to remove this filter in shortcodes and html, because it broke my embeds and my shortcodes aswell.

    Thread Starter mayaboni

    (@mayaboni)

    I know, the content is everything inside post.
    But, still it is weird.

    function url_auto( $atts, $content = null ) {
    $string = get_the_content();
    echo make_clickable($string);
    }
    
    add_filter( 'the_content', 'url_auto' );

    This outputs everything nice and links are clickable. Than logic would be that mine function. I will try with another way if not possible I ‘ll quit. I am very limited with php. Even what I knew I am confused more now.

    Thread Starter mayaboni

    (@mayaboni)

    Result should be:

    <a href="http://wordpress.org">okokok</a>This is wordpress website, ....

    And not all content inside href.

    Thread Starter mayaboni

    (@mayaboni)

    I am newbie.
    I kinda sort it out now with quotes.
    With double quotes i have to add \ before any quote that shouldn’t be the end of an string.

    Problem here is this, if I use function like this:

    function url_auto( $atts, $content = null ) {
    $string = get_the_content();
    echo make_clickable($string);
    }

    This will output nice.
    But I need to customize that to output url into my html form (link holder page).

    Tried:

    $string= "<a href=\"/external/?link=" . get_the_content() . "\" target=\"_blank\">okokok</a>";

    and

    $string = '<a href="/external/?link=' . get_the_content() . '">okokok</a>';

    Both outputing everything inside post.

    For example, output is like:

    <a href="http://wordpress.orgThis is wordpress website, ....">okokok</a>

    This is confusing.

    header.php

    find <head>

    add after

    Forum: Fixing WordPress
    In reply to: Remove filter?
    Thread Starter mayaboni

    (@mayaboni)

    Still, it messes html and shortcodes. πŸ™

    Forum: Fixing WordPress
    In reply to: Remove filter?
    Thread Starter mayaboni

    (@mayaboni)

    That will remove filter even in plain text.

    I am doing this:

    function url_auto( $atts, $content = null ) {
    $url_pattern = "/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/";
    $text = get_the_content();
    $replace = '<a href="$1" target="_blank">$2</a>';
    $text= preg_replace($url_pattern, $replace, $text);
    echo $text;
    }
    
    add_filter( 'the_content', 'url_auto' );

    URL to HTML.

    Thread Starter mayaboni

    (@mayaboni)

    I solved it, with help on another place.

    Add to header:
    <meta property=”og:image” content=”IMAGE URL” />

Viewing 11 replies - 1 through 11 (of 11 total)