Jump to content

Recommended Posts

Hello can someone please help me i need to setup some shortcode here is the code that i what as shortcode.

 

<a href="<?php echo c2c_get_custom('main image'); ?>" rel="lightbox" title="<?php echo c2c_get_custom('title'); ?>"><img src="<?php echo c2c_get_custom('thumb'); ?>" width="60" height="45" alt="df" /></a>

 

Ive been looking at smashing magazines shortcode and come up with this.

 

function insert() {

    return '<a href="<?php echo c2c_get_custom('main image'); ?>" rel="lightbox" title="<?php echo c2c_get_custom('title'); ?>"><img src="<?php echo c2c_get_custom('thumb'); ?>" width="60" height="45" alt="df" /></a>';

}

 

add_shortcode('image', 'insert');

 

but i get errors im a newbie to php and would really appreciate some help. Or a push in the right direction. Do i need to escape all the " and ' are they clashing?

Link to comment
https://forums.phpfreaks.com/topic/177341-escaping/
Share on other sites

 

ah right ok thanks for the reply i will give this a try now so am i right in thinking this is correct.

 

function insert() {

    return '<a href='<?php echo c2c_get_custom("main image"); ?>' rel='lightbox' title='<?php echo c2c_get_custom("title"); ?>'><img src='<?php echo c2c_get_custom("thumb"); ?>' width='60' height='45' alt='df' /></a>';

}

 

add_shortcode('image', 'insert');

Link to comment
https://forums.phpfreaks.com/topic/177341-escaping/#findComment-935048
Share on other sites

is that a php function? if so you are getting errors because you are trying to open php tags in php tags. why are you doing that? and yes the multiple closing/opening single quotes are coinciding. Next time put code in code tags

 

function insert() {
    return '<a href="'.c2c_get_custom("main image").'" rel="lightbox" title='".echo c2c_get_custom("title")."'><img src='".c2c_get_custom("thumb")."' width="60" height="45" alt="df" /></a>';
}

Link to comment
https://forums.phpfreaks.com/topic/177341-escaping/#findComment-935068
Share on other sites

lol, wow. i overlooked it an at a glance assumed jscript. yeah dude escaping is to make it easier to place $var inline with html.

Escaping 101

  • standard html<div id="whatever">
  • escaped html<div id=/"whatever/">
  • shortcut html<div id='whatever'>

 

is that a php function? if so you are getting errors because you are trying to open php tags in php tags. why are you doing that? and yes the multiple closing/opening single quotes are coinciding. Next time put code in code tags

 

function insert() {
    return '<a href="'.c2c_get_custom("main image").'" rel="lightbox" title='".echo c2c_get_custom("title")."'><img src='".c2c_get_custom("thumb")."' width="60" height="45" alt="df" /></a>';
}

Link to comment
https://forums.phpfreaks.com/topic/177341-escaping/#findComment-935088
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.