WordPress RSS Feed - ’ instead of the apostrophe (') - wordpress

In my Wordpress RSS Feed : http://hellobiz.fr/feed/
Apostrophes are replaced by "’" in
I need to use the true character: '
Do you have solution please ?
Thank you !

I actually fixed the problem, although it might not be the most correct/elegant solution.
In wp-includes/feed-functions.php
function get_the_title_rss() {
$title = get_the_title();
// $title = apply_filters('the_title', $title);
$title = apply_filters('the_title_rss', $title);
return $title;
Commenting out that line changed the offending "right single quotation mark" (aka ’) into the straight up and down apostrophe that apparently magpie can handle no problem.
Before I started digging in the code I was playing with the encoding, and was in for a HECK of a surprise when I changed it to UTF-16.

Related

PHP's explode() is not working on hyphen-minus -

I am try to use explode() on a string fetched from a database but it didn't work. I have tried explode('-',$string) but it's still not working.
Here is my string which I want to explode:
Expression of Interest – Join our Paint Team – North
If you look closely the hyphen from the string is not the same as the hyphen you use as your argument for the explode.
The hyphen in the string is the following – while the hyphen you pass as the argument for explode() is -. As you can see they don't match (the one in the string is longer than the one you try to compare it with). Because the characters don't match, the explode function is returning the whole string.
<?php
$string = "Expression of Interest – Join our Paint Team – North";
$strings = explode('–', $string);
var_dump($strings);
I have copied the hyphen from the text and used that as an argument for explode() and it works fine.
Might be $string is not string, you can use strval( $string ) to convert it to string i.e. explode('–', strval ( $string ) );
$eString = explode('–', strval ( $string ) );
// vardump($eString) - Now it is an array.
// echo $eString[0];
I have fix the issue by trying this
$post_job_title = htmlentities(get_the_title($posts));
$post_job_title = explode (" – ", $post_job_title);

How to use Wordpress Trim Words Function

i want to trim a single word i.e, Monday in wordpress, how can i trim this word?
$my_title = get_the_title();
echo wp_trim_words($my_title, 1, null );
the title coming from database Monday So i want to trim Monday to Mo or M.
wp_trim_words() will works easily without any problems. You can use it with below sample code:
echo wp_trim_words( get_the_title(), 1, '' );
But do note that it will trim the first character in whole post/page title, not regconize the date in your example.
I don't know that wp_trim_words() works that way. I'd recommend just using regex and preg_match():
$my_title = get_the_title();
to get the first character:
$regex = '/(.?)/';
or to get the first two characters, change the variable to this:
$regex = '/(.?)./';
Then get the matches for the regex pattern:
preg_match($regex, $my_title, $matches);
Echo out the first one:
echo $matches[0];

WooCommerce - Translate a word on the Checkout page

I'm trying to translate a word on the WooCommerce checkout page.
My website is in the Dutch language, but they translated it poorly, so I want to use a different word.
What needs to be translated
It concerns the following line:
"Totaal €469,38 (Inclusief €79,38 Belasting)"
In English this says:
"Total €469,38 (Includes €79,38 tax)"
It's the line that sums up the total amount of the order. And I want to translate the word 'Belasting' to 'BTW'.
What I've tried
Checked out settings in WooCommerce
Installed the plugin Loco translator
Searched for the word with FTP (Adobe Dreamweaver)
As I couldn't find the word 'Belasting' anywhere, I did find the php-file with the element of the line.
This I found in the PHP-document wc-cart-functions.php:
if ( ! empty( $tax_string_array ) ) {
$value .= '<small class="includes_tax">' . sprintf( __( '(Includes %s)', 'woocommerce' ), implode( ', ', $tax_string_array ) ) . '</small>';
}
And this is how the HTML part looks like:
<small class="includes_tax">
(inclusief
<span class="amount">€79,38</span>
Belasting)
</small>
My Question
I presume it does print the word 'Belasting' with the '%s' variable. However I am unable to find the content for that variable anywhere.
So can anybody help me out by finding how to translate this word?
Thanks for reading and I'd appreciate the help.
You can try using the gettext filter
Example
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Related Products' :
$translated_text = __( 'Check out these related products', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );
WooCommerce uses gettext for translations, as described here there are several methods of updating the translation, the easies of which is editing the file in woocommerce/i18n/languages/
The "Includes" part is translate-supported. i.e. you just need to add it to your translation file:
The translation file is in my case (danish): "../wp-content/languages/plugins/woocommerce-da_DK.po"
Open the file in your texteditor, e.g. Notepad++ and add these lines:
#: includes/class-wc-order.php:40 includes/wc-cart-functions.php:246
msgid "(Includes %s)"
msgstr "(Inkluderer %s)"
Now you need to compile the PO file to an MO file and you can use Poedit.
Just open the PO file and save it, it will create a new MO file that you can upload and replace the current MO file (path: "../wp-content/languages/plugins/")
So fare so good!
In regards to the "Tax" part. This is controlled in the admin module:

Query Posts issue in wordpress

I am a little unsure how to do a WP_Query to search a meta value of my posts. The meta data includes a persons height. So valid entries would be 5'9" or 4'11" and I need to do a Compare-Between.
To make it a bit clearer: I have a filter page. So the user can select the height between 4'0" - 5'9 or 5'9" - 5'11"
The problem is I have the ' and " symbols. I can remove these. But then it will be searching between 59 and 511 which is not going to work.
Anyone know of a work around?
Save the values in inches.
You could then set up a WP_Query or a $wpdb query to fetch your results.
Whenever you are displaying the values on the front end, you convert them back to feet and inches.
update:
function convert_to_feet( $input){
$feet = (int) ($input/12);
$inches = $input%12;
return $feet . "'" . $inches . '"';
}
echo convert_to_feet(71);

Problem with quotes in "onclick" function

I'm trying to concatenate PHP variables into an "onclick" function.
Here is the line I'm having trouble with (look for the "onclick" part):
$imagecontent = '<div class="imagensfw" id="image'.$id.'" style="width:'.round($wd).'px;height:'.round($ht).'px;" onclick="viewimage(image'.$id.','.round($wd).','.$url.');"><p>Image</div>';
I'm particularly having trouble with concatenating the $url variable. I'd want to put it between quotes, but if I do so, the "onclick" function becomes all messed up (when the code is displayed in the browser).
I think that putting the URL address ($url variable as a parameter in the onclick) between quotes will fix the error its shooting:
Error : missing ) after argument list
Here's my short Javascript function if you're interested:
function viewimage(id,width,url){
var image = document.getElementById(id);
image.innerHTML = '<img src="'+url+'" width="'+width+'" alt="Image" />';
}
Here's what I tried but didn't work (i.e. messed up the code):
onclick="viewimage(image'.$id.','.round($wd).', **"** '.$url.' **"** );"
(Noticed the double quotes added between the $url variable).
Thank you for your time.
Have you tried using variable parsing? From the link's example:
$beer = 'Heineken';
echo "He drank some ${beer}s";
This should simplify the construction of your string.
Silly me, I just noticed an error on my part. I thought we could use double quotes in an "onclick" function. Turns out not, we have to use single quotes ( ' ). It fixed my problem. Thanks!

Resources