Section en-wordpress

WordPress: Disable the Gutenberg Editor in the Widgets Administration

Written by on 04/04/2021
Category:   Wordpress, Backoffice
It surely did not escape your notice that WordPress updated its WYSIWYG content editor.And it works very well for standard content pages.A few months ago, the editor was implemented in the management of widgets. And then, bang…JS error when loading the page:index.js:1:3953Uncaught (in promise) TypeError: e is undefinedAnd it becomes impossible to edit already configured sidebars: While waiting for the Gutenberg issue to be resolved, you might want to swit...

WordPress: Add a New Widget Area to a WordPress Theme

Written by admin on 21/03/2021
Category:   Wordpress, Backoffice, Front
Tags:   widget, wordpress
If you're familiar with WordPress themes, you know that many themes come with a widgetized sidebar. This means that you can add, remove, and rearrange widgets on your WordPress website using the "Widgets" section of your WordPress dashboard.Having a widgetized sidebar is very useful, but you may also want to widgetize other parts of your WordPress theme. It's quite easy to do, and once your theme is modified, it will be simple for you or the WordPress admini...

Set the Correct Permissions for WordPress Files

Written by on 16/01/2020
Category:   Wordpress
Tags:  
WordPress permissions should be set to 755 for directories and 644 for files.The entire set must have the same user/group as the server. chown www-data:www-data -R * find . -type d | xargs chmod -v 755 find . -type f | xargs chmod -v 644

WordPress: Reset Admin Password

Written by on 16/08/2014
Category:   Wordpress, Backoffice
Tags:   admin, wordpress
Useful when you receive project delivery, and the idiot who delivers it forgets to tell you that the password is admin1234. Instead of being stuck without being able to run your tests, you just need to apply the following SQL query:UPDATE wp_users SET user_pass = MD5( 'new_password' ) WHERE user_login = 'your-username';

WordPress: Rename the Excerpt Editing Area Label

Written by on 15/05/2014
Category:   Wordpress, Backoffice
Tags:   admin, wordpress
It's true that when we talk about an excerpt, nobody understands what it refers to.To change the title of this editing area, just use the following snippet of code: add_filter( 'gettext', 'wpse22764_gettext', 10, 2 ); function wpse22764_gettext( $translation, $original ) { if ( 'Excerpt' == $original ) { return 'Sous-titre'; }else{ $pos = strpos($original, 'Excerpts are optional hand-crafted summaries of your'); if ($pos !== false) { return 'Sous-titre affiché dans les push.'; } } ret...

WordPress: Filter Mime Types of Uploads

Written by on 15/05/2014
Category:   Wordpress, Backoffice
Tags:   admin, wordpress
To ensure that just about anything isn't uploaded from the admin, you can configure the authorized MIME types as follows: add_filter('upload_mimes','custom_upload_mimes'); function custom_upload_mimes($mime_types=array()){ $mime_types = array( 'jpg|jpeg|jpe' => 'image/jpeg', 'png' => 'image/png', 'mp4' => 'video/mp4', 'flv' => 'video/x-flv' ); return $mime_types; }

WordPress: Add an author filter to the admin post list

Written by on 15/05/2014
Category:   Wordpress, Backoffice
Tags:   admin, wordpress
To add an author filter on the list of articles page available in WordPress, simply add the following code to the functions.php file: Note: I have left the comment on the conditional instruction concerning the post types, it might come in handy 😊 function restrict_manage_authors() { /*if (isset($_GET['post_type']) && post_type_exists($_GET['post_type']) && in_array(strtolower($_GET['post_type']), array('your_custom_post_types', 'here'))) { */wp_dropdown_users(a...

WordPress: Remove comment metaboxes everywhere

Written by on 15/05/2014
Category:   Wordpress, Backoffice
Tags:   admin, wordpress
To remove comment metaboxes from WordPress content editing pages, add the following code to your functions.php file: add_action('admin_menu','remove_comments_metabox'); function remove_comments_metabox() { remove_meta_box( 'postcomments','post','normal' ); } // Disable support for comments and trackbacks in post types function df_disable_comments_post_types_support() { $post_types = get_post_types(); foreach ($post_types as $post_type) { if(post_type_supports($post_type, 'comments')) { remov...

WordPress: Changing the Default Colors of the WordPress HTML Editor

Written by on 15/05/2014
Category:   Wordpress, Backoffice
Tags:   admin, wordpress
To change the default colors available in the WordPress WYSIWYG editor, simply add the following code to the functions.php file: // change buttons in WYSWIG post editor, edit color palette function change_mce_options( $init ) { $init['theme_advanced_text_colors'] = 'd21268,146c52,82b600,00949b,010080,001c4b'; $init['theme_advanced_more_colors'] = true; return $init; } add_filter('tiny_mce_before_init', 'change_mce_options');

WordPress: Override a template when a variable is present in the URL

Written by on 15/05/2014
Category:   Wordpress, Front
Tags:   wordpress
In very rare cases, one might need to override the default template (although it's a bit dirty to do that).In the functions.php file, add the following code: function wpa_overload_template( $template ) { if( isset( $_GET['parameter'] ) ) { $template = locate_template('template-overload.php', false ); } return $template; } add_filter( 'template_include', 'wpa_overload_template' );

WordPress: Add a favicon to the admin

Written by on 15/05/2014
Category:   Wordpress, Backoffice
Tags:   admin, wordpress
No real interest in adding a favicon to the WordPress admin area, but a client may request it, which has already happened: function favicon(){ echo '<link rel="shortcut icon" href="',get_template_directory_uri(),'/images/favicon.ico" />',"\n"; } add_action('admin_head','favicon');

WordPress: Remove WPML's Paid Translation Boxes

Written by on 15/05/2014
Category:   Wordpress, Backoffice
Tags:   admin, WPML, wordpress
When you install WPML to manage translations, it automatically adds prompts for paid translations on the post editing page. To remove them, a simple way is to delete the box from the DOM.Insert the following code into your functions.php file: add_action( 'admin_footer', 'wpmlRemoveBox_hook' ); function wpmlRemoveBox_hook( $hook_suffix ) { ?> <script type="text/javascript"> jQuery( document ).ready(function() { jQuery('.icl_cyan_box').remove(); jQuery('#cpt_info_box').re...

WordPress: Configure the Color Picker of a Custom Field Type

Written by on 15/05/2014
Category:   Wordpress, Backoffice
Tags:   admin, wordpress
To set up the default colors for the color picker of custom type fields, simply add a JavaScript snippet to override the default configuration.In your functions.php file, add the following code, and configure the palette as you wish: add_action( 'admin_footer', 'backgroundColor_hook' ); function backgroundColor_hook( $hook_suffix ) { ?> <script type="text/javascript"> jQuery( document ).ready(function() { jQuery('.js-types-colorpicker').each(function(){ jQuery(this).wpC...

WordPress: Set Up Default Theme Information

Written by on 13/05/2014
Category:   Wordpress, Backoffice
Tags:   admin, wordpress
To associate a screenshot and add credits for a theme on the WordPress theme selection page, simply add a file named « screenshot.jpg » and place it at the root of the theme. For the credits, just add the following code to the style.css file at the root of the theme and include the following header: @charset "utf-8"; /* Theme Name: Le nom de mon theme Theme URI: http://ledomainedutheme.com/cequetuveux/ Author: partITech Author URI: http://www.partitech.com Version: 1.0 */

WordPress: Set Up an Options Page in the Admin

Written by on 13/05/2014
Category:   Wordpress, Backoffice
Tags:   admin, wordpress
This example allows the addition of an options page for a WordPress theme. The file should be named theme-options.php and must be placed in the functions directory of your theme. This example is taken from the Pubicis-Verbe project. <?php add_action('admin_menu','verbe_menu_page'); function verbe_menu_page(){ add_theme_page('Verbe Theme Options', 'Theme Option', 'manage_options', 'verbe-theme-option', 'verbe_setting_page'); } add_action('admin_init', 'verbe_register_setting'); fu...

WordPress: Configure TinyMCE

Written by on 13/05/2014
Category:   Wordpress, Backoffice
Tags:   admin, TinyMCE, wordpress
Overriding the default TinyMCE configuration:To insert into the functions.php function myformatTinyMCE($in) { $in['remove_linebreaks']=false; $in['gecko_spellcheck']=false; $in['keep_styles']=true; $in['accessibility_focus']=true; $in['tabfocus_elements']='major-publishing-actions'; $in['media_strict']=false; $in['paste_remove_styles']=false; $in['paste_remove_spans']=false; $in['paste_strip_class_attributes']='none'; $in['paste_text_use_dialog']=true; $in['wpeditimage_disable_captions']=tru...

WordPress: Add a Taxonomy Manually

Written by on 13/05/2014
Category:   Wordpress, Backoffice
Tags:   admin, taxonomy, wordpress
Example of manual addition of a taxonomy (without going through the configuration).To be placed in the functions.php file: /** * Manual add new Field to taxonomy or you can use plugin "taxonomy manager" * * BEGIN */ // A callback function to add a custom field to our "expertise" taxonomy function expertise_taxonomy_custom_fields($tag) { // Check for existing taxonomy meta for the term you're editing $t_id = $tag->term_id; // Get the ID of the term you're editing $term_meta = get_optio...