Upwork WordPress Test Answer-2016

1. Which of the following functions can be used to create a WordPress page?

Answers:

a.wp_insert_post()

b. wp_insert_page()

c. wp_create_post()

d. wp_create_page()

 

2. Which of the following will correctly load localized (translated) text for a WordPress plugin?

Answers:

a.function custom_theme_setup() { $lang_dir = get_template_directory() . ‘/lang’); load_theme_textdomain(‘tutsplus’, $lang_dir); } add_action(‘after_setup_theme’, ‘custom_theme_setup’);

b. function custom_theme_setup() { $lang_dir = get_template_directory() . ‘/lang’); add_action(‘after_setup_theme’, ‘custom_theme_setup’); }

c. function custom_theme_setup() { $lang_dir = get_template_directory() . ‘/lang’); add_action(‘after_setup_theme’, ‘custom_theme_setup’); } load_theme_textdomain(‘tutsplus’, $lang_dir);

d. function load_theme_textdomain(‘tutsplus’, $lang_dir); { $lang_dir = get_template_directory() . ‘/lang’); custom_theme_setup(); } add_action(‘after_setup_theme’, ‘custom_theme_setup’);

 

3. Are categories and tags available for pages? 

<b>Note:</b> Categories must have distinct slugs. Even if two categories have different parents and would therefore have different permalinks, you can’t assign them the same slug.

Answers:

a. Yes

b. No

 

4. Which of the following will hash a string/password to its md5 equivalent?

Answers:

a. md5()

b. wp_generate_password()

c. wp_generate_md5()

d. password_md5()

 

5. Can the contents of the wp-content folder be moved or renamed without changing any settings?

Answers:

a.Yes

b.No

 

6. How many built-in user roles does wordpress have?

Answers:

a. 3

b. 4

c. 5

d. 6

 

7. Which of the following is the correct way to retrieve a featured image from a post?

Answer:

a. <?php echo get_post_thumb($page->ID, ‘thumbnail’); ?>

b. <?php echo get_featured_image($page->ID, ‘thumbnail’); ?>

c.<?php echo get_the_post_thumbnail($page->ID, ‘thumbnail’); ?>

d.<?php echo get_post_thumbnail($page->ID, ‘thumbnail’); ?

 

8. Which of the following is the correct way to print the slug property of $firstTag Object in this code snippet?

 $tags = wp_get_post_tags($post -> ID);
 $firstTag = $tags[0];

Answer:

a. $firstTag[‘slug’];

b.$firstTag -> slug;

c. $firstTag.slug;

d. $firstTag[0][‘slug’];

 

9. Which of the following is an example of a WordPress plugin that provides multilingual capabilities?

Answers:

a. WP Super Cache

b. qTranslate

c.BuddyPress

d. Hotfix

 

10.How can a post ID be retrieved from the permalink?

Answer:

a. Its not possible to retrieve post ID due to its structure.

b. It can be retrieved by using a regular expression.

c. wp_get_post_id($permalink);

d. url_to_postid($permalink);

 

11. Which of the following functions can be used to create a WordPress page?

Answers:

a. wp_insert_post()

b. wp_insert_page()

c. wp_create_post()

d. wp_create_page()

 

12. User Level 7 converts to _________?

Answers:

a. Contributor

b. Author

c. Editor

d. Subscribe

e. Administration

 

13. On which of the following databases can WordPress be installed by default?

Answers:

a. MySQL

b. Oracle Database

c. Microsoft SQL Server

d. PostgreSQL


14. Meta tags can be added to WordPress pages by ________________.

Answers:

a. using plug-ins

b. adding them to the header.php file

c. updating the database

d. a and b

e. b and c

15. Which of the following functions are used when adding CSS and jQuery codes on a WordPress plugin?

Answers:

a. wp_register_style

b. wp_enqueue_style

c. wp_enqueue_script

d.None of these.

 

16. Can the contents of the wp-content folder be moved or renamed without changing any settings?

Answers:

a. Yes

b. No

 

17. User level 7 converts to

Answer:

a. Editor

b. Administrator

c. Author

d. Subscriber

 

18. How would you integrate WordPress Tiny MCE editor with a plugin?

Answer:

a. wp_enqueue_script(tiny_mce’)

b. wp_editor( $content, $id );

c. add_action(init’,’tiny_mce’)

d. Cannot integrate Tiny MCE with custom plug ins

 

19. Which of the following code snippets best protects a system from SQL injections?

Answers:

a. sql_real_escape_strong()

b. mysql_real_escape()

c. mysql_real_escape_string()

d. mysql_not_real_delete_string()

 

20. Which conditional tag check if the dashboard or the administration panel is attempting to be displayed by  returning “true”(if the URL being accessed is in the admin section) or “false”(for a font-end page)

Answers:

a. my_admin()

b. view_admin()

c. is_admin()

d. root_admin()

 

21. Which of the following WordPress Multisite functions allows for getting content from one blog and display it on another?

Answers:

a. switch_blog()

b. switch_to_blog()

c. restore_current_blog()

d. restore_to_current_blog()

 

22. How can the class name of a sub-menu be changed in the wp_nav_menu?

Answer:

a. By manually adding the class name in Appearance–>Menus

b. WordPress does not support the ability to change the classname of a sub-menu in the wp_nav_menu.

c. By adding the following code in functions.php:

                    class UL_Class_Walker extends Walker_Nav_Menu{

                             function start_lv1(&$output, $depth) {

                             $indent = str_repeat(“\t”, $depth);

                            $output .= “\n$indent<ul class=\”level-“.$depth.”\”>\n”;

                        }

                    }
d. By adding the following code in header.php:

class UL_Class_Walker extends Walker_Nav_Menu{

function start_lv1(&$output, $depth) {

$indent = str_repeat(“\t”, $depth);

$output .= “\n$indent<ul class=\”level-“.$depth.”\”>\n”;

}

}

 

23. A possible way to allow the display of several authors’ names on one post is to ______

Answers:

a. update the database

b. change the admin settings

c. change the config files

d. use a plugin

 

24. User level 3 converts to

Answers:

a. Editor

b. Contributor

c. Subscriber

d. Author

 

25. Which is the following is Online Code Coloring Service?

Answer:

a. Prettify

b. SyntaxHighligheriext

c. Edit pad

d. Collabedit

 

26. One possible way to collect realtime statistics about traffic on a WordPress site is:

Answers:

a. using a built-in tool

b. using a plugin

c. using a widget

d. Traffic statistics cannot be collected on a WordPress site.

 

27. Which of the following methods can be used to make permalinks SEO friendly?

Answers :

a. Updating the database

b. Changing the source code

c. Configuring the feature in the config file

d. Configuring the feature in the admin settings

 

28. User level 1 converts to

Answers:

a. Contributor

b. Subscriber

c. Editor

d. Administrator

 

29.What is the best way to get last inserted row ID from WordPress Database?

Answer:

a.Use the following code snippet:

$lastid -> wpdb=$lastid ->get_row;

b. The call to mysql_insert_id() inside a transaction should be added:

mysql_query(‘BEGIN’);

// Whatever code that does the insert here.

$id = mysql_insert_id();

mysql_query(‘COMMIT’);

// Stuff with Sid.

c. The following code snippet should be added

$last = $wpdb->get_row(“SHOW TABLE STATUS LIKE ‘table name'”);

$lastid = $last->Auto_increment;

d. right after the $wpdb->insert() insert, the following code should be added:

          $lastid = $wpdb->insert_id;

 

30.Which is the following is the correct way to add a simple wordpress gallery in an external php file?

Answer:

a. add_filter(‘do_shortcode

‘ ,11);

b. echo do_shortcode(‘

‘);

c. add_filter(‘widget_text’, ‘do_shortcode

‘);

d. This can’t be done.

 

31.User level 0 converts to

Answer:

a. Subscriber

b. Author

c. Editor

d. None of the above

 

32. What is the first action you need to take for enabling the WordPress multisite (MS) feature?

Answers:

a. Enable the WordPress multisite feature on admin panel

b. Enable the Network feature

c. Add this code to wp-config.php file: define( ‘WP_ALLOW_MULTISITE’, true );

 


33 .What is the name of theme file for a page id ‘3’?

Answers:

a. page-id-3.php

b. page-3.php

c. 3.php

 

34. Which of the following actions cannot be hooked in with add_submenu_page() function?

Answers:

a. admin_submenu

b. admin_menu

c. user_admin_menu

d. network_admin_menu

 

35. Which of the following is the correct way to filter the content for a few posts?

Answers:

a. By using apply_filters(filter,postId)

b. This is not possible in wordpress

c. Can create filter for posts in a specific wordpress category

d. Passing arguments into the_content()

 

36. Which of the following code snippets will create plugins back-end page without showing it as menu item?

Answers:

a. add_submenu_page with parent slug = null

b. add_menu_page with parent slug = null

c. add_submenu_page without parent slug = null

d. add_menu_page without parent slug = null

 

37. ____________ can manage their own profiles, but can do virtually nothing else in the administration area.

Answers:

a. Contributor

b. Author

c. Editor

d. Subscriber

e. Administrator

 

38. Are categories and tags available for pages? 

<b>Note:</b> Categories must have distinct slugs. Even if two categories have different parents and would therefore have different permalinks, you can’t assign them the same slug.

Answers:

a. Yes

b. No

 

39. Conditional tags can be used to _______________________.

Answers:

a. get all comments from one post

b. get all posts from one category

c. change the content to be displayed

d. None of the above: conditional tags are not available in WordPress.

 

40. Which of the following commands can change the ownership of WordPress directory to www-data (for Apache)?

Answers:

a. sudo chown -Rf www-data *

b. chown -Rf www-data *

c. sudo crown -Df www-data *

d. Alldo chown -Rf www-data *

 

41. How can a custom content filter be added?

Answers:

a. By using add_action(‘the_content’,’my_custom_filter’)

b. By using add_filter(‘the_content’,’my_custom_filter’)

c. By using wp_filter(‘the_content’,’my_custom_filter’)

d. By using add_action(‘content’,’my_custom_filter’)

 

42. _____________ can publish, edit, and delete their own posts. They cannot write pages. They can upload some kinds of media files, and they are allowed to use only the limited set of HTML tags.

Answers:

a. Contributo

b. Author

c. Edito

d. Subscribe

e. Administrato

 

43. How can a post ID be retrieved from the permalink?

Answers:

a. Its not possible to retrieve the post ID from a permalink due to its structure.

b. It can be retrieved by using a Regular Expression.

c. wp_get_post_id($permalink)

d. url_to_postid($permalink)

 

45. Which of the following is the correct code to get an array of every image uploaded to a particular post?

Answers:

a. $images =& get_children( ‘post_type=attachment&post_mime_type=image&post_parent=10’ );

b. $images = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );

c. $images = get_post(7, ARRAY_A);

d. It cannot be done

 

46.Which of the following is the correct way to get WordPress Post ID from the Post title?

Answers:

a. $page = get_page_title( ‘About’ ); wp_pages( ‘exclude=’ . $page->ID );

b. $page = get_page_by_title( ‘Home’ ); $page_id = $page->ID;

c. $page = get_page_by_title( ‘About’ ); wp_pages( ‘exclude=’ . $page->ID );

d. None of the above

 

47. Which of the following codes will return the current plugin directory in WordPress?

Answers:

a. <?php plugin_basename($file); ?>

b. <?php plugin_basename(‘url’); ?>

c. <?php bloginfo_plugin(‘url’); ?>

d. <?php content_plugin_url( $path ); ?>

 

48. What is the first action you need to take for enabling WordPress MU feature?

Answers:

a. Enable WordPress MU feature on admin panel

b. Enable Network feature

c. Add this code to wp-config.php file: define( ‘WP_ALLOW_MULTISITE’, true );

 

49. You can limit the number of revisions WordPress stores by _____

 

<b>Note:</b> Categories must have distinct slugs. Even if two categories have different parents and would therefore have different permalinks, you can’t assign them the same slug.

Answers:

a. adding the following line to your wp-config.php file: define(‘WP_POST_REVISIONS’, 3);

b. using a plugin

c. changing a setting on admin panel

 

50. ____________ can publish, edit, and delete their own posts.They cannot write pages.They can upload some kinds of media files, and they are allowed to use only limited set of HTML tags.

Answers:

a. Contributor

b. Author

c. Editor

d. Subscriber

e. Administrator

 

50. Which of the following is the correct way to retrieve a featured image from a post?

Answers:

a. <?php echo get_post_thumb($page->ID, ‘thumbnail’); ?>

b. <?php echo get_featured_image($page->ID, ‘thumbnail’); ?>

c. <?php echo get_the_post_thumbnail($page->ID, ‘thumbnail’); ?>

d. <?php echo get_post_thumbnail($page->ID, ‘thumbnail’); ?>

 

51. Which of the following is the correct way to redirect the default login and registration page URL to a custom login and registration page URL?

Answers:

a.  add_action(‘init’,’possibly_redirect’);
function possibly_redirect()
{
global $pagenow;
if( ‘wp-login.php’ == $pagenow )
{
return(‘Your custom url’);
exit();
}
}

b.  add_action(‘init’,’possibly_redirect’);
function possibly_redirect()
{
global $pagenow;
if( ‘wp-login.php’ == $pagenow )
{
wp_redirect(‘Your custom url’);
exit();
}
}

c. add_action(‘init’,’possibly_redirect’);
function possibly_redirect()
{
global $pagenow;
if( ‘wp-login.php’ == $pagenow )
{
redirect(‘Your custom url’);
exit();
}
}

d. add_action(‘init’,’possibly_redirect’);
function possibly_redirect()
{
global $pagenow;
if( ‘wp-login.php’ == $pagenow )
{
wp_return(‘Your custom url’);
exit();
}
}

 

53. What is the first action you need to take for enabling the WordPress multisite (MS) feature?

Answers:

a. Enable the WordPress multisite feature on admin panel

b. Enable the Network feature

c. Add this code to wp-config.php file: define( ‘WP_ALLOW_MULTISITE’, true );

 

54. What is the BEST way to get last inserted row ID from WordPress database ?

Answers:

a. Use the following code snippet $lastid->$wpdb=$last->get_row;

b. The call to mysql_insert_id() inside a transaction should be added:
mysql_query(‘BEGIN’); // Whatever code that does the insert here. $id = mysql_insert_id(); mysql_query(‘COMMIT’); // Stuff with $id.

c. The following code snippet should be added
$last = $wpdb->get_row(“SHOW TABLE STATUS LIKE ‘table_name'”);
$lastid = $last->Auto_increment;

d. Straight after the $wpdb->insert()
insert, the following code should be added: $lastid = $wpdb->insert_id;

 


55. Which of the following is the correct sequence of steps to adapt a WordPress plugin to a multisite?

Answers:

a. 1.Use $wpdb to iterate through all blogs
2. Hook according to the $blog_id
3. Install the plugin as Network only
4. Uninstall depends the specific plugin

 

b. 1.Use $wp_posts to iterate through all blogs
2. Hook according to the $function
3. IInstall the plugin as Network only
4. Uninstall depends the specific plugin

c. 1.Use $wp_posts to iterate through all blogs
2. Hook according to the $function
3. Install other activations except Network
4. Uninstall is the same for all the plugins

d. 1.Use $wp_posts to iterate through all blogs
2. Hook according to the $function
3. Install the plugin as Network only
4. Uninstall is same for all the plugins

 

56. Which of the following is the correct way to redirect the default login and registration page URL to a custom login and registration page URL?

Answers:

a. add_action(‘init’,’possibly_redirect’); function possibly_redirect(){ global $pagenow; if( ‘wp-login.php’ == $pagenow ) { return(‘Your custom url’); exit(); } }

b. add_action(‘init’,’possibly_redirect’); function possibly_redirect(){ global $pagenow; if( ‘wp-login.php’ == $pagenow ) { wp_redirect(‘Your custom url’); exit(); } }

c. add_action(‘init’,’possibly_redirect’); function possibly_redirect(){ global $pagenow; if( ‘wp-login.php’ == $pagenow ) { redirect(‘Your custom url’); exit(); } }

d. add_action(‘init’,’possibly_redirect’); function possibly_redirect(){ global $pagenow; if( ‘wp-login.php’ == $pagenow ) { wp_return(‘Your custom url’); exit(); } }


57. Which of the following will correctly add custom mod rewrite rules to .htaccess from a WordPress plugin?

Answers:

a. $custom_mod_rewrite = new custom_mod_rewrite; register_activation_hook( __FILE__, array($custom_mod_rewrite, ‘flush_rewrite_rules’)); register_deactivation_hook( __FILE__, array($custom_mod_rewrite, ‘flush_rewrite_rules’)); add_action(‘generate_rewrite_rules’, array($custom_mod_rewrite, “generate_rewrite_rules”)); class custom_mod_rewrite { function __construct() { $this->wp_rewrite = & $POST[“wp_rewrite”]; }}

b. $custom_mod_rewrite = new custom_mod_rewrite; register_activation_hook( __FILE__, array($custom_mod_rewrite, ‘flush_rewrite_rules’)); register_deactivation_hook( __FILE__, array($custom_mod_rewrite, ‘flush_rewrite_rules’)); add_action(‘generate_rewrite_rules’, array($custom_mod_rewrite, “generate_rewrite_rules”)); class custom_mod_rewrite { function __construct() { $this->wp_rewrite = & $GLOBALS[“wp_rewrite”]; } }

c. $custom_mod_rewrite = new custom_mod_rewrite; register_activation_hook( __FILE__, array($custom_mod_rewrite, ‘flush_rewrite_rules’)); register_deactivation_hook( __FILE__, array($custom_mod_rewrite, ‘flush_rewrite_rules’)); add_action(‘generate_rewrite_rules’, array($custom_mod_rewrite, “generate_rewrite_rules”)); class custom_mod_rewrite { function __construct() { $this->wp_rewrite = & $GLOBALS[“wp_rewrite”]; } function mod_rewrite_rules($rules) { return preg_replace(‘#^(RewriteRule \^.*/)\?\$plugin_name .*(http://.*) \[QSA,L\]#mi’, ‘$1 $2 [R=301,L]’, $rules); } }

d. $custom_mod_rewrite = new custom_mod_rewrite; register_activation_hook( __FILE__, array($custom_mod_rewrite, ‘flush_rewrite_rules’)); register_deactivation_hook( __FILE__, array($custom_mod_rewrite, ‘flush_rewrite_rules’)); add_action(‘generate_rewrite_rules’, array($custom_mod_rewrite, “generate_rewrite_rules”)); class custom_mod_rewrite { function __construct() { $this->wp_rewrite = & $SESSION[“wp_rewrite”]; } }

 

 

 

 

 

 

 

Comments

comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.