Skip to content

Instantly share code, notes, and snippets.

View quasel's full-sized avatar
🙃
Don't worry be happy!

Bernhard quasel

🙃
Don't worry be happy!
View GitHub Profile
@quasel
quasel / beaver-builder-css-class-selector.php
Created August 1, 2018 06:00 — forked from webmandesign/beaver-builder-css-class-selector.php
Beaver Builder 2.1.4+ CSS class selector integration
<?php
// START COPYING HERE...
// Requires Beaver Builder v2.1.4 and newer!
/**
* Populates CSS classes dropdown selector with custom classes selection.
*
* Hooks onto `fl_builder_field_js_config` filter hook. See Beaver Builder code directly
* for filter hook attributes (in `classes/class-fl-builder-ui-settings-forms.php` file).
/**
* Beaver Themer: WooCommeece Module:
* Single category archive page template for WooCommerce
*
* You get a checkbox saying autoselect parent,
* when it's set to true, the parent_id field gets hidden
* and the parent_id will be automatically set, when it's false the user can enter a parent_id
*/
add_filter('fl_builder_before_render_module', function($module) {
@quasel
quasel / gist:7673c96713ccb8cf264cf672ecaf47e3
Created July 14, 2018 18:44 — forked from nicdford/gist:3ecb45803e0935cf9b49
Control output of looped items
/*========== In Pods Template, Use Function on Field Output ==========*/
{@legend_items,add_icons}
/*========== Add to functions.php ==========*/
function add_icons($items) {
// loop through items
foreach ($items as $item) :
@quasel
quasel / custom-hooks.php
Created July 10, 2018 17:07 — forked from djrmom/custom-hooks.php
facetwp index a field in a related post type
<?php
/**
** look up and index a value from a post relationship field
** set the datasource to the relationship field
** get the post id of that related post and use it to
** lookup its associated value
** for ACF you may want get_field() instead of get_post_meta()
** remember to do a full re-index after adding code
** check the wp_facetwp_index table if needed to see what values are being indexed
**/
@quasel
quasel / custom-hooks.php
Created July 2, 2018 14:48 — forked from djrmom/custom-hooks.php
facetwp index checkbox saved as array
<?php
/** index a serialized checkbox
** run reindex after adding code to your site
**/
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( 'my_facet' == $params['facet_name'] ) { // change my_facet to name of your facet
$values = maybe_unserialize( $params['facet_value'] );
if ( is_array( $values ) && ! empty( $values ) ) {
foreach ( $values as $value ) {
<?php
/**
* Plugin initialization file
*
* @package WP_Plugin_MU_Loader
* @since 1.0.0
*
* @wordpress-plugin
* Plugin Name: WP Plugin MU Loader
* Plugin URI: https://gist.github.com/felixarntz/daff4006112b60dfea677ca08fc0b31c
@quasel
quasel / nginx.conf
Created June 25, 2018 18:14
WordPress+Plesk+Nginx Config
# Source: https://www.websavers.org/how-to-speed-up-wordpress/
rewrite !\.(js|ico|gif|jpg|png|css|pdf|mov|mp3|eot|svg|ttf|woff|otf|txt|swf)$ /index.php break;
rewrite /wp-admin/$ /wp-admin/index.php break;
rewrite /$ /index.php break;
# enable gzip compression
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/plain application/x-javascript text/xml text/css;
@quasel
quasel / functions.php
Created June 18, 2018 06:29
Heartbeat API example usage for Post Locking on frontend
<?php
/**
* Add display name / role for post locking dialogs.
*
* @param array $response The Heartbeat response.
* @param array $data The $_POST data sent.
* @param string $screen_id The screen id.
*
* @return array The Heartbeat response.
@quasel
quasel / gist:30ebb948b5d594d31274953dbdb1220c
Created June 7, 2018 17:54 — forked from sc0ttkclark/gist:8768847
pods_api_post_save_pod_item_{pod} hook example
<?php
/**
* Filter the Pods saving process and run actions / modify values
*
* @param array $pieces An array of different variables you can *change*, see below
*
* List of $pieces variables includes:
*
* array $pieces['fields'] An array of fields on the Pod, 'value' key stores the *new* value if it's been set to save
*
@quasel
quasel / custom-menu-items.php
Created May 20, 2018 07:31 — forked from daggerhart/custom-menu-items.php
WordPress class for easily adding custom menu items dynamically to a menu.
<?php
class custom_menu_items {
// only register with wp hooks once
protected $has_registered = false;
// internal list of menus affected
public $menus = array();
// internal list of new menu items