Skip to content

Instantly share code, notes, and snippets.

View bobbydank's full-sized avatar
💭
Always working

Bobby Danklefsen bobbydank

💭
Always working
View GitHub Profile
@bobbydank
bobbydank / react-htaccess
Created December 15, 2023 15:49
htaccess for react apps
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.html [L]
@bobbydank
bobbydank / disable-wp-rest.php
Last active October 13, 2023 16:24
disables wordpress rest api
<?php
add_filter(
'rest_authentication_errors',
function ($access) {
return new WP_Error(
'rest_disabled',
__("The Wordpress REST API has been disabled."),
array(
'status' => rest_authorization_required_code(),
@bobbydank
bobbydank / remove-rss-wordpress.php
Created October 12, 2023 16:48
removes rss feeds from wordpress
<?php
function cl_itsme_disable_feed() {
wp_die( __( 'No feed available, please visit the <a href="'. esc_url( home_url( '/' ) ) .'">homepage</a>!' ) );
}
add_action('do_feed', 'cl_itsme_disable_feed', 1);
add_action('do_feed_rdf', 'cl_itsme_disable_feed', 1);
add_action('do_feed_rss', 'cl_itsme_disable_feed', 1);
add_action('do_feed_rss2', 'cl_itsme_disable_feed', 1);
@bobbydank
bobbydank / tailwindcss-login.html
Last active July 6, 2023 18:30
tailwindcss-login.html
<div class="min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8">
<div class="max-w-md w-full space-y-8">
<div>
<h2 class="mt-6 text-center text-3xl font-extrabold text-gray-900">
Sign in to your account
</h2>
</div>
<form class="mt-8 space-y-6" action="" id="login-form" method="POST">
<input type="hidden" name="remember" value="true">
@bobbydank
bobbydank / php-endpoint.php
Created July 2, 2023 03:17
Starting point for a PHP API Endpoint.
<?php
header("Content-Type: application/json; charset=UTF-8");
ini_set('display_errors', 0);
ini_set('log_errors', 1);
error_reporting(E_ALL);
/* Vars
-------------------------------------- */
@bobbydank
bobbydank / classify.php
Last active January 25, 2023 19:02
takes a string and makes a css class out of it.
<?php
function _classify($string) {
$string = preg_replace("/[^A-Za-z ]/", '', strtolower($string));
return str_replace(' ', '-', $string);
}
function custom_submenu_page() {
add_submenu_page(
'options-general.php', // Parent menu slug
'Custom Submenu Page', // Page title
'Custom Submenu', // Menu title
'manage_options', // Capability
'custom-submenu-page', // Menu slug
'custom_submenu_page_callback' // Callback function
);
}
@bobbydank
bobbydank / disable-comments.php
Created December 9, 2022 16:22
Code to disable comments in Wordpress
<?php
//found somewhere. Not sure if this works.
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_safe_redirect(admin_url());
exit;
<?php
/**
* Filter the except length to any specified length of words.
*
* @param string $content the content
* @param int $length Excerpt length.
* @return int (Maybe) modified excerpt length.
*/
function catchy_labs_custom_excerpt($content, $limit) {
@bobbydank
bobbydank / wp-simple-subnav.php
Last active August 1, 2022 15:45
Simple function for creating a subnav in your Wordpress theme
<?php
/**
* author: Robert Danklefsen
* website: https://www.catchylabs.com/
*
* Simple function for creating a subnav in your Wordpress theme
*/
function catchylabs_get_top_parent_page_id() {
global $post;