Skip to content

Instantly share code, notes, and snippets.

@britweb-tim
britweb-tim / wp-cli-wc-import-csv.php
Last active November 18, 2024 23:03
Add a WP CLI Command for importing woocommerce products from csv
<?php
// Add a WP CLI Command which allows import of CSV files from the command line.
if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once WP_PLUGIN_DIR . '/woocommerce/includes/import/class-wc-product-csv-importer.php';
// Maybe require and invoke any other filters you need here as theme/plugins may not be loaded at this point.
class WP_CLI_WC_Import_CSV {
@Phoenix2k
Phoenix2k / wordpress-custom-tax-columns.php
Created December 12, 2017 14:13
WordPress: Custom taxonomy columns with sorting support
<?php
/**
* This example uses 'main-category' as a custom taxonomy and values
* from Carbon Fields for sorting https://carbonfields.net
*/
// Add custom column title
add_filter( 'manage_edit-main-category_columns', function( $columns ) {
$column_position = 2;
$before = array_slice( $columns, 0, $column_position, true );
@mattclements
mattclements / function.php
Last active October 29, 2024 22:04
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@tomfinitely
tomfinitely / move-excerpt.php
Created June 16, 2015 21:19
WordPress - Move Excerpt Above Content Metabox
/* -----------------------------------------
* Put excerpt meta-box before editor
* ----------------------------------------- */
add_action( 'add_meta_boxes', 'my_add_excerpt_meta_box' );
function my_add_excerpt_meta_box( $post_type ) {
if ( in_array( $post_type, array( 'tribe_events' ) ) ) {
add_meta_box(
'contact_details_meta', __( 'Excerpt' ), 'post_excerpt_meta_box', $post_type, 'test', // change to something other then normal, advanced or side
'high'
@salcode
salcode / .gitignore
Last active February 19, 2025 22:44
Please see https://salferrarello.com/wordpress-gitignore/ for the canonical version of this WordPress .gitignore file. Note: I do not receive notifications for comments here (because GitHub does not send notifications on Gists)
# -----------------------------------------------------------------
# .gitignore for WordPress @salcode
# ver 20180808
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/salcode/b515f520d3f8207ecd04/raw/.gitignore
# to download this file
#
# By default all files are ignored. You'll need to whitelist
# any mu-plugins, plugins, or themes you want to include in the repo.
@n1shantshrivastava
n1shantshrivastava / readme.md
Last active August 13, 2021 19:56
Send Mail Configuration : Disable Local Delivery

What I did to disable local delivery. I'll be using the example.com domain.

Requirements:

  • example.com A entry pointing to IP address assigned to one of the eth interfaces.
  • /etc/hosts defining example.com assigned to the very same IP address as above
  • example.com MX records pointing to Google servers (ASPMX.L.GOOGLE.COM, etc)
  • default sendmail installation (mine was on Ubuntu)