Skip to content

Instantly share code, notes, and snippets.

View nfsarmento's full-sized avatar

NS nfsarmento

View GitHub Profile
@nfsarmento
nfsarmento / functions.php
Last active October 30, 2018 15:08
Add custom text on feature image Custom Post Type
/**
* Add custom text on feature image Custom Post Type
*
* https://www.nuno-sarmento.com
*/
add_action( 'admin_head', 'ns_remove_my_meta_boxen' );
function ns_remove_my_meta_boxen() {
remove_meta_box( 'postimagediv', 'staff', 'side' );
add_meta_box('postimagediv', __('Add staff photo W 750px x H 400px'), 'post_thumbnail_meta_box', 'staff', 'side', 'high');
@nfsarmento
nfsarmento / functions.php
Last active October 30, 2018 15:03
Disabled admin notices wordpress
/**
* Disabled admin notices
*
* https://www.nuno-sarmento.com
*/
add_action('admin_enqueue_scripts', 'ds_admin_theme_style');
add_action('login_enqueue_scripts', 'ds_admin_theme_style');
function ds_admin_theme_style() {
if (!current_user_can( 'manage_options' )) {
echo '<style>.update-nag, .updated, .error, .is-dismissible { display: none; }</style>';
@nfsarmento
nfsarmento / javascript.js
Created May 17, 2018 15:57
WordPress Custom Post Type Categories - Collapse List
$('.toggle__categories').click(function(e) {
e.preventDefault();
var $this = $(this);
$this.next().toggleClass();
$this.next().slideToggle();
});
$(function() {
$('.plus-minus-toggle').on('click', function() {
$(this).toggleClass('collapsed');
@nfsarmento
nfsarmento / functions.php
Created May 21, 2018 16:21
Add information above a custom post type listing of all posts page
function wpa_admin_notice() {
$screen = get_current_screen();
if( 'your_post_type' == $screen->post_type
&& 'edit' == $screen->base ){
?>
<div class="updated">
<p>Here is some text</p>
</div>
<?php
}
@nfsarmento
nfsarmento / functions.php
Last active October 30, 2018 14:44
WordPress dashboard widget to show logged in users
/**
* Creates the new widget section to the administration dashboard if the user has the administrator user role.
*
* https://www.nuno-sarmento.com
*/
add_action('wp_dashboard_setup', 'm1ka_online_users_widget');
function m1ka_online_users_widget() {
if ( current_user_can( 'manage_options' ) ) {
wp_add_dashboard_widget( 'm1ka_online_users', 'Users Stats', 'm1ka_online_users' );
}
@nfsarmento
nfsarmento / functions.php
Last active August 8, 2018 16:52
Custom WordPress dashboard widget
/**
* Custom dashboard widget
*/
add_action('wp_dashboard_setup', 'ns_custom_dashboard_widgets');
function ns_custom_dashboard_widgets() {
global $wp_meta_boxes;
wp_add_dashboard_widget('custom_help_widget', 'Website Support', 'custom_dashboard_help');
@nfsarmento
nfsarmento / functions.php
Last active August 8, 2018 16:52 — forked from bmoredrew/gist:dcc7d04b23e785f6c0bb
Front-end Attendee List WooCommerce WooTickets Events Calendar Plugin
<?php
global $current_user;
get_currentuserinfo();
if (is_user_logged_in() && $current_user->ID == $post->post_author) {
// Build a list of attendees
$attendeeList = TribeEventsTickets::get_event_attendees($event_id);
$customerList = array();
@nfsarmento
nfsarmento / functions.php
Created August 8, 2018 16:51
Add custom css to WP Admin
add_action('admin_head', 'ns_custom_style');
function ns_custom_style() {
echo '<style>
body, td, textarea, input, select {
font-family: "Lucida Grande";
font-size: 12px;
}
</style>';
}
@nfsarmento
nfsarmento / funtions.php
Last active October 30, 2018 14:44
Force users to use default colour scheme
/**
* Force users to use the ocean colour scheme
*
* https://www.nuno-sarmento.com
*/
function aet_change_admin_color( $result ) {
return 'ocean';
}
add_filter( 'get_user_option_admin_color', 'aet_change_admin_color' );
@nfsarmento
nfsarmento / functions.php
Last active October 30, 2018 14:43
This function makes posts in the admin filterable by the author
/**
* This function makes posts in the admin filterable by the author.
*
* https://www.nuno-sarmento.com
*/
function ns_filter_by_the_author() {
$params = array(
'name' => 'author', // this is the "name" attribute for filter <select>
'show_option_all' => 'All authors' // label for all authors (display posts without filter)
);