Discuss your project

PartITech blog

Technology blog

Technical analysis, practical guides and field experience to build, modernize and maintain sustainable applications.

232 articles Page 19

WordPress: Add a favicon in the admin

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'); Reproduce this customization today The principle of the hook remains useful, but the administration screens and WordPress APIs have evolved since the publication. Test the code in a staging enviro...

Apache: PHP Directives in the .htaccess File

Here is a non-exhaustive list of PHP directives that can be added to the .htaccess file: php_flag display_errors Off error_log = /path/filename php_value date.timezone 'Region/Zone' php_value max_execution_time 30 php_flag register_globals Off php_flag magic_quotes_gpc Off php_value upload_max_filesize 200M php_value post_max_size 200M php_value memory_limit 20M php_value max_input_vars 100 Compatibility context This procedure documents a PHP or Apache environment from its time. PHP 5.x an...

Apache: Enable compression

To enable compression in Apache, you have two options; The first is to insert the directives into the .htaccess file, and the second is to place these directives directly in the declaration of your vhost. <ifModule mod_gzip.c> mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^i...

WordPress: Remove WPML paid translation boxes

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

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...

Zend: Create a CLI file and activate it in the shell

To add a cron job and make it accessible in the shell, you first need to configure your environment to point to the libraries.Step 1: Add the zf script to the /usr/bin/ directory (zf.sh and zf.php) These files are available in the bin directory of the ZendFramework 1.x library. You can either copy them or create a symbolic link.Step 2: Configure your bash to recognize the zf alias. Edit the ~/.bashrc file and insert the following line alias zf="/usr/bin/zf.sh" Step 3: Add the global variable ...

Shell: Remove all .svn recursively

To recursively remove all svn management files (.svn) from a working copy, simply navigate to the root directory of your working copy and execute the following command: find . -name ".svn" -exec rm -rf {} \; Another solution is to create an alias in your ~/.bashrc and then execute the command when needed: alias rmsvn='find . -name ".svn" -exec rm -rf {} \;' Precautions before executing the order This tutorial retains the command and the context of its publication. Before using it on a curr...

SVN: Make a recursive addition in shell

To add files recursively from the command line with svn, we have several possibilities.The first one, probably the cleanest: svn add --force * --auto-props --parents --depth infinity -q Although only the following options seem really necessary: svn add --force * Then there are alternative solutions a bit more complicated to understand: svn status | grep '?' | sed 's/^.* /svn add /' | bash svn add `svn status .|grep "^?"|awk '{print $2}'` svn st | grep "^\?" | awk "{print \$2}" | xargs svn...

WordPress: Hide the default category on the front

To be placed in the functions.php file: add_filter( 'list_terms_exclusions', 'global_cat_exclude' ); function global_cat_exclude( $terms ) { if( !is_admin() ) $terms = "AND t.term_id != " . get_option( 'default_category' ) . " "; return $terms; } Reproduce this customization today The principle of the hook remains useful, but the administration screens and WordPress APIs have evolved since the publication. Test the code in a staging environment with the exact version of the site's core,...

WordPress: Configure the default information of a theme

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: Configure an options page in the admin

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

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...