Skip to content

Instantly share code, notes, and snippets.

View nfsarmento's full-sized avatar

NS nfsarmento

View GitHub Profile
@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 / 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 / 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 / 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>
@nfsarmento
nfsarmento / javascript.js
Created May 17, 2018 15:57
WordPress Custom Post Type Categories - Collapse List
$('.toggle__categories').click(function(e) {
e.preventDefault();
var $this = $(this);
$this.next().toggleClass();
$this.next().slideToggle();
});
$(function() {
$('.plus-minus-toggle').on('click', function() {
$(this).toggleClass('collapsed');
@nfsarmento
nfsarmento / functions.php
Created May 21, 2018 16:21
Add information above a custom post type listing of all posts page
function wpa_admin_notice() {
$screen = get_current_screen();
if( 'your_post_type' == $screen->post_type
&& 'edit' == $screen->base ){
?>
<div class="updated">
<p>Here is some text</p>
</div>
<?php
}