Skip to content

Instantly share code, notes, and snippets.

View robertdevore's full-sized avatar
🐺
#LoneWolfLifestyle

Robert DeVore robertdevore

🐺
#LoneWolfLifestyle
View GitHub Profile
<?php
/**
* Checks if a particular user has one or more roles.
*
* Returns true on first matching role. Returns false if no roles match.
*
* @param array|string $roles - Role name (or array of names).
* @param int $user_id - (Optional) The ID of a user. Defaults to the current user.
*
<?php
/**
* The plugin bootstrap file
*
* @link https://robertdevore.com
* @since 1.0.0
* @package Customer_Cleanup
*
* @wordpress-plugin
*
<?php
/**
* Get explicit image sizes
*
* @param string $image_url The image URL - https:// ...
*
* @return string
*/
function get_explicit_image_sizes( $image_url ) {
<?php
/**
* Get image sizes by ID
*
* @param int $media_id The media ID
*
* @return array|bool
*/
function get_image_sizes_by_id( $media_id ) {
<?php
/**
* Get media ID from URL
*
* @param string $image_url The image URL - https:// ...
*
* @return int|null
*/
function get_media_id_from_url( $image_url ) {

Remove blank lines from txt file

This script reads in the input file line by line and writes the encoded lines to the output file. It skips any empty lines in the input file.

You can use this script by replacing input.txt with the name of your input file and output.txt with the name of the output file you want to create.

Useful for when you have a password or vuln list that has blank lines you need to clean up before running them through your scanners.

<?php
/**
* Get array of post ID's with specific meta key and value
*
* @param string $meta_key - The meta key you are checking for
* @param string $meta_value - The meta value for the meta key you're checking for
* @param string $post_type - The post type to use with get_posts() - default: post
*
* @return array
*/
<?php
/**
* Example cipher function
*
* @param string $quote - the quote used for the cipher base
* @param string $secret - the secret message
* @param bool $with_symbols - add random symbols to the string
* @param bool $lowercase - should the quote have all lowercase lettering?
*
* @return string