Jump to content

maxxd

Gurus
  • Posts

    1,655
  • Joined

  • Last visited

  • Days Won

    51

Everything posted by maxxd

  1. What version of PHP is the staging server using? date_create_from_format() [DateTime::createFromFormat()] was introduced in 5.3.0 according to the docs.
  2. Look for a call to the function apply_filters() right around this area. The apply_filters() and do_action() functions are how WordPress allows themes and plugin to programmatically override core and extended functionality. If there is an apply_filter() call, I would think it would allow you to change the contents of the array the above function is creating. Of course, without knowing what theme you're using or what the rest of the code around this function looks like, I can't guarantee anything.
  3. Also, if this is a home-spun solution, is there a reason you've determined that the best way to understand the meaning of the 'd' array values is by position instead of named index? I know it's done a lot, but if you're creating this yourself why not make it a bit easier on everyone now and in the future by using logically named indexes?
  4. The cookie superglobal in PHP is $_COOKIE[], not $COOKIE[]. So that may be part of the problem you're seeing. And as long as you're using the jQuery cookie plugin (which I assume you are from the snippet you posted), you should be able to read the contents of the cookie with: console.log($.cookie('calc')); See this SO question for more details. Also note that the jQuery cookie plugin has been deprecated in favor of a non-jQuery dependent version.
  5. I'd highly recommend switching from mysqli to PDO if it's not too late for your project. It's much, much easier to deal with, especially regarding prepared statements. Just remember to turn off emulate prepared statements, which is on by default for reasons no one has yet been able to adequately explain...
  6. It does let you run JavaScript willy-nilly in a post or page body though, so there's always that...
  7. Actually, it's safe to say there are several problems with the way this is written. There are problems with the PHP (malformed conditional, malformed conditional block, nested double quotes in output), the WordPress specific code (malformed get_post_meta() call), the actual output (inline styling), and the basic tenets of modern programming (duplicate code). If you turn on error reporting (either PHP's error reporting or set WordPress's WP_DEBUG constant to true), you should see several rather helpful error messages.
  8. <?php foreach($images as $image): $opena = !empty($image['caption']) ? '<a href="'.esc_attr($image['caption']).'" data-lity>' : ''; $closea = !empty($image['caption']) ? "</a>" : ''; ?> <li><?= $opena; ?><img src="<?= esc_attr($image['url']); ?>" alt="<?= esc_attr($image['alt']); ?>"><?= $closea; ?></li> <?php endforeach; ?> Obviously the variable assignments can be refactored into a traditional if() block instead of two ternary statements if that makes it a bit easier to read - kind of up to you. You need to escape output in WordPress - it won't do it for you. Also, what's the data-lity attribute doing? You don't assign it a value anywhere that I see.
  9. Nope, nothing wrong with it at all. In fact, that's typically how it's done.
  10. First and foremost, please organize and format your source. You've got queries (some of which may be redundant - I haven't had enough coffee yet this morning to properly tell) mixed in with HTML, none of which is indented properly so it's difficult to see what you're actually doing. You're also opening and closing PHP at times to output straight HTML while at other times, you're printing the HTML from within PHP. It's all very confusing. I suspect this might be the reason you've not gotten a reply on this topic. However, to your actual question. It looks like (again, hard to read) you're using tables to display your products. Without JavaScript, you won't be able to add or remove table cells within a row depending on monitor size, and PHP is processed on the server, which doesn't know and doesn't care about your user's browser width. Try using something other than a table for output - look into flexbox. There are some gotchas depending on your browser support requirements, but those are easy enough to get around once you figure them out. And you won't be dependent on JS for proper output, which is going to make the site easier to style responsively.
  11. We'd need to see some actual code to see if there's an issue there. Having said that, you'll get shortcode working using the add_shortcode hook in your theme or plugin's functions file. It's also possible to use do_shortcode() in your template or functions file(s). In addition, from a quick Google search it looks like there are a couple WP plugins already developed that may make your life a bit easier, especially if you don't know WP or PHP.
  12. Personally, I don't find it confusing at all - I'll often write statements in the same manner.
  13. Well, that would certainly do it...
  14. Are you sure $home_team and $away_team contain the values you expect? Try printing them both before running the bank of queries.
  15. Is this in an object or function sheet? I don't see a scope definition on the function, but you use $this->logger->pushHandler(...) after creating a static $logger instance (no $this reference), which I'm not sure makes a lot of sense to begin with. I could be wrong on that last bit, though - it's been a long week...
  16. Sounds like in certain situations, the Answer object stored in answersessions isn't being instantiated. Take a look at the logic flow and see if there's a path around the instantiation.
  17. Sounds like in certain situations, the standard class object stored in answersessions isn't being instantiated. Take a look at the logic flow and see if there's a path around the instantiation.
  18. You're assigning $_GET['page'] to $action only if $_GET['page'] isn't set. How is any of this working for you?
  19. Admittedly it's early, but I'm not really sure what you're trying to accomplish with this logic. It sounds like you're trying to create a carousel on an image gallery, but doing a whole lot of work to do it. Is it not possible in your situation to create the gallery in the post? WordPress will typically create a div to wrap the gallery images that is assigned a class of "gallery". Use your functions.php file to include Slick Carousel on the appropriate pages, and use your theme's javascript - just target the gallery wrapper div in the Slick initialization options and tweak from there.
  20. In my experience, using namespaces requires a bit more work than that in the autoloader. For instance, to use requinix's example of "Site\LoginAttemptsLog" converting to "classes/Site\LoginAttemptsLog.class.php", that's not going to be a valid path due to the backslash. So you'd want to explode the class string on a backslash, then implode the resulting array using the directory separator as the glue. This'll give you an include path like "classes/Site/LoginAttemptsLog.class.php", which of course you'll want to test to make sure exists and is a readable file, plus other security checks and stops that Jacques1 can explain far better than I. As long as you follow the directory structure conventions, you should be golden. It's like the days of PEAR naming conventions where file names were long and words separated by underscores, except now the underscores are backslashes and you've got the ability to use the 'use' directive in your code to cut down on the amount of typing you have to do.
  21. If I'm understand what you're trying to accomplish, you could do something like this: $dt = new DateTime('now', new DateTimeZone('America/New_York')); print("<p>This is the date: {$dt->format('F j, Y')}</p>"); print("<p>It's the {$dt->format('W')} week of the year</p>"); if( ((int) $dt->format('W')) % 2 == 0 ){ print("<p>The week is even</p>"); }else{ print("<p>Odd week, eh?</p>"); }
  22. Thanks, kicken - I'll give that a try this morning!
  23. It should forward to domainA.com/domain-b-landing-page. PS - sorry for the silly domain names. Client property, and of course it all sounded better in my head while I was composing my post...
  24. Hey y'all. I've got two currently active domains (http://www.domainA.com and http://www.domainB.com) that I'm going to be combining next week. In other words, I'll be updating the DNS records to point to the same IP address. I need http://www.domainB.com to point to http://www.domainA.com/domain-b-landing-page and am not having much luck with RewriteRule or Redirect. I don't know if it complicates things a bit or not, but I also nee http://www.domainB.com/page/ to redirect to http://www.domainA.com/domain-b-landing-page/different-page. Right now (for testing purposes) I've updated my local hosts file to point both the existing domain names to the new IP address, and I can't get http://www.domainB.com to point to the correct page - it only points to the home page of domainA. Any URL with a sub-page from domainB doesn't redirect at all and only returns a 404. I've tried this to no avail: RewriteCond %{HTTP_HOST} ^domainB.com$ RewriteRule (.*) http://www.%{HTTP_HOST}%/domain-b-landing-page/$1 I'm hoping this makes some sense and somebody can point me in the proper direction.
×
×
  • 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.