• asbell

    (@asbell)


    Friends, there is absolutely no basic documentation on the shortcode parameters or format. Can you please at least share a file or publish a page with how to use this? Its not obvious.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Eli

    (@scheeeli)

    Here is the example shortocde from the FAQ section:
    [remote_get url=”https://wordpress.org/plugins/shortcurl/stats/” start='<div class=”block-content”‘ stop=’!– block-content–‘ length=”-1″ replace=”=’/extend” with=”=’https://wordpress.org/extend” replace2=”%2Fextend%2F” with2=”http%3A%2F%2Fwordpress.org%2Fextend%2F”]

    In it’s simplest form you only need to pass the url parameter:
    [remote_get url=”https://wordpress.org/plugins/shortcurl/”]

    Other paramiters that can be useful are:
    start=’something to search for as a marker for where to start the output’
    stop=’something to search for as a marker for where to stop the output’
    length=”the length of the output if you want to trim it”
    replace=’something to search for to be replaced by “with” param’
    with=’something to replace what is found by “replace” param’

    asbell

    (@asbell)

    Yes that I got. But for example: If I start and stop is it inclusive of the start and stop points or exclusive (does it copy or snip)? When I replace does it replace the 1st occurrence or all matching occurrences? Also what other parameters are there? What specific matching engine is it using?

    Plugin Author Eli

    (@scheeeli)

    So first of all, this is a really simple plugin with only 200 lines of code. If you are asking about things like “what specific matching engine is it using?” then you could probably figure out the answers to these questions by just looking at the code.

    Anyway the “start” param is inclusive and the “stop” param is exclusive but there is also an “end” param that is inclusive if you want.

    The replace uses the str_replace function so it will replace ALL occurrences.

    There is also a ‘timeout’ param which defaults to 30 seconds, and an ‘expire’ param which is the number of second to use the cache before refreshing the captured content (defaults to 24 hour).

    asbell

    (@asbell)

    =) I dont know php well enough to read or understand it.

    So if the start is inclusive but we DONT want to include it in the final, how do we get rid of it? How does it know when/where to snip and grao the remaining chunk?

    Plugin Author Eli

    (@scheeeli)

    Can you give me an example of the HTML that you want to capture and the start param that you are trying to use?

    asbell

    (@asbell)

    So there are a few scenarios
    <Parent>
    <Child>text I don’t want</Child>
    <Child>text</Child>
    <Child>text</Child>
    </Parent>

    1) I want everything between the parents including the parents
    2) I want everything between the parents but not the parents
    3) I want all child elements but not the first one

    asbell

    (@asbell)

    Got this warning that does not match the SHORTCODE

    04-05 11:57: /test/
    SHORTCURL start=</p> <div class=”wntFormatedDivContent”> but not found in (http://search.kwboca.com/fl_rmls/jonathanasbell/index.cfm?action=newsearchsession&search_mode=form&primarysearchtype=active&searchtype=city&state=FL&min_price=600000&max_price=1200000&listing_status=Active&has_pool=Y&built_after=2007&city=Bay%20Harbor%20Islands%2CBoca%20Raton%2CCoconut%20Grove%2CCoral%20Gables%2CDelray%20Beach%2CFort%20Lauderdale%2CHighland%20Beach%2CJupiter%2CKey%20Biscayne%2CLauderdale%20By%20The%20Sea%2CLighthouse%20Point%2CManalapan%2CMiami%20Beach%2COcean%20Ridge%2CPalm%20Beach%20Gardens%2CParkland%2CPinecrest%2CSouthwest%20Ranches%2CWellington&single_family=y&resetform=1)! SHORTCURL stop=</p> <div class=”wntSearchResultsToolbar”> but not found in (http://search.kwboca.com/fl_rmls/jonathanasbell/index.cfm?action=newsearchsession&search_mode=form&primarysearchtype=active&searchtype=city&state=FL&min_price=600000&max_price=1200000&listing_status=Active&has_pool=Y&built_after=2007&city=Bay%20Harbor%20Islands%2CBoca%20Raton%2CCoconut%20Grove%2CCoral%20Gables%2CDelray%20Beach%2CFort%20Lauderdale%2CHighland%20Beach%2CJupiter%2CKey%20Biscayne%2CLauderdale%20By%20The%20Sea%2CLighthouse%20Point%2CManalapan%2CMiami%20Beach%2COcean%20Ridge%2CPalm%20Beach%20Gardens%2CParkland%2CPinecrest%2CSouthwest%20Ranches%2CWellington&single_family=y&resetform=1)!

    THE SHORTCODE

    [remote_get url=’http://search.kwboca.com/fl_rmls/jonathanasbell/index.cfm?action=newsearchsession&search_mode=form&primarysearchtype=active&searchtype=city&state=FL&min_price=600000&max_price=1200000&listing_status=Active&has_pool=Y&built_after=2007&city=Bay%20Harbor%20Islands%2CBoca%20Raton%2CCoconut%20Grove%2CCoral%20Gables%2CDelray%20Beach%2CFort%20Lauderdale%2CHighland%20Beach%2CJupiter%2CKey%20Biscayne%2CLauderdale%20By%20The%20Sea%2CLighthouse%20Point%2CManalapan%2CMiami%20Beach%2COcean%20Ridge%2CPalm%20Beach%20Gardens%2CParkland%2CPinecrest%2CSouthwest%20Ranches%2CWellington&single_family=y&resetform=1′ start='<div class=”wntFormatedDivContent”>’ stop='<div class=”wntSearchResultsToolbar”>’ length=’-1′]

    Plugin Author Eli

    (@scheeeli)

    This is a common problem and one that no real good solution other than a convoluted workaround that is hard to express on this forum because it involves escaping special characters and the forum also escapes special characters but I’ll try to explain anyway.

    First of all the problem is caused because WordPress tries to “fix” and HTML that you enter in your post with filters that add the “P” tags before other tags you enter like your “div” tag (yes, even when your div is inside the quotes of a shortcode parameter). I know it is stupid that WordPress filters change anything you write in your post, especially when it’s inside a shortcode, but that’s what we have to work around.

    Now we have to trick WordPress so that it does not see the div tag in yout start param:
    start='<div class=”wntFormatedDivContent”>’
    I have found that it will usually work if just encode the first “<” (less than) symbol before the “div” using the HTML entity code (let’s see if I can double encode this so that it shows up right on the forum):
    &lt;

    • This reply was modified 1 year ago by  Eli.
    asbell

    (@asbell)

    04-05 19:48: /wp-admin/post.php
    SHORTCURL ERROR: wp_remote_get(’http://search.kwboca.com/fl_rmls/jonathanasbell/index.cfm?action=searchresults&searchkey=9756ba8b-a795-fdd1-680b-b53ca8733bd5&sr=1′) returned Array ( [ERROR] => WP_Error Object ( [errors] => Array ( [http_request_failed] => Array ( [0] => A valid URL was not provided. ) ) [error_data] => Array ( ) ) ) SHORTCURL ERROR: wp_remote_get(’http://search.kwboca.com/fl_rmls/jonathanasbell/index.cfm?action=searchresults&searchkey=9756ba8b-a795-fdd1-680b-b53ca8733bd5&sr=1′) returned NOTHING!

    Plugin Author Eli

    (@scheeeli)

    Yeah, that URL gets redirected to the main search form. I’m not sure that this shortcode is going to be able to do what you are wanting it to do.

    asbell

    (@asbell)

    I used the redirect link instead and got the same result

    Plugin Author Eli

    (@scheeeli)

    That is a wp_remote_get error not an error generated by my plugin. What you see is what you get. I don’t know what I can do about that. Like I said. This is a simple shortcode that uses the built in wp_remote_get function to fetch external pages. It may not be capable of doing what you want it to do. Besides, that error message indicates that it is something wrong with the URL you are using.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Guys, please’ is closed to new replies.