Skip to content

Instantly share code, notes, and snippets.

View moabi's full-sized avatar
🎯
Focusing

David Fieffé moabi

🎯
Focusing
View GitHub Profile
@danielbachhuber
danielbachhuber / add-rel-nofollow-checkbox.php
Created February 13, 2017 17:06
Add a 'Add rel="nofollow" to link' checkbox to the WordPress link editor
<?php
/**
* Add a 'Add rel="nofollow" to link' checkbox to the WordPress link editor
*
* @see https://danielbachhuber.com/tip/rel-nofollow-link-modal/
*/
add_action( 'after_wp_tiny_mce', function(){
?>
<script>
@phlbnks
phlbnks / wp_helper.sh
Last active April 16, 2021 18:02
Utility script to help manage WordPress sites on an EasyEngine server (but not limited to EE)
#!/bin/bash
# Help / usage info.
USAGE=$'WordPress Helper script, built for EasyEngine but should be widely compatible.\nWithout any args it will search /var/www/ for WordPress sites, loop over them in alphabetical order and check for core and plugin updates.\nAlso accepts:\n\t--sites=[space seperated list of site paths relative to /var/www]\n\t--update=[plugins|wp|all].'
# Die function for exiting on errors.
die () {
echo "${1}, exitting..." >&2 ; echo ; exit 1
}
@bentasm1
bentasm1 / functions.php
Last active January 12, 2017 16:30 — forked from digitalchild/functions.php
How to make a field required in WC Vendors Pro
To require, or not to require, that is the question...... In the future, we'll make these into checkboxes to require/not require,
but for now you use filters. Add this code to your themes functions.php file. Here's the process:
1.) Find the filter for the field you want to adjust the requirements. This file is in /plugins/wc-vendors-pro/public/forms/class-wcvendors-pro-product-form.php
2.) Create a filter for each field you'd like to make required (or not required). The code below will make the description required:
/* WC Vendors Pro - Make Description Required */
function wcv_product_description_required( $args ) {
$args[ 'custom_attributes' ] = array(
@bentasm1
bentasm1 / functions.php
Last active January 12, 2017 16:30
WC Vendors Notify Vendor when Product is Approved
/* WC Vendors Pro - Notify Vendor when Product is Approved */
add_action( 'pending_to_publish', 'wcv_notify_vendor_on_publish' );
function wcv_notify_vendor_on_publish( $post_id ) {
global $post;
if ( $post->post_author != get_current_user_id() ) {
$author = new WP_User( $post->post_author );
$email_data = array(
'to' => $author->user_email,
'subject' => sprintf( __( 'Your post on %1$s has been published!', 'email_author_on_publish' ), get_bloginfo('name') ),
'message' => sprintf( __( 'Your post "%1$s" on %2$s has been published: %3$s', 'email_author_on_publish' ), $post->post_title, get_bloginfo( 'name' ), get_permalink( $post->ID ) ),
@bentasm1
bentasm1 / product-edit.php
Created January 6, 2016 02:07 — forked from digitalchild/product-edit.php
WC Vendors Pro Form Input Type Examples
<?php
/**
* Example text input with validation
*/
WCVendors_Pro_Form_Helper::input(
array(
'post_id' => $object_id,
'id' => '_wcv_custom_product_example_text_input',
'label' => __( 'Product Meta Text Input', 'wcvendors-pro' ),
@bentasm1
bentasm1 / functions.php
Created January 5, 2016 03:32
WooCommerce - Collect buyers First and Last Name at Registration
/* BEGIN REGISTRATION FIELDS */
function cs_wc_extra_register_fields() {
?>
<p class="form-row form-row-first">
<label for="reg_billing_first_name"><?php _e( 'First Name', 'textdomain' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="billing_first_name" id="reg_billing_first_name" value="<?php if ( ! empty( $_POST['billing_first_name'] ) ) esc_attr_e( $_POST['billing_first_name'] ); ?>" />
</p>
<p class="form-row form-row-last">
<label for="reg_billing_last_name"><?php _e( 'Last Name', 'textdomain' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="billing_last_name" id="reg_billing_last_name" value="<?php if ( ! empty( $_POST['billing_last_name'] ) ) esc_attr_e( $_POST['billing_last_name'] ); ?>" />
@bentasm1
bentasm1 / functions.php
Last active September 13, 2016 14:57 — forked from digitalchild/wcv_vendors_menu
WC Vendors Free & Pro Dynamic Vendor Menus
// Place this in your themes functions.php
// This will put the menu item in your primary menu. Change the theme location if you want to change which menu this goes in.
// Use the Free code for WC Vendors Free, use the Pro code for WC Vendors Pro
/* BEGIN WC Vendors Free */
add_filter( 'wp_nav_menu_items', 'wcv_vendors_menu', 10, 2 );
function wcv_vendors_menu ( $items, $args ) {
if ($args->theme_location == 'primary') {
$vendors = get_users( array( 'role' => 'vendor' ) );
$items .= '<li><a href="#">Vendors</a>';
@mathpere
mathpere / config.json
Created November 18, 2014 18:35
PayZen with NodeJS
{
"payZen": {
"url": "https://secure.payzen.eu/vads-payment/",
"certificat": "XXXXXXXXX",
"vads_site_id": "YYYYYYYY",
"vads_version": "V2",
"vads_ctx_mode": "TEST"
}
}
<?php
/**
* Create ACF setting page under Events CPT menu
*
* @since 1.0.0
*/
if ( function_exists( 'acf_add_options_sub_page' ) ){
acf_add_options_sub_page(array(
'title' => 'Event Settings',
'parent' => 'edit.php?post_type=events',
@wpscholar
wpscholar / functions.php
Last active March 1, 2021 13:26
Enqueueing IE conditional stylesheets in WordPress the right way
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_my_styles' );
/**
* Example callback function that demonstrates how to properly enqueue conditional stylesheets in WordPress for IE.
* IE10 and up does not support conditional comments in standards mode.
*
* @uses wp_style_add_data() WordPress function to add the conditional data.
* @link https://developer.wordpress.org/reference/functions/wp_style_add_data/