Skip to content

Instantly share code, notes, and snippets.

Avatar

Julio Potier JulioPotier

View GitHub Profile
@JulioPotier
JulioPotier / gist:756f6873d6231133fc756095c8295a58
Created May 4, 2017
Patch WordPress Reset Password Vulnerability
View gist:756f6873d6231133fc756095c8295a58
add_filter( 'wp_mail_from', 'baw_fix_wp_474_mail_reset_vulnerability' );
function baw_fix_wp_474_mail_reset_vulnerability( $from_email ) {
return 'wordpress@example.com';
}
View gist:45a425c14adbc807e62d
add_filter( 'embed_site_title_html', 'baw_embed_site_title' );
function baw_embed_site_title( $title ) {
return '<a href="http://wpsolo.fr" target="_top"><img src="/wp-content/uploads/2011/07/iMovie-Logo.png" width="32" height="32" alt="" class="wp-embed-site-icon"><span>MyMovies</span></a>';
}
add_action( 'embed_content', 'baw_embed_content' );
function baw_embed_content() {
echo '<i>Rating</i>: ' . str_repeat( '&bigstar;', 5 );
}
View gist:bbc90dd08c29c50a20a8
add_filter( 'the_title', 'baw_add_color_to_title' );
function baw_add_color_to_title( $title ) {
global $post;
if ( is_single() ) {
$term = get_the_terms( 0, 'category' );
if ( $term ) {
$term = reset( $term );
$color = get_term_meta( $term->term_id, 'color', true );
$title = sprintf( '<span style="color:%s">%s</span>', esc_attr( $color ), $title );
}
View gist:ff7e6ca779c4b51e843a
add_action( 'edit_category', 'baw_save_term_color' );
add_action( 'create_category', 'baw_save_term_color' );
function baw_save_term_color( $term_id ) {
if ( defined( 'DOING_AJAX' ) ) {
return;
}
if ( ! isset( $_POST['add_term_meta_color_nonce'] ) ||
! isset( $_POST['baw_term_color'] ) ||
! wp_verify_nonce( $_POST['add_term_meta_color_nonce'], 'add_term_meta_color' )
View gist:69c03da5973c04e0eb12
add_action( 'category_add_form_fields', 'baw_new_term_color_field' );
function baw_new_term_color_field() {
wp_nonce_field( 'add_term_meta_color', 'add_term_meta_color_nonce' );
?>
<div class="form-field">
<label for="baw_term_color"><?php _e( 'Front Color', 'baw' ); ?></label>
<input type="text" name="baw_term_color" id="baw_term_color" data-default-color="#FFFFFF" value="#FFFFFF" />
</div>
<?php
View gist:9525143ebc1d90cf4cf4
add_filter( 'pre_get_imagify_option_admin_bar_menu', 'imagify_admin_bar_for_admins' );
function imagify_admin_bar_for_admins() {
return current_user_can( 'manage_options' );
}
View gist:bfc2c66461722c86f8eb
<?php
add_filter( 'manage_edit-category_columns', 'baw_edit_term_columns' );
function baw_edit_term_columns( $columns ) {
$columns['color'] = __( 'Front Color', 'baw' );
return $columns;
}
View gist:2e5e8c45ec43faf7c48f
<?php
add_action( 'admin_head-edit-tags.php', 'baw_admin_enqueue_styles' );
function baw_admin_enqueue_styles() {
global $taxnow;
if ( 'category' != $taxnow ) {
return;
}
add_action( 'admin_head', 'baw_term_colors_print_styles' );
View gist:c125e569da04ff307cb5
<?php
add_action( 'admin_head-edit-tags.php', 'baw_admin_enqueue_scripts' );
function baw_admin_enqueue_scripts() {
global $taxnow;
if ( 'category' != $taxnow ) {
return;
}
wp_enqueue_style( 'wp-color-picker' );
View gist:a64ddcd716e1d3cd45e1
<?php
add_action( 'category_add_form_fields', 'baw_new_term_color_field' );
function baw_new_term_color_field() {
wp_nonce_field( 'add_term_meta_color', 'add_term_meta_color_nonce' );
?>
<div class="form-field">
<label for="baw_term_color"><?php _e( 'Front Color', 'baw' ); ?></label>
<input type="text" name="baw_term_color" id="baw_term_color" data-default-color="#ffffff" />
</div>
<?php