Forum Replies Created

Viewing 15 replies - 1 through 15 (of 23 total)
  • Thread Starter sarahjadesigns

    (@sarahjadesigns)

    Finally had the chance to look into this. It wasn’t enough to swap file_get_contents() with wp_remote_get() – this would give an error about the line below with json_decode() needing a string.

    By wrapping $filecontent on that line in wp_remote_retrieve_body() (thanks Google!), the code now works. Full function below.

    function full_comment_count() {  
    global $post;  
    $url = get_permalink($post->ID);  
          
    $filecontent = wp_remote_get('https://graph.facebook.com/?ids=' . $url);
    $json = json_decode(wp_remote_retrieve_body($filecontent)); 
    $count = $json->$url->comments;  
    $wpCount = get_comments_number();  
    $realCount = $count + $wpCount;  
    if ($realCount == 0 || !isset($realCount)) {  
        $realCount = 0;  
    }  
    return $realCount;  
    }
    Thread Starter sarahjadesigns

    (@sarahjadesigns)

    Thanks @ipstenu. My skills with PHP pretty much only extend to be able to tweak things a tiny bit. When it comes to function building, I have a pretty fuzzy understanding.

    Comparing your info on wp_remote_get() and file_get_contents(), I get the sense that the main difference is that the former allows you to fetch an external URL. Could I then just swap it like so?

    function full_comment_count() {  
    global $post;  
    $url = get_permalink($post->ID);  
          
    $filecontent = wp_remote_get('https://graph.facebook.com/?ids=' . $url);
    $json = json_decode($filecontent);  
    $count = $json->$url->comments;  
    $wpCount = get_comments_number();  
    $realCount = $count + $wpCount;  
    if ($realCount == 0 || !isset($realCount)) {  
        $realCount = 0;  
    }  
    return $realCount;  
    }

    Or is there more I need to do with wp_remote_get() to get a combined count of Facebook and WordPress comments for a post?

    Thread Starter sarahjadesigns

    (@sarahjadesigns)

    Looks like zlib was enabled on both with PHP 5.6 and 7.4. I tried switching to version 8.0 to see if whatever issue had been resolved with that one, but that just gives me a big fat WordPress error and the site won’t load at all.

    I’m completely at a loss for how to fix this. Any other insight would be appreciated.

    Thread Starter sarahjadesigns

    (@sarahjadesigns)

    Thanks for clarifying. I did have a look at the extensions in my cPanel, but didn’t find anything similar to zlib, which is why I thought I maybe had initially misunderstood your link. I’ll get in touch with my host and see if they can help me get to the bottom of this.

    Thread Starter sarahjadesigns

    (@sarahjadesigns)

    Thanks @joyously, I did read it. However, this bit and the supporting links about fopen wrappers are sort of Greek to me, as I don’t know enough about PHP to code it from scratch. Is the notion that I can just swap out file_get_contents() with fopen(), or is there more I need to do here?

    Thread Starter sarahjadesigns

    (@sarahjadesigns)

    I’m not sure what you mean @joyously, the info at the top of the page you linked seems to indicate it works with versions 5, 7 and 8. Even the changelog further down indicates as much.

    But if I’m misinterpreting this, then what could I do to replace file_get_contents()?

    This worked great, thanks for the fix!

    Forum: Plugins
    In reply to: [AJAX Contact] Get user IP
    Thread Starter sarahjadesigns

    (@sarahjadesigns)

    I’d like to add that I’ve been able to add a function to my theme which displays the visitor’s IP (see what I used here). This displays the IP when you use the shortcode [ show_ip ]. It works on pages and posts without a problem. But I can’t get it to work in the hidden field, either by typing it enclosed in single [ ] or double [ [ ] ] square brackets (the forum is doing funny stuff with displaying stuff between square brackets, hope this is clear).

    Thread Starter sarahjadesigns

    (@sarahjadesigns)

    Hmm, couldn’t get it to work with those settings either, weird.

    In any case, I managed to fix my issue, so thank you very much ??

    Thread Starter sarahjadesigns

    (@sarahjadesigns)

    Hello Andrew,

    Thanks again. Yes, I did need overflow: hidden; but I see now that this is the problem and I can probably work my way around this.

    I am aware of this feature in Chrome, but when I set the emulation panel to iPhone 5, I did not get this result. It appeared as I want it to be, not how it actually did on my phone. I’ve not found this panel to accurately replicate what I see on my mobile in the past, may I ask what settings you’re using to get this result?

    And thank you again for your help.

    Thread Starter sarahjadesigns

    (@sarahjadesigns)

    Hi Andrew, thanks for catching that. I had a missing </div> in the sidebar.

    Unfortunately this did not fix my problem. All the other flags from the validator are unrelated to this navigation.

    Thread Starter sarahjadesigns

    (@sarahjadesigns)

    Hi Stefanus,

    It has been intriguing me why someone would want to add the title attribute to an <img>, so I did a bit of research.

    First, I want to apologize for my previous comments which dismissed your wanting to use the title attribute and saying it is not possible to add it to anything other than links. Somehow in my 15 years of coding HTML, it has completely escaped me that this is an attribute you can add to all visible HTML tags.

    Still though, I was wondering what the best approach would be for SEO purposes. Should the title attribute be added to the <img> tag, the <a> tag or both?

    If you’re wanting your images to come up in Google search results, then use it on your <img> tags. If you want to improve your site’s ranking in Google, don’t bother with it on <img> tags, Google tends to focus on the information in the ALT text. Still though, nice to use it on <a> tags to get the friendly tooltip. This you can do with Drew’s code above.

    If you still want to apply the title attribute to your <img> tags for image searches, try the code below based on Drew’s solution. Please note that I’ve not tested this myself.

    Change line 1860 in wp-content/plugins/easyrotator-for-wordpress/engine/main.php from:

    $codeOut .= '<img class="main" src="' . htmlspecialchars($src) . '"';

    to:

    $codeOut .= '<img class="main" src="' . htmlspecialchars($src) . '"' title="' . htmlspecialchars($title) . '"';

    Thread Starter sarahjadesigns

    (@sarahjadesigns)

    Hi Stefanus,

    I meant what is the result you want on your website? If I go to your site now and hover over your slider, I see specific text for each image. “Modular Buildings”, “Multi House”, etc. This is what my original post was asking how to do, and it seems you’ve been able to do it successfully too.

    In HTML, there is no such thing as a title attribute on <img> tags. Even if you added it, it would have no effect, because browsers don’t recognize this as a valid HTML attribute.

    So what is it you’re trying to change on your site’s slider now?

    PS Can you edit your original post so your code is in wrapped in backticks and doesn’t mess with the format of this page?

    Thread Starter sarahjadesigns

    (@sarahjadesigns)

    Hi Stefanus,

    Can you clarify what you’re trying to do? The title attribute is added to link tags, not image tags. You might be mixing it with alt attribute that you can add to image tags.

    What I was wanting to do is add the article’s title as hover text on each slide: https://lucky-stars.ca/ptp

    If you go in to edit the plugin file like Drew shows above, you’ll get the same result.

    If you want to add the alt attribute to your images, that’s a another question altogether ??

    Thread Starter sarahjadesigns

    (@sarahjadesigns)

    Found a solution. It doesn’t explain why the problem was happening only on children of the front page, but fixes it nonetheless.

    When editing the page, under Sidebar (bottom right), I chose Primary Widget Area from the drop-down, which is the content of my Default template’s sidebar.

Viewing 15 replies - 1 through 15 (of 23 total)