This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($){ | |
var ajaxurl = object.ajaxurl; | |
var data = { | |
action: 'my_action', // wp_ajax_my_action / wp_ajax_nopriv_my_action in ajax.php. Can be named anything. | |
foobar: 'some value', // translates into $_POST['foobar'] in PHP | |
}; | |
$.post(ajaxurl, data, function(response) { | |
alert("Server returned this:" + response); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# http://kovshenin.com/2012/the-wordpress-settings-api/ | |
# http://codex.wordpress.org/Settings_API | |
add_action( 'admin_menu', 'my_admin_menu' ); | |
function my_admin_menu() { | |
add_options_page( __('My Plugin Options', 'textdomain' ), __('My Plugin Options', 'textdomain' ), 'manage_options', 'my-plugin', 'my_options_page' ); | |
} | |
add_action( 'admin_init', 'my_admin_init' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function change_acf_color_picker() { | |
$client_colors = array( | |
"#DD3333", | |
"#81D742", | |
"#1E73BE", | |
"#8224E3", | |
"#DD9933", | |
"#EEEE22" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adds a box to the main column on the Post and Page edit screens. | |
*/ | |
function myplugin_add_custom_box() { | |
$screens = array( 'post', 'page' ); | |
foreach ( $screens as $screen ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function hip_has_shortcode( $content, $tags ) { | |
if( is_array( $tags ) ) { | |
foreach ( $tags as $tag ) { | |
preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); | |
if ( empty( $matches ) ) | |
return false; | |
foreach ( $matches as $shortcode ) { | |
if ( $tag === $shortcode[2] ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When dynamically creating a fileupload field with multiple files option enabled | |
you must also run the gform_post_multifile_upload filter on the field for it to work properly | |
https://docs.gravityforms.com/gform_multifile_upload_field/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
desktops=$(wmctrl -d | awk '{ print $2":"$10 }') | |
for desktop in $desktops | |
do | |
# example output of $desktop: -Work or *Leisure | |
if [[ $(echo $desktop | cut -c1-1) = '*' ]]; then | |
echo $desktop | cut -c3- | |
fi | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function hip_auto_login() { | |
/* emails with + will not work "properly", then wont be logged in with this filter */ | |
if( isset( $_GET['u'] ) && isset( $_GET['plux'] ) && isset( $_GET['post_id'] ) ) { | |
$email = wp_kses( $_GET['u'],array() ); | |
$checksum = wp_kses( $_GET['plux'],array() ); | |
$post_id = wp_kses( $_GET['post_id'],array() ); | |
if (!is_user_logged_in() && !empty($checksum) && !empty($email)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Enter host (defined in ~/.ssh/config):" | |
read host | |
if [ -z "${host}" ]; then | |
echo "No host given. Exiting." | |
else | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
rm -rf images.csv | |
for file in *; do | |
if [[ $file == *.jpg ]] | |
then | |
sharelink=$(dropbox sharelink "$file") | |
sharelink=${sharelink/dl=0/dl=1} ## replace dl=0 with dl=1 in the sharelinks | |
filename=$(basename "$file") |
NewerOlder