Skip to content

Instantly share code, notes, and snippets.

/**
* Handles the bulk action.
*/
function my_bulk_action_handler( $redirect_to, $action, $post_ids ) {
if ( $action !== 'draft_posts' ) {
return $redirect_to;
}
foreach ( $post_ids as $post_id ) {
wp_update_post( array(
/**
* Shows a notice in the admin once the bulk action is completed.
*/
function my_bulk_action_admin_notice() {
if ( ! empty( $_REQUEST['bulk_draft_posts'] ) ) {
$drafts_count = intval( $_REQUEST['bulk_draft_posts'] );
printf(
'<div id="message" class="updated fade">' .
_n( '%s post moved to drafts.', '%s posts moved to drafts.', $drafts_count, 'domain' )
/**
* Prints the Breadcrumb in Storefront using the function by Yoast SEO.
*/
function storefront_yoast_breadcrumb() {
if ( function_exists( 'yoast_breadcrumb' ) && ! is_home() ) {
yoast_breadcrumb( '<nav class="breadcrumbs">','</nav>' );
}
}
add_action( 'storefront_content_top', 'storefront_yoast_breadcrumb' );
.breadcrumbs {
background-color: #f8f8f8;
margin-left: -99em;
margin-right: -99em;
margin-bottom: 4.235801032em;
padding: 1.41575em 99em;
}
.breadcrumbs a {
color: #92969e;
/**
* Print a View Comment link in the comments list in the admin.
*
* @param array $actions
* @return array
*/
function custom_view_comment_action( $actions ) {
global $comment;
if ( $comment->comment_type !== '' ) {
class WC_Custom_My_Account_Tabs extends WC_Query {
/**
* Adds main filters and actions and inits the endpoints.
*/
public function __construct() {
add_action( 'init', array( $this, 'add_endpoints' ) );
if ( ! is_admin() ) {
add_filter( 'query_vars', array( $this, 'add_query_vars' ), 0 );
add_filter( 'woocommerce_account_menu_items', array( $this, 'edit_navigation' ) );
@SirDarcanos
SirDarcanos / functions.php
Last active December 7, 2023 09:10
Add an Enquiry Form to The My Account Page in WooCommerce
<?php
class WC_Custom_My_Account_Tabs extends WC_Query {
/**
* Adds main filters and actions and inits the endpoints.
*/
public function __construct() {
add_action( 'init', array( $this, 'add_endpoints' ) );
if ( ! is_admin() ) {
add_filter( 'query_vars', array( $this, 'add_query_vars' ), 0 );
@SirDarcanos
SirDarcanos / contact.php
Created February 3, 2017 08:34
contact.php
<h2><?php echo esc_html( 'Contact Us!' ); ?></h2>
<p><?php echo esc_html( 'Do you need any help? Please feel free to contact us from here!' ); ?></p>
<?php echo do_shortcode( 'WRITE HERE YOUR CONTACT FORM 7 SHORTCODE' ); ?>
remove_action( 'storefront_footer', 'storefront_handheld_footer_bar', 999 );
// Get current user ID
$user_id = get_current_user_id();
// Check if the user is member of the plan 'gold'
if ( wc_memberships_is_user_active_member( $user_id, 'gold' ) ) {
echo 'This is a special message only for Gold members!';
} else {
echo 'I\'m sorry, you are not a gold member. There\'s nothing here for you!';
}