Jump to content

maxxd

Gurus
  • Posts

    1,655
  • Joined

  • Last visited

  • Days Won

    51

Posts posted by maxxd

  1. 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.

  2. 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.

  3. 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.

  4. <?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.

  5. 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.

  6. 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.

  7. 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...

  8. 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.

  9. 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.

  10. 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>");
    }
    
  11. 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.

  12. I have to agree with mac_gyver - a 6-second query is suspect. Post more details (table structure, query, etc.).

     

    Also, just because you're moving to an object-oriented approach doesn't mean you need to pull all the information every time you instantiate the object. You can always initially populate the quote object with the data you know you're going to need (customer details, total, and so on) and then grab the more esoteric or specific data when requested or needed. Granted, if the only purpose of the object is to build a quote view or report, then you will actually need all that data at once. However, I fail to see how - in that instance - the object would have to persist across page loads.

     

    Admittedly, I'm not a big fan of stuffing objects into session, but that's just me. I've seen some systems in the past where it just blew up everything one way or another. I can't say it wasn't programmer error (I wasn't working closely with that section of the code) so I may be unjustly biased, but there it is.

×
×
  • 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.