Skip to content

Instantly share code, notes, and snippets.

@bainternet
bainternet / 0-toc.md
Created Sep 16, 2020 — forked from benlk/0-toc.md
Collection of notes on WP_UnitTestCase
View 0-toc.md
  1. Table of contents
  2. General information
    1. Terms
    2. General structure of a test
    3. WordPress-specific assertions and test functions
      • enqueues
      • creating posts
      • creating terms
      • attaching images
      • ?
@bainternet
bainternet / export_database_with_replace.sh
Created Apr 18, 2020 — forked from jan-koch/export_database_with_replace.sh
Bash script to export a database from a WordPress container and perform a search/replace using the UNIX command "sed". Script is based on https://hub.docker.com/r/jankoch/wordpress.
View export_database_with_replace.sh
#! /bin/bash
CONTAINER=$1
SEARCH=$2
REPLACE=$3
# Dump the file
DUMP=$(docker exec $CONTAINER wp db export --add-drop-table --porcelain)
View How to add custom fields to posts and pages in WordPress.md

How to add custom fields to posts and pages in WordPress

Ever want to capture more data when creating a post or a page? Want to add some custom fields to your custom post type?

With WordPress’s metabox functionality, you can! There are a few moving parts here, so let’s walk through them one-by-one.

Quick aside: I’m going to share some PHP snippets. Place them in a plugin, or (less ideally) your functions.php file.

Create your metabox #

@bainternet
bainternet / php-server-with-wordpress.md
Created Jan 8, 2020 — forked from ginfuru/php-server-with-wordpress.md
Using PHP's built in server for WordPress development.
View php-server-with-wordpress.md

Preface

So in the past, I've used MAMP/MAMP Pro apps and others alike. I've also, setup my own local MAMP stack with homebrew, that used dnsmasq to dynamically add vhosts anytime I added a new folder to the Sites folder which made it very convenient. But, then I started running into other environment issues with PHP versions on remote machines/servers not being updated or some other crazy thingamabob breaking. I researched and invested time in Vagrant, but that seem to break more often than my homebrew setup. So I researched again investing time into Docker via Docker for Mac (which is BAMF), which I'm sold on and use daily, but it still seems a little bleeding edge and not so simple to wrap your head around the concept. Not to mention I don't have a real use case to play with and take advantage of all the features that come packed with Docker.

This is the beginning of trying to find something more simple, and slightly quicker to setup.

@bainternet
bainternet / collapse_sections.php
Created Jun 16, 2019 — forked from SJ-James/collapse_sections.php
Add a 'Collapse Section' button to the Elementor Editor
View collapse_sections.php
<?php
//Add to functions.php in child theme
function e_collapse_sections(){
?>
<!-- Scripts and styles should enqueued properly but for the sake of having it all in one function...-->
<script>
if ( self !== top ) { // Check if we're in a preview window / iframe
jQuery(document).ready(function($){
View elementor-form-additional-webhook.php
<?php
/**
* Plugin Name: Elementor Form Additional Webhook
* Plugin URI: https://coreysalzano.com/
* Description: Adds a second Webhook to the Lot Wizard trial signup form
* Version: 1.0.0
* Author: Corey Salzano
* Author URI: https://github.com/mistercorey
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
@bainternet
bainternet / file.php
Created Oct 11, 2018
dd support for "Addify - Hide Product Price" to Elementor Price, and Add to Cart widgets
View file.php
<?php
/**
* Add support for "Addify - Hide Product Price" to
* Elementor Price, and Add to Cart widgets
*/
add_filter( 'elementor/widget/render_content', function ( $widget_content, $widget ) {
global $product;
// Make sure its an add to cart or price widget
$widget_name = $widget->get_name();
if ( ! in_array( $widget_name, [ 'wc-add-to-cart', 'woocommerce-product-price' ] ) ) {
@bainternet
bainternet / GitHubIntegration.gs
Created Oct 11, 2018 — forked from ZachBray/GitHubIntegration.gs
Google Sheets GitHub Issue Integration
View GitHubIntegration.gs
var paramsSheetName = "GitHub Params";
function createGitHubParams() {
var sheets = SpreadsheetApp.getActiveSpreadsheet();
var sheet = sheets.insertSheet(paramsSheetName);
sheet.appendRow(["API Token", "TODO"]);
sheet.appendRow(["Owner", "TODO"]);
sheet.appendRow(["Repository", "TODO"]);
}
View coundown-evergreen.php
<?php
namespace ElementorLandingPress\Widgets;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Typography;
use Elementor\Scheme_Color;
use Elementor\Scheme_Typography;
use Elementor\Utils;
use Elementor\Widget_Base;
@bainternet
bainternet / elementor-custom-templates.php
Created Dec 7, 2017 — forked from Tmeister/elementor-custom-templates.php
You can show *your* page templates in the predesigned templates area with screenshots
View elementor-custom-templates.php
<?php
/**
* Elementor get the local templates via a CPT query and use a filter to let us change the template data
* https://github.com/pojome/elementor/blob/master/includes/template-library/sources/local.php#L202
* In ouy theme or plugin we can hook that filter as follow
*
* This filter change the source only for the *page* template type to show it in the main tab
* @see https://cl.ly/1z2Y1n2x0K0F
**/
You can’t perform that action at this time.