Skip to content

Instantly share code, notes, and snippets.

View rhcarlosweb's full-sized avatar
🖖

Rhuan Carlos rhcarlosweb

🖖
View GitHub Profile
@rhcarlosweb
rhcarlosweb / nexo_breadcrumb.php
Last active October 26, 2021 02:28
Breadcrumb WordPress, support taxonomy, and post types
<?php
function nexo_breadcrumb(array $options = array()) {
// default values assigned to options
$options = array_merge(array(
'crumbId' => 'nav_crumb', // id for the breadcrumb Div
'crumbClass' => 'nav_crumb', // class for the breadcrumb Div
'beginningText' => '', // text showing before breadcrumb starts
'showOnHome' => 1, // 1 - show breadcrumbs on the homepage, 0 - don't show
'delimiter' => '<i class="fa fa-angle-right"></i>', // delimiter between crumbs
<?php
function rw_image_resize( $attachment_id, $width, $height, $crop = true )
{
$path = get_attached_file( $attachment_id );
if ( ! file_exists( $path ) )
{
return false;
}
$upload = wp_upload_dir();
@rhcarlosweb
rhcarlosweb / url_get_contents.php
Last active July 14, 2017 22:41
file_get_contents alternative curl function
<?php
function url_get_contents($url) {
if (function_exists('file_get_contents') && ini_get('allow_url_fopen')) {
$url_get_contents_data = file_get_contents($url);
} elseif (function_exists('curl_exec')) {
$conn = curl_init($url);
curl_setopt($conn, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($conn, CURLOPT_FRESH_CONNECT, true);
curl_setopt($conn, CURLOPT_RETURNTRANSFER, 1);
@rhcarlosweb
rhcarlosweb / function.js
Created August 17, 2017 21:22
Convert ul li on dropdown
function listToDropdown(selector) {
var $list = $(selector),
$select = $('<select class="btn btn-outline btn-white select-field-menup" />');
// blank
$select.append($('<option />').attr('value', '').html('Navegação'));
// for each list change to a option in select field
$list.children('li').each(function(index, el) {
@rhcarlosweb
rhcarlosweb / owlcarousel2thumbs.js
Last active February 18, 2021 15:26
Owl Carousel 2 Sync Two Sliders
var sync1 = $('#sync1'),
sync2 = $('#sync2'),
duration = 300,
thumbs = 4;
// Sync nav
sync1.on('click', '.owl-next', function () {
sync2.trigger('next.owl.carousel')
});
sync1.on('click', '.owl-prev', function () {
scss/ # Import all ‘-dir.scss’ files
|
|- abstracts/
| |- __abstracts-dir.scss # Import all abstracts .scss files
| |- _fonts.scss # Font Import
| |- _mixins.scss # Scss Mixins
| |- _variables.scss # Scss Variables
|
|- base/
| |- __base-dir.scss # Import all base .scss files
@rhcarlosweb
rhcarlosweb / NexoYoutubeClass.php
Last active February 28, 2018 02:42
Get Recent YouTube Videos from Username or Channel ID | WordPress
<?php
/**
* Class NexoYoutubeVideos
*
* Get video list from youtube
* Max of 50 videos
*/
class NexoYoutubeVideos {
@rhcarlosweb
rhcarlosweb / functions.php
Created July 7, 2018 19:43
Disable Comments WodPress
<?php
// Disable support for comments and trackbacks in post types
add_action( 'admin_init', 'nexo_disable_comments_post_types_support' );
function nexo_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ( $post_types as $post_type ) {
if ( post_type_supports( $post_type, 'comments' ) ) {
remove_post_type_support( $post_type, 'comments' );
remove_post_type_support( $post_type, 'trackbacks' );
}
@rhcarlosweb
rhcarlosweb / menu-name-wordpress.php
Created February 13, 2019 19:44
Get wordpress menu name
<?php
/**
* Get Menu id
*
* @param $name_location
*
* @return
*/
function nexo_menu_title( $name_location = '' ) {
if ( has_nav_menu( $name_location ) ) :
function ChangeLang(a) {
var b, elemento = "";
if (document.createEvent) {
var c = document.createEvent("HTMLEvents");
c.initEvent("click", true, true)
}
if (a == 'pt') {
elemento = $(".goog-te-banner-frame:eq(0)").contents().find("button[id*='restore']")
} else {
switch (a) {