Skip to content

Instantly share code, notes, and snippets.

View lkoudal's full-sized avatar

Lars Koudal lkoudal

View GitHub Profile
@maheshwaghmare
maheshwaghmare / extract-links-from-content.php
Last active June 11, 2020 23:15
Get image & other links from the given content.
@maheshwaghmare
maheshwaghmare / custom-sortable-columns.php
Created May 22, 2020 09:38
WordPress - Add custom sortable columns for custom post type.
<?php
/**
* Add custom column
*
* @todo Change the `prefix_` and with your own unique prefix.
*
* @since 1.0.0
*/
if( ! function_exists( 'prefix_add_custom_column' ) ) :
function prefix_add_custom_column( $columns = array() ) {
@thetwopct
thetwopct / functions.php
Created February 8, 2020 12:33
Preload any footer JS files in the header
/**
* Preload any footer JS files in the header
*
* originally from: https://macarthur.me/posts/preloading-javascript-in-wordpress
*/
add_action('wp_head', function () {
global $wp_scripts;
@vovafeldman
vovafeldman / README.md
Last active August 18, 2019 18:48
A code snippet to automatically activate the locally stored license key from the previous eCommerce platform (EDD/WC) with the Freemius SDK

Description

This extra snippet will check if a license was previously activated, and if it does, will activate it through Freemius in the background.

Usage

  • You will need to replace my_fs() with your theme's relevant shortcode.
  • You will need to rename the function my_fs_license_key_migration() to a unique name.
  • You will need to rename 'my_fs_migrated2fs' to a unique option name.
  • You will need to replace my_get_license_key_from_prev_platform_storage() with some logic that fetches the theme's license key.
@xnau
xnau / wp-locale-conversion-array.php
Created February 1, 2019 19:56
Conversion array for WordPress locale codes and standard language codes and names
<?php
$wp_locale_conversion = array(
'af' => array(
'name' => 'Afrikaans',
'code' => 'af',
'wp_locale' => 'af'
) ,
'ak' => array(
'name' => 'Akan',
'code' => 'ak',
@hiranthi
hiranthi / functions.php
Last active November 21, 2019 21:06
New encryption with Gravity Forms
<?php
function my_custom_gravityforms_encrypt( $to_encrypt )
{
if ( '' === $to_encrypt ) return null;
if ( function_exists('openssl_encrypt') && function_exists('openssl_random_pseudo_bytes') )
{
$iv = openssl_random_pseudo_bytes( openssl_cipher_iv_length( 'aes-256-cbc' ) );
$encrypted = openssl_encrypt( $to_encrypt, 'aes-256-cbc', MY_CUSTOM_GF_ENCRYPTION_KEY, 0, $iv );
@darkoromanov
darkoromanov / freemius-2-fomo.php
Last active July 22, 2021 17:58
Freemius integration for Fomo
<?php
// Fomo documentation: https://docs.fomo.com/reference
// Freemius documentation: http://freemius.com/help/documentation/marketing-automation/events-webhooks/
// Install Fomo PHP SDK https://github.com/usefomo/fomo-php-sdk
include "vendor/autoload.php";
define("FOMO_AUTH_TOKEN", "*********");
@maheshwaghmare
maheshwaghmare / remove-author-link-from-author-box.php
Created September 3, 2018 07:33
Astra Theme - Remove author link from the author box.
@Mte90
Mte90 / freemius-to-slack.php
Last active June 26, 2024 17:52
Freemius to slack notification
<?php
// Get Freemius data
$json = file_get_contents('php://input');
$data = json_decode($json, true);
if( isset( $data['objects'] ) ) {
slack($data);
}
function slack($data) {
<?php
/**
* Really simple GET request
*/
add_action( 'rest_api_init', function ( WP_REST_Server $wp_rest_server ) {
register_rest_route( '/custom-namespace/v1', '/no-param', [
'methods' => 'GET',
'callback' => function ( WP_REST_Request $request ) {
if ( $throw_error = false ) {