• Resolved capson

    (@capson)


    Hello,

    We love your plugin and have the pro version.

    One thing that would be great to see added is {} curly-bracket for the Google short link

    As it is now you have to be manually added it, and I am guessing here but I think most everyone uses a URL Shortener

    I am using this plugin to get Goo.gl short link the code is open source and I suspect could be easily integrated into to Nelio

    https://wordpress.org/plugins/googl/

    Please consider this as without it we cannot automate our process as we would like

    Thank you

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author David Aguilera

    (@davilera)

    Hi @capson,

    Thanks for the suggestion. I don’t think adding custom curly-brackets is a good idea, as it opens the door to everyone requesting their own placeholders. However, there’s one possible workaround: we can add a custom filter in our plugin so that the standard {permalink} tag resolves to the shortened version. Would that be helpful?

    Thread Starter capson

    (@capson)

    Hello David, thank you for the timely response.

    Can you help me understand what

    we can add a custom filter in our plugin so that the standard {permalink} tag resolves to the shortened version

    would mean?

    I have a post with a URL like so:
    http://greaterthanthesum.com/aldo1/

    The short link is:
    https://goo.gl/EuAKyk

    what would

    resolves to the shortened version

    look like?

    Thanks again for the response

    • This reply was modified 6 years, 7 months ago by capson.
    Plugin Author David Aguilera

    (@davilera)

    Hi!

    Can you help me understand what [a custom filter] would mean?

    Sure! Let’s focus on your example. By default, Nelio Content will replace the placeholder {permalink} with http://greaterthanthesum.com/aldo1/, right? In order to do this, our plugin asks WordPress “hey, what’s the URL of this post?”, and WordPress replies “it’s this one”. Well, what I’m proposing is a slightly modification in our plugin (a filter) so that, when the plugin asks for a URL, WordPress replies “it’s this short link”.

    How would WordPress tell us a different URL? That’s where you com in. Basically, you’d use the filter we create to “tweak” the expected result:

    
    add_filter( 'nelio_content_permalink', 'nc_use_googl_short_link', 2 );
    function nc_use_googl_short_link( $permalink, $post_id ) {
    
      $short = get_post_meta( $post_id, '_googl_url', true ); // This needs tweaking.
    
      if ( ! empty( $short ) ) {
        return $short;
      }//end if
    
      return $permalink;
    
    }//end nc_use_googl_short_link()
    

    You should add the previous snippet (well, one that works for you) in your theme’s functions.php file (or, even better, create a custom plugin).

    Now, if you take a closer look at the function nc_use_googl_short_link, you’ll see how it works. The function tries to determine the short link of a given post (in this case, I assumed it’s stored in a custom meta named _googl_url, but you should figure out how to retrieve that value from the plugin you’re using). If we find a short link, we return it. Otherwise, we use the regular permalink.

    Once this function is set in place, all social message’s {permalink} will be changed to https://goo.gl/EuAKyk, instead of http://greaterthanthesum.com/aldo1/.

    So, would the filter solution work for you?

    Thread Starter capson

    (@capson)

    Hello David,

    Yeah, that looks like it would give us what we need. Are you saying I could take that code snippet & set that up right now or do you need to do something first?

    Thank you

    Plugin Author David Aguilera

    (@davilera)

    Yeah, that looks like it would give us what we need.

    Awesome!

    Are you saying I could take that code snippet & set that up right now or do you need to do something first?

    Right now, this wouldn’t work. I need to modify the plugin and upload a new version so that it behaves like this… but, in the meantime (until we release this new version), you can modify the plugin yourself and place the same filter I’ll include. Just follow these instructions:

    1. In includes/class-nelio-content-auto-sharer.php, around line 575, there’s this:

    $result = array(
      'id' => get_the_ID(),
      ...
      'permalink' => $permalink,
      ...
    );

    Change the permalink line to this:

    'permalink' => apply_filters( 'nelio_content_permalink', $permalink, get_the_ID() )

    2. In admin/class-nelio-content-post-helper.php, around line 416, you’ll find a similar pattern. Again, change this:

    'permalink' => $permalink

    to this:

    'permalink' => apply_filters( 'nelio_content_permalink', $permalink, get_the_ID() )

    Once you’ve done this, you’ll be able to create your own function as I described in my previous answer and replace WordPress’ permalink with Google shortener’s.

    Thread Starter capson

    (@capson)

    David, this is great, thanks for all of this!!!

    Plugin Author David Aguilera

    (@davilera)

    You’re welcome 🙂

    And, please, don’t forget to rate and comment on our plugin 😉

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Make a curly-bracket for the google short link’ is closed to new replies.