Skip to content

Instantly share code, notes, and snippets.

View daniloparrajr's full-sized avatar
🏃‍♂️
Onward to good things!

Danilo Parra Jr daniloparrajr

🏃‍♂️
Onward to good things!
View GitHub Profile
@daniloparrajr
daniloparrajr / functions.php
Created July 12, 2018 02:02
Filter image src if the attachment parent post is woocommerce product then change its * image src as desired
<?php
/**
* Filter image src if the attachment parent post is woocommerce product then change its
* image src as desired.
*
* @param array|false $image
* @param int $attachment_id
* @param string|array $size
* @param bool $icon
@daniloparrajr
daniloparrajr / functions.php
Created July 10, 2018 06:30
Wordpress Adding Custom Post Type on WP REST API
<?php
/**
* Add WCC contest details into the WP Rest API
*
* @param [class] $object Query Object.
* @return string Contest details.
*/
function get_wcc_contest_details( $object ) {
$wcc_contest_details = get_post_meta( $object['id'], '_wcc_contest_details', true );
<?php
/**
* Enqueue Site Files for child theme.
*
* @return void
*/
function dvc_theme_enqueue_styles() {
wp_enqueue_style( 'divi-parent-style', get_template_directory_uri() . '/style.css' );
}
@daniloparrajr
daniloparrajr / functions.php
Last active July 12, 2018 01:59
Change WordPress image attributes depending on post type.
<?php
/**
* Filter image attributes if the attachment parent post is woocommerce product then change its
* image attributes as desired.
*
* @param array $attr Attributes for the image markup.
* @param WP_Post $attachment Image attachment post.
* @param string|array $size Requested size. Image size or array of width and height values
* (in that order). Default 'thumbnail'.
* @return array $image Modified Image attributes
@daniloparrajr
daniloparrajr / functions.php
Last active March 27, 2019 02:21
Divi social menu shortcode
<?php
/**
* Utilize Native Divi Social media icons and convert it to a wordpress shortcode.
*
* @return string html social media list.
*/
function divi_social_icons_func() {
$social_media = '';
$link_class_name = '';
$social_links = array(
@daniloparrajr
daniloparrajr / style.css
Created May 23, 2018 08:08
Divi Meia Query breakpoints
/*** Responsive Styles Large Desktop And Above ***/
@media all and (min-width: 1405px) {
}
/*** Responsive Styles Standard Desktop Only ***/
@media all and (min-width: 1100px) and (max-width: 1405px) {
}
@daniloparrajr
daniloparrajr / index.php
Last active May 21, 2018 06:16
CSS and Javascript cache busting
<?php
// CSS
$css_file_path = get_template_directory_uri() . '/assets/css/website-responsive.css';
wp_enqueue_style(
'site_responsive',
$css_file_path,
false,
filemtime( $css_file_path )
);
@daniloparrajr
daniloparrajr / styles.css
Created April 10, 2018 09:32
CSS Table of contents template
/*--------------------------------------------------------------
>>> TABLE OF CONTENTS:
----------------------------------------------------------------
1.0 Base
2.0 Header
3.0 Footer
--------------------------------------------------------------*/
/*--------------------------------------------------------------
1.0 Base
@daniloparrajr
daniloparrajr / functions.php
Created February 19, 2018 03:44
Wordpress Redirect user
<?php
function themeprefix_redirect_user()
{
if( is_page( 'login' ) && ! is_user_logged_in() )
{
wp_redirect( home_url( '/signup/' ) );
die;
}
}
@daniloparrajr
daniloparrajr / index.php
Created February 16, 2018 03:11
Truncate a string provided by the maximum limit
<?php
/**
* Truncate a string provided by the maximum limit.
* @param string $str
* @param integer $maxlen
* @return string
*/
function limitString($string, $limit = 100, $end = '&hellip;')
{