• Resolved jaggerwarellc

    (@jaggerwarellc)


    Hi,

    I have been using a Style to create Buttons underneath images on my web site.

    So, I have an image placed onto my page using Add Media. In the Caption section I copy something like:

    [wpi_designer_button text=’CLICK HERE’ link=’/my-internal-post’ style_id=’38’ icon=’digg’ target=’_blank’]

    I do the very same thing on the same page, but not inside an image. When outside of an image, the button shows up correctly. When inside the image, no button shows up.

    I can provide a link to my web site if needed.

    I’ve turned off all other plugins and I still get the same behavior. I’ve turned off all of my caching plugins and turned off Minify options in CloudFlare. But, still seeing this issue. I think this started happening in the last 3 or 4 days. But, not 100% positive about that (just noticed a big drop in conversions over that time).

    Thanks in advance for any help you can provide!

    Regards,
    sjmyst

Viewing 15 replies - 1 through 15 (of 17 total)
  • Thread Starter jaggerwarellc

    (@jaggerwarellc)

    FYI, I copied back in older copies of WPi Designer Button plugin, and that didn’t fix the issue.

    Could this be an issue with the latest WordPress (4.7)?

    Regards,
    sjmyst

    Plugin Author WooPrali

    (@wooprali)

    Hi,

    Thanks for using designer button.

    Please give me the website link.

    I will check and try to find the issue.

    Regards,

    Pralu

    Thread Starter jaggerwarellc

    (@jaggerwarellc)

    Pralu,

    Thank you for creating such a great plugin.

    Here is an example page that is seeing this problem:

    https://www.dakotasays.net/the-best-puppy-food-for-german-shepherd-breeds/

    As you can see on this page, the button style is working at the beginning and the end of the page. However, the last three images also have button styles and they are not showing up. For example, for the last image that shows Royal Canin dog food, create that image from the WordPress Edit Post page by:

    – Selecting the “Add Media” button
    – Entering the following text into the Caption field:
    [wpi_designer_button text=’ADOPT ABUNDANCE’ link=’/amazon/RoyalCaninGermanShepherdAdultDryDogFood’ style_id=’38’ icon=’digg’ target=’_blank’]
    – Enter Alternate text “Royal Canin Breed Health Nutrition German Shepherd Adult dry dog food”
    – Under Display settings I choose Align right
    – Under Display settings change Link To to ‘Customer URL’, and in the text box I enter ‘/amazon/RoyalCaninGermanShepherdAdultDryDogFood’ (which is another link on my site.
    – Under Advanced Options I check the ‘Open link in a new tab’

    I have done the same thing for the two images before the Royal Canin image.

    Let me know if you need anything else.

    Regards,
    sjmyst

    Plugin Author WooPrali

    (@wooprali)

    Hi,

    I tried to find out the issue.

    Actually the problem is in wordpress caption shortcode. it is not supporting shortcodes placed inside the caption field.

    if you really need this feature and it is important. then i will try to add extra feature to designer button plugin.

    regards,

    PRALI

    Thread Starter jaggerwarellc

    (@jaggerwarellc)

    Yes, this is a pretty important feature for my web sites. It allows me to put a Button below my affiliate images. And, the Button (as you know or you probably wouldn’t have created this plugin), makes it much more obvious to readers/shoppers to click through.

    I would really appreciate if you could make this work or help to get WordPress to “fix” it’s code to allow short codes again. I’m guessing that change to WordPress wasn’t intentional.

    Thank you in advance for any help you can provide.

    Regards,
    sjmyst

    Plugin Author WooPrali

    (@wooprali)

    Hi,

    Please install the latest version of designer button plugin v2.5.9.

    and follow this steps how-to-use-shortcode-inside-the-caption-text-of-image

    If any issues please let me know.

    Regards,

    PRALI

    • This reply was modified 7 years, 10 months ago by WooPrali.
    • This reply was modified 7 years, 10 months ago by WooPrali.
    Thread Starter jaggerwarellc

    (@jaggerwarellc)

    PRALI,

    Thank you for looking into this. However, this didn’t fix this issue for my web site.

    I did upgrade the plugin to the version you stated above. I flushed all of my caches (at all levels) and made a change to a page to make sure the change was being seen. However, the image was still not showing the button like it was before. No button is seen.

    Let me know if there is a way I can help.

    Regards,
    Steve

    • This reply was modified 7 years, 10 months ago by jaggerwarellc.
    Plugin Author WooPrali

    (@wooprali)

    hi,

    did you check this link https://designerbutton.prali.in/how-to-use-shortcode-inside-the-caption-text-of-image/.

    did you replace the shortcode from “caption” to “wpi_caption”?

    Let me know if you did above things.

    Bcoz its working in my website.

    regards,

    PRALI

    • This reply was modified 7 years, 10 months ago by WooPrali.
    Thread Starter jaggerwarellc

    (@jaggerwarellc)

    PRALI,

    I’m sorry. I didn’t see your instructions. My bad.

    I was able to make this work. And, I DO really appreciate you adding this…

    However, this is really going to be a difficult change for me. I have probably 75 or more pages each with 4 or 5 of these links I now have to change using this procedure. If that were all, I could “suck it up” and make the changes. But, it’s not only the procedure that doesn’t really work well. After I make the change following the procedure, the [wpi_capture…]…[/wpi_capture] text shows up in the middle of my post when I go back from Text mode to Visual mode. It really makes it difficult to see how the page will show up when live.

    I am TRULY glad I have a path forward. And, I do appreciate you working on this and getting me something very quickly. But, is there no other way to do this that doesn’t require this multiple step process and doesn’t “clutter” the Visual mode with something like the following showing up in the middle of my text while in Visual mode:

    [wpi_caption id=”” align=”alignright” width=”327″]Title (our choice for The Best Puppy Food For German Shepherd Breeds) [wpi_designer_button text=’EAT EUKANUBA’ link=’/amazon/EukanubaBreedSpecificAdultDryDogFood’ style_id=’38’ icon=’digg’ target=’_blank’][/wpi_caption]

    If there isn’t another way, I’ll live with it.

    Do you think there is a possibility that WordPress will recognize that they made a change that is affecting plugins like yours and will return to previous behavior?

    I do thank you for your hard work on this!

    Regards,
    sjmyst

    • This reply was modified 7 years, 10 months ago by jaggerwarellc.
    Thread Starter jaggerwarellc

    (@jaggerwarellc)

    PRALI,

    If you can’t improve on what you’ve already provided, can you give me a “coders” description of what the problem is so I can report it to WordPress?

    At a high level, I think the description would be that special plugin codes entered into the Caption field in an image are stripped out by WordPress before the plugin can convert the special plugin code into HTML. Special plugin codes look like “[plugin_code plugin_parameters …]”.

    Anything else you can add to make this more clear to WordPress developers?

    Or, do you think this isn’t something that might be fixable by WordPress?

    Regards,
    sjmyst

    Plugin Author WooPrali

    (@wooprali)

    Hi,

    Its simple.

    Ask them to add one line of code to get required result.

    File: wp_includes/media.php.
    Function: img_caption_shortcode()
    Line: 1520
    Code: $attr['caption']=do_shortcode($attr['caption']);

    Above code should be added after line 1520.

    Hope this will solve your problem.

    Regards,

    Prali

    Thread Starter jaggerwarellc

    (@jaggerwarellc)

    Excellent!!

    Thank you for your very strong support.

    Off to give you a 5 star review (if I haven’t already). I looked for a Donate using Paypal button (or something similar) to buy you a cup of coffee (all I can afford with my new sites), but I wasn’t seeing a place for that.

    Regards,
    sjmyst

    Thread Starter jaggerwarellc

    (@jaggerwarellc)

    Prali,

    I decided to try and patch my version of WordPress with your suggested change until something can be done in WordPress.

    I tried, but it doesn’t seem to work for me. Unfortunately I had upgraded to WordPress 4.7.1, so maybe the line numbers don’t line up.

    Can you confirm that the line you suggested to add above line 1520 should look like the following (I’ve copied the statements before and after where I think you were suggesting to add this line:

    $atts = shortcode_atts( array(
    ‘id’ => ”,
    ‘align’ => ‘alignnone’,
    ‘width’ => ”,
    ‘caption’ => ”,
    ‘class’ => ”,
    ), $attr, ‘caption’ );

    $attr[‘caption’]=do_shortcode($attr[‘caption’]);
    $atts[‘width’] = (int) $atts[‘width’];

    Would that be where your suggested change would go?

    Thanks in advance for all of your help with this.

    Regards,
    sjmyst

    Plugin Author WooPrali

    (@wooprali)

    Hi,

    please check this code from wp_includes/media.php.

    
    function img_caption_shortcode( $attr, $content = null ) {
    	// New-style shortcode with the caption inside the shortcode with the link and image tags.
    	if ( ! isset( $attr['caption'] ) ) {
    		if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) {
    			$content = $matches[1];
    			$attr['caption'] = trim( $matches[2] );
    		}
    	} elseif ( strpos( $attr['caption'], '<' ) !== false ) {
    		$attr['caption'] = wp_kses( $attr['caption'], 'post' );
    	}
    	
    	$attr['caption'] = do_shortcode($attr['caption']);
    
            /**
    	 * Filters the default caption shortcode output.
    	 *
    	 * If the filtered output isn't empty, it will be used instead of generating
    	 * the default caption template.
    	 *
    	 * @since 2.6.0
    	 *
    	 * @see img_caption_shortcode()
    	 *
    	 * @param string $output  The caption output. Default empty.
    	 * @param array  $attr    Attributes of the caption shortcode.
    	 * @param string $content The image element, possibly wrapped in a hyperlink.
    	 */
    	

    Find “img_caption_shortcode” function in media.php
    in that function code I added $attr['caption'] = do_shortcode($attr['caption']); after if condition and before comments.

    Regards,

    PRALI

    • This reply was modified 7 years, 10 months ago by WooPrali.
    • This reply was modified 7 years, 10 months ago by WooPrali.
    Thread Starter jaggerwarellc

    (@jaggerwarellc)

    Excellent… Much better!

    You saved me several hours of trying to learn the internals of WordPress. I code for a living, but have done very little with PHP (although the syntax seems very similar to many other languages). But, the WordPress internals would have been a lot more challenging since I’ve only looked at a few files and don’t know ANYTHING about how things are structured.

    Even though I’ll have to remember to “patch” this file for each WordPress upgrade, I think this will be a much easier solution for me until WordPress “fixes” this (if I can get them to do that).

    YOU ROCK!!!

    Thanks for this workaround! It’s going to be a life saver for me.

    Regards,
    sjmyst

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Button stopped working inside image captions’ is closed to new replies.