Title: [Plugin: WordPress.com Custom CSS] Localization and startup error
Last modified: August 19, 2016

---

# [Plugin: WordPress.com Custom CSS] Localization and startup error

 *  [Peter Holme Obrestad](https://wordpress.org/support/users/peterhol/)
 * (@peterhol)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/plugin-wordpresscom-custom-css-localization-and-startup-error/)
 * Hi!
 * I’d be interested in localizing this plugin – now it’s supposed to get its translations
   from wp.com, right? I have validator access for the norwegian at both wp.com 
   and wp.org – but it doesn’t do anything when I translate strings at [http://translate.wordpress.com/projects/wpcom/no/default](http://translate.wordpress.com/projects/wpcom/no/default)
   
   So it would maybe be an idea to add a local textdomain??
 * Also, When a user activates the plugin, before saving their own stylesheet, and
   while using php 5.3 – there is an error. It can be fixed by applying this patch(
   printout from svn diff):
 *     ```
       --- wp-content/plugins/safecss/safecss.php	(revision 21)
       +++ wp-content/plugins/safecss/safecss.php	(working copy)
       @@ -103,8 +103,9 @@
         *
         * @return array
         */
       -function get_safecss_post() {
       -	$safecss_post = get_object_vars( array_shift( get_posts( array( 'numberposts' => 1, 'post_type' => 'safecss', 'post_status' => 'publish' ) ) ) );
       +function get_safecss_post() {
       +	$a = array_shift( get_posts( array( 'numberposts' => 1, 'post_type' => 'safecss', 'post_status' => 'publish' ) ) );
       +	if ($a) $safecss_post = get_object_vars( $a );  // needed for php 5.3
        	return $safecss_post;
        }
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [Peter Holme Obrestad](https://wordpress.org/support/users/peterhol/)
 * (@peterhol)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/plugin-wordpresscom-custom-css-localization-and-startup-error/#post-1593087)
 * I went ahead and localized the rest of safecss.php as well… Here is the diff (
   including the hack to allow php 5.3:
 *     ```
       Index: wp-content/plugins/safecss/safecss.php
       ===================================================================
       --- wp-content/plugins/safecss/safecss.php	(revision 21)
       +++ wp-content/plugins/safecss/safecss.php	(revision 26)
       @@ -9,6 +9,16 @@
        */
   
        /**
       + * Add local textdomain
       + */
       +add_action( 'init', 'safecss_load_plugin_textdomain' );
       +
       +function safecss_load_plugin_textdomain() {
       +	load_plugin_textdomain( 'safecss', false, 'safecss/languages' );
       +}
       +
       +
       +/**
         * Migration routine for moving safecss from wp_options to wp_posts to support revisions
         *
         * @return void
       @@ -103,8 +113,9 @@
         *
         * @return array
         */
       -function get_safecss_post() {
       -	$safecss_post = get_object_vars( array_shift( get_posts( array( 'numberposts' => 1, 'post_type' => 'safecss', 'post_status' => 'publish' ) ) ) );
       +function get_safecss_post() {
       +	$a = array_shift( get_posts( array( 'numberposts' => 1, 'post_type' => 'safecss', 'post_status' => 'publish' ) ) );
       +	if ($a) $safecss_post = get_object_vars( $a ); // needed for php 5.3
        	return $safecss_post;
        }
   
       @@ -332,7 +343,7 @@
        	$css = str_replace( array( '\\0BB \\020', 'BB 20', '0BB 020' ), '0BB 020', $css );
   
        	if ( empty( $css ) ) {
       -		$css = '/* Welcome to Custom CSS!
       +		$css = _e('/* Welcome to Custom CSS!
   
        If you are familiar with CSS or you have a stylesheet ready to paste, you may delete these comments and get started.
   
       @@ -366,7 +377,7 @@
         * sharing your CSS!
         * testing in several browsers!
         * helping others in the forum!
       -';
       +', 'safecss');
        $css .= "\n*/";
        	}
   
       @@ -455,7 +466,7 @@
        	if ( is_admin() )
        		return;
   
       -	$message = wp_specialchars(__('Preview: changes must be saved or they will be lost'), 'single');
       +	$message = wp_specialchars(__('Preview: changes must be saved or they will be lost', 'safecss'), 'single');
        	return "
        <script type='text/javascript'>
        // <![CDATA[
       @@ -625,18 +636,18 @@
        ?>
        <div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>">
        <div class="wrap">
       -<h2><?php _e('CSS Stylesheet Editor'); ?></h2>
       +<h2><?php _e('CSS Stylesheet Editor', 'safecss'); ?></h2>
        <form id="safecssform" action="" method="post">
        	<p><textarea id="safecss" name="safecss"><?php echo str_replace('</textarea>', '</textarea&gt', safecss()); ?></textarea></p>
        	<p class="custom-css-help"><?php _e('For help with CSS try <a href="http://www.w3schools.com/css/default.asp">W3Schools</a>, <a href="http://alistapart.com/">A List Apart</a>, and our own <a href="http://support.wordpress.com/editing-css/">CSS documentation</a> and <a href="http://en.forums.wordpress.com/forum/css-customization">CSS Forum</a>.', 'safecss'); ?></p>
        	<h4><?php _e("Do you want to make changes to your current theme's stylesheet, or do you want to start from scratch?", 'safecss'); ?></h4>
       -	<p><label><input type="radio" name="add_to_existing" value="true" <?php if ( get_option( 'safecss_add') != 'no' ) echo ' checked="checked"'; ?> /> <?php printf( __('Add this to the %s theme\'s CSS stylesheet (<a href="%s">view original stylesheet</a>)'), get_current_theme(), get_bloginfo( 'stylesheet_directory' ) . '/style.css' . '?minify=false' ); ?></label><br />
       -	<label><input type="radio" name="add_to_existing" value="false" <?php if ( get_option( 'safecss_add') == 'no' ) echo ' checked="checked"'; ?> /> <?php _e('Start from scratch and just use this '); ?></label>
       +	<p><label><input type="radio" name="add_to_existing" value="true" <?php if ( get_option( 'safecss_add') != 'no' ) echo ' checked="checked"'; ?> /> <?php printf( __('Add this to the %s theme\'s CSS stylesheet (<a href="%s">view original stylesheet</a>)', 'safecss'), get_current_theme(), get_bloginfo( 'stylesheet_directory' ) . '/style.css' . '?minify=false' ); ?></label><br />
       +	<label><input type="radio" name="add_to_existing" value="false" <?php if ( get_option( 'safecss_add') == 'no' ) echo ' checked="checked"'; ?> /> <?php _e('Start from scratch and just use this ', 'safecss'); ?></label>
        	</p>
   
       -	<h4> <?php _e("If you change the width of your main content column, make sure your media files fit. Enter the maximum width for media files in your new CSS below."); ?></h4>
       -	<p class="custom_content_width"><label for="custom_content_width"><?php _e('Limit width to'); ?></label>
       -	<input type="text" name="custom_content_width" id="custom_content_width" value="<?php echo $custom_content_width; ?>" size=5 /> <?php printf( __('pixels for videos, full size images, and other shortcodes. (<a href="%s">more info</a>)'), 'http://support.wordpress.com/editing-css/#limited-width'); ?></p>
       +	<h4> <?php _e("If you change the width of your main content column, make sure your media files fit. Enter the maximum width for media files in your new CSS below.", 'safecss'); ?></h4>
       +	<p class="custom_content_width"><label for="custom_content_width"><?php _e('Limit width to', 'safecss'); ?></label>
       +	<input type="text" name="custom_content_width" id="custom_content_width" value="<?php echo $custom_content_width; ?>" size=5 /> <?php printf( __('pixels for videos, full size images, and other shortcodes. (<a href="%s">more info</a>)', 'safecss'), 'http://support.wordpress.com/editing-css/#limited-width'); ?></p>
        	<p class="submit">
        		<input type="hidden" name="action" value="save" />
        		<?php wp_nonce_field('safecss') ?>
       @@ -663,7 +674,7 @@
        		wp_list_post_revisions( $safecss_post['ID'], $args );
        	}
   
       -	add_meta_box( 'revisionsdiv', __('CSS Revisions'), 'post_revisions_meta_box', 'editcss', 'normal' );
       +	add_meta_box( 'revisionsdiv', __('CSS Revisions', 'safecss'), 'post_revisions_meta_box', 'editcss', 'normal' );
        	do_meta_boxes( 'editcss', 'normal', $safecss_post );
        }
        ?>
       ```
   
 *  Plugin Contributor [briancolinger](https://wordpress.org/support/users/briancolinger/)
 * (@briancolinger)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/plugin-wordpresscom-custom-css-localization-and-startup-error/#post-1593429)
 * [@peterhol](https://wordpress.org/support/users/peterhol/), I’ve merged your 
   patch into the plugin.
    Thanks again!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Plugin: WordPress.com Custom CSS] Localization and startup error’ is
closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/safecss.svg)
 * [WordPress.com Custom CSS](https://wordpress.org/plugins/safecss/)
 * [Support Threads](https://wordpress.org/support/plugin/safecss/)
 * [Active Topics](https://wordpress.org/support/plugin/safecss/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/safecss/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/safecss/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [briancolinger](https://wordpress.org/support/users/briancolinger/)
 * Last activity: [15 years, 9 months ago](https://wordpress.org/support/topic/plugin-wordpresscom-custom-css-localization-and-startup-error/#post-1593429)
 * Status: not resolved