Skip to content

Instantly share code, notes, and snippets.

View nfsarmento's full-sized avatar

NS nfsarmento

View GitHub Profile
@nfsarmento
nfsarmento / funtions.php
Created April 17, 2024 19:13
WordPress - Disable a specific plugin update check
<?php
/**
*
* Prevent update notification for plugin
*
*/
function ns_disable_plugin_updates( $value ) {
$pluginsToDisable = [
'plugin-folder/plugin.php',
@nfsarmento
nfsarmento / functions.php
Last active April 17, 2024 19:08
Redirect all users that are not in the users array to the wp-admin dashboard page if trying to access the pages below declared
/**
*
* Redirect all users that are not in the users array to the wp-admin dashboard page if trying to access the pages below declared
*
*/
if ( ! function_exists( 'ns_redirect_users_by_role' ) ) :
function ns_redirect_users_by_role() {
global $pagenow;
@nfsarmento
nfsarmento / functions.php
Created March 20, 2024 16:30
Default/fallback post thumbnail image.
<?php
/**
*
* Default/fallback post thumbnail image.
*
*/
function aoa_filter_thumbnail_id( $thumbnail_id, $post = null ) {
if ( ! $thumbnail_id ) {
@nfsarmento
nfsarmento / nginx-wordpress.conf
Last active March 7, 2024 13:38
Harden wordpress security nginx
############ WordPress ####################
# Disable logging for favicon and robots.txt
location = /favicon.ico {
try_files /favicon.ico @empty;
access_log off;
log_not_found off;
expires max;
}
@nfsarmento
nfsarmento / breadcrumb.php
Last active January 26, 2024 17:26 — forked from timnovis/breadcrumb.php
WordPress Breadcrumbs & Schema Markup
<?php
/**
* Breadcrumbs
*
* @package nunosarmento
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
@nfsarmento
nfsarmento / functions.php
Last active January 26, 2024 16:34
WordPress menu itens to Swiper Slider
<?php
add_shortcode( 'wp-nav-slider', 'nav_slider' );
function nav_slider( $atts ) {
if(empty($atts['id'])){
echo 'enter menu id';
return;
}?>
<div class="nav-slider-main">
<div class="nav-slider-inner swiper-container">
@nfsarmento
nfsarmento / functions.php
Created October 1, 2021 10:06
Custom contact form shortcode - used for custom product enquiry on WooCommerce
/**
*
* Shortcode contact form
*/
// @codingStandardsIgnoreStart
function decorativefair_shortcode_product_form($item) {
ob_start();
global $post, $product;
$author_name = get_the_author_meta( 'user_email', $product->post->post_author );
@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 / WordPress shortoce to show Custom Post Type .php
Last active September 22, 2023 14:35
WordPress shortoce to show Custom Post Type
<?php
/**
*
* Usage [newscpt posts_per_page="4" term="4"] .
* Change post_type to your CPT name
* Change taxonomy to your taxonomy name
*
*/
// @codingStandardsIgnoreStart
@nfsarmento
nfsarmento / export-all-woo-subscripitions.sql
Created September 15, 2023 12:11
Export ALL subscriptions from WooCommerce Subscriptions using a MySQL query
SELECT
p.ID as 'Subscription ID',
p.post_status as 'Subscription Status',
pm1.meta_value as 'Billing First Name',
pm2.meta_value as 'Billing Last Name',
pm3.meta_value as 'Billing Email',
oitems.order_item_name as 'Product',
pm4.meta_value as 'Order Total',
pm5.meta_value as 'Order Tax'
FROM wp_posts p