Skip to content

Instantly share code, notes, and snippets.

View delennerd's full-sized avatar

Pascal Lehnert delennerd

View GitHub Profile
@delennerd
delennerd / myShortcodeController.php
Created September 28, 2023 10:38
WordPress Custom Shortcode Controller
<?php
/**
* @since 1.0.0
* @package MyPlugin
* @subpackage PostType
* @author XXXXX
*/
namespace MyPlugin\Controllers;
@delennerd
delennerd / WordPress_functions_utils.php
Last active August 5, 2022 10:08 — forked from juanlopezdev/WORDPRESS_functions_utils.php
Useful functions for wordpress #php #wordpress
<?php
/**
* Funciones Útiles Wordpress / Useful functions for wordpress
*/
// Print Nav Menu
// https://developer.wordpress.org/reference/functions/wp_nav_menu/
//---------------------------------------------------------------
wp_nav_menu(array(
@delennerd
delennerd / WP Custom DB Tables .php
Created January 13, 2022 17:09
WordPress Custom DB Table
<?php
/**
* Install database tables
*/
public function db_install_recordings()
{
global $wpdb;
$table_name = $wpdb->prefix . "myprefix_mytable";
$charset_collate = $wpdb->get_charset_collate();
@delennerd
delennerd / AAA WordPress Advanced Functions
Last active January 14, 2022 08:57
WordPress Advanced Programming Functions - Some nice function to make your website nicer
WordPress Advanced Programming Functions - Some nice function to make your website nicer
@delennerd
delennerd / WC-Snippets.php
Last active January 7, 2024 17:59 — forked from mairagall/WC Snippets
WooCommerce Snippets
<?php
//Add a stylesheet after WC styles
add_action( 'wp_enqueue_scripts', 'maira_add_stylesheet' );
function maira_add_stylesheet() {
wp_register_style( 'woocommerce', get_stylesheet_directory_uri() . '/woocommerce/woocommerce.css' );
if ( class_exists( 'woocommerce' ) ) {
wp_enqueue_style( 'woocommerce' );
}
}
@delennerd
delennerd / wc-display-subcategories.php
Last active December 5, 2021 21:09
WooCommerce - Display subcategories on category page (set category as default shop page)
<?php
add_action( 'woocommerce_after_subcategory', 'dlm_display_subcategories_on_category', 12 );
function dlm_display_subcategories_on_category( $category )
{
$cat_id = $category->term_id;
$taxonomy = 'product_cat';
// Get subcategories of the current category
@delennerd
delennerd / bp-profile-tab-and-subnav.php
Created September 2, 2021 15:11 — forked from shanebp/bp-profile-tab-and-subnav.php
BuddyPress add profile tab and subnav
<?php
function add_animal_tabs() {
global $bp;
bp_core_new_nav_item( array(
'name' => 'Animals',
'slug' => 'animals',
'parent_url' => $bp->displayed_user->domain,
'parent_slug' => $bp->profile->slug,
@delennerd
delennerd / class-example-shortcode.php
Created September 1, 2021 07:59
WordPress: Register shortcodes with Class and Interfaces
<?php
/**
* @package DlmWpTheme
*/
// Exit if accessed directly.
defined('ABSPATH') || exit;
require_once dirname(__FILE__) . '/class-interface-package.php';
require_once dirname(__FILE__) . '/class-interface-package-shortcode.php';
@delennerd
delennerd / wp-config-sample.php
Last active June 10, 2022 18:29
Custom WordPress Config
<?php
/**
*
* Secret-Keys, Sprache und ABSPATH. Mehr Informationen zur wp-config.php gibt es auf der {@link http://codex.wordpress.org/Editing_wp-config.php
*
* und die Installationsroutine (/wp-admin/install.php) aufgerufen wird.
* Man kann aber auch direkt in dieser Datei alle Eingaben vornehmen und sie von wp-config-sample.php in wp-config.php umbenennen und die Installation starten.
*
* @package WordPress
*/
@delennerd
delennerd / category-manufacturer-or-subcategories.php
Last active December 4, 2021 15:44
WooCommerce - Display subcategories only on main category
<?php
// This function is used to display manufactures of products
// With ACF create a true/false field "show_manufacturer"
// Create main categories and subcategories (manufactures) and add a logo
/**
* Display subcategories of a main category - using ACF fields
* @author Pascal Lehnert
* @copyright 2021-02-28
*/