Skip to content

Instantly share code, notes, and snippets.

View renatonascalves's full-sized avatar
🇧🇷

Renato Alves renatonascalves

🇧🇷
View GitHub Profile
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@khromov
khromov / gist:740578d08abd86dd093e
Last active July 26, 2016 12:08
WordPress CRON

So how does WP CRON work? Whenever an admin user loads WordPress, WP checks whether any CRON jobs need to run (they are scheduled by timestamp), and if they do, WordPress makes a secondary request to itself using the spawn_cron() function. This secondary page load will load /wp-cron.php, which in turn loads another full copy of WP.

Now we're in the secondary CRON request, you can see this as being run asynchronously with the request that spawned it - spawn_cron() uses a cute little trick and sets a very low timeout value when calling the secondary CRON request, the result being both requests run in parallel, see here: https://github.com/WordPress/WordPress/blob/2f3e567f44e7bc335b6795713ae970b4f37117cd/wp-includes/cron.php#L297

@johnbillion
johnbillion / wp_mail.md
Last active January 27, 2024 14:06
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This documentation has moved here: https://github.com/johnbillion/wp_mail

@lucnap
lucnap / fb-page-access-token-no-expire
Last active October 22, 2021 09:53
How to get a Facebook Page Access Token that doesn't expire Never!
How to get a Facebook Page Access Token that doesn't expire Never!
- Go to http://developers.facebook.com/tools/explorer/
- Get a User Access Token with a permission "manage_pages"
- Convert this short-lived access token into a long-lived one by making this Graph API call:
https://graph.facebook.com/v2.6/oauth/access_token?client_id=<your FB App ID >&client_secret=<your FB App secret>&grant_type=fb_exchange_token&fb_exchange_token=<your short-lived access token>
- Make a call Graph API:
https://graph.facebook.com/v2.6/<your personal account FB user id>/accounts?access_token=<your long-lived access token>
- The returned access_token has no expiration unless you change your password or not more admin of the target page or deauthorize FB page
@khromov
khromov / deploy.php
Created June 8, 2016 07:28
Deploy WordPress with Deployer on EasyEngine
<?php
require 'recipe/common.php';
// Set configurations
set('repository', 'ssh://gogs@git.server.com:22/user/repo.git');
set('shared_files', ['public/wp-config.php']);
set('shared_dirs', ['public/wp-content/uploads']);
set('writable_dirs', []);
set('keep_releases', 10);
set('composer_command', 'composer');
@bekarice
bekarice / wc-hide-non-free-shipping.php
Created September 22, 2016 04:11
Show only free / $0 shipping methods when available
<?php // only copy if needed
/**
* Hides any non-free shipping methods if free shipping is available
*
* @param array $rates array of \WC_Shipping_Rate objects that apply to the cart
* @return array - the updated available rates
*/
function sww_wc_hide_non_free_shipping( $rates ) {
@bjornjohansen
bjornjohansen / moderate_comments.sh
Created October 2, 2016 12:12
Moderate comments in a WordPress installation with WP-CLI
#!/bin/bash
# Copyright © 2016 Bjørn Johansen
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
# Check if WP-CLI is available
if ! hash wp 2>/dev/null; then
echo "WP-CLI is not available"
exit
@bjornjohansen
bjornjohansen / test-password-permutations.php
Last active February 2, 2017 11:09
Test a bunch of permutations of the password when logging into WordPress.
<?php
/**
* Test a bunch of permutations of the password when logging into WordPress.
*
* Drop this file in your mu-plugins directory.
* Inspired by Facebook: https://twitter.com/gcpascutto/status/821755332984717314/photo/1
* Works with any properly coded hashing pluggables, like Roots’ WP Password bcrypt.
*
* @author bjornjohansen
* @version 0.1.4
1. Highlight a recommended option,

2. Allow users to switch currency (€/$/£)

3. Allow users to switch pricing monthly/yearly

4. Keep the entire pricing plan area clickable

5. Use slider to calculate how much a user would save

6. Provide free first month for good engagement

7. Prominently highlight testimonials prominently

8. Repeating call to action on top and bottom

9. Sell benefits instead of features

10. Indicate that users can cancel any time

@mikejolley
mikejolley / functions.php
Created February 10, 2017 14:49
WooCommerce - Notify admin when a new customer account is created
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_action( 'woocommerce_created_customer', 'woocommerce_created_customer_admin_notification' );
function woocommerce_created_customer_admin_notification( $customer_id ) {
wp_send_new_user_notifications( $customer_id, 'admin' );
}