This file contains 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 | |
function get_cron_events_to_ignore() { | |
return [ | |
'a8c_cron_control_force_publish_missed_schedules', | |
'a8c_cron_control_confirm_scheduled_posts', | |
]; | |
} | |
// If an ignorable cron event runs, let's unschedule it so it runs no more. |
This file contains 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 | |
/* | |
* Dynamic Queue adjustments for autoscaling Action Scheduler. | |
* | |
* Every few minutes, this checks to see if the AS queue has exceeded a certain | |
* threshold of "due now" actions. And if so, will schedule additional queues to run | |
* concurrently in cron until the queue is caught up. | |
* | |
* Scales directly off of cron control's JOB_CONCURRENCY_LIMIT. |
This file contains 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 | |
/* | |
* Jetpack's JSON API Authorization flow needs to run free of the 2FA checks. | |
* JP already does additional validation on top of the normal login, so we can rely on that as the 2fa here. | |
* | |
* First we hook into wp_login right before the VIP Two_Factor_Core plugin does. | |
* Then if the situation is right, remove the additional 2FA login step. | |
*/ | |
add_action( 'wp_login', function( $user_login, $user ) { |
This file contains 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 2FA from being enforced for JP JSON API requests. | |
add_filter( 'wpcom_vip_is_two_factor_forced', function( $forced ) { | |
$current_user = wp_get_current_user(); | |
if ( vip_is_jetpack_xml_rpc_json_api_request() && isset( $current_user->user_login ) && 'example_username' === $current_user->user_login ) { | |
$forced = false; | |
} | |
return $forced; |
This file contains 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 | |
if ( ! class_exists( 'WPCOM_VIP_CLI_Command' ) || ! ( defined( 'WP_CLI' ) && WP_CLI ) ) { | |
return; | |
} | |
WP_CLI::add_command( 'vip-remove-old-revisions', 'VIP_Remove_Old_Revisions_Command' ); | |
class VIP_Remove_Old_Revisions_Command extends WPCOM_VIP_CLI_Command { |
This file contains 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
#!/bin/bash | |
# Usage: wp-create sitename | |
if [ $# -eq 0 ]; then | |
echo "Need to provide the directory name to be created." | |
exit 1 | |
fi | |
# set up new folder to house the WP install |
This file contains 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 | |
/* | |
* Remove the SRM redirect for 'doc_id' query strings after a certain ID is reached. | |
*/ | |
add_filter( 'srm_registered_redirects', function( $redirects, $requested_path ) { | |
// The last post ID that we want to be automatically redirected. | |
$redirect_breakpoint_id = 565000; | |
// The SRM post ID for the redirect we will conditionally remove. |
This file contains 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 | |
/** | |
* Return a more abstract error message when an invalid password was entered but for a valid username. | |
* | |
* @param null|WP_User|WP_Error $user WP_User if the user is authenticated, WP_Error or null otherwise. | |
*/ | |
add_filter( 'authenticate', function( $user ) { | |
if ( is_wp_error( $user ) && 'incorrect_password' === $user->get_error_code() ) { | |
$user = new WP_Error( 'authentication_failed', __( '<strong>ERROR</strong>: Invalid username, email address or incorrect password.' ) ); |
This file contains 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 | |
// We don't need this query to run if it's asking for all comments (post_id = 0). | |
add_filter( 'wp_count_comments', function ( $count, $post_id ) { | |
if ( 0 === $post_id ) { | |
$stats = array( | |
'approved' => 0, | |
'moderated' => 0, | |
'spam' => 0, | |
'trash' => 0, |
This file contains 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 | |
/** | |
* Co-Author Plus ES query fix. | |
* | |
* With CAP, authors are attached either with the traditional | |
* author field or via an "author" taxonomy. So we need to check both. | |
*/ | |
add_filter( 'es_posts_request', function( $es_args, $query ) { | |
if ( ! $query->is_author() ) { |
NewerOlder