Skip to content

Instantly share code, notes, and snippets.

@yuliyang
yuliyang / .htaccess
Created November 30, 2016 18:23
[WordPress] use remote images in local environment
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^wp-content/uploads/(.*)$ http://www.example.com/wp-content/uploads/$1 [R=302,L,NC]
</IfModule>
# BEGIN WordPress
# ----- WP generated code
@yuliyang
yuliyang / wp-login-custom-font.php
Last active April 14, 2017 02:34
[WordPress] Custom Fonts in Login Screen
<?php
function scripts_enqueues_admin() {
wp_enqueue_style('typography', '//typography.url/font-file.css', null);
}
add_action( 'login_enqueue_scripts', 'scripts_enqueues_admin' );
@yuliyang
yuliyang / wp-disable-admin-bar.php
Last active April 14, 2017 02:35
[WordPress] Disable admin bar for logged in users
<?php
// Disable admin bar
function disable_admin_bar() {
if ( ! current_user_can('edit_posts') ) {
add_filter('show_admin_bar', '__return_false');
}
}
add_action( 'after_setup_theme', 'disable_admin_bar' );
@yuliyang
yuliyang / wp-allow-svg-upload.php
Last active November 1, 2018 07:49
[WordPress] Allow uploading SVG files
<?php
// allow more file types for uploads
function cc_mime_types($mimes)
{
$mimes['zip'] = 'application/zip';
$mimes['rar'] = 'application/x-rar-compressed';
$mimes['tar'] = 'application/x-tar';
$mimes['gz'] = 'application/x-gzip';
$mimes['gzip'] = 'application/x-gzip';
$mimes['tiff'] = 'image/tiff';
@yuliyang
yuliyang / functions.php
Last active June 18, 2019 11:15
[Elementor] Adding fonts to typography options
<?php
/**
* Adding fonts to Elementor typography options
*/
function ching_add_fonts_elementor( $controls_registry ) {
// retrieve fonts list from Elementor
$fonts = $controls_registry->get_control( 'font' )->get_settings( 'options' );
// add your new custom font
$new_fonts = array_merge( [ 'Your Custom Font Family Name' => 'system' ], $fonts );
@yuliyang
yuliyang / functions.php
Created January 7, 2019 05:55
[Gravity Form] Repeater field
<?php
// change "3" to your form ID
add_filter( 'gform_form_post_get_meta_3', 'add_my_field' );
function add_my_field( $form ) {
$name = GF_Fields::create( array(
'type' => 'text',
'id' => 1005,
'formId' => $form['id'],
@yuliyang
yuliyang / gist:4411ccfd71f91110ce3f054d4cc10e1f
Created January 11, 2019 03:47
[ACF] States for selector
AL : Alabama
AK : Alaska
AZ : Arizona
AR : Arkansas
CA : California
CO : Colorado
CT : Connecticut
DE : Delaware
DC : District of Columbia
FL : Florida
@yuliyang
yuliyang / customizer-links.php
Created April 16, 2019 02:50 — forked from slushman/customizer-links.php
How to link into the WordPress Customizer
@yuliyang
yuliyang / robots.txt
Last active June 14, 2019 03:56
[WordPress] control how participating bots interact with the site using robots.txt
User-agent: *
Disallow: /wp-admin/
Disallow: /wp-includes/
Disallow: /wp-login.php
# make sure to update theme folder
Disallow: /wp-content/themes/theme-name
Allow: /wp-admin/admin-ajax.php
# to restraict the whole site
User-agent: *
@yuliyang
yuliyang / functions.php
Last active June 18, 2019 11:14
[Ninja Forms] Allow shortcode in Ninja Forms
<?php
add_filter( 'ninja_forms_action_email_message', function( $message, $data, $action_settings ) {
return do_shortcode( $message );
}, 20, 3);