Jump to content

maxxd

Gurus
  • Posts

    1,655
  • Joined

  • Last visited

  • Days Won

    51

Everything posted by maxxd

  1. Highly recommend PHPMailer instead of native PHP mail(). It's much easier to use and offers robust debugging when you run into problems. I don't have direct experience (mostly because I haven't used native mail() in a long time) but PHPMailer is apparently more reliable as well.
  2. I'm not sure how WP handles the oEmbeds any more, but I'd say try firing your hook later. The third parameter to add_filter is a priority - set it to like 100 or something high. It's possible that somehow what you're doing is interfering with however WP handles oEmbeds in the content.
  3. If you're using webpack or a build process, you can uselet let jqueryui = require('jquery-ui'); That should give you access to the functionality through the jqueryui object.
  4. It sounds like you want to sort by geographical distance when searching address but by post ID when other fields are searched? If so there are a couple options - either you're doing the WP_Query call manually (the global $gmw_query variable makes me think this is the case) at which point check the search parameters and update the ORDER BY clause there. Or, this is hooked into a generic WP query at which point you'll want to use the posts_orderby hook to see if the post in question is a search and modify the ORDER BY clause appropriately.
  5. Hey y'all. I'm currently working on a project at work and it involves creating a package with assets. Laravel's ServiceProvider has the loadRoutesFrom() and loadViewsFrom() methods which are all well and good, but the only solution I can find in the documentation or code for syncing javascript, font, and style files from the package to the full Laravel install is to run the artisan publish command. This means I'd have to run the publish command every time I make a change which is clearly not a solution I'm excited about. My solution at the moment is to use a symlink from the compiled assets location in the package directory to the appropriate directories in the public webroot of the overriding install - all good and working except for one thing. When I use the mix() helper in my view to load the javascript files they can't be found [ie: <script src="{{ mix('packagename/js/main.js') }}"</script>] where packagename is the symlink; however, when I point directly to them it works perfectly [ie: <script src="packagename/js/mix.js"></script>]. The asset() helper function works just fine. My only concern with just linking directly is that now I can't use versioning in my mix build process, my tester has a computer that caches aggressively. TL;DR - has anyone come across a situation where Laravel's native mix() function can't traverse a symlink or is this something known in the php ecosystem that I've somehow never come across before?
  6. Use php to set a variable containing the number of rows in the HTML. Then use JavaScript to get that variable, check it, and react accordingly. Don't mix the two like you've done - technically, it's kinda possible but as you're seeing now it's a complete pain.
  7. If you're dealing with SVGs I highly recommend looking at GreenSock - it abstracts away a lot of the annoying crap you have to deal with when using SVGs and canvas.
  8. No, backslash is an escape character. Note how every character after a backslash is red in your screencap - that means it's being interpreted as a command character (tbh I'm not sure that's the right term - it's being interpreted as something other than a simple character in a string). So where you have `\`, you should have `\\` - this will escape the second backslash and make the interpreter read it as a character in a string. So, basically "C:\Program Files\your\path\php.exe" becomes "C:\\Program Files\\your\\path\\php.exe"
  9. I'm glad to know Mustache.php is still active - it's the first template system I used in php. Right now I'm using mostly Laravel so I'm on Blade, but before that I was using Twig, which is syntactically very similar and just kinda awesome.
  10. Doing my digging and it appears this is chapter 4. Code from the sample: <?php Require_once("e10dog.php"); $lab = new Dog; // ------------------------------Set Properties-------------------------- $dog_error_message = $lab->set_dog_name('Fred'); print $dog_error_message == TRUE ? 'Name update successful<br/>' : 'Name update not successful<br/>'; Note the lack of 'bool' before $dog_error_message. I'm not trying to be a jackass here, but when you're learning a language you have to read the tutorials completely, follow them accurately, and listen to the people who know what they're talking about when they try to help with any confusion.
  11. lab.php does not define a class. It uses a class - these are two very different things. Look at my previous examples and the use of the word 'class'. Then compare that to your own files; I think you'll see the important difference. I don't have Learn PHP 8 from apress, but the source is available through github. What chapter is this lesson?
  12. Right. And I see where you instantiate an instance of that class in the global namespace, right before you try to type a variable in that same global namespace. The code you're showing isn't inside a class or a method/function signature. For instance, <?php class Testing{ private bool $truefalse; } is perfectly valid, because it's inside a class. <?php function testing(bool $truefalse){ echo $truefalse; } is also perfectly valid as that's typing a function parameter. However, <?php bool $truefalse = false; is not valid, as it's not within a class or function.
  13. But in the code you've posted, you don't have a class. You can type method/function parameters and class properties, but as far as I've found trying to type variables in the global namespace doesn't work even in 8.0. What book are you using?
  14. All that having been said, understand that any time span type calculation is ... just harder than it should be. You look at it and it's like "oh, yeah - no problem". Then you start actually working on it and it's far more complicated than you might think. So even the idea of comparing not only start time and end time as implied above, you suddenly then have to consider potentially time zones and then daylight savings time (which is it's own barrel of fish)...
  15. Where you assign $day_end_each, you've got several (frankly, redundant) calls to date() to define the month, day, and year. Replace those calls with specified values and you can set any date you'd like. However, I have a sneaking suspicion that the problem may lie with the direction of your comparison. It seems like your query is working when considered from the start of the shift, but there's no consideration for the end of the shift. So perhaps there needs to be a condition that looks at $row['shift_'.$i.'_end'] or $row['shift_'.$i.'_start'] + $shift_duration (or something similar)?
  16. I would start off by using var_export to dump the result of each of your conditionals. echo "<pre>".var_export(date("Y-m-d", strtotime($row["shift_" . $i . "_start"])) == date("Y-m-d", strtotime($date_each)), true)."</pre>"; echo "<pre>".var_export(date("Y-m-d H:i:s", strtotime($row["shift_" . $i . "_start"])) <= $day_end_each, true)."</pre>"; echo "<pre>".var_export($row["member_shift_" . $i . "_on_call"] == 0, true)."</pre>"; From there you can check if and where your logic chain is failing, and that'll give you a more specific place to start actually debugging.
  17. You've got three conditionals happening in your if statement - do you know that $day_end_each is the part that's failing? Print out each of your conditionals and make sure you're focusing on the right one. Having no idea what $row['shift_{$x}_(start|end|on_call)'] actually contains, there are several ways the comparisons may have gone wrong.
  18. Highly recommend this book if you're getting into patterns and more advanced OO concepts: https://www.amazon.com/PHP-Objects-Patterns-Practice-Enhancements/dp/1484267907/
  19. You also need to escape the slashes in your path.
  20. Sounds like you're looking at a facade pattern? Or maybe composite or adapter depending on how you want to use the objects.
  21. To clarify, it's standard practice to omit the closing tag in files that only include PHP. If you're mixing your PHP into HTML (which is it's own kettle of fish) you can either close the PHP block before you write your HTML or - as ginerjm mentioned - you can use a heredoc and then output the markup from that variable.
  22. Yeah, in CI it's a flash message - same general idea insofar as i recall.
  23. This is typically called a toast notification. For instance, if you happen to use Laravel you'd install toastr as a dependency in pacakge.json: "dependencies": { "toastr": "^2.1.4" } Create a toast component or partial: <script> @if(Session::has('message')) window.toastr.success("{{ session('message') }}"); @endif @if(Session::has('error')) window.toastr.error("{{ session('error') }}"); @endif @if(Session::has('info')) toastr.info("{{ session('info') }}"); @endif @if(Session::has('warning')) window.toastr.warning("{{ session('warning') }}"); @endif </script> Include that component/partial in your main template file: @include('components.toast') Finally, set the message in $_SESSION like so: return Response::redirect('/dashboard')->with('message', 'Data Saved!'); Obviously if you're not using Laravel you'll have to do some digging but hopefully that's a decent starting point.
  24. Sounds like you want a Markdown library. I can't say for sure as I think I'm the one person on the planet that's not used Reddit, but `>` denotes a blockquote in most Markdown versions I've come across. If you Google it, there are many PHP libraries that can help you out.
  25. Give the documentation, it looks like the functionality you want is the default. I've not used DataTables but I'd start by removing the `columns: ':visible'` from your exportOptions object; the pages aren't visible so that may have something to do with it.
×
×
  • 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.