Skip to content

Instantly share code, notes, and snippets.

@arber1
arber1 / awesome-wp-config-file.php
Created February 14, 2023 21:46 — forked from ashfame/awesome-wp-config-file.php
awesome-wp-config-file
<?php
/**
* Define type of server
*
* Depending on the type other stuff can be configured
* Note: Define them all, don't skip one if other is already defined
*/
define( 'DB_CREDENTIALS_PATH', dirname( ABSPATH ) ); // cache it for multiple use
@arber1
arber1 / WP_Bag_of_Tricks.txt
Created February 14, 2023 19:09 — forked from boogah/WP_Bag_of_Tricks.txt
Things I've learned by being a WordPress nerd.
WP Bag of Tricks
1. Helpful Scripts/Plugins:
Hacks:
http://wordpress.org/extend/plugins/tac/
http://wordpress.org/extend/plugins/exploit-scanner/ (Can be extremely resource intensive.)
http://wordpress.org/extend/plugins/wp-malwatch/
@arber1
arber1 / wp-config.php
Created February 12, 2023 13:39 — forked from franz-josef-kaiser/wp-config.php
My default wp-config.php file for the nightly.dev stack. Not beautiful, but it got everything.
<?php
# SHORTS
# DIRECTORY SEPARATOR
define( 'DS', DIRECTORY_SEPARATOR );
# PATH SEPARATOR
define( 'PS', PATH_SEPARATOR );
# Absolute path to the WordPress directory.
! defined( 'ABSPATH' )
AND define( 'ABSPATH', dirname( __FILE__ ).DS );
@arber1
arber1 / custom-post-type-data-export.php
Created February 12, 2023 13:00 — forked from 84em/custom-post-type-data-export.php
ChatGPT Generated WordPress plugin
<?php
/*
Plugin Name: Custom Post Type Data Export
Description: Exports custom post type data using REST API and PHP classes with namespaces and bearer authentication
*/
namespace CustomPostTypeDataExport;
use \WP_REST_Controller as WP_REST_Controller;
class ExportController extends WP_REST_Controller {
public function __construct() {
add_action('rest_api_init', [$this, 'register_routes']);
@arber1
arber1 / add-gtm-wp.php
Created February 12, 2023 01:51 — forked from jsn789/add-gtm-wp.php
Add Google Tag Manager through functions.php in WordPress
/* Add Google Tag Manager javascript code as close to
the opening <head> tag as possible
=====================================================*/
function add_gtm_head(){
?>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
@arber1
arber1 / wp-head-clean.php
Created February 11, 2023 22:13 — forked from blacksaildivision/wp-head-clean.php
Remove all unnecessary stuff from WordPress <head> tag
<?php
/**
* Alter dns-prefetch links in <head>
*/
add_filter('wp_resource_hints', function (array $urls, string $relation): array {
// If the relation is different than dns-prefetch, leave the URLs intact
if ($relation !== 'dns-prefetch') {
return $urls;
}
@arber1
arber1 / image-convert.php
Created February 11, 2023 22:12 — forked from vardumper/image-convert.php
Convert Wordpress User Uploads to WebP and update DB references
<?php
declare(strict_types = 1);
use WebPConvert\WebPConvert;
set_time_limit(0);
chdir(dirname(__DIR__)); // one level up to project root
// check requirements
if (! is_file('vendor/autoload.php')) {
echo "File vendor/autoload.php not found. Is the path correct?";
exit();
}
@arber1
arber1 / fbcbfwss.php
Created February 11, 2023 22:03 — forked from ocean90/fbcbfwss.php
WordPress Plugin: Filename-based cache busting for scripts/styles.
<?php
/**
* Plugin Name: Filename-based cache busting
* Version: 0.3
* Description: Filename-based cache busting for WordPress scripts/styles.
* Author: Dominik Schilling
* Author URI: https://dominikschilling.de/
* Plugin URI: https://gist.github.com/ocean90/1966227/
*
* License: GPLv2 or later
@arber1
arber1 / DD32s-combine-plugin.php
Created February 11, 2023 21:59 — forked from mjc/DD32s-combine-plugin.php
WIP: Combine Javascript and CSS in wordpress
<?php
/*
Plugin Name: The Combiner
Plugin URI: http://dd32.id.au/wordpress-plugins/?plugin=combine-css-js
Description: Combine CSS & JS into one large monolithic file
Author: DD32
Version: 1.0
Author URI: http://dd32.id.au/
*/
@arber1
arber1 / cpt.php
Created February 11, 2023 21:53 — forked from igorbenic/cpt.php
Simple WordPress Advertising Plugin: Introduction | http://www.ibenic.com/simple-wordpress-advertising-plugin-introduction
<?php
// ...
public function load_dependencies(){
/**
* Base functions
*/