Showing posts with label Wordpress. Show all posts
Showing posts with label Wordpress. Show all posts

Friday, 5 August 2016

What html tags are allowed by wordpress.com?

What html tags are allowed by wordpress.com?

Question: What html tags are allowed by wordpress.com?
Following HTML Tags are allowed in wordpress.com
.
 
address,
a, 
abbr, 
acronym, 
area, 
article, 
aside, 
b, 
big, 
blockquote, 
br, 
caption, 
cite, 
class, 
code, 
col, 
del, 
details, 
dd, 
div, 
dl, 
dt, 
em, 
figure, 
figcaption, 
footer, 
font, 
h1, h2, h3, h4, h5, h6, header, hgroup, hr, i, img, ins, kbd, li, map, ol, p, pre, q, s, section, small, span, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var





Question: Can we add javascript in wordpress.com?
No, You can add.
script Tags are not allowed.



Question: How to embed youtube video?
Just add following code in post.
[youtube=http://www.youtube.com/watch?v=w0wflz6Iwqs]



Question: Give list of URL which videos is allowed by wordpress.com?
 
YouTube
Vimeo
DailyMotion
blip.tv
Flickr (both videos and images)
Viddler
Hulu
Qik
Revision3
Scribd
Photobucket
PollDaddy
Google Video
WordPress.tv (only VideoPress-type videos for the time being)
SmugMug (WordPress 3.0+)
FunnyOrDie.com (WordPress 3.0+)



Wednesday, 13 April 2016

How to create wordpress Shortcode?

How to create wordpress Shortcode?

Question: What is Shortcode in Wordpress?
A shortcode is code that lets you do nifty things with very little effort.


Question: What is use Shortcode in Wordpress?
Shortcodes can be embed in post Or page which can do lot of things like Image Gallery, Video listing etc.


Question: Give a simple Shortcode example?
[gallery]

It would add photo gallery of images attached to that post or page.


Question: What is Shortcode API in Wordpress?
Shortcode API is set of functions for creating shortcodes in Page and Post.


The Shortcode API also support attributes like below:
[gallery id="123" size="large"]



Question: What is name of function which is used to register a shortcode handler?
add_shortcode

It has two parameter.
first is shortcode name and second callback function. For Example:
add_shortcode( 'shortcode', 'shortcode_handler' );



Question: How many parameter can be passed in callback function?
  1. $atts - an associative array of attributes.
  2. $content - the enclosed content
  3. $tag - the shortcode tag, useful for shared callback functions



Question: How to create shortcode in wordpress? Give working example? Create Shortcode
function testdata_function() {
  return 'This is testing data. This is testing data. This is testing data. This is testing data. This is testing data. This is testing data.';
}
add_shortcode('testdata', 'testdata_function');

Use Shortcode
[testdata]



Question: How to create shortcode with attributes in wordpress? Give working example?
Create Shortcode
function testdata_function($atts) {
    extract(shortcode_atts(array(
      'header' => 'This is default heading',
      'footer' => 'This is default footer',
   ), $atts));

  return '<b>'.$header.'</b>
This is testing data. This is testing data. This is testing data. This is testing data.
<b>'.$footer.'</b>';
}
add_shortcode('testdata', 'testdata_function');

Use Shortcode
[testdata header="Custom Heading" footer="Custom footer"]



Question: How to create shortcode with in wordpress? Give working example?
Create Shortcode
function testdata_function($attr, $content) {
  return $content.' This is testing data. This is testing data. This is testing data. This is testing data. This is testing data. This is testing data.';
}
add_shortcode('testdata', 'testdata_function');


Use Shortcode
[testdata]This is content[/testdata]



Question: What to do if Ampersand (i.e &) converted to &#038;?
Use html_entity_decode function (PHP inbuilt function).


Question: How to use meta tags in shortcode?
If you want to add meta tags in head tag. then use below function.
add_action('wp_head', 'add_meta_tags');
function add_meta_tags() {
        echo '';
    }



Saturday, 9 January 2016

XMLRPC Wordpress Attack

How to protect your wordpress website from xmlrpc attack

Queston: What is XMLRPC?
XML-RPC is one of the protocols that use XML for messages between two server. It is used to "Remote Procedure Calls" using XML.


Queston: Question: What is JSON-RPC?
JSON-RPC is one of the protocols that use JSON for messages between two server.
It is used to "Remote Procedure Calls" using JSON.


Queston: What is xmlrpc in wordpress?
WordPress uses an XML-RPC interface.
XML-RPC protocol is used to post entries.


Question: How to protect your website from xmlrpc attack?
Add following code in bottom of .htaccess file in root folder.
<Files 'xmlrpc.php'>
Order Allow,Deny
deny from all
</files>



Question: How to stop abusing XML-RPC file?
Open functions.php file in your add theme and following code.
add_filter( 'xmlrpc_methods', function( $methods ) {
         unset( $methods['pingback.ping'] );
            return $methods;
      } ); 



Sunday, 31 May 2015

Wordpress insert record into table and get last insert Id

Wordpress insert record into table and get last insert Id

In Wordpress, Record insertion into table is quite simple.
1. Create an Object of $wpdb;
2. Set the data in an Array.
3. Set the table name.
4. Use insert function  to insert record.
5. In insert function, first argument is table name and Second argument is array.


See Example Below:
global $wpdb;
$tableName = $wpdb->prefix . "users";
$saveFieldArray=array( 
'user_login' => 'mylogin',
'user_pass'=>'pass',
'user_nicename' => 'Poonam', 
'user_email' => 'email@no-spam.com',
'user_registered' => date('Y-m-d H:i:s',time()),
'user_status' => '1',
'display_name' => 'Arun Kumar');

//Insert Into Database
$wpdb->insert( $tableName, $saveFieldArray);

//get the last inert Id
$lastInsertId = $wpdb->insert_id;