Skip to content

Instantly share code, notes, and snippets.

View nfsarmento's full-sized avatar

NS nfsarmento

View GitHub Profile
@nfsarmento
nfsarmento / acf-postobject-repeater.php
Created April 26, 2017 09:21
ACF: Get Post Object data within a Repeater
<section class="slider">
<?php if( have_rows('slides') ): ?>
<div id="slider" class="flexslider">
<ul class="slides">
<?php while ( have_rows('slides') ) : the_row(); ?>
@nfsarmento
nfsarmento / is_blog.php
Created August 9, 2017 17:58 — forked from wesbos/is_blog.php
WordPress is_blog()
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ;
}
Usage:
<?php if (is_blog()) { echo 'You are on a blog page'; } ?>
@nfsarmento
nfsarmento / simple-map-defer.php
Created December 12, 2017 12:46 — forked from glueckpress/simple-map-defer.php
[WordPress][Simple Map] Load Google Maps API script from Simple Map deferred.
<?php
defined( 'ABSPATH' ) or die( 'No direct access here.' );
/**
* Plugin Name: Simple Map | Defer
* Description: Makes sure Google Maps API script from <a href="https://wordpress.org/plugins/simple-map/">Simple Map</a> gets loaded deferred.
* Author: Caspar Hübinger
* Author URI: https://profiles.wordpress.org/glueckpress
* Plugin URI: https://gist.github.com/glueckpress/56c88900aad391b95b5d44f4e752a1a4
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
@nfsarmento
nfsarmento / php7.1.md
Last active January 31, 2018 08:45 — forked from VirtuBox/php7.1.md
How to install php7.1-fpm with EasyEngine

How to install php7.1-fpm with EasyEngine


Install php7.1-fpm

apt install php7.1-common php7.1-cli php7.1-zip php7.1-opcache php7.1-mysql php7.1-mcrypt php7.1-mbstring php7.1-json php7.1-intl php7.1-gd php7.1-fpm php7.1-curl php7.1-bz2

Copy the php7.1-fpm pool configuration from php7.0-fpm

cp -f /etc/php/7.0/fpm/pool.d/www.conf /etc/php/7.1/fpm/pool.d/www.conf
@nfsarmento
nfsarmento / a-theme-auth.php
Created January 31, 2018 19:55 — forked from itzikbenh/a-theme-auth.php
WordPress class for registering users via Linkedin
<?php
function a_theme_auth_options_page()
{
add_options_page( "A-Theme Auth options", "A-Theme Auth", "manage_options", "a-theme-auth", "a_theme_auth_options" );
}
add_action( 'admin_menu', 'a_theme_auth_options_page' );
function register_a_theme_auth_settings()
{
@nfsarmento
nfsarmento / ajax-filter-posts.js
Created March 11, 2018 12:42
Ajax filters for CPT with custom taxonomy
(function($) {
'use strict';
jQuery(document).ready(function() {
//Load all posts
asr_ajax_get_postdata(-1);
$('.asr_texonomy').on('click',function(){
var term_id = $(this).attr('data_id');
@nfsarmento
nfsarmento / content-reports.php
Created March 11, 2018 12:47
CPT metabox check option to show CPT post on page template
<article <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>">
<header class="heading-cpt">
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail( 'full' );
}
?>
<?php
$page_id = get_queried_object_id();
$post_thumbnail_id = get_post_thumbnail_id( $page_id );
$bkgdImg = wp_get_attachment_url( $post_thumbnail_id );
echo $bkgdImg;
?>
function ns_mce4_options($init) {
$custom_colours = '
"3366FF", "Color 1 name",
"CCFFCC", "Color 2 name",
"FFFF00", "Color 3 name",
"99CC00", "Color 4 name",
"FF0000", "Color 5 name",
"FF99CC", "Color 6 name",
"CCFFFF", "Color 7 name"
@nfsarmento
nfsarmento / bootstrap 4 collapse accordion with ACF repeater.php
Last active March 22, 2018 16:46
bootstrap 4 collapse accordion with ACF repeater
<?php if( have_rows('collapse') ): ?>
<div id="accordion" role="tablist">
<?php $i=1; while ( have_rows('collapse') ) : the_row(); ?>
<div class="card">
<div class="card-header" role="tab" id="heading-<?php echo $i; ?>">
<h5 class="mb-0">
<a data-toggle="collapse" href="#collapse-<?php echo $i; ?>" aria-expanded="true" aria-controls="collapseOne">
<?php the_sub_field('title'); ?>
</a>
</h5>