Navigation Menu

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 / 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 / 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
@nfsarmento
nfsarmento / export-active-woo-subscripitions.sql
Last active September 15, 2023 12:11
Export all ACTIVE 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
@nfsarmento
nfsarmento / functions.php
Created July 4, 2023 19:46
Shortcode to show post title truncated
<?php
/**
*
* Shortcode to show post title truncated
*
* [posttitle]
*
*/
function ns_post_title_shortcode(){
return wp_trim_words( get_the_title(), 10 );
@nfsarmento
nfsarmento / functions.php
Created July 4, 2023 19:45
Shortcode to show parent category
<php
/**
*
* Shortcode to show parent category
*
* [postcat]
*
*/
function ns_post_cat_shortcode(){
@nfsarmento
nfsarmento / functions.php
Created July 4, 2023 19:44
Post estimated reading time shortcode
<?php
/**
*
* Post estimated reading time shortcode
*
*/
function ns_reading_time_shortcode() {
$content = get_post_field( 'post_content', $post->ID );
@nfsarmento
nfsarmento / functions.php
Created March 29, 2023 14:36
Add new WooCommerce account menu item for a specific members role
<?php
/*
*
* Add new WooCommerce account menu item for a specific members role
*
* */
add_filter ( 'woocommerce_account_menu_items', 'ns_members_link', 40 );
function ns_members_link( $menu_links ){
$product_ids = array( 38, 41, 85, 95 );