Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unyson-Framework that supports rtl #1

Closed
wants to merge 10 commits into from
Closed

Unyson-Framework that supports rtl #1

wants to merge 10 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Oct 8, 2014

for the past 20 days i've been working on a version for this great framework to make it supports rtl
this version was tested on an arabic version of WordPress.
with every line file and line of code i add i make a commit

@ghost
Copy link
Author

ghost commented Oct 9, 2014

Thank you very much for contribution.


Storing the original and rtl styles in separate files is cleaner, but harder to maintain. Every time you update the original style, you will have to remember to search in the rtl file for that style.

We find out that on the Arabic version, the WordPress adds the rtl class to the body

class

and we thought it will be more clear and easy to have the rtl styles right next to the original styles, and we did that

.hello {
    ...
}
body.rtl .hello {
    ...
}

That way, we moved manually all your changes next to their original styles in the same files without creating the *-rtl.css files.

Those changes will be included in the next release.


Screenshots

@ghost ghost closed this Oct 9, 2014
@ghost
Copy link
Author

ghost commented Oct 16, 2014

This changes are included in the 1.4.0 release

@georgestephanis
Copy link

There's actually a much better way to handle RTL styles -- that core actually helps you with.

For an example of how we did it in Jetpack: https://github.com/Automattic/jetpack/blob/6cfa4e59e815420f0cc147df64be66c91d911e26/_inc/lib/admin-pages/class.jetpack-admin-page.php#L89-L98

but here's a summation with a rather verbose explanation:

/**
 * If you're supplying a pre-minified version of the stylesheet, you'll
 * need this, and to add the `suffix` data, so that core knows to
 * replace `example-min.css` with `example-rtl-min.css` -- handling
 * the suffix properly.
 */
$min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
/**
 * The normal registration. You're familiar with this already.
 */
wp_register_style( 'example', plugins_url( "css/example{$min}.css", __FILE__ ), array(), '1.0' );
/**
 * I set the value to 'replace', so it will replace the normal css file if rtl,
 * but it could also be 'addon' for a css file that just gets enqueued as
 * well, rather than replacing the normal one.
 *
 * @see https://github.com/WordPress/WordPress/blob/809baf442b/wp-includes/class.wp-styles.php#L88-L104
 */
wp_style_add_data( 'example', 'rtl', 'replace' );
/**
 * Finally, if we are replacing the existing file, and there's some sort of
 * suffix like `-min` as mentioned earlier, we need to let core know about
 * it, so that it can keep that suffix after the added `-rtl` that it's adding to
 * the path.
 */
wp_style_add_data( 'example', 'suffix', $min );

/**
 * Then we just enqueue it as we would normally!  If it's going to always
 * be enqueued regardless, we could just call `wp_enqueue_style()` rather
 * than `wp_register_style()` above.
 */
wp_enqueue_style( 'example' );

@ghost ghost mentioned this pull request Mar 10, 2016
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants