-
Posts
1,698 -
Joined
-
Last visited
-
Days Won
53
Everything posted by maxxd
-
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.
-
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.
-
Programming style for multidimensional associative arrays
maxxd replied to cyberRobot's topic in PHP Coding Help
Personally, I don't find it confusing at all - I'll often write statements in the same manner. -
Well, that would certainly do it...
-
Are you sure $home_team and $away_team contain the values you expect? Try printing them both before running the bank of queries.
-
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...
-
Session is partly lost sometimes (hard to reproduce)
maxxd replied to vriezerweb's topic in PHP Coding Help
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. -
Session is partly lost sometimes (hard to reproduce)
maxxd replied to vriezerweb's topic in PHP Coding Help
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. -
Get Image by number, but if loop when no image? Help
maxxd replied to Rowena_Harris's topic in PHP Coding Help
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.- 2 replies
-
- get image
- image slider
-
(and 1 more)
Tagged with:
-
Combining domain names with RewriteRule or Redirect?
maxxd replied to maxxd's topic in Apache HTTP Server
kicken, thanks much - that worked perfectly! -
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.
-
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>"); }
-
Combining domain names with RewriteRule or Redirect?
maxxd replied to maxxd's topic in Apache HTTP Server
Thanks, kicken - I'll give that a try this morning! -
Combining domain names with RewriteRule or Redirect?
maxxd replied to maxxd's topic in Apache HTTP Server
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... -
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.
-
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.
-
add_filter('woocommerce_bookings_remove_inactive_cart_time', changeDeleteTime()); function changeDeleteTime(){ return time() + ( 30 * 24 * 60 * 60 ); } That should work. What errors are you getting? By the way, I truly mean should - I've not tested it.
- 2 replies
-
- remove filter
- replace filter
-
(and 1 more)
Tagged with:
-
Passing from data to PHP to capture variables and run an exe
maxxd replied to lynns's topic in PHP Coding Help
If you're trying to run something from the command line, I think you want shell_exec(). At the same point, why is the company with which you are working not allowed to post to this API with PHP only? Have you tried cURL instead? It would certainly be safer than running a shell command... Either way, you're going to have to assign the response from exec() or shell_exec() to a variable in order to use it. -
Do me a favor and explain what you mean by 'raw text'. The widget() function is what renders in the widget area in WordPress. The following part of the code outputs an unordered list of the data. // Construct unorganized list for each row echo '<ul class="mycred-this-weeks-leaderboard">'; foreach ( $leaderboard as $position => $data ) { $avatar = get_avatar( $data->user_id, 32 ); echo '<li>' . $avatar . $data->display_name . ' with ' . $mycred->format_creds( $data->total ) . '</li>'; } echo '</ul>'; If it's not spitting out a list as described, it's possible there's escaping on the content. Look for a line in your functions.php file that starts with the following: add_filter('the_content', ... After the comma is a function name. Find that function in the functions.php file and see what it does. An escape function in WordPress (like esc_attr(), for instance) will convert special characters into HTML entities, so your output would actually be the HTML markup itself. Now, understand that escaping is important and very much needs to be there, but there are several different escape functions in WordPress, and some are more appropriate than others for some situations.
-
Also, it looks like the widget already outputs an unordered list with the class 'mycred-this-weeks-leaderboard' - you can style that. It's safer than trying to modify a plugin file, because any time the author of the plugin releases an update, your changes will be overwritten.
-
Checking the value of a dropdowns in sql php
maxxd replied to sarojthapa60's topic in PHP Coding Help
Then this is a simple JavaScript question, not a PHP question. Create an change event handler to change the background color to the value selected by the user. Note that 'amber' is not recognized by Firefox as a valid color, so you'll probably want to do hex values, but this should get you started: HTML: <tr> <td id='capacity_cell' style='width:300px;height:250px;background-color:grey;'> <label for='capacity'>Capacity</label> <select id='capacity'> <option value=''>Select One</option> <option value='green'>Green</option> <option value='amber'>Amber</option> <option value='red'>Red</option> <option value='black'>Black</option> </select> </td> </tr> jQuery: $(function(){ $('#capacity').change(function(e){ var bg = $(this).val(); $('#capacity_cell').css({ backgroundColor: bg }); }); }); -
Checking the value of a dropdowns in sql php
maxxd replied to sarojthapa60's topic in PHP Coding Help
Possibly more importantly, there is a lot of redundant and inefficient code in what you've posted. First and foremost, don't simply 'SELECT *' from a table when you only need three columns. Specify the columns you need. Also, you're running the same query twice. Don't. Run the query once to get the values, store the values in an array, and loop through the array twice. On top of that, you're including the database.php file three separate times. You are at lease using require_once(), but why take the time to do the extra typing? Include the external file at the top of this file and you're good to go. I'm in the same boat as cyberRobot here - until you explain a bit more thoroughly what exactly you're trying to do, we're not going to be able to help you find the correct answer. -
Or you can use func_get_args() and not force the function parameter to be a randomly formatted string. Or, pass in an array of values and simply loop through them. Point being, unless you're tied to this data format for the function parameter, there are far easier ways to handle the situation.
-
Checking the value of a dropdowns in sql php
maxxd replied to sarojthapa60's topic in PHP Coding Help
There's neither a question nor a drop-down in your post...