Skip to content

Instantly share code, notes, and snippets.

@Dannyholt
Dannyholt / menu_items.php
Last active February 6, 2018 18:59
Unset BB UI menu items. Add this to your child theme's functions.php file. (2.0) Unset BB UI menu items.php
add_filter( 'fl_builder_main_menu', function( $views ) {
unset( $views['main']['items'][100]); // Admin Menu Item
unset( $views['main']['items'][120]); // Keyboard Shortcuts Item
return $views;
});
@tlctara
tlctara / Beaver Builder Mega Menu Integration CSS Example
Last active May 8, 2020 15:43
CSS to customize Beaver Builder Mega Menu with columns as sub pages, images and intro text
/* This code hides the column headers when they are a sub-menu item */
.fl-menu .sub-menu .fl-has-submenu-container {
display:none;
}
/* This code styles the images and intro text in the mega menu */
.menu-image a {
visibility: hidden;
margin-top: -20px!important;
}
@gemmadlou
gemmadlou / remove-visual-composer-shortcodes.md
Last active April 20, 2024 14:56
Removing Visual Composer & Shortcodes From Wordpress Content

Adding @k1sul1's suggestion from the comments as it's more concise than what I had before:

I just wanted them all gone, so I ran this in the MySQL shell.

UPDATE wp_posts SET post_content = REGEXP_REPLACE(post_content, "\\[\/?vc(.*?)\]", "");

Note the double backslash. If you forget it, you'll replace all v's and c's with nothing, and the shortcodes will still be there. This works for other shortcode as well, just replace vc.

@tripflex
tripflex / functions.php
Last active May 4, 2022 14:07
Automatically set/assign parent taxonomy terms for hierarchical taxonomies in WordPress (job listings, with job_listing_category taxonomy)
<?php
add_action( 'set_object_terms', 'auto_set_parent_terms', 9999, 6 );
/**
* Automatically set/assign parent taxonomy terms to posts
*
* This function will automatically set parent taxonomy terms whenever terms are set on a post,
* with the option to configure specific post types, and/or taxonomies.
*
*
* @param int $object_id Object ID.
@scottopolis
scottopolis / wp-api-user-meta.php
Last active April 18, 2020 19:13
Add user meta to the WP-API
<?php
/* Adds all user meta to the /wp-json/wp/v2/user/[id] endpoint */
function sb_user_meta( $data, $field_name, $request ) {
if( $data['id'] ){
$user_meta = get_user_meta( $data['id'] );
}
if ( !$user_meta ) {
return new WP_Error( 'No user meta found', 'No user meta found', array( 'status' => 404 ) );
}
@tomazzaman
tomazzaman / class-developer-import.php
Created March 31, 2015 18:03
Import JSON into WordPress
<?php
// Published under GPL
// tutorial here: https://codeable.io/community/how-to-import-json-into-wordpress/
class Developer_Import {
public function __construct() {
add_action( 'wp_ajax_import_developer', array( $this, 'import_developer' ) );
@renventura
renventura / class-edd-gf-product-reviews.php
Last active March 28, 2018 00:03
Gravity Forms EDD Product Reviews
<?php
/**
* Class file for adding EDD Gravity Forms product reviews
*
* Creates a new review post on a Gravity Forms submission and associates it with the correct product
* @author Ren Ventura <EngageWP.com>
*/
class EDD_GF_Reviews {
@bappi-d-great
bappi-d-great / How to write dynamic css in a php file in wordpress.php
Last active February 11, 2019 18:48
How to write dynamic css in a php file in wordpress
<!-- functions.php -->
<?php
add_action( 'wp_enqueue_scripts', 'theme_custom_style_script', 11 );
function theme_custom_style_script() {
wp_enqueue_style( 'dynamic-css', admin_url('admin-ajax.php').'?action=dynamic_css', '', VERSION);
}
add_action('wp_ajax_dynamic_css', 'dynamic_css');
add_action('wp_ajax_nopriv_dynamic_css', 'dynamic_css');
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@CMCDragonkai
CMCDragonkai / angularjs_directive_attribute_explanation.md
Last active November 29, 2023 15:35
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>