Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by maxxd

  1. From the jQuery documentation: The AJAX call will connect with the script assigned to the url parameter of settings object. In that script is where some action has to take place. For instance, in WordPress you pass a field named 'action' in your dataset to admin-ajax.php. admin-ajax.php then uses the value of that field to know what PHP functions to call in order to get you the data you need. What taquitosensei and I are suggesting is that you add the following to the end of he script - after the closing bracket of your class definition: $job_data = new jobsDatabasee(); $data = $job_data->getAllRoles(); die($data); and change `echo $json` to `return $json` inside the getAllRoles() method. Before you do that however, what does the response header show in your devtool's network tab after the AJAX call has been made?
  2. What taquitosensei just posted is what I was talking about. Ajax is connecting to the file jobsDatabase.php and will parse that file. But if there's no action in the script (like instantiating the object and calling the getallRoles() method), nothing will happen.
  3. Couple questions here, but the big one is this: you are calling the jobsDatabase::getAllRoles() method, right? In your ajax target script (../../../components/jobsDatabase.php) you instantiate a jobsDatabase object, then call getAllRoles() on that object, right? If so, then yes, it might make more sense to return from the method instead of directly outputting (you'd have to dump the returned value from the instantiated object). At this point var_dump() $json after your while loop and check the network tab of your browser's developer's tools to see what the output is. If you're not doing that, then that would be the problem - you're never going to get data from a method you don't call inside and object you don't instantiate.
  4. The email files are located in the woocommerce/templates/emails directory - I believe you're looking for the customer-processing-order.php file. Don't change the files in the plugin directory, though, or any changes you make will be overwritten next time the plugin updates. Create a /woocommerce directory in the root of your theme. Inside that, match the directory structure of the plugin's templates directory and copy the file there, then make changes to that version. In other words, copy /plugins/woocommerce/templates/emails/customer-processing-order.php file to /your-theme/woocommerce/emails/customer-processing-order.php. Make the change in the version that's in your theme directory.
  5. Excellent point about unicode and non-printable characters. And while I do agree there should be at least some sort of warning to people that obvious usernames should be avoided, I'd also say the user roles should be relevant to the application, not user names. So 'admin' , 'moderator', etc. are perfectly acceptable user roles and user names because the one has no bearing on the other. That being said, there's nothing at all wrong with dictating which should be used for logging in - and doing so minimizes chances of logic errors during the process.
  6. I have to disagree with @requinix about this - I find limiting the characters in usernames ickier than checking against both the username and email addresses. There should only be one instance of the email and the username in the database - remember, that's one instance each and not a combination of both. So if either exists in the database and the password matches, there's a not insubstantial assurance that it's the correct registered user.
  7. According to the documentation, find() returns null if the requested object isn't found. So check for null before you attempt the children() call - right now you're checking if $lis2 is greater than 0.
  8. @cyberRobot - I had the same thought about the 'download' attribute, but looking it up on MDN it's a legit attribute.
  9. Actually, what you posted and what @micky007 posted aren't quite equivalent. Here's yours: echo " Download <a href=".$file_path." download>Here</a>"; When parsed, this turns into: <a href=path/to/file download>Here</a> True, technically attributes don't need to be enclosed in quotes (last time I checked - that may be wrong now), but it is generally considered a good idea.
  10. I haven't done any php DOM manipulation or parsing in quite some time and as far as I can recall I've not used the Simple HTML Dom Parser library (usually just use DOMDocument), but from the docs it looks this could be what you're looking for: foreach($html->find('li') as $li){ print("<p>{$li->first_child()->innertext}</p>"); } The first_child() of each list item element should be the anchor tag, and innertext should return the contents of that anchor tag. Unless I'm not reading something correctly - it's been a long day, so it's very possible that I am...
  11. Another option would be to record the package cost to the customer with the specific customer row. A 'current_rate' field or a many-to-many table with `customerID`, `planID`, and `rate` fields. This way you could give discounts or charge somebody more depending on what mood you're in.
  12. Give this a try: $li = $html->find('li'); print("<p>{$li[0]->children[0]->attr['href']}</p>"); and see if you can follow the track through the output of the var_dump() function. Then try this: $li = $html->find('li', 0); print("<p>{$li->children[0]->attr['href']}</p>"); and follow that as well. Coupled with the documentation and the comments above, things will hopefully start to look a little clearer...
  13. They weren't intended to be copy and paste solutions. They were a mashup of the documentation and your code with the goal of showing you how the function call needs to be made to get you the results you want. Read the code, read the documentation, then apply logic. As @gw1500se says, $str1 isn't a string, it's an object with some properties that are arrays and it needs to be treated as such.
  14. It sounds like you're determined to make each package option an element of a form the sole purpose of which is to select a plan, just so you can use $_POST to get the value the user selected. My point is that you don't have to deal with form actions or button elements - just make each choice a link. Style it however you want, then pull the selection from $_GET on the target page and go from there. It's not a huge thing, but it's slightly less typing and potential troubleshooting for you and, from a coding and semantics perspective, it makes more logical sense.
  15. Look at some sites using that method (InMotion hosting comes to mind immediately). They're mostly links to pages, not buttons in a form. It seems like you're introducing quite a bit of unnecessary complexity to a fairly simple pattern. If you really wanted to, you could always just set the package to a session variable on load at the target pages from the comparison links (I hope that makes sense).
  16. Take a look at how you're making the call and how the documentation makes the call. I've updated the examples a bit to make the comparison more direct, I hope. Yours: $li->find('a')->first_child(); Theirs: $li->find('a', 0)->first_child(); And the error message: Call to a member function first_child() on array And finally, the documentation itself states (modified for emphasis): Hope that helps.
  17. I got a message with the actual code we've requested here... OP - if you want help with the task, post the code here and let all of us take a look at it. More eyes = more help, but remember this is your homework. So we will help, but we won't write it for you.
  18. Think it through. One of the things you'll see and hear about regularly in programming is 'pseudo-code' - write the steps you need the program to follow in order to solve the problem, then write the code to actually do it. So what do you need to do here? for the first 50 units of energy energy used add .10 to the total bill are there units left to bill? for the next 100 units of energy used add .15 to the total bill are there units left to bill? for the next 100 units of energy used add .25 to the total bill are there any units left to bill? for the rest of the units add .35 to the total bill take the total bill and mulitply it by .2 to figure the VAT add the VAT to the total bill output the total bill You need to look at conditional logic and math functions. There's a bunch of different ways you can do this, so write some code and post it here. If your throws errors post those, too.
  19. This means that the return value of PT_Secure($_GET['page']) is always 'category'. The problem is with PT_Secure() - check the documentation to make sure it's being used correctly.
  20. If you're visiting the 'trending', 'latest', and 'top' pages and seeing 'HELLOcategory text here' on all three (or any of the three, actually), then something is wrong with either PT_Secure() or your use of it because the value of $page is never not 'category'. Change die("<pre>".var_export($page, true)."</pre>"); to print("<pre>".var_export($page, true)."</pre>"); then visit the 'trending', 'latest', and 'top' pages and compare the output.
  21. The goal has been achieved. The script is doing exactly what you've said you wanted - you're printing custom text on each of the three specified pages; you're just not testing from one of those three pages. If you need custom text per page and don't want to limit it to the three listed pages, you'll have to account for those pages in your conditional logic.
  22. Change this $text = ''; $category_id = ''; $videos = array(); to die("<pre>".var_export($page, true)."</pre>"); $text = ''; $category_id = ''; $videos = array(); and see what it says.
  23. You're assigning a value to both variables, then sending both variables to PT_LoadPage(), where you print both out. So by showing both, your code is actually doing exactly what you're asking it to do. You've already got some logic to determine the page. Inside those logic blocks, you can set a value to $text that is specific to that page. Then only include $text as a parameter of PT_LoadPage(). That way, you'll know the variable is set no matter what page you're on but it'll be populated with page-specific data. You could also continue the way you're going and look into template conditional logic tags, but at that point you're mixing your logic and display code to an extant that's - IMO - missing the point of using a templating language anyway.
  24. I think the way you're doing it is not a bad solution. Grab an array of the IDs (select only the ID in order to make it a quick query) at first page load on initial visit to the site and store that in session or a cookie - it's not like the historical air date is going to change, so the data doesn't need to be all that fresh, honestly. Then you can grab the next or previous episode by the episode ID from the previously set and stored array.
  • 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.