Register theme customizer settings when theme activates [duplicate]

You need only use the default value on the wp_customize and that is all $wp_customize->add_setting(‘mytextoption’, array( ‘default’ => ‘defaultvalue’, ‘capability’ => ‘edit_theme_options’, ‘type’ => ‘option’, replace defaultvalue for the value you want, and when the user activate the theme this line will register the default value on the DB only when not exist on the … Read more

Exclude file from theme editor

In general I wouldn’t recommend editing files that way and just disable it with the well known DISALLOW_FILE_EDIT or DISALLOW_FILE_MODS constants, that are checked within the map_meta_cap() function. But anyway it’s interesting to see if we can find a way to exclude files from the theme editor. Here are some ideas: There doesn’t seem to … Read more

Generating the ogp tags in theme

If it is a page the global post object is already set when wp_head fires. But you have to get the data for this page with custom code. Pseudo code: add_action ( ‘wp_head’, ‘wpse_58539_get_ogp’ ); function wpse_58539_get_ogp() { if ( ! is_page_template( ‘your-template-name’ ) ) { return; } $page = get_post( $GLOBALS[‘post’] ); // Inspect … Read more

Extra User Profile Field Upload File / Image

PHP CODE /* * Load style & scripts */ function itclanbd_admin_load_scripts( $hook ) { $allowed = [‘profile.php’, ‘user-new.php’, ‘user-edit.php’]; if ( ! in_array( $hook, $allowed ) ) { return; } wp_enqueue_media(); wp_enqueue_style(‘finance2sell’, plugins_url(‘css/style.css’, __FILE__), array(), null); wp_enqueue_script(‘finance2sell’, plugins_url(‘js/scripts.js’, __FILE__), array(), ‘1.3’, true); } add_action( ‘admin_enqueue_scripts’, ‘itclanbd_admin_load_scripts’ ); /** * Create custom fields * @param $user … Read more

Getting rid of unused css directives [closed]

The guys behind this project I trust a lot. https://unused-css.com/ Also I used this long time ago: https://addons.mozilla.org/en-US/firefox/addon/dust-me-selectors/ However, you need to be careful, because you must not remove some CSS that will be used in the future, or in case some feature is enabled later.

Enqueue different stylesheets using IE conditionals

While basic use of CSS IE conditionals is off-topic for WPSE, WordPress does include a method for enqueueing stylesheets conditionally, based on CSS IE conditionals. First, you need to use the correct conditionals: <!–[if lt IE 9]> ie.css <![endif]–> Second, you should enqueue this stylesheet properly, in functions.php, via callback hooked into wp_enqueue_scripts: <?php function … Read more

How do I change the fonts in the Twenty Thirteen theme?

I looked at TwentyThirteen’s twentythirteen_fonts_url() function and there are no hooks so you need to deregister twentythirteen-fonts and enqueue your own fonts. Removing the fonts is easy: function deregister_gfonts_wpse_111190() { wp_deregister_style(‘twentythirteen-fonts’); } add_action(‘wp_enqueue_scripts’,’deregister_gfonts_wpse_111190′,100); Add your own Google fonts (or other) the same way that TwentyThirteen did. You will need to add another stylesheet to override … Read more

How to delete default themes

My approach is to delete the default themes using ftp or your control panel file-manager once you have your site up and running. These themes will not be re-installed when you update WordPress, and will not show up in your update notifications. I usually keep the TwentySixteen theme on the system as this is the … Read more