This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function codepotent_debug_notifier_register_admin_bar() { | |
// ...adjust the permission to suit your needs. | |
if (!current_user_can('manage_options')) { | |
return; | |
} | |
// Bring the admin bar into scope. | |
global $wp_admin_bar; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The following code will remove access to the /users/ endpoint. This makes the | |
* endpoint inaccessible while not blocking access to other endpoints. This code | |
* works with both WordPress and ClassicPress. | |
* | |
* Why do this? The REST API is very handy, however, by default, it exposes data | |
* that you may not want exposed – namely, your site's usernames. With a list of | |
* your usernames, the success of a brut-force attack becomes more likely. | |
* | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This can go into whatever file is enqueued for the given page, using the traditional admin_enqueue_scripts hook. | |
jQuery(document).ready(function($) { | |
var onElementExists = function(element, callback) { | |
if ($(element).length) { | |
callback($(element)); | |
} | |
function check_again(element, callback) { | |
setTimeout(function() { | |
onElementExists(element, callback); | |
}, 100); // interval |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-/(SHA|downloadable|zoom|jqmigrate|webfonts|mozPressure)/ | |
Drop the above line into Firefox's browser console filter to remove certain messages. | |
Examples of messages removed: | |
- This page uses the non standard property “zoom”. Consider using calc() in the relevant property values, or using “transform” along with “transform-origin: 0 0”. | |
- JQMIGRATE: Migrate is installed with logging active, version 1.4.1 | |
- MouseEvent.mozPressure is deprecated. Use PointerEvent.pressure instead. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Keep calm and code potent. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* ----------------------------------------------------------------------------- | |
* Capture div as image and save to server with html2canvas | |
* ----------------------------------------------------------------------------- | |
* Copyright 2021, John Alarcon | |
* ----------------------------------------------------------------------------- | |
* This is free software released under the terms of the General Public License, | |
* version 2, or later. It is distributed WITHOUT ANY WARRANTY; without even the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_dashicons() { | |
$icons = [ | |
'admin' => [ | |
'menu', | |
'admin-site', | |
'dashboard', | |
'admin-post', | |
'admin-media', | |
'admin-links', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Prevent direct access. | |
if (strpos($_SERVER['PHP_SELF'], 'debug.php')) { | |
die(); | |
} | |
/** | |
* Debug - to expose data in variables, arrays, objects. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Remove plugins from search results in ClassicPress dashboard. | |
* A little ditty by Code Potent. https://codepotent.com | |
*/ | |
// Add slugs for any individual plugins to remove. | |
function codepotent_plugins_to_remove() { | |
$slugs = [ | |
'wordfence', | |
'jetpack', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ajaxSuccess(function(e, xhr, settings) { | |
// This is the data of interest. | |
console.log(settings); | |
// Identifier for your (or whatever) particular widget. | |
var widget_id_base = 'text'; // text, search, my-widget, et al. | |
// Check if updating a widget of this type. | |
if((settings.data.search('action=save-widget') != -1) && (settings.data.search('id_base='+widget_id_base) != -1)) { |
NewerOlder