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_action( 'edit_form_advanced', 'force_post_title' ); | |
function force_post_title( $post ) { | |
// List of post types that we want to require post titles for. | |
$post_types = array( | |
'post', | |
'report', | |
// 'event', |
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
# In your Jenkins job configuration, select "Add build step > Execute shell", and paste this script contents. | |
# Replace `______your-plugin-name______`, `______your-wp-username______` and `______your-wp-password______` as needed. | |
# main config | |
WP_ORG_USER="______your-wp-username______" # your WordPress.org username | |
WP_ORG_PASS="______your-wp-password______" # your WordPress.org password | |
PLUGINSLUG="______your-plugin-name______" | |
CURRENTDIR=`pwd` | |
MAINFILE="______your-plugin-name______.php" # this should be the name of your main php file in the wordpress plugin |
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 array_dechunk( $array ) { | |
return array_reduce( $array, function ( $carry, $item ) { | |
return array_merge( $carry, $item ); | |
}, [] ); | |
} |
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 | |
// Sum all values from order_total column in completed orders, and return. | |
$qb = $em->createQueryBuilder(); | |
$qb = $qb | |
->select( 'SUM(e.orderTotal) as totalRevenue' ) | |
->from( '[Vendor]\[Package]\Entity\Orders', 'e' ) | |
->where( $qb->expr()->andX( | |
$qb->expr()->eq( 'e.orderStatus', ':status' ), | |
// $qb->expr()->in( 'e.state', array( 'queued', 'confirmed' ) ) |
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 | |
/** | |
* Removes custom style selector for non Administrator user roles. | |
* Uses acf/load_field filter https://www.advancedcustomfields.com/resources/acf-load_field/ | |
* | |
* @param array $field | |
* @return array | |
*/ | |
function acf_filter_radio_choices( $field ) { |
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 | |
/** | |
* Output an AddThis floating share sidebar to the left with selected services. | |
* | |
* Notice 'desktop' and 'mobile' parameters, they take a Boolean data type as value, meaning it can be used to | |
* allow a more dynamic control and display of the sharing sidebar. | |
* | |
* More options to play with can be found here in the docs: https://www.addthis.com/academy/smart-layers-api/ | |
* Just notice to convert the JSON format in the examples to PHP's array() format |
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> |