Skip to content

Instantly share code, notes, and snippets.

View mklasen's full-sized avatar

Marinus Klasen mklasen

View GitHub Profile
@mklasen
mklasen / flex-video-logic.php
Last active March 17, 2018 16:08
flex-video-logic.php
<?php
register_post_type('video', array(
'label' => 'Videos'.
'public' => true,
'menu_icon' => 'dashicons-video-alt3',
));
register_taxonomy( 'Category', 'video', array('label' => 'Categories', 'hierarchical' => true));
add_shortcode('flex-videos', 'flex_videos_shortcode');
@mklasen
mklasen / element-image-fields.php
Last active March 19, 2018 12:19
WPH Field Groups
<?php
$image_element = array(
// Adds first tab + tab content
array(
'key' => 'image_tab_1',
'label' => __('Image', 'hortus-field-groups'),
'type' => 'tab',
),
// The actual image
@mklasen
mklasen / acf.fields.php
Created July 23, 2018 08:39
Example fields for ACF (simple, in PHP)
if ( function_exists( 'acf_add_local_field_group' ) ):
acf_add_local_field_group( array(
'key' => 'key_name',
'title' => 'Title',
'fields' => array(
array(
'label' => 'Group',
'key' => 'key',
'name' => 'name',
'type' => 'group',
@mklasen
mklasen / quantity-arrows.css
Last active July 31, 2021 10:30
Add arrow buttons to woocommerce quantity input elements
div.quantity {
position: relative;
margin: 0 0 1rem;
}
div.quantity div.arrows {
padding: 1px 0;
position: absolute;
display: flex;
flex-direction: column;
right: 0;
$args = \Inpsyde\MultilingualPress\Framework\Api\TranslationSearchArgs::forContext(new \Inpsyde\MultilingualPress\Framework\WordpressContext())
->forSiteId(get_current_blog_id())
->includeBase();
$translations = \Inpsyde\MultilingualPress\resolve(
\Inpsyde\MultilingualPress\Framework\Api\Translations::class
)->searchTranslations($args);
var_dump($translations);
@mklasen
mklasen / wp-cli-command-example.php
Last active November 2, 2018 14:07
WP CLi Command
<?php
/*
* Plugin Name: WP CLI Command Example
* Author: Marinus Klasen
* Description: WP CLI Command Example
*/
/*
Command: wp cli mk example
*/
@mklasen
mklasen / remove-product-base.php
Created November 13, 2018 08:21
Remove /products/ slug from Yoast Breadcrumb in Woocommerce Product Page
<?php
add_filter( 'wpseo_breadcrumb_links', function($items) {
// Remove second array item
if( is_product() ) {
unset( $items[1] );
}
// Sort array
ksort($items);
@mklasen
mklasen / create-local-user.sh
Created January 4, 2019 08:38
Create new user for local development with WP-CLI
wp user create wpadmin [email protected] --user_pass=password
wp user set-role wpadmin administrator
# Multisite:
wp super-admin add wpadmin
## For each multisite url
wp user set-role wpadmin administrator --url=domain.test/subsite
@mklasen
mklasen / reliable-plugins.txt
Last active March 15, 2019 08:46
Reliable WordPress Plugins
- woo-product-feed-pro
- sympose
@mklasen
mklasen / acf-fields-array.php
Last active April 29, 2019 12:09
Add content to Woocommerce e-mails with ACF Fields
<?php
$acf_field = array(
'key' => 'woocommerce_emails',
'label' => 'Woocommerce e-mails',
'name' => 'woocommerce_emails',
'type' => 'repeater',
'layout' => 'row',
'sub_fields' => array(
array(
'key' => 'id',