Skip to content

Instantly share code, notes, and snippets.

View Basilakis's full-sized avatar
🏠
Working from home

Basilis Kanonidis Basilakis

🏠
Working from home
View GitHub Profile
@Basilakis
Basilakis / wp-update.sh
Created December 18, 2020 18:23 — forked from pacoorozco/wp-update.sh
Backup and update a Wordpress Site using wp-cli
#!/usr/bin/env bash
##########################################################################
# Shellscript: Backup and update WordPress using wp-cli
# Author : Paco Orozco <paco@pacoorozco.info>
# Requires : wp-cli
##########################################################################
# Changelog
# 20170125: 1.0
# Adds a default option to upgrade only when it's needed.
# 20161220: 0.1
@Basilakis
Basilakis / linkedin-unfollow-everyone.js
Created October 27, 2020 15:18 — forked from brunolemos/linkedin-unfollow-everyone.js
Unfollow everyone on Linkedin
(() => {
let count = 0;
function getAllButtons() {
return document.querySelectorAll('button.is-following') || [];
}
async function unfollowAll() {
const buttons = getAllButtons();
@Basilakis
Basilakis / acf_repeater_shortcode.php
Created September 23, 2020 20:30 — forked from FranciscoG/acf_repeater_shortcode.php
An Advanced Custom Fields shortcode that allows to loop through a field with a repeater. This only handles simple cases, it can't handle nested repeater fields
<?php
/**
* ACF Pro repeater field shortcode
*
* I created this shortcode function because it didn't exist and it was being requested by others
* I originally posted it here: https://support.advancedcustomfields.com/forums/topic/repeater-field-shortcode/
*
* @attr {string} field - (Required) the name of the field that contains a repeater sub group
* @attr {string} sub_fields - (Required) a comma separated list of sub field names that are part of the field repeater group
* @attr {string} post_id - (Optional) Specific post ID where your value was entered. Defaults to current post ID (not required). This can also be options / taxonomies / users / etc
@Basilakis
Basilakis / functions.php
Created May 24, 2020 11:52
Get eventsON Related Events Further Details for Locations
// Related Events @+2.8
case 'relatedEvents':
$events = $EVENT->get_prop('ev_releated');
$events = !empty($events)? json_decode($events, true): false;
if($events && is_array($events)){
ob_start();
?>
<div class='evo_metarow_rel_events evorow bordb evcal_evdata_row'>
@Basilakis
Basilakis / single.php
Last active April 15, 2020 08:29
Check if WooCommerce Restrict Content user has Membership
<?php
/*
* More Refrences: https://docs.woocommerce.com/document/woocommerce-memberships-admin-hook-reference/
* Function that checked if user has access to this specific content
* Usage: if(can_user_access_content(get_current_user_id(),$post->ID)){ }
*/
function can_user_access_content($user_id,$post_id){
//check if there's a force public on this content
if(get_post_meta($post_id,'_wc_memberships_force_public',true)=='yes') return true;
$args = array( 'status' => array( 'active' ));
@Basilakis
Basilakis / functions.php
Last active March 27, 2020 09:23
Add Product Weight to WooCommerce Emails
add_action( 'woocommerce_order_item_meta_end', 'ts_order_item_meta_end', 10, 4 );
function ts_order_item_meta_end( $item_id, $item, $order, $plain_text, $product ){
global $product;
$product = wc_get_product();
echo $product->get_weight();
}
@Basilakis
Basilakis / cloudways-mautic.sh
Last active February 27, 2020 12:54 — forked from heathdutton/cloudways-mautic.sh
Recommended cron tasks for Mautic 2 in Cloudways.
# Recommended cron tasks for Mautic 2 in Cloudways.
# All tasks are ran as www-data
# Output is ignored to avoid log file overhead.
# --quiet is used to reduce MySQL overhead on some tasks.
# --max-contacts is used to prevent one object's backlog from locking updates for other object.
# SEGMENTS
# Update all segments.
*/5 * * * * php /home/master/applications/fwhtzfeudw/public_html/app/console mautic:segments:update --max-contacts=10000 --quiet >/dev/null 2>&1
@Basilakis
Basilakis / functions.php
Last active February 26, 2020 18:00
Change Status from Processing to Complete over WooCommerce
/**
* Auto Complete all WooCommerce orders.
*/
add_filter( 'woocommerce_payment_complete_order_status', 'cg_update_order_status', 10, 2 );
function cg_update_order_status( $order_status, $order_id ) {
$order = new WC_Order( $order_id );
if ( 'processing' == $order_status && ( 'on-hold' == $order->status || 'pending' == $order->status || 'failed' == $order->status ) ) {
@Basilakis
Basilakis / functions.php
Created September 30, 2019 20:11
Create Filters to be used over Post Type to short by category(ies)
function filter_cars_by_taxonomies( $post_type, $which ) {
// Apply this only on a specific post type
if ( 'car' !== $post_type )
return;
// A list of taxonomy slugs to filter by
$taxonomies = array( 'manufacturer', 'model', 'transmission', 'doors', 'color' );
foreach ( $taxonomies as $taxonomy_slug ) {
/**
* Event On Modificacitons for Columns
*/
// Remove the Default WordPress Columns
add_filter('manage_ajde_events_posts_columns', function ( $columns )
{
unset($columns['author'], $columns['tags']);
return $columns;
} );
// Remove the EventOn Event Type 2 column