Skip to content

Instantly share code, notes, and snippets.

View j-mccarthy's full-sized avatar
💭
passing by

John McCarthy j-mccarthy

💭
passing by
  • flowethic
  • United Kingdom
View GitHub Profile
<?php
/**
*
* You can find the complete tutorial for this here:
* https://pluginrepublic.com/woocommerce-custom-fields
*
* Alternatively, check out the plugin
* https://pluginrepublic.com/wordpress-plugins/woocommerce-product-add-ons-ultimate/
*
@wpscholar
wpscholar / wp-rest-api-add-gutenberg-blocks.php
Last active March 15, 2022 01:19
Surface all Gutenberg blocks in the WordPress REST API
<?php
add_action('rest_api_init', function() {
// Surface all Gutenberg blocks in the WordPress REST API
$post_types = get_post_types_by_support( [ 'editor' ] );
foreach ( $post_types as $post_type ) {
if ( gutenberg_can_edit_post_type( $post_type ) ) {
@helgatheviking
helgatheviking / add-taxonomy-to-woocommerce-export.php
Last active May 22, 2024 03:15
Add a custom taxonomy to WooCommerce import/export
<?php
/*
* Plugin Name: WooCommerce Add Taxonomy to Export
* Plugin URI: https://gist.github.com/helgatheviking/114c8df50cabb7119b3c895b1d854533/
* Description: Add a custom taxonomy to WooCommerce import/export.
* Version: 1.0.1
* Author: Kathy Darling
* Author URI: https://kathyisawesome.com/
*
* Woo: 18716:fbca839929aaddc78797a5b511c14da9
@HoangPV
HoangPV / str_putcsv.php
Created September 13, 2017 08:41
Convert a multi-dimensional, associative array to CSV data
<?php
/**
* Convert a multi-dimensional, associative array to CSV data
* @param array $data the array of data
* @return string CSV text
*/
function str_putcsv($data) {
# Generate CSV data from array
$fh = fopen('php://temp', 'rw'); # don't create a file, attempt
# to use memory instead
@Shelob9
Shelob9 / caldera_forms_manage_cap1.php
Last active October 18, 2020 19:29
Examples of how to change the capabilities for what kind of user can use Caldera Forms admin via the caldera_forms_manage_cap filter SEE: https://calderaforms.com/doc/caldera_forms_manage_cap/
<?php
/**
Allow users with the editor role to use the Caldera Forms admin screen
*/
add_filter( 'caldera_forms_manage_cap', function( $cap, $context ) {
if( 'admin' == $context ) {
return 'edit_pages';
}
return $cap;

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@azizultex
azizultex / Change slug ( add_rewrite_rule ) of already registered taxonomy or custom post type
Last active January 4, 2022 14:09
Change slug ( add_rewrite_rule ) of already registered taxonomy or custom post type
/***************************************************
USING add_rewrite_rule
****************************************************/
/* azizultex
1. https://www.ait-themes.club/knowledge-base/how-can-i-change-items-slug-and-slug-of-other-custom-post-types/
2. http://wordpress.stackexchange.com/questions/41988/redeclare-change-slug-of-a-plugins-custom-post-type
3. http://wordpress.stackexchange.com/questions/134322/rewrite-rule-for-custom-taxonomy
*/
@noelboss
noelboss / git-deployment.md
Last active May 16, 2024 20:41
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

// 1/4 width on Desktop and adjust appropriately based on device size
@mixin one-quarter {
@include media($small-screen) {
@include span-columns(2);
@include omega(1n);
}
@include media($medium-screen) {
@include span-columns(2);
@include omega(2n);
}
<?php
add_filter( 'genesis_attr_site-inner', 'sk_attributes_site_inner' );
/**
* Add attributes for site-inner element.
*
* @since 2.0.0
*
* @param array $attributes Existing attributes.
*