-
Posts
1,655 -
Joined
-
Last visited
-
Days Won
51
Posts posted by maxxd
-
-
Not sure how that would have happened, but dude I feel ya' - losing WIP sucks. Check to see if your editor created a temp file somewhere or if there's an automated backup. Obviously, this is one of the benefits of using git but if you're not or you didn't commit or push, it may be rough. How exactly were you running the script that an infinite loop could have wiped your file?
- 1
-
U+2002 is a space. Is there a reason you're encoding it? I'm sorry, I don't trust 'invisiblecharacter.net' so I won't be visiting your link; perhaps you can explain further?
-
From what I can see 'inded' is a typo for index. What that means is that the URL you passed in to the function doesn't include a URL query. Use the null coalescing assignment operator instead of directly assigning the value.
-
Just getting back to this. According to the ThemeForest page the last update to this theme was in 2018. A lot has happened in both PHP and WordPress since then - it might be time to start shopping for a new theme. I can almost guarantee that if you're seeing these issues now you're going to see worse issues with the code in the future.
-
Nothing in the vast amounts of code you've posted has to do with creating the output in your screengrab. Post that output function and we can help.
-
Seeing as $subcategories is the common variable on both lines, I'd assume that is the problem. As of 7.2, php starting emitting a warning if the variable passed to count() isn't an array or another type that actually can be counted. I don't know what the 'knowledge template' is, but I'd bet it was developed before php7, and that sometimes there are no subcategories - this is probably leaving $subcategories null or 0, which isn't countable. Check to see if there's an updated version of the theme; if not you'll need to find where $subcategories is defined and make sure it's an array even if there aren't any subcategories to be found.
-
Ah, well that would explain it. I forgot about the Chrome extension bit...
-
I feel like something else is happening - this code works for me:
<script src="https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js"></script> <script> function setCookie(){ Cookies.set('testing2', JSON.stringify([{ testing1: 'hi there', testing2: 'whaddup?!?', testing3: 'how you doing?', }]), { expires: 3650 }); } var json_string = Cookies.get('testing2'); console.log(json_string); if(typeof json_string == 'undefined'){ setCookie(); json_string = Cookies.get('testing2'); } console.log(json_string); </script>
First time I visit the page, i get 'undefined' followed by the JSON string. Subsequent visits give me the JSON string both times.
The only real difference here is that I'm setting json_string from the cookie after I set it where you're hard-coding the value. But even then, you shouldn't be seeing the 'set new cookie' console log because after the first page load the cookie would be set.
What does your entire script look like? Are you getting any errors?
-
Your last post isn't the same code as your first. It's the code I told you to run - the parenthesis have nothing to do with it, it's using typeof result as a comparator, not in window.
-
Have you tried swapping this:
!(json_str in window)
with this:
typeof json_str == "undefined"
-
When dealing with cookies in Javascript, I usually use this library. In my experience it's just easier and less clunky.
-
Again - you're already in php mode, so using the opening and closing php tags is redundant and will throw an error.
Change this line:
header('link: < https://example.com<?php echo ($_SERVER['REQUEST_URI']); ?>>; rel="canonical"');
to this:
header('link: <https://example.com/'.$_SERVER['REQUEST_URI'].'>; rel="canonical"');
and see what that gives you.
-
You're already in php, so you don't need the `<?php echo` and `?>` around the $_SERVER['REQUEST_URI']. You will, however, have to concatenate as you're using single quotes for that header string and single quotes won't interpolate php code.
I'm not overly familiar with the `link` header so I can't say for certain, but I wouldn't be surprised if there were additional syntax errors on that line.
-
Is there a reason you're not just using the shortcode multiple times with different video IDs? The function just returns a number; you can add formatted text around the numbers.
-
I think I misinterpreted the original post. I read it as 'favorite of three flavors', not 'favorite three flavors'. Given that, I wouldn't recommend using an enum datatype. Personally, I'd probably go with a table to keep the flavors and another table to keep the votes. Count and group on select and everything's good to go. It's honestly just an over-engineered version of kicken's suggestion, but I have a tendency to over-engineer at the outset...
-
To make it even simpler (maybe), you could actually have a single column in your table - use an enum with the three flavors as the values. Each row represents a vote - then you can count and group by value.
Not sure it's worth doing this over kicken's suggestion, just another way to look at it.
-
It's been a while since I've dealt with WooCommerce and even in my current job my interaction with WP core has been limited so ymmv, but given you're talking about WordPress plugins I assume the global $post variable is available. If I remember correctly (and a quick SO search didn't lead my brain astray) you should be able to add `$order = new WC_Order($post->id);` before the code requinix suggested if you get an error with just that code alone. WordPress relies heavily on global variables and this unfortunately makes debugging difficult at times...
- 1
-
Whether it's padding or margin in this case doesn't really matter - the question could still be valid and of use to others. If you could explain a bit more fully what it is you're after and what you've tried we can all work to come to a solution that works regardless the target attribute.
-
That's what I get for responding grumpy and insufficiently caffeinated. I missed the whole part about skipping entries based on ID.
-
You've hard-coded a customer id of 1 into your query. Change that to be a prepared statement placeholder.
-
This is exactly the same as the question barand solved for you here less than 24 hours ago. Apply what you're being told.
-
What does your App\Models\Admin class look like?
- 1
-
The only margin of zero in your code is the top and bottom margins, and they'll be zero at any browser size.
I'm not gonna lie, I'm not completely sure I understand the question you're asking but it sounds like you may be looking for CSS clamp().
-
My life have ended help please
in PHP Coding Help
Posted
That is really strange; try opening the file in a plain text editor. It almost looks like it could be an issue with your editor (atom? i don't recognize the icon).