<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Zlatko Zlatev</title>
	<atom:link href="https://zzlatev.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://zzlatev.com</link>
	<description>Code Experience</description>
	<lastBuildDate>Thu, 25 Jul 2013 18:41:42 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>qTranslate &#8211; Localize language names</title>
		<link>https://zzlatev.com/qtranslate-localize-language-names/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=qtranslate-localize-language-names</link>
		<comments>https://zzlatev.com/qtranslate-localize-language-names/#comments</comments>
		<pubDate>Thu, 25 Jul 2013 18:41:42 +0000</pubDate>
		<dc:creator><![CDATA[zlatev]]></dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[qTranslate]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress multilingual]]></category>
		<category><![CDATA[wordpress plugin]]></category>

		<guid isPermaLink="false">http://zzlatev.com/?p=203</guid>
		<description><![CDATA[<p>I&#8217;ve used qTranslate in quite some projects already. It&#8217;s not perfect but it&#8217;s surely most user-friedly multilingual plugin for WordPress. I give you that qTranslate. Every now and then a client is irritated by the fact language names appear in &#8230; <a href="https://zzlatev.com/qtranslate-localize-language-names/">Continued</a></p><p>The post <a href="https://zzlatev.com/qtranslate-localize-language-names/">qTranslate &#8211; Localize language names</a> appeared first on <a href="https://zzlatev.com">Zlatko Zlatev</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve used qTranslate in quite some projects already. It&#8217;s not perfect but it&#8217;s surely most user-friedly multilingual plugin for WordPress. I give you that qTranslate.</p>
<p>Every now and then a client is irritated by the fact language names appear in their native language and are not localized properly. An example would be:</p>
<pre>Sorry, this entry is only available in <strong>Български</strong>.</pre>
<p>My first encounter with this problem ended up hard-coding some lines for code into the plugin inself. After some time I needed to update the core and the plugin and totally forgot I did something there. Of course I lost my changes. With a better understanding of WordPress and the concepts it&#8217;s based on I once again went for that task. I was able to hook to qTranslate loading proccess at the point when it determines the language of the loaded page and apply its own localization methods to accomplish my goal.</p>
<p>&nbsp;</p>
<p>First thing you need to do is to change your language name so it uses the <a href="http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&amp;t=385" target="_blank">qTranslate Quicktags</a>.</p>
<div id="attachment_206" style="width: 483px" class="wp-caption alignnone"><img class="size-full wp-image-206" alt="qtranslate-edit-language" src="http://zzlatev.com/wp-content/blogs.dir/3/files/qtranslate-edit-language.jpg?1a5c7e" width="473" height="222" /><p class="wp-caption-text">qTranslate &#8211; Edit language screen</p></div>
<p>&nbsp;</p>
<p>The following piece of code will set filter to the <em>qtranslate_language</em> hook and kinda use it as an action rather than a filter. Tricky part here is that <em>qtranslate_language</em> is very early hook. It fires upon <em>plugins_loaded </em>action. This means theme&#8217;s <em>functions.php </em>is no good in this case. To be able to hook to it we need to place this code into a plugin.</p>
<p>While creating a plugin may be an overkill for a several lines of code, a <a href="http://codex.wordpress.org/Must_Use_Plugins" target="_blank">MU plugin</a> seems far more suitable for the purpose. It loads before any other regular plugin and guarantees the availability of every single one action and filter set in plugins.</p>
<ol>
<li>Go to your <strong>/wp-content/mu-plugins/</strong> directory. If it doesn&#8217;t exists on your install create it.</li>
<li>Create a <strong>qtranslate.mu.php </strong>file for example (may be any name) and place the code below into that file.</li>
</ol>
<pre class="prettyprint linenums">&lt;?php
function qtrans_translate_lang_names( $language ) {

 if ( is_admin() &amp;&amp; $_GET['page'] == 'qtranslate' )
 return $language;

 global $q_config;
 $q_config['language_name'] = array_map( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage', $q_config['language_name'] );

 return $language;
}
add_filter('qtranslate_language', 'qtrans_translate_lang_names' );</pre>
<p>Now your language names should be localized in every page even admin screens, except qTranslate Settings pages.</p>
<p>The post <a href="https://zzlatev.com/qtranslate-localize-language-names/">qTranslate &#8211; Localize language names</a> appeared first on <a href="https://zzlatev.com">Zlatko Zlatev</a>.</p>]]></content:encoded>
			<wfw:commentRss>https://zzlatev.com/qtranslate-localize-language-names/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Support JetPack Comments in WordPress themes.</title>
		<link>https://zzlatev.com/wordpress-jetpack-comments-in-themes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wordpress-jetpack-comments-in-themes</link>
		<comments>https://zzlatev.com/wordpress-jetpack-comments-in-themes/#comments</comments>
		<pubDate>Fri, 02 Nov 2012 13:08:25 +0000</pubDate>
		<dc:creator><![CDATA[zlatev]]></dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[jetpack]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://zzlatev.com/?p=95</guid>
		<description><![CDATA[<p>Comments&#8230; yeah, I leave them for last too. I hardly can recall a dicent WP theme having nicely working (and looking) comment template. If that&#8217;s the case for you would probably like to try the Jetpack Comments extension as a module of &#8230; <a href="https://zzlatev.com/wordpress-jetpack-comments-in-themes/">Continued</a></p><p>The post <a href="https://zzlatev.com/wordpress-jetpack-comments-in-themes/">Support JetPack Comments in WordPress themes.</a> appeared first on <a href="https://zzlatev.com">Zlatko Zlatev</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Comments&#8230; yeah, I leave them for last too.</p>
<p>I hardly can recall a dicent WP theme having nicely working (and looking) comment template. If that&#8217;s the case for you would probably like to try the Jetpack Comments extension as a module of the Jetpack plugin for WordPress. Automattic is providing some of the WordPress.com awesomeness as a plugin for self-hosted installations.</p>
<p>To get to the point I will suggest a way to support JetPack Comments in themes. The important thing to know is this module depends exclusively on the <strong><a title="comment_form() Function @ codex.wordpress.org" href="http://codex.wordpress.org/Function_Reference/comment_form" target="_blank">comment_form</a> </strong>template tag. If your <em>comments.php</em> is not using it, you won&#8217;t get Jetpack Comments working.</p>
<h3>How to get it working without completely annihilating your comments template.</h3>
<h3></h3>
<pre class="prettyprint linenums">&lt;!-- just after walking existing comments --&gt;
&lt;div id="respond"&gt;
&lt;?php if ( did_action( 'jetpack_comments_loaded' ) ) : ?&gt;
&lt;?php comment_form(); ?&gt;
&lt;?php else: ?&gt;
&lt;!-- here comes default theme's comment form --&gt;
&lt;?php endif; ?&gt;
&lt;/div&gt;</pre>
<p>
That&#8217;s how i enabled Jetpack Comment here using the <a href="http://www.rootstheme.com/">Roots Theme</a> where <em>comment_form</em> wasn&#8217;t used also. Now if I need to disable Jetpack for some reason Roots&#8217; default comment form will kick in.</p>
<p>The post <a href="https://zzlatev.com/wordpress-jetpack-comments-in-themes/">Support JetPack Comments in WordPress themes.</a> appeared first on <a href="https://zzlatev.com">Zlatko Zlatev</a>.</p>]]></content:encoded>
			<wfw:commentRss>https://zzlatev.com/wordpress-jetpack-comments-in-themes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>bbPress 2.x &#8211; Cure 404 header in Users Profiles</title>
		<link>https://zzlatev.com/bbpress-404-header-in-users-profiles/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=bbpress-404-header-in-users-profiles</link>
		<comments>https://zzlatev.com/bbpress-404-header-in-users-profiles/#comments</comments>
		<pubDate>Sun, 23 Sep 2012 14:30:43 +0000</pubDate>
		<dc:creator><![CDATA[zlatev]]></dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[bbpress]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[bugfix]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://zzlatev.com/?p=78</guid>
		<description><![CDATA[<p>When bbPress is parsing a user query it sets the author_name query var. // Set author_name as current user's nicename to get correct posts $posts_query-&#62;set( 'author_name', $user-&#62;user_nicename ); This could be useful if you want to show user&#8217;s blog posts &#8230; <a href="https://zzlatev.com/bbpress-404-header-in-users-profiles/">Continued</a></p><p>The post <a href="https://zzlatev.com/bbpress-404-header-in-users-profiles/">bbPress 2.x &#8211; Cure 404 header in Users Profiles</a> appeared first on <a href="https://zzlatev.com">Zlatko Zlatev</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>When bbPress is parsing a user query it sets the author_name query var.</p>
<pre class="prettyprint linenums">    // Set author_name as current user's nicename to get correct posts
    $posts_query-&gt;set( 'author_name', $user-&gt;user_nicename );</pre>
<p>This could be useful if you want to show user&#8217;s blog posts as the query_var above tells WordPress to do exactly that. If WordPress fails to return posts $wp-&gt;handle_404(); comes along and sets the 404 despite the fact bbPress is trying to prevent it earlier on parse_query action.</p>
<p>I rolled my own fix.</p>
<pre class="prettyprint linenums">function bbp_fix_users_404_headers() {
    if ( ! function_exists( 'bbpress' ) ) return;       
    $bbp = bbpress();

    if ( !empty( $bbp-&gt;displayed_user ) &amp;&amp; is_404() ) {
        global $wp_query;
        $wp_query-&gt;is_404 = false;
        status_header( 200 );
    }
}
add_action( 'wp', 'bbp_fix_users_404_headers' );</pre>
<p>Personally i put these in MU file as i often need to set hooks before plugins&#8217; run-time. For this one theme&#8217;s functions.php is OK too.</p>
<p>The post <a href="https://zzlatev.com/bbpress-404-header-in-users-profiles/">bbPress 2.x &#8211; Cure 404 header in Users Profiles</a> appeared first on <a href="https://zzlatev.com">Zlatko Zlatev</a>.</p>]]></content:encoded>
			<wfw:commentRss>https://zzlatev.com/bbpress-404-header-in-users-profiles/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Limit file size and image dimensions in Gravity Forms upload fields</title>
		<link>https://zzlatev.com/gravity-forms-upload-limits/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=gravity-forms-upload-limits</link>
		<comments>https://zzlatev.com/gravity-forms-upload-limits/#comments</comments>
		<pubDate>Fri, 13 Apr 2012 18:08:48 +0000</pubDate>
		<dc:creator><![CDATA[zlatev]]></dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[file size]]></category>
		<category><![CDATA[file upload]]></category>
		<category><![CDATA[gravity forms]]></category>
		<category><![CDATA[gravityforms]]></category>
		<category><![CDATA[image dimensions]]></category>
		<category><![CDATA[image upload]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://zzlatev.com/?p=41</guid>
		<description><![CDATA[<p>Update 31.05.2013 I’ve put together a plugin to do what the snippet above used to do. I believe it’s far more bug free than its predecessor so please use it instead. Plugin should work with Gravity Forms 1.6.2+ so no guaranties &#8230; <a href="https://zzlatev.com/gravity-forms-upload-limits/">Continued</a></p><p>The post <a href="https://zzlatev.com/gravity-forms-upload-limits/">Limit file size and image dimensions in Gravity Forms upload fields</a> appeared first on <a href="https://zzlatev.com">Zlatko Zlatev</a>.</p>]]></description>
				<content:encoded><![CDATA[<h3>Update 31.05.2013</h3>
<p>I’ve put together a <a href="http://wordpress.org/plugins/gravity-forms-upload-rules/" target="_blank">plugin </a>to do what the snippet above used to do. I believe it’s far more bug free than its predecessor so please use it instead. Plugin should work with Gravity Forms 1.6.2+ so no guaranties for earlier versions!</p>
<p><img class="alignnone size-full wp-image-166" alt="gravity-forms-upload-rules-01" src="http://zzlatev.com/wp-content/blogs.dir/3/files/gravity-forms-upload-rules-01.jpg?1a5c7e" width="500" height="608" /></p>
<p><a name="donate"></a></p>
<p><img class="alignnone size-full wp-image-165" alt="gravity-forms-upload-rules-02" src="http://zzlatev.com/wp-content/blogs.dir/3/files/gravity-forms-upload-rules-02.jpg?1a5c7e" width="500" height="607" /></p>
<p><a href="http://wordpress.org/plugins/gravity-forms-upload-rules/" target="_blank">Download Gravity Forms Upload Rules</a></p>
<!-- Begin PayPal Donations by http://johansteen.se/ -->
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <div class="paypal-donations">
        <input type="hidden" name="cmd" value="_donations" />
        <input type="hidden" name="business" value="zlatko.zlatev@gmail.com" />
<input type="hidden" name="item_name" value="Gravity Forms Upload Rules" /><input type="hidden" name="rm" value="0" /><input type="hidden" name="currency_code" value="USD" /><input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" name="submit" alt="PayPal - The safer, easier way to pay online." /><img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />    </div>
</form>
<!-- End PayPal Donations -->

<h3>Original Post</h3>
<p>There are already a couple of projects that needed file upload functionality (image upload to be specific) so we needed a solution for file size and image dimensions limitations. To be honest I was quite surprised when I found out GravityForms isn&#8217;t offering such functionality by far. It&#8217;s offering great hooks though.</p>
<pre class="prettyprint linenums">function public_news_image_validation( $valid_obj ) {
  if ( empty( $_FILES ) ) return $valid_obj;
  $form_id = $valid_obj['form']['id'];
  $formFields = &amp;$valid_obj['form']['fields'];
  $page_number = GFFormDisplay::get_source_page( $form_id );
  foreach ( $formFields as &amp;$field ) {
  if ( $page_number &gt; 0 &amp;&amp; $field["pageNumber"] != $page_number ) continue; //paged form scenario - only validate fields that are on current page
    if ( in_array( 
        ( $field_type = RGFormsModel::get_input_type($field) ), 
        array( 'fileupload', 'post_image' ) 
      ) 
    ) {

      $field_id = $field['id'];
      $input_name = 'input_' . $field_id;

      if ( $field['failed_validation'] ) return $valid_obj;
      $file_info = RGFormsModel::get_temp_filename( $form_id, $input_name );
      $temp_filepath = RGFormsModel::get_upload_path($form_id) . "/tmp/" . $file_info["temp_filename"];

      if ( file_exists( $temp_filepath ) ) {
        $bytes = filesize( $temp_filepath );
        $dims = @getimagesize( $temp_filepath );
      }
      elseif ( isset( $_FILES[$input_name] ) &amp;&amp; !empty( $_FILES[$input_name] ) )  {
        $bytes = $_FILES[$input_name]['size'];
        $dims = @getimagesize( $_FILES[$input_name]['tmp_name'] );
      } 
      else return $valid_obj;
      $max_size = 1024*300; // 300kb
      if ( $bytes &gt; $max_size ) {

        unset( RGFormsModel::$uploaded_files[$form_id][$input_name] );
        unset( $_FILES[$input_name] );
        $field['failed_validation'] = true;
        $field['validation_message'] = sprintf( __( 'File upload size (%s) exceeded', 'gravityforms' ), $max_size/1024 . 'kb' );
        $valid_obj['is_valid'] = false;
        return $valid_obj;
      }
      if ( ! empty( $dims ) &amp;&amp; is_array( $dims ) ) {
        list( $up_width, $up_height ) = $dims;
        if ( min( $up_width, $up_height ) &lt; 300 ) { //smallest image size should be at least 300px

          unset( RGFormsModel::$uploaded_files[$form_id][$input_name] );
          unset( $_FILES[$input_name] );
          $field['failed_validation'] = true;
          $field['validation_message'] = sprintf( __( 'Image should be at least %s', 'gravityforms' ), '300x300 (px)' );
          $valid_obj['is_valid'] = false;
          //return $valid_obj;
        }
      }
    }
  }
  return $valid_obj;
}

add_action( 'gform_validation_3', 'public_news_image_validation' );</pre>
<p><strong>EDIT: Added paged forms compatibility.</strong></p>
<p>The post <a href="https://zzlatev.com/gravity-forms-upload-limits/">Limit file size and image dimensions in Gravity Forms upload fields</a> appeared first on <a href="https://zzlatev.com">Zlatko Zlatev</a>.</p>]]></content:encoded>
			<wfw:commentRss>https://zzlatev.com/gravity-forms-upload-limits/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Get rid of &#8220;My Sites&#8221; admin bar menu in MultiSite</title>
		<link>https://zzlatev.com/wp-multisite-admin-bar/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wp-multisite-admin-bar</link>
		<comments>https://zzlatev.com/wp-multisite-admin-bar/#comments</comments>
		<pubDate>Sat, 03 Mar 2012 08:39:15 +0000</pubDate>
		<dc:creator><![CDATA[zlatev]]></dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wpms]]></category>

		<guid isPermaLink="false">http://zzlatev.com/?p=16</guid>
		<description><![CDATA[<p>By default WordPress (3.3.1) performs a check when generates the admin bar object if current user have sites. The &#8220;My Site&#8221; menu is displayed if it does. That&#8217;s okey for multisites&#8217; general purpose but my point is that current user don&#8217;t &#8230; <a href="https://zzlatev.com/wp-multisite-admin-bar/">Continued</a></p><p>The post <a href="https://zzlatev.com/wp-multisite-admin-bar/">Get rid of &#8220;My Sites&#8221; admin bar menu in MultiSite</a> appeared first on <a href="https://zzlatev.com">Zlatko Zlatev</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>By default WordPress (3.3.1) performs a check when generates the admin bar object if <em>current user</em> have sites. The &#8220;My Site&#8221; menu is displayed if it does. That&#8217;s okey for multisites&#8217; general purpose but my point is that <em>current user</em> don&#8217;t need that extra menu if it owns just one site. Hopefully it is quite easy to hook core and alter that behaviour using the <strong>&#8216;wp_before_admin_bar_render&#8217; </strong>action. Here&#8217;s my solution.</p>
<pre class="prettyprint linenums">class My_Network {

	public static function clean_admin_bar() {
		global $wp_admin_bar;

		if ( count( $wp_admin_bar-&gt;user-&gt;blogs ) &gt; 1 || is_super_admin() ) return;

		$wp_admin_bar-&gt;remove_menu( 'my-sites' );
	}
}
add_action( 'wp_before_admin_bar_render', array( 'My_Network', 'clean_admin_bar' ) );</pre>
<p>We basicly check wheather user is <em>super admin </em>or is registered to more than one site. If it&#8217;s not we wipe the whole &#8220;My Sites&#8221; stuff leaving the admin bar as it&#8217;s in any regular WordPress installation.</p>
<p>The post <a href="https://zzlatev.com/wp-multisite-admin-bar/">Get rid of &#8220;My Sites&#8221; admin bar menu in MultiSite</a> appeared first on <a href="https://zzlatev.com">Zlatko Zlatev</a>.</p>]]></content:encoded>
			<wfw:commentRss>https://zzlatev.com/wp-multisite-admin-bar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Database Caching 52/66 queries in 0.012 seconds using disk
Object Caching 1160/1162 objects using disk

 Served from: zzlatev.com @ 2026-10-09 01:28:06 by W3 Total Cache -->