Skip to content

Instantly share code, notes, and snippets.

View otakupahp's full-sized avatar
🇪🇨
Latin Coder

Pablo Hernández (OtakuPahp) otakupahp

🇪🇨
Latin Coder
View GitHub Profile
@MikeNGarrett
MikeNGarrett / wp-config.php
Last active July 17, 2024 18:02
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@Oceas
Oceas / wds-hello-world.php
Last active June 2, 2023 10:03
WDS WP-CLI 101 Complete
<?php
/*
Plugin Name: WDS Hello World
Plugin URI: https://webdevstudios.com/
Description: Teaching the basics of WP-CLI
Author: Web Dev Studios
Version: 1.0.0
Author URI: https://webdevstudios.com/
*/
class WDS_CLI {
@otakupahp
otakupahp / .gitattributes
Last active February 16, 2021 21:51
Git attributes configuration for any new WP Plugin using PHPStorm
# fix EOL error for multiple environments for text files
*.* text eol=lf
# set image and fonts as binary
*.png binary
*.jpg binary
*.gif binary
*.pdf binary
*.eps binary
*.zip binary
@otakupahp
otakupahp / WP_Debug.php
Last active February 24, 2021 03:49
Enable WP Silent Debug mode
<?php
# Enable WP_DEBUG mode, logging to the /wp-content/debug.log file , without displaying on screen errors and warnings
define('WP_DEBUG', true);
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
@otakupahp
otakupahp / jquery.js
Last active July 19, 2021 18:26
JQuery on ready
(function( $ ) {
'use strict';
// DOM ready
$(function() {
});
// Window loaded
$(window).on("load",function(){
@otakupahp
otakupahp / activate_plugin.php
Last active July 12, 2021 22:51
Simple function to check a plugin activation
<?php
/**
* @since 1.0.0
*
* @param $plugin_name
*/
public static function activate($plugin_name) {
# Initialize variables
@otakupahp
otakupahp / file.php
Last active February 21, 2021 15:57
WordPress Ajax done correctly
<?php
# After enquequing the JS add this localization to add the nonce and other variables
$params = [
'action' => 'your_action',
'wp_nonce' => wp_create_nonce( 'wp_ajax_nonce' ),
'error' => __('There was an error with the Ajax call. Please try again later'),
];
wp_localize_script( 'custom_ajax_params', 'wp_globals', $params );
@otakupahp
otakupahp / README.txt
Last active April 12, 2022 16:26
Plugin Header text to add Compatibility info
=== Plugin Name ===
.
.
.
Requires at least: 5.9
Tested up to: 5.9.3
Requires PHP: 8.0
WC requires at least: 6.0
WC tested up to: 6.0
License: GPLv2 or later
@otakupahp
otakupahp / otk-security.php
Last active December 13, 2022 14:25
WP MU Misc Plugins
<?php
/*
Plugin Name: OtakuPahp Security Measures
Description: Some Wordpress Hacks to improve site security
Author: Pablo Hernandez (OtakuPahp)
Author URI: https://otakupahp.llc
Version: 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {