I am getting comments from wp_comments table but when display it on browser it does not show emoticons instead showing :) and :D though comment have some emoticons. I read Using Smilies and now I want to create custom function which replace :) with appropriate icon and so on.
But I have no idea how?
This page describes the use of Emoticons/Smileys as graphics:
http://codex.wordpress.org/Using_Smilies
Go to your Admin Panel
Select Settings -> Writing
Check the box for "Convert emoticons like :-) and :-P to graphics on display"
If you're looking for the wp-script that converts the emoticons look here:
httpdocs/wp-includes/formatting.php
~line: 1715
/**
* Convert one smiley code to the icon graphic file equivalent.
*
* Looks up one smiley code in the $wpsmiliestrans global array and returns an
* <img> string for that smiley.
*
* #global array $wpsmiliestrans
* #since 2.8.0
*
* #param string $smiley Smiley code to convert to image.
* #return string Image string for smiley.
*/
function translate_smiley($smiley) {
...
/**
* Convert text equivalent of smilies to images.
*
* Will only convert smilies if the option 'use_smilies' is true and the global
* used in the function isn't empty.
*
* #since 0.71
* #uses $wp_smiliessearch
*
* #param string $text Content to convert smilies from text.
* #return string Converted content with text smilies replaced with images.
*/
function convert_smilies($text) {
Related
Using Karate, according to Karate - is it possible to find element according to part of its parameter I have tried to do that using:
* def filter = function(x){ return x.attribute('placeholder').startsWith('Very') }
* def list = locateAll('input[placeholder]', filter)
But I have no idea how to use it for inserting the value. I have tried this:
* retry().input(list[0], '12312312311111')
and this:
* retry().input('list[0]', '12312312311111')
but neither worked.
Have you any idea what is wrong in syntax?
Thank you.
Whatever locate returns is an Element object. So you can call methods on it. Please read the documentation: https://github.com/intuit/karate/tree/master/karate-core#locate
So this should work:
* list[0].input('12312312311111')
* list[0].retry().input('12312312311111')
I am currently stuck on a probably very simple question.
How do I validate my DateIntervalType to be != 0 - meaning atleast something has been selected.
And how do I set a minimum/maximum: for example minimum interval of 1 day.
Background: I want to send an email every X years/months/days depending on the user select - an interval of 0 would mean permanent email sending, which I do not want.
Sadly I did not find anything helpful yet. Also tried integer assertations like #Assert\GratherThan etc. but that does not work.
Thanks in advance
Solution: Thanks to #Arleigh Hix for putting me on the right direction.
I solved my problem with following solution:
/**
* #Assert\Expression("this.checkInterval()")
*/
private $interval;
public function checkInterval() {
return $this->getTimestamp()->add($this->getInterval()) > $this->getTimestamp(); //getTimestamp() returns a DateTime
}
So basically just add the interval to any date and compare the new date to the initial date. With this way you can also get the difference in seconds and compare for min max values.
Better practise is probably to create a custom validator which will be my next step.
It looks you should be able to use an Expression constraint Maybe like this (I'm not sure about syntax for constructing the \DateInterval in the annotation)
/**
* #Assert\Expression(
* "value >= minimum",
* values = { "minimum": new \DateInterval('P1D') }
* )
*/
$dateIntervalField;
Alternatively, you should be able to set your minimum interval to an entity property and then compare value to that.
public function __construct()
{
$this->minInterval = new \DateInterval('P1D');
}
/**
* #Assert\GreaterThanOrEqual(
* value = this.minInterval
* )
*/
$dateIntervalField;
I want to use alnum type but without spaces, can i do something with that or i have to make my own type? I want to make username without spaces.
Like this here:
private $username;
/**
* #Assert\NotBlank()
* #Assert\Length(max=4096)
* #Assert\Type(type="alnum")
The most powerful validation to solve this kind of trouble is the Regex Constraint.
For your case (a very simple case) is enough to use (see Length)
/**
* #Assert\Length(max=4096, minMessage="...", maxMessage="...")
* #Assert\Regex(
* pattern = "/^[a-z0-9]+$/i",
* htmlPattern = "^[a-zA-Z0-9]+$",
* message="Your name must contain only letter or numbers"
* )
*/
It is possible to unify both validator here in only one validator constraint but keep in mind that you lose the ability to show the exact error message if you have multiple conditions (like length and forbidden chars)
/**
* #Assert\Regex(
* pattern = "/^[a-z0-9]{1,4096}$/i",
* htmlPattern = "^[a-zA-Z0-9]{1,4096}$",
* message="Your name must contain only letter or numbers and must have length between 1 and 4096"
* )
*/
Where {1,4096} is the min and max values for limits of length string.
The htmlPattern and message are optional.
this may be a weird question and English is not my first language so I'll try to word it as best as I can. Also, keep in mind that I'm very, very new to programming. I've looked for this question quite a bit and can't seem to find the answer, either because it doesn't exist, or much more likely because I don't know how to word it properly.
How do I replace the text being currently displayed (being printed) rather than add the text after (below) it.
Let me explain. I've created a simple program that executes automated mouse and keyboard actions using pyautogui. What I'm trying to do is not even really necessary for my program to function, but I'm trying to learn programming so I want to make my program just a little more fun to use. So instead of having different scripts for each automated actions or to simply ask a question and then input a number for each script, I tried to emulate sort of a user interface (again, I'm a total beginner at both Python and programming in general, so it's incredibly basic). What I've tried to do was create a simple menu where the options are displayed and the user can type the number associated with the script they want to execute.
The only issue is that I find the end result to not be visually interesting. When something happens, the new text or, eventually the new contextual menu, doesn't replace the current one. It just prints below the older one.
Here is what the menu looks like:
**************************************************************************
* *
* *
* *
* *
* What script would you like to execute? *
* *
* *
* 1. Option 1 *
* 2. Option 2 *
* 3. Option 3 *
* *
* * Type "quit" to shut down *
* *
* *
* *
* *
* *
**************************************************************************
Now let's imagine that Option 1 leads to another menu where you can choose Option 1.1, 1.2, etc. How do I make the new menu replace the current one rather than just print next to it?
Here is the part of the code I'm talking about:
def launch():
print('''
**************************************************************************
* *
* *
* *
* *
* What script would you like to execute? *
* *
* *
* 1. Create an opportunity *
* 2. Show sales dashboard *
* 3. Show pipeline dashboard *
* *
* * Type "quit" to shut down *
* *
* *
* *
* *
* *
**************************************************************************
''')
answer = input("Enter your choice now.\n\n")
if answer == "1":
print('Launching "Show sales dashboard ".')
time.sleep(1)
create_opp_move()
elif answer == "2":
print('Launching "Create an opportunity".')
time.sleep(1)
show_sales()
elif answer == "3":
print('Launching "Show pipeline dashboard".')
time.sleep(1)
show_pipeline()
elif answer == "quit":
print("You have chosen to quit this program.")
time.sleep(2)
print("Program shutting down in...")
time.sleep(1)
print("3")
time.sleep(1)
print("2")
time.sleep(1)
print("1")
time.sleep(1)
raise SystemExit
else:
print("Answer is invalid. Please enter a valid statement.")
time.sleep(2)
launch()
Clear the screen using
print('\033c')
Then rebuild the screen.
I'm working on a Symfony2.3 project and I need an input number that lets me save the value with decimals and samples the arrows. With the following code I can show the decimals but then only the whole part is saved.
Entity
/**
*
* #ORM\Column(name="horas", type="decimal", scale=1)
* #Assert\NotBlank()
*/
private $hours;
FormType
->add('hours','integer', array('required' => true,'attr' => array('min' => 15,'max' => 40,'step' => 0.5)))
I appreciate your help.
To store a floating point value in a decimal field, you must first decide how many digits you need before the point, and how many after. For example, your field could look like this:
/**
* #ORM\Column(type="decimal", precision=3, scale=1)
* #Assert\Range(min=15, max=40)
*/
private $hours;
In a decimal field, the precision is always the total number of digits, while scale denotes the length of the fraction part. In the example above, the decimal field could store values between 0 and 99, while one digit after the point would be stored.
Note that Doctrine will represent the field as string, so if you retrieve the entity, the value of the field would be "20.5" (i.e. a string). You must manually convert the value to a float again. This can be done in the getter for the field:
public function getHours()
{
return (float) $this->hours;
}