-
Posts
1,698 -
Joined
-
Last visited
-
Days Won
53
Everything posted by maxxd
-
Good point, Ch0cu3r. It's not going to magically make the links pretty, but it will interpret pretty urls in the same way as the traditional links. Now, you'll probably have to employ a routing system as well.
-
Is mod_rewrite is enabled on your server?
-
I haven't read the entirety of this article yet, but it should get you pointed in the right direction.
-
I would check out Selenium automated testing - I believe it reports on load and render time. Don't quote me on that, but I believe it does.
-
Why are you using json at all? You encode the query results, immediately decode the results, then decode the results again when you print. If you just get the result set, what does that look like?
-
Your ipn.php code is connecting and selecting the DB using mysql_, but using mysqli_ for the interaction. Change the connection and selection calls.
-
get_stylesheet_uri() doesn't take parameters. You'll need to do get_stylesheet_uri().'/../css/style.css';
-
Style a wordpress admin dashboard for page of a plugin
maxxd replied to Nonno's topic in PHP Coding Help
admin_enqueue_scripts is the correct hook to use, but your unction checks the value of $hook that gets passed in. Print that out and make sure that it equals 'hotels.php', not 'admin.php?page=hotels' or something else. -
Style a wordpress admin dashboard for page of a plugin
maxxd replied to Nonno's topic in PHP Coding Help
So, wait - do you want to style the page, or add controls to the page? If you're looking to style what's there, check the page source and make sure that your style sheet is being included. It could just be a targeting issue within the .css. Also, try printing the value of $hook to screen - looking at it, I'm not sure that WP is going to deliver "hotels.php", but rather something along the lines of "admin.php?page=hotels". If you want to add controls, start reading here - https://codex.wordpress.org/Settings_API and here - https://codex.wordpress.org/Creating_Options_Pages. -
Style a wordpress admin dashboard for page of a plugin
maxxd replied to Nonno's topic in PHP Coding Help
Try using wp_enqueue_style() instead of wp_enqueue_script() to queue up your style sheet. Not sure if it'll make a difference, but it might... -
Right. As I said, target was just a thing - assign the value of that to a variable you can use. If you're passing in a string reference to the DOM object (for instance: swapContent('http://myURL.com', array('testing','more'), 'myDivID'); ), this should work for you: var tgt = '#' + target; $(tgt).html('<p>Woot</p>'); If you're passing in the DOM object itself (as such: swapContent('http://myURL.com', array('testing','more'), $('#myDivID')); ), just use it directly: tgt.html('<p>Woot!</p>');
-
Is $ds defined in the function (or function sheet) you're altering? Check the code on the page you're using as an example - it's probably (I'm assuming you're using WordPress) a global, and you should be able to use it by adding global $ds; at the top of the function. However, it's difficult to tell without looking at the code.
-
Create downloadable CSV file using AJAX question(s)
maxxd replied to maxxd's topic in PHP Coding Help
Yeah, I understand that JS won't save the files, just thought it could initiate the request to the user to save the file. Thanks for the link to the plugin - I'll check that out! -
Create downloadable CSV file using AJAX question(s)
maxxd replied to maxxd's topic in PHP Coding Help
Thanks guys (or gals, not sure). The thing is, I've seen this method work for a dynamically created .zip file before, and can't quite figure out why it's not doing anything for a CSV. I'll give a shot to the redirect method, which hopefully will work in WP. And thanks much for the heads-up on the output stream. I'm not terribly excited about the prospects of writing and deleting a file on the server every time my client wants to export the data, so that'll put my mind at ease a bit! -
Convert from Hard-coding to Algorithmic Coding
maxxd replied to illdefinedartistry's topic in PHP Coding Help
Try setting the $keys array index to the post ID? I'm honestly not entirely sure what you're hoping to see as the output. Right now, the $keys array is going to be a numerically-indexed array of page slugs, so the select options are probably going to look a lot like this: <select value='1'>page_slug_1</select> <select value='2'>page_slug_47</select> <select value='3'>page_slug_15</select> etc.. If you want to associate the page with it's slug, create the array like this: foreach($pages as $page){ $keys[$page->ID] = $page->post_title; } then use $keys as the value of 'options'. I'm not familiar with the Quemalabs theme, so I don't know exactly how you're creating the select box, but from what you've said I think this'll work for you. -
Convert from Hard-coding to Algorithmic Coding
maxxd replied to illdefinedartistry's topic in PHP Coding Help
Try removing the second array_fill_keys() and adjusting to 'options' => $objects. I don't have time to test, but it looks to me like you're putting the array $objects into each index of $options. -
Hey y'all. I've dug around on SO and other sites, and pretty much everything I'm finding is making me think that what I'm doing here should be working. Problem being, it's not. First, a little background. I'm trying to create a CSV export of a WordPress back-end report that I've built and have had working for a bit now. I'm using AJAX to gather the data for both the display and the export. So, the user selects a date range, clicks 'Go', and the system uses AJAX to populate the report data into the table as expected. At this point, the user can click the 'Export' button, and - theoretically - once again the page uses AJAX to gather the data and display a 'Save as...' window with the newly generated report. My PHP code: public function exportReportData(){ $data = $this->gatherReportData(false); $tmp = tempnam(sys_get_temp_dir(), 'your_csv_dl'); if($tmp === false || !file_exists($tmp)){ print(json_encode(array('success',false))); exit; } $fileName = 'report_'.(new \DateTime())->format('Ydmhis').'.csv'; $handle = fopen($tmp,'w'); foreach($data as $row){ fputcsv($handle,$row); } fclose($handle); header('Content-Description: File Transfer'); header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename='.$fileName); header('Expires: 0'); header('Cache-Control: no-cache must-revalidate'); header('Pragma: public'); header('Content-Length: '.filesize($tmp)); readfile($tmp); unlink($tmp); exit; } The system outputs the expected data - I can view it in my console. However, it doesn't pop up the expected 'Save as...' dialog, and I have no idea why. I've tried Content-Type: application/octet-stream, text/csv, application/csv, and a couple others that I can't remember right now. So, a couple questions - first off, the obvious. Does anyone see anything in the code above that's causing it to not work as expected? Did I leave something out, use the wrong value for a header, name something incorrectly, anything at all? Secondly, if I'm creating the file in the server temp directory, is it necessary to unlink() it at the end of the script, or will garbage collection take care of it on it's own? Any and all help is much appreciated, and thanks for taking the time to take a look.
-
Why not define the system path in the constant? Instead of 'http://example.com/site/2/' use '/public_html/your_account/site/2' - this way you can put your included files above the web root for security if you want, plus you still only have to change the constant value once across the site.
-
If you're looking for CSS compatibility information, check CanIUse.com. As far as Safari support goes, modern versions on the Mac handle vh and vw just fine. If someone's using it in a Windows environment, well... support was dropped for that quite some time ago.
-
It's possible the error is referring to the attempt to read $_REQUEST['sort'] - try print("<pre>".print_r($_REQUEST, true)."</pre>"); before line 15. Also - and this is more a personal preference, so take it with a grain of salt and all, but don't use $_REQUEST. Variables in the $_REQUEST superglobal can come from $_GET, $_POST, $_SESSION, or $_COOKIE. Know what data you're looking for and where to find it. If you submit your form using post, check $_POST; if you submit using get, check $_GET.
-
Set up the frequency as DateInterval() objects, then feed them to DateTime::add() as necessary. DateTime::add() - http://php.net/manual/en/datetime.add.php DateInterval() - http://php.net/manual/en/class.dateinterval.php
-
The $('#target').innerHTML was kind of a stub. I should've mentioned the code wasn't tested - sorry. My point was to get you moving in the right direction, not give you a cut and paste solution. It looks like you're passing target as a DOM reference, so the way you've got it set up now should be working. What's the output of the processing script in the console?
-
Only load Ajax function once and delay text being shown.
maxxd replied to NetGuru87's topic in Javascript Help
You could check the contents of $('#res3') and only run the AJAX call if it's empty. Or, set a variable (loaded = true, for instance) in the .success() function of the AJAX call and check that before you attempt to load the data again. -
You shouldn't have to append the data directly to the url - using the 'get' method will handle that for you, as well as JSON encoding the data. However, you do have to give the data to the ajax call. $.ajax({ type:'get', url:href, beforeSend:function(){ $('#target').html("<p>Doing something - please wait.</p>"); }, data:url_data, }).done(function(ajaxObject){ var resp = JSON.parse(ajaxObject); if(resp.success == true){ $('#target').html("<p>Woot!</p>"); }else{ $('#target').html('<p>Processing error - system returned false!</p>'); } }).error(function(){ $('#target').html('<p>System error - not processing related!</p>'); }); Note that there' are both a done() and error() handler attached to this. sucess() will always fire as long as the call itself goes through - there's no guarantee that the processing was successful.
-
Try this in your CSS: #my-button{ position: absolute; top: 50%; -ms-transform: translateY(-50%); -webkit-transform: translateY(-50%); transform: translateY(-50%); } Obviously change the #my-button identifier to whatever ID you're using for the button, and make sure the surrounding container has a position: value of either 'absolute' or 'relative'.