Skip to content

Instantly share code, notes, and snippets.

View robertdevore's full-sized avatar
🛠️
#NeverNotWorking

Robert DeVore robertdevore

🛠️
#NeverNotWorking
View GitHub Profile
<?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 ) {
<?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 explicit image sizes
*
* @param string $image_url The image URL - https:// ...
*
* @return string
*/
function get_explicit_image_sizes( $image_url ) {
<?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.
*
@robertdevore
robertdevore / restrict-your-plugin-usage-on-wordpress-com.php
Created December 21, 2024 05:20
Stop your plugin from being used on websites hosted at wordpress.com
<?php
/**
* Helper function to handle WordPress.com environment checks.
*
* @param string $plugin_slug The plugin slug.
* @param string $learn_more_link The link to more information.
* @return void
*/
function wp_com_plugin_check( $plugin_slug, $learn_more_link ) {
@robertdevore
robertdevore / cache-clearer-for-wp-rocket.php
Created January 2, 2025 20:09
Auto-clear the WP Rocket cache every 5 minutes
<?php
/**
* The plugin bootstrap file
*
* @link https://freshysites.com
* @since 1.0.0
* @package Cache_Clearer_WP_Rocket
*
* @wordpress-plugin
<?php
/*
Plugin Name: BioBox
Description: A plugin that provides a BioBox widget and shortcode for author information.
Version: 1.0
Author: Your Name
Text Domain: biobox
*/
// Security measure to prevent direct access
@robertdevore
robertdevore / 01-ai-content-generation-tests.md
Last active January 26, 2025 18:16
Examples of content generation with AI

AI Content Generation

Below is the prompt I gave to the various AI's

Write me a blog post about 7 security tips for wordpress developers. The tips shouldn't be your everyday run of the mill tips like 'keep plugins updated', but sshould speak to specific code updates you can make to your code. The goal of the article is to educate my readers who are WordPress developers like me, and show them how to make ttheir projects more secure.

<?php
/**
* Convert HEX color to RGBA.
*
* @param string $hex_color The HEX color code (e.g., '#FF0000').
* @param float $opacity The opacity level (0 to 1).
*
* @return string The RGBA color format.
*/

📂 Project File Tree Generator

A simple Python script that generates a Markdown overview of your project’s folder structure—complete with depth control and inline includes of your README.md, package.json, and composer.json. Outputs to filetree.md, with an optional --clip flag to copy the result to your clipboard.


Features

  • Directory tree Recursively list files and folders in Markdown format.