Skip to content

Instantly share code, notes, and snippets.

@itzikbenh
itzikbenh / admin.js
Created August 26, 2017 23:14
Category Image
$('#update-cat-featured-img, #add-cat-featured-img').click(function(e) {
e.preventDefault();
var custom_uploader = wp.media({
title: 'Featured Image',
button: {
text: 'Insert image'
},
multiple: false // Set this to "add" to allow multiple files to be selected
})
@bars3s
bars3s / nginx.conf
Last active December 2, 2022 21:04
nginx image resizer with size parameters in query string
# Example: test.com/images/cats.jpeg?w=100&h=100
location ~* ^/images/(.+\.(?:jpe?g|png|gif))$ {
set $image_name $1;
set $demins "${arg_w}x${arg_h}";
set $check_str "${demins}";
# check that original size file exists
if ( -f $request_filename ) {
set $check_str "${check_str}F1";
@ahmadawais
ahmadawais / upload-a-file.MD
Created June 18, 2017 11:07 — forked from websupporter/upload-a-file.MD
Upload a file using the WordPress REST API

Upload files

Using the REST API to upload a file to WordPress is quite simple. All you need is to send the file in a POST-Request to the wp/v2/media route.

There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle:

<?php
$args = array(
'label' => '', // Text in Label
'class' => '',
'style' => '',
'wrapper_class' => '',
'value' => '', // if empty, retrieved from post meta where id is the meta_key
'id' => '', // required
'name' => '', //name will set from id if empty
<?php
/**
* Custom queries and getters.
*
* @package WDS8
*/
/**
* Get two most recent posts.
*
@gottalovelattes
gottalovelattes / Instagram CSS Gradient BG
Created February 27, 2017 00:19
Instagram CSS gradient background
background: #f09433;
background: -moz-linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
background: -webkit-linear-gradient(45deg, #f09433 0%,#e6683c 25%,#dc2743 50%,#cc2366 75%,#bc1888 100%);
background: linear-gradient(45deg, #f09433 0%,#e6683c 25%,#dc2743 50%,#cc2366 75%,#bc1888 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f09433', endColorstr='#bc1888',GradientType=1 );
}
Failed attempts by username:
grep "Invalid user " /var/log/auth.log | cut -d' ' -f8 | awk '{a[$0]++}END{for(i in a)print i,a[i]}' | sort -k 2 -n -r | head -n 100
IP address of each attempt:
grep "Invalid user " /var/log/auth.log | cut -d' ' -f10 | awk '{a[$0]++}END{for(i in a)print i,a[i]}' | sort -k 2 -n -r | head -n 100
Filter for brute-force interactive SSH logins:
grep sshd.\*Failed /var/log/auth.log | less
Look for failed connections (i.e. no login attempted, could be a port scanner, etc.):
@gregrickaby
gregrickaby / php-array-isset-vs-empty.md
Last active May 4, 2020 19:43 — forked from efuller/array.md
PHP Array isset and empty
@fiskhandlarn
fiskhandlarn / custom-search-acf-wordpress.php
Last active April 17, 2024 06:52 — forked from jserrao/custom-search-acf-wordpress.php
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request. I updated this original script with better documentation and XSS / SQL injection support.
<?php
/*
##############################
########### Search ###########
##############################
Included are steps to help make this script easier for other to follow
All you have to do is add custom ACF post types into Step 1 and custom taxonomies into Step 10
I also updated this work to include XSS and SQL injection projection
[list_searcheable_acf list all the custom fields we want to include in our search query]
@carlodaniele
carlodaniele / custom-queries.php
Last active January 23, 2024 01:35
An example plugin showing how to add custom query vars, rewrite tags and rewrite rules to WordPress
<?php
/**
* @package Custom_queries
* @version 1.0
*/
/*
Plugin Name: Custom queries
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin
Author: Carlo Daniele