Skip to content

Instantly share code, notes, and snippets.

View mennwebs's full-sized avatar

Menn mennwebs

View GitHub Profile
@greird
greird / slack-files-downloader.sh
Last active October 9, 2024 09:45
Download all files from a Slack workspace export folder.
#!/bin/bash
#
# This script will browse a Slack export folder and download all files in a new /export folder
#
# HOW TO:
# 1. As a Workspace admin, download an export of your Slack history (https://www.slack.com/services/export)
# 2. Make sure you have jq installed (https://stedolan.github.io/jq/)
# 3. Place this file at the root of your Slack export folder, next to channels.json
# 4. Run `bash slack-files-downloader.sh` in your terminal
#
@pbrocks
pbrocks / install-phpcs-with-homebrew.md
Last active June 3, 2024 14:27
Install phpcs with Homebrew

Install phpcs with Homebrew

To set up php linting, you’ll want to install this PHP CodeSniffer repo and configure with this WordPress Coding Standards repo: . There are a number of ways to do this, whether direct download, Composer, Homebrew, Pear, etc. The following is what works for me on MacOS using Homebrew:

In a terminal window on your Mac, start by updating your Homebrew.

brew doctor

Then install the Code Sniffer:

@chaance
chaance / wp-get-primary-tax-term.php
Last active September 11, 2020 08:13
Get the Yoast SEO primary term for a given taxonomy.
<?php
/**
* Get primary taxonomy term (YoastSEO).
*
* @param mixed $taxonomy Taxonomy to check for.
* @param boolean $term_as_obj Whether to return an object or the term name.
* @param int $post_id Post ID.
* @return mixed The primary term.
*/
function xx_get_primary_tax_term( $taxonomy = 'category', $term_as_obj = true, $post_id = 0 ) {
@felixarntz
felixarntz / wp-alignment-classes.css
Created November 24, 2017 15:52
New WordPress alignment classes introduced by Gutenberg
/* -------------------------------------------------------------
# Variables
------------------------------------------------------------- */
$site_maxwidth: 72rem; // Maximum width the entire site should not exceed
$site_maxwidth-text: 40rem; // Maximum width the main content text should not exceed
$spacing_horizontal: 1rem; // General horizontal padding
/* -------------------------------------------------------------
# General Styles
@djrmom
djrmom / custom-hooks.php
Last active August 25, 2020 16:01
facetwp index only direct children of a parent term
<?php
/**
** filter on facetwp_index_row to index only direct children of a parent term
** this is for use with Parent term setting which by default indexes child terms, and grand child terms, etc
** If you want to have the index include posts of child/grandchild, etc of terms, you need to set Hierarchical to yes
**/
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( in_array( $params['facet_name'], array( 'my_facet', 'my_other_facet' ) ) ) { // create an array of facet names to check against
$parent = $class->facet['parent_term']; // this gives the parent term from the facet's settings
@Jany-M
Jany-M / wp_ics.php
Last active September 19, 2023 03:15 — forked from jakebellacera/ICS.php
[WP] Generate a downloadable .ics file from any WordPress post or custom post type
<?php
/*
For a better understanding of ics requirements and time formats
please check https://gist.github.com/jakebellacera/635416
*/
// UTILS
// Check if string is a timestamp
@kontikidigital
kontikidigital / functions.php
Last active January 14, 2021 09:42
WooCommerce: Change Select Options Button Text for variable products
add_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text' );
/**
* custom_woocommerce_template_loop_add_to_cart
*/
function custom_woocommerce_product_add_to_cart_text() {
global $product;
$product_type = $product->get_type();
switch ( $product_type ) {
@benhuson
benhuson / htaccess-not-ip-redirect.txt
Last active May 15, 2019 01:26
.htaccess rules for redirecting if IP address does not match.
# Redirect other IP addresses
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Single IP Address
RewriteCond %{REMOTE_HOST} !^00.00.00.00
# Multiple IP Addresses
RewriteCond %{REMOTE_HOST} !^(00.00.00.00|00.00.00.00)
RewriteRule .* http://www.example.com/ [R=301,L]
@escopecz
escopecz / functions.md
Last active April 3, 2019 04:39
Set expiration date for Easy Digital Downloads Wordpress plugin

Here is solution for Easy Digital Downloads WP plugin to disable downloads one year after purchase.

Place these 3 functions to /wp-content/themes/{your_theme}/functions.php:

/**
 * Function returns expiration date based on post / payment date.
 * Replace '365 day' with your time period.
 * 
 * @param string date of post / payment