Skip to content

Instantly share code, notes, and snippets.

View dospuntocero's full-sized avatar

Francisco arenas dospuntocero

View GitHub Profile
@dospuntocero
dospuntocero / example.css
Created November 1, 2017 02:43
use jquery to test for changed css property and make responsive changes. instead of checking on browser width
//The CSS
.tocheck {float:left;}
@media only screen and (max-width: 800px){
.tocheck {float:none;}
}
@dospuntocero
dospuntocero / next previous URLs wordpress
Last active January 12, 2018 02:26
get only the next and prev URL instead of full anchor. useful when you need extensive markup styling
<?php
$prev = get_permalink(get_adjacent_post(false,'',false));
$next = get_permalink(get_adjacent_post(false,'',true));
?>
<a href="<?php echo $prev; ?>">Previous Post</a>
<a href="<?php echo $next; ?>">Next Post</a>
<?php //What if there isn’t a previous or next post? ?>
@dospuntocero
dospuntocero / vwvh-conversion.scss
Created February 9, 2018 19:09
//px 2 vw - vh conversion tool
@function get-vw($object_width,$window_width:1440) {
$vw: ($window_width * 0.01) * 1px;
@return ($object_width / $vw) * 1vw;
}
@function get-vh($object_height,$window_height:768) {
$vh: ($window_height * 0.01) * 1px;
@return ($object_height / $vh) * 1vh;
}
@dospuntocero
dospuntocero / dospuntocerocms.php
Last active February 11, 2018 16:23
wordpress MEGALITE cms. for clients that don't need anything but blog or pages and you don't want them to mess things around. i'm using https://nestedpages.com/ for controlling the page tree. also added a small css for removing the regular editor links. added 2 useful functions: svg capability for uploading and removing thumbnail hardcode dimens…
<?php
/*
Plugin Name: dospuntocero
Plugin URI: -
Description: lite CMS
Author: Francisco Arenas
Version: 1
Author URI: http://dospuntocero.cl
@dospuntocero
dospuntocero / _masonry.scss
Created February 18, 2018 13:49
masonry layout for foundation 6 controlled by flexbox breakpoints. you need to add a masonry-container class to the parent and a masonry-item class to the child. the .grid-container class is optional
$masonry-css-column-gap: $global-margin;
$global-margin: 1rem !default;
.masonry-container {
column-count: 1;
column-gap: $masonry-css-column-gap;
@if ($flexbox-responsive-breakpoints) {
$i: 0;
@each $size in $breakpoint-classes {
@dospuntocero
dospuntocero / even-odd.php
Created September 9, 2018 15:45
even odd classes on wordpress loop example on line 10 / 13
<?php
// WP_Query Arguments
$args = array(
'order' => 'DESC',
'posts_per_page' => 5
);
// The Loop
$query = new WP_Query( $args );
while ( $query->have_posts() ) : $query->the_post();
$even_odd_class = $wp_query->current_post % 2 == 0 ? 'even' : 'odd';
@dospuntocero
dospuntocero / even-odd for functions.php
Created September 9, 2018 16:02
add this function to your functions.php class and then add the filter to the result you need to have it.
function oddeven_post_class ( $classes ) {
global $current_class;
$classes[] = $current_class;
$current_class = ($current_class == 'odd') ? 'even' : 'odd';
return $classes;
}
add_filter ( 'post_class' , 'oddeven_post_class' );
global $current_class;
$current_class = 'odd';
@dospuntocero
dospuntocero / even odd inside foreach example
Created September 9, 2018 16:03
use this if you need a foreach with even/odd classes
<?php
$recent_posts = wp_get_recent_posts();
?>
<?php $current_class = 'odd';?>
<?php foreach( $recent_posts as $recent ):?>
<?php $current_class = ($current_class == 'odd') ? 'even' : 'odd'; ?>
<div class="<?php echo $current_class ?>">
<?php echo $recent["post_title"]?>
<a href="<?php echo get_permalink($recent["ID"])?>">READ MORE</a>
@dospuntocero
dospuntocero / remove editor
Created September 9, 2018 18:26
remove plain editor from wordpress waiting for guttenberg support on pages
function hide_editor() {
remove_post_type_support('page', 'editor');
}
add_action( 'admin_init', 'hide_editor' );
@dospuntocero
dospuntocero / excerpt_limit.php
Created November 19, 2018 01:24
Limit the excerpt by number of characters but do NOT truncate the last word. This will allow you to return a maximum number of characters but preserve full words, so only the words that can fit within the specified number limit are returned and allow you to specify the source of where the excerpt will come from.
function get_excerpt($limit, $source = null){
$excerpt = $source == "content" ? get_the_content() : get_the_excerpt();
$excerpt = preg_replace(" (\[.*?\])",'',$excerpt);
$excerpt = strip_shortcodes($excerpt);
$excerpt = strip_tags($excerpt);
$excerpt = substr($excerpt, 0, $limit);
$excerpt = substr($excerpt, 0, strripos($excerpt, " "));
$excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt));
$excerpt = $excerpt.'... <a href="'.get_permalink($post->ID).'">more</a>';