5 WordPress interview questions

1. Using the line numbers please describe what problems are preventing the following PHP/WordPress code from working properly as well as changes you would make to optimize this code to make it more efficient, if any.

class User {
   public function __get($username) {
         return 'valid';

      return 'invalid';

$e = new User();
   $x = 0;

for($i = 0; $i < 10; $i++) {
   echo '<ul id="'.$i."">';
   for($j = 0; $j < 10; $j++) {
      if($x == 0)

   echo '<li id=".'$j'.">Menu Item'.$j.'</li>';

   if($x =! 0){
      echo '</ul>';

/*Some more menu stuff here...*/
$options = get_option( 'theme-options' );
$colors = array('coral','toffee','sunshine','wildflower','wine');
$i = 0;
echo "<select name='theme-options[color]'>"
while($i < 5); {
echo '<option value="$colors[$i]"'. ((esc_attr( $options['color']== $color[$i])? 'selected="selected"': '' ).'>$colors[$i]</option>';
echo '</select>';

2. Using JavaScript and jQuery please provide code that will remove placeholders in the template on page load to produce result shown below.


<div class="class-replace">
      <a href="http://[SITE].com">[NAME]</a> © [START]-[CURRENT]. All rights reserved

Expected result:

<div class="copyright">
      <a href="http://foobar.com">FooBar</a> © 2011-2017. All rights reserved

3. What does the following function remove from a WordPress users admin area?

function remove_stuff ( $actions )
   if( !is_super_admin() && !current_user_can( 'edit_theme_options' ) ) {
      unset($actions['inline hide-if-no-js']);
      return $actions;
   } else {
      return $actions;
add_filter( 'page_row_actions', 'remove_stuff' );
add_filter( 'post_row_actions', 'remove_stuff' );

4. Some users find it difficult to insert media from a URL via the media uploader. Since 98% of our users don’t use that tab we would like to remove it. Please provide an example of how you would remove that tab for all users.

5. Users who aren’t super admins or cannot edit theme options are not permitted to create new pages. Even with that capability removed, WordPress still shows the “Add New” button. Please provide an example of how you would remove this button.

You May Also Like


Leave a Reply


This site uses Akismet to reduce spam. Learn how your comment data is processed.