GithubHelp home page GithubHelp logo

mundschenk-at / wp-typography Goto Github PK

View Code? Open in Web Editor NEW
21.0 4.0 3.0 9.28 MB

Improve your WordPress micro typography.

Home Page: https://code.mundschenk.at/wp-typography/

License: Other

PHP 92.93% JavaScript 6.54% CSS 0.18% SCSS 0.36%
wordpress hyphenation smartquotes css-hooks php

wp-typography's Introduction

wp-Typography

Build Status Latest Stable Version Quality Gate Status Coverage License

Improve your web typography with:

  • Hyphenation — over 70 languages supported

  • Space control, including:

    • widow protection
    • gluing values to units
    • forced internal wrapping of long URLs & email addresses
  • Intelligent character replacement, including smart handling of:

    • quote marks
    • dashes
    • ellipses
    • trademarks, copyright & service marks
    • math symbols
    • fractions
    • ordinal suffixes
  • CSS hooks for styling:

    • ampersands,
    • uppercase words,
    • numbers,
    • initial quotes & guillemets.

wp‐Typography has the following requirements:

  • The host server must run PHP 7.4.0 or later,
  • your installation of PHP must include the following PHP extensions (most do):
  • text must be encoded in UTF‐8.

wp-Typography can easily be ported to any other PHP-based content management system. The Composer package mundschenk-at/php-typography assembles all typographic functionality (without any WordPress-specific code) in an object oriented format that is ready use.

View the wp-Typography homepage for more information.

Frequently Asked Questions

FAQs are maintained at the wp-Typography website.

Three questions come up so frequently, we will republish their answers here:

Will this plu­gin slow my page load­ing times?

Maybe. For best performance, use a persistent object cache plugin like WP Redis.

This plugin breaks post title links. What gives?

More likely than not, your WordPress theme is using an improper function to set the title attribute of your heading's link. It is probably using the the_title() function, which delivers the post title after filtering. It should be using the_title_attribute() which delivers the post title before filtering. Change out this function throughout your theme when it is used inside of an HTML tag, and the problem should go away.

If you are uncomfortable editing your theme's code, you may alternatively go to the wp-Typography settings page in your admin panel and add h1 and h2 to the "Do not process the content of these HTML elements:" field. This will disable typographic processing within improperly designed page title links and page titles.

What are the privacy implications of using the plugin?

wp-Typography does not store, transmit or otherwise process personal data as such. It does cache the content of the site's posts. If necessary, you can clear this cache from the plugin's settings page.

Changelog

A detailed release changelog can be found on the wp-Typography website.

wp-typography's People

Contributors

jeffreydking avatar melindrea avatar mundschenk-at avatar sarukuku avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

wp-typography's Issues

Transform registration marks and 501(c)(3)

Copied from https://wordpress.org/support/topic/bug-transform-registration-marks-and-501c3?replies=2#post-8360072

When having the Transform registration marks option checked, the (c) portion of 501(c)(3) is converted to a copyright symbol, of course. But technically, that's not supposed to be a copyright symbol (and means something else.)

The Transform registration marks option should have an exception to when it applies, when the (c) is directly preceded by 501. (Since there are a bunch of types of 501(c) organizations.)

problems with db-use

i was urged to disable the plugin, because it causes a huge writing load in the database. it seems, that the plugin read/writes the typo_transient_keys with such a frequency, that the server didn't work anymore ...
my hoster-admin suggested, that there may be no/a faulty clean-up-mechanism for these sql-statements.

Cache results via Transient API

The plugin should cache its results via the WordPress Transient API. Since we probably need to integrate two MD5 hashes, this will have to wait until after WordPress 4.4 is released because of Trac #13310.

Ampersand wrapping in HTML title element

Hi

I'm using the stock Twenty Sixteen theme and on the single post page for posts with an ampersand in the title, the ampersand is being wrapped with the <span class="amp"> in the content of the HTML title element.

I have checked and title is one of the disallowed tags so I'm not sure why the HTML title is being processed? I read the FAQ about title links but as I'm using the stock theme and this is about the HTML title rather than anything in the page content, I'm not sure what to do.

Thanks

French punctuation: insert `&nbsp;` for literal `«` and `»`

Use case: input text was correctly typed as « bonjour » or copied from a word processor that converts straight quotes to « and » for French documents.

Provided the following input:

Les « courants de bord ouest » du Pacifique ?
Eh bien : ils sont "fabuleux".

I'm getting this result (with hyphenation turned off):

Les « courants de bord ouest » du Pacifique&nbsp;?
Eh bien&nbsp;: ils sont «&nbsp;fabuleux&nbsp;».

Ideally, I would like the set_french_punctuation_spacing method or other relevant setting (not sure for wp-Typography, since I'm using https://github.com/fabianmichael/kirby-typography and its settings are named and managed differently) to deal with « » quotes in the same way it deals with ?!:;, i.e. to transform «\s+ to «&nbsp; and \s+» to &nbsp;».

Since it's a setting for French, there should be no doubt whether » is a closing or opening quote (it's a closing quote).

Would that be doable in PHP_Typography?

PS: issue ported from fabianmichael/kirby-typography#8

Workaround for safari hyphenation bug causes wrong rendering in Chrome on initial page loads after link clicks, disappears after redraw

  • wp-typography 3.1.3
  • Chromium 48.0 and Chrome for Android 48.0

The "Add workaround for Safari hyphenation bug" is causing trouble in Chrome, both for desktop and Android. See the following screenshot:

screenshot from 2016-02-20 16 24 12

The words apparently set in a "lighter" font are the hyphenated words (where &shy; has been added by wp-typography), and they're shown in the correct font (Raleway). I'm unsure which font the rest of the words are in. It's not the default theme font (Merriweather). It might be the default font in the browser.

Here's how it's supposed to look:

screenshot from 2016-02-20 16 27 32

I have turned off the "Safari workaround" setting on the live website now, but I can turn it on again if you want to do live debugging.

To reproduce this bug, I went to http://www.relativisticramblings.com (my blog). The bug does not appear on the front page initially. If I clicked on a post the error appeared on the post page. Furthermore, if I clicked the logo to get back to the front page, the error was visible there now.

Any kind of redraw seems to get rid of the error. This includes reloading a problematic page, entering responsive view in the Chrome developer tools, changing any CSS rules in the developer tools, or hitting a break point while resizing the window.

In other words, the error only seems to appear when you land on a page by clicking on a link.

The error doesn't appear in Firefox. I haven't tested other browsers.

Correct typographic spaces for French (a few tweaks needed)

Although it’s hard to find precise recommendations for correct spacing around punctuation in French. After reading a lot about “orthotypographie”, I have gathered that the exact rules are:

  1. Full no-break space before the colon (:). (Technically this space should not vary when using text-align:justify, but that’s a browser limitation that wp-typography can do nothing about.)
  2. Narrow no-break space before »;?!.
  3. Narrow no-break space after «.

The meaning of those rules is that a little bit of space around certain punctuation characters is considered more readable (I’ll note that it’s also used by some English language publishers for ;?!, though they tend to prefer thin spaces over the narrow space), and that space should not be too big (not a full space), except for the colon because instead of closing a proposition (like the other characters do) it creates a bridge from one proposition to the next (hence the full space). That’s the rationale I’ve read anyway. :)

Other punctuation signs don’t have extra space, or use regular breaking spaces, and don't concern wp-typography.

Also some publishers, typographers, graphic designers etc. may tweak these rules a bit or a lot, which is a given in any publishing and graphic design environment. For instance I know a typographer who uses «» with hair spaces instead of narrow spaces, and in graphic design many use “English” quotes (“”) for posters or book covers, though novels tend to keep the «» with narrow non-breaking spaces.

Changes that would be needed in php-typography to enable those rules:

Use PHP_Typography::chr['noBreakNarrowSpace'] for doubleGuillemetsFrench quote style:

https://github.com/mundschenk-at/wp-typography/blob/master/php-typography/class-php-typography.php#L301

            'doubleGuillemetsFrench'   => array( 'open'  => $this->chr['guillemetOpen'].$this->chr['noBreakNarrowSpace'],
                                                 'close' => $this->chr['noBreakNarrowSpace'].$this->chr['guillemetClose'] ),

Separate the spacing for the colon (:) from PHP_Typography::regex['frenchPunctuationSpacing']:

https://github.com/mundschenk-at/wp-typography/blob/master/php-typography/class-php-typography.php#L1091

        // french punctuation spacing
        $this->regex['frenchPunctuationSpacing']             = '/(\w+)(\s?)([?!:»])(\s|\Z)/u';
        $this->regex['frenchPunctuationSpacingColon']        = '/(\w+)(\s?)(:)(\s|\Z)/u';

and https://github.com/mundschenk-at/wp-typography/blob/master/php-typography/class-php-typography.php#L2700

        $textnode->data = preg_replace( $this->regex['frenchPunctuationSpacing'],             '$1' . $this->chr['noBreakNarrowSpace'] . '$3$4', $textnode->data );
        $textnode->data = preg_replace( $this->regex['frenchPunctuationSpacingColon'],        '$1' . $this->chr['noBreakSpace'] . '$3$4', $textnode->data );

With those changes, if users activate the narrow no-break spaces, they should get perfect French punctuation spacing with supporting browsers and fonts.

PS: the modified code extracts are for illustrating how the rules could be implemented. I haven’t actually tested them or ran this code. I could perhaps make a PR but that would be in 10 days at best.

Pretty logo

wp-Typography would benefit from a nice logo (and maybe a banner as well).

"Duplicate ID" warnings with certain versions of libXML2

Hi,

Wp-typography is conflicting with YITH Woocommerce Social Login on my site. I get this error whenever I get to the social login screen:

Warning: DOMElement::setIdAttribute(): ID wpnonce already defined in /home/*****/public_html/_*/wp-content/plugins/wp-typography/vendor/Masterminds/HTML5/Parser/DOMTreeBuilder.php on line 424

By the way, wp-typography is a great plugin. I hope you can solve this issue.

Extreme DB usage due to this plugin

We just updated WP from 4.4.0 to 4.4.1 and this plugin to version 3.1.1 and our DB server went nuts immediately.
It created nearly a million _transient_typo (_timout_typo) entries in the DB.

This shot our DB server to 100% CPU and degrades total performance a lot.

I removed the plugin now and deleted all its _transient DB entries -> freed 2.5 GB diskspace!!

The identifiers you use for the name seem very "random" or at least a hash of something bound to time or so. Please check that.

Add a way for theme developers to call WP_Typography::process

Due to lazy initialization, plugin and theme developers can't easily create their own WP_Typography object. For to performance reasons, they should not, either. wp-Typography has to provide a clean way to call WP_Typography::process() on arbitrary strings.

Hyphens in <title>

Some Browsers don't deal well with hyphens in the title-element. I think wp-typography tries to address this in /includes/class-wp-typography.php in the section commented with

// extra care needs to be taken with the <title> tag

by adding the filter process_title_parts() to document_title_parts. This doesn't have any effect on the title-element, because wp_title() uses wp_title_parts() and not document_title_parts(). Changing

add_filter( 'document_title_parts', array( $this, 'process_title_parts' ), $priority );

to

add_filter( 'wp_title_parts', array( $this, 'process_title_parts' ), $priority );

fixes the issue here.

Grüße, Matthias

Multilingual support

wp-Typography should honor the current content language when running on a multilingual installation.

Advanced Filter Configuration option

Sometimes there are issues with other plugins that would make it beneficial to be able to switch off certain seldom used content filter (e.g. on widget_text) to prevent double parsing by WP_Typography::process() and the resulting side effects.

Remove obsolete references to IE6

  • %1$s Force thin spaces between em &amp; en dashes and adjoining words. This will display poorly in IE6 with some fonts (like Tahoma) and in rare instances in WebKit browsers (Safari and Chrome).
  • %1$s Remove zero-width spaces from IE6.
  • IE6 displays mangles zero-width spaces with some fonts like Tahoma (uses JavaScript).

Language-specific default settings

Default settings/options should depend on the site language. Existing installs will not be affected unless the "Restore Defaults" button is used.

ACF support

Add support for Advanced Custom Fields (via acf_the_content).

Fatal error after unserialize

In some hosting environments, there PHP_Typography gets unserialized before the class definition is loaded:

Fa­tal er­ror: WP_Typography::get_php_typo(): The script tried to ex­e­cute a method or ac­cess a prop­erty of an in­com­plete ob­ject. Please en­sure that the class de­f­i­n­i­tion “PHP_Typography\PHP_Typography” of the ob­ject you are try­ing to op­er­ate on was loaded _​before_​un­se­ri­al­ize() gets called or provide a _​_​autoload() func­tion to load the class de­f­i­n­i­tion in /home/content/p3pnexwpnas09_data02/11/3172511/html/wp-content/plugins/wp-typography/includes/class-wp-typography.php on line 411

It looks like this might be the same problem as http://pyebrook.com/diagnosing-a-wp-ecommerce-error-on-godaddy-hosting-with-php-apc/ and https://wordpress.org/support/topic/fatal-error-pll_model_languages_list (i.e. a bug in APC Object Cache used by GoDaddy).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.