Skip to content

Instantly share code, notes, and snippets.

View johnalarcon's full-sized avatar
😎
Coding potently.

John Alarcon johnalarcon

😎
Coding potently.
View GitHub Profile
/*
If you are switching from f(x) Updater [or] if you are moving
from Update Manager RC1 to RC2, run the following two queries
directly against your database to convert the post types into
the post types used by RC2. In these queries, you must change
the prefix "cp_" to match your own prefix. This is a one-time
thing to resolve issue #1.
See: https://github.com/codepotent/Update-Manager/issues/1
@johnalarcon
johnalarcon / functions.php
Last active December 14, 2019 02:58
Show current PHP version in ClassicPress admin bar
/**
* Add PHP version to ClassicPress admin bar.
*
* For environments in which the PHP version is subject to change, this will add
* the currently-running PHP version number to the admin bar to save some clicks
* and keep it immediately discoverable.
*
* @author John Alarcon
*/
function codepotent_adminbar_php_version() {
@johnalarcon
johnalarcon / readme.txt
Last active December 22, 2019 12:02
A robust endpoint example demonstrating how to create a fully-populated display around a plugin. For use with Update Manager plugin for ClassicPress. This can be copied directly into the endpoint text editor and tweaked to suit.
=== Update Manager ===
Description: Painlessly push updates to your ClassicPress plugin users! Serve updates from GitHub, your own site, or somewhere in the cloud. 100% integrated with the ClassicPress update process; slim and performant.
Version: 1.0.0-rc2
Text Domain: codepotent-update-manager
Domain Path: /languages
Requires PHP: 5.6
Requires: 1.0.0
Tested: 4.9.99
Author: Code Potent
@johnalarcon
johnalarcon / functions.php
Last active January 3, 2020 12:47
A few custom tweaks for the new ClassicPress Security page
/**
* Remove ClassicPress security page from admin menu and convert icon to text.
*
* Reasoning: After being initially in favor of the addition of a security page,
* the implementation seems rushed and incomplete. Since I already have a plugin
* for security, this means I have 2 entries for security in the top-level admin
* menu. This action hook removes the needless core menu item. This doesn't kill
* the security page's functionality; it only removes the admin menu item. For a
* plugin that has registered security settings to be displayed on that page, it
* will still have a "shield" icon on the plugin admin page leading to the right
@johnalarcon
johnalarcon / functions.php
Created March 8, 2020 23:22
Whitelist the usernames that can login to a ClassicPress site.
function codepotent_disable_rogue_logins($user, $username, $pass) {
// An array of usernames allowed to login.
$allowed_usernames = [
'coolChick582',
'geekdude1',
'some_other_username'
];
// Not an allowed username? Fail the login.
@johnalarcon
johnalarcon / hierarchy.php
Created April 17, 2020 20:02 — forked from johnbillion/hierarchy.php
ASCII WordPress Template Hierarchy
<?php
/*
WordPress Template Hierarchy (as of WordPress 4.9)
is_404() -------------------------------------------------------------------------------------------------> 404.php
is_search() ----------------------------------------------------------------------------------------------> search.php
is_front_page() ------------------------------------------------------------------------------------------> front-page.php
is_home() ------------------------------------------------------------------------------------------------> home.php
@johnalarcon
johnalarcon / README.md
Created September 29, 2020 05:21
For testing purposes.

=== Update Manager ===

Description: Painlessly push updates to your ClassicPress plugin and theme users! Serve updates from GitHub, your own site, or somewhere in the cloud. 100% integrated with the ClassicPress update process; slim and performant. Version: 2.0.0 Text Domain: codepotent-update-manager Domain Path: /languages Requires PHP: 5.6 Requires: 1.0.0 Tested: 4.9.99 Author: Code Potent

@johnalarcon
johnalarcon / codepotent-readme-sections.php
Created September 29, 2020 06:44
Extract sections from README.md in a typical ClassicPress plugin.
<?php
namespace CodePotent\Readme2Sections;
// Usage
$readme_file = 'https://gist.githubusercontent.com/johnalarcon/c19d3111dc73578a3fe224084e2194ec/raw/9a9facfc849e915851fd99cbb6495ded9904340a/README.md';
$readme_lines = file($readme_file);
$sections_array = get_sections($readme_lines);
// Result
@johnalarcon
johnalarcon / codepotent-readme-complete.php
Created September 29, 2020 06:45
Extract full plugin details from README.md in a typical ClassicPress plugin.
<?php
namespace CodePotent\Readme2Complete;
// Usage
$readme_file = 'https://gist.githubusercontent.com/johnalarcon/c19d3111dc73578a3fe224084e2194ec/raw/9a9facfc849e915851fd99cbb6495ded9904340a/README.md';
$readme_lines = file($readme_file);
$readme_array = parse_readme($readme_lines);
// Result
@johnalarcon
johnalarcon / apply-action-after-plugin-update.php
Created October 16, 2020 14:04
Apply action after ClassicPress plugin update
if ($options['action'] == 'update') {
if ($options['type'] == 'plugin') {
if (!empty($options['plugins'])) {
if (in_array(plugin_basename(__FILE__), $options['plugins'], true)) {
// Do stuff.
}
}
}
}