Skip to content

Instantly share code, notes, and snippets.

View dospuntocero's full-sized avatar

Francisco arenas dospuntocero

View GitHub Profile
@dospuntocero
dospuntocero / article.php
Created February 26, 2020 02:21
cutting the title and content for showing even smaller excerpts they they dont fit in the design
<div class="cell medium-4">
<div class="media__teaser">
<p class="media__teaser--type">
<?php echo get_the_category()[0]->name; ?>
</p>
<div class="media__teaser--title">
<?php echo mb_strimwidth(get_the_title(), 0, 50, '...'); ?>
@dospuntocero
dospuntocero / instructions.md
Last active February 23, 2020 07:36
Running MacOS on Debian/Ubuntu/Pop_OS!

If you want to experiment with a MacOS system and use GNU/Linux on your machines, then it’s actually quite simple to setup a virtual instance of MacOS on VirtualBox. Instead of looking for a Hackintosh image, I tried using a Vagrant image and was able to boot into MacOS within minutes.

  1. Prerequisites

    Install VirtualBox from VirtualBox’s download page Install additional dependencies: sudo apt-get install virtualbox-guest-utils virtualbox-guest-x11 virtualbox-guest-dkms

    Setup Vagrant by downloading the appropriate Vagrant DEB package from Vagrant’s download page

  2. Meat

@dospuntocero
dospuntocero / gh-pages-deploy.md
Created January 26, 2020 19:16 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

<?php
namespace Roots\Sage\Nav;
use Roots\Sage\Utils;
/**
* Cleaner walker for wp_nav_menu()
*
* Walker_Nav_Menu (WordPress default) example output:
@dospuntocero
dospuntocero / super-clean-wp-menu.php
Last active January 4, 2020 11:06
from time to time you need to completely change the way a menu markup is displayed and the walker class is a pain. you can just use this procedural function and add classes or markup you need
function clean_custom_menus() {
$menu_name = 'nav-primary'; // specify custom menu slug
if (($locations = get_nav_menu_locations()) && isset($locations[$menu_name])) {
$menu = wp_get_nav_menu_object($locations[$menu_name]);
$menu_items = wp_get_nav_menu_items($menu->term_id);
$menu_list = '<nav>';
$menu_list .= '<ul>';
foreach ((array) $menu_items as $key => $menu_item) {
$title = $menu_item->title;
@dospuntocero
dospuntocero / childmenu.php
Created December 18, 2019 23:04
child menu with current class using sage roots
public function childMenu() {
global $post;
// Set up the objects needed
$childQuery = new \WP_Query();
$pages = $childQuery->query(array('post_type' => 'page', 'posts_per_page' => '-1'));
if ( is_page() && $post->post_parent ){
$childpages = get_page_children( $post->post_parent, $pages);
}
else{
@dospuntocero
dospuntocero / instructions.md
Created December 2, 2019 21:26
Disabling StyleLint on Sage 9

#The Problem You receive a ton of “Expected indentation” or “Expected empty line before rule” messages when yarn compiles your code when using Sage 9.

#The Solution Just turn Style Lint off. Locate the webpack.config.js and comment out the following code…

// new StyleLintPlugin({ // failOnError: !config.enabled.watcher, // syntax: 'scss', // }),

@dospuntocero
dospuntocero / remove-all-products.sql
Created November 11, 2019 23:11
remove all products from woocommerce database
DELETE relations.*, taxes.*, terms.*
FROM wp_term_relationships AS relations
INNER JOIN wp_term_taxonomy AS taxes
ON relations.term_taxonomy_id=taxes.term_taxonomy_id
INNER JOIN wp_terms AS terms
ON taxes.term_id=terms.term_id
WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='product');
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product');
DELETE FROM wp_posts WHERE post_type = 'product';
@dospuntocero
dospuntocero / remove-wh.php
Created October 18, 2019 20:25
remove width and height from wordpress images
add_filter( 'post_thumbnail_html', 'remove_wps_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_wps_width_attribute', 10 );
function remove_wps_width_attribute( $html ) {
$html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
return $html;
}
@dospuntocero
dospuntocero / gsap.css
Created October 1, 2019 02:43
gsap slideUp/slideDown functionality
body{
background-color:black;
height:100%;
margin:10px;
}
.box{
position:relative;