Skip to content

Instantly share code, notes, and snippets.

View beardedtim's full-sized avatar
💭
I may be slow to respond.

Tim Roberts beardedtim

💭
I may be slow to respond.
View GitHub Profile
@beardedtim
beardedtim / wp-sync-tuts.md
Last active February 23, 2024 02:45
How to clone wordpress to local dev

In Terminal

  • cd into your Dev folder
  • git clone scotchbox folderName
  • change ** in vagrantfile line config.vm.network "private_network", ip: "192.168.33.**" to a new two digit number
  • open up hosts file (Finder -> Go -> Go To Folder - > /private/etc/hosts )
  • if you don't have access to edit that, create new plaintext doc
  • add new line with 192.168.33.** urlName.dev with ** being the two digit number you entered
  • if you used a new plaintext doc, override/replace /private/etc/hosts with new file

PHP/WordPress CheatSheet

print_r($myarray);

  • prints off the array and its keys
  • helpful when you get the error trying to do $myarray[0] since there's some weird stuff with keys in php
  • need to figure out php keys
  • more info here

If SSH Error:

  • this error is because you are not giving your VM the correct creds.
  • to fix this, in your Vagrantfile, make it look something like:

   config.ssh.forward_agent = true
 config.ssh.username = 'vagrant'
jQuery(window).scroll(function(){
var previousHeight = jQuery('#animation-trigger').prev().height() ;
var startingPixelsDown = jQuery('#animation-trigger').offset().top;
var currentViewPortPosition = jQuery(window).scrollTop();
//console.log(startingPixelsDown);
// console.log( currentViewPortPosition + previousHeight);
// console.log(startingPixelsDown - ( currentViewPortPosition + previousHeight ) );
// console.log(startingPixelsDown);
var pixelsToGoTillDivAtTop = startingPixelsDown - ( currentViewPortPosition + previousHeight ) ;
<div class="flex-container">
<p>This is some text we want to right align</p>
</div>
<style>
.flex-container {
text-align: right;
display: flex;
}
// OR!
// We create an object of the specific divs we want to sort
var games = jQuery('.future-games-box .single-game-listing-box');
// then we create a function to
var orderedDivs = jQuery(games).sort(function(a,b){
// We are targeting the text, which is a date, inside of the
// <p></p> that is inside of the div .single-listing-box
return jQuery(a).find("p").html() > jQuery(b).find("p").html();
add_action('wp_ajax_testFunction', 'testFunction');
add_action('wp_ajax_nopriv_testFunction', 'testFunction');
function testFunction() {
?>
<p>I WAS CALLED!</p>
<?php
$p= $_GET['id'];
?>
<p>And I got <?php echo $p; ?> for id</p>
<div class="text-box">
<?php
$textGroup = $page['text_group'];
// prettyEcho($text);
foreach($textGroup as $text){
if($text['heading']){ ?>
<?php
// http://php.net/manual/en/functions.anonymous.php
$anon = function($var){
return $var + 1;
};
$arrayCheck = array(
'function' => $anon,