Skip to content

Instantly share code, notes, and snippets.

@gaupoit
gaupoit / fix-private-link.php
Created July 2, 2019 08:39
Fix private link
@gaupoit
gaupoit / thank-you.php
Last active July 2, 2019 08:27
PHP Snippet to implement the contact form redirection
add_action( 'wp_footer', 'redirect_cf7' );
function redirect_cf7() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '1460' == event.detail.contactFormId ) { // Sends sumissions on form 1460 to the custom thank you page
location = 'https://example.com/thank-you/';
}
}, false );
<?php
/**
* Handle auto upgrade extension
*/
public function pda_handle_upgrade_extension() {
$updates = get_plugin_updates();
$pda_skin = new PDA_WP_Upgrader_Skin();
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$upgrader = new Plugin_Upgrader( $pda_skin );
foreach ( $updates as $plugin ) {
@gaupoit
gaupoit / pda_wp_upgrader_skin.php
Created May 4, 2019 06:48
WP_Upgrader_Skin class without showing the feedback message
<?php
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
if ( ! class_exists( 'PDA_WP_Upgrader_Skin' ) ) {
class PDA_WP_Upgrader_Skin extends WP_Upgrader_Skin {
function feedback( $string ) {
return;
}
}
@gaupoit
gaupoit / auto-update.php
Last active May 4, 2019 06:03
Snippet to update WordPress plugins automatically
<?php
function pda_auto_update_specific_plugins ( $update, $item ) {
$plugins = array (
'wp-pda-ip-block',
'pda-membership-integration',
);
if ( in_array( $item->slug, $plugins ) ) {
return true; // We can add more control logic here, for example only update in the specific version
} else {
@gaupoit
gaupoit / hello.html
Created February 23, 2019 10:55
hello vue component
<div>
<hello-vue></hello-vue>
</div>
@gaupoit
gaupoit / enqueue_script.php
Last active February 23, 2019 10:35
Enqueue script
<?php
wp_enqueue_script(
'csw_bundle',
plugin_dir_url( CSW_BASE_FILE ) . 'admin/js/dist/gists-snippet-bundle.js',
array(),
CSW_VERSION,
true
);
@gaupoit
gaupoit / index.js
Created February 23, 2019 10:28
Index file
import Vue from 'vue';
import App from './App.vue';
window.addEventListener('load', () => {
new Vue({
el: '#csw-app',
render: h => h(App),
});
});
@gaupoit
gaupoit / App.vue
Created February 23, 2019 10:07
App vue file
<template>
<form>
OAuth Token: <br/>
<input type="text" name="oauth-token" v-model="oauthToken"/>
<br/><br/>
<input type="submit" value="Save changes" v-on:click="save"/>
</form>
</template>
<script>
@gaupoit
gaupoit / package.json
Last active February 23, 2019 10:05
Npm package configuration file
{
"name": "app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack --config webpack.dev.js --process -w",
"build": "webpack --config webpack.prod.js"
},