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 | |
// wp-content/mu-plugins/wp-cfm-multi-env.php | |
// ... | |
function my_wpcfm_multi_env_register( $environments ) { | |
// Define an array containing the hosting environment names. | |
// Or detect these with your own code logic if all are available in `$_ENV` or `$_SERVER` super-globals. | |
// ... | |
$environments = [ | |
'dev', |
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 | |
/* | |
Plugin Name: WP-CFM Multi-environment | |
Description: Enables configuration management for multiple environments with WP-CFM. | |
*/ | |
// If this file is called directly, abort. | |
if ( ! defined( 'WPINC' ) ) { | |
die; | |
} |
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 correct_date_string( $str ) { | |
if ( $str ) { | |
$date = DateTime::createFromFormat('Y.m.d', $str); | |
return $date->format('m/d/Y'); | |
} else { | |
return ''; | |
} | |
} |
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 | |
// Relates a post by title. | |
function rel_post_by_title( $title, $post_type ) { | |
// If we don't have a title to lookup, then return null; | |
if ( !$title ) return null; | |
// Check if related post already exists. If it doesn't then create it. | |
// Attempt to find page by value. | |
$page = get_page_by_title( $title, null, $post_type ); |
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
function replaceUrlParam(url, paramName, paramValue) { | |
if (paramValue == null) { | |
paramValue = ''; | |
} | |
var pattern = new RegExp('\\b('+paramName+'=).*?(&|#|$)'); | |
if (url.search(pattern)>=0) { | |
return url.replace(pattern,'$1' + paramValue + '$2'); | |
} | |
url = url.replace(/[?#]$/,''); |
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 remove_tax_parent_dropdown() { | |
$screen = get_current_screen(); | |
if ( 'region' == $screen->taxonomy ) { | |
if ( 'edit-tags' == $screen->base ) { | |
$parent = "$('label[for=parent]').parent()"; | |
} elseif ( 'term' == $screen->base ) { | |
$parent = "$('label[for=parent]').parent().parent()"; |
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 | |
add_filter( 'facetwp_query_args', function( $query_args, $class ) { | |
$query_args['post__not_in'] = [ 239 ]; | |
return $query_args; | |
}, 10, 2 ); |
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 | |
// ... | |
/** | |
* Tweak Archive pages queries. | |
* @param object $query | |
* @return object | |
*/ | |
function tweak_archives( $query ) { |
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
# Put parameters here that don't need to change on each machine where the app is deployed | |
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration | |
parameters: | |
locale: 'en' | |
# My application specific parameters. | |
app.gpu_qty: # The number of GPU cards each mining rig has. | |
rukia: 12 | |
zangetsu: 4 | |
app.gpu_share: 3 # How many GPU cards the two rig shares to divide profits. |
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 trash_empty_confirmation() { ?> | |
<script type="text/javascript"> | |
(function($) { | |
$('[id=delete_all]').click(function(e){ | |
return confirm( "Are you sure you want to permanently erase all content items in the Trash ?" ); | |
}); | |
})( jQuery ); | |
</script> |