Skip to content

Instantly share code, notes, and snippets.

@alpha1
alpha1 / append_site_options_to_wp_json_index.php
Created November 30, 2022 03:20
Append Site Options to WP JSON API Index
<?php
//https://developer.wordpress.org/reference/hooks/rest_index/
add_filter( 'rest_index', 'append_site_public_settings_to_rest_api_index', 10, 2 );
function append_site_public_settings_to_rest_api_index( $response, $request ){
$options_to_include = array(
'date_format',
'time_format',
'gmt_offset',
'blog_public',
@alpha1
alpha1 / gravity_forms_sane_starter_validations_rules.php
Last active June 15, 2022 20:16
Gravity Forms Sane Validation Rules
<?php
/*
Plugin Name: WP Hacks Gravity Forms Validation Rules
Description:
Author: WP Hacks
Version: 0.1.0
Author URI: https://wphacks.org
*/
/*
#!/bin/bash
#wpbpfile=$(wp export --allow-root')
#cd to wordpress directory if needed
#cd /srv/www/wordpress-directory
wp_db_bk_filename=$(wp db export --allow-root --porcelain)
curl --ftp-ssl -T $wp_db_bk_filename ftp://HOSTNAME --user USERNAME:PASSWORD
unset wp_db_bk_filename
77.69.102.145
39.50.235.181
213.141.197.253
41.200.122.73
117.198.49.50
76.68.71.95
177.149.95.194
177.47.169.240
176.88.51.253
154.121.7.26
@alpha1
alpha1 / gist:da0192de8e6cc91c43ee9f86950d69c3
Last active October 11, 2018 22:20
Table Based UL for HTML emails
<table width="100%" style="border-collapse:collapse; width:100%">
<tbody>
<tr>
<td valign="top" width="30" style="width:30px;">&nbsp;</td><!--remove this row is you don't want the default indent-->
<td valign="top">&bull;&nbsp;</td>
<td valign="top" style="">Bullet A</td>
</tr>
<tr>
<td valign="top" width="30" style="width:30px;">&nbsp;</td>
<td valign="top">&bull;&nbsp;</td>
@alpha1
alpha1 / append_iteration_array.php
Created August 9, 2018 04:50
Append Character to each item on Array [PHP]
<?php
foreach($input_array as &$value) {
$value = '`'. $value .'`';
}
unset($value);
?>
@alpha1
alpha1 / revive_ad_server.sql
Last active June 12, 2018 02:51
Revive Ad Server raw SQL
#Show all active campaigns
SELECT * FROM `rv_campaigns` WHERE `activate_time` <= now() and expire_time >= now()
#show all past campaigns
SELECT * FROM `rv_campaigns` WHERE `activate_time` <= now() and expire_time <= now()
#show all upcoming campaigns
SELECT * FROM `rv_campaigns` WHERE `activate_time` >= now()
#show campaigns with clients (advertiser) information
@alpha1
alpha1 / keymap.cson
Created June 12, 2018 00:43
Atom Custom keymap.cson
'atom-text-editor':
'ctrl-d':'editor:duplicate-lines'
@alpha1
alpha1 / srv_dir_size.sh
Created March 30, 2018 17:38
Get Size of Directories in /SRV/WWW
du -chs /srv/www/*
@alpha1
alpha1 / delete-all-guest-authors.php
Last active March 22, 2018 19:19
Co-Authors-Plus: Delete All GuestAuthors
<?php
function delete_all_coauthors(){
global $coauthors_plus;
$coauths = get_posts( array( 'post_type' => 'guest-author', 'posts_per_page' => -1, 'post_status' => 'any' ) );
foreach( $coauths as $coauth){
$coauthors_plus->guest_authors->delete( $coauth->ID, false );
}
}
?>