add_filter( ‘block_editor_settings_all’, function( $editor_settings ) { $css = wp_get_custom_css_post()->post_content; $editor_settings[‘styles’][] = array( ‘css’ => $css ); return $editor_settings; } );Continue reading
/** * Allow SVG uploads for administrator users. * * @param array $upload_mimes Allowed mime types. * * @return mixed */ add_filter( ‘upload_mimes’, function ( $upload_mimes ) { // By default, only administrator users are allowed to add SVGs. //…Continue reading
/** * Change a currency symbol */ add_filter(‘woocommerce_currency_symbol’, ‘change_existing_currency_symbol’, 10, 2); function change_existing_currency_symbol( $currency_symbol, $currency ) { switch( $currency ) { case ‘مصري’: $currency_symbol = ‘جنيه’; break; } return $currency_symbol; }Continue reading
function replace_admin_bar_text() { global $wp_admin_bar; $wp_admin_bar->add_node(array( ‘id’ => ‘site-name’, ‘title’ => __(”), )); $wp_admin_bar->add_node(array( ‘id’ => ‘my-account’, ‘title’ => ‘👤‘, ‘href’ => get_edit_profile_url(), )); } add_action(‘wp_before_admin_bar_render’, ‘replace_admin_bar_text’, 0); function remove_wp_logo() { global $wp_admin_bar; $wp_admin_bar->remove_menu(‘wp-logo’); } add_action(‘wp_before_admin_bar_render’, ‘remove_wp_logo’, 0); function remove_comments()…Continue reading
/** * Notify admin and user when a user registers with Charitable. * * @param array[] $fields * @param Charitable_Donation_Form $form * @return array[] */ function charitable_notify_new_user($user_id, $values) { wp_new_user_notification( $user_id, null, ‘admin’ ); } add_action(‘charitable_after_insert_user’, ‘charitable_notify_new_user’, 10, 2);Continue reading
/** * Display percent donated as rounded whole number. * * @param string $return * @param int $percent * @return string */ function ed_round_percent_donated_to_whole_number( $return, $percent ) { return ceil( $percent ) . ‘%’; } add_filter( ‘charitable_percent_donated’, ‘ed_round_percent_donated_to_whole_number’, 10, 2…Continue reading
/** * NOTE: This snippet will not work in versions of Charitable prior to 1.2. * * Set the default colour used by Charitable. * * @return string */ function en_set_default_highlight_colour() { return ‘#123456’; } add_filter( ‘charitable_default_highlight_colour’, ‘en_set_default_highlight_colour’ );Continue reading
/** * Collect a checkbox field in the donation form. * * This snippet only works in Charitable 1.5 or above. * * Related examples: * * @see Register a text field (detailed example) – https://github.com/Charitable/library/blob/master/donation-form/register-new-donation-field-1.5.php * @see Register multiple…Continue reading