I’m trying to make a WordPress plugin. Well, actually it’s done and fully working, except one thing. I have added a shortcode for the plugin. But no matter where in the content I call this shortcode, the contents it gets are always on top of the post, instead of where I placed the tag. The code th…
Tag: php
Add attribute to wp_get_attachment_image
I’m trying to add an attribute to the result of wp_get_attachment_image. I want to use jquery lazyload to handle loading of my post thumbnails and to do that I need to add a data-original= attribute to the <img> tag wp_get_attachment_image is creating. I’ve tried: But it doesn’t add th…
Escape raw SQL queries in Laravel 4
How does one go about escaping parameters passed to a raw query in Laravel 4? I expected something like DB::escape() (which rings a bell from Laravel 3) and also attempted DB::quote() (which I thought could be available through the PDO object) We can’t use the select method with placeholders as the abov…
Add PHP variable inside echo statement as href link address?
I’m trying to use a PHP variable to add a href value for a link in an echo statement. Here’s a simplified version of the code I want to use. I know that I can’t just add the variable into the echo statement, but I can’t seem to find an example anywhere that works. Answer Try like HTML …
Fatal error: Call to a member function isAttributeRequired()
I am having the following form The above form throws an error as I am new you yii framework so i am unable to guess where the error is. can anyone help Edit 1 Edit-2 If remove <?php echo $form->labelEx($model,’oldPassword’); ?> am getting error as Answer The $model variable does not conta…
Bake every table in CakePHP?
The database I’m working on has more than 100 tables, so I’m not going to sit here baking a model and controller for each one individually. I would like to bake all of the tables at the same time with something like the .xml files in Hibernate that tells it the limitations on fields so that I don&…
Dynamically output the page title with php
I am trying to output the page title dynamically. I am using induces and this script is withing the header.php the goal is to output the header dynamically using a case/switch statement. here is my code: I am getting a error telling me my variable $title is not defined? What i am doing wrong? Answer In your f…
Nested PHP ternary operator precedence
Yes, I know this is very bad code, but I’d still like to understand it: If $a is 11, then the result of the 1st line is “option 2”, but in the 2nd line, the result is “option 1” – what effect is the pair of brackets having? Answer The first line is parsed like so: Which is …
Generating cryptographically secure tokens
In order to generate a 32 character token for access to our API we currently use: I have read that this method is not cryptographically secure as it’s based on the system clock, and that openssl_random_pseudo_bytes would be a better solution as it would be harder to predict. If this is the case, what wo…
website showing 403-forbidden, .htaccess file has changed because of back up
I have back up files from public_html using filezilla, but after doing it my website shows 403-forbidden. In .htaccess file ‘order deny,allow’ at the top of the page and ‘deny from all’ at the end. I …