Skip to content

Instantly share code, notes, and snippets.

@rubelmiah
rubelmiah / show_only_image_media_files.php
Created January 26, 2023 06:31
Beside administrator show only image media files.
<?php
/**
* Beside administrator show only image media files.
*
* @param [type] $query
* @return void
*/
function show_only_image_media_files( $query ) {
@rubelmiah
rubelmiah / show_current_user_attachments.php
Last active January 26, 2023 06:34
Besides administrator show only the current user media files
<?php
//Besides administrator show only the current user media files
function show_current_user_attachments( $query ) {
if ( ! current_user_can('administrator') ) {
$user_id = get_current_user_id();
if ( $user_id ) {
$query['author'] = $user_id;
}
}
@rubelmiah
rubelmiah / edd_format_amount_decimals.php
Created January 19, 2023 12:33
Remove zero cents ".00" from Easy Digital Downloads.
<?php
function rm_edd_format_amount_decimals( $decimals, $amount ) {
if ( floor( $amount ) == $amount )
$decimals = 0;
return $decimals;
}
add_filter( 'edd_format_amount_decimals', 'rm_edd_format_amount_decimals', 10, 2 );
@rubelmiah
rubelmiah / Total Download Count For Plugins on WordPress.org Username.php
Last active October 15, 2016 15:08
How to Total Download Count For Plugins on WordPress.org Username
<?php
// Add this code in your functions.php file.
function rm_total_download( $username = false, $args = array() ) {
if( $username ) {
$params = array(
'timeout' => 10,
'sslverify' => false
);
<?php $popular_items = new WP_Query (array(
'post_type' => 'download',
'orderby' => 'meta_value_num',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => '_edd_download_sales',
'compare' => '>',
'value' => 0,
'order' => 'DESC',