Skip to content

Instantly share code, notes, and snippets.

View imarkdesigns's full-sized avatar

Mark Joseph Rivera imarkdesigns

View GitHub Profile
@imarkdesigns
imarkdesigns / custom-post-type.php
Created December 3, 2017 19:25
Display custom category on a single post #wordpress
<?php
// To call custom category and fetch the category by slug
// Change $term->slug to $term->name to display capitalize name
$terms = get_the_terms( $post->ID , 'custom-taxonomy' );
foreach ( $terms as $term ) {
echo $term->slug;
}
// Displaying full post with selected custom category
@imarkdesigns
imarkdesigns / full-page.php
Last active November 26, 2017 16:57
YouTube iFrame API #api #youtube #acf
<section class="uk-section uk-padding-remove __video-introduction">
<?php while ( have_rows( 'screen_media_section' ) ) : the_row(); ?>
<div class="uk-container uk-container-expand uk-padding-remove">
<div class="uk-cover-container uk-height-large">
<?php
$youtubeURL = get_sub_field('youtube_id');
$youtubeID = explode( '=', $youtubeURL );
?>
<iframe uk-cover id="player" type="text/html" width="100%" height="100%" src="https://www.youtube.com/embed/<?php echo $youtubeID[1]; ?>?start=0&end=140&playsinline=1&playlist=<?php echo $youtubeID[1]; ?>&enablejsapi=1&disablekb=1&autoplay=1&controls=0&showinfo=0&rel=0&loop=1&wmode=transparent&" frameborder="0"></iframe>
@imarkdesigns
imarkdesigns / strip_word_html.php
Created October 31, 2017 03:46 — forked from dave1010/strip_word_html.php
Strip MS Word HTML. From php.net
<?php
function strip_word_html($text, $allowed_tags = '<b><i><sup><sub><em><strong><u><br>')
{
mb_regex_encoding('UTF-8');
//replace MS special characters first
$search = array('/&lsquo;/u', '/&rsquo;/u', '/&ldquo;/u', '/&rdquo;/u', '/&mdash;/u');
$replace = array('\'', '\'', '"', '"', '-');
$text = preg_replace($search, $replace, $text);
//make sure _all_ html entities are converted to the plain ascii equivalents - it appears
//in some MS headers, some html entities are encoded and some aren't
@imarkdesigns
imarkdesigns / macOS terminal
Last active October 8, 2017 01:52
Delete .DS_Store file #terminal
$ find . -name '*.DS_Store' -type f -delete
@imarkdesigns
imarkdesigns / single.php
Created September 16, 2017 23:32
Related Posts with Thumbnails in WordPress (no plugins) #wp #php
<?php $orig_post = $post;
global $post;
$categories = get_the_category($post->ID);
if ($categories) {
$category_ids = array();
foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
$args=array(
'category__in' => $category_ids,
'post__not_in' => array($post->ID),
'posts_per_page'=> 2, // Number of related posts that will be shown.
@imarkdesigns
imarkdesigns / trigger.less
Created September 8, 2017 21:02
Double Ring Animation #less
@D: 60px; // size control // diametro
@R: (@D/2); // radio
@B: (@R/6);
@O: 0.7; // opacity
@A: 2s; // accelerate
.trigger { position: relative; background: transparent; width: @D; height: @D; margin-left: -@R; margin-top: -@R; border: 0; outline: none; cursor: pointer;
&:after, &:before { content:""; border-radius: 100%; position:absolute; top: 0; left: 0; width: 100%; height: 100%; transform-origin: center center; }
&:after{
@imarkdesigns
imarkdesigns / browser-tab-modifier.js
Created September 1, 2017 07:35
jQuery Browser Tab Title Modifier #jquery
var initTabTitle = function() {
var $doc = $(document),
$body = $("body"),
$window = $(window);
var titleTimer = 0;
var titleTimerRunning = false;
var origTitle = $doc.find("title").text();
var newTitle = "Don't forget to read this...";
var isOrig = true;
@imarkdesigns
imarkdesigns / functions.php
Created September 1, 2017 07:30
Create WP User Administrator via FTP #wp #php
<?php
function add_admin_acct(){
$login = 'yourusername';
$passw = 'yourpass';
$email = 'youremail';
if ( !username_exists( $login ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $login, $passw, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
}
@imarkdesigns
imarkdesigns / macOS terminal
Last active March 21, 2018 01:53
macOS Dock show/hide animation #terminal #dock
defaults write com.apple.dock autohide-delay -float 0
defaults write com.apple.dock autohide-time-modifier -float 0.5
killall Dock
@imarkdesigns
imarkdesigns / meta-tags.md
Created July 25, 2016 20:32 — forked from kevinSuttle/meta-tags.md
List of Usable HTML Meta and Link Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>