Embed Video Player

Video Class code attached. You can put this file in any directory. Previously it was put in a folder called classes.

Calling video class

$link = "https://www.youtube.com/watch?v=NpEaa2P7qZI";
$embed = Video::get_embed_URL($link)."?&autoplay=1&loop=1";

Video Class

class Video {
const _youtube_regex = '/(\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)&?(.*)/';
const _youtubeshort_regex = '/(\/\/.*?youtu\.be)\/([^\?]+)(.*)/i';
const _vimeo_regex = '/(\/\/.*?)vimeo\.[a-z]+\/([0-9]+).*?/';

/**
 * Given filetype column from DB's article_medias table will return true if the media is video
 * @param string $source source from article_medias.filetype column
 * @return bool True if video
 */
public static function is_video( $source ) {
	if ($source == 'youtube' || $source == 'youtu.be' || $source == 'vimeo') {
		return true;
	} else {
		return false;
	}
}


/**
 * Given a url param to a youtube or vimeo video, will return the related format
 * @param string $url Url to the video
 * @return bool|string
 */
public static function get_source( $url ) {
	if (preg_match(self::_youtube_regex, $url)) {
		$format = 'youtube';
	} else if (preg_match(self::_youtubeshort_regex, $url)) {
		$format = 'youtu.be';
	} else if (preg_match(self::_vimeo_regex, $url)) {
		$format = 'vimeo';
	} else {
		return false;
	}

	return $format;
}



/**
 * Given a video url to either a youtube or vimeo video, will return the specific video id
 * @param string $url Video url
 * @return bool|string
 */
public static function get_source_ID( $url ) {
	$format = self::get_source($url);

	switch ($format) {
		case 'vimeo':
			$vid_id = preg_replace(self::_vimeo_regex, '$2', $url);
			if (substr($vid_id, 0, 5) == "http:") { $vid_id = substr($vid_id, 5); }
			if (substr($vid_id, 0, 6) == "https:") { $vid_id = substr($vid_id, 6); }
			break;

		case 'youtube':
			$vid_id = rtrim(preg_replace(self::_youtube_regex, '$2', $url), '?');
			if (substr($vid_id, 0, 5) == "http:") { $vid_id = substr($vid_id, 5); }
			if (substr($vid_id, 0, 6) == "https:") { $vid_id = substr($vid_id, 6); }
			break;

		case 'youtu.be':
			$vid_id = rtrim(preg_replace(self::_youtubeshort_regex, '$2', $url), '?');
			if (substr($vid_id, 0, 5) == "http:") { $vid_id = substr($vid_id, 5); }
			if (substr($vid_id, 0, 6) == "https:") { $vid_id = substr($vid_id, 6); }
			break;

		default:
			return false;
	}
	return $vid_id;
}


 /**
	* Gets the html url for the video
	* @param string $id Video id
	* @param string $format Video format/source
	* @return bool|string returns url for embedding the video
	*/
public static function get_embed_URL($url) {
	$format = self::get_source($url);
	$id = self::get_source_ID($url);

 switch ($format) {
	 case 'vimeo':
		 $link = 'https://player.vimeo.com/video/'.$id;
		 break;

	 case 'youtube':
		 $link = 'https://www.youtube.com/embed/'.$id;
		 break;

	 case 'youtu.be':
		 $link = 'https://www.youtube.com/embed/'.$id;
		 break;

	 default:
		 return false;
 }

 return $link;
}

}

Custom Tiny MCE Buttons

screen-shot-2016-10-07-at-4-19-25-pm
screen-shot-2016-10-07-at-4-19-31-pm
screen-shot-2016-10-07-at-4-20-38-pm
screen-shot-2016-10-07-at-4-20-45-pm
add_action( 'after_setup_theme', 'wpse3882_after_setup_theme' );
function wpse3882_after_setup_theme()
{
    add_editor_style();
}

add_filter('mce_buttons_2', 'wpse3882_mce_buttons_2');
function wpse3882_mce_buttons_2($buttons)
{
    array_unshift($buttons, 'styleselect');
    return $buttons;
}

add_filter('tiny_mce_before_init', 'wpse3882_tiny_mce_before_init');
function wpse3882_tiny_mce_before_init($settings)
{
    $settings['theme_advanced_blockformats'] = 'p,h2,h3,h4';

    // From http://tinymce.moxiecode.com/examples/example_24.php
    $style_formats = array(
        array('title' => 'Link With Icon', 'selector' => 'a', 'classes' => 'cta-link')
    );
    // Before 3.1 you needed a special trick to send this array to the configuration.
    // See this post history for previous versions.
    $settings['style_formats'] = json_encode( $style_formats );

    return $settings;
}

Typography

h1 That easy. This is the time to get out all your frustrations

h2 Don’t be afraid to make these big decisions

h3 I thought today we would make a happy little stream that’s just running through the woods here

h4 Anyone can paint. Nothing wrong with washing your brush.

p Just go back and put one little more happy tree in there. Have fun with it. We don’t really know where this goes – and I’m not sure we really care. Let’s make some happy little clouds in our world. You could sit here for weeks with your one hair brush trying to do that – or you could do it with one stroke with an almighty brush. Van Dyke Brown is a very nice brown, it’s almost like a chocolate brown.

  • li As trees get older they lose their chlorophyll.
  • li Just float and wait for the wind to blow you around. In nature, dead trees are just as normal as live trees. Isn’t it great to do something you can’t fail at?
  • li See how easy it is to create a little tree right in your world.
  1. li As trees get older they lose their chlorophyll.
  2. li Just float and wait for the wind to blow you around. In nature, dead trees are just as normal as live trees. Isn’t it great to do something you can’t fail at?
  3. li See how easy it is to create a little tree right in your world.

 
NOTE: The code below will not replicate the above example. It is simply standard classes to start with. Adding font weight, font size, and font family with produce * similar * results.

p {
	line-height: 24px;
}

h2, .h2, h3, .h3, h4, .h4 {
	margin-bottom: 0.5em;
	line-height: 1.2;
}

h1, .h1 {
	line-height: 1.2;
}
h2, .h2 {
	font-size: 21px;
}

a, a:visited {
	text-decoration: none ;
	&:hover, &:focus {
		text-decoration: none ;
	}
}

.entry-content a:hover, .entry-content a:focus, .fancybox-wrap a:hover p, .fancybox-wrap a:focus p {
	color:$color-primary-hover;
}


hr {
	border-color: #ccc;

}

Setup Laravel Elastic Search

# Install Elastic Search
– cd into your Homestead folder

– before ‘end’ add the lines:
 config.ssh.forward_x11 = true
 config.vm.network “forwarded_port”, guest: 9200, host: 62000
– SSH into the vagrant box by running ‘vagrant ssh’
– run the command ‘./runAfterSSH_toInstallElasticSearch.sh’
– exit your vagrant SSH using the command ‘exit’
– run ‘vagrant reload’

Website Pre Launch

Pre-Launch Checklist

  • All test copy has been removed
  • Content has been checked for spelling, grammar etc.
  • No broken links in the navigation & throughout the content
  • Favicon has been added
  • Enable search engine crawling – ensure robots.txt is not blocking the site from being crawled
  • In WordPress, this is usually controlled in Settings > Reading > Discourage search engines.
  • Custom 404 page has been created
  • Add 301 redirects where needed
  • Cross-browser development has been done, IE9+, Firefox, Chrome, Safari
  • All forms are sending to the correct email addresses
  • Passes W3C Validation (not needed, but nice to have)
  • All custom functionality has been tested
  • Add Google Analytics – if a rebuild, use the existing ID else create a new one under my account
  • Add site to the following services:
  • Webmaster tools
  • Firewall
  • DuplicatorPro Backups
  • UptimeRobot
  • ManageWP

CMS

OVERALL

    • hide any SEO or performance plugins from client
    • ensure all fields and labels have the same typeface (including WYSIWYG)
    • ensure wording on things makes sense for client
    • CMS login information has been setup for client
    • log in to CMS under user account and ensure they can add/edit/delete everything they are supposed to

CAROUSEL

    • ensure carousel text fields have a character count cap if needed

NAV UPDATES

    • move menu management into main nav (out of appearance nav)
    • hide posts, comments, contact forms, appearance, settings, users, tools, performance, SEO, framework nav items from if not needed
    • move pods under the Pages nav item

PAGES/POSTS/PODS

    • hide any fields or field groups that are not being used
    • rearrange field groups so they make sense/match front end ordering

PLUG-INS

    • Install Wordfence Security
    • Activate Facebook Thumb Fixer plugin

SEO

Meta Tags

    • Title

Accessibility

Installing Laravel With Homestead

Laravel 5.2 Installation with Homestead