Jump to content

maxxd

Gurus
  • Posts

    1,660
  • Joined

  • Last visited

  • Days Won

    52

Posts posted by maxxd

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

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

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

  4. 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>");
    }
    
  5. 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.

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

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

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

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

  10. I am trying to change the background color of the cell of the table, not the background color of the dropdown. 

     

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

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